llvm/llvm/unittests/IR/ConstantRangeTest.cpp

//===- ConstantRangeTest.cpp - ConstantRange tests ------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "llvm/IR/ConstantRange.h"
#include "llvm/ADT/BitVector.h"
#include "llvm/ADT/Sequence.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Operator.h"
#include "llvm/Support/KnownBits.h"
#include "gtest/gtest.h"

usingnamespacellvm;

namespace {

class ConstantRangeTest : public ::testing::Test {};

template<typename Fn>
static void EnumerateAPInts(unsigned Bits, Fn TestFn) {}

template<typename Fn>
static void EnumerateConstantRanges(unsigned Bits, Fn TestFn) {}

template <typename Fn>
static void EnumerateInterestingConstantRanges(Fn TestFn) {}

template <typename Fn>
static void EnumerateTwoInterestingConstantRanges(Fn TestFn) {}

template <typename Fn>
static void ForeachNumInConstantRange(const ConstantRange &CR, Fn TestFn) {}

PreferFn;

bool PreferSmallest(const ConstantRange &CR1, const ConstantRange &CR2) {}

bool PreferSmallestUnsigned(const ConstantRange &CR1,
                            const ConstantRange &CR2) {}

bool PreferSmallestSigned(const ConstantRange &CR1, const ConstantRange &CR2) {}

bool PreferSmallestNonFullUnsigned(const ConstantRange &CR1,
                                   const ConstantRange &CR2) {}

bool PreferSmallestNonFullSigned(const ConstantRange &CR1,
                                 const ConstantRange &CR2) {}

testing::AssertionResult rangeContains(const ConstantRange &CR, const APInt &N,
                                       ArrayRef<ConstantRange> Inputs) {}

// Check whether constant range CR is an optimal approximation of the set
// Elems under the given PreferenceFn. The preference function should return
// true if the first range argument is strictly preferred to the second one.
static void TestRange(const ConstantRange &CR, const SmallBitVector &Elems,
                      PreferFn PreferenceFn, ArrayRef<ConstantRange> Inputs,
                      bool CheckOptimality = true) {}

UnaryRangeFn;
UnaryIntFn;

static void TestUnaryOpExhaustive(UnaryRangeFn RangeFn, UnaryIntFn IntFn,
                                  PreferFn PreferenceFn = PreferSmallest) {}

BinaryRangeFn;
BinaryIntFn;
BinaryCheckFn;

static bool CheckAll(const ConstantRange &, const ConstantRange &) {}

static bool CheckCorrectnessOnly(const ConstantRange &, const ConstantRange &) {}

static bool CheckSingleElementsOnly(const ConstantRange &CR1,
                                    const ConstantRange &CR2) {}

static bool CheckNonWrappedOnly(const ConstantRange &CR1,
                                const ConstantRange &CR2) {}

static bool CheckNonSignWrappedOnly(const ConstantRange &CR1,
                                    const ConstantRange &CR2) {}

static bool
CheckNoSignedWrappedLHSAndNoWrappedRHSOnly(const ConstantRange &CR1,
                                           const ConstantRange &CR2) {}

static bool CheckNonWrappedOrSignWrappedOnly(const ConstantRange &CR1,
                                             const ConstantRange &CR2) {}

// CheckFn determines whether optimality is checked for a given range pair.
// Correctness is always checked.
static void TestBinaryOpExhaustive(BinaryRangeFn RangeFn, BinaryIntFn IntFn,
                                   PreferFn PreferenceFn = PreferSmallest,
                                   BinaryCheckFn CheckFn = CheckAll) {}

ConstantRange ConstantRangeTest::Full(16, true);
ConstantRange ConstantRangeTest::Empty(16, false);
ConstantRange ConstantRangeTest::One(APInt(16, 0xa));
ConstantRange ConstantRangeTest::Some(APInt(16, 0xa), APInt(16, 0xaaa));
ConstantRange ConstantRangeTest::Wrap(APInt(16, 0xaaa), APInt(16, 0xa));

TEST_F(ConstantRangeTest, Basics) {}

TEST_F(ConstantRangeTest, Equality) {}

TEST_F(ConstantRangeTest, SingleElement) {}

TEST_F(ConstantRangeTest, GetMinsAndMaxes) {}

TEST_F(ConstantRangeTest, SignWrapped) {}

TEST_F(ConstantRangeTest, UpperWrapped) {}

TEST_F(ConstantRangeTest, Trunc) {}

TEST_F(ConstantRangeTest, ZExt) {}

TEST_F(ConstantRangeTest, SExt) {}

TEST_F(ConstantRangeTest, IntersectWith) {}

template <typename Fn1, typename Fn2, typename Fn3>
void testBinarySetOperationExhaustive(Fn1 OpFn, Fn2 ExactOpFn, Fn3 InResultFn) {}

TEST_F(ConstantRangeTest, IntersectWithExhaustive) {}

TEST_F(ConstantRangeTest, UnionWithExhaustive) {}

TEST_F(ConstantRangeTest, UnionWith) {}

TEST_F(ConstantRangeTest, SetDifference) {}

TEST_F(ConstantRangeTest, getActiveBits) {}
TEST_F(ConstantRangeTest, losslessUnsignedTruncationZeroext) {}

TEST_F(ConstantRangeTest, getMinSignedBits) {}
TEST_F(ConstantRangeTest, losslessSignedTruncationSignext) {}

TEST_F(ConstantRangeTest, SubtractAPInt) {}

TEST_F(ConstantRangeTest, Add) {}

TEST_F(ConstantRangeTest, AddWithNoWrap) {}

TEST_F(ConstantRangeTest, Sub) {}

TEST_F(ConstantRangeTest, SubWithNoWrap) {}

TEST_F(ConstantRangeTest, Multiply) {}

TEST_F(ConstantRangeTest, MultiplyWithNoWrap) {}

TEST_F(ConstantRangeTest, smul_fast) {}

TEST_F(ConstantRangeTest, UMax) {}

TEST_F(ConstantRangeTest, SMax) {}

TEST_F(ConstantRangeTest, UMin) {}

TEST_F(ConstantRangeTest, SMin) {}

TEST_F(ConstantRangeTest, UDiv) {}

TEST_F(ConstantRangeTest, SDiv) {}

TEST_F(ConstantRangeTest, URem) {}

TEST_F(ConstantRangeTest, SRem) {}

TEST_F(ConstantRangeTest, Shl) {}

TEST_F(ConstantRangeTest, ShlWithNoWrap) {}

TEST_F(ConstantRangeTest, Lshr) {}

TEST_F(ConstantRangeTest, Ashr) {}

TEST(ConstantRange, MakeAllowedICmpRegion) {}

TEST(ConstantRange, MakeSatisfyingICmpRegion) {}

void ICmpTestImpl(CmpInst::Predicate Pred) {}

TEST(ConstantRange, ICmp) {}

TEST(ConstantRange, MakeGuaranteedNoWrapRegion) {}

template<typename Fn>
void TestNoWrapRegionExhaustive(Instruction::BinaryOps BinOp,
                                unsigned NoWrapKind, Fn OverflowFn) {}

// Show that makeGuaranteedNoWrapRegion() is maximal, and for single-element
// ranges also exact.
TEST(ConstantRange, NoWrapRegionExhaustive) {}

TEST(ConstantRange, GetEquivalentICmp) {}

#define EXPECT_MAY_OVERFLOW(op)
#define EXPECT_ALWAYS_OVERFLOWS_LOW(op)
#define EXPECT_ALWAYS_OVERFLOWS_HIGH(op)
#define EXPECT_NEVER_OVERFLOWS(op)

TEST_F(ConstantRangeTest, UnsignedAddOverflow) {}

TEST_F(ConstantRangeTest, UnsignedSubOverflow) {}

TEST_F(ConstantRangeTest, SignedAddOverflow) {}

TEST_F(ConstantRangeTest, SignedSubOverflow) {}

template <typename Fn1, typename Fn2>
static void TestOverflowExhaustive(Fn1 OverflowFn, Fn2 MayOverflowFn) {}

TEST_F(ConstantRangeTest, UnsignedAddOverflowExhaustive) {}

TEST_F(ConstantRangeTest, UnsignedSubOverflowExhaustive) {}

TEST_F(ConstantRangeTest, UnsignedMulOverflowExhaustive) {}

TEST_F(ConstantRangeTest, SignedAddOverflowExhaustive) {}

TEST_F(ConstantRangeTest, SignedSubOverflowExhaustive) {}

TEST_F(ConstantRangeTest, FromKnownBits) {}

TEST_F(ConstantRangeTest, FromKnownBitsExhaustive) {}

TEST_F(ConstantRangeTest, ToKnownBits) {}

TEST_F(ConstantRangeTest, Negative) {}

TEST_F(ConstantRangeTest, UAddSat) {}

TEST_F(ConstantRangeTest, USubSat) {}

TEST_F(ConstantRangeTest, UMulSat) {}

TEST_F(ConstantRangeTest, UShlSat) {}

TEST_F(ConstantRangeTest, SAddSat) {}

TEST_F(ConstantRangeTest, SSubSat) {}

TEST_F(ConstantRangeTest, SMulSat) {}

TEST_F(ConstantRangeTest, SShlSat) {}

TEST_F(ConstantRangeTest, Abs) {}

TEST_F(ConstantRangeTest, Ctlz) {}

TEST_F(ConstantRangeTest, Cttz) {}

TEST_F(ConstantRangeTest, Ctpop) {}

TEST_F(ConstantRangeTest, castOps) {}

TEST_F(ConstantRangeTest, binaryAnd) {}

TEST_F(ConstantRangeTest, binaryOr) {}

TEST_F(ConstantRangeTest, binaryXor) {}

TEST_F(ConstantRangeTest, binaryNot) {}

template <typename T>
void testConstantRangeICmpPredEquivalence(ICmpInst::Predicate SrcPred, T Func) {}

TEST_F(ConstantRangeTest, areInsensitiveToSignednessOfICmpPredicate) {}

TEST_F(ConstantRangeTest, areInsensitiveToSignednessOfInvertedICmpPredicate) {}

TEST_F(ConstantRangeTest, getEquivalentPredWithFlippedSignedness) {}

TEST_F(ConstantRangeTest, isSizeLargerThan) {}

TEST_F(ConstantRangeTest, MakeMaskNotEqualRange) {}

TEST_F(ConstantRangeTest, MakeMaskNotEqualRangeExhaustive) {}

} // anonymous namespace