/// loop (inserting one if there is none). A canonical induction variable
/// starts at zero and steps by one on each iteration.
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty){
- assert((Ty->isIntegral() || Ty->isFloatingPoint()) &&
+ assert((Ty->isInteger() || Ty->isFloatingPoint()) &&
"Can only insert integer or floating point induction variables!");
SCEVHandle H = SCEVAddRecExpr::get(SCEVUnknown::getIntegerSCEV(0, Ty),
SCEVUnknown::getIntegerSCEV(1, Ty), L);
Value *expandInTy(SCEV *S, const Type *Ty) {
Value *V = expand(S);
if (Ty && V->getType() != Ty) {
- if (isa<PointerType>(Ty) && V->getType()->isIntegral())
+ if (isa<PointerType>(Ty) && V->getType()->isInteger())
return InsertCastOfTo(Instruction::IntToPtr, V, Ty);
- else if (Ty->isIntegral() && isa<PointerType>(V->getType()))
+ else if (Ty->isInteger() && isa<PointerType>(V->getType()))
return InsertCastOfTo(Instruction::PtrToInt, V, Ty);
else if (Ty->getPrimitiveSizeInBits() ==
V->getType()->getPrimitiveSizeInBits())
}
MachOSection *getConstSection(const Type *Ty) {
// FIXME: support cstring literals and pointer literal
- if (Ty->isPrimitiveType() || Ty->isIntegral()) {
+ if (Ty->isPrimitiveType() || Ty->isInteger()) {
unsigned Size = TM.getTargetData()->getTypeSize(Ty);
switch(Size) {
default: break; // Fall through to __TEXT,__const
/// getDescription - Return the string representation of the type...
const std::string &getDescription() const;
- /// isInteger - Equivalent to isSigned() || isUnsigned()
+ /// isInteger - True if this is an instance of IntegerType.
///
- bool isInteger() const { return ID == IntegerTyID && this != Int1Ty; }
-
- /// isIntegral - Returns true if this is an integral type, which is either
- /// Int1Ty or one of the Integer types.
- ///
- bool isIntegral() const { return ID == IntegerTyID; }
+ bool isInteger() const { return ID == IntegerTyID; }
/// isFloatingPoint - Return true if this is one of the two floating point
/// types
///
bool isSized() const {
// If it's a primitive, it is always sized.
- if (ID == IntegerTyID || (ID >= FloatTyID && ID <= DoubleTyID) ||
- ID == PointerTyID)
+ if (ID == IntegerTyID || isFloatingPoint() || ID == PointerTyID)
return true;
// If it is not something that can have a size (e.g. a function or label),
// it doesn't have a size.
///
unsigned getPrimitiveSizeInBits() const;
- /// getIntegralTypeMask - Return a bitmask with ones set for all of the bits
+ /// getIntegerTypeMask - Return a bitmask with ones set for all of the bits
/// that can be set by an unsigned version of this type. This is 0xFF for
/// sbyte/ubyte, 0xFFFF for shorts, etc.
- uint64_t getIntegralTypeMask() const {
- assert(isIntegral() && "This only works for integral types!");
+ uint64_t getIntegerTypeMask() const {
+ assert(isInteger() && "This only works for integer types!");
return ~uint64_t(0UL) >> (64-getPrimitiveSizeInBits());
}
using namespace llvm;
static ConstantInt *getMaxValue(const Type *Ty, bool isSigned = false) {
- if (Ty->isIntegral()) {
+ if (Ty->isInteger()) {
if (isSigned) {
// Calculate 011111111111111...
unsigned TypeBits = Ty->getPrimitiveSizeInBits();
// Static constructor to create the minimum constant for an integral type...
static ConstantInt *getMinValue(const Type *Ty, bool isSigned = false) {
- if (Ty->isIntegral()) {
+ if (Ty->isInteger()) {
if (isSigned) {
// Calculate 1111111111000000000000
unsigned TypeBits = Ty->getPrimitiveSizeInBits();
/// Initialize a full (the default) or empty set for the specified type.
///
ConstantRange::ConstantRange(const Type *Ty, bool Full) {
- assert(Ty->isIntegral() &&
+ assert(Ty->isInteger() &&
"Cannot make constant range of non-integral type!");
if (Full)
Lower = Upper = getMaxValue(Ty);
/// subtract - Subtract the specified constant from the endpoints of this
/// constant range.
ConstantRange ConstantRange::subtract(ConstantInt *CI) const {
- assert(CI->getType() == getType() && getType()->isIntegral() &&
+ assert(CI->getType() == getType() && getType()->isInteger() &&
"Cannot subtract from different type range or non-integer!");
// If the set is empty or full, don't modify the endpoints.
if (Lower == Upper) return *this;
/// known to have. This method is only valid on integer SCEV objects.
ConstantRange SCEV::getValueRange() const {
const Type *Ty = getType();
- assert(Ty->isIntegral() && "Can't get range for a non-integer SCEV!");
+ assert(Ty->isInteger() && "Can't get range for a non-integer SCEV!");
// Default to a full range if no better information is available.
return ConstantRange(getType());
}
SCEVTruncateExpr::SCEVTruncateExpr(const SCEVHandle &op, const Type *ty)
: SCEV(scTruncate), Op(op), Ty(ty) {
- assert(Op->getType()->isIntegral() && Ty->isIntegral() &&
+ assert(Op->getType()->isInteger() && Ty->isInteger() &&
"Cannot truncate non-integer value!");
assert(Op->getType()->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits()
&& "This is not a truncating conversion!");
SCEVZeroExtendExpr::SCEVZeroExtendExpr(const SCEVHandle &op, const Type *ty)
: SCEV(scZeroExtend), Op(op), Ty(ty) {
- assert(Op->getType()->isIntegral() && Ty->isIntegral() &&
+ assert(Op->getType()->isInteger() && Ty->isInteger() &&
"Cannot zero extend non-integer value!");
assert(Op->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()
&& "This is not an extending conversion!");
/// extended.
static SCEVHandle getTruncateOrZeroExtend(const SCEVHandle &V, const Type *Ty) {
const Type *SrcTy = V->getType();
- assert(SrcTy->isIntegral() && Ty->isIntegral() &&
+ assert(SrcTy->isInteger() && Ty->isInteger() &&
"Cannot truncate or zero extend with non-integer arguments!");
if (SrcTy->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
return V; // No conversion
if (SCEVTruncateExpr *T = dyn_cast<SCEVTruncateExpr>(S))
return GetConstantFactor(T->getOperand()) &
- T->getType()->getIntegralTypeMask();
+ T->getType()->getIntegerTypeMask();
if (SCEVZeroExtendExpr *E = dyn_cast<SCEVZeroExtendExpr>(S))
return GetConstantFactor(E->getOperand());
case Instruction::BitCast:
// BitCasts are no-op casts so we just eliminate the cast.
- if (I->getType()->isIntegral() &&
- I->getOperand(0)->getType()->isIntegral())
+ if (I->getType()->isInteger() &&
+ I->getOperand(0)->getType()->isInteger())
return getSCEV(I->getOperand(0));
break;
}
}
}
- } else if (AddRec->isQuadratic() && AddRec->getType()->isIntegral()) {
+ } else if (AddRec->isQuadratic() && AddRec->getType()->isInteger()) {
// If this is a quadratic (3-term) AddRec {L,+,M,+,N}, find the roots of
// the quadratic equation to solve it.
std::pair<SCEVHandle,SCEVHandle> Roots = SolveQuadraticEquation(AddRec);
}
if (Cond == ICmpInst::ICMP_SLT) {
- if (PreCondLHS->getType()->isIntegral()) {
+ if (PreCondLHS->getType()->isInteger()) {
if (RHS != getSCEV(PreCondRHS))
return UnknownValue; // Not a comparison against 'm'.
OS << "Classifying expressions for: " << F.getName() << "\n";
for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I)
- if (I->getType()->isIntegral()) {
+ if (I->getType()->isInteger()) {
OS << *I;
OS << " --> ";
SCEVHandle SV = getSCEV(&*I);
SV->print(OS);
OS << "\t\t";
- if ((*I).getType()->isIntegral()) {
+ if ((*I).getType()->isInteger()) {
ConstantRange Bounds = SV->getValueRange();
if (!Bounds.isFullSet())
OS << "Bounds: " << Bounds << " ";
const Type *Ty = S->getType();
const Loop *L = S->getLoop();
// We cannot yet do fp recurrences, e.g. the xform of {X,+,F} --> X+{0,+,F}
- assert(Ty->isIntegral() && "Cannot expand fp recurrences yet!");
+ assert(Ty->isInteger() && "Cannot expand fp recurrences yet!");
// {X,+,F} --> X + {0,+,F}
if (!isa<SCEVConstant>(S->getStart()) ||
const llvm::Type* ElemTy = yyvsp[-1].TypeVal->get();
if ((unsigned)yyvsp[-3].UInt64Val != yyvsp[-3].UInt64Val)
GEN_ERROR("Unsigned result not equal to signed result");
- if (!ElemTy->isFloatingPoint() && !ElemTy->isIntegral())
+ if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
GEN_ERROR("Element type of a PackedType must be primitive");
if (!isPowerOf2_32(yyvsp[-3].UInt64Val))
GEN_ERROR("Vector length should be a power of 2!");
{
if (yyvsp[-3].ConstVal->getType() != yyvsp[-1].ConstVal->getType())
GEN_ERROR("Logical operator types must match!");
- if (!yyvsp[-3].ConstVal->getType()->isIntegral()) {
+ if (!yyvsp[-3].ConstVal->getType()->isInteger()) {
if (!isa<PackedType>(yyvsp[-3].ConstVal->getType()) ||
- !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isIntegral())
+ !cast<PackedType>(yyvsp[-3].ConstVal->getType())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
yyval.ConstVal = ConstantExpr::get(yyvsp[-5].BinaryOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
{
if (yyvsp[-1].ConstVal->getType() != Type::Int8Ty)
GEN_ERROR("Shift count for shift constant must be i8 type!");
- if (!yyvsp[-3].ConstVal->getType()->isIntegral())
+ if (!yyvsp[-3].ConstVal->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
yyval.ConstVal = ConstantExpr::get(yyvsp[-5].OtherOpVal, yyvsp[-3].ConstVal, yyvsp[-1].ConstVal);
{
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
- if (!(*yyvsp[-3].TypeVal)->isIntegral() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
+ if (!(*yyvsp[-3].TypeVal)->isInteger() && !(*yyvsp[-3].TypeVal)->isFloatingPoint() &&
!isa<PackedType>((*yyvsp[-3].TypeVal).get()))
GEN_ERROR(
"Arithmetic operator requires integer, FP, or packed operands!");
{
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*yyvsp[-3].TypeVal)->getDescription());
- if (!(*yyvsp[-3].TypeVal)->isIntegral()) {
+ if (!(*yyvsp[-3].TypeVal)->isInteger()) {
if (!isa<PackedType>(yyvsp[-3].TypeVal->get()) ||
- !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isIntegral())
+ !cast<PackedType>(yyvsp[-3].TypeVal->get())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
Value* tmpVal1 = getVal(*yyvsp[-3].TypeVal, yyvsp[-2].ValIDVal);
{
if (yyvsp[0].ValueVal->getType() != Type::Int8Ty)
GEN_ERROR("Shift amount must be i8 type!");
- if (!yyvsp[-2].ValueVal->getType()->isIntegral())
+ if (!yyvsp[-2].ValueVal->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
yyval.InstVal = new ShiftInst(yyvsp[-3].OtherOpVal, yyvsp[-2].ValueVal, yyvsp[0].ValueVal);
const llvm::Type* ElemTy = $4->get();
if ((unsigned)$2 != $2)
GEN_ERROR("Unsigned result not equal to signed result");
- if (!ElemTy->isFloatingPoint() && !ElemTy->isIntegral())
+ if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
GEN_ERROR("Element type of a PackedType must be primitive");
if (!isPowerOf2_32($2))
GEN_ERROR("Vector length should be a power of 2!");
| LogicalOps '(' ConstVal ',' ConstVal ')' {
if ($3->getType() != $5->getType())
GEN_ERROR("Logical operator types must match!");
- if (!$3->getType()->isIntegral()) {
+ if (!$3->getType()->isInteger()) {
if (!isa<PackedType>($3->getType()) ||
- !cast<PackedType>($3->getType())->getElementType()->isIntegral())
+ !cast<PackedType>($3->getType())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
$$ = ConstantExpr::get($1, $3, $5);
| ShiftOps '(' ConstVal ',' ConstVal ')' {
if ($5->getType() != Type::Int8Ty)
GEN_ERROR("Shift count for shift constant must be i8 type!");
- if (!$3->getType()->isIntegral())
+ if (!$3->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
$$ = ConstantExpr::get($1, $3, $5);
InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
- if (!(*$2)->isIntegral() && !(*$2)->isFloatingPoint() &&
+ if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint() &&
!isa<PackedType>((*$2).get()))
GEN_ERROR(
"Arithmetic operator requires integer, FP, or packed operands!");
| LogicalOps Types ValueRef ',' ValueRef {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
- if (!(*$2)->isIntegral()) {
+ if (!(*$2)->isInteger()) {
if (!isa<PackedType>($2->get()) ||
- !cast<PackedType>($2->get())->getElementType()->isIntegral())
+ !cast<PackedType>($2->get())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
Value* tmpVal1 = getVal(*$2, $3);
| ShiftOps ResolvedVal ',' ResolvedVal {
if ($4->getType() != Type::Int8Ty)
GEN_ERROR("Shift amount must be i8 type!");
- if (!$2->getType()->isIntegral())
+ if (!$2->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
$$ = new ShiftInst($1, $2, $4);
const llvm::Type* ElemTy = $4->get();
if ((unsigned)$2 != $2)
GEN_ERROR("Unsigned result not equal to signed result");
- if (!ElemTy->isFloatingPoint() && !ElemTy->isIntegral())
+ if (!ElemTy->isFloatingPoint() && !ElemTy->isInteger())
GEN_ERROR("Element type of a PackedType must be primitive");
if (!isPowerOf2_32($2))
GEN_ERROR("Vector length should be a power of 2!");
| LogicalOps '(' ConstVal ',' ConstVal ')' {
if ($3->getType() != $5->getType())
GEN_ERROR("Logical operator types must match!");
- if (!$3->getType()->isIntegral()) {
+ if (!$3->getType()->isInteger()) {
if (!isa<PackedType>($3->getType()) ||
- !cast<PackedType>($3->getType())->getElementType()->isIntegral())
+ !cast<PackedType>($3->getType())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
$$ = ConstantExpr::get($1, $3, $5);
| ShiftOps '(' ConstVal ',' ConstVal ')' {
if ($5->getType() != Type::Int8Ty)
GEN_ERROR("Shift count for shift constant must be i8 type!");
- if (!$3->getType()->isIntegral())
+ if (!$3->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
$$ = ConstantExpr::get($1, $3, $5);
InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
- if (!(*$2)->isIntegral() && !(*$2)->isFloatingPoint() &&
+ if (!(*$2)->isInteger() && !(*$2)->isFloatingPoint() &&
!isa<PackedType>((*$2).get()))
GEN_ERROR(
"Arithmetic operator requires integer, FP, or packed operands!");
| LogicalOps Types ValueRef ',' ValueRef {
if (!UpRefs.empty())
GEN_ERROR("Invalid upreference in type: " + (*$2)->getDescription());
- if (!(*$2)->isIntegral()) {
+ if (!(*$2)->isInteger()) {
if (!isa<PackedType>($2->get()) ||
- !cast<PackedType>($2->get())->getElementType()->isIntegral())
+ !cast<PackedType>($2->get())->getElementType()->isInteger())
GEN_ERROR("Logical operator requires integral operands!");
}
Value* tmpVal1 = getVal(*$2, $3);
| ShiftOps ResolvedVal ',' ResolvedVal {
if ($4->getType() != Type::Int8Ty)
GEN_ERROR("Shift amount must be i8 type!");
- if (!$2->getType()->isIntegral())
+ if (!$2->getType()->isInteger())
GEN_ERROR("Shift constant expression requires integer operand!");
CHECK_FOR_ERROR;
$$ = new ShiftInst($1, $2, $4);
}
void BytecodeWriter::outputConstant(const Constant *CPV) {
- assert(((CPV->getType()->isPrimitiveType() || CPV->getType()->isIntegral()) ||
+ assert(((CPV->getType()->isPrimitiveType() || CPV->getType()->isInteger()) ||
!CPV->isNullValue()) && "Shouldn't output null constants!");
// We must check for a ConstantExpr before switching by type because
// We can emit the pointer value into this slot if the slot is an
// integer slot greater or equal to the size of the pointer.
- if (Ty->isIntegral() &&
+ if (Ty->isInteger() &&
TD->getTypeSize(Ty) >= TD->getTypeSize(Op->getType()))
return EmitConstantValueOnly(Op);
/// LowerBSWAP - Emit the code to lower bswap of V before the specified
/// instruction IP.
static Value *LowerBSWAP(Value *V, Instruction *IP) {
- assert(V->getType()->isIntegral() && "Can't bswap a non-integer type!");
+ assert(V->getType()->isInteger() && "Can't bswap a non-integer type!");
unsigned BitSize = V->getType()->getPrimitiveSizeInBits();
/// LowerCTPOP - Emit the code to lower ctpop of V before the specified
/// instruction IP.
static Value *LowerCTPOP(Value *V, Instruction *IP) {
- assert(V->getType()->isIntegral() && "Can't ctpop a non-integer type!");
+ assert(V->getType()->isInteger() && "Can't ctpop a non-integer type!");
static const uint64_t MaskValues[6] = {
0x5555555555555555ULL, 0x3333333333333333ULL,
ECStack.pop_back();
if (ECStack.empty()) { // Finished main. Put result into exit code...
- if (RetTy && RetTy->isIntegral()) { // Nonvoid return type?
+ if (RetTy && RetTy->isInteger()) { // Nonvoid return type?
ExitValue = Result; // Capture the exit value of the program
} else {
memset(&ExitValue, 0, sizeof(ExitValue));
// this by zero or sign extending the value as appropriate according to the
// source type.
const Type *Ty = V->getType();
- if (Ty->isIntegral()) {
+ if (Ty->isInteger()) {
if (Ty->getPrimitiveSizeInBits() == 1)
ArgVals.back().Int32Val = ArgVals.back().Int1Val;
else if (Ty->getPrimitiveSizeInBits() <= 8)
if (isa<PointerType>(DstTy)) {
assert(isa<PointerType>(SrcTy) && "Invalid BitCast");
Dest.PointerVal = Src.PointerVal;
- } else if (DstTy->isIntegral()) {
+ } else if (DstTy->isInteger()) {
const IntegerType *DITy = cast<IntegerType>(DstTy);
unsigned DBitWidth = DITy->getBitWidth();
if (SrcTy == Type::FloatTy) {
Dest.Int32Val = FloatToBits(Src.FloatVal);
} else if (SrcTy == Type::DoubleTy) {
Dest.Int64Val = DoubleToBits(Src.DoubleVal);
- } else if (SrcTy->isIntegral()) {
+ } else if (SrcTy->isInteger()) {
const IntegerType *SITy = cast<IntegerType>(SrcTy);
unsigned SBitWidth = SITy->getBitWidth();
assert(SBitWidth <= 64 && "Integer types > 64 bits not supported");
} else
assert(0 && "Invalid BitCast");
} else if (DstTy == Type::FloatTy) {
- if (SrcTy->isIntegral())
+ if (SrcTy->isInteger())
Dest.FloatVal = BitsToFloat(Src.Int32Val);
else
Dest.FloatVal = Src.FloatVal;
} else if (DstTy == Type::DoubleTy) {
- if (SrcTy->isIntegral())
+ if (SrcTy->isInteger())
Dest.DoubleVal = BitsToDouble(Src.Int64Val);
else
Dest.DoubleVal = Src.DoubleVal;
using namespace llvm;
static ConstantInt *getMaxValue(const Type *Ty, bool isSigned = false) {
- if (Ty->isIntegral()) {
+ if (Ty->isInteger()) {
if (isSigned) {
// Calculate 011111111111111...
unsigned TypeBits = Ty->getPrimitiveSizeInBits();
// Static constructor to create the minimum constant for an integral type...
static ConstantInt *getMinValue(const Type *Ty, bool isSigned = false) {
- if (Ty->isIntegral()) {
+ if (Ty->isInteger()) {
if (isSigned) {
// Calculate 1111111111000000000000
unsigned TypeBits = Ty->getPrimitiveSizeInBits();
/// Initialize a full (the default) or empty set for the specified type.
///
ConstantRange::ConstantRange(const Type *Ty, bool Full) {
- assert(Ty->isIntegral() &&
+ assert(Ty->isInteger() &&
"Cannot make constant range of non-integral type!");
if (Full)
Lower = Upper = getMaxValue(Ty);
/// subtract - Subtract the specified constant from the endpoints of this
/// constant range.
ConstantRange ConstantRange::subtract(ConstantInt *CI) const {
- assert(CI->getType() == getType() && getType()->isIntegral() &&
+ assert(CI->getType() == getType() && getType()->isInteger() &&
"Cannot subtract from different type range or non-integer!");
// If the set is empty or full, don't modify the endpoints.
if (Lower == Upper) return *this;
std::ostream &
CWriter::printSimpleType(std::ostream &Out, const Type *Ty, bool isSigned,
const std::string &NameSoFar) {
- assert((Ty->isPrimitiveType() || Ty->isIntegral()) &&
+ assert((Ty->isPrimitiveType() || Ty->isInteger()) &&
"Invalid type for printSimpleType");
switch (Ty->getTypeID()) {
case Type::VoidTyID: return Out << "void " << NameSoFar;
std::ostream &CWriter::printType(std::ostream &Out, const Type *Ty,
bool isSigned, const std::string &NameSoFar,
bool IgnoreName) {
- if (Ty->isPrimitiveType() || Ty->isIntegral()) {
+ if (Ty->isPrimitiveType() || Ty->isInteger()) {
printSimpleType(Out, Ty, isSigned, NameSoFar);
return Out;
}
}
if (NeedsExplicitCast) {
Out << "((";
- if (Ty->isIntegral() && Ty != Type::Int1Ty)
+ if (Ty->isInteger() && Ty != Type::Int1Ty)
printSimpleType(Out, Ty, TypeIsSigned);
else
printType(Out, Ty); // not integer, sign doesn't matter
// operand.
if (shouldCast) {
Out << "((";
- if (OpTy->isIntegral() && OpTy != Type::Int1Ty)
+ if (OpTy->isInteger() && OpTy != Type::Int1Ty)
printSimpleType(Out, OpTy, castIsSigned);
else
printType(Out, OpTy); // not integer, sign doesn't matter
void CWriter::printContainedStructs(const Type *Ty,
std::set<const StructType*> &StructPrinted){
// Don't walk through pointers.
- if (isa<PointerType>(Ty) || Ty->isPrimitiveType() || Ty->isIntegral()) return;
+ if (isa<PointerType>(Ty) || Ty->isPrimitiveType() || Ty->isInteger()) return;
// Print all contained types first.
for (Type::subtype_iterator I = Ty->subtype_begin(),
return false;
const Type *SrcTy = I.getOperand(0)->getType();
const Type *DstTy = I.getType();
- return (SrcTy->isFloatingPoint() && DstTy->isIntegral()) ||
- (DstTy->isFloatingPoint() && SrcTy->isIntegral());
+ return (SrcTy->isFloatingPoint() && DstTy->isInteger()) ||
+ (DstTy->isFloatingPoint() && SrcTy->isInteger());
}
void CWriter::printFunction(Function &F) {
// Verify this is a simple bswap.
if (CI->getNumOperands() != 2 ||
CI->getType() != CI->getOperand(1)->getType() ||
- !CI->getType()->isIntegral())
+ !CI->getType()->isInteger())
return false;
const Type *Ty = CI->getType();
case Instruction::Add:
case Instruction::Sub:
- if (!Ty->isIntegral() && !Ty->isFloatingPoint()) return false;
+ if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false;
if (!ExpressionConvertibleToType(I->getOperand(0), Ty, CTMap, TD) ||
!ExpressionConvertibleToType(I->getOperand(1), Ty, CTMap, TD))
return false;
break;
case Instruction::LShr:
case Instruction::AShr:
- if (!Ty->isIntegral()) return false;
+ if (!Ty->isInteger()) return false;
if (!ExpressionConvertibleToType(I->getOperand(0), Ty, CTMap, TD))
return false;
break;
case Instruction::Shl:
- if (!Ty->isIntegral()) return false;
+ if (!Ty->isInteger()) return false;
if (!ExpressionConvertibleToType(I->getOperand(0), Ty, CTMap, TD))
return false;
break;
case Instruction::Add:
case Instruction::Sub: {
- if (!Ty->isIntegral() && !Ty->isFloatingPoint()) return false;
+ if (!Ty->isInteger() && !Ty->isFloatingPoint()) return false;
Value *OtherOp = I->getOperand((V == I->getOperand(0)) ? 1 : 0);
return ValueConvertibleToType(I, Ty, CTMap, TD) &&
case Instruction::AShr:
case Instruction::Shl:
if (I->getOperand(1) == V) return false; // Cannot change shift amount type
- if (!Ty->isIntegral()) return false;
+ if (!Ty->isInteger()) return false;
return ValueConvertibleToType(I, Ty, CTMap, TD);
case Instruction::Free:
// Can convert store if the incoming value is convertible and if the
// result will preserve semantics...
const Type *Op0Ty = I->getOperand(0)->getType();
- if (!(Op0Ty->isIntegral() ^ ElTy->isIntegral()) &&
+ if (!(Op0Ty->isInteger() ^ ElTy->isInteger()) &&
!(Op0Ty->isFloatingPoint() ^ ElTy->isFloatingPoint()))
return ExpressionConvertibleToType(I->getOperand(0), ElTy, CTMap, TD);
}
//
static inline bool ShouldNukeSymtabEntry(const Type *Ty){
// Nuke all names for primitive types!
- if (Ty->isPrimitiveType() || Ty->isIntegral())
+ if (Ty->isPrimitiveType() || Ty->isInteger())
return true;
// Nuke all pointers to primitive types as well...
if (const PointerType *PT = dyn_cast<PointerType>(Ty))
if (PT->getElementType()->isPrimitiveType() ||
- PT->getElementType()->isIntegral())
+ PT->getElementType()->isInteger())
return true;
return false;
// Make sure the called function looks like exit (int argument, int return
// type, external linkage, not varargs).
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
- return F->arg_size() >= 1 && F->arg_begin()->getType()->isIntegral();
+ return F->arg_size() >= 1 && F->arg_begin()->getType()->isInteger();
}
virtual bool OptimizeCall(CallInst* ci, SimplifyLibCalls& SLC) {
Function::const_arg_iterator AI = F->arg_begin();
if (F->arg_size() != 3 || !isa<PointerType>(AI->getType())) return false;
if (!isa<PointerType>((++AI)->getType())) return false;
- if (!(++AI)->getType()->isIntegral()) return false;
- if (!F->getReturnType()->isIntegral()) return false;
+ if (!(++AI)->getType()->isInteger()) return false;
+ if (!F->getReturnType()->isInteger()) return false;
return true;
}
: LibCallOptimization("isascii", "Number of 'isascii' calls simplified") {}
virtual bool ValidateCalledFunction(const Function *F, SimplifyLibCalls &SLC){
- return F->arg_size() == 1 && F->arg_begin()->getType()->isIntegral() &&
- F->getReturnType()->isIntegral();
+ return F->arg_size() == 1 && F->arg_begin()->getType()->isInteger() &&
+ F->getReturnType()->isInteger();
}
/// @brief Perform the isascii optimization.
Value *Replacement;
public:
ValueInfo(const Type *Ty)
- : Bounds(Ty->isIntegral() ? Ty : Type::Int32Ty), Replacement(0) {}
+ : Bounds(Ty->isInteger() ? Ty : Type::Int32Ty), Replacement(0) {}
// getBounds() - Return the constant bounds of the value...
const ConstantRange &getBounds() const { return Bounds; }
if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop...
BasicBlock *BB = L->getBlocks()[i];
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E;) {
- if (I->getType()->isIntegral()) { // Is an integer instruction
+ if (I->getType()->isInteger()) { // Is an integer instruction
SCEVHandle SH = SE->getSCEV(I);
if (SH->hasComputableLoopEvolution(L) || // Varies predictably
HasConstantItCount) {
for (BasicBlock::iterator I = Header->begin(); isa<PHINode>(I); ++I) {
PHINode *PN = cast<PHINode>(I);
- if (PN->getType()->isIntegral()) { // FIXME: when we have fast-math, enable!
+ if (PN->getType()->isInteger()) { // FIXME: when we have fast-math, enable!
SCEVHandle SCEV = SE->getSCEV(PN);
if (SCEV->hasComputableLoopEvolution(L))
// FIXME: It is an extremely bad idea to indvar substitute anything more
if (LI->getLoopFor(L->getBlocks()[i]) == L) { // Not in a subloop...
BasicBlock *BB = L->getBlocks()[i];
for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
- if (I->getType()->isIntegral() && // Is an integer instruction
+ if (I->getType()->isInteger() && // Is an integer instruction
!I->use_empty() &&
!Rewriter.isInsertedInstruction(I)) {
SCEVHandle SH = SE->getSCEV(I);
// Otherwise, return null.
//
static inline Value *dyn_castFoldableMul(Value *V, ConstantInt *&CST) {
- if (V->hasOneUse() && V->getType()->isIntegral())
+ if (V->hasOneUse() && V->getType()->isInteger())
if (Instruction *I = dyn_cast<Instruction>(V)) {
if (I->getOpcode() == Instruction::Mul)
if ((CST = dyn_cast<ConstantInt>(I->getOperand(1))))
Instruction *I = dyn_cast<Instruction>(V);
if (!I) return;
- Mask &= V->getType()->getIntegralTypeMask();
+ Mask &= V->getType()->getIntegerTypeMask();
switch (I->getOpcode()) {
case Instruction::And:
return;
case Instruction::BitCast: {
const Type *SrcTy = I->getOperand(0)->getType();
- if (SrcTy->isIntegral()) {
+ if (SrcTy->isInteger()) {
ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
return;
}
case Instruction::ZExt: {
// Compute the bits in the result that are not present in the input.
const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegralTypeMask();
- uint64_t NewBits = I->getType()->getIntegralTypeMask() & NotIn;
+ uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
+ uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
- Mask &= SrcTy->getIntegralTypeMask();
+ Mask &= SrcTy->getIntegerTypeMask();
ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
// The top bits are known to be zero.
case Instruction::SExt: {
// Compute the bits in the result that are not present in the input.
const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegralTypeMask();
- uint64_t NewBits = I->getType()->getIntegralTypeMask() & NotIn;
+ uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
+ uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
- Mask &= SrcTy->getIntegralTypeMask();
+ Mask &= SrcTy->getIntegerTypeMask();
ComputeMaskedBits(I->getOperand(0), Mask, KnownZero, KnownOne, Depth+1);
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
uint64_t KnownZero,
uint64_t KnownOne,
int64_t &Min, int64_t &Max) {
- uint64_t TypeBits = Ty->getIntegralTypeMask();
+ uint64_t TypeBits = Ty->getIntegerTypeMask();
uint64_t UnknownBits = ~(KnownZero|KnownOne) & TypeBits;
uint64_t SignBit = 1ULL << (Ty->getPrimitiveSizeInBits()-1);
uint64_t KnownOne,
uint64_t &Min,
uint64_t &Max) {
- uint64_t TypeBits = Ty->getIntegralTypeMask();
+ uint64_t TypeBits = Ty->getIntegerTypeMask();
uint64_t UnknownBits = ~(KnownZero|KnownOne) & TypeBits;
// The minimum value is when the unknown bits are all zeros.
}
// If this is the root being simplified, allow it to have multiple uses,
// just set the DemandedMask to all bits.
- DemandedMask = V->getType()->getIntegralTypeMask();
+ DemandedMask = V->getType()->getIntegerTypeMask();
} else if (DemandedMask == 0) { // Not demanding any bits from V.
if (V != UndefValue::get(V->getType()))
return UpdateValueUsesWith(V, UndefValue::get(V->getType()));
Instruction *I = dyn_cast<Instruction>(V);
if (!I) return false; // Only analyze instructions.
- DemandedMask &= V->getType()->getIntegralTypeMask();
+ DemandedMask &= V->getType()->getIntegerTypeMask();
uint64_t KnownZero2 = 0, KnownOne2 = 0;
switch (I->getOpcode()) {
assert((KnownZero & KnownOne) == 0 && "Bits known to be one AND zero?");
break;
case Instruction::BitCast:
- if (!I->getOperand(0)->getType()->isIntegral())
+ if (!I->getOperand(0)->getType()->isInteger())
return false;
if (SimplifyDemandedBits(I->getOperand(0), DemandedMask,
case Instruction::ZExt: {
// Compute the bits in the result that are not present in the input.
const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegralTypeMask();
- uint64_t NewBits = I->getType()->getIntegralTypeMask() & NotIn;
+ uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
+ uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
- DemandedMask &= SrcTy->getIntegralTypeMask();
+ DemandedMask &= SrcTy->getIntegerTypeMask();
if (SimplifyDemandedBits(I->getOperand(0), DemandedMask,
KnownZero, KnownOne, Depth+1))
return true;
case Instruction::SExt: {
// Compute the bits in the result that are not present in the input.
const Type *SrcTy = I->getOperand(0)->getType();
- uint64_t NotIn = ~SrcTy->getIntegralTypeMask();
- uint64_t NewBits = I->getType()->getIntegralTypeMask() & NotIn;
+ uint64_t NotIn = ~SrcTy->getIntegerTypeMask();
+ uint64_t NewBits = I->getType()->getIntegerTypeMask() & NotIn;
// Get the sign bit for the source type
uint64_t InSignBit = 1ULL << (SrcTy->getPrimitiveSizeInBits()-1);
- int64_t InputDemandedBits = DemandedMask & SrcTy->getIntegralTypeMask();
+ int64_t InputDemandedBits = DemandedMask & SrcTy->getIntegerTypeMask();
// If any of the sign extended bits are demanded, we know that the sign
// bit is demanded.
// Compute the new bits that are at the top now.
uint64_t HighBits = (1ULL << ShiftAmt)-1;
HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt;
- uint64_t TypeMask = I->getType()->getIntegralTypeMask();
+ uint64_t TypeMask = I->getType()->getIntegerTypeMask();
// Unsigned shift right.
if (SimplifyDemandedBits(I->getOperand(0),
(DemandedMask << ShiftAmt) & TypeMask,
// Compute the new bits that are at the top now.
uint64_t HighBits = (1ULL << ShiftAmt)-1;
HighBits <<= I->getType()->getPrimitiveSizeInBits() - ShiftAmt;
- uint64_t TypeMask = I->getType()->getIntegralTypeMask();
+ uint64_t TypeMask = I->getType()->getIntegerTypeMask();
// Signed shift right.
if (SimplifyDemandedBits(I->getOperand(0),
(DemandedMask << ShiftAmt) & TypeMask,
// (X & 254)+1 -> (X&254)|1
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegralTypeMask(),
+ SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
KnownZero, KnownOne))
return &I;
}
// This is a sign extend if the top bits are known zero.
uint64_t Mask = ~0ULL;
Mask <<= 64-(TySizeBits-Size);
- Mask &= XorLHS->getType()->getIntegralTypeMask();
+ Mask &= XorLHS->getType()->getIntegerTypeMask();
if (!MaskedValueIsZero(XorLHS, Mask))
Size = 0; // Not a sign ext, but can't be any others either.
goto FoundSExt;
}
// X + X --> X << 1
- if (I.getType()->isIntegral() && I.getType() != Type::Int1Ty) {
+ if (I.getType()->isInteger() && I.getType() != Type::Int1Ty) {
if (Instruction *Result = AssociativeOpt(I, AddRHS(RHS))) return Result;
if (Instruction *RHSI = dyn_cast<Instruction>(RHS)) {
// Form a mask of all bits from the lowest bit added through the top.
uint64_t AddRHSHighBits = ~((AddRHSV & -AddRHSV)-1);
- AddRHSHighBits &= C2->getType()->getIntegralTypeMask();
+ AddRHSHighBits &= C2->getType()->getIntegerTypeMask();
// See if the and mask includes all of these bits.
uint64_t AddRHSHighBitsAnd = AddRHSHighBits & C2->getZExtValue();
if (CastInst *CI = dyn_cast<CastInst>(V)) {
const Type *CTy = CI->getType();
const Type *OpTy = CI->getOperand(0)->getType();
- if (CTy->isIntegral() && OpTy->isIntegral()) {
+ if (CTy->isInteger() && OpTy->isInteger()) {
if (CTy->getPrimitiveSizeInBits() == OpTy->getPrimitiveSizeInBits())
return RemoveNoopCast(CI->getOperand(0));
} else if (isa<PointerType>(CTy) && isa<PointerType>(OpTy))
// If the sign bits of both operands are zero (i.e. we can prove they are
// unsigned inputs), turn this into a udiv.
- if (I.getType()->isIntegral()) {
+ if (I.getType()->isInteger()) {
uint64_t Mask = 1ULL << (I.getType()->getPrimitiveSizeInBits()-1);
if (MaskedValueIsZero(Op1, Mask) && MaskedValueIsZero(Op0, Mask)) {
return BinaryOperator::createUDiv(Op0, Op1, I.getName());
Val >>= 64-TypeBits; // Shift out unwanted 1 bits...
return C->getSExtValue() == Val-1;
}
- return C->getZExtValue() == C->getType()->getIntegralTypeMask()-1;
+ return C->getZExtValue() == C->getType()->getIntegerTypeMask()-1;
}
// isMinValuePlusOne - return true if this is Min+1
uint64_t AndRHSV = cast<ConstantInt>(AndRHS)->getZExtValue();
// Clear bits that are not part of the constant.
- AndRHSV &= AndRHS->getType()->getIntegralTypeMask();
+ AndRHSV &= AndRHS->getType()->getIntegerTypeMask();
// If there is only one bit set...
if (isOneBitSet(cast<ConstantInt>(AndRHS))) {
// is all N is, ignore it.
unsigned MB, ME;
if (isRunOfOnes(Mask, MB, ME)) { // begin/end bit of run, inclusive
- uint64_t Mask = RHS->getType()->getIntegralTypeMask();
+ uint64_t Mask = RHS->getType()->getIntegerTypeMask();
Mask >>= 64-MB+1;
if (MaskedValueIsZero(RHS, Mask))
break;
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegralTypeMask(),
+ SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
KnownZero, KnownOne))
return &I;
if (ConstantInt *AndRHS = dyn_cast<ConstantInt>(Op1)) {
uint64_t AndRHSMask = AndRHS->getZExtValue();
- uint64_t TypeMask = Op0->getType()->getIntegralTypeMask();
+ uint64_t TypeMask = Op0->getType()->getIntegerTypeMask();
uint64_t NotAndRHS = AndRHSMask^TypeMask;
// Optimize a variety of ((val OP C1) & C2) combinations...
if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
if (Op0C->getOpcode() == Op1C->getOpcode()) { // same cast kind ?
const Type *SrcTy = Op0C->getOperand(0)->getType();
- if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+ if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isInteger() &&
// Only do this if the casts both really cause code to be generated.
ValueRequiresCast(Op0C->getOpcode(), Op0C->getOperand(0),
I.getType(), TD) &&
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegralTypeMask(),
+ SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
KnownZero, KnownOne))
return &I;
if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
if (Op0C->getOpcode() == Op1C->getOpcode()) {// same cast kind ?
const Type *SrcTy = Op0C->getOperand(0)->getType();
- if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+ if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isInteger() &&
// Only do this if the casts both really cause code to be generated.
ValueRequiresCast(Op0C->getOpcode(), Op0C->getOperand(0),
I.getType(), TD) &&
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
if (!isa<PackedType>(I.getType()) &&
- SimplifyDemandedBits(&I, I.getType()->getIntegralTypeMask(),
+ SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
KnownZero, KnownOne))
return &I;
if (CastInst *Op1C = dyn_cast<CastInst>(Op1))
if (Op0C->getOpcode() == Op1C->getOpcode()) { // same cast kind?
const Type *SrcTy = Op0C->getOperand(0)->getType();
- if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isIntegral() &&
+ if (SrcTy == Op1C->getOperand(0)->getType() && SrcTy->isInteger() &&
// Only do this if the casts both really cause code to be generated.
ValueRequiresCast(Op0C->getOpcode(), Op0C->getOperand(0),
I.getType(), TD) &&
// See if we can fold the comparison based on bits known to be zero or one
// in the input.
uint64_t KnownZero, KnownOne;
- if (SimplifyDemandedBits(Op0, Ty->getIntegralTypeMask(),
+ if (SimplifyDemandedBits(Op0, Ty->getIntegerTypeMask(),
KnownZero, KnownOne, 0))
return &I;
Value *CastOp = Cast->getOperand(0);
const Type *SrcTy = CastOp->getType();
unsigned SrcTySize = SrcTy->getPrimitiveSizeInBits();
- if (SrcTy->isIntegral() &&
+ if (SrcTy->isInteger() &&
SrcTySize == Cast->getType()->getPrimitiveSizeInBits()) {
// If this is an unsigned comparison, try to make the comparison use
// smaller constant values.
// See if we can simplify any instructions used by the instruction whose sole
// purpose is to compute bits we don't care about.
uint64_t KnownZero, KnownOne;
- if (SimplifyDemandedBits(&I, I.getType()->getIntegralTypeMask(),
+ if (SimplifyDemandedBits(&I, I.getType()->getIntegerTypeMask(),
KnownZero, KnownOne))
return &I;
// See if we can simplify any instructions used by the LHS whose sole
// purpose is to compute bits we don't care about.
uint64_t KnownZero = 0, KnownOne = 0;
- if (SimplifyDemandedBits(&CI, DestTy->getIntegralTypeMask(),
+ if (SimplifyDemandedBits(&CI, DestTy->getIntegerTypeMask(),
KnownZero, KnownOne))
return &CI;
if (Op1CV == 0 || isPowerOf2_64(Op1CV)) {
// If Op1C some other power of two, convert:
uint64_t KnownZero, KnownOne;
- uint64_t TypeMask = Op1->getType()->getIntegralTypeMask();
+ uint64_t TypeMask = Op1->getType()->getIntegerTypeMask();
ComputeMaskedBits(Op0, TypeMask, KnownZero, KnownOne);
// This only works for EQ and NE
// If we're actually extending zero bits and the trunc is a no-op
if (MidSize < DstSize && SrcSize == DstSize) {
// Replace both of the casts with an And of the type mask.
- uint64_t AndValue = CSrc->getType()->getIntegralTypeMask();
+ uint64_t AndValue = CSrc->getType()->getIntegerTypeMask();
Constant *AndConst = ConstantInt::get(A->getType(), AndValue);
Instruction *And =
BinaryOperator::createAnd(CSrc->getOperand(0), AndConst);
const Type *SrcTy = Src->getType();
const Type *DestTy = CI.getType();
- if (SrcTy->isIntegral() && DestTy->isIntegral()) {
+ if (SrcTy->isInteger() && DestTy->isInteger()) {
if (Instruction *Result = commonIntCastTransforms(CI))
return Result;
} else {
}
// See if we can fold the select into one of our operands.
- if (SI.getType()->isIntegral()) {
+ if (SI.getType()->isInteger()) {
// See the comment above GetSelectFoldableOperands for a description of the
// transformation we are doing here.
if (Instruction *TVI = dyn_cast<Instruction>(TrueVal))
//Either we can cast directly, or we can upconvert the argument
bool isConvertible = ActTy == ParamTy ||
(isa<PointerType>(ParamTy) && isa<PointerType>(ActTy)) ||
- (ParamTy->isIntegral() && ActTy->isIntegral() &&
+ (ParamTy->isInteger() && ActTy->isInteger() &&
ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits()) ||
(c && ParamTy->getPrimitiveSizeInBits() >= ActTy->getPrimitiveSizeInBits()
&& c->getSExtValue() > 0);
Value *Src = CI->getOperand(0);
const Type *SrcTy = Src->getType();
const Type *DestTy = CI->getType();
- if (Src->getType()->isIntegral()) {
+ if (Src->getType()->isInteger()) {
if (SrcTy->getPrimitiveSizeInBits() ==
DestTy->getPrimitiveSizeInBits()) {
// We can always eliminate a cast from ulong or long to the other.
if (const PointerType *SrcTy = dyn_cast<PointerType>(CastOp->getType())) {
const Type *SrcPTy = SrcTy->getElementType();
- if (DestPTy->isIntegral() || isa<PointerType>(DestPTy) ||
+ if (DestPTy->isInteger() || isa<PointerType>(DestPTy) ||
isa<PackedType>(DestPTy)) {
// If the source is an array, the code below will not succeed. Check to
// see if a trivial 'gep P, 0, 0' will help matters. Only do this for
SrcPTy = SrcTy->getElementType();
}
- if ((SrcPTy->isIntegral() || isa<PointerType>(SrcPTy) ||
+ if ((SrcPTy->isInteger() || isa<PointerType>(SrcPTy) ||
isa<PackedType>(SrcPTy)) &&
// Do not allow turning this into a load of an integer, which is then
// casted to a pointer, this pessimizes pointer analysis a lot.
if (const PointerType *SrcTy = dyn_cast<PointerType>(CastOp->getType())) {
const Type *SrcPTy = SrcTy->getElementType();
- if (DestPTy->isIntegral() || isa<PointerType>(DestPTy)) {
+ if (DestPTy->isInteger() || isa<PointerType>(DestPTy)) {
// If the source is an array, the code below will not succeed. Check to
// see if a trivial 'gep P, 0, 0' will help matters. Only do this for
// constants.
SrcPTy = SrcTy->getElementType();
}
- if ((SrcPTy->isIntegral() || isa<PointerType>(SrcPTy)) &&
+ if ((SrcPTy->isInteger() || isa<PointerType>(SrcPTy)) &&
IC.getTargetData().getTypeSize(SrcPTy) ==
IC.getTargetData().getTypeSize(DestPTy)) {
Instruction::CastOps opcode = Instruction::BitCast;
Value *SIOp0 = SI.getOperand(0);
if (isa<PointerType>(SrcPTy)) {
- if (SIOp0->getType()->isIntegral())
+ if (SIOp0->getType()->isInteger())
opcode = Instruction::IntToPtr;
- } else if (SrcPTy->isIntegral()) {
+ } else if (SrcPTy->isInteger()) {
if (isa<PointerType>(SIOp0->getType()))
opcode = Instruction::PtrToInt;
}
/// return true. Otherwise, return false.
bool LoopStrengthReduce::AddUsersIfInteresting(Instruction *I, Loop *L,
std::set<Instruction*> &Processed) {
- if (!I->getType()->isIntegral() && !isa<PointerType>(I->getType()))
+ if (!I->getType()->isInteger() && !isa<PointerType>(I->getType()))
return false; // Void and FP expressions cannot be reduced.
if (!Processed.insert(I).second)
return true; // Instruction already handled.
// If this is a not or neg instruction, do not count it for rank. This
// assures us that X and ~X will have the same rank.
- if (!I->getType()->isIntegral() ||
+ if (!I->getType()->isInteger() ||
(!BinaryOperator::isNot(I) && !BinaryOperator::isNeg(I)))
++Rank;
Accum = In;
} else if (In == Type::VoidTy) {
// Noop.
- } else if (In->isIntegral() && Accum->isIntegral()) { // integer union.
+ } else if (In->isInteger() && Accum->isInteger()) { // integer union.
// Otherwise pick whichever type is larger.
if (cast<IntegerType>(In)->getBitWidth() >
cast<IntegerType>(Accum)->getBitWidth())
case Type::FloatTyID: Accum = Type::Int32Ty; break;
case Type::DoubleTyID: Accum = Type::Int64Ty; break;
default:
- assert(Accum->isIntegral() && "Unknown FP type!");
+ assert(Accum->isInteger() && "Unknown FP type!");
break;
}
case Type::FloatTyID: In = Type::Int32Ty; break;
case Type::DoubleTyID: In = Type::Int64Ty; break;
default:
- assert(In->isIntegral() && "Unknown FP type!");
+ assert(In->isInteger() && "Unknown FP type!");
break;
}
return MergeInType(In, Accum, TD);
IsNotTrivial = true;
const Type *SubElt = CanConvertToScalar(GEP, IsNotTrivial);
if (SubElt == 0) return 0;
- if (SubElt != Type::VoidTy && SubElt->isIntegral()) {
+ if (SubElt != Type::VoidTy && SubElt->isInteger()) {
const Type *NewTy =
getUIntAtLeastAsBitAs(TD.getTypeSize(SubElt)*8+BitOffset);
if (NewTy == 0 || MergeInType(NewTy, UsedType, TD)) return 0;
// an integer.
NV = new BitCastInst(NV, LI->getType(), LI->getName(), LI);
} else {
- assert(NV->getType()->isIntegral() && "Unknown promotion!");
+ assert(NV->getType()->isInteger() && "Unknown promotion!");
if (Offset && Offset < TD.getTypeSize(NV->getType())*8) {
NV = new ShiftInst(Instruction::LShr, NV,
ConstantInt::get(Type::Int8Ty, Offset),
}
// If the result is an integer, this is a trunc or bitcast.
- if (LI->getType()->isIntegral()) {
+ if (LI->getType()->isInteger()) {
NV = CastInst::createTruncOrBitCast(NV, LI->getType(),
LI->getName(), LI);
} else if (LI->getType()->isFloatingPoint()) {
if (TotalBits != SrcSize) {
assert(TotalBits > SrcSize);
uint64_t Mask = ~(((1ULL << SrcSize)-1) << Offset);
- Mask = Mask & SV->getType()->getIntegralTypeMask();
+ Mask = Mask & SV->getType()->getIntegerTypeMask();
Old = BinaryOperator::createAnd(Old,
ConstantInt::get(Old->getType(), Mask),
Old->getName()+".mask", SI);
Value *CompVal = 0;
std::vector<ConstantInt*> Values;
bool TrueWhenEqual = GatherValueComparisons(Cond, CompVal, Values);
- if (CompVal && CompVal->getType()->isIntegral()) {
+ if (CompVal && CompVal->getType()->isInteger()) {
// There might be duplicate constants in the list, which the switch
// instruction can't handle, remove them now.
std::sort(Values.begin(), Values.end(), ConstantIntOrdering());
const Type *Ty = cast<Type>(TI->second);
if (!isa<PointerType>(Ty) ||
!cast<PointerType>(Ty)->getElementType()->isPrimitiveType() ||
- !cast<PointerType>(Ty)->getElementType()->isIntegral() ||
+ !cast<PointerType>(Ty)->getElementType()->isInteger() ||
isa<OpaqueType>(cast<PointerType>(Ty)->getElementType()))
TypeNames.insert(std::make_pair(Ty, getLLVMName(TI->first)));
}
std::vector<const Type *> &TypeStack,
std::map<const Type *, std::string> &TypeNames,
std::string & Result){
- if (Ty->isIntegral() || (Ty->isPrimitiveType() && !isa<OpaqueType>(Ty))) {
+ if (Ty->isInteger() || (Ty->isPrimitiveType() && !isa<OpaqueType>(Ty))) {
Result += Ty->getDescription(); // Base case
return;
}
// Primitive types always print out their description, regardless of whether
// they have been named or not.
//
- if (Ty->isIntegral() || (Ty->isPrimitiveType() && !isa<OpaqueType>(Ty)))
+ if (Ty->isInteger() || (Ty->isPrimitiveType() && !isa<OpaqueType>(Ty)))
return Out << Ty->getDescription();
// Check to see if the type is named.
// If the src and dest elements are both integers, or both floats, we can
// just BitCast each element because the elements are the same size.
- if ((SrcEltTy->isIntegral() && DstEltTy->isIntegral()) ||
+ if ((SrcEltTy->isInteger() && DstEltTy->isInteger()) ||
(SrcEltTy->isFloatingPoint() && DstEltTy->isFloatingPoint())) {
for (unsigned i = 0; i != SrcNumElts; ++i)
Result.push_back(
}
// If this is an int-to-fp cast ..
- if (SrcEltTy->isIntegral()) {
+ if (SrcEltTy->isInteger()) {
// Ensure that it is int-to-fp cast
assert(DstEltTy->isFloatingPoint());
if (DstEltTy->getTypeID() == Type::DoubleTyID) {
}
// Otherwise, this is an fp-to-int cast.
- assert(SrcEltTy->isFloatingPoint() && DstEltTy->isIntegral());
+ assert(SrcEltTy->isFloatingPoint() && DstEltTy->isInteger());
if (SrcEltTy->getTypeID() == Type::DoubleTyID) {
for (unsigned i = 0; i != SrcNumElts; ++i) {
// Handle integral constant input.
if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
// Integral -> Integral, must be changing sign.
- if (DestTy->isIntegral())
+ if (DestTy->isInteger())
return ConstantInt::get(DestTy, CI->getZExtValue());
if (DestTy->isFloatingPoint()) {
// Handle ConstantFP input.
if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
// FP -> Integral.
- if (DestTy->isIntegral()) {
+ if (DestTy->isInteger()) {
if (DestTy == Type::Int32Ty)
return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
assert(DestTy == Type::Int64Ty &&
// If the cast is not actually changing bits, and the second operand is a
// null pointer, do the comparison with the pre-casted value.
if (V2->isNullValue() &&
- (isa<PointerType>(CE1->getType()) || CE1->getType()->isIntegral())) {
+ (isa<PointerType>(CE1->getType()) || CE1->getType()->isInteger())) {
bool sgnd = CE1->getOpcode() == Instruction::ZExt ? false :
(CE1->getOpcode() == Instruction::SExt ? true :
(CE1->getOpcode() == Instruction::PtrToInt ? false : isSigned));
if (const ConstantExpr *CE2 = dyn_cast<ConstantExpr>(V2))
if (CE2->isCast() && isa<PointerType>(CE1->getType()) &&
CE1->getOperand(0)->getType() == CE2->getOperand(0)->getType() &&
- CE1->getOperand(0)->getType()->isIntegral()) {
+ CE1->getOperand(0)->getType()->isInteger()) {
bool sgnd = CE1->getOpcode() == Instruction::ZExt ? false :
(CE1->getOpcode() == Instruction::SExt ? true :
(CE1->getOpcode() == Instruction::PtrToInt ? false : isSigned));
return getTrue();
else
return getFalse();
- return IntConstants->getOrCreate(Ty, V & Ty->getIntegralTypeMask());
+ return IntConstants->getOrCreate(Ty, V & Ty->getIntegerTypeMask());
}
//---- ConstantFP::get() implementation...
Constant *ConstantExpr::getPointerCast(Constant *S, const Type *Ty) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
- assert((Ty->isIntegral() || isa<PointerType>(Ty)) && "Invalid cast");
+ assert((Ty->isInteger() || isa<PointerType>(Ty)) && "Invalid cast");
- if (Ty->isIntegral())
+ if (Ty->isInteger())
return getCast(Instruction::PtrToInt, S, Ty);
return getCast(Instruction::BitCast, S, Ty);
}
Constant *ConstantExpr::getIntegerCast(Constant *C, const Type *Ty,
bool isSigned) {
- assert(C->getType()->isIntegral() && Ty->isIntegral() && "Invalid cast");
+ assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
unsigned SrcBits = C->getType()->getPrimitiveSizeInBits();
unsigned DstBits = Ty->getPrimitiveSizeInBits();
Instruction::CastOps opcode =
}
Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) {
- assert(C->getType()->isIntegral() && "Trunc operand must be integer");
- assert(Ty->isIntegral() && "Trunc produces only integral");
+ assert(C->getType()->isInteger() && "Trunc operand must be integer");
+ assert(Ty->isInteger() && "Trunc produces only integral");
assert(C->getType()->getPrimitiveSizeInBits() > Ty->getPrimitiveSizeInBits()&&
"SrcTy must be larger than DestTy for Trunc!");
}
Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty) {
- assert(C->getType()->isIntegral() && "SEXt operand must be integral");
- assert(Ty->isIntegral() && "SExt produces only integer");
+ assert(C->getType()->isInteger() && "SEXt operand must be integral");
+ assert(Ty->isInteger() && "SExt produces only integer");
assert(C->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()&&
"SrcTy must be smaller than DestTy for SExt!");
}
Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty) {
- assert(C->getType()->isIntegral() && "ZEXt operand must be integral");
- assert(Ty->isIntegral() && "ZExt produces only integer");
+ assert(C->getType()->isInteger() && "ZEXt operand must be integral");
+ assert(Ty->isInteger() && "ZExt produces only integer");
assert(C->getType()->getPrimitiveSizeInBits() < Ty->getPrimitiveSizeInBits()&&
"SrcTy must be smaller than DestTy for ZExt!");
}
Constant *ConstantExpr::getUIToFP(Constant *C, const Type *Ty) {
- assert(C->getType()->isIntegral() && Ty->isFloatingPoint() &&
+ assert(C->getType()->isInteger() && Ty->isFloatingPoint() &&
"This is an illegal uint to floating point cast!");
return getFoldedCast(Instruction::UIToFP, C, Ty);
}
Constant *ConstantExpr::getSIToFP(Constant *C, const Type *Ty) {
- assert(C->getType()->isIntegral() && Ty->isFloatingPoint() &&
+ assert(C->getType()->isInteger() && Ty->isFloatingPoint() &&
"This is an illegal sint to floating point cast!");
return getFoldedCast(Instruction::SIToFP, C, Ty);
}
Constant *ConstantExpr::getFPToUI(Constant *C, const Type *Ty) {
- assert(C->getType()->isFloatingPoint() && Ty->isIntegral() &&
+ assert(C->getType()->isFloatingPoint() && Ty->isInteger() &&
"This is an illegal floating point to uint cast!");
return getFoldedCast(Instruction::FPToUI, C, Ty);
}
Constant *ConstantExpr::getFPToSI(Constant *C, const Type *Ty) {
- assert(C->getType()->isFloatingPoint() && Ty->isIntegral() &&
+ assert(C->getType()->isFloatingPoint() && Ty->isInteger() &&
"This is an illegal floating point to sint cast!");
return getFoldedCast(Instruction::FPToSI, C, Ty);
}
Constant *ConstantExpr::getPtrToInt(Constant *C, const Type *DstTy) {
assert(isa<PointerType>(C->getType()) && "PtrToInt source must be pointer");
- assert(DstTy->isIntegral() && "PtrToInt destination must be integral");
+ assert(DstTy->isInteger() && "PtrToInt destination must be integral");
return getFoldedCast(Instruction::PtrToInt, C, DstTy);
}
Constant *ConstantExpr::getIntToPtr(Constant *C, const Type *DstTy) {
- assert(C->getType()->isIntegral() && "IntToPtr source must be integral");
+ assert(C->getType()->isInteger() && "IntToPtr source must be integral");
assert(isa<PointerType>(DstTy) && "IntToPtr destination must be a pointer");
return getFoldedCast(Instruction::IntToPtr, C, DstTy);
}
case Instruction::Sub:
case Instruction::Mul:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
- assert((C1->getType()->isIntegral() || C1->getType()->isFloatingPoint() ||
+ assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint() ||
isa<PackedType>(C1->getType())) &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::UDiv:
case Instruction::SDiv:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
- assert((C1->getType()->isIntegral() || (isa<PackedType>(C1->getType()) &&
- cast<PackedType>(C1->getType())->getElementType()->isIntegral())) &&
+ assert((C1->getType()->isInteger() || (isa<PackedType>(C1->getType()) &&
+ cast<PackedType>(C1->getType())->getElementType()->isInteger())) &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::FDiv:
case Instruction::URem:
case Instruction::SRem:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
- assert((C1->getType()->isIntegral() || (isa<PackedType>(C1->getType()) &&
- cast<PackedType>(C1->getType())->getElementType()->isIntegral())) &&
+ assert((C1->getType()->isInteger() || (isa<PackedType>(C1->getType()) &&
+ cast<PackedType>(C1->getType())->getElementType()->isInteger())) &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::FRem:
case Instruction::Or:
case Instruction::Xor:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
- assert((C1->getType()->isIntegral() || isa<PackedType>(C1->getType())) &&
+ assert((C1->getType()->isInteger() || isa<PackedType>(C1->getType())) &&
"Tried to create a logical operation on a non-integral type!");
break;
case Instruction::Shl:
case Instruction::LShr:
case Instruction::AShr:
assert(C2->getType() == Type::Int8Ty && "Shift should be by ubyte!");
- assert(C1->getType()->isIntegral() &&
+ assert(C1->getType()->isInteger() &&
"Tried to create a shift operation on a non-integer type!");
break;
default:
Opcode == Instruction::LShr ||
Opcode == Instruction::AShr) &&
"Invalid opcode in binary constant expression");
- assert(C1->getType()->isIntegral() && C2->getType() == Type::Int8Ty &&
+ assert(C1->getType()->isInteger() && C2->getType() == Type::Int8Ty &&
"Invalid operand types for Shift constant expr!");
if (Constant *FC = ConstantFoldBinaryInstruction(Opcode, C1, C2))
case Mul:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
- assert((getType()->isIntegral() || getType()->isFloatingPoint() ||
+ assert((getType()->isInteger() || getType()->isFloatingPoint() ||
isa<PackedType>(getType())) &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case SDiv:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
- assert((getType()->isIntegral() || (isa<PackedType>(getType()) &&
- cast<PackedType>(getType())->getElementType()->isIntegral())) &&
+ assert((getType()->isInteger() || (isa<PackedType>(getType()) &&
+ cast<PackedType>(getType())->getElementType()->isInteger())) &&
"Incorrect operand type (not integer) for S/UDIV");
break;
case FDiv:
case SRem:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
- assert((getType()->isIntegral() || (isa<PackedType>(getType()) &&
- cast<PackedType>(getType())->getElementType()->isIntegral())) &&
+ assert((getType()->isInteger() || (isa<PackedType>(getType()) &&
+ cast<PackedType>(getType())->getElementType()->isInteger())) &&
"Incorrect operand type (not integer) for S/UREM");
break;
case FRem:
case Xor:
assert(getType() == LHS->getType() &&
"Logical operation should return same type as operands!");
- assert((getType()->isIntegral() ||
+ assert((getType()->isInteger() ||
(isa<PackedType>(getType()) &&
- cast<PackedType>(getType())->getElementType()->isIntegral())) &&
+ cast<PackedType>(getType())->getElementType()->isInteger())) &&
"Tried to create a logical operation on a non-integral type!");
break;
default:
case Instruction::Trunc:
return true;
case Instruction::BitCast:
- return getOperand(0)->getType()->isIntegral() && getType()->isIntegral();
+ return getOperand(0)->getType()->isInteger() && getType()->isInteger();
}
}
case 3:
// no-op cast in second op implies firstOp as long as the DestTy
// is integer
- if (DstTy->isIntegral())
+ if (DstTy->isInteger())
return firstOp;
return 0;
case 4:
case 5:
// no-op cast in first op implies secondOp as long as the SrcTy
// is an integer
- if (SrcTy->isIntegral())
+ if (SrcTy->isInteger())
return secondOp;
return 0;
case 6:
const std::string &Name,
BasicBlock *InsertAtEnd) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
- assert((Ty->isIntegral() || isa<PointerType>(Ty)) &&
+ assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
"Invalid cast");
- if (Ty->isIntegral())
+ if (Ty->isInteger())
return create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
}
const std::string &Name,
Instruction *InsertBefore) {
assert(isa<PointerType>(S->getType()) && "Invalid cast");
- assert((Ty->isIntegral() || isa<PointerType>(Ty)) &&
+ assert((Ty->isInteger() || isa<PointerType>(Ty)) &&
"Invalid cast");
- if (Ty->isIntegral())
+ if (Ty->isInteger())
return create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
return create(Instruction::BitCast, S, Ty, Name, InsertBefore);
}
CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty,
bool isSigned, const std::string &Name,
Instruction *InsertBefore) {
- assert(C->getType()->isIntegral() && Ty->isIntegral() && "Invalid cast");
+ assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
unsigned SrcBits = C->getType()->getPrimitiveSizeInBits();
unsigned DstBits = Ty->getPrimitiveSizeInBits();
Instruction::CastOps opcode =
CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty,
bool isSigned, const std::string &Name,
BasicBlock *InsertAtEnd) {
- assert(C->getType()->isIntegral() && Ty->isIntegral() && "Invalid cast");
+ assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
unsigned SrcBits = C->getType()->getPrimitiveSizeInBits();
unsigned DstBits = Ty->getPrimitiveSizeInBits();
Instruction::CastOps opcode =
unsigned DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr/packed
// Run through the possibilities ...
- if (DestTy->isIntegral()) { // Casting to integral
- if (SrcTy->isIntegral()) { // Casting from integral
+ if (DestTy->isInteger()) { // Casting to integral
+ if (SrcTy->isInteger()) { // Casting from integral
if (DestBits < SrcBits)
return Trunc; // int -> smaller int
else if (DestBits > SrcBits) { // its an extension
return PtrToInt; // ptr -> int
}
} else if (DestTy->isFloatingPoint()) { // Casting to floating pt
- if (SrcTy->isIntegral()) { // Casting from integral
+ if (SrcTy->isInteger()) { // Casting from integral
if (SrcIsSigned)
return SIToFP; // sint -> FP
else
} else if (isa<PointerType>(DestTy)) {
if (isa<PointerType>(SrcTy)) {
return BitCast; // ptr -> ptr
- } else if (SrcTy->isIntegral()) {
+ } else if (SrcTy->isInteger()) {
return IntToPtr; // int -> ptr
} else {
assert(!"Casting pointer to other than pointer or int");
switch (op) {
default: return false; // This is an input error
case Instruction::Trunc:
- return SrcTy->isIntegral() && DstTy->isIntegral()&& SrcBitSize > DstBitSize;
+ return SrcTy->isInteger() && DstTy->isInteger()&& SrcBitSize > DstBitSize;
case Instruction::ZExt:
- return SrcTy->isIntegral() && DstTy->isIntegral()&& SrcBitSize < DstBitSize;
+ return SrcTy->isInteger() && DstTy->isInteger()&& SrcBitSize < DstBitSize;
case Instruction::SExt:
- return SrcTy->isIntegral() && DstTy->isIntegral()&& SrcBitSize < DstBitSize;
+ return SrcTy->isInteger() && DstTy->isInteger()&& SrcBitSize < DstBitSize;
case Instruction::FPTrunc:
return SrcTy->isFloatingPoint() && DstTy->isFloatingPoint() &&
SrcBitSize > DstBitSize;
return SrcTy->isFloatingPoint() && DstTy->isFloatingPoint() &&
SrcBitSize < DstBitSize;
case Instruction::UIToFP:
- return SrcTy->isIntegral() && DstTy->isFloatingPoint();
+ return SrcTy->isInteger() && DstTy->isFloatingPoint();
case Instruction::SIToFP:
- return SrcTy->isIntegral() && DstTy->isFloatingPoint();
+ return SrcTy->isInteger() && DstTy->isFloatingPoint();
case Instruction::FPToUI:
- return SrcTy->isFloatingPoint() && DstTy->isIntegral();
+ return SrcTy->isFloatingPoint() && DstTy->isInteger();
case Instruction::FPToSI:
- return SrcTy->isFloatingPoint() && DstTy->isIntegral();
+ return SrcTy->isFloatingPoint() && DstTy->isInteger();
case Instruction::PtrToInt:
- return isa<PointerType>(SrcTy) && DstTy->isIntegral();
+ return isa<PointerType>(SrcTy) && DstTy->isInteger();
case Instruction::IntToPtr:
- return SrcTy->isIntegral() && isa<PointerType>(DstTy);
+ return SrcTy->isInteger() && isa<PointerType>(DstTy);
case Instruction::BitCast:
// BitCast implies a no-op cast of type only. No bits change.
// However, you can't cast pointers to anything but pointers.
assert(Op0Ty == Op1Ty &&
"Both operands to ICmp instruction are not of the same type!");
// Check that the operands are the right type
- assert(Op0Ty->isIntegral() || isa<PointerType>(Op0Ty) ||
+ assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
(isa<PackedType>(Op0Ty) &&
- cast<PackedType>(Op0Ty)->getElementType()->isIntegral()) &&
+ cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
"Invalid operand types for ICmp instruction");
return;
}
assert(Op0Ty == Op1Ty &&
"Both operands to ICmp instruction are not of the same type!");
// Check that the operands are the right type
- assert(Op0Ty->isIntegral() || isa<PointerType>(Op0Ty) ||
+ assert(Op0Ty->isInteger() || isa<PointerType>(Op0Ty) ||
(isa<PackedType>(Op0Ty) &&
- cast<PackedType>(Op0Ty)->getElementType()->isIntegral()) &&
+ cast<PackedType>(Op0Ty)->getElementType()->isInteger()) &&
"Invalid operand types for ICmp instruction");
return;
}
NumElements = NumEl;
assert(NumEl > 0 && "NumEl of a PackedType must be greater than 0");
- assert((ElType->isIntegral() || ElType->isFloatingPoint()) &&
+ assert((ElType->isInteger() || ElType->isFloatingPoint()) &&
"Elements of a PackedType must be a primitive type");
}
unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits();
unsigned DestBitSize = DestTy->getPrimitiveSizeInBits();
- Assert1(SrcTy->isIntegral(), "Trunc only operates on integer", &I);
- Assert1(DestTy->isIntegral(), "Trunc only produces integer", &I);
+ Assert1(SrcTy->isInteger(), "Trunc only operates on integer", &I);
+ Assert1(DestTy->isInteger(), "Trunc only produces integer", &I);
Assert1(SrcBitSize > DestBitSize,"DestTy too big for Trunc", &I);
visitInstruction(I);
const Type *DestTy = I.getType();
// Get the size of the types in bits, we'll need this later
- Assert1(SrcTy->isIntegral(), "ZExt only operates on integer", &I);
- Assert1(DestTy->isIntegral(), "ZExt only produces an integer", &I);
+ Assert1(SrcTy->isInteger(), "ZExt only operates on integer", &I);
+ Assert1(DestTy->isInteger(), "ZExt only produces an integer", &I);
unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits();
unsigned DestBitSize = DestTy->getPrimitiveSizeInBits();
unsigned SrcBitSize = SrcTy->getPrimitiveSizeInBits();
unsigned DestBitSize = DestTy->getPrimitiveSizeInBits();
- Assert1(SrcTy->isIntegral(), "SExt only operates on integer", &I);
- Assert1(DestTy->isIntegral(), "SExt only produces an integer", &I);
+ Assert1(SrcTy->isInteger(), "SExt only operates on integer", &I);
+ Assert1(DestTy->isInteger(), "SExt only produces an integer", &I);
Assert1(SrcBitSize < DestBitSize,"Type too small for SExt", &I);
visitInstruction(I);
const Type *SrcTy = I.getOperand(0)->getType();
const Type *DestTy = I.getType();
- Assert1(SrcTy->isIntegral(),"UInt2FP source must be integral", &I);
+ Assert1(SrcTy->isInteger(),"UInt2FP source must be integral", &I);
Assert1(DestTy->isFloatingPoint(),"UInt2FP result must be FP", &I);
visitInstruction(I);
const Type *SrcTy = I.getOperand(0)->getType();
const Type *DestTy = I.getType();
- Assert1(SrcTy->isIntegral(),"SInt2FP source must be integral", &I);
+ Assert1(SrcTy->isInteger(),"SInt2FP source must be integral", &I);
Assert1(DestTy->isFloatingPoint(),"SInt2FP result must be FP", &I);
visitInstruction(I);
const Type *DestTy = I.getType();
Assert1(SrcTy->isFloatingPoint(),"FP2UInt source must be FP", &I);
- Assert1(DestTy->isIntegral(),"FP2UInt result must be integral", &I);
+ Assert1(DestTy->isInteger(),"FP2UInt result must be integral", &I);
visitInstruction(I);
}
const Type *DestTy = I.getType();
Assert1(SrcTy->isFloatingPoint(),"FPToSI source must be FP", &I);
- Assert1(DestTy->isIntegral(),"FP2ToI result must be integral", &I);
+ Assert1(DestTy->isInteger(),"FP2ToI result must be integral", &I);
visitInstruction(I);
}
const Type *DestTy = I.getType();
Assert1(isa<PointerType>(SrcTy), "PtrToInt source must be pointer", &I);
- Assert1(DestTy->isIntegral(), "PtrToInt result must be integral", &I);
+ Assert1(DestTy->isInteger(), "PtrToInt result must be integral", &I);
visitInstruction(I);
}
const Type *SrcTy = I.getOperand(0)->getType();
const Type *DestTy = I.getType();
- Assert1(SrcTy->isIntegral(), "IntToPtr source must be an integral", &I);
+ Assert1(SrcTy->isInteger(), "IntToPtr source must be an integral", &I);
Assert1(isa<PointerType>(DestTy), "IntToPtr result must be a pointer",&I);
visitInstruction(I);
// Check that logical operators are only used with integral operands.
if (B.getOpcode() == Instruction::And || B.getOpcode() == Instruction::Or ||
B.getOpcode() == Instruction::Xor) {
- Assert1(B.getType()->isIntegral() ||
+ Assert1(B.getType()->isInteger() ||
(isa<PackedType>(B.getType()) &&
- cast<PackedType>(B.getType())->getElementType()->isIntegral()),
+ cast<PackedType>(B.getType())->getElementType()->isInteger()),
"Logical operators only work with integral types!", &B);
Assert1(B.getType() == B.getOperand(0)->getType(),
"Logical operators must have same type for operands and result!",
Assert1(B.getType() == B.getOperand(0)->getType(),
"Arithmetic operators must have same type for operands and result!",
&B);
- Assert1(B.getType()->isIntegral() || B.getType()->isFloatingPoint() ||
+ Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint() ||
isa<PackedType>(B.getType()),
"Arithmetic operators must have integer, fp, or packed type!", &B);
}
Assert1(Op0Ty == Op1Ty,
"Both operands to ICmp instruction are not of the same type!", &IC);
// Check that the operands are the right type
- Assert1(Op0Ty->isIntegral() || isa<PointerType>(Op0Ty),
+ Assert1(Op0Ty->isInteger() || isa<PointerType>(Op0Ty),
"Invalid operand types for ICmp instruction", &IC);
visitInstruction(IC);
}
}
void Verifier::visitShiftInst(ShiftInst &SI) {
- Assert1(SI.getType()->isIntegral(),
+ Assert1(SI.getType()->isInteger(),
"Shift must return an integer result!", &SI);
Assert1(SI.getType() == SI.getOperand(0)->getType(),
"Shift return type must be same as first operand!", &SI);
CppWriter::getCppName(const Type* Ty)
{
// First, handle the primitive types .. easy
- if (Ty->isPrimitiveType() || Ty->isIntegral()) {
+ if (Ty->isPrimitiveType() || Ty->isInteger()) {
switch (Ty->getTypeID()) {
case Type::VoidTyID: return "Type::VoidTy";
case Type::IntegerTyID: {
bool
CppWriter::printTypeInternal(const Type* Ty) {
// We don't print definitions for primitive types
- if (Ty->isPrimitiveType() || Ty->isIntegral())
+ if (Ty->isPrimitiveType() || Ty->isInteger())
return false;
// If we already defined this type, we don't need to define it again.
// For primitive types and types already defined, just add a name
TypeMap::const_iterator TNI = TypeNames.find(TI->second);
- if (TI->second->isIntegral() || TI->second->isPrimitiveType() ||
+ if (TI->second->isInteger() || TI->second->isPrimitiveType() ||
TNI != TypeNames.end()) {
Out << "mod->addTypeName(\"";
printEscapedString(TI->first);