From 8c65f6e71c1d46d823b9a884819992a9255edd54 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 5 Jan 2010 21:05:54 +0000 Subject: [PATCH] Move remaining stuff to the isInteger predicate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92771 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 5 ++--- lib/AsmParser/LLParser.cpp | 2 +- lib/CodeGen/StackProtector.cpp | 2 +- lib/ExecutionEngine/ExecutionEngine.cpp | 8 +++---- lib/ExecutionEngine/JIT/JIT.cpp | 2 +- lib/Target/X86/X86ISelLowering.cpp | 3 +-- lib/Transforms/IPO/GlobalOpt.cpp | 2 +- .../InstCombine/InstCombineCalls.cpp | 2 +- .../InstCombine/InstructionCombining.cpp | 3 +-- .../Instrumentation/ProfilingUtils.cpp | 2 +- lib/Transforms/Scalar/SimplifyLibCalls.cpp | 21 ++++++++----------- lib/VMCore/ConstantFold.cpp | 8 +++---- lib/VMCore/Constants.cpp | 4 ++-- lib/VMCore/Instructions.cpp | 7 +++---- 14 files changed, 31 insertions(+), 40 deletions(-) diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index acd3119abea..9a106248126 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -1348,7 +1348,7 @@ bool llvm::GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset, // Make sure the index-ee is a pointer to array of i8. const PointerType *PT = cast(GEP->getOperand(0)->getType()); const ArrayType *AT = dyn_cast(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 @@ -1387,8 +1387,7 @@ bool llvm::GetConstantStringInfo(Value *V, std::string &Str, uint64_t Offset, // Must be a Constant Array ConstantArray *Array = dyn_cast(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 diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp index 0a3617575ef..ca001c1f09d 100644 --- a/lib/AsmParser/LLParser.cpp +++ b/lib/AsmParser/LLParser.cpp @@ -3656,7 +3656,7 @@ int LLParser::ParseAlloc(Instruction *&Inst, PerFunctionState &PFS, } } - if (Size && Size->getType() != Type::getInt32Ty(Context)) + if (Size && !Size->getType()->isInteger(32)) return Error(SizeLoc, "element count must be i32"); if (isAlloca) { diff --git a/lib/CodeGen/StackProtector.cpp b/lib/CodeGen/StackProtector.cpp index e8ee82213a4..48bb5af4db3 100644 --- a/lib/CodeGen/StackProtector.cpp +++ b/lib/CodeGen/StackProtector.cpp @@ -113,7 +113,7 @@ bool StackProtector::RequiresStackProtector() const { if (const ArrayType *AT = dyn_cast(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, diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 35e69229e74..c466400393e 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -356,7 +356,7 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn, } // 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 @@ -618,13 +618,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { 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: - assert(DestTy == Type::getInt64Ty(DestTy->getContext()) && - "Invalid bitcast"); + assert(DestTy->isInteger(64) && "Invalid bitcast"); GV.IntVal.doubleToBits(GV.DoubleVal); break; case Type::PointerTyID: diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index f8165ce2235..faf724fa854 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -411,7 +411,7 @@ GenericValue JIT::runFunction(Function *F, // 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) && diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 1fdb494a1fe..0367165f5c4 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -7535,8 +7535,7 @@ bool X86TargetLowering::isTruncateFree(EVT VT1, EVT VT2) const { 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 { diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 54a96cf0d35..2555ed59f57 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -1925,7 +1925,7 @@ GlobalVariable *GlobalOpt::FindGlobalCtors(Module &M) { if (!ATy) return 0; const StructType *STy = dyn_cast(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(STy->getElementType(1)); if (!PFTy) return 0; const FunctionType *FTy = dyn_cast(PFTy->getElementType()); diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index da5465988a8..6aacf5dd0ef 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -199,7 +199,7 @@ Instruction *InstCombiner::SimplifyMemSet(MemSetInst *MI) { // Extract the length and alignment and fill if they are constant. ConstantInt *LenC = dyn_cast(MI->getLength()); ConstantInt *FillC = dyn_cast(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(); diff --git a/lib/Transforms/InstCombine/InstructionCombining.cpp b/lib/Transforms/InstCombine/InstructionCombining.cpp index 6064cc5b0de..60231857222 100644 --- a/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -596,8 +596,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { // (where tmp = 8*tmp2) into: // getelementptr [100 x double]* %arr, i32 0, i32 %tmp2; bitcast - if (TD && isa(SrcElTy) && - ResElTy == Type::getInt8Ty(GEP.getContext())) { + if (TD && isa(SrcElTy) && ResElTy->isInteger(8)) { uint64_t ArrayEltSize = TD->getTypeAllocSize(cast(SrcElTy)->getElementType()); diff --git a/lib/Transforms/Instrumentation/ProfilingUtils.cpp b/lib/Transforms/Instrumentation/ProfilingUtils.cpp index 1679bea08c1..3214c8c4595 100644 --- a/lib/Transforms/Instrumentation/ProfilingUtils.cpp +++ b/lib/Transforms/Instrumentation/ProfilingUtils.cpp @@ -84,7 +84,7 @@ void llvm::InsertProfilingInitCall(Function *MainFn, const char *FnName, 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); diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp index 43a34185604..becb9a48b28 100644 --- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp @@ -505,8 +505,7 @@ static uint64_t GetStringLengthH(Value *V, SmallPtrSet &PHIs) { // Must be a Constant Array ConstantArray *Array = dyn_cast(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 @@ -678,9 +677,7 @@ struct StrChrOpt : public LibCallOptimization { 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. @@ -722,7 +719,7 @@ struct StrCmpOpt : public LibCallOptimization { // 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; @@ -770,7 +767,7 @@ struct StrNCmpOpt : public LibCallOptimization { // 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(FT->getParamType(2))) @@ -991,7 +988,7 @@ struct MemCmpOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); if (FT->getNumParams() != 3 || !isa(FT->getParamType(0)) || !isa(FT->getParamType(1)) || - FT->getReturnType() != Type::getInt32Ty(*Context)) + !FT->getReturnType()->isInteger(32)) return 0; Value *LHS = CI->getOperand(1), *RHS = CI->getOperand(2); @@ -1353,7 +1350,7 @@ struct FFSOpt : public LibCallOptimization { // 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(FT->getParamType(0))) return 0; @@ -1389,7 +1386,7 @@ struct IsDigitOpt : public LibCallOptimization { const FunctionType *FT = Callee->getFunctionType(); // We require integer(i32) if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || - FT->getParamType(0) != Type::getInt32Ty(*Context)) + !FT->getParamType(0)->isInteger(32)) return 0; // isdigit(c) -> (c-'0') getFunctionType(); // We require integer(i32) if (FT->getNumParams() != 1 || !isa(FT->getReturnType()) || - FT->getParamType(0) != Type::getInt32Ty(*Context)) + !FT->getParamType(0)->isInteger(32)) return 0; // isascii(c) -> c 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 diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 87220dee08a..3a24389134e 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1229,10 +1229,10 @@ static int IdxCompare(LLVMContext &Context, Constant *C1, Constant *C2, // 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)); - 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 @@ -2042,10 +2042,10 @@ Constant *llvm::ConstantFoldGetElementPtr(LLVMContext &Context, // 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)); - if (Div->getType() != Type::getInt64Ty(Context)) + if (!Div->getType()->isInteger(64)) Div = ConstantExpr::getSExt(Div, Type::getInt64Ty(Context)); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 73973e1afc2..cc8961fb5f5 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -928,7 +928,7 @@ void ConstantArray::destroyConstant() { /// 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. @@ -943,7 +943,7 @@ bool ConstantArray::isString() const { /// 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. diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index b95fc9a70af..3733b6a7769 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1391,8 +1391,7 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index, bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) { - if (!isa(Val->getType()) || - Index->getType() != Type::getInt32Ty(Val->getContext())) + if (!isa(Val->getType()) || !Index->getType()->isInteger(32)) return false; return true; } @@ -1439,7 +1438,7 @@ bool InsertElementInst::isValidOperands(const Value *Vec, const Value *Elt, if (Elt->getType() != cast(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; } @@ -1491,7 +1490,7 @@ bool ShuffleVectorInst::isValidOperands(const Value *V1, const Value *V2, const VectorType *MaskTy = dyn_cast(Mask->getType()); if (!isa(Mask) || MaskTy == 0 || - MaskTy->getElementType() != Type::getInt32Ty(V1->getContext())) + !MaskTy->getElementType()->isInteger(32)) return false; return true; } -- 2.34.1