14 files changed:
// Make sure the index-ee is a pointer to array of i8.
const PointerType *PT = cast<PointerType>(GEP->getOperand(0)->getType());
const ArrayType *AT = dyn_cast<ArrayType>(PT->getElementType());
// Make sure the index-ee is a pointer to array of i8.
const PointerType *PT = cast<PointerType>(GEP->getOperand(0)->getType());
const ArrayType *AT = dyn_cast<ArrayType>(PT->getElementType());
- if (AT == 0 || AT->getElementType() != Type::getInt8Ty(V->getContext()))
+ if (AT == 0 || !AT->getElementType()->isInteger(8))
return false;
// Check to make sure that the first operand of the GEP is an integer and
return false;
// Check to make sure that the first operand of the GEP is an integer and
// Must be a Constant Array
ConstantArray *Array = dyn_cast<ConstantArray>(GlobalInit);
// Must be a Constant Array
ConstantArray *Array = dyn_cast<ConstantArray>(GlobalInit);
- if (Array == 0 ||
- Array->getType()->getElementType() != Type::getInt8Ty(V->getContext()))
+ if (Array == 0 || !Array->getType()->getElementType()->isInteger(8))
return false;
// Get the number of elements in the array
return false;
// Get the number of elements in the array
- if (Size && Size->getType() != Type::getInt32Ty(Context))
+ if (Size && !Size->getType()->isInteger(32))
return Error(SizeLoc, "element count must be i32");
if (isAlloca) {
return Error(SizeLoc, "element count must be i32");
if (isAlloca) {
if (const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType())) {
// We apparently only care about character arrays.
if (const ArrayType *AT = dyn_cast<ArrayType>(AI->getAllocatedType())) {
// We apparently only care about character arrays.
- if (AT->getElementType() != Type::getInt8Ty(AT->getContext()))
+ if (!AT->getElementType()->isInteger(8))
continue;
// If an array has more than SSPBufferSize bytes of allocated space,
continue;
// If an array has more than SSPBufferSize bytes of allocated space,
}
// FALLS THROUGH
case 1:
}
// FALLS THROUGH
case 1:
- if (FTy->getParamType(0) != Type::getInt32Ty(Fn->getContext())) {
+ if (!FTy->getParamType(0)->isInteger(32)) {
llvm_report_error("Invalid type for first argument of main() supplied");
}
// FALLS THROUGH
llvm_report_error("Invalid type for first argument of main() supplied");
}
// FALLS THROUGH
GV.DoubleVal = GV.IntVal.bitsToDouble();
break;
case Type::FloatTyID:
GV.DoubleVal = GV.IntVal.bitsToDouble();
break;
case Type::FloatTyID:
- assert(DestTy == Type::getInt32Ty(DestTy->getContext()) &&
- "Invalid bitcast");
+ assert(DestTy->isInteger(32) && "Invalid bitcast");
GV.IntVal.floatToBits(GV.FloatVal);
break;
case Type::DoubleTyID:
GV.IntVal.floatToBits(GV.FloatVal);
break;
case Type::DoubleTyID:
- assert(DestTy == Type::getInt64Ty(DestTy->getContext()) &&
- "Invalid bitcast");
+ assert(DestTy->isInteger(64) && "Invalid bitcast");
GV.IntVal.doubleToBits(GV.DoubleVal);
break;
case Type::PointerTyID:
GV.IntVal.doubleToBits(GV.DoubleVal);
break;
case Type::PointerTyID:
// Handle some common cases first. These cases correspond to common `main'
// prototypes.
// Handle some common cases first. These cases correspond to common `main'
// prototypes.
- if (RetTy == Type::getInt32Ty(F->getContext()) || RetTy->isVoidTy()) {
+ if (RetTy->isInteger(32) || RetTy->isVoidTy()) {
switch (ArgValues.size()) {
case 3:
if (FTy->getParamType(0)->isInteger(32) &&
switch (ArgValues.size()) {
case 3:
if (FTy->getParamType(0)->isInteger(32) &&
bool X86TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const {
// x86-64 implicitly zero-extends 32-bit results in 64-bit registers.
bool X86TargetLowering::isZExtFree(const Type *Ty1, const Type *Ty2) const {
// x86-64 implicitly zero-extends 32-bit results in 64-bit registers.
- return Ty1 == Type::getInt32Ty(Ty1->getContext()) &&
- Ty2 == Type::getInt64Ty(Ty1->getContext()) && Subtarget->is64Bit();
+ return Ty1->isInteger(64) && Ty2->isInteger(64) && Subtarget->is64Bit();
}
bool X86TargetLowering::isZExtFree(EVT VT1, EVT VT2) const {
}
bool X86TargetLowering::isZExtFree(EVT VT1, EVT VT2) const {
if (!ATy) return 0;
const StructType *STy = dyn_cast<StructType>(ATy->getElementType());
if (!STy || STy->getNumElements() != 2 ||
if (!ATy) return 0;
const StructType *STy = dyn_cast<StructType>(ATy->getElementType());
if (!STy || STy->getNumElements() != 2 ||
- STy->getElementType(0) != Type::getInt32Ty(M.getContext())) return 0;
+ !STy->getElementType(0)->isInteger(32)) return 0;
const PointerType *PFTy = dyn_cast<PointerType>(STy->getElementType(1));
if (!PFTy) return 0;
const FunctionType *FTy = dyn_cast<FunctionType>(PFTy->getElementType());
const PointerType *PFTy = dyn_cast<PointerType>(STy->getElementType(1));
if (!PFTy) return 0;
const FunctionType *FTy = dyn_cast<FunctionType>(PFTy->getElementType());
// Extract the length and alignment and fill if they are constant.
ConstantInt *LenC = dyn_cast<ConstantInt>(MI->getLength());
ConstantInt *FillC = dyn_cast<ConstantInt>(MI->getValue());
// Extract the length and alignment and fill if they are constant.
ConstantInt *LenC = dyn_cast<ConstantInt>(MI->getLength());
ConstantInt *FillC = dyn_cast<ConstantInt>(MI->getValue());
- if (!LenC || !FillC || FillC->getType() != Type::getInt8Ty(MI->getContext()))
+ if (!LenC || !FillC || !FillC->getType()->isInteger(8))
return 0;
uint64_t Len = LenC->getZExtValue();
Alignment = MI->getAlignment();
return 0;
uint64_t Len = LenC->getZExtValue();
Alignment = MI->getAlignment();
// (where tmp = 8*tmp2) into:
// getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast
// (where tmp = 8*tmp2) into:
// getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast
- if (TD && isa<ArrayType>(SrcElTy) &&
- ResElTy == Type::getInt8Ty(GEP.getContext())) {
+ if (TD && isa<ArrayType>(SrcElTy) && ResElTy->isInteger(8)) {
uint64_t ArrayEltSize =
TD->getTypeAllocSize(cast<ArrayType>(SrcElTy)->getElementType());
uint64_t ArrayEltSize =
TD->getTypeAllocSize(cast<ArrayType>(SrcElTy)->getElementType());
AI = MainFn->arg_begin();
// If the program looked at argc, have it look at the return value of the
// init call instead.
AI = MainFn->arg_begin();
// If the program looked at argc, have it look at the return value of the
// init call instead.
- if (AI->getType() != Type::getInt32Ty(Context)) {
+ if (!AI->getType()->isInteger(32)) {
Instruction::CastOps opcode;
if (!AI->use_empty()) {
opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
Instruction::CastOps opcode;
if (!AI->use_empty()) {
opcode = CastInst::getCastOpcode(InitCall, true, AI->getType(), true);
// Must be a Constant Array
ConstantArray *Array = dyn_cast<ConstantArray>(GlobalInit);
// Must be a Constant Array
ConstantArray *Array = dyn_cast<ConstantArray>(GlobalInit);
- if (!Array ||
- Array->getType()->getElementType() != Type::getInt8Ty(V->getContext()))
+ if (!Array || !Array->getType()->getElementType()->isInteger(8))
return false;
// Get the number of elements in the array
return false;
// Get the number of elements in the array
if (!TD) return 0;
uint64_t Len = GetStringLength(SrcStr);
if (!TD) return 0;
uint64_t Len = GetStringLength(SrcStr);
- if (Len == 0 ||
- FT->getParamType(1) != Type::getInt32Ty(*Context)) // memchr needs
- // i32.
+ if (Len == 0 || !FT->getParamType(1)->isInteger(32)) // memchr needs i32.
return 0;
return EmitMemChr(SrcStr, CI->getOperand(2), // include nul.
return 0;
return EmitMemChr(SrcStr, CI->getOperand(2), // include nul.
// Verify the "strcmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
// Verify the "strcmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 2 ||
- FT->getReturnType() != Type::getInt32Ty(*Context) ||
+ !FT->getReturnType()->isInteger(32) ||
FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Type::getInt8PtrTy(*Context))
return 0;
FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Type::getInt8PtrTy(*Context))
return 0;
// Verify the "strncmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 ||
// Verify the "strncmp" function prototype.
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 ||
- FT->getReturnType() != Type::getInt32Ty(*Context) ||
+ !FT->getReturnType()->isInteger(32) ||
FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Type::getInt8PtrTy(*Context) ||
!isa<IntegerType>(FT->getParamType(2)))
FT->getParamType(0) != FT->getParamType(1) ||
FT->getParamType(0) != Type::getInt8PtrTy(*Context) ||
!isa<IntegerType>(FT->getParamType(2)))
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || !isa<PointerType>(FT->getParamType(0)) ||
!isa<PointerType>(FT->getParamType(1)) ||
const FunctionType *FT = Callee->getFunctionType();
if (FT->getNumParams() != 3 || !isa<PointerType>(FT->getParamType(0)) ||
!isa<PointerType>(FT->getParamType(1)) ||
- FT->getReturnType() != Type::getInt32Ty(*Context))
+ !FT->getReturnType()->isInteger(32))
return 0;
Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2);
return 0;
Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2);
// Just make sure this has 2 arguments of the same FP type, which match the
// result type.
if (FT->getNumParams() != 1 ||
// Just make sure this has 2 arguments of the same FP type, which match the
// result type.
if (FT->getNumParams() != 1 ||
- FT->getReturnType() != Type::getInt32Ty(*Context) ||
+ !FT->getReturnType()->isInteger(32) ||
!isa<IntegerType>(FT->getParamType(0)))
return 0;
!isa<IntegerType>(FT->getParamType(0)))
return 0;
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
- FT->getParamType(0) != Type::getInt32Ty(*Context))
+ !FT->getParamType(0)->isInteger(32))
return 0;
// isdigit(c) -> (c-'0') <u 10
return 0;
// isdigit(c) -> (c-'0') <u 10
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
const FunctionType *FT = Callee->getFunctionType();
// We require integer(i32)
if (FT->getNumParams() != 1 || !isa<IntegerType>(FT->getReturnType()) ||
- FT->getParamType(0) != Type::getInt32Ty(*Context))
+ !FT->getParamType(0)->isInteger(32))
return 0;
// isascii(c) -> c <u 128
return 0;
// isascii(c) -> c <u 128
const FunctionType *FT = Callee->getFunctionType();
// We require i32(i32)
if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) ||
const FunctionType *FT = Callee->getFunctionType();
// We require i32(i32)
if (FT->getNumParams() != 1 || FT->getReturnType() != FT->getParamType(0) ||
- FT->getParamType(0) != Type::getInt32Ty(*Context))
+ !FT->getParamType(0)->isInteger(32))
return 0;
// isascii(c) -> c & 0x7f
return 0;
// isascii(c) -> c & 0x7f
// Ok, we have two differing integer indices. Sign extend them to be the same
// type. Long is always big enough, so we use it.
// Ok, we have two differing integer indices. Sign extend them to be the same
// type. Long is always big enough, so we use it.
- if (C1->getType() != Type::getInt64Ty(Context))
+ if (!C1->getType()->isInteger(64))
C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(Context));
C1 = ConstantExpr::getSExt(C1, Type::getInt64Ty(Context));
- if (C2->getType() != Type::getInt64Ty(Context))
+ if (!C2->getType()->isInteger(64))
C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(Context));
if (C1 == C2) return 0; // They are equal
C2 = ConstantExpr::getSExt(C2, Type::getInt64Ty(Context));
if (C1 == C2) return 0; // They are equal
// Before adding, extend both operands to i64 to avoid
// overflow trouble.
// Before adding, extend both operands to i64 to avoid
// overflow trouble.
- if (PrevIdx->getType() != Type::getInt64Ty(Context))
+ if (!PrevIdx->getType()->isInteger(64))
PrevIdx = ConstantExpr::getSExt(PrevIdx,
Type::getInt64Ty(Context));
PrevIdx = ConstantExpr::getSExt(PrevIdx,
Type::getInt64Ty(Context));
- if (Div->getType() != Type::getInt64Ty(Context))
+ if (!Div->getType()->isInteger(64))
Div = ConstantExpr::getSExt(Div,
Type::getInt64Ty(Context));
Div = ConstantExpr::getSExt(Div,
Type::getInt64Ty(Context));
/// if the elements of the array are all ConstantInt's.
bool ConstantArray::isString() const {
// Check the element type for i8...
/// if the elements of the array are all ConstantInt's.
bool ConstantArray::isString() const {
// Check the element type for i8...
- if (getType()->getElementType() != Type::getInt8Ty(getContext()))
+ if (!getType()->getElementType()->isInteger(8))
return false;
// Check the elements to make sure they are all integers, not constant
// expressions.
return false;
// Check the elements to make sure they are all integers, not constant
// expressions.
/// null bytes except its terminator.
bool ConstantArray::isCString() const {
// Check the element type for i8...
/// null bytes except its terminator.
bool ConstantArray::isCString() const {
// Check the element type for i8...
- if (getType()->getElementType() != Type::getInt8Ty(getContext()))
+ if (!getType()->getElementType()->isInteger(8))
return false;
// Last element must be a null.
return false;
// Last element must be a null.
bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
- if (!isa<VectorType>(Val->getType()) ||
- Index->getType() != Type::getInt32Ty(Val->getContext()))
+ if (!isa<VectorType>(Val->getType()) || !Index->getType()->isInteger(32))
return false;
return true;
}
return false;
return true;
}
if (Elt->getType() != cast<VectorType>(Vec->getType())->getElementType())
return false;// Second operand of insertelement must be vector element type.
if (Elt->getType() != cast<VectorType>(Vec->getType())->getElementType())
return false;// Second operand of insertelement must be vector element type.
- if (Index->getType() != Type::getInt32Ty(Vec->getContext()))
+ if (!Index->getType()->isInteger(32))
return false; // Third operand of insertelement must be i32.
return true;
}
return false; // Third operand of insertelement must be i32.
return true;
}
const VectorType *MaskTy = dyn_cast<VectorType>(Mask->getType());
if (!isa<Constant>(Mask) || MaskTy == 0 ||
const VectorType *MaskTy = dyn_cast<VectorType>(Mask->getType());
if (!isa<Constant>(Mask) || MaskTy == 0 ||
- MaskTy->getElementType() != Type::getInt32Ty(V1->getContext()))
+ !MaskTy->getElementType()->isInteger(32))
return false;
return true;
}
return false;
return true;
}