From jay.foad at gmail.com Mon Jul 11 02:28:50 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 07:28:50 -0000 Subject: [llvm-commits] [llvm] r134887 - /llvm/trunk/lib/VMCore/AsmWriter.cpp Message-ID: <20110711072850.238272A6C12C@llvm.org> Author: foad Date: Mon Jul 11 02:28:49 2011 New Revision: 134887 URL: http://llvm.org/viewvc/llvm-project?rev=134887&view=rev Log: Remove mentions of type planes. Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=134887&r1=134886&r2=134887&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/AsmWriter.cpp (original) +++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon Jul 11 02:28:49 2011 @@ -311,11 +311,11 @@ const Function* TheFunction; bool FunctionProcessed; - /// mMap - The TypePlanes map for the module level data. + /// mMap - The slot map for the module level data. ValueMap mMap; unsigned mNext; - /// fMap - The TypePlanes map for the function level data. + /// fMap - The slot map for the function level data. ValueMap fMap; unsigned fNext; @@ -536,7 +536,7 @@ // Check for uninitialized state and do lazy initialization. initialize(); - // Find the type plane in the module map + // Find the value in the module map ValueMap::iterator MI = mMap.find(V); return MI == mMap.end() ? -1 : (int)MI->second; } @@ -546,7 +546,7 @@ // Check for uninitialized state and do lazy initialization. initialize(); - // Find the type plane in the module map + // Find the MDNode in the module map mdn_iterator MI = mdnMap.find(N); return MI == mdnMap.end() ? -1 : (int)MI->second; } From jay.foad at gmail.com Mon Jul 11 02:56:41 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 07:56:41 -0000 Subject: [llvm-commits] [llvm] r134888 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ unittests/Analysis/ unittests/ExecutionEngine/JIT/ unittests/Support/ unittests/VMCore/ Message-ID: <20110711075642.18E002A6C12C@llvm.org> Author: foad Date: Mon Jul 11 02:56:41 2011 New Revision: 134888 URL: http://llvm.org/viewvc/llvm-project?rev=134888&view=rev Log: De-constify Types in FunctionType::get(). Modified: llvm/trunk/include/llvm/DerivedTypes.h llvm/trunk/include/llvm/Intrinsics.h llvm/trunk/include/llvm/Support/TypeBuilder.h llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/IRBuilder.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp llvm/trunk/unittests/Support/TypeBuilderTest.cpp llvm/trunk/unittests/VMCore/PassManagerTest.cpp Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 02:56:41 2011 @@ -103,8 +103,6 @@ /// a FunctionType. /// static FunctionType *get(const Type *Result, - ArrayRef Params, bool isVarArg); - static FunctionType *get(const Type *Result, ArrayRef Params, bool isVarArg); /// FunctionType::get - Create a FunctionType taking no parameters. Modified: llvm/trunk/include/llvm/Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.h (original) +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 02:56:41 2011 @@ -44,12 +44,12 @@ /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". - std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); + std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// const FunctionType *getType(LLVMContext &Context, ID id, - const Type **Tys = 0, unsigned numTys = 0); + Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. @@ -67,7 +67,7 @@ /// overloaded intrinsic, Tys should point to an array of numTys pointers to /// Type, and must provide exactly one type for each overloaded type in the /// intrinsic. - Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, + Function *getDeclaration(Module *M, ID id, Type **Tys = 0, unsigned numTys = 0); /// Map a GCC builtin name to an intrinsic ID. Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 02:56:41 2011 @@ -51,7 +51,7 @@ /// namespace llvm { /// template class TypeBuilder { /// public: -/// static const StructType *get(LLVMContext &Context) { +/// static StructType *get(LLVMContext &Context) { /// // If you cache this result, be sure to cache it separately /// // for each LLVMContext. /// return StructType::get( @@ -104,7 +104,7 @@ // Pointers template class TypeBuilder { public: - static const PointerType *get(LLVMContext &Context) { + static PointerType *get(LLVMContext &Context) { return PointerType::getUnqual(TypeBuilder::get(Context)); } }; @@ -115,14 +115,14 @@ // Arrays template class TypeBuilder { public: - static const ArrayType *get(LLVMContext &Context) { + static ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), N); } }; /// LLVM uses an array of length 0 to represent an unknown-length array. template class TypeBuilder { public: - static const ArrayType *get(LLVMContext &Context) { + static ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), 0); } }; @@ -152,7 +152,7 @@ #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ template<> class TypeBuilder { \ public: \ - static const IntegerType *get(LLVMContext &Context) { \ + static IntegerType *get(LLVMContext &Context) { \ return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ } \ }; \ @@ -181,14 +181,14 @@ template class TypeBuilder, cross> { public: - static const IntegerType *get(LLVMContext &C) { + static IntegerType *get(LLVMContext &C) { return IntegerType::get(C, num_bits); } }; template<> class TypeBuilder { public: - static const Type *get(LLVMContext& C) { + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; @@ -196,7 +196,7 @@ template<> class TypeBuilder { public: - static const Type *get(LLVMContext& C) { + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; @@ -204,32 +204,32 @@ template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } + static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } + static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } + static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } + static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } }; template class TypeBuilder { public: - static const Type *get(LLVMContext &C) { + static Type *get(LLVMContext &C) { return Type::getVoidTy(C); } }; @@ -247,14 +247,14 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { + static FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), false); } }; template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), @@ -264,8 +264,8 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -276,8 +276,8 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -291,8 +291,8 @@ bool cross> class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -307,8 +307,8 @@ typename A5, bool cross> class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -322,15 +322,15 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { + static FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), true); } }; template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), params, true); @@ -339,8 +339,8 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -351,8 +351,8 @@ template class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -366,8 +366,8 @@ bool cross> class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -382,8 +382,8 @@ typename A5, bool cross> class TypeBuilder { public: - static const FunctionType *get(LLVMContext &Context) { - std::vector params; + static FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 02:56:41 2011 @@ -1442,7 +1442,7 @@ "argument attributes invalid in function type"); } - SmallVector ArgListTy; + SmallVector ArgListTy; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ArgListTy.push_back(ArgList[i].Ty); @@ -2655,7 +2655,7 @@ // Okay, if we got here, the function is syntactically valid. Convert types // and do semantic checks. - std::vector ParamTypeList; + std::vector ParamTypeList; SmallVector Attrs; if (RetAttrs != Attribute::None) @@ -3171,7 +3171,7 @@ if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); @@ -3508,7 +3508,7 @@ if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 02:56:41 2011 @@ -582,7 +582,7 @@ // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *T = getTypeByID(Record[i])) ArgTys.push_back(T); @@ -838,7 +838,7 @@ // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *Elt = getTypeByIDOrNull(Record[i])) ArgTys.push_back(Elt); Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 02:56:41 2011 @@ -497,10 +497,8 @@ // Find the rewind function if we didn't already. if (!RewindFunction) { LLVMContext &Ctx = ResumeInsts[0]->getContext(); - std::vector - Params(1, Type::getInt8PtrTy(Ctx)); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), - Params, false); + Type::getInt8PtrTy(Ctx), false); const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); } Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 02:56:41 2011 @@ -29,7 +29,7 @@ ArgIt ArgBegin, ArgIt ArgEnd, const Type *RetTy) { // Insert a correctly-typed definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back(I->getType()); M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); @@ -69,7 +69,7 @@ // program already contains a function with this name. Module *M = CI->getParent()->getParent()->getParent(); // Get or insert the definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back((*I)->getType()); Constant* FCache = M->getOrInsertFunction(NewFn, @@ -553,12 +553,12 @@ !CI->getType()->isIntegerTy()) return false; - const IntegerType *Ty = dyn_cast(CI->getType()); + IntegerType *Ty = dyn_cast(CI->getType()); if (!Ty) return false; // Okay, we can do this xform, do so now. - const Type *Tys[] = { Ty }; + Type *Tys[] = { Ty }; Module *M = CI->getParent()->getParent()->getParent(); Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 @@ -83,7 +83,7 @@ static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 @@ -92,7 +92,7 @@ static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 02:56:41 2011 @@ -493,7 +493,7 @@ // Start by computing a new prototype for the function, which is the same as // the old function, but has modified arguments. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; typedef std::set ScalarizeTable; Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 02:56:41 2011 @@ -208,7 +208,7 @@ // the old function, but doesn't have isVarArg set. const FunctionType *FTy = Fn.getFunctionType(); - std::vector Params(FTy->param_begin(), FTy->param_end()); + std::vector Params(FTy->param_begin(), FTy->param_end()); FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false); unsigned NumArgs = Params.size(); @@ -647,7 +647,7 @@ // Start by computing a new prototype for the function, which is the same as // the old function, but has fewer arguments and a different return type. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; // Set up to build a new list of parameter attributes. SmallVector AttributesVec; Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 02:56:41 2011 @@ -1400,7 +1400,7 @@ /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. /// If so, insert the new bswap intrinsic and return it. Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { - const IntegerType *ITy = dyn_cast(I.getType()); + IntegerType *ITy = dyn_cast(I.getType()); if (!ITy || ITy->getBitWidth() % 16 || // ByteMask only allows up to 32-byte values. ITy->getBitWidth() > 32*8) @@ -1424,7 +1424,7 @@ for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) if (ByteValues[i] != V) return 0; - const Type *Tys[] = { ITy }; + Type *Tys[] = { ITy }; Module *M = I.getParent()->getParent()->getParent(); Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); return CallInst::Create(F, V); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 02:56:41 2011 @@ -217,9 +217,9 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - const Type *Tys[3] = { CI.getArgOperand(0)->getType(), - CI.getArgOperand(1)->getType(), - CI.getArgOperand(2)->getType() }; + Type *Tys[3] = { CI.getArgOperand(0)->getType(), + CI.getArgOperand(1)->getType(), + CI.getArgOperand(2)->getType() }; CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); Changed = true; } @@ -1187,7 +1187,7 @@ const AttrListPtr &NestAttrs = NestF->getAttributes(); if (!NestAttrs.isEmpty()) { unsigned NestIdx = 1; - const Type *NestTy = 0; + Type *NestTy = 0; Attributes NestAttr = Attribute::None; // Look for a parameter marked with the 'nest' attribute. @@ -1249,7 +1249,7 @@ // Handle this by synthesizing a new function type, equal to FTy // with the chain parameter inserted. - std::vector NewTypes; + std::vector NewTypes; NewTypes.reserve(FTy->getNumParams()+1); // Insert the chain's type into the list of parameter types, which may Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 02:56:41 2011 @@ -1683,7 +1683,7 @@ // result and the overflow bit. Module *M = I.getParent()->getParent()->getParent(); - const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); + Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, &NewType, 1); @@ -1725,7 +1725,7 @@ Builder->SetInsertPoint(OrigAdd); Module *M = I.getParent()->getParent()->getParent(); - const Type *Ty = LHS->getType(); + Type *Ty = LHS->getType(); Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); Value *Add = Builder->CreateExtractValue(Call, 0); Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 02:56:41 2011 @@ -572,14 +572,13 @@ } Constant *GCOVProfiler::getStartFileFunc() { - const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), - Args, false); + Type::getInt8PtrTy(*Ctx), false); return M->getOrInsertFunction("llvm_gcda_start_file", FTy); } Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { - const Type *Args[] = { + Type *Args[] = { Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row }; @@ -589,7 +588,7 @@ } Constant *GCOVProfiler::getEmitFunctionFunc() { - const Type *Args[2] = { + Type *Args[2] = { Type::getInt32Ty(*Ctx), // uint32_t ident Type::getInt8PtrTy(*Ctx), // const char *function_name }; @@ -599,7 +598,7 @@ } Constant *GCOVProfiler::getEmitArcsFunc() { - const Type *Args[] = { + Type *Args[] = { Type::getInt32Ty(*Ctx), // uint32_t num_counters Type::getInt64PtrTy(*Ctx), // uint64_t *counters }; Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 02:56:41 2011 @@ -840,9 +840,9 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - const Type *ArgTys[3] = { M->getRawDest()->getType(), - M->getRawSource()->getType(), - M->getLength()->getType() }; + Type *ArgTys[3] = { M->getRawDest()->getType(), + M->getRawSource()->getType(), + M->getLength()->getType() }; M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 02:56:41 2011 @@ -1498,8 +1498,8 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { if (!RetainRVCallee) { LLVMContext &C = M->getContext(); - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1515,8 +1515,8 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { if (!AutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1532,7 +1532,7 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) { if (!ReleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1548,7 +1548,7 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) { if (!RetainCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1564,7 +1564,7 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { if (!AutoreleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -3269,9 +3269,9 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { if (!StoreStrongCallee) { LLVMContext &C = M->getContext(); - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - const Type *I8XX = PointerType::getUnqual(I8X); - std::vector Params; + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + Type *I8XX = PointerType::getUnqual(I8X); + std::vector Params; Params.push_back(I8XX); Params.push_back(I8X); @@ -3291,8 +3291,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { if (!RetainAutoreleaseCallee) { LLVMContext &C = M->getContext(); - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -3307,8 +3307,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { if (!RetainAutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 02:56:41 2011 @@ -992,7 +992,7 @@ } // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 - const Type *ArgType = Op->getType(); + Type *ArgType = Op->getType(); Value *F = Intrinsic::getDeclaration(Callee->getParent(), Intrinsic::cttz, &ArgType, 1); Value *V = B.CreateCall(F, Op, "cttz"); Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 02:56:41 2011 @@ -140,7 +140,7 @@ Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo) { - std::vector ArgTypes; + std::vector ArgTypes; // The user might be deleting arguments to the function by specifying them in // the VMap. If so, we need to not add the arguments to the arg ty vector Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 02:56:41 2011 @@ -258,7 +258,7 @@ default: RetTy = Type::getInt16Ty(header->getContext()); break; } - std::vector paramTy; + std::vector paramTy; // Add the types of the input values to the function's argument list for (Values::const_iterator i = inputs.begin(), @@ -279,7 +279,7 @@ } DEBUG(dbgs() << "Function type: " << *RetTy << " f("); - for (std::vector::iterator i = paramTy.begin(), + for (std::vector::iterator i = paramTy.begin(), e = paramTy.end(); i != e; ++i) DEBUG(dbgs() << **i << ", "); DEBUG(dbgs() << ")\n"); Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 02:56:41 2011 @@ -663,7 +663,7 @@ LLVMContext &Context = Arg->getContext(); - const Type *VoidPtrTy = Type::getInt8PtrTy(Context); + Type *VoidPtrTy = Type::getInt8PtrTy(Context); // Create the alloca. If we have TargetData, use nice alignment. unsigned Align = 1; @@ -680,7 +680,7 @@ Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; + Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, Tys, 3); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 02:56:41 2011 @@ -260,7 +260,7 @@ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) Tys.push_back(unwrap(*I)); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 02:56:41 2011 @@ -333,7 +333,7 @@ return 0; } -std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { +std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); static const char * const Table[] = { "not_intrinsic", @@ -356,10 +356,10 @@ } const FunctionType *Intrinsic::getType(LLVMContext &Context, - ID id, const Type **Tys, + ID id, Type **Tys, unsigned numTys) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR @@ -384,7 +384,7 @@ #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_ATTRIBUTES -Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, +Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, unsigned numTys) { // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 02:56:41 2011 @@ -65,7 +65,7 @@ bool isVolatile, MDNode *TBAATag) { Ptr = getCastedInt8PtrValue(Ptr); Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; - const Type *Tys[] = { Ptr->getType(), Size->getType() }; + Type *Tys[] = { Ptr->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); @@ -85,7 +85,7 @@ Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); @@ -105,7 +105,7 @@ Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 02:56:41 2011 @@ -216,8 +216,8 @@ va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (const Type *ArgTy = va_arg(Args, const Type*)) + std::vector ArgTys; + while (Type *ArgTy = va_arg(Args, Type*)) ArgTys.push_back(ArgTy); va_end(Args); @@ -234,8 +234,8 @@ va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (const Type *ArgTy = va_arg(Args, const Type*)) + std::vector ArgTys; + while (Type *ArgTy = va_arg(Args, Type*)) ArgTys.push_back(ArgTy); va_end(Args); Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 02:56:41 2011 @@ -325,13 +325,6 @@ NumContainedTys = Params.size() + 1; // + 1 for result type } -// FIXME: Remove this version. -FunctionType *FunctionType::get(const Type *ReturnType, - ArrayRef Params, bool isVarArg) { - return get(ReturnType, ArrayRef(const_cast(Params.data()), - Params.size()), isVarArg); -} - // FunctionType::get - The factory function for the FunctionType class. FunctionType *FunctionType::get(const Type *ReturnType, ArrayRef Params, bool isVarArg) { @@ -357,7 +350,7 @@ FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { - return get(Result, ArrayRef(), isVarArg); + return get(Result, ArrayRef(), isVarArg); } Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 02:56:41 2011 @@ -23,7 +23,7 @@ Module M("world", Context); const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), - std::vector(), false); + std::vector(), false); Function *F = cast(M.getOrInsertFunction("f", FTy)); BasicBlock *BB = BasicBlock::Create(Context, "entry", F); ReturnInst::Create(Context, 0, BB); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 02:56:41 2011 @@ -21,7 +21,7 @@ namespace { Function *makeFakeFunction() { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); return Function::Create(FTy, GlobalValue::ExternalLinkage); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 02:56:41 2011 @@ -37,7 +37,7 @@ namespace { Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), params, false); Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); @@ -322,7 +322,7 @@ const FunctionType *Func1Ty = cast(TypeBuilder::get(Context)); - std::vector arg_types; + std::vector arg_types; arg_types.push_back(Type::getInt1Ty(Context)); const FunctionType *FuncTy = FunctionType::get( Type::getVoidTy(Context), arg_types, false); Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 02:56:41 2011 @@ -120,7 +120,7 @@ } TEST(TypeBuilderTest, Functions) { - std::vector params; + std::vector params; EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), (TypeBuilder::get(getGlobalContext()))); EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff ============================================================================== --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 02:56:41 2011 @@ -405,13 +405,13 @@ mod->setTargetTriple("x86_64-unknown-linux-gnu"); // Type Definitions - std::vectorFuncTy_0_args; + std::vectorFuncTy_0_args; FunctionType* FuncTy_0 = FunctionType::get( /*Result=*/IntegerType::get(getGlobalContext(), 32), /*Params=*/FuncTy_0_args, /*isVarArg=*/false); - std::vectorFuncTy_2_args; + std::vectorFuncTy_2_args; FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); FunctionType* FuncTy_2 = FunctionType::get( /*Result=*/Type::getVoidTy(getGlobalContext()), From zwarich at apple.com Mon Jul 11 03:35:17 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Mon, 11 Jul 2011 08:35:17 -0000 Subject: [llvm-commits] [llvm] r134889 - /llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll Message-ID: <20110711083517.902702A6C12C@llvm.org> Author: zwarich Date: Mon Jul 11 03:35:17 2011 New Revision: 134889 URL: http://llvm.org/viewvc/llvm-project?rev=134889&view=rev Log: Add a missing test for r134882. Added: llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll Added: llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll?rev=134889&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll (added) +++ llvm/trunk/test/CodeGen/ARM/2011-07-10-GlobalMergeBug.ll Mon Jul 11 03:35:17 2011 @@ -0,0 +1,8 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-p:32:32:32-i1:8:32-i8:8:32-i16:16:32-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:32:64-v128:32:128-a0:0:32-n32" +target triple = "thumbv7-apple-darwin10" + +; CHECK-NOT: MergedGlobals + + at a = internal unnamed_addr global i1 false + at b = internal global [64 x i8] zeroinitializer, align 64 From jay.foad at gmail.com Mon Jul 11 04:56:21 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 09:56:21 -0000 Subject: [llvm-commits] [llvm] r134893 - in /llvm/trunk: include/llvm/DerivedTypes.h include/llvm/Target/TargetData.h lib/CodeGen/SjLjEHPrepare.cpp lib/Target/ARM/ARMGlobalMerge.cpp lib/Target/TargetData.cpp lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/Instrumentation/ProfilingUtils.cpp lib/Transforms/Utils/CodeExtractor.cpp lib/VMCore/Constants.cpp lib/VMCore/Core.cpp lib/VMCore/Type.cpp tools/bugpoint/ExtractFunction.cpp unittests/Support/TypeBuilderTest.cpp Message-ID: <20110711095621.64F512A6C124@llvm.org> Author: foad Date: Mon Jul 11 04:56:20 2011 New Revision: 134893 URL: http://llvm.org/viewvc/llvm-project?rev=134893&view=rev Log: De-constify Types in StructType::get() and TargetData::getIntPtrType(). Modified: llvm/trunk/include/llvm/DerivedTypes.h llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp llvm/trunk/unittests/Support/TypeBuilderTest.cpp Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 04:56:20 2011 @@ -204,11 +204,6 @@ /// StructType::get - This static method is the primary way to create a /// StructType. - /// - /// FIXME: Remove the 'const Type*' version of this when types are pervasively - /// de-constified. - static StructType *get(LLVMContext &Context, ArrayRef Elements, - bool isPacked = false); static StructType *get(LLVMContext &Context, ArrayRef Elements, bool isPacked = false); @@ -220,7 +215,7 @@ /// structure types by specifying the elements as arguments. Note that this /// method always returns a non-packed struct, and requires at least one /// element type. - static StructType *get(const Type *elt1, ...) END_WITH_NULL; + static StructType *get(Type *elt1, ...) END_WITH_NULL; bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; } Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Mon Jul 11 04:56:20 2011 @@ -259,7 +259,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. /// - const IntegerType *getIntPtrType(LLVMContext &C) const; + IntegerType *getIntPtrType(LLVMContext &C) const; /// getIndexedOffset - return the offset from the beginning of the type for /// the specified indices. This is used to implement getelementptr. Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Jul 11 04:56:20 2011 @@ -87,9 +87,8 @@ bool SjLjEHPass::doInitialization(Module &M) { // Build the function context structure. // builtin_setjmp uses a five word jbuf - const Type *VoidPtrTy = - Type::getInt8PtrTy(M.getContext()); - const Type *Int32Ty = Type::getInt32Ty(M.getContext()); + Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext()); + Type *Int32Ty = Type::getInt32Ty(M.getContext()); FunctionContextTy = StructType::get(VoidPtrTy, // __prev Int32Ty, // call_site Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp Mon Jul 11 04:56:20 2011 @@ -128,10 +128,10 @@ for (size_t i = 0, e = Globals.size(); i != e; ) { size_t j = 0; uint64_t MergedSize = 0; - std::vector Tys; + std::vector Tys; std::vector Inits; for (j = i; j != e; ++j) { - const Type *Ty = Globals[j]->getType()->getElementType(); + Type *Ty = Globals[j]->getType()->getElementType(); MergedSize += TD->getTypeAllocSize(Ty); if (MergedSize > MaxOffset) { break; Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Mon Jul 11 04:56:20 2011 @@ -535,7 +535,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. -const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { +IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { return IntegerType::get(C, getPointerSizeInBits()); } Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 04:56:20 2011 @@ -659,13 +659,13 @@ // Find out the new return value. - const Type *RetTy = FTy->getReturnType(); + Type *RetTy = FTy->getReturnType(); const Type *NRetTy = NULL; unsigned RetCount = NumRetVals(F); // -1 means unused, other numbers are the new index SmallVector NewRetIdxs(RetCount, -1); - std::vector RetTypes; + std::vector RetTypes; if (RetTy->isVoidTy()) { NRetTy = RetTy; } else { Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Jul 11 04:56:20 2011 @@ -134,7 +134,7 @@ void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) { // llvm.global_dtors is an array of type { i32, void ()* }. Prepare those // types. - const Type *GlobalDtorElems[2] = { + Type *GlobalDtorElems[2] = { Type::getInt32Ty(Mod->getContext()), FunctionType::get(Type::getVoidTy(Mod->getContext()), false)->getPointerTo() }; Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 04:56:20 2011 @@ -403,7 +403,7 @@ AllocaInst *Struct = 0; if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { - std::vector ArgTypes; + std::vector ArgTypes; for (Values::iterator v = StructValues.begin(), ve = StructValues.end(); v != ve; ++v) ArgTypes.push_back((*v)->getType()); Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 11 04:56:20 2011 @@ -619,7 +619,7 @@ StructType *ConstantStruct::getTypeForElements(LLVMContext &Context, ArrayRef V, bool Packed) { - SmallVector EltTypes; + SmallVector EltTypes; for (unsigned i = 0, e = V.size(); i != e; ++i) EltTypes.push_back(V[i]->getType()); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 04:56:20 2011 @@ -290,7 +290,7 @@ LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ElementTypes, *E = ElementTypes + ElementCount; I != E; ++I) Tys.push_back(unwrap(*I)); Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 04:56:20 2011 @@ -458,22 +458,15 @@ //===----------------------------------------------------------------------===// // StructType Helper functions. -// FIXME: Remove this version. -StructType *StructType::get(LLVMContext &Context, ArrayRefElements, - bool isPacked) { - return get(Context, ArrayRef(const_cast(Elements.data()), - Elements.size()), isPacked); -} - StructType *StructType::get(LLVMContext &Context, bool isPacked) { - return get(Context, llvm::ArrayRef(), isPacked); + return get(Context, llvm::ArrayRef(), isPacked); } -StructType *StructType::get(const Type *type, ...) { +StructType *StructType::get(Type *type, ...) { assert(type != 0 && "Cannot create a struct type with no elements with this"); LLVMContext &Ctx = type->getContext(); va_list ap; - SmallVector StructFields; + SmallVector StructFields; va_start(ap, type); while (type) { StructFields.push_back(type); Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Mon Jul 11 04:56:20 2011 @@ -173,7 +173,7 @@ static Constant *GetTorInit(std::vector > &TorList) { assert(!TorList.empty() && "Don't create empty tor list!"); std::vector ArrayElts; - const Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); + Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); const StructType *STy = StructType::get(Int32Ty, TorList[0].first->getType(), NULL); Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134893&r1=134892&r2=134893&view=diff ============================================================================== --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 04:56:20 2011 @@ -187,7 +187,7 @@ static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); @@ -210,7 +210,7 @@ static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder, cross>::get(Context)); st.push_back(TypeBuilder*, cross>::get(Context)); st.push_back(TypeBuilder*[], cross>::get(Context)); From jay.foad at gmail.com Mon Jul 11 06:11:24 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 11:11:24 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r134894 - in /llvm-gcc-4.2/trunk/gcc: config/alpha/llvm-alpha.cpp config/arm/llvm-arm-target.h config/arm/llvm-arm.cpp config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp config/rs6000/llvm-rs6000.cpp llvm-abi-default.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-internal.h llvm-types.cpp Message-ID: <20110711111124.750C52A6C12C@llvm.org> Author: foad Date: Mon Jul 11 06:11:24 2011 New Revision: 134894 URL: http://llvm.org/viewvc/llvm-project?rev=134894&view=rev Log: De-constify LLVM Types enough to fix arm and i386 builds. Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp Mon Jul 11 06:11:24 2011 @@ -102,7 +102,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - const Type *ResultType, + Type *ResultType, std::vector &Ops) { switch (FnCode) { case ALPHA_BUILTIN_UMULH: { Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Mon Jul 11 06:11:24 2011 @@ -48,16 +48,16 @@ #ifdef LLVM_ABI_H extern bool -llvm_arm_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, +llvm_arm_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, CallingConv::ID&, - std::vector&); + std::vector&); #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ llvm_arm_should_pass_aggregate_in_mixed_regs((T), (TY), (CC), (E)) struct DefaultABIClient; extern bool -llvm_arm_try_pass_aggregate_custom(tree, std::vector&, +llvm_arm_try_pass_aggregate_custom(tree, std::vector&, CallingConv::ID&, struct DefaultABIClient*); @@ -65,8 +65,8 @@ llvm_arm_try_pass_aggregate_custom((T), (E), (CC), (C)) extern -bool llvm_arm_aggregate_partially_passed_in_regs(std::vector&, - std::vector&, +bool llvm_arm_aggregate_partially_passed_in_regs(std::vector&, + std::vector&, CallingConv::ID&); #define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, CC) \ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Mon Jul 11 06:11:24 2011 @@ -246,13 +246,13 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - const Type *ResultType, + Type *ResultType, std::vector &Ops) { neon_datatype datatype = neon_datatype_unspecified; bool isRounded = false; Intrinsic::ID intID = Intrinsic::not_intrinsic; Function *intFn; - const Type* intOpTypes[2]; + Type* intOpTypes[2]; if (FnCode < ARM_BUILTIN_NEON_BASE) return false; @@ -1415,7 +1415,7 @@ const VectorType *VTy = dyn_cast(ResultType); assert(VTy && "expected a vector type for vabdl result"); - const llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); + llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); intFn = Intrinsic::getDeclaration(TheModule, intID, &DTy, 1); Ops[0] = Builder.CreateCall2(intFn, Ops[0], Ops[1]); Result = Builder.CreateZExt(Ops[0], ResultType); @@ -1445,7 +1445,7 @@ const VectorType *VTy = dyn_cast(ResultType); assert(VTy && "expected a vector type for vabal result"); - const llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); + llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); intFn = Intrinsic::getDeclaration(TheModule, intID, &DTy, 1); Ops[1] = Builder.CreateCall2(intFn, Ops[1], Ops[2]); Ops[1] = Builder.CreateZExt(Ops[1], ResultType); @@ -2033,7 +2033,7 @@ case NEON_BUILTIN_vld4: { const StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - const Type *VTy = STy->getElementType(0); + Type *VTy = STy->getElementType(0); switch (neon_code) { case NEON_BUILTIN_vld2: intID = Intrinsic::arm_neon_vld2; break; case NEON_BUILTIN_vld3: intID = Intrinsic::arm_neon_vld3; break; @@ -2062,9 +2062,9 @@ case NEON_BUILTIN_vld2_lane: case NEON_BUILTIN_vld3_lane: case NEON_BUILTIN_vld4_lane: { - const StructType *STy = dyn_cast(ResultType); + StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - const VectorType *VTy = dyn_cast(STy->getElementType(0)); + VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); if (!isValidLane(Ops[2], VTy->getNumElements())) return UnexpectedError("%Hinvalid lane number", exp, Result); @@ -2105,9 +2105,9 @@ case NEON_BUILTIN_vld2_dup: case NEON_BUILTIN_vld3_dup: case NEON_BUILTIN_vld4_dup: { - const StructType *STy = dyn_cast(ResultType); + StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - const VectorType *VTy = dyn_cast(STy->getElementType(0)); + VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); intOpTypes[0] = VTy; @@ -2168,7 +2168,7 @@ } case NEON_BUILTIN_vst1: { - const Type *VTy = Ops[1]->getType(); + Type *VTy = Ops[1]->getType(); intID = Intrinsic::arm_neon_vst1; intFn = Intrinsic::getDeclaration(TheModule, intID, &VTy, 1); Type *VPTy = PointerType::getUnqual(Type::getInt8Ty(Context)); @@ -2184,7 +2184,7 @@ case NEON_BUILTIN_vst4: { const StructType *STy = dyn_cast(Ops[1]->getType()); assert(STy && "expected a struct type"); - const Type *VTy = STy->getElementType(0); + Type *VTy = STy->getElementType(0); switch (neon_code) { case NEON_BUILTIN_vst2: intID = Intrinsic::arm_neon_vst2; break; case NEON_BUILTIN_vst3: intID = Intrinsic::arm_neon_vst3; break; @@ -2224,9 +2224,9 @@ case NEON_BUILTIN_vst2_lane: case NEON_BUILTIN_vst3_lane: case NEON_BUILTIN_vst4_lane: { - const StructType *STy = dyn_cast(Ops[1]->getType()); + StructType *STy = dyn_cast(Ops[1]->getType()); assert(STy && "expected a struct type"); - const VectorType *VTy = dyn_cast(STy->getElementType(0)); + VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); if (!isValidLane(Ops[2], VTy->getNumElements())) return UnexpectedError("%Hinvalid lane number", exp, Result); @@ -2521,11 +2521,11 @@ // Walk over an LLVM Type that we know is a homogeneous aggregate and // push the proper LLVM Types that represent the register types to pass // that struct member in. -static void push_elts(const Type *Ty, std::vector &Elts) +static void push_elts(const Type *Ty, std::vector &Elts) { for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { - const Type *STy = *I; + Type *STy = *I; if (const VectorType *VTy = dyn_cast(STy)) { switch (VTy->getBitWidth()) { @@ -2538,8 +2538,8 @@ default: assert (0 && "invalid vector type"); } - } else if (const ArrayType *ATy = dyn_cast(STy)) { - const Type *ETy = ATy->getElementType(); + } else if (ArrayType *ATy = dyn_cast(STy)) { + Type *ETy = ATy->getElementType(); for (uint64_t i = ATy->getNumElements(); i > 0; --i) Elts.push_back(ETy); @@ -2550,7 +2550,7 @@ } } -static unsigned count_num_words(std::vector &ScalarElts) { +static unsigned count_num_words(std::vector &ScalarElts) { unsigned NumWords = 0; for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -2574,7 +2574,7 @@ // the IL a bit more explicit about how arguments are handled. extern bool llvm_arm_try_pass_aggregate_custom(tree type, - std::vector& ScalarElts, + std::vector& ScalarElts, CallingConv::ID& CC, struct DefaultABIClient* C) { if (CC != CallingConv::ARM_AAPCS && CC != CallingConv::C) @@ -2596,14 +2596,14 @@ // First, build a type that will be bitcast to the original one and // from where elements will be extracted. - std::vector Elts; - const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); + std::vector Elts; + Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); const unsigned NumRegularArgs = Size / 4; for (unsigned i = 0; i < NumRegularArgs; ++i) { Elts.push_back(Int32Ty); } const unsigned RestSize = Size % 4; - const llvm::Type *RestType = NULL; + llvm::Type *RestType = NULL; if (RestSize> 2) { RestType = Type::getInt32Ty(getGlobalContext()); } else if (RestSize > 1) { @@ -2641,9 +2641,9 @@ // for parameter passing. This only applies to AAPCS-VFP "homogeneous // aggregates" as specified in 4.3.5 of the AAPCS spec. bool -llvm_arm_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, +llvm_arm_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, CallingConv::ID &CC, - std::vector &Elts) { + std::vector &Elts) { if (!llvm_arm_should_pass_or_return_aggregate_in_regs(TreeType, CC)) return false; @@ -2686,7 +2686,7 @@ // count_num_registers_uses - Simulate argument passing reg allocation in SPRs. // Caller is expected to zero out SPRs. Returns true if all of ScalarElts fit // in registers. -static bool count_num_registers_uses(std::vector &ScalarElts, +static bool count_num_registers_uses(std::vector &ScalarElts, bool *SPRs) { for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -2734,8 +2734,8 @@ // part of the aggregate, return true. That means the aggregate should instead // be passed in memory. bool -llvm_arm_aggregate_partially_passed_in_regs(std::vector &Elts, - std::vector &ScalarElts, +llvm_arm_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts, CallingConv::ID &CC) { // Homogeneous aggregates are an AAPCS-VFP feature. if ((CC != CallingConv::ARM_AAPCS_VFP) || @@ -2763,7 +2763,7 @@ // Walk Ty and push LLVM types corresponding to register types onto // Elts. - std::vector Elts; + std::vector Elts; const Type *Ty = ConvertType(TreeType); push_elts(Ty, Elts); Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Mon Jul 11 06:11:24 2011 @@ -225,18 +225,18 @@ llvm_x86_should_pass_aggregate_as_fca(X, TY) #endif -extern bool llvm_x86_should_pass_aggregate_in_memory(tree, const Type *); +extern bool llvm_x86_should_pass_aggregate_in_memory(tree, Type *); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_x86_should_pass_aggregate_in_memory(X, TY) extern bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, - std::vector&); +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, + std::vector&); extern bool -llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, - std::vector&); +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, + std::vector&); #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ (TARGET_64BIT ? \ @@ -244,8 +244,8 @@ llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E))) extern -bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, - std::vector&); +bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, + std::vector&); #define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, CC) \ (TARGET_64BIT ? \ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Jul 11 06:11:24 2011 @@ -95,7 +95,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - const Type *ResultType, + Type *ResultType, std::vector &Ops) { switch (FnCode) { default: break; @@ -1108,8 +1108,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. This is only called for x86-32. */ bool -llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, - std::vector &Elts){ +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, + std::vector &Elts){ // If this is a small fixed size type, investigate it. HOST_WIDE_INT SrcSize = int_size_in_bytes(TreeType); if (SrcSize <= 0 || SrcSize > 16) @@ -1125,7 +1125,7 @@ if (!STy || STy->isPacked()) return false; for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - const Type *EltTy = STy->getElementType(i); + Type *EltTy = STy->getElementType(i); // 32 and 64-bit integers are fine, as are float and double. Long double // (which can be picked as the type for a union of 16 bytes) is not fine, // as loads and stores of it get only 10 bytes. @@ -1165,7 +1165,7 @@ /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in memory. */ -bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { +bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, Type *Ty) { if (llvm_x86_should_pass_aggregate_as_fca(TreeType, Ty)) return false; @@ -1178,7 +1178,7 @@ return false; if (!TARGET_64BIT) { - std::vector Elts; + std::vector Elts; return !llvm_x86_32_should_pass_aggregate_in_mixed_regs(TreeType, Ty, Elts); } return llvm_x86_64_should_pass_aggregate_in_memory(TreeType, Mode); @@ -1186,7 +1186,7 @@ /* count_num_registers_uses - Return the number of GPRs and XMMs parameter register used so far. Caller is responsible for initializing outputs. */ -static void count_num_registers_uses(std::vector &ScalarElts, +static void count_num_registers_uses(std::vector &ScalarElts, unsigned &NumGPRs, unsigned &NumXMMs) { for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -1220,8 +1220,8 @@ part of the aggregate, return true. That means the aggregate should instead be passed in memory. */ bool -llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, - std::vector &ScalarElts) { +llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts) { // Counting number of GPRs and XMMs used so far. According to AMD64 ABI // document: "If there are no registers available for any eightbyte of an // argument, the whole argument is passed on the stack." X86-64 uses 6 @@ -1266,8 +1266,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. This is only called for x86-64. */ bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, - std::vector &Elts){ +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, + std::vector &Elts){ if (llvm_x86_should_pass_aggregate_as_fca(TreeType, Ty)) return false; @@ -1633,7 +1633,7 @@ /// llvm_x86_64_should_pass_aggregate_in_mixed_regs code. void llvm_x86_64_get_multiple_return_reg_classes(tree TreeType, const Type *Ty, - std::vector &Elts){ + std::vector &Elts){ enum x86_64_reg_class Class[MAX_CLASSES]; enum machine_mode Mode = ix86_getNaturalModeForType(TreeType); HOST_WIDE_INT Bytes = @@ -1774,7 +1774,7 @@ return NULL; const StructType *STy = cast(Ty); - std::vector ElementTypes; + std::vector ElementTypes; // Special handling for _Complex. if (llvm_x86_should_not_return_complex_in_memory(type)) { @@ -1783,7 +1783,7 @@ return StructType::get(Context, ElementTypes, STy->isPacked()); } - std::vector GCCElts; + std::vector GCCElts; llvm_x86_64_get_multiple_return_reg_classes(type, Ty, GCCElts); return StructType::get(Context, GCCElts, false); } Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Jul 11 06:11:24 2011 @@ -94,7 +94,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - const Type *ResultType, + Type *ResultType, std::vector &Ops) { switch (FnCode) { default: break; @@ -554,8 +554,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. */ bool -llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type* Ty, - std::vector&Elts) { +llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree TreeType, Type* Ty, + std::vector&Elts) { // FIXME there are plenty of ppc64 cases that need this. if (TARGET_64BIT) return false; Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Mon Jul 11 06:11:24 2011 @@ -9,7 +9,7 @@ /// on the client that indicate how its pieces should be handled. This /// handles things like returning structures via hidden parameters. void DefaultABI::HandleReturnType(tree type, tree fn, bool isBuiltin, - std::vector &ScalarElts) { + std::vector &ScalarElts) { unsigned Offset = 0; const Type *Ty = ConvertType(type); if (Ty->isVectorTy()) { @@ -53,7 +53,7 @@ // FIXME: should return the hidden first argument for some targets // (e.g. ELF i386). - const PointerType *PTy = Ty->getPointerTo(); + PointerType *PTy = Ty->getPointerTo(); C.HandleAggregateShadowResult(PTy, false); ScalarElts.push_back(PTy); } @@ -64,21 +64,21 @@ /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. -void DefaultABI::HandleArgument(tree type, std::vector &ScalarElts, +void DefaultABI::HandleArgument(tree type, std::vector &ScalarElts, Attributes *Attributes) { unsigned Size = 0; bool DontCheckAlignment = false; - const Type *Ty = ConvertType(type); + Type *Ty = ConvertType(type); // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do // not include variable sized fields here. - std::vector Elts; + std::vector Elts; if (Ty->isVoidTy()) { // Handle void explicitly as a {} type. - const Type *OpTy = StructType::get(getGlobalContext()); + Type *OpTy = StructType::get(getGlobalContext()); C.HandleScalarArgument(OpTy, type); ScalarElts.push_back(OpTy); } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - const Type *PtrTy = Ty->getPointerTo(); + Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); } else if (Ty->isVectorTy()) { @@ -134,7 +134,7 @@ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) if (TREE_CODE(Field) == FIELD_DECL) { const tree Ftype = getDeclaredType(Field); - const Type *FTy = ConvertType(Ftype); + Type *FTy = ConvertType(Ftype); unsigned FNo = GET_LLVM_FIELD_INDEX(Field); assert(FNo != ~0U && "Case not handled yet!"); @@ -174,7 +174,7 @@ } /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. -void DefaultABI::HandleUnion(tree type, std::vector &ScalarElts) { +void DefaultABI::HandleUnion(tree type, std::vector &ScalarElts) { if (TYPE_TRANSPARENT_UNION(type)) { tree Field = TYPE_FIELDS(type); assert(Field && "Transparent union must have some elements!"); @@ -218,7 +218,7 @@ /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. If Size is set we pass only that many bytes. void DefaultABI::PassInIntegerRegisters(tree type, - std::vector &ScalarElts, + std::vector &ScalarElts, unsigned origSize, bool DontCheckAlignment) { unsigned Size; @@ -240,8 +240,8 @@ unsigned ArraySize = Size / ElementSize; // Put as much of the aggregate as possible into an array. - const Type *ATy = NULL; - const Type *ArrayElementType = NULL; + Type *ATy = NULL; + Type *ArrayElementType = NULL; if (ArraySize) { Size = Size % ElementSize; ArrayElementType = (UseInt64 ? @@ -252,7 +252,7 @@ // Pass any leftover bytes as a separate element following the array. unsigned LastEltRealSize = 0; - const llvm::Type *LastEltTy = 0; + llvm::Type *LastEltTy = 0; if (Size > 4) { LastEltTy = Type::getInt64Ty(getGlobalContext()); } else if (Size > 2) { @@ -267,7 +267,7 @@ LastEltRealSize = Size; } - std::vector Elts; + std::vector Elts; if (ATy) Elts.push_back(ATy); if (LastEltTy) @@ -298,13 +298,13 @@ /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. void DefaultABI::PassInMixedRegisters(const Type *Ty, - std::vector &OrigElts, - std::vector &ScalarElts) { + std::vector &OrigElts, + std::vector &ScalarElts) { // We use VoidTy in OrigElts to mean "this is a word in the aggregate // that occupies storage but has no useful information, and is not passed // anywhere". Happens on x86-64. - std::vector Elts(OrigElts); - const Type* wordType = getTargetData().getPointerSize() == 4 ? + std::vector Elts(OrigElts); + Type* wordType = getTargetData().getPointerSize() == 4 ? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); for (unsigned i=0, e=Elts.size(); i!=e; ++i) if (OrigElts[i]->isVoidTy()) Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Jul 11 06:11:24 2011 @@ -407,31 +407,31 @@ /// on the client that indicate how its pieces should be handled. This /// handles things like returning structures via hidden parameters. void HandleReturnType(tree type, tree fn, bool isBuiltin, - std::vector &ScalarElts); + std::vector &ScalarElts); /// HandleArgument - This is invoked by the target-independent code for each /// argument type passed into the function. It potentially breaks down the /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. - void HandleArgument(tree type, std::vector &ScalarElts, + void HandleArgument(tree type, std::vector &ScalarElts, Attributes *Attributes = NULL); /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. /// - void HandleUnion(tree type, std::vector &ScalarElts); + void HandleUnion(tree type, std::vector &ScalarElts); /// PassInIntegerRegisters - Given an aggregate value that should be passed in /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. If Size is set we pass only that many bytes. - void PassInIntegerRegisters(tree type, std::vector &ScalarElts, + void PassInIntegerRegisters(tree type, std::vector &ScalarElts, unsigned origSize, bool DontCheckAlignment); /// PassInMixedRegisters - Given an aggregate value that should be passed in /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. - void PassInMixedRegisters(const Type *Ty, std::vector &OrigElts, - std::vector &ScalarElts); + void PassInMixedRegisters(const Type *Ty, std::vector &OrigElts, + std::vector &ScalarElts); }; #endif /* LLVM_ABI_H */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Jul 11 06:11:24 2011 @@ -915,8 +915,7 @@ LLVMContext &Context = getGlobalContext(); const Type *FPTy = - FunctionType::get(Type::getVoidTy(Context), - std::vector(), false); + FunctionType::get(Type::getVoidTy(Context), std::vector(), false); FPTy = FPTy->getPointerTo(); for (unsigned i = 0, e = Tors.size(); i != e; ++i) { Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jul 11 06:11:24 2011 @@ -381,8 +381,8 @@ // bytes, but only 10 are copied. If the object is really a union // we might need the other bytes. We must also be careful to use // the smaller alignment. - const Type *SBP = Type::getInt8PtrTy(Context); - const Type *IntPtr = getTargetData().getIntPtrType(Context); + Type *SBP = Type::getInt8PtrTy(Context); + Type *IntPtr = getTargetData().getIntPtrType(Context); Value *Ops[5] = { Builder.CreateCast(Instruction::BitCast, Loc, SBP), Builder.CreateCast(Instruction::BitCast, AI, SBP), @@ -392,7 +392,7 @@ LLVM_BYVAL_ALIGNMENT(type)), ConstantInt::get(Type::getInt1Ty(Context), false) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, ArgTypes, 3), Ops, Ops+5); @@ -434,13 +434,13 @@ // isPassedByVal - Return true if an aggregate of the specified type will be // passed in memory byval. -static bool isPassedByVal(tree type, const Type *Ty, - std::vector &ScalarArgs, +static bool isPassedByVal(tree type, Type *Ty, + std::vector &ScalarArgs, CallingConv::ID &CC) { if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty, CC)) return true; - std::vector Args; + std::vector Args; if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, CC, Args) && LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Args, ScalarArgs, CC)) @@ -677,7 +677,7 @@ DefaultABI ABIConverter(Client); // Scalar arguments processed so far. - std::vector ScalarArgs; + std::vector ScalarArgs; // Handle the DECL_RESULT. ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl, @@ -693,7 +693,7 @@ const char *Name = "unnamed_arg"; if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args)); - const Type *ArgTy = ConvertType(TREE_TYPE(Args)); + Type *ArgTy = ConvertType(TREE_TYPE(Args)); bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || (ArgTy->isVectorTy() && @@ -1655,8 +1655,8 @@ Value *TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - const Type *SBP = Type::getInt8PtrTy(Context); - const Type *IntPtr = TD.getIntPtrType(Context); + Type *SBP = Type::getInt8PtrTy(Context); + Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), @@ -1665,7 +1665,7 @@ ConstantInt::get(Type::getInt1Ty(Context), false) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, ArgTypes, 3), Ops, Ops+5); return Ops[0]; @@ -1673,8 +1673,8 @@ Value *TreeToLLVM::EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - const Type *SBP = Type::getInt8PtrTy(Context); - const Type *IntPtr = TD.getIntPtrType(Context); + Type *SBP = Type::getInt8PtrTy(Context); + Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), @@ -1682,7 +1682,7 @@ ConstantInt::get(Type::getInt32Ty(Context), Align), ConstantInt::get(Type::getInt1Ty(Context), false) }; - const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, ArgTypes, 3), Ops, Ops+5); @@ -1691,8 +1691,8 @@ Value *TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align) { - const Type *SBP = Type::getInt8PtrTy(Context); - const Type *IntPtr = TD.getIntPtrType(Context); + Type *SBP = Type::getInt8PtrTy(Context); + Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), @@ -1701,7 +1701,7 @@ ConstantInt::get(Type::getInt1Ty(Context), false) }; - const Type *ArgTypes[2] = {SBP, IntPtr }; + Type *ArgTypes[2] = {SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, ArgTypes, 2), Ops, Ops+5); return Ops[0]; @@ -3034,7 +3034,7 @@ DefaultABI ABIConverter(Client); // Handle the result, including struct returns. - std::vector ScalarArgs; + std::vector ScalarArgs; ABIConverter.HandleReturnType(TREE_TYPE(exp), fndecl ? fndecl : exp, fndecl ? DECL_BUILT_IN(fndecl) : false, @@ -4354,7 +4354,7 @@ } // Turn this into a 'tmp = call Ty asm "", "={reg}"()'. - FunctionType *FTy = FunctionType::get(Ty, std::vector(),false); + FunctionType *FTy = FunctionType::get(Ty, std::vector(),false); const char *Name = extractRegisterName(decl); int RegNum = decode_reg_name(Name); @@ -4370,7 +4370,7 @@ /// that copies the value out of the specified register. Value *TreeToLLVM::EmitMoveOfRegVariableToRightReg(Instruction *I, tree var) { // Create a 'call void asm sideeffect "", "{reg}"(Ty %RHS)'. - const Type *Ty = I->getType(); + Type *Ty = I->getType(); // If there was an error, return something bogus. if (ValidateRegisterVariable(var)) { @@ -4379,7 +4379,7 @@ return 0; // Just don't copy something into DestLoc. } - std::vector ArgTys; + std::vector ArgTys; ArgTys.push_back(Ty); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), ArgTys, false); @@ -4392,7 +4392,7 @@ Call->setDoesNotThrow(); // Create another asm with the same reg, this time producing an output. // Turn this into a 'tmp = call Ty asm "", "={reg}"()'. - FunctionType *FTy2 = FunctionType::get(Ty, std::vector(), + FunctionType *FTy2 = FunctionType::get(Ty, std::vector(), false); InlineAsm *IA2 = InlineAsm::get(FTy2, "", "={"+std::string(Name)+"}", true); @@ -4409,8 +4409,8 @@ return; // Turn this into a 'call void asm sideeffect "", "{reg}"(Ty %RHS)'. - std::vector ArgTys; - const Type* Ty = ConvertType(TREE_TYPE(decl)); + std::vector ArgTys; + Type* Ty = ConvertType(TREE_TYPE(decl)); if (LLVM_IS_DECL_MMX_REGISTER(decl)) Ty = Type::getX86_MMXTy(Context); ArgTys.push_back(Ty); @@ -4869,14 +4869,14 @@ } std::vector CallOps; - std::vector CallArgTypes; + std::vector CallArgTypes; std::string NewAsmStr = ConvertInlineAsmStr(exp, NumOutputs+NumInputs); std::string ConstraintStr; bool HasSideEffects = ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp); // StoreCallResultAddr - The pointer to store the result of the call through. SmallVector StoreCallResultAddrs; - SmallVector CallResultTypes; + SmallVector CallResultTypes; SmallVector CallResultIsSigned; SmallVector, 4> OutputLocations; @@ -4936,8 +4936,7 @@ } LValue Dest = EmitLV(Operand); - const Type *DestValTy = - cast(Dest.Ptr->getType())->getElementType(); + Type *DestValTy = cast(Dest.Ptr->getType())->getElementType(); assert(!Dest.isBitfield() && "Cannot assign into a bitfield!"); if (!AllowsMem && DestValTy->isSingleValueType()) {// Reg dest -> asm return @@ -5077,7 +5076,7 @@ } } - const Type* AdjTy = LLVM_ADJUST_MMX_INLINE_PARAMETER_TYPE( + Type* AdjTy = LLVM_ADJUST_MMX_INLINE_PARAMETER_TYPE( Constraint, Op->getType()); if (AdjTy != Op->getType()) Op = BitCastToType(Op, AdjTy); @@ -5158,9 +5157,7 @@ case 0: CallResultType = Type::getVoidTy(Context); break; case 1: CallResultType = CallResultTypes[0]; break; default: - std::vector TmpVec(CallResultTypes.begin(), - CallResultTypes.end()); - CallResultType = StructType::get(Context, TmpVec); + CallResultType = StructType::get(Context, CallResultTypes); break; } @@ -5308,7 +5305,7 @@ Value *&Result) { #ifdef LLVM_TARGET_INTRINSIC_LOWER // Get the result type and operand line in an easy to consume format. - const Type *ResultType = ConvertType(TREE_TYPE(TREE_TYPE(fndecl))); + Type *ResultType = ConvertType(TREE_TYPE(TREE_TYPE(fndecl))); std::vector Operands; for (tree Op = TREE_OPERAND(exp, 1); Op; Op = TREE_CHAIN(Op)) { tree OpVal = TREE_VALUE(Op); @@ -5352,13 +5349,13 @@ Value * TreeToLLVM::BuildBinaryAtomicBuiltin(tree exp, Intrinsic::ID id) { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5391,14 +5388,14 @@ Value * TreeToLLVM::BuildCmpAndSwapAtomicBuiltin(tree exp, tree type, bool isBool) { - const Type *ResultTy = ConvertType(type); + Type *ResultTy = ConvertType(type); tree arglist = TREE_OPERAND(exp, 1); Value* C[3] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0), Emit(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(arglist))), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5571,7 +5568,7 @@ }; // Grab the current return type. - const Type* Ty; + Type* Ty; Ty = ConvertType(TREE_TYPE(exp)); // Manually coerce the arg to the correct pointer type. @@ -5767,7 +5764,7 @@ // Get arguments. tree arglist = TREE_OPERAND(exp, 1); Value *ExprVal = Emit(TREE_VALUE(arglist), 0); - const Type *Ty = ExprVal->getType(); + Type *Ty = ExprVal->getType(); Value *StrVal = Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0); SmallVector Args; @@ -5927,13 +5924,13 @@ case BUILT_IN_ADD_AND_FETCH_1: case BUILT_IN_ADD_AND_FETCH_2: case BUILT_IN_ADD_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5974,13 +5971,13 @@ case BUILT_IN_SUB_AND_FETCH_1: case BUILT_IN_SUB_AND_FETCH_2: case BUILT_IN_SUB_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6021,13 +6018,13 @@ case BUILT_IN_OR_AND_FETCH_1: case BUILT_IN_OR_AND_FETCH_2: case BUILT_IN_OR_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6068,13 +6065,13 @@ case BUILT_IN_AND_AND_FETCH_1: case BUILT_IN_AND_AND_FETCH_2: case BUILT_IN_AND_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6115,13 +6112,13 @@ case BUILT_IN_XOR_AND_FETCH_1: case BUILT_IN_XOR_AND_FETCH_2: case BUILT_IN_XOR_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6162,13 +6159,13 @@ case BUILT_IN_NAND_AND_FETCH_1: case BUILT_IN_NAND_AND_FETCH_2: case BUILT_IN_NAND_AND_FETCH_4: { - const Type *ResultTy = ConvertType(TREE_TYPE(exp)); + Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - const Type* Ty[2]; + Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6293,7 +6290,7 @@ // varying type. Make sure that we specify the actual type for "iAny" // by passing it as the 3rd and 4th parameters. This isn't needed for // most intrinsics, but is needed for ctpop, cttz, ctlz. - const Type *Ty = InVal->getType(); + Type *Ty = InVal->getType(); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Id, &Ty, 1), InVal); return true; @@ -6301,7 +6298,7 @@ Value *TreeToLLVM::EmitBuiltinSQRT(tree exp) { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - const Type* Ty = Amt->getType(); + Type* Ty = Amt->getType(); return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::sqrt, &Ty, 1), @@ -6315,7 +6312,7 @@ Value *Val = Emit(TREE_VALUE(ArgList), 0); Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); - const Type *Ty = Val->getType(); + Type *Ty = Val->getType(); Pow = CastToSIntType(Pow, Type::getInt32Ty(Context)); SmallVector Args; @@ -6333,7 +6330,7 @@ Value *Val = Emit(TREE_VALUE(ArgList), 0); Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); - const Type *Ty = Val->getType(); + Type *Ty = Val->getType(); SmallVector Args; Args.push_back(Val); @@ -7079,7 +7076,7 @@ Value *TreeToLLVM::EmitFieldAnnotation(Value *FieldPtr, tree FieldDecl) { tree AnnotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl)); - const Type *SBP = Type::getInt8PtrTy(Context); + Type *SBP = Type::getInt8PtrTy(Context); Function *Fn = Intrinsic::getDeclaration(TheModule, Intrinsic::ptr_annotation, Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Jul 11 06:11:24 2011 @@ -129,7 +129,7 @@ public: TypeConverter() : RecursionStatus(CS_Normal) {} - const Type *ConvertType(tree_node *type); + Type *ConvertType(tree_node *type); /// GCCTypeOverlapsWithLLVMTypePadding - Return true if the specified GCC type /// has any data that overlaps with structure padding in the specified LLVM @@ -140,11 +140,11 @@ /// ConvertFunctionType - Convert the specified FUNCTION_TYPE or METHOD_TYPE /// tree to an LLVM type. This does the same thing that ConvertType does, but /// it also returns the function's LLVM calling convention and attributes. - const FunctionType *ConvertFunctionType(tree_node *type, - tree_node *decl, - tree_node *static_chain, - CallingConv::ID &CallingConv, - AttrListPtr &PAL); + FunctionType *ConvertFunctionType(tree_node *type, + tree_node *decl, + tree_node *static_chain, + CallingConv::ID &CallingConv, + AttrListPtr &PAL); /// ConvertArgListToFnType - Given a DECL_ARGUMENTS list on an GCC tree, /// return the LLVM type corresponding to the function. This is useful for @@ -156,8 +156,8 @@ AttrListPtr &PAL); private: - const Type *ConvertRECORD(tree_node *type, tree_node *orig_type); - const Type *ConvertUNION(tree_node *type, tree_node *orig_type); + Type *ConvertRECORD(tree_node *type, tree_node *orig_type); + Type *ConvertUNION(tree_node *type, tree_node *orig_type); bool DecodeStructFields(tree_node *Field, StructTypeConversionInfo &Info); void DecodeStructBitField(tree_node *Field, StructTypeConversionInfo &Info); void SelectUnionMember(tree_node *type, StructTypeConversionInfo &Info); @@ -167,7 +167,7 @@ /// ConvertType - Convert the specified tree type to an LLVM type. /// -inline const Type *ConvertType(tree_node *type) { +inline Type *ConvertType(tree_node *type) { return TheTypeConverter->ConvertType(type); } @@ -615,7 +615,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - const Type *ResultType, + Type *ResultType, std::vector &Ops); public: Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=134894&r1=134893&r2=134894&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Jul 11 06:11:24 2011 @@ -59,8 +59,8 @@ // a map. // Collection of LLVM Types -static std::vector LTypes; -typedef DenseMap LTypesMapTy; +static std::vector LTypes; +typedef DenseMap LTypesMapTy; static LTypesMapTy LTypesMap; static LLVMContext &Context = getGlobalContext(); @@ -72,7 +72,7 @@ (TYPE_CHECK (NODE)->type.symtab.llvm = index) // Note down LLVM type for GCC tree node. -static const Type * llvm_set_type(tree Tr, const Type *Ty) { +static Type * llvm_set_type(tree Tr, Type *Ty) { #ifndef NDEBUG // For x86 long double, llvm records the size of the data (80) while // gcc's TYPE_SIZE including alignment padding. getTypeAllocSizeInBits @@ -107,12 +107,12 @@ return Ty; } -#define SET_TYPE_LLVM(NODE, TYPE) (const Type *)llvm_set_type(NODE, TYPE) +#define SET_TYPE_LLVM(NODE, TYPE) llvm_set_type(NODE, TYPE) // Get LLVM Type for the GCC tree node based on LTypes vector index. // When GCC tree node is initialized, it has 0 as the index value. This is // why all recorded indexes are offset by 1. -extern "C" const Type *llvm_get_type(unsigned Index) { +extern "C" Type *llvm_get_type(unsigned Index) { if (Index == 0) return NULL; assert ((Index - 1) < LTypes.size() && "Invalid LLVM Type index"); @@ -120,10 +120,10 @@ } #define GET_TYPE_LLVM(NODE) \ - (const Type *)llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm) + llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm) // Erase type from LTypes vector -static void llvmEraseLType(const Type *Ty) { +static void llvmEraseLType(Type *Ty) { LTypesMapTy::iterator I = LTypesMap.find(Ty); if (I != LTypesMap.end()) { @@ -161,7 +161,7 @@ return; // Convert the LTypes list to a list of pointers. - std::vector PTys; + std::vector PTys; for (unsigned i = 0, e = LTypes.size(); i != e; ++i) { // Cannot form pointer to void. Use i8 as a sentinel. if (LTypes[i]->isVoidTy()) @@ -488,7 +488,7 @@ // Main Type Conversion Routines //===----------------------------------------------------------------------===// -const Type *TypeConverter::ConvertType(tree orig_type) { +Type *TypeConverter::ConvertType(tree orig_type) { if (orig_type == error_mark_node) return Type::getInt32Ty(Context); // LLVM doesn't care about variants such as const, volatile, or restrict. @@ -504,7 +504,7 @@ case QUAL_UNION_TYPE: case UNION_TYPE: return ConvertRECORD(type, orig_type); case BOOLEAN_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; return SET_TYPE_LLVM(type, IntegerType::get(Context, TREE_INT_CST_LOW(TYPE_SIZE(type)))); @@ -513,25 +513,25 @@ // Use of an enum that is implicitly declared? if (TYPE_SIZE(orig_type) == 0) { // If we already compiled this type, use the old type. - if (const Type *Ty = GET_TYPE_LLVM(orig_type)) + if (Type *Ty = GET_TYPE_LLVM(orig_type)) return Ty; // Just mark it as a named type for now. - const Type *Ty = StructType::createNamed(Context, - GetTypeName("enum.", orig_type)); + Type *Ty = StructType::createNamed(Context, + GetTypeName("enum.", orig_type)); return SET_TYPE_LLVM(orig_type, Ty); } // FALL THROUGH. type = orig_type; case INTEGER_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; // The ARM port defines __builtin_neon_xi as a 511-bit type because GCC's // type precision field has only 9 bits. Treat this as a special case. int precision = TYPE_PRECISION(type) == 511 ? 512 : TYPE_PRECISION(type); return SET_TYPE_LLVM(type, IntegerType::get(Context, precision)); } case REAL_TYPE: - if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; switch (TYPE_PRECISION(type)) { default: fprintf(stderr, "Unknown FP type!\n"); @@ -557,13 +557,13 @@ } case COMPLEX_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; - const Type *Ty = ConvertType(TREE_TYPE(type)); + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; + Type *Ty = ConvertType(TREE_TYPE(type)); return SET_TYPE_LLVM(type, StructType::get(Ty, Ty, NULL)); } case VECTOR_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; - const Type *Ty = ConvertType(TREE_TYPE(type)); + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; + Type *Ty = ConvertType(TREE_TYPE(type)); Ty = VectorType::get(Ty, TYPE_VECTOR_SUBPARTS(type)); return SET_TYPE_LLVM(type, Ty); } @@ -576,7 +576,7 @@ if (RecursionStatus == CS_Struct) RecursionStatus = CS_StructPtr; - const Type *Ty = ConvertType(TREE_TYPE(type)); + Type *Ty = ConvertType(TREE_TYPE(type)); RecursionStatus = SavedCS; @@ -587,7 +587,7 @@ case METHOD_TYPE: case FUNCTION_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; // No declaration to pass through, passing NULL. @@ -597,7 +597,7 @@ CallingConv, PAL)); } case ARRAY_TYPE: { - if (const Type *Ty = GET_TYPE_LLVM(type)) + if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; uint64_t ElementSize; @@ -665,13 +665,13 @@ namespace { class FunctionTypeConversion : public DefaultABIClient { const Type *&RetTy; - std::vector &ArgTypes; + std::vector &ArgTypes; CallingConv::ID &CallingConv; bool isShadowRet; bool KNRPromotion; unsigned Offset; public: - FunctionTypeConversion(const Type *&retty, std::vector &AT, + FunctionTypeConversion(const Type *&retty, std::vector &AT, CallingConv::ID &CC, bool KNR) : RetTy(retty), ArgTypes(AT), CallingConv(CC), KNRPromotion(KNR), Offset(0) { CallingConv = CallingConv::C; @@ -704,7 +704,7 @@ } /// HandleShadowResult - Handle an aggregate or scalar shadow argument. - void HandleShadowResult(const PointerType *PtrArgTy, bool RetPtr) { + void HandleShadowResult(PointerType *PtrArgTy, bool RetPtr) { // This function either returns void or the shadow argument, // depending on the target. RetTy = RetPtr ? PtrArgTy : Type::getVoidTy(Context); @@ -720,8 +720,7 @@ /// returns an aggregate value by using a "shadow" first parameter, which is /// a pointer to the aggregate, of type PtrArgTy. If RetPtr is set to true, /// the pointer argument itself is returned from the function. - void HandleAggregateShadowResult(const PointerType *PtrArgTy, - bool RetPtr) { + void HandleAggregateShadowResult(PointerType *PtrArgTy, bool RetPtr) { HandleShadowResult(PtrArgTy, RetPtr); } @@ -729,15 +728,15 @@ /// returns a scalar value by using a "shadow" first parameter, which is a /// pointer to the scalar, of type PtrArgTy. If RetPtr is set to true, /// the pointer argument itself is returned from the function. - void HandleScalarShadowResult(const PointerType *PtrArgTy, bool RetPtr) { + void HandleScalarShadowResult(PointerType *PtrArgTy, bool RetPtr) { HandleShadowResult(PtrArgTy, RetPtr); } - void HandlePad(const llvm::Type *LLVMTy) { + void HandlePad(llvm::Type *LLVMTy) { HandleScalarArgument(LLVMTy, 0, 0); } - void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, + void HandleScalarArgument(llvm::Type *LLVMTy, tree type, unsigned RealSize = 0) { if (KNRPromotion) { if (type == float_type_node) @@ -752,7 +751,7 @@ /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer /// (of type PtrTy) to the argument is passed rather than the argument itself. - void HandleByInvisibleReferenceArgument(const llvm::Type *PtrTy, tree type) { + void HandleByInvisibleReferenceArgument(llvm::Type *PtrTy, tree type) { ArgTypes.push_back(PtrTy); } @@ -765,7 +764,7 @@ /// HandleFCAArgument - This callback is invoked if the aggregate function /// argument is a first class aggregate passed by value. - void HandleFCAArgument(const llvm::Type *LLVMTy, + void HandleFCAArgument(llvm::Type *LLVMTy, tree type ATTRIBUTE_UNUSED) { ArgTypes.push_back(LLVMTy); } @@ -798,7 +797,7 @@ ConvertArgListToFnType(tree type, tree Args, tree static_chain, CallingConv::ID &CallingConv, AttrListPtr &PAL) { tree ReturnType = TREE_TYPE(type); - std::vector ArgTys; + std::vector ArgTys; const Type *RetTy = Type::getVoidTy(Context); FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/); @@ -808,7 +807,7 @@ TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif - std::vector ScalarArgs; + std::vector ScalarArgs; // Builtins are always prototyped, so this isn't one. ABIConverter.HandleReturnType(ReturnType, current_function_decl, false, ScalarArgs); @@ -865,11 +864,11 @@ return FunctionType::get(RetTy, ArgTys, false); } -const FunctionType *TypeConverter:: +FunctionType *TypeConverter:: ConvertFunctionType(tree type, tree decl, tree static_chain, CallingConv::ID &CallingConv, AttrListPtr &PAL) { const Type *RetTy = Type::getVoidTy(Context); - std::vector ArgTypes; + std::vector ArgTypes; bool isVarArg = false; FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/); DefaultABI ABIConverter(Client); @@ -879,7 +878,7 @@ TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif - std::vector ScalarArgs; + std::vector ScalarArgs; ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl, decl ? DECL_BUILT_IN(decl) : false, ScalarArgs); @@ -973,7 +972,7 @@ for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){ tree ArgTy = TREE_VALUE(Args); if (!isPassedByInvisibleReference(ArgTy)) - if (const StructType *STy = dyn_cast(ConvertType(ArgTy))) + if (StructType *STy = dyn_cast(ConvertType(ArgTy))) if (STy->isOpaque()) { // If we are passing an opaque struct by value, we don't know how many // arguments it will turn into. Because we can't handle this yet, @@ -1649,7 +1648,7 @@ // If Field has user defined alignment and it does not match Ty alignment // then convert to a packed struct and try again. if (TYPE_USER_ALIGN(DECL_BIT_FIELD_TYPE(Field))) { - const Type *Ty = ConvertType(getDeclaredType(Field)); + Type *Ty = ConvertType(getDeclaredType(Field)); if (TYPE_ALIGN(DECL_BIT_FIELD_TYPE(Field)) != 8 * Info.getTypeAlignment(Ty)) return false; @@ -1666,7 +1665,7 @@ assert((StartOffsetInBits & 7) == 0 && "Non-bit-field has non-byte offset!"); uint64_t StartOffsetInBytes = StartOffsetInBits/8; - const Type *Ty = ConvertType(getDeclaredType(Field)); + Type *Ty = ConvertType(getDeclaredType(Field)); // If this field is packed then the struct may need padding fields // before this field. @@ -1875,7 +1874,7 @@ TREE_INT_CST_LOW(DECL_SIZE(Field)) == 0) continue; - const Type *TheTy = ConvertType(TheGccTy); + Type *TheTy = ConvertType(TheGccTy); unsigned Size = Info.getTypeSize(TheTy); unsigned Align = Info.getTypeAlignment(TheTy); @@ -1939,9 +1938,9 @@ // // For LLVM purposes, we build a new type for B-within-D that // has the correct size and layout for that usage. -const Type *TypeConverter::ConvertRECORD(tree type, tree orig_type) { +Type *TypeConverter::ConvertRECORD(tree type, tree orig_type) { bool IsStruct = TREE_CODE(type) == RECORD_TYPE; - if (const StructType *Ty = cast_or_null(GET_TYPE_LLVM(type))) { + if (StructType *Ty = cast_or_null(GET_TYPE_LLVM(type))) { // If we already compiled this type, and if it was not a forward // definition that is now defined, use the old type. if (!Ty->isOpaque() || TYPE_SIZE(type) == 0) @@ -2060,7 +2059,7 @@ } else { uint64_t FieldOffsetInBits = getFieldOffsetInBits(Field); tree FieldType = getDeclaredType(Field); - const Type *FieldTy = ConvertType(FieldType); + Type *FieldTy = ConvertType(FieldType); // If this is a bitfield, we may want to adjust the FieldOffsetInBits // to produce safe code. In particular, bitfields will be @@ -2101,7 +2100,7 @@ if (IsStruct) RestoreOriginalFields(type); - const StructType *ResultTy = cast(GET_TYPE_LLVM(type)); + StructType *ResultTy = cast(GET_TYPE_LLVM(type)); Info->fillInLLVMType((StructType*)ResultTy); StructTypeInfoMap[type] = Info; From tobias at grosser.es Mon Jul 11 06:14:33 2011 From: tobias at grosser.es (Tobias Grosser) Date: Mon, 11 Jul 2011 13:14:33 +0200 Subject: [llvm-commits] [llvm] r134893 - in /llvm/trunk: include/llvm/DerivedTypes.h include/llvm/Target/TargetData.h lib/CodeGen/SjLjEHPrepare.cpp lib/Target/ARM/ARMGlobalMerge.cpp lib/Target/TargetData.cpp lib/Transforms/IPO/DeadArgumentElimination.cpp lib/Transforms/Instrumentation/ProfilingUtils.cpp lib/Transforms/Utils/CodeExtractor.cpp lib/VMCore/Constants.cpp lib/VMCore/Core.cpp lib/VMCore/Type.cpp tools/bugpoint/ExtractFunction.cpp unittests/Support/TypeBuilderTest.cpp In-Reply-To: <20110711095621.64F512A6C124@llvm.org> References: <20110711095621.64F512A6C124@llvm.org> Message-ID: <4E1ADB19.4020401@grosser.es> On 07/11/2011 11:56 AM, Jay Foad wrote: > Author: foad > Date: Mon Jul 11 04:56:20 2011 > New Revision: 134893 > > URL: http://llvm.org/viewvc/llvm-project?rev=134893&view=rev > Log: > De-constify Types in StructType::get() and TargetData::getIntPtrType(). Do Builder.getInt8PtrTy() and Co also need the const removed? Cheers Tobi From jay.foad at gmail.com Mon Jul 11 06:24:57 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 12:24:57 +0100 Subject: [llvm-commits] [llvm] r134893 - in /llvm/trunk: include/llvm/DerivedTypes.h include/llvm/Target/TargetData.h lib/CodeGen/SjLjEHPrepare.cpp lib/Target/ARM/ARMGlobalMerge.cpp lib/Target/TargetData.cpp lib/Transforms/IPO/DeadArgumentElimination.cpp Message-ID: On 11 July 2011 12:14, Tobias Grosser wrote: > On 07/11/2011 11:56 AM, Jay Foad wrote: >> Author: foad >> Date: Mon Jul 11 04:56:20 2011 >> New Revision: 134893 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134893&view=rev >> Log: >> De-constify Types in StructType::get() and TargetData::getIntPtrType(). > > Do Builder.getInt8PtrTy() and Co also need the const removed? I think the plan is to remove the const *everywhere*, eventually. I'm just doing the bits that I have some motivation for. Thanks, Jay. From jay.foad at gmail.com Mon Jul 11 06:35:40 2011 From: jay.foad at gmail.com (Jay Foad) Date: Mon, 11 Jul 2011 11:35:40 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r134895 - in /llvm-gcc-4.2/trunk/gcc/config: mips/llvm-mips.cpp rs6000/llvm-rs6000.cpp rs6000/rs6000.h Message-ID: <20110711113541.068AF2A6C12C@llvm.org> Author: foad Date: Mon Jul 11 06:35:40 2011 New Revision: 134895 URL: http://llvm.org/viewvc/llvm-project?rev=134895&view=rev Log: De-constify LLVM Types enough to fix mips and rs6000 builds. Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp?rev=134895&r1=134894&r2=134895&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp Mon Jul 11 06:35:40 2011 @@ -67,7 +67,7 @@ const Type *Ty = ConvertType(type); const StructType *STy = cast(Ty); - std::vector ElementTypes; + std::vector ElementTypes; // Special handling for _Complex. if (llvm_mips_should_not_return_complex_in_memory(type)) { Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=134895&r1=134894&r2=134895&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Jul 11 06:35:40 2011 @@ -391,7 +391,7 @@ return false; } -static unsigned count_num_registers_uses(std::vector &ScalarElts) { +static unsigned count_num_registers_uses(std::vector &ScalarElts) { unsigned NumGPRs = 0; for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { if (NumGPRs >= 8) @@ -423,7 +423,7 @@ /// arguments are always passed in general purpose registers, never in /// Floating-point registers or vector registers. bool llvm_rs6000_try_pass_aggregate_custom(tree type, - std::vector &ScalarElts, + std::vector &ScalarElts, const CallingConv::ID &CC, struct DefaultABIClient* C) { if (!isSVR4ABI()) @@ -432,8 +432,8 @@ // Eight GPR's are availabe for parameter passing. const unsigned NumArgRegs = 8; unsigned NumGPR = count_num_registers_uses(ScalarElts); - const Type *Ty = ConvertType(type); - const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); + Type *Ty = ConvertType(type); + Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); if (Ty->isSingleValueType()) { if (Ty->isIntegerTy()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); @@ -469,7 +469,7 @@ if (TREE_CODE(type) == COMPLEX_TYPE) { unsigned SrcSize = int_size_in_bytes(type); unsigned NumRegs = (SrcSize + 3) / 4; - std::vector Elts; + std::vector Elts; // This looks very strange, but matches the old code. if (SrcSize == 8) { @@ -505,7 +505,7 @@ /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed using the byval mechanism. */ -bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, const Type *Ty) { +bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, Type *Ty) { /* FIXME byval not implemented for ppc64. */ if (TARGET_64BIT) return false; Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=134895&r1=134894&r2=134895&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Mon Jul 11 06:35:40 2011 @@ -3490,14 +3490,14 @@ #ifdef LLVM_ABI_H extern bool llvm_rs6000_try_pass_aggregate_custom(tree, - std::vector&, + std::vector&, const CallingConv::ID &, struct DefaultABIClient*); #define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \ llvm_rs6000_try_pass_aggregate_custom((T), (E), (CC), (C)) -extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *); +extern bool llvm_rs6000_should_pass_aggregate_byval(tree, Type *); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_rs6000_should_pass_aggregate_byval((X), (TY)) @@ -3508,8 +3508,8 @@ #define LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(X) \ llvm_rs6000_should_pass_vector_in_integer_regs((X)) -extern bool llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree, const Type*, - std::vector&); +extern bool llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree, Type*, + std::vector&); /* FIXME this is needed for 64-bit */ #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ From grosbach at apple.com Mon Jul 11 09:49:55 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 11 Jul 2011 07:49:55 -0700 Subject: [llvm-commits] [llvm] r134746 - in /llvm/trunk: lib/Target/ARM/ARMConstantIslandPass.cpp lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/Thumb1FrameLowering.cpp test/CodeGen/Thumb2/machine-licm.ll test/CodeGen/Thumb2/thumb2-bcc.ll test/CodeGen/Thumb2/thumb2-branch.ll test/CodeGen/Thumb2/thumb2-ifcvt1.ll In-Reply-To: References: <20110708215005.1EF1E2A6C12C@llvm.org> Message-ID: <45BC38E9-CC2D-4E4B-B36A-463042E670A0@apple.com> On Jul 9, 2011, at 4:47 PM, Evan Cheng wrote: > Hi Jim, > > It's generally a bad idea to use hidden options for these tests. Can you disable ifcvt another way? Have you tried specifying CPU name or adjust the tests? > I agree it's suboptimal to reference those sorts of options. In this case I took it as the lesser of two evils, as adjusting the tests would either a) change them t no longer test what they are written to be testing, or b) obfuscate the test by enlarging them solely to defeat if-conversion. Neither of those options seems very appealing. I didn't see any other way to disable if conversion short of disabling optimization altogether. I don''t think a different CPU name would have any effect here. Did you have something specific in mind? If there's something along those lines that would work, that would be great. -Jim > > On Jul 8, 2011, at 2:50 PM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Fri Jul 8 16:50:04 2011 >> New Revision: 134746 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134746&view=rev >> Log: >> Make tBX_RET and tBX_RET_vararg predicable. >> >> The normal tBX instruction is predicable, so there's no reason the >> pseudos for using it as a return shouldn't be. Gives us some nice code-gen >> improvements as can be seen by the test changes. In particular, several >> tests now have to disable if-conversion because it works too well and defeats >> the test. >> >> Modified: >> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >> llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp >> llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >> llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll >> llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll >> llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll >> >> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Fri Jul 8 16:50:04 2011 >> @@ -1538,7 +1538,10 @@ >> if (MI->getOpcode() == ARM::tPOP_RET && >> MI->getOperand(2).getReg() == ARM::PC && >> MI->getNumExplicitOperands() == 3) { >> - BuildMI(MI->getParent(), MI->getDebugLoc(), TII->get(ARM::tBX_RET)); >> + // Create the new insn and copy the predicate from the old. >> + BuildMI(MI->getParent(), MI->getDebugLoc(), TII->get(ARM::tBX_RET)) >> + .addOperand(MI->getOperand(0)) >> + .addOperand(MI->getOperand(1)); >> MI->eraseFromParent(); >> MadeChange = true; >> } >> >> Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) >> +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Fri Jul 8 16:50:04 2011 >> @@ -385,13 +385,13 @@ >> } >> >> let isReturn = 1, isTerminator = 1, isBarrier = 1 in { >> - def tBX_RET : tPseudoExpand<(outs), (ins), Size2Bytes, IIC_Br, >> - [(ARMretflag)], (tBX LR, (ops 14, zero_reg))>; >> + def tBX_RET : tPseudoExpand<(outs), (ins pred:$p), Size2Bytes, IIC_Br, >> + [(ARMretflag)], (tBX LR, pred:$p)>; >> >> // Alternative return instruction used by vararg functions. >> - def tBX_RET_vararg : tPseudoExpand<(outs), (ins tGPR:$Rm), >> + def tBX_RET_vararg : tPseudoExpand<(outs), (ins tGPR:$Rm, pred:$p), >> Size2Bytes, IIC_Br, [], >> - (tBX GPR:$Rm, (ops 14, zero_reg))>; >> + (tBX GPR:$Rm, pred:$p)>; >> } >> >> // All calls clobber the non-callee saved registers. SP is marked as a use to >> >> Modified: llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp Fri Jul 8 16:50:04 2011 >> @@ -273,8 +273,8 @@ >> >> emitSPUpdate(MBB, MBBI, TII, dl, *RegInfo, VARegSaveSize); >> >> - BuildMI(MBB, MBBI, dl, TII.get(ARM::tBX_RET_vararg)) >> - .addReg(ARM::R3, RegState::Kill); >> + AddDefaultPred(BuildMI(MBB, MBBI, dl, TII.get(ARM::tBX_RET_vararg)) >> + .addReg(ARM::R3, RegState::Kill)); >> // erase the old tBX_RET instruction >> MBB.erase(MBBI); >> } >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Jul 8 16:50:04 2011 >> @@ -8,26 +8,25 @@ >> define void @t1(i32* nocapture %vals, i32 %c) nounwind { >> entry: >> ; CHECK: t1: >> -; CHECK: cbz >> +; CHECK: bxeq lr >> + >> %0 = icmp eq i32 %c, 0 ; [#uses=1] >> br i1 %0, label %return, label %bb.nph >> >> bb.nph: ; preds = %entry >> -; CHECK: BB#1 >> ; CHECK: movw r[[R2:[0-9]+]], :lower16:L_GV$non_lazy_ptr >> ; CHECK: movt r[[R2]], :upper16:L_GV$non_lazy_ptr >> ; CHECK: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] >> ; CHECK: ldr{{.*}}, [r[[R2b]] >> -; CHECK: LBB0_2 >> +; CHECK: LBB0_ >> ; CHECK-NOT: LCPI0_0: >> >> -; PIC: BB#1 >> ; PIC: movw r[[R2:[0-9]+]], :lower16:(L_GV$non_lazy_ptr-(LPC0_0+4)) >> ; PIC: movt r[[R2]], :upper16:(L_GV$non_lazy_ptr-(LPC0_0+4)) >> ; PIC: add r[[R2]], pc >> ; PIC: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] >> ; PIC: ldr{{.*}}, [r[[R2b]] >> -; PIC: LBB0_2 >> +; PIC: LBB0_ >> ; PIC-NOT: LCPI0_0: >> ; PIC: .section >> %.pre = load i32* @GV, align 4 ; [#uses=1] >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll Fri Jul 8 16:50:04 2011 >> @@ -1,5 +1,7 @@ >> -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s >> -; RUN: llc < %s -march=thumb -mattr=+thumb2 | not grep it >> +; RUN: llc < %s -ifcvt-limit=0 -march=thumb -mattr=+thumb2 | FileCheck %s >> +; RUN: llc < %s -ifcvt-limit=0 -march=thumb -mattr=+thumb2 | not grep it >> +; If-conversion defeats the purpose of this test, which is to check CBZ >> +; generation, so turn it off. >> >> define i32 @t1(i32 %a, i32 %b, i32 %c) { >> ; CHECK: t1: >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll Fri Jul 8 16:50:04 2011 >> @@ -1,4 +1,6 @@ >> -; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s >> +; RUN: llc < %s -ifcvt-limit=0 -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s >> +; If-conversion defeats the purpose of this test, which is to check conditional >> +; branch generation, so turn it off. >> >> define i32 @f1(i32 %a, i32 %b, i32* %v) { >> entry: >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll?rev=134746&r1=134745&r2=134746&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll Fri Jul 8 16:50:04 2011 >> @@ -2,8 +2,10 @@ >> >> define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { >> ; CHECK: t1: >> -; CHECK: it ne >> +; CHECK: ittt ne >> ; CHECK: cmpne >> +; CHECK: addne >> +; CHECK: bxne lr >> switch i32 %c, label %cond_next [ >> i32 1, label %cond_true >> i32 7, label %cond_true >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Mon Jul 11 10:11:19 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 11 Jul 2011 08:11:19 -0700 Subject: [llvm-commits] [llvm] r134760 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/mode-switch.s In-Reply-To: <20110708223629.5AD072A6C12C@llvm.org> References: <20110708223629.5AD072A6C12C@llvm.org> Message-ID: Hi Evan, It's really great to have this. It's been a big problem with the ARM assembly handling for a long time. Some comments inline. On Jul 8, 2011, at 3:36 PM, Evan Cheng wrote: > Author: evancheng > Date: Fri Jul 8 17:36:29 2011 > New Revision: 134760 > > URL: http://llvm.org/viewvc/llvm-project?rev=134760&view=rev > Log: > Add support for ARM / Thumb mode switching with .code 16 and .code 32. > > Added: > llvm/trunk/test/MC/ARM/mode-switch.s > Modified: > llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp > > Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=134760&r1=134759&r2=134760&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) > +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Jul 8 17:36:29 2011 > @@ -42,7 +42,11 @@ > > class ARMAsmParser : public TargetAsmParser { > MCAsmParser &Parser; > - OwningPtr STI; > + /// STI, ARM_STI, Thumb_STI - Subtarget info for ARM and Thumb modes. STI > + /// points to either ARM_STI or Thumb_STI depending on the mode. > + const MCSubtargetInfo *STI; > + OwningPtr ARM_STI; > + OwningPtr Thumb_STI; > > MCAsmParser &getParser() const { return Parser; } > MCAsmLexer &getLexer() const { return Parser.getLexer(); } > @@ -89,10 +93,13 @@ > // FIXME: Can tablegen auto-generate this? > return (STI->getFeatureBits() & ARM::ModeThumb) != 0; > } > - > bool isThumbOne() const { > return isThumb() && (STI->getFeatureBits() & ARM::FeatureThumb2) == 0; > } > + void SwitchMode() { > + STI = isThumb() ? ARM_STI.get() : Thumb_STI.get(); > + setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); > + } > Perhaps better to use a standard setter method here with an explicit parameter indicating which is desired? That would be more consistent with the rest of the code, plus it would make the calling function(s) more explicit without the need for control flow. On the nitpicky side, the naming convention changed recently such that function names should always start with a lower-case letter. (i.e., switchMode() rather than SwitchMod()). > /// @name Auto-generated Match Functions > /// { > @@ -129,10 +136,24 @@ > > public: > ARMAsmParser(StringRef TT, StringRef CPU, StringRef FS, MCAsmParser &_Parser) > - : TargetAsmParser(), Parser(_Parser), > - STI(ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS)) { > - > + : TargetAsmParser(), Parser(_Parser) { > MCAsmParserExtension::Initialize(_Parser); > + > + STI = ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS); > + // FIXME: Design a better way to create two subtargets with only difference > + // being a feature change. > + if (isThumb()) { > + Thumb_STI.reset(STI); > + assert(TT.startswith("thumb") && "Unexpected Triple string for Thumb!"); > + Twine ARM_TT = "arm" + TT.substr(5); > + ARM_STI.reset(ARM_MC::createARMMCSubtargetInfo(ARM_TT.str(), CPU, FS)); > + } else { > + ARM_STI.reset(STI); > + assert(TT.startswith("arm") && "Unexpected Triple string for ARM!"); > + Twine Thumb_TT = "thumb" + TT.substr(3); > + Thumb_STI.reset(ARM_MC::createARMMCSubtargetInfo(Thumb_TT.str(),CPU, FS)); > + } > + I'm not sure I follow this bit. Why is this conditional on the starting mode? Don't we want to unconditionally create both STI's and then conditionally set the starting available features based on the which STI the mode indicates we should use? > // Initialize the set of available features. > setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); > } > @@ -2215,18 +2236,11 @@ > return Error(Parser.getTok().getLoc(), "unexpected token in directive"); > Parser.Lex(); > > - // FIXME: We need to be able switch subtargets at this point so that > - // MatchInstructionImpl() will work when it gets the AvailableFeatures which > - // includes Feature_IsThumb or not to match the right instructions. This is > - // blocked on the FIXME in llvm-mc.cpp when creating the TargetMachine. > - if (Val == 16){ > - assert(isThumb() && > - "switching between arm/thumb not yet suppported via .code 16)"); > + if (Val == 16) { > + if (!isThumb()) SwitchMode(); > getParser().getStreamer().EmitAssemblerFlag(MCAF_Code16); > - } > - else{ > - assert(!isThumb() && > - "switching between thumb/arm not yet suppported via .code 32)"); > + } else { > + if (isThumb()) SwitchMode(); > getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32); > } > > > Added: llvm/trunk/test/MC/ARM/mode-switch.s > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/mode-switch.s?rev=134760&view=auto > ============================================================================== > --- llvm/trunk/test/MC/ARM/mode-switch.s (added) > +++ llvm/trunk/test/MC/ARM/mode-switch.s Fri Jul 8 17:36:29 2011 > @@ -0,0 +1,16 @@ > +@ Test ARM / Thumb mode switching with .code > +@ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s > + > +.code 16 > + > +@ CHECK: add.w r0, r0, r1 @ encoding: [0x01,0x00,0x00,0xeb] > + add.w r0, r0, r1 > + > +.code 32 > +@ CHECK: add r0, r0, r1 @ encoding: [0x01,0x00,0x80,0xe0] > + add r0, r0, r1 > + > +.code 16 > +@ CHECK: add r0, r0, r1 @ encoding: [0x40,0x18] > + > + add r0, r0, r1 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Jul 11 11:07:35 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 09:07:35 -0700 Subject: [llvm-commits] [llvm] r134746 - in /llvm/trunk: lib/Target/ARM/ARMConstantIslandPass.cpp lib/Target/ARM/ARMInstrThumb.td lib/Target/ARM/Thumb1FrameLowering.cpp test/CodeGen/Thumb2/machine-licm.ll test/CodeGen/Thumb2/thumb2-bcc.ll test/CodeGen/Thumb2/thumb2-branch.ll test/CodeGen/Thumb2/thumb2-ifcvt1.ll In-Reply-To: <45BC38E9-CC2D-4E4B-B36A-463042E670A0@apple.com> References: <20110708215005.1EF1E2A6C12C@llvm.org> <45BC38E9-CC2D-4E4B-B36A-463042E670A0@apple.com> Message-ID: On Jul 11, 2011, at 7:49 AM, Jim Grosbach wrote: > > On Jul 9, 2011, at 4:47 PM, Evan Cheng wrote: > >> Hi Jim, >> >> It's generally a bad idea to use hidden options for these tests. Can you disable ifcvt another way? Have you tried specifying CPU name or adjust the tests? >> > > I agree it's suboptimal to reference those sorts of options. In this case I took it as the lesser of two evils, as adjusting the tests would either a) change them t no longer test what they are written to be testing, or b) obfuscate the test by enlarging them solely to defeat if-conversion. Neither of those options seems very appealing. > > I didn't see any other way to disable if conversion short of disabling optimization altogether. I don''t think a different CPU name would have any effect here. Did you have something specific in mind? If there's something along those lines that would work, that would be great. Yes, different cpu's have different misprediction costs which impact ifcvt. I don't know if it matters for these tests but it's worth trying. Evan > > -Jim > >> >> On Jul 8, 2011, at 2:50 PM, Jim Grosbach wrote: >> >>> Author: grosbach >>> Date: Fri Jul 8 16:50:04 2011 >>> New Revision: 134746 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=134746&view=rev >>> Log: >>> Make tBX_RET and tBX_RET_vararg predicable. >>> >>> The normal tBX instruction is predicable, so there's no reason the >>> pseudos for using it as a return shouldn't be. Gives us some nice code-gen >>> improvements as can be seen by the test changes. In particular, several >>> tests now have to disable if-conversion because it works too well and defeats >>> the test. >>> >>> Modified: >>> llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>> llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp >>> llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >>> llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll >>> llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll >>> llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Fri Jul 8 16:50:04 2011 >>> @@ -1538,7 +1538,10 @@ >>> if (MI->getOpcode() == ARM::tPOP_RET && >>> MI->getOperand(2).getReg() == ARM::PC && >>> MI->getNumExplicitOperands() == 3) { >>> - BuildMI(MI->getParent(), MI->getDebugLoc(), TII->get(ARM::tBX_RET)); >>> + // Create the new insn and copy the predicate from the old. >>> + BuildMI(MI->getParent(), MI->getDebugLoc(), TII->get(ARM::tBX_RET)) >>> + .addOperand(MI->getOperand(0)) >>> + .addOperand(MI->getOperand(1)); >>> MI->eraseFromParent(); >>> MadeChange = true; >>> } >>> >>> Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) >>> +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Fri Jul 8 16:50:04 2011 >>> @@ -385,13 +385,13 @@ >>> } >>> >>> let isReturn = 1, isTerminator = 1, isBarrier = 1 in { >>> - def tBX_RET : tPseudoExpand<(outs), (ins), Size2Bytes, IIC_Br, >>> - [(ARMretflag)], (tBX LR, (ops 14, zero_reg))>; >>> + def tBX_RET : tPseudoExpand<(outs), (ins pred:$p), Size2Bytes, IIC_Br, >>> + [(ARMretflag)], (tBX LR, pred:$p)>; >>> >>> // Alternative return instruction used by vararg functions. >>> - def tBX_RET_vararg : tPseudoExpand<(outs), (ins tGPR:$Rm), >>> + def tBX_RET_vararg : tPseudoExpand<(outs), (ins tGPR:$Rm, pred:$p), >>> Size2Bytes, IIC_Br, [], >>> - (tBX GPR:$Rm, (ops 14, zero_reg))>; >>> + (tBX GPR:$Rm, pred:$p)>; >>> } >>> >>> // All calls clobber the non-callee saved registers. SP is marked as a use to >>> >>> Modified: llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/Thumb1FrameLowering.cpp Fri Jul 8 16:50:04 2011 >>> @@ -273,8 +273,8 @@ >>> >>> emitSPUpdate(MBB, MBBI, TII, dl, *RegInfo, VARegSaveSize); >>> >>> - BuildMI(MBB, MBBI, dl, TII.get(ARM::tBX_RET_vararg)) >>> - .addReg(ARM::R3, RegState::Kill); >>> + AddDefaultPred(BuildMI(MBB, MBBI, dl, TII.get(ARM::tBX_RET_vararg)) >>> + .addReg(ARM::R3, RegState::Kill)); >>> // erase the old tBX_RET instruction >>> MBB.erase(MBBI); >>> } >>> >>> Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) >>> +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Jul 8 16:50:04 2011 >>> @@ -8,26 +8,25 @@ >>> define void @t1(i32* nocapture %vals, i32 %c) nounwind { >>> entry: >>> ; CHECK: t1: >>> -; CHECK: cbz >>> +; CHECK: bxeq lr >>> + >>> %0 = icmp eq i32 %c, 0 ; [#uses=1] >>> br i1 %0, label %return, label %bb.nph >>> >>> bb.nph: ; preds = %entry >>> -; CHECK: BB#1 >>> ; CHECK: movw r[[R2:[0-9]+]], :lower16:L_GV$non_lazy_ptr >>> ; CHECK: movt r[[R2]], :upper16:L_GV$non_lazy_ptr >>> ; CHECK: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] >>> ; CHECK: ldr{{.*}}, [r[[R2b]] >>> -; CHECK: LBB0_2 >>> +; CHECK: LBB0_ >>> ; CHECK-NOT: LCPI0_0: >>> >>> -; PIC: BB#1 >>> ; PIC: movw r[[R2:[0-9]+]], :lower16:(L_GV$non_lazy_ptr-(LPC0_0+4)) >>> ; PIC: movt r[[R2]], :upper16:(L_GV$non_lazy_ptr-(LPC0_0+4)) >>> ; PIC: add r[[R2]], pc >>> ; PIC: ldr{{(.w)?}} r[[R2b:[0-9]+]], [r[[R2]] >>> ; PIC: ldr{{.*}}, [r[[R2b]] >>> -; PIC: LBB0_2 >>> +; PIC: LBB0_ >>> ; PIC-NOT: LCPI0_0: >>> ; PIC: .section >>> %.pre = load i32* @GV, align 4 ; [#uses=1] >>> >>> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll (original) >>> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-bcc.ll Fri Jul 8 16:50:04 2011 >>> @@ -1,5 +1,7 @@ >>> -; RUN: llc < %s -march=thumb -mattr=+thumb2 | FileCheck %s >>> -; RUN: llc < %s -march=thumb -mattr=+thumb2 | not grep it >>> +; RUN: llc < %s -ifcvt-limit=0 -march=thumb -mattr=+thumb2 | FileCheck %s >>> +; RUN: llc < %s -ifcvt-limit=0 -march=thumb -mattr=+thumb2 | not grep it >>> +; If-conversion defeats the purpose of this test, which is to check CBZ >>> +; generation, so turn it off. >>> >>> define i32 @t1(i32 %a, i32 %b, i32 %c) { >>> ; CHECK: t1: >>> >>> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll (original) >>> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-branch.ll Fri Jul 8 16:50:04 2011 >>> @@ -1,4 +1,6 @@ >>> -; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s >>> +; RUN: llc < %s -ifcvt-limit=0 -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s >>> +; If-conversion defeats the purpose of this test, which is to check conditional >>> +; branch generation, so turn it off. >>> >>> define i32 @f1(i32 %a, i32 %b, i32* %v) { >>> entry: >>> >>> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll?rev=134746&r1=134745&r2=134746&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll (original) >>> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1.ll Fri Jul 8 16:50:04 2011 >>> @@ -2,8 +2,10 @@ >>> >>> define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { >>> ; CHECK: t1: >>> -; CHECK: it ne >>> +; CHECK: ittt ne >>> ; CHECK: cmpne >>> +; CHECK: addne >>> +; CHECK: bxne lr >>> switch i32 %c, label %cond_next [ >>> i32 1, label %cond_true >>> i32 7, label %cond_true >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From evan.cheng at apple.com Mon Jul 11 11:10:45 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 09:10:45 -0700 Subject: [llvm-commits] [llvm] r134760 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/mode-switch.s In-Reply-To: References: <20110708223629.5AD072A6C12C@llvm.org> Message-ID: On Jul 11, 2011, at 8:11 AM, Jim Grosbach wrote: > Hi Evan, > > It's really great to have this. It's been a big problem with the ARM assembly handling for a long time. Some comments inline. > > On Jul 8, 2011, at 3:36 PM, Evan Cheng wrote: > >> Author: evancheng >> Date: Fri Jul 8 17:36:29 2011 >> New Revision: 134760 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134760&view=rev >> Log: >> Add support for ARM / Thumb mode switching with .code 16 and .code 32. >> >> Added: >> llvm/trunk/test/MC/ARM/mode-switch.s >> Modified: >> llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp >> >> Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=134760&r1=134759&r2=134760&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Jul 8 17:36:29 2011 >> @@ -42,7 +42,11 @@ >> >> class ARMAsmParser : public TargetAsmParser { >> MCAsmParser &Parser; >> - OwningPtr STI; >> + /// STI, ARM_STI, Thumb_STI - Subtarget info for ARM and Thumb modes. STI >> + /// points to either ARM_STI or Thumb_STI depending on the mode. >> + const MCSubtargetInfo *STI; >> + OwningPtr ARM_STI; >> + OwningPtr Thumb_STI; >> >> MCAsmParser &getParser() const { return Parser; } >> MCAsmLexer &getLexer() const { return Parser.getLexer(); } >> @@ -89,10 +93,13 @@ >> // FIXME: Can tablegen auto-generate this? >> return (STI->getFeatureBits() & ARM::ModeThumb) != 0; >> } >> - >> bool isThumbOne() const { >> return isThumb() && (STI->getFeatureBits() & ARM::FeatureThumb2) == 0; >> } >> + void SwitchMode() { >> + STI = isThumb() ? ARM_STI.get() : Thumb_STI.get(); >> + setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); >> + } >> > > Perhaps better to use a standard setter method here with an explicit parameter indicating which is desired? That would be more consistent with the rest of the code, plus it would make the calling function(s) more explicit without the need for control flow. I plan to change this to avoid unnecessarily recompute features. > > On the nitpicky side, the naming convention changed recently such that function names should always start with a lower-case letter. (i.e., switchMode() rather than SwitchMod()). > >> /// @name Auto-generated Match Functions >> /// { >> @@ -129,10 +136,24 @@ >> >> public: >> ARMAsmParser(StringRef TT, StringRef CPU, StringRef FS, MCAsmParser &_Parser) >> - : TargetAsmParser(), Parser(_Parser), >> - STI(ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS)) { >> - >> + : TargetAsmParser(), Parser(_Parser) { >> MCAsmParserExtension::Initialize(_Parser); >> + >> + STI = ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS); >> + // FIXME: Design a better way to create two subtargets with only difference >> + // being a feature change. >> + if (isThumb()) { >> + Thumb_STI.reset(STI); >> + assert(TT.startswith("thumb") && "Unexpected Triple string for Thumb!"); >> + Twine ARM_TT = "arm" + TT.substr(5); >> + ARM_STI.reset(ARM_MC::createARMMCSubtargetInfo(ARM_TT.str(), CPU, FS)); >> + } else { >> + ARM_STI.reset(STI); >> + assert(TT.startswith("arm") && "Unexpected Triple string for ARM!"); >> + Twine Thumb_TT = "thumb" + TT.substr(3); >> + Thumb_STI.reset(ARM_MC::createARMMCSubtargetInfo(Thumb_TT.str(),CPU, FS)); >> + } >> + > > I'm not sure I follow this bit. Why is this conditional on the starting mode? Don't we want to unconditionally create both STI's and then conditionally set the starting available features based on the which STI the mode indicates we should use? This code has completely changed already. Evan > >> // Initialize the set of available features. >> setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); >> } >> @@ -2215,18 +2236,11 @@ >> return Error(Parser.getTok().getLoc(), "unexpected token in directive"); >> Parser.Lex(); >> >> - // FIXME: We need to be able switch subtargets at this point so that >> - // MatchInstructionImpl() will work when it gets the AvailableFeatures which >> - // includes Feature_IsThumb or not to match the right instructions. This is >> - // blocked on the FIXME in llvm-mc.cpp when creating the TargetMachine. >> - if (Val == 16){ >> - assert(isThumb() && >> - "switching between arm/thumb not yet suppported via .code 16)"); >> + if (Val == 16) { >> + if (!isThumb()) SwitchMode(); >> getParser().getStreamer().EmitAssemblerFlag(MCAF_Code16); >> - } >> - else{ >> - assert(!isThumb() && >> - "switching between thumb/arm not yet suppported via .code 32)"); >> + } else { >> + if (isThumb()) SwitchMode(); >> getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32); >> } >> >> >> Added: llvm/trunk/test/MC/ARM/mode-switch.s >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/mode-switch.s?rev=134760&view=auto >> ============================================================================== >> --- llvm/trunk/test/MC/ARM/mode-switch.s (added) >> +++ llvm/trunk/test/MC/ARM/mode-switch.s Fri Jul 8 17:36:29 2011 >> @@ -0,0 +1,16 @@ >> +@ Test ARM / Thumb mode switching with .code >> +@ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s >> + >> +.code 16 >> + >> +@ CHECK: add.w r0, r0, r1 @ encoding: [0x01,0x00,0x00,0xeb] >> + add.w r0, r0, r1 >> + >> +.code 32 >> +@ CHECK: add r0, r0, r1 @ encoding: [0x01,0x00,0x80,0xe0] >> + add r0, r0, r1 >> + >> +.code 16 >> +@ CHECK: add r0, r0, r1 @ encoding: [0x40,0x18] >> + >> + add r0, r0, r1 >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From grosbach at apple.com Mon Jul 11 11:12:03 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 11 Jul 2011 09:12:03 -0700 Subject: [llvm-commits] [llvm] r134760 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/mode-switch.s In-Reply-To: References: <20110708223629.5AD072A6C12C@llvm.org> Message-ID: Cool. Thanks! -Jim On Jul 11, 2011, at 9:10 AM, Evan Cheng wrote: > > > On Jul 11, 2011, at 8:11 AM, Jim Grosbach wrote: > >> Hi Evan, >> >> It's really great to have this. It's been a big problem with the ARM assembly handling for a long time. Some comments inline. >> >> On Jul 8, 2011, at 3:36 PM, Evan Cheng wrote: >> >>> Author: evancheng >>> Date: Fri Jul 8 17:36:29 2011 >>> New Revision: 134760 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=134760&view=rev >>> Log: >>> Add support for ARM / Thumb mode switching with .code 16 and .code 32. >>> >>> Added: >>> llvm/trunk/test/MC/ARM/mode-switch.s >>> Modified: >>> llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp >>> >>> Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=134760&r1=134759&r2=134760&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Jul 8 17:36:29 2011 >>> @@ -42,7 +42,11 @@ >>> >>> class ARMAsmParser : public TargetAsmParser { >>> MCAsmParser &Parser; >>> - OwningPtr STI; >>> + /// STI, ARM_STI, Thumb_STI - Subtarget info for ARM and Thumb modes. STI >>> + /// points to either ARM_STI or Thumb_STI depending on the mode. >>> + const MCSubtargetInfo *STI; >>> + OwningPtr ARM_STI; >>> + OwningPtr Thumb_STI; >>> >>> MCAsmParser &getParser() const { return Parser; } >>> MCAsmLexer &getLexer() const { return Parser.getLexer(); } >>> @@ -89,10 +93,13 @@ >>> // FIXME: Can tablegen auto-generate this? >>> return (STI->getFeatureBits() & ARM::ModeThumb) != 0; >>> } >>> - >>> bool isThumbOne() const { >>> return isThumb() && (STI->getFeatureBits() & ARM::FeatureThumb2) == 0; >>> } >>> + void SwitchMode() { >>> + STI = isThumb() ? ARM_STI.get() : Thumb_STI.get(); >>> + setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); >>> + } >>> >> >> Perhaps better to use a standard setter method here with an explicit parameter indicating which is desired? That would be more consistent with the rest of the code, plus it would make the calling function(s) more explicit without the need for control flow. > > I plan to change this to avoid unnecessarily recompute features. > > >> >> On the nitpicky side, the naming convention changed recently such that function names should always start with a lower-case letter. (i.e., switchMode() rather than SwitchMod()). >> >>> /// @name Auto-generated Match Functions >>> /// { >>> @@ -129,10 +136,24 @@ >>> >>> public: >>> ARMAsmParser(StringRef TT, StringRef CPU, StringRef FS, MCAsmParser &_Parser) >>> - : TargetAsmParser(), Parser(_Parser), >>> - STI(ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS)) { >>> - >>> + : TargetAsmParser(), Parser(_Parser) { >>> MCAsmParserExtension::Initialize(_Parser); >>> + >>> + STI = ARM_MC::createARMMCSubtargetInfo(TT, CPU, FS); >>> + // FIXME: Design a better way to create two subtargets with only difference >>> + // being a feature change. >>> + if (isThumb()) { >>> + Thumb_STI.reset(STI); >>> + assert(TT.startswith("thumb") && "Unexpected Triple string for Thumb!"); >>> + Twine ARM_TT = "arm" + TT.substr(5); >>> + ARM_STI.reset(ARM_MC::createARMMCSubtargetInfo(ARM_TT.str(), CPU, FS)); >>> + } else { >>> + ARM_STI.reset(STI); >>> + assert(TT.startswith("arm") && "Unexpected Triple string for ARM!"); >>> + Twine Thumb_TT = "thumb" + TT.substr(3); >>> + Thumb_STI.reset(ARM_MC::createARMMCSubtargetInfo(Thumb_TT.str(),CPU, FS)); >>> + } >>> + >> >> I'm not sure I follow this bit. Why is this conditional on the starting mode? Don't we want to unconditionally create both STI's and then conditionally set the starting available features based on the which STI the mode indicates we should use? > > This code has completely changed already. > > Evan > >> >>> // Initialize the set of available features. >>> setAvailableFeatures(ComputeAvailableFeatures(STI->getFeatureBits())); >>> } >>> @@ -2215,18 +2236,11 @@ >>> return Error(Parser.getTok().getLoc(), "unexpected token in directive"); >>> Parser.Lex(); >>> >>> - // FIXME: We need to be able switch subtargets at this point so that >>> - // MatchInstructionImpl() will work when it gets the AvailableFeatures which >>> - // includes Feature_IsThumb or not to match the right instructions. This is >>> - // blocked on the FIXME in llvm-mc.cpp when creating the TargetMachine. >>> - if (Val == 16){ >>> - assert(isThumb() && >>> - "switching between arm/thumb not yet suppported via .code 16)"); >>> + if (Val == 16) { >>> + if (!isThumb()) SwitchMode(); >>> getParser().getStreamer().EmitAssemblerFlag(MCAF_Code16); >>> - } >>> - else{ >>> - assert(!isThumb() && >>> - "switching between thumb/arm not yet suppported via .code 32)"); >>> + } else { >>> + if (isThumb()) SwitchMode(); >>> getParser().getStreamer().EmitAssemblerFlag(MCAF_Code32); >>> } >>> >>> >>> Added: llvm/trunk/test/MC/ARM/mode-switch.s >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/mode-switch.s?rev=134760&view=auto >>> ============================================================================== >>> --- llvm/trunk/test/MC/ARM/mode-switch.s (added) >>> +++ llvm/trunk/test/MC/ARM/mode-switch.s Fri Jul 8 17:36:29 2011 >>> @@ -0,0 +1,16 @@ >>> +@ Test ARM / Thumb mode switching with .code >>> +@ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s >>> + >>> +.code 16 >>> + >>> +@ CHECK: add.w r0, r0, r1 @ encoding: [0x01,0x00,0x00,0xeb] >>> + add.w r0, r0, r1 >>> + >>> +.code 32 >>> +@ CHECK: add r0, r0, r1 @ encoding: [0x01,0x00,0x80,0xe0] >>> + add r0, r0, r1 >>> + >>> +.code 16 >>> +@ CHECK: add r0, r0, r1 @ encoding: [0x40,0x18] >>> + >>> + add r0, r0, r1 >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From geek4civic at gmail.com Mon Jul 11 11:21:52 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 11 Jul 2011 16:21:52 -0000 Subject: [llvm-commits] [llvm] r134900 - /llvm/trunk/test/CodeGen/PowerPC/vector.ll Message-ID: <20110711162152.846B92A6C12D@llvm.org> Author: chapuni Date: Mon Jul 11 11:21:52 2011 New Revision: 134900 URL: http://llvm.org/viewvc/llvm-project?rev=134900&view=rev Log: test/CodeGen/PowerPC/vector.ll: Tweak redirection >%t >%t to >%t >>%t. See also r134814 (test/CodeGen/X86/vector.ll). Modified: llvm/trunk/test/CodeGen/PowerPC/vector.ll Modified: llvm/trunk/test/CodeGen/PowerPC/vector.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/vector.ll?rev=134900&r1=134899&r2=134900&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/PowerPC/vector.ll (original) +++ llvm/trunk/test/CodeGen/PowerPC/vector.ll Mon Jul 11 11:21:52 2011 @@ -1,6 +1,6 @@ ; Test that vectors are scalarized/lowered correctly. ; RUN: llc < %s -march=ppc32 -mcpu=g5 > %t -; RUN: llc < %s -march=ppc32 -mcpu=g3 > %t +; RUN: llc < %s -march=ppc32 -mcpu=g3 >> %t %d8 = type <8 x double> %f1 = type <1 x float> From gvenn.cfe.dev at gmail.com Mon Jul 11 11:31:53 2011 From: gvenn.cfe.dev at gmail.com (Garrison Venn) Date: Mon, 11 Jul 2011 16:31:53 -0000 Subject: [llvm-commits] [llvm] r134901 - /llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp Message-ID: <20110711163153.7A8E92A6C12D@llvm.org> Author: gvenn Date: Mon Jul 11 11:31:53 2011 New Revision: 134901 URL: http://llvm.org/viewvc/llvm-project?rev=134901&view=rev Log: Modified demo to work with non const Type parameters as is required by new type system. However most of these modifications were due to IRBuilder (IRBuilderBase), not having been modified to NOT return such const qualified free types. If IRBuilder does not change, as can also be seen in its instruction creation methods, to use const free types, it may be useful to have ExceptionDemo drop IRBuilder usage. Modifying builder.getInt32Ty() to llvm::Type::getInt32Ty(builder.getContext()) is pretty ugly. Modified: llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp Modified: llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp?rev=134901&r1=134900&r2=134901&view=diff ============================================================================== --- llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp (original) +++ llvm/trunk/examples/ExceptionDemo/ExceptionDemo.cpp Mon Jul 11 11:31:53 2011 @@ -190,7 +190,7 @@ static llvm::ConstantInt *ourExceptionCaughtState; typedef std::vector ArgNames; -typedef std::vector ArgTypes; +typedef std::vector ArgTypes; // // Code Generation Utilities @@ -987,7 +987,7 @@ ourExceptionNotThrownState); const llvm::PointerType *exceptionStorageType = - builder.getInt8Ty()->getPointerTo(); + builder.getInt8Ty()->getPointerTo(); *exceptionStorage = createEntryBlockAlloca(toAddTo, "exceptionStorage", @@ -1098,7 +1098,7 @@ llvm::Function *toPrint32Int = module.getFunction("print32Int"); ArgTypes argTypes; - argTypes.push_back(builder.getInt32Ty()); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); ArgNames argNames; argNames.push_back("exceptTypeToThrow"); @@ -1376,7 +1376,7 @@ llvm::LLVMContext &context = module.getContext(); namedValues.clear(); ArgTypes unwindArgTypes; - unwindArgTypes.push_back(builder.getInt32Ty()); + unwindArgTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); ArgNames unwindArgNames; unwindArgNames.push_back("exceptTypeToThrow"); @@ -1622,7 +1622,7 @@ // End test functions // -typedef llvm::ArrayRef TypeArray; +typedef llvm::ArrayRef TypeArray; /// This initialization routine creates type info globals and /// adds external function declarations to module. @@ -1650,8 +1650,7 @@ // Create our type info type ourTypeInfoType = llvm::StructType::get(context, - TypeArray(builder.getInt32Ty())); - + TypeArray(llvm::Type::getInt32Ty(builder.getContext()))); // Create OurException type ourExceptionType = llvm::StructType::get(context, TypeArray(ourTypeInfoType)); @@ -1661,7 +1660,9 @@ // Note: Declaring only a portion of the _Unwind_Exception struct. // Does this cause problems? ourUnwindExceptionType = - llvm::StructType::get(context, TypeArray(builder.getInt64Ty())); + llvm::StructType::get(context, + TypeArray(llvm::Type::getInt64Ty(builder.getContext()))); + struct OurBaseException_t dummyException; // Calculate offset of OurException::unwindException member. @@ -1726,7 +1727,7 @@ const llvm::Type *retType = builder.getVoidTy(); argTypes.clear(); - argTypes.push_back(builder.getInt32Ty()); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); argTypes.push_back(builder.getInt8Ty()->getPointerTo()); argNames.clear(); @@ -1745,7 +1746,7 @@ retType = builder.getVoidTy(); argTypes.clear(); - argTypes.push_back(builder.getInt64Ty()); + argTypes.push_back(llvm::Type::getInt64Ty(builder.getContext())); argTypes.push_back(builder.getInt8Ty()->getPointerTo()); argNames.clear(); @@ -1782,7 +1783,7 @@ retType = builder.getVoidTy(); argTypes.clear(); - argTypes.push_back(builder.getInt32Ty()); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); argNames.clear(); @@ -1818,7 +1819,7 @@ retType = builder.getInt8Ty()->getPointerTo(); argTypes.clear(); - argTypes.push_back(builder.getInt32Ty()); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); argNames.clear(); @@ -1876,9 +1877,9 @@ retType = builder.getInt32Ty(); argTypes.clear(); - argTypes.push_back(builder.getInt32Ty()); - argTypes.push_back(builder.getInt32Ty()); - argTypes.push_back(builder.getInt64Ty()); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); + argTypes.push_back(llvm::Type::getInt32Ty(builder.getContext())); + argTypes.push_back(llvm::Type::getInt64Ty(builder.getContext())); argTypes.push_back(builder.getInt8Ty()->getPointerTo()); argTypes.push_back(builder.getInt8Ty()->getPointerTo()); From grosbach at apple.com Mon Jul 11 11:48:36 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 11 Jul 2011 16:48:36 -0000 Subject: [llvm-commits] [llvm] r134902 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.h test/CodeGen/ARM/constants.ll test/CodeGen/ARM/fast-isel.ll test/CodeGen/ARM/fp.ll test/CodeGen/ARM/long.ll test/CodeGen/ARM/select-imm.ll test/CodeGen/ARM/select_xform.ll test/CodeGen/ARM/sub.ll test/MC/ARM/simple-encoding.ll test/MC/Disassembler/ARM/arm-tests.txt Message-ID: <20110711164836.ED8EF2A6C12C@llvm.org> Author: grosbach Date: Mon Jul 11 11:48:36 2011 New Revision: 134902 URL: http://llvm.org/viewvc/llvm-project?rev=134902&view=rev Log: Simplify printing of ARM shifted immediates. Print shifted immediate values directly rather than as a payload+shifter value pair. This makes for more readable output assembly code, simplifies the instruction printer, and is consistent with how Thumb immediates are displayed. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h llvm/trunk/test/CodeGen/ARM/constants.ll llvm/trunk/test/CodeGen/ARM/fast-isel.ll llvm/trunk/test/CodeGen/ARM/fp.ll llvm/trunk/test/CodeGen/ARM/long.ll llvm/trunk/test/CodeGen/ARM/select-imm.ll llvm/trunk/test/CodeGen/ARM/select_xform.ll llvm/trunk/test/CodeGen/ARM/sub.ll llvm/trunk/test/MC/ARM/simple-encoding.ll llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Mon Jul 11 11:48:36 2011 @@ -434,7 +434,6 @@ return ARM_AM::getSOImmVal(Imm) != -1; }]> { let EncoderMethod = "getSOImmOpValue"; - let PrintMethod = "printSOImmOperand"; } // Break so_imm's up into two pieces. This handles immediates with up to 16 Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Mon Jul 11 11:48:36 2011 @@ -126,38 +126,6 @@ } } -static void printSOImm(raw_ostream &O, int64_t V, raw_ostream *CommentStream, - const MCAsmInfo *MAI) { - // Break it up into two parts that make up a shifter immediate. - V = ARM_AM::getSOImmVal(V); - assert(V != -1 && "Not a valid so_imm value!"); - - unsigned Imm = ARM_AM::getSOImmValImm(V); - unsigned Rot = ARM_AM::getSOImmValRot(V); - - // Print low-level immediate formation info, per - // A5.2.3: Data-processing (immediate), and - // A5.2.4: Modified immediate constants in ARM instructions - if (Rot) { - O << "#" << Imm << ", #" << Rot; - // Pretty printed version. - if (CommentStream) - *CommentStream << (int)ARM_AM::rotr32(Imm, Rot) << "\n"; - } else { - O << "#" << Imm; - } -} - - -/// printSOImmOperand - SOImm is 4-bit rotate amount in bits 8-11 with 8-bit -/// immediate in bits 0-7. -void ARMInstPrinter::printSOImmOperand(const MCInst *MI, unsigned OpNum, - raw_ostream &O) { - const MCOperand &MO = MI->getOperand(OpNum); - assert(MO.isImm() && "Not a valid so_imm value!"); - printSOImm(O, MO.getImm(), CommentStream, &MAI); -} - // so_reg is a 4-operand unit corresponding to register forms of the A5.1 // "Addressing Mode 1 - Data-processing operands" forms. This includes: // REG 0 0 - e.g. R5 Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h Mon Jul 11 11:48:36 2011 @@ -38,8 +38,6 @@ void printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O); - void printSOImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); - void printSORegOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printAddrMode2Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O); Modified: llvm/trunk/test/CodeGen/ARM/constants.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/constants.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/constants.ll (original) +++ llvm/trunk/test/CodeGen/ARM/constants.ll Mon Jul 11 11:48:36 2011 @@ -14,31 +14,31 @@ define i32 @f3() { ; CHECK: f3 -; CHECK: mov r0, #1, #24 +; CHECK: mov r0, #256 ret i32 256 } define i32 @f4() { ; CHECK: f4 -; CHECK: orr{{.*}}#1, #24 +; CHECK: orr{{.*}}#256 ret i32 257 } define i32 @f5() { ; CHECK: f5 -; CHECK: mov r0, #255, #2 +; CHECK: mov r0, #-1073741761 ret i32 -1073741761 } define i32 @f6() { ; CHECK: f6 -; CHECK: mov r0, #63, #28 +; CHECK: mov r0, #1008 ret i32 1008 } define void @f7(i32 %a) { ; CHECK: f7 -; CHECK: cmp r0, #1, #16 +; CHECK: cmp r0, #65536 %b = icmp ugt i32 %a, 65536 br i1 %b, label %r, label %r r: Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Mon Jul 11 11:48:36 2011 @@ -43,7 +43,7 @@ br label %b2 ; THUMB: add.w {{.*}} #4096 -; ARM: add {{.*}} #1, #20 +; ARM: add {{.*}} #4096 b2: %b = add i32 %tmp, 4095 Modified: llvm/trunk/test/CodeGen/ARM/fp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fp.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/fp.ll (original) +++ llvm/trunk/test/CodeGen/ARM/fp.ll Mon Jul 11 11:48:36 2011 @@ -42,7 +42,7 @@ define double @h(double* %v) { ;CHECK: h: -;CHECK: vldr.64 +;CHECK: vldr.64 ;CHECK-NEXT: vmov entry: %tmp = load double* %v ; [#uses=1] @@ -51,7 +51,7 @@ define float @h2() { ;CHECK: h2: -;CHECK: mov r0, #254, #10 +;CHECK: mov r0, #1065353216 entry: ret float 1.000000e+00 } Modified: llvm/trunk/test/CodeGen/ARM/long.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/long.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/long.ll (original) +++ llvm/trunk/test/CodeGen/ARM/long.ll Mon Jul 11 11:48:36 2011 @@ -14,14 +14,14 @@ define i64 @f3() { ; CHECK: f3: -; CHECK: mvn r0, #2, #2 +; CHECK: mvn r0, #-2147483648 entry: ret i64 2147483647 } define i64 @f4() { ; CHECK: f4: -; CHECK: mov r0, #2, #2 +; CHECK: mov r0, #-2147483648 entry: ret i64 2147483648 } @@ -29,7 +29,7 @@ define i64 @f5() { ; CHECK: f5: ; CHECK: mvn r0, #0 -; CHECK: mvn r1, #2, #2 +; CHECK: mvn r1, #-2147483648 entry: ret i64 9223372036854775807 } Modified: llvm/trunk/test/CodeGen/ARM/select-imm.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select-imm.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/select-imm.ll (original) +++ llvm/trunk/test/CodeGen/ARM/select-imm.ll Mon Jul 11 11:48:36 2011 @@ -6,7 +6,7 @@ entry: ; ARM: t1: ; ARM: mov [[R1:r[0-9]+]], #101 -; ARM: orr [[R1b:r[0-9]+]], [[R1]], #1, #24 +; ARM: orr [[R1b:r[0-9]+]], [[R1]], #256 ; ARM: movgt r0, #123 ; ARMT2: t1: @@ -27,7 +27,7 @@ ; ARM: t2: ; ARM: mov r0, #123 ; ARM: movgt r0, #101 -; ARM: orrgt r0, r0, #1, #24 +; ARM: orrgt r0, r0, #256 ; ARMT2: t2: ; ARMT2: mov r0, #123 Modified: llvm/trunk/test/CodeGen/ARM/select_xform.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select_xform.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/select_xform.ll (original) +++ llvm/trunk/test/CodeGen/ARM/select_xform.ll Mon Jul 11 11:48:36 2011 @@ -4,7 +4,7 @@ define i32 @t1(i32 %a, i32 %b, i32 %c) nounwind { ; ARM: t1: -; ARM: sub r0, r1, #6, #2 +; ARM: sub r0, r1, #-2147483647 ; ARM: movgt r0, r1 ; T2: t1: Modified: llvm/trunk/test/CodeGen/ARM/sub.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/sub.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/sub.ll (original) +++ llvm/trunk/test/CodeGen/ARM/sub.ll Mon Jul 11 11:48:36 2011 @@ -12,7 +12,7 @@ ; 66846720 = 0x03fc0000 define i64 @f2(i64 %a) { ; CHECK: f2 -; CHECK: subs r0, r0, #255, #14 +; CHECK: subs r0, r0, #66846720 ; CHECK: sbc r1, r1, #0 %tmp = sub i64 %a, 66846720 ret i64 %tmp Modified: llvm/trunk/test/MC/ARM/simple-encoding.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-encoding.ll?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/simple-encoding.ll (original) +++ llvm/trunk/test/MC/ARM/simple-encoding.ll Mon Jul 11 11:48:36 2011 @@ -39,8 +39,7 @@ define i32 @f4(i32 %a, i32 %b) { ; CHECK: f4 -; CHECK: add r0, r0, #254, #28 @ encoding: [0xfe,0x0e,0x80,0xe2] -; CHECK: @ 4064 +; CHECK: add r0, r0, #4064 @ encoding: [0xfe,0x0e,0x80,0xe2] ; CHECK: bx lr @ encoding: [0x1e,0xff,0x2f,0xe1] %add = add nsw i32 %a, 4064 ret i32 %add @@ -118,7 +117,7 @@ define i64 @f13() { ; CHECK: f13: ; CHECK: mvn r0, #0 @ encoding: [0x00,0x00,0xe0,0xe3] -; CHECK: mvn r1, #2, #2 @ encoding: [0x02,0x11,0xe0,0xe3] +; CHECK: mvn r1, #-2147483648 @ encoding: [0x02,0x11,0xe0,0xe3] ret i64 9223372036854775807 } @@ -229,7 +228,7 @@ define void @f24(i32 %a) { ; CHECK: f24 -; CHECK: cmp r0, #1, #16 @ encoding: [0x01,0x08,0x50,0xe3] +; CHECK: cmp r0, #65536 @ encoding: [0x01,0x08,0x50,0xe3] %b = icmp ugt i32 %a, 65536 br i1 %b, label %r, label %r r: Modified: llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt?rev=134902&r1=134901&r2=134902&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/ARM/arm-tests.txt Mon Jul 11 11:48:36 2011 @@ -1,6 +1,6 @@ # RUN: llvm-mc --disassemble %s -triple=arm-apple-darwin9 | FileCheck %s -# CHECK: addpl r4, pc, #19, #8 +# CHECK: addpl r4, pc, #318767104 0x4c 0x45 0x8f 0x52 # CHECK: b #0 @@ -21,7 +21,7 @@ # CHECK: mov pc, lr 0x0e 0xf0 0xa0 0xe1 -# CHECK: mov pc, #255, #2 +# CHECK: mov pc, #3221225535 0xff 0xf1 0xa0 0xe3 # CHECK: movw r7, #4096 @@ -72,7 +72,7 @@ # CHECK: movt r8, #65535 0xff 0x8f 0x4f 0xe3 -# CHECK: mvnspl r7, #245, #2 +# CHECK: mvnspl r7, #1073741885 0xf5 0x71 0xf0 0x53 # CHECK-NOT: orr r7, r8, r7, rrx #0 @@ -152,7 +152,7 @@ # CHECK: msr cpsr_fc, r0 0x00 0xf0 0x29 0xe1 -# CHECK: msrmi cpsr_c, #241, #8 +# CHECK: msrmi cpsr_c, #4043309056 0xf1 0xf4 0x21 0x43 # CHECK: rsbs r6, r7, r8 From grosbach at apple.com Mon Jul 11 12:09:57 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 11 Jul 2011 17:09:57 -0000 Subject: [llvm-commits] [llvm] r134903 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/basic-arm-instructions.s Message-ID: <20110711170957.62EE92A6C12C@llvm.org> Author: grosbach Date: Mon Jul 11 12:09:57 2011 New Revision: 134903 URL: http://llvm.org/viewvc/llvm-project?rev=134903&view=rev Log: Fix recognition of ARM 'adcs' mnemonic. The 'CS' is not a predication suffix in this case. Added: llvm/trunk/test/MC/ARM/basic-arm-instructions.s Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=134903&r1=134902&r2=134903&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Jul 11 12:09:57 2011 @@ -1808,29 +1808,32 @@ Mnemonic == "vqdmlal" || Mnemonic == "bics")) return Mnemonic; - // First, split out any predication code. - unsigned CC = StringSwitch(Mnemonic.substr(Mnemonic.size()-2)) - .Case("eq", ARMCC::EQ) - .Case("ne", ARMCC::NE) - .Case("hs", ARMCC::HS) - .Case("cs", ARMCC::HS) - .Case("lo", ARMCC::LO) - .Case("cc", ARMCC::LO) - .Case("mi", ARMCC::MI) - .Case("pl", ARMCC::PL) - .Case("vs", ARMCC::VS) - .Case("vc", ARMCC::VC) - .Case("hi", ARMCC::HI) - .Case("ls", ARMCC::LS) - .Case("ge", ARMCC::GE) - .Case("lt", ARMCC::LT) - .Case("gt", ARMCC::GT) - .Case("le", ARMCC::LE) - .Case("al", ARMCC::AL) - .Default(~0U); - if (CC != ~0U) { - Mnemonic = Mnemonic.slice(0, Mnemonic.size() - 2); - PredicationCode = CC; + // First, split out any predication code. Ignore mnemonics we know aren't + // predicated but do have a carry-set and so weren't caught above. + if (Mnemonic != "adcs") { + unsigned CC = StringSwitch(Mnemonic.substr(Mnemonic.size()-2)) + .Case("eq", ARMCC::EQ) + .Case("ne", ARMCC::NE) + .Case("hs", ARMCC::HS) + .Case("cs", ARMCC::HS) + .Case("lo", ARMCC::LO) + .Case("cc", ARMCC::LO) + .Case("mi", ARMCC::MI) + .Case("pl", ARMCC::PL) + .Case("vs", ARMCC::VS) + .Case("vc", ARMCC::VC) + .Case("hi", ARMCC::HI) + .Case("ls", ARMCC::LS) + .Case("ge", ARMCC::GE) + .Case("lt", ARMCC::LT) + .Case("gt", ARMCC::GT) + .Case("le", ARMCC::LE) + .Case("al", ARMCC::AL) + .Default(~0U); + if (CC != ~0U) { + Mnemonic = Mnemonic.slice(0, Mnemonic.size() - 2); + PredicationCode = CC; + } } // Next, determine if we have a carry setting bit. We explicitly ignore all Added: llvm/trunk/test/MC/ARM/basic-arm-instructions.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/basic-arm-instructions.s?rev=134903&view=auto ============================================================================== --- llvm/trunk/test/MC/ARM/basic-arm-instructions.s (added) +++ llvm/trunk/test/MC/ARM/basic-arm-instructions.s Mon Jul 11 12:09:57 2011 @@ -0,0 +1,31 @@ +@ RUN: llvm-mc -triple=armv7-apple-darwin -show-encoding < %s | FileCheck %s + .syntax unified + .globl _func +_func: +@ CHECK: _func + +@ ADC (immediate) + adc r1, r2, #0xf + adc r1, r2, #0xf0 + adc r1, r2, #0xf00 + adc r1, r2, #0xf000 + adc r1, r2, #0xf0000 + adc r1, r2, #0xf00000 + adc r1, r2, #0xf000000 + adc r1, r2, #0xf0000000 + adc r1, r2, #0xf000000f + adcs r1, r2, #0xf00 + adcseq r1, r2, #0xf00 + +@ CHECK: adc r1, r2, #15 @ encoding: [0x0f,0x10,0xa2,0xe2] +@ CHECK: adc r1, r2, #240 @ encoding: [0xf0,0x10,0xa2,0xe2] +@ CHECK: adc r1, r2, #3840 @ encoding: [0x0f,0x1c,0xa2,0xe2] +@ CHECK: adc r1, r2, #61440 @ encoding: [0x0f,0x1a,0xa2,0xe2] +@ CHECK: adc r1, r2, #983040 @ encoding: [0x0f,0x18,0xa2,0xe2] +@ CHECK: adc r1, r2, #15728640 @ encoding: [0x0f,0x16,0xa2,0xe2] +@ CHECK: adc r1, r2, #251658240 @ encoding: [0x0f,0x14,0xa2,0xe2] +@ CHECK: adc r1, r2, #4026531840 @ encoding: [0x0f,0x12,0xa2,0xe2] +@ CHECK: adc r1, r2, #4026531855 @ encoding: [0xff,0x12,0xa2,0xe2] + +@ CHECK: adcs r1, r2, #3840 @ encoding: [0x0f,0x1c,0xb2,0xe2] +@ CHECK: adcseq r1, r2, #3840 @ encoding: [0x0f,0x1c,0xb2,0x02] From stoklund at 2pi.dk Mon Jul 11 12:11:03 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 10:11:03 -0700 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: References: Message-ID: On Jul 8, 2011, at 9:41 AM, David Greene wrote: > Here's a patch to manage TableGen Inits using a FoldingSet. This allows > us to clean up all of the allocated Inits on TableGen exit, saves memory > and makes TableGen run a bit faster due to elimination of duplicate > objects. Very nice. Please use get() instead of Create(). Please move all of the mechanical const-ness to a separate patch. It is very hard to figure out what is going on with all that noise. /jakob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110711/635a923a/attachment.html From ssen at apple.com Mon Jul 11 12:57:30 2011 From: ssen at apple.com (Shantonu Sen) Date: Mon, 11 Jul 2011 17:57:30 -0000 Subject: [llvm-commits] [llvm] r134905 - in /llvm/trunk: lib/MC/MCDisassembler/EDInfo.h lib/MC/MCDisassembler/EDOperand.cpp utils/TableGen/EDEmitter.cpp Message-ID: <20110711175730.DFAAC2A6C12C@llvm.org> Author: ssen Date: Mon Jul 11 12:57:30 2011 New Revision: 134905 URL: http://llvm.org/viewvc/llvm-project?rev=134905&view=rev Log: Resynchronize EDInfo.h and EDEmitter.cpp. The enum names as well as order (i.e. value) had skewed, which means that consumers of the tablegen-ed table would see different values than intended. Make both files have a superset of enums, and add classification as needed for numMCOperands. Reviewed by Owen Anderson Modified: llvm/trunk/lib/MC/MCDisassembler/EDInfo.h llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/MC/MCDisassembler/EDInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDInfo.h?rev=134905&r1=134904&r2=134905&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/EDInfo.h (original) +++ llvm/trunk/lib/MC/MCDisassembler/EDInfo.h Mon Jul 11 12:57:30 2011 @@ -25,8 +25,11 @@ kOperandTypeARMBranchTarget, kOperandTypeARMSoReg, kOperandTypeARMSoImm, + kOperandTypeARMRotImm, kOperandTypeARMSoImm2Part, kOperandTypeARMPredicate, + kOperandTypeAddrModeImm12, + kOperandTypeLdStSOReg, kOperandTypeARMAddrMode2, kOperandTypeARMAddrMode2Offset, kOperandTypeARMAddrMode3, @@ -38,13 +41,20 @@ kOperandTypeARMAddrMode7, kOperandTypeARMAddrModePC, kOperandTypeARMRegisterList, + kOperandTypeARMDPRRegisterList, + kOperandTypeARMSPRRegisterList, kOperandTypeARMTBAddrMode, kOperandTypeThumbITMask, - kOperandTypeThumbAddrModeS1, - kOperandTypeThumbAddrModeS2, - kOperandTypeThumbAddrModeS4, + kOperandTypeThumbAddrModeRegS1, + kOperandTypeThumbAddrModeRegS2, + kOperandTypeThumbAddrModeRegS4, + kOperandTypeThumbAddrModeImmS1, + kOperandTypeThumbAddrModeImmS2, + kOperandTypeThumbAddrModeImmS4, kOperandTypeThumbAddrModeRR, kOperandTypeThumbAddrModeSP, + kOperandTypeThumbAddrModePC, + kOperandTypeThumb2AddrModeReg, kOperandTypeThumb2SoReg, kOperandTypeThumb2SoImm, kOperandTypeThumb2AddrModeImm8, @@ -52,8 +62,7 @@ kOperandTypeThumb2AddrModeImm12, kOperandTypeThumb2AddrModeSoReg, kOperandTypeThumb2AddrModeImm8s4, - kOperandTypeThumb2AddrModeImm8s4Offset, - kOperandTypeThumb2AddrModeReg + kOperandTypeThumb2AddrModeImm8s4Offset }; enum OperandFlags { Modified: llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp?rev=134905&r1=134904&r2=134905&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp (original) +++ llvm/trunk/lib/MC/MCDisassembler/EDOperand.cpp Mon Jul 11 12:57:30 2011 @@ -61,11 +61,14 @@ switch (operandType) { default: case kOperandTypeARMRegisterList: + case kOperandTypeARMDPRRegisterList: + case kOperandTypeARMSPRRegisterList: break; case kOperandTypeImmediate: case kOperandTypeRegister: case kOperandTypeARMBranchTarget: case kOperandTypeARMSoImm: + case kOperandTypeARMRotImm: case kOperandTypeThumb2SoImm: case kOperandTypeARMSoImm2Part: case kOperandTypeARMPredicate: @@ -78,6 +81,7 @@ numMCOperands = 1; break; case kOperandTypeThumb2SoReg: + case kOperandTypeAddrModeImm12: case kOperandTypeARMAddrMode2Offset: case kOperandTypeARMAddrMode3Offset: case kOperandTypeARMAddrMode4: @@ -86,17 +90,22 @@ case kOperandTypeThumb2AddrModeImm8: case kOperandTypeThumb2AddrModeImm12: case kOperandTypeThumb2AddrModeImm8s4: + case kOperandTypeThumbAddrModeImmS1: + case kOperandTypeThumbAddrModeImmS2: + case kOperandTypeThumbAddrModeImmS4: case kOperandTypeThumbAddrModeRR: case kOperandTypeThumbAddrModeSP: + case kOperandTypeThumbAddrModePC: numMCOperands = 2; break; case kOperandTypeARMSoReg: + case kOperandTypeLdStSOReg: case kOperandTypeARMAddrMode2: case kOperandTypeARMAddrMode3: case kOperandTypeThumb2AddrModeSoReg: - case kOperandTypeThumbAddrModeS1: - case kOperandTypeThumbAddrModeS2: - case kOperandTypeThumbAddrModeS4: + case kOperandTypeThumbAddrModeRegS1: + case kOperandTypeThumbAddrModeRegS2: + case kOperandTypeThumbAddrModeRegS4: case kOperandTypeARMAddrMode6Offset: numMCOperands = 3; break; @@ -270,9 +279,9 @@ case kOperandTypeARMAddrMode7: case kOperandTypeARMAddrModePC: case kOperandTypeARMBranchTarget: - case kOperandTypeThumbAddrModeS1: - case kOperandTypeThumbAddrModeS2: - case kOperandTypeThumbAddrModeS4: + case kOperandTypeThumbAddrModeRegS1: + case kOperandTypeThumbAddrModeRegS2: + case kOperandTypeThumbAddrModeRegS4: case kOperandTypeThumbAddrModeRR: case kOperandTypeThumbAddrModeSP: case kOperandTypeThumb2SoImm: Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=134905&r1=134904&r2=134905&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Mon Jul 11 12:57:30 2011 @@ -653,12 +653,12 @@ MISC("t2am_imm8s4_offset", "kOperandTypeThumb2AddrModeImm8s4Offset"); // R, I MISC("tb_addrmode", "kOperandTypeARMTBAddrMode"); // I - MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS"); // R, R - MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS"); // R, R - MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS"); // R, R - MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS"); // R, I - MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS"); // R, I - MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS"); // R, I + MISC("t_addrmode_rrs1", "kOperandTypeThumbAddrModeRegS1"); // R, R + MISC("t_addrmode_rrs2", "kOperandTypeThumbAddrModeRegS2"); // R, R + MISC("t_addrmode_rrs4", "kOperandTypeThumbAddrModeRegS4"); // R, R + MISC("t_addrmode_is1", "kOperandTypeThumbAddrModeImmS1"); // R, I + MISC("t_addrmode_is2", "kOperandTypeThumbAddrModeImmS2"); // R, I + MISC("t_addrmode_is4", "kOperandTypeThumbAddrModeImmS4"); // R, I MISC("t_addrmode_rr", "kOperandTypeThumbAddrModeRR"); // R, R MISC("t_addrmode_sp", "kOperandTypeThumbAddrModeSP"); // R, I MISC("t_addrmode_pc", "kOperandTypeThumbAddrModePC"); // R, I @@ -666,14 +666,9 @@ return 1; } -#undef SOREG -#undef SOIMM -#undef PRED #undef REG #undef MEM -#undef LEA -#undef IMM -#undef PCR +#undef MISC #undef SET @@ -874,8 +869,12 @@ operandTypes.addEntry("kOperandTypeARMSPRRegisterList"); operandTypes.addEntry("kOperandTypeARMTBAddrMode"); operandTypes.addEntry("kOperandTypeThumbITMask"); - operandTypes.addEntry("kOperandTypeThumbAddrModeRegS"); - operandTypes.addEntry("kOperandTypeThumbAddrModeImmS"); + operandTypes.addEntry("kOperandTypeThumbAddrModeImmS1"); + operandTypes.addEntry("kOperandTypeThumbAddrModeImmS2"); + operandTypes.addEntry("kOperandTypeThumbAddrModeImmS4"); + operandTypes.addEntry("kOperandTypeThumbAddrModeRegS1"); + operandTypes.addEntry("kOperandTypeThumbAddrModeRegS2"); + operandTypes.addEntry("kOperandTypeThumbAddrModeRegS4"); operandTypes.addEntry("kOperandTypeThumbAddrModeRR"); operandTypes.addEntry("kOperandTypeThumbAddrModeSP"); operandTypes.addEntry("kOperandTypeThumbAddrModePC"); From greened at obbligato.org Mon Jul 11 13:25:51 2011 From: greened at obbligato.org (David Greene) Date: Mon, 11 Jul 2011 18:25:51 -0000 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ Message-ID: <20110711182552.740612A6C12C@llvm.org> Author: greened Date: Mon Jul 11 13:25:51 2011 New Revision: 134907 URL: http://llvm.org/viewvc/llvm-project?rev=134907&view=rev Log: [AVX] Make Inits Foldable Manage Inits in a FoldingSet. This provides several benefits: - Memory for Inits is properly managed - Duplicate Inits are folded into Flyweights, saving memory - It enforces const-correctness, protecting against certain classes of bugs The above benefits allow Inits to be used in more contexts, which in turn provides more dynamism to TableGen. This enhanced capability will be used by the AVX code generator to a fold common patterns together. Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp llvm/trunk/utils/TableGen/CallingConvEmitter.cpp llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.h llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/CodeGenInstruction.cpp llvm/trunk/utils/TableGen/CodeGenInstruction.h llvm/trunk/utils/TableGen/CodeGenRegisters.cpp llvm/trunk/utils/TableGen/CodeGenTarget.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp llvm/trunk/utils/TableGen/FastISelEmitter.cpp llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp llvm/trunk/utils/TableGen/OptParserEmitter.cpp llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h llvm/trunk/utils/TableGen/Record.cpp llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp llvm/trunk/utils/TableGen/SetTheory.cpp llvm/trunk/utils/TableGen/SetTheory.h llvm/trunk/utils/TableGen/TGParser.cpp llvm/trunk/utils/TableGen/TGParser.h llvm/trunk/utils/TableGen/TableGen.cpp llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -114,7 +114,7 @@ /// byteFromBitsInit - Return the byte value from a BitsInit. /// Called from getByteField(). -static uint8_t byteFromBitsInit(BitsInit &init) { +static uint8_t byteFromBitsInit(const BitsInit &init) { int width = init.getNumBits(); assert(width <= 8 && "Field is too large for uint8_t!"); @@ -125,7 +125,7 @@ uint8_t ret = 0; for (index = 0; index < width; index++) { - if (static_cast(init.getBit(index))->getValue()) + if (static_cast(init.getBit(index))->getValue()) ret |= mask; mask <<= 1; @@ -135,12 +135,12 @@ } static uint8_t getByteField(const Record &def, const char *str) { - BitsInit *bits = def.getValueAsBitsInit(str); + const BitsInit *bits = def.getValueAsBitsInit(str); return byteFromBitsInit(*bits); } -static BitsInit &getBitsField(const Record &def, const char *str) { - BitsInit *bits = def.getValueAsBitsInit(str); +static const BitsInit &getBitsField(const Record &def, const char *str) { + const BitsInit *bits = def.getValueAsBitsInit(str); return *bits; } @@ -183,15 +183,15 @@ static int Value(bit_value_t V) { return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); } -static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { - if (BitInit *bit = dynamic_cast(bits.getBit(index))) +static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { + if (const BitInit *bit = dynamic_cast(bits.getBit(index))) return bit->getValue() ? BIT_TRUE : BIT_FALSE; // The bit is uninitialized. return BIT_UNSET; } // Prints the bit value for each position. -static void dumpBits(raw_ostream &o, BitsInit &bits) { +static void dumpBits(raw_ostream &o, const BitsInit &bits) { unsigned index; for (index = bits.getNumBits(); index > 0; index--) { @@ -424,7 +424,8 @@ if (AllInstructions[Opcode]->isPseudo) return; - BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); + const BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, + "Inst"); for (unsigned i = 0; i < BIT_WIDTH; ++i) Insn[i] = bitFromBits(Bits, i); @@ -1558,7 +1559,7 @@ const StringRef Name = Def.getName(); uint8_t Form = getByteField(Def, "Form"); - BitsInit &Bits = getBitsField(Def, "Inst"); + const BitsInit &Bits = getBitsField(Def, "Inst"); // If all the bit positions are not specified; do not decode this instruction. // We are bound to fail! For proper disassembly, the well-known encoding bits Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -869,7 +869,7 @@ int SubOpIdx) { Record *Rec = OI.Rec; if (SubOpIdx != -1) - Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); + Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); if (Rec->isSubClassOf("RegisterOperand")) { // RegisterOperand may have an associated ParserMatchClass. If it does, @@ -879,7 +879,7 @@ throw "Record `" + Rec->getName() + "' does not have a ParserMatchClass!\n"; - if (DefInit *DI= dynamic_cast(R->getValue())) { + if (const DefInit *DI= dynamic_cast(R->getValue())) { Record *MatchClass = DI->getDef(); if (ClassInfo *CI = AsmOperandClasses[MatchClass]) return CI; @@ -1046,9 +1046,9 @@ ClassInfo *CI = AsmOperandClasses[*it]; CI->Kind = ClassInfo::UserClass0 + Index; - ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); + const ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); for (unsigned i = 0, e = Supers->getSize(); i != e; ++i) { - DefInit *DI = dynamic_cast(Supers->getElement(i)); + const DefInit *DI = dynamic_cast(Supers->getElement(i)); if (!DI) { PrintError((*it)->getLoc(), "Invalid super class reference!"); continue; @@ -1065,28 +1065,28 @@ CI->ValueName = (*it)->getName(); // Get or construct the predicate method name. - Init *PMName = (*it)->getValueInit("PredicateMethod"); - if (StringInit *SI = dynamic_cast(PMName)) { + const Init *PMName = (*it)->getValueInit("PredicateMethod"); + if (const StringInit *SI = dynamic_cast(PMName)) { CI->PredicateMethod = SI->getValue(); } else { - assert(dynamic_cast(PMName) && + assert(dynamic_cast(PMName) && "Unexpected PredicateMethod field!"); CI->PredicateMethod = "is" + CI->ClassName; } // Get or construct the render method name. - Init *RMName = (*it)->getValueInit("RenderMethod"); - if (StringInit *SI = dynamic_cast(RMName)) { + const Init *RMName = (*it)->getValueInit("RenderMethod"); + if (const StringInit *SI = dynamic_cast(RMName)) { CI->RenderMethod = SI->getValue(); } else { - assert(dynamic_cast(RMName) && + assert(dynamic_cast(RMName) && "Unexpected RenderMethod field!"); CI->RenderMethod = "add" + CI->ClassName + "Operands"; } // Get the parse method name or leave it as empty. - Init *PRMName = (*it)->getValueInit("ParserMethod"); - if (StringInit *SI = dynamic_cast(PRMName)) + const Init *PRMName = (*it)->getValueInit("ParserMethod"); + if (const StringInit *SI = dynamic_cast(PRMName)) CI->ParserMethod = SI->getValue(); AsmOperandClasses[*it] = CI; Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -40,7 +40,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) { - ListInit *CCActions = CC->getValueAsListInit("Actions"); + const ListInit *CCActions = CC->getValueAsListInit("Actions"); Counter = 0; O << "\n\nstatic bool " << CC->getName() @@ -67,7 +67,7 @@ O << IndentStr << "if ("; if (Action->isSubClassOf("CCIfType")) { - ListInit *VTs = Action->getValueAsListInit("VTs"); + const ListInit *VTs = Action->getValueAsListInit("VTs"); for (unsigned i = 0, e = VTs->getSize(); i != e; ++i) { Record *VT = VTs->getElementAsRecord(i); if (i != 0) O << " ||\n " << IndentStr; @@ -91,7 +91,7 @@ << "(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n" << IndentStr << " return false;\n"; } else if (Action->isSubClassOf("CCAssignToReg")) { - ListInit *RegList = Action->getValueAsListInit("RegList"); + const ListInit *RegList = Action->getValueAsListInit("RegList"); if (RegList->getSize() == 1) { O << IndentStr << "if (unsigned Reg = State.AllocateReg("; O << getQualifiedName(RegList->getElementAsRecord(0)) << ")) {\n"; @@ -112,8 +112,8 @@ O << IndentStr << " return false;\n"; O << IndentStr << "}\n"; } else if (Action->isSubClassOf("CCAssignToRegWithShadow")) { - ListInit *RegList = Action->getValueAsListInit("RegList"); - ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); + const ListInit *RegList = Action->getValueAsListInit("RegList"); + const ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); if (ShadowRegList->getSize() >0 && ShadowRegList->getSize() != RegList->getSize()) throw "Invalid length of list of shadowed registers"; Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -21,17 +21,19 @@ static const std::vector getValueAsListOfStrings(Record &R, StringRef FieldName) { - ListInit *List = R.getValueAsListInit(FieldName); + const ListInit *List = R.getValueAsListInit(FieldName); assert (List && "Got a null ListInit"); std::vector Strings; Strings.reserve(List->getSize()); - for (ListInit::iterator i = List->begin(), e = List->end(); i != e; ++i) { + for (ListInit::const_iterator i = List->begin(), e = List->end(); + i != e; + ++i) { assert(*i && "Got a null element in a ListInit"); - if (StringInit *S = dynamic_cast(*i)) + if (const StringInit *S = dynamic_cast(*i)) Strings.push_back(S->getValue()); - else if (CodeInit *C = dynamic_cast(*i)) + else if (const CodeInit *C = dynamic_cast(*i)) Strings.push_back(C->getValue()); else assert(false && "Got a non-string, non-code element in a ListInit"); Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -74,7 +74,8 @@ static std::string getDiagnosticCategory(const Record *R, DiagGroupParentMap &DiagGroupParents) { // If the diagnostic is in a group, and that group has a category, use it. - if (DefInit *Group = dynamic_cast(R->getValueInit("Group"))) { + if (const DefInit *Group = + dynamic_cast(R->getValueInit("Group"))) { // Check the diagnostic's diag group for a category. std::string CatName = getCategoryFromDiagGroup(Group->getDef(), DiagGroupParents); @@ -159,7 +160,8 @@ OS.write_escaped(R.getValueAsString("Text")) << '"'; // Warning associated with the diagnostic. - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) { + if (const DefInit *DI = + dynamic_cast(R.getValueInit("Group"))) { OS << ", \""; OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; } else { @@ -225,7 +227,7 @@ Records.getAllDerivedDefinitions("Diagnostic"); for (unsigned i = 0, e = Diags.size(); i != e; ++i) { const Record *R = Diags[i]; - DefInit *DI = dynamic_cast(R->getValueInit("Group")); + const DefInit *DI = dynamic_cast(R->getValueInit("Group")); if (DI == 0) continue; std::string GroupName = DI->getDef()->getValueAsString("GroupName"); DiagsInGroup[GroupName].DiagsInGroup.push_back(R); Modified: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -28,7 +28,8 @@ if (R.getValueAsBit("Hidden")) return true; // Not declared as hidden, check the parent package if it is hidden. - if (DefInit *DI = dynamic_cast(R.getValueInit("ParentPackage"))) + if (const DefInit *DI = + dynamic_cast(R.getValueInit("ParentPackage"))) return isHidden(*DI->getDef()); return false; @@ -42,7 +43,8 @@ static std::string getParentPackageFullName(const Record *R) { std::string name; - if (DefInit *DI = dynamic_cast(R->getValueInit("ParentPackage"))) + if (const DefInit *DI = + dynamic_cast(R->getValueInit("ParentPackage"))) name = getPackageFullName(DI->getDef()); return name; } @@ -63,8 +65,8 @@ } static std::string getStringValue(const Record &R, StringRef field) { - if (StringInit * - SI = dynamic_cast(R.getValueInit(field))) + if (const StringInit * + SI = dynamic_cast(R.getValueInit(field))) return SI->getValue(); return std::string(); } @@ -129,8 +131,8 @@ for (unsigned i = 0, e = checkers.size(); i != e; ++i) { Record *R = checkers[i]; Record *package = 0; - if (DefInit * - DI = dynamic_cast(R->getValueInit("ParentPackage"))) + if (const DefInit * + DI = dynamic_cast(R->getValueInit("ParentPackage"))) package = DI->getDef(); if (!isCheckerNamed(R) && !package) throw "Checker '" + R->getName() + "' is neither named, nor in a package!"; @@ -149,21 +151,23 @@ Record *currR = isCheckerNamed(R) ? R : package; // Insert the checker and its parent packages into the subgroups set of // the corresponding parent package. - while (DefInit *DI - = dynamic_cast(currR->getValueInit("ParentPackage"))) { + while (const DefInit *DI = + dynamic_cast(currR->getValueInit("ParentPackage"))) { Record *parentPackage = DI->getDef(); recordGroupMap[parentPackage]->SubGroups.insert(currR); currR = parentPackage; } // Insert the checker into the set of its group. - if (DefInit *DI = dynamic_cast(R->getValueInit("Group"))) + if (const DefInit *DI = + dynamic_cast(R->getValueInit("Group"))) recordGroupMap[DI->getDef()]->Checkers.insert(R); } // If a package is in group, add all its checkers and its sub-packages // checkers into the group. for (unsigned i = 0, e = packages.size(); i != e; ++i) - if (DefInit *DI = dynamic_cast(packages[i]->getValueInit("Group"))) + if (const DefInit *DI = + dynamic_cast(packages[i]->getValueInit("Group"))) addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap); typedef std::map SortedRecords; @@ -204,7 +208,8 @@ OS << "PACKAGE(" << "\""; OS.write_escaped(getPackageFullName(&R)) << "\", "; // Group index - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = + dynamic_cast(R.getValueInit("Group"))) OS << groupToSortIndex[DI->getDef()] << ", "; else OS << "-1, "; @@ -232,7 +237,8 @@ OS << "\""; OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; // Group index - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = + dynamic_cast(R.getValueInit("Group"))) OS << groupToSortIndex[DI->getDef()] << ", "; else OS << "-1, "; Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Mon Jul 11 13:25:51 2011 @@ -38,21 +38,25 @@ R->getValueAsBit("isPseudo")) continue; - BitsInit *BI = R->getValueAsBitsInit("Inst"); + const BitsInit *BI = R->getValueAsBitsInit("Inst"); unsigned numBits = BI->getNumBits(); - BitsInit *NewBI = new BitsInit(numBits); + + SmallVector NewBits(numBits); + for (unsigned bit = 0, end = numBits / 2; bit != end; ++bit) { unsigned bitSwapIdx = numBits - bit - 1; - Init *OrigBit = BI->getBit(bit); - Init *BitSwap = BI->getBit(bitSwapIdx); - NewBI->setBit(bit, BitSwap); - NewBI->setBit(bitSwapIdx, OrigBit); + const Init *OrigBit = BI->getBit(bit); + const Init *BitSwap = BI->getBit(bitSwapIdx); + NewBits[bit] = BitSwap; + NewBits[bitSwapIdx] = OrigBit; } if (numBits % 2) { unsigned middle = (numBits + 1) / 2; - NewBI->setBit(middle, BI->getBit(middle)); + NewBits[middle] = BI->getBit(middle); } + + const BitsInit *NewBI = BitsInit::Create(NewBits.begin(), NewBits.end()); // Update the bits in reversed order so that emitInstrOpBits will get the // correct endianness. @@ -63,12 +67,14 @@ // If the VarBitInit at position 'bit' matches the specified variable then // return the variable bit position. Otherwise return -1. int CodeEmitterGen::getVariableBit(const std::string &VarName, - BitsInit *BI, int bit) { - if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { - if (VarInit *VI = dynamic_cast(VBI->getVariable())) + const BitsInit *BI, int bit) { + if (const VarBitInit *VBI = + dynamic_cast(BI->getBit(bit))) { + if (const VarInit *VI = dynamic_cast(VBI->getVariable())) if (VI->getName() == VarName) return VBI->getBitNum(); - } else if (VarInit *VI = dynamic_cast(BI->getBit(bit))) { + } else if (const VarInit *VI = + dynamic_cast(BI->getBit(bit))) { if (VI->getName() == VarName) return 0; } @@ -77,8 +83,8 @@ } void CodeEmitterGen:: -AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, - unsigned &NumberedOp, +AddCodeToMergeInOperand(Record *R, const BitsInit *BI, + const std::string &VarName, unsigned &NumberedOp, std::string &Case, CodeGenTarget &Target) { CodeGenInstruction &CGI = Target.getInstruction(R); @@ -181,7 +187,7 @@ CodeGenTarget &Target) { std::string Case; - BitsInit *BI = R->getValueAsBitsInit("Inst"); + const BitsInit *BI = R->getValueAsBitsInit("Inst"); const std::vector &Vals = R->getValues(); unsigned NumberedOp = 0; @@ -238,12 +244,12 @@ continue; } - BitsInit *BI = R->getValueAsBitsInit("Inst"); + const BitsInit *BI = R->getValueAsBitsInit("Inst"); // Start by filling in fixed values. unsigned Value = 0; for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) { - if (BitInit *B = dynamic_cast(BI->getBit(e-i-1))) + if (const BitInit *B = dynamic_cast(BI->getBit(e-i-1))) Value |= B->getValue() << (e-i-1); } o << " " << Value << "U," << '\t' << "// " << R->getName() << "\n"; Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.h (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.h Mon Jul 11 13:25:51 2011 @@ -35,11 +35,11 @@ void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace); void emitGetValueBit(raw_ostream &o, const std::string &Namespace); void reverseBits(std::vector &Insts); - int getVariableBit(const std::string &VarName, BitsInit *BI, int bit); + int getVariableBit(const std::string &VarName, const BitsInit *BI, int bit); std::string getInstructionCase(Record *R, CodeGenTarget &Target); void - AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, - unsigned &NumberedOp, + AddCodeToMergeInOperand(Record *R, const BitsInit *BI, + const std::string &VarName, unsigned &NumberedOp, std::string &Case, CodeGenTarget &Target); }; Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Mon Jul 11 13:25:51 2011 @@ -583,7 +583,7 @@ static void FindDepVarsOf(TreePatternNode *N, DepVarMap &DepMap) { if (N->isLeaf()) { - if (dynamic_cast(N->getLeafValue()) != NULL) + if (dynamic_cast(N->getLeafValue()) != NULL) DepMap[N->getName()]++; } else { for (size_t i = 0, e = N->getNumChildren(); i != e; ++i) @@ -692,7 +692,7 @@ unsigned Size = 3; // The node itself. // If the root node is a ConstantSDNode, increases its size. // e.g. (set R32:$dst, 0). - if (P->isLeaf() && dynamic_cast(P->getLeafValue())) + if (P->isLeaf() && dynamic_cast(P->getLeafValue())) Size += 2; // FIXME: This is a hack to statically increase the priority of patterns @@ -716,7 +716,7 @@ Child->getType(0) != MVT::Other) Size += getPatternSize(Child, CGP); else if (Child->isLeaf()) { - if (dynamic_cast(Child->getLeafValue())) + if (dynamic_cast(Child->getLeafValue())) Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2). else if (Child->getComplexPatternInfo(CGP)) Size += getPatternSize(Child, CGP); @@ -742,7 +742,8 @@ std::string PatternToMatch::getPredicateCheck() const { std::string PredicateCheck; for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) { - if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { + if (const DefInit *Pred = + dynamic_cast(Predicates->getElement(i))) { Record *Def = Pred->getDef(); if (!Def->isSubClassOf("Predicate")) { #ifndef NDEBUG @@ -866,12 +867,13 @@ // The NodeToApply must be a leaf node that is a VT. OtherOperandNum must // have an integer type that is smaller than the VT. if (!NodeToApply->isLeaf() || - !dynamic_cast(NodeToApply->getLeafValue()) || - !static_cast(NodeToApply->getLeafValue())->getDef() + !dynamic_cast(NodeToApply->getLeafValue()) || + !static_cast(NodeToApply->getLeafValue())->getDef() ->isSubClassOf("ValueType")) TP.error(N->getOperator()->getName() + " expects a VT operand!"); MVT::SimpleValueType VT = - getValueType(static_cast(NodeToApply->getLeafValue())->getDef()); + getValueType(static_cast(NodeToApply->getLeafValue()) + ->getDef()); EEVT::TypeSet TypeListTmp(VT, TP); @@ -1021,10 +1023,10 @@ return PFRec->getOnlyTree()->getNumTypes(); // Get the result tree. - DagInit *Tree = Operator->getValueAsDag("Fragment"); + const DagInit *Tree = Operator->getValueAsDag("Fragment"); Record *Op = 0; - if (Tree && dynamic_cast(Tree->getOperator())) - Op = dynamic_cast(Tree->getOperator())->getDef(); + if (Tree && dynamic_cast(Tree->getOperator())) + Op = dynamic_cast(Tree->getOperator())->getDef(); assert(Op && "Invalid Fragment"); return GetNumNodeResults(Op, CDP); } @@ -1098,8 +1100,8 @@ return false; if (isLeaf()) { - if (DefInit *DI = dynamic_cast(getLeafValue())) { - if (DefInit *NDI = dynamic_cast(N->getLeafValue())) { + if (const DefInit *DI = dynamic_cast(getLeafValue())) { + if (const DefInit *NDI = dynamic_cast(N->getLeafValue())) { return ((DI->getDef() == NDI->getDef()) && (DepVars.find(getName()) == DepVars.end() || getName() == N->getName())); @@ -1155,9 +1157,9 @@ for (unsigned i = 0, e = getNumChildren(); i != e; ++i) { TreePatternNode *Child = getChild(i); if (Child->isLeaf()) { - Init *Val = Child->getLeafValue(); - if (dynamic_cast(Val) && - static_cast(Val)->getDef()->getName() == "node") { + const Init *Val = Child->getLeafValue(); + if (dynamic_cast(Val) && + static_cast(Val)->getDef()->getName() == "node") { // We found a use of a formal argument, replace it with its value. TreePatternNode *NewChild = ArgMap[Child->getName()]; assert(NewChild && "Couldn't find formal argument!"); @@ -1319,7 +1321,7 @@ return 0; unsigned IID = - dynamic_cast(getChild(0)->getLeafValue())->getValue(); + dynamic_cast(getChild(0)->getLeafValue())->getValue(); return &CDP.getIntrinsicInfo(IID); } @@ -1329,7 +1331,7 @@ TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const { if (!isLeaf()) return 0; - DefInit *DI = dynamic_cast(getLeafValue()); + const DefInit *DI = dynamic_cast(getLeafValue()); if (DI && DI->getDef()->isSubClassOf("ComplexPattern")) return &CGP.getComplexPattern(DI->getDef()); return 0; @@ -1382,7 +1384,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { CodeGenDAGPatterns &CDP = TP.getDAGPatterns(); if (isLeaf()) { - if (DefInit *DI = dynamic_cast(getLeafValue())) { + if (const DefInit *DI = dynamic_cast(getLeafValue())) { // If it's a regclass or something else known, include the type. bool MadeChange = false; for (unsigned i = 0, e = Types.size(); i != e; ++i) @@ -1391,7 +1393,7 @@ return MadeChange; } - if (IntInit *II = dynamic_cast(getLeafValue())) { + if (const IntInit *II = dynamic_cast(getLeafValue())) { assert(Types.size() == 1 && "Invalid IntInit"); // Int inits are always integers. :) @@ -1651,7 +1653,7 @@ static bool OnlyOnRHSOfCommutative(TreePatternNode *N) { if (!N->isLeaf() && N->getOperator()->getName() == "imm") return true; - if (N->isLeaf() && dynamic_cast(N->getLeafValue())) + if (N->isLeaf() && dynamic_cast(N->getLeafValue())) return true; return false; } @@ -1701,14 +1703,14 @@ // TreePattern implementation // -TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, +TreePattern::TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ isInputPattern = isInput; for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i) Trees.push_back(ParseTreePattern(RawPat->getElement(i), "")); } -TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput, +TreePattern::TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ isInputPattern = isInput; Trees.push_back(ParseTreePattern(Pat, "")); @@ -1739,16 +1741,17 @@ } -TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){ - if (DefInit *DI = dynamic_cast(TheInit)) { +TreePatternNode *TreePattern::ParseTreePattern(const Init *TheInit, + StringRef OpName){ + if (const DefInit *DI = dynamic_cast(TheInit)) { Record *R = DI->getDef(); // Direct reference to a leaf DagNode or PatFrag? Turn it into a // TreePatternNode of its own. For example: /// (foo GPR, imm) -> (foo GPR, (imm)) if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) - return ParseTreePattern(new DagInit(DI, "", - std::vector >()), + return ParseTreePattern(DagInit::Create(DI, "", + std::vector >()), OpName); // Input argument? @@ -1763,26 +1766,26 @@ return Res; } - if (IntInit *II = dynamic_cast(TheInit)) { + if (const IntInit *II = dynamic_cast(TheInit)) { if (!OpName.empty()) error("Constant int argument should not have a name!"); return new TreePatternNode(II, 1); } - if (BitsInit *BI = dynamic_cast(TheInit)) { + if (const BitsInit *BI = dynamic_cast(TheInit)) { // Turn this into an IntInit. - Init *II = BI->convertInitializerTo(new IntRecTy()); - if (II == 0 || !dynamic_cast(II)) + const Init *II = BI->convertInitializerTo(new IntRecTy()); + if (II == 0 || !dynamic_cast(II)) error("Bits value must be constants!"); return ParseTreePattern(II, OpName); } - DagInit *Dag = dynamic_cast(TheInit); + const DagInit *Dag = dynamic_cast(TheInit); if (!Dag) { TheInit->dump(); error("Pattern has unexpected init kind!"); } - DefInit *OpDef = dynamic_cast(Dag->getOperator()); + const DefInit *OpDef = dynamic_cast(Dag->getOperator()); if (!OpDef) error("Pattern has unexpected operator type!"); Record *Operator = OpDef->getDef(); @@ -1860,7 +1863,7 @@ else // Otherwise, no chain. Operator = getDAGPatterns().get_intrinsic_wo_chain_sdnode(); - TreePatternNode *IIDNode = new TreePatternNode(new IntInit(IID), 1); + TreePatternNode *IIDNode = new TreePatternNode(IntInit::Create(IID), 1); Children.insert(Children.begin(), IIDNode); } @@ -1947,7 +1950,8 @@ // us to match things like: // def : Pat<(v1i64 (bitconvert(v2i32 DPR:$src))), (v1i64 DPR:$src)>; if (Nodes[i] == Trees[0] && Nodes[i]->isLeaf()) { - DefInit *DI = dynamic_cast(Nodes[i]->getLeafValue()); + const DefInit *DI = + dynamic_cast(Nodes[i]->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) continue; @@ -2096,7 +2100,7 @@ // First step, parse all of the fragments. for (unsigned i = 0, e = Fragments.size(); i != e; ++i) { - DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); + const DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); TreePattern *P = new TreePattern(Fragments[i], Tree, true, *this); PatternFragments[Fragments[i]] = P; @@ -2108,8 +2112,8 @@ P->error("Cannot have unnamed 'node' values in pattern fragment!"); // Parse the operands list. - DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); - DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); + const DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); + const DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); // Special cases: ops == outs == ins. Different names are used to // improve readability. if (!OpsOp || @@ -2121,8 +2125,8 @@ // Copy over the arguments. Args.clear(); for (unsigned j = 0, e = OpsList->getNumArgs(); j != e; ++j) { - if (!dynamic_cast(OpsList->getArg(j)) || - static_cast(OpsList->getArg(j))-> + if (!dynamic_cast(OpsList->getArg(j)) || + static_cast(OpsList->getArg(j))-> getDef()->getName() != "node") P->error("Operands list should all be 'node' values."); if (OpsList->getArgName(j).empty()) @@ -2180,19 +2184,19 @@ // Find some SDNode. assert(!SDNodes.empty() && "No SDNodes parsed?"); - Init *SomeSDNode = new DefInit(SDNodes.begin()->first); + const Init *SomeSDNode = DefInit::Create(SDNodes.begin()->first); for (unsigned iter = 0; iter != 2; ++iter) { for (unsigned i = 0, e = DefaultOps[iter].size(); i != e; ++i) { - DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); + const DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); // Clone the DefaultInfo dag node, changing the operator from 'ops' to // SomeSDnode so that we can parse this. - std::vector > Ops; + std::vector > Ops; for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op) Ops.push_back(std::make_pair(DefaultInfo->getArg(op), DefaultInfo->getArgName(op))); - DagInit *DI = new DagInit(SomeSDNode, "", Ops); + const DagInit *DI = DagInit::Create(SomeSDNode, "", Ops); // Create a TreePattern to parse this. TreePattern P(DefaultOps[iter][i], DI, false, *this); @@ -2231,7 +2235,7 @@ // No name -> not interesting. if (Pat->getName().empty()) { if (Pat->isLeaf()) { - DefInit *DI = dynamic_cast(Pat->getLeafValue()); + const DefInit *DI = dynamic_cast(Pat->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) I->error("Input " + DI->getDef()->getName() + " must be named!"); @@ -2241,7 +2245,7 @@ Record *Rec; if (Pat->isLeaf()) { - DefInit *DI = dynamic_cast(Pat->getLeafValue()); + const DefInit *DI = dynamic_cast(Pat->getLeafValue()); if (!DI) I->error("Input $" + Pat->getName() + " must be an identifier!"); Rec = DI->getDef(); } else { @@ -2259,7 +2263,7 @@ } Record *SlotRec; if (Slot->isLeaf()) { - SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); + SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); } else { assert(Slot->getNumChildren() == 0 && "can't be a use with children!"); SlotRec = Slot->getOperator(); @@ -2294,7 +2298,7 @@ if (!Dest->isLeaf()) I->error("implicitly defined value should be a register!"); - DefInit *Val = dynamic_cast(Dest->getLeafValue()); + const DefInit *Val = dynamic_cast(Dest->getLeafValue()); if (!Val || !Val->getDef()->isSubClassOf("Register")) I->error("implicitly defined value should be a register!"); InstImpResults.push_back(Val->getDef()); @@ -2335,7 +2339,7 @@ if (!Dest->isLeaf()) I->error("set destination should be a register!"); - DefInit *Val = dynamic_cast(Dest->getLeafValue()); + const DefInit *Val = dynamic_cast(Dest->getLeafValue()); if (!Val) I->error("set destination should be a register!"); @@ -2401,7 +2405,7 @@ return false; const TreePatternNode *N0 = N->getChild(0); - if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) + if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) return false; const TreePatternNode *N1 = N->getChild(1); @@ -2418,7 +2422,7 @@ void AnalyzeNode(const TreePatternNode *N) { if (N->isLeaf()) { - if (DefInit *DI = dynamic_cast(N->getLeafValue())) { + if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { Record *LeafRec = DI->getDef(); // Handle ComplexPattern leaves. if (LeafRec->isSubClassOf("ComplexPattern")) { @@ -2525,9 +2529,9 @@ std::vector Instrs = Records.getAllDerivedDefinitions("Instruction"); for (unsigned i = 0, e = Instrs.size(); i != e; ++i) { - ListInit *LI = 0; + const ListInit *LI = 0; - if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) + if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) LI = Instrs[i]->getValueAsListInit("Pattern"); // If there is no pattern, only collect minimal information about the @@ -2619,7 +2623,7 @@ if (i == 0) Res0Node = RNode; - Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); + Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); if (R == 0) I->error("Operand $" + OpName + " should be a set destination: all " "outputs must occur before inputs in operand list!"); @@ -2664,8 +2668,8 @@ InstInputsCheck.erase(OpName); // It occurred, remove from map. if (InVal->isLeaf() && - dynamic_cast(InVal->getLeafValue())) { - Record *InRec = static_cast(InVal->getLeafValue())->getDef(); + dynamic_cast(InVal->getLeafValue())) { + Record *InRec = static_cast(InVal->getLeafValue())->getDef(); if (Op.Rec != InRec && !InRec->isSubClassOf("ComplexPattern")) I->error("Operand $" + OpName + "'s register class disagrees" " between the operand and pattern"); @@ -2865,13 +2869,13 @@ for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { Record *CurPattern = Patterns[i]; - DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); + const DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); TreePattern *Pattern = new TreePattern(CurPattern, Tree, true, *this); // Inline pattern fragments into it. Pattern->InlinePatternFragments(); - ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); + const ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); if (LI->getSize() == 0) continue; // no pattern. // Parse the instruction. @@ -3183,7 +3187,8 @@ for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { TreePatternNode *Child = N->getChild(i); if (Child->isLeaf()) - if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { + if (const DefInit *DI = + dynamic_cast(Child->getLeafValue())) { Record *RR = DI->getDef(); if (RR->isSubClassOf("Register")) continue; Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Mon Jul 11 13:25:51 2011 @@ -306,7 +306,7 @@ /// Val - The init value (e.g. the "GPRC" record, or "7") for a leaf. /// - Init *Val; + const Init *Val; /// Name - The name given to this node with the :$foo notation. /// @@ -327,7 +327,7 @@ : Operator(Op), Val(0), TransformFn(0), Children(Ch) { Types.resize(NumResults); } - TreePatternNode(Init *val, unsigned NumResults) // leaf ctor + TreePatternNode(const Init *val, unsigned NumResults) // leaf ctor : Operator(0), Val(val), TransformFn(0) { Types.resize(NumResults); } @@ -358,7 +358,7 @@ return Types[ResNo].isDynamicallyResolved(); } - Init *getLeafValue() const { assert(isLeaf()); return Val; } + const Init *getLeafValue() const { assert(isLeaf()); return Val; } Record *getOperator() const { assert(!isLeaf()); return Operator; } unsigned getNumChildren() const { return Children.size(); } @@ -517,9 +517,9 @@ /// TreePattern constructor - Parse the specified DagInits into the /// current record. - TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, + TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, CodeGenDAGPatterns &ise); - TreePattern(Record *TheRec, DagInit *Pat, bool isInput, + TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, CodeGenDAGPatterns &ise); TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput, CodeGenDAGPatterns &ise); @@ -576,7 +576,7 @@ void dump() const; private: - TreePatternNode *ParseTreePattern(Init *DI, StringRef OpName); + TreePatternNode *ParseTreePattern(const Init *DI, StringRef OpName); void ComputeNamedNodes(); void ComputeNamedNodes(TreePatternNode *N); }; @@ -631,7 +631,7 @@ /// processed to produce isel. class PatternToMatch { public: - PatternToMatch(Record *srcrecord, ListInit *preds, + PatternToMatch(Record *srcrecord, const ListInit *preds, TreePatternNode *src, TreePatternNode *dst, const std::vector &dstregs, unsigned complexity, unsigned uid) @@ -639,7 +639,7 @@ Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {} Record *SrcRecord; // Originating Record for the pattern. - ListInit *Predicates; // Top level predicate conditions to match. + const ListInit *Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. std::vector Dstregs; // Physical register defs being matched. @@ -647,7 +647,7 @@ unsigned ID; // Unique ID for the record. Record *getSrcRecord() const { return SrcRecord; } - ListInit *getPredicates() const { return Predicates; } + const ListInit *getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } TreePatternNode *getDstPattern() const { return DstPattern; } const std::vector &getDstRegs() const { return Dstregs; } Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Mon Jul 11 13:25:51 2011 @@ -30,9 +30,10 @@ hasOptionalDef = false; isVariadic = false; - DagInit *OutDI = R->getValueAsDag("OutOperandList"); + const DagInit *OutDI = R->getValueAsDag("OutOperandList"); - if (DefInit *Init = dynamic_cast(OutDI->getOperator())) { + if (const DefInit *Init = + dynamic_cast(OutDI->getOperator())) { if (Init->getDef()->getName() != "outs") throw R->getName() + ": invalid def name for output list: use 'outs'"; } else @@ -40,8 +41,8 @@ NumDefs = OutDI->getNumArgs(); - DagInit *InDI = R->getValueAsDag("InOperandList"); - if (DefInit *Init = dynamic_cast(InDI->getOperator())) { + const DagInit *InDI = R->getValueAsDag("InOperandList"); + if (const DefInit *Init = dynamic_cast(InDI->getOperator())) { if (Init->getDef()->getName() != "ins") throw R->getName() + ": invalid def name for input list: use 'ins'"; } else @@ -50,7 +51,7 @@ unsigned MIOperandNo = 0; std::set OperandNames; for (unsigned i = 0, e = InDI->getNumArgs()+OutDI->getNumArgs(); i != e; ++i){ - Init *ArgInit; + const Init *ArgInit; std::string ArgName; if (i < NumDefs) { ArgInit = OutDI->getArg(i); @@ -60,7 +61,7 @@ ArgName = InDI->getArgName(i-NumDefs); } - DefInit *Arg = dynamic_cast(ArgInit); + const DefInit *Arg = dynamic_cast(ArgInit); if (!Arg) throw "Illegal operand for the '" + R->getName() + "' instruction!"; @@ -68,7 +69,7 @@ std::string PrintMethod = "printOperand"; std::string EncoderMethod; unsigned NumOps = 1; - DagInit *MIOpInfo = 0; + const DagInit *MIOpInfo = 0; if (Rec->isSubClassOf("RegisterOperand")) { PrintMethod = Rec->getValueAsString("PrintMethod"); } else if (Rec->isSubClassOf("Operand")) { @@ -78,8 +79,8 @@ MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); // Verify that MIOpInfo has an 'ops' root value. - if (!dynamic_cast(MIOpInfo->getOperator()) || - dynamic_cast(MIOpInfo->getOperator()) + if (!dynamic_cast(MIOpInfo->getOperator()) || + dynamic_cast(MIOpInfo->getOperator()) ->getDef()->getName() != "ops") throw "Bad value for MIOperandInfo in operand '" + Rec->getName() + "'\n"; @@ -178,7 +179,7 @@ } // Find the suboperand number involved. - DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; + const DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; if (MIOpInfo == 0) throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; @@ -400,12 +401,13 @@ /// constructor. It checks if an argument in an InstAlias pattern matches /// the corresponding operand of the instruction. It returns true on a /// successful match, with ResOp set to the result operand to be used. -bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, +bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, + unsigned AliasOpNo, Record *InstOpRec, bool hasSubOps, SMLoc Loc, CodeGenTarget &T, ResultOperand &ResOp) { - Init *Arg = Result->getArg(AliasOpNo); - DefInit *ADI = dynamic_cast(Arg); + const Init *Arg = Result->getArg(AliasOpNo); + const DefInit *ADI = dynamic_cast(Arg); if (ADI && ADI->getDef() == InstOpRec) { // If the operand is a record, it must have a name, and the record type @@ -451,7 +453,7 @@ return true; } - if (IntInit *II = dynamic_cast(Arg)) { + if (const IntInit *II = dynamic_cast(Arg)) { if (hasSubOps || !InstOpRec->isSubClassOf("Operand")) return false; // Integer arguments can't have names. @@ -470,7 +472,7 @@ Result = R->getValueAsDag("ResultInst"); // Verify that the root of the result is an instruction. - DefInit *DI = dynamic_cast(Result->getOperator()); + const DefInit *DI = dynamic_cast(Result->getOperator()); if (DI == 0 || !DI->getDef()->isSubClassOf("Instruction")) throw TGError(R->getLoc(), "result of inst alias should be an instruction"); @@ -480,7 +482,7 @@ // the same class. StringMap NameClass; for (unsigned i = 0, e = Result->getNumArgs(); i != e; ++i) { - DefInit *ADI = dynamic_cast(Result->getArg(i)); + const DefInit *ADI = dynamic_cast(Result->getArg(i)); if (!ADI || Result->getArgName(i).empty()) continue; // Verify we don't have something like: (someinst GR16:$foo, GR32:$foo) @@ -519,11 +521,12 @@ // If the argument did not match the instruction operand, and the operand // is composed of multiple suboperands, try matching the suboperands. if (NumSubOps > 1) { - DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; + const DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; for (unsigned SubOp = 0; SubOp != NumSubOps; ++SubOp) { if (AliasOpNo >= Result->getNumArgs()) throw TGError(R->getLoc(), "not enough arguments for instruction!"); - Record *SubRec = dynamic_cast(MIOI->getArg(SubOp))->getDef(); + Record *SubRec = + dynamic_cast(MIOI->getArg(SubOp))->getDef(); if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false, R->getLoc(), T, ResOp)) { ResultOperands.push_back(ResOp); Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original) +++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Mon Jul 11 13:25:51 2011 @@ -94,7 +94,7 @@ /// MIOperandInfo - Default MI operand type. Note an operand may be made /// up of multiple MI operands. - DagInit *MIOperandInfo; + const DagInit *MIOperandInfo; /// Constraint info for this operand. This operand can have pieces, so we /// track constraint info for each. @@ -102,7 +102,7 @@ OperandInfo(Record *R, const std::string &N, const std::string &PMN, const std::string &EMN, unsigned MION, unsigned MINO, - DagInit *MIOI) + const DagInit *MIOI) : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN), MIOperandNo(MION), MINumOperands(MINO), MIOperandInfo(MIOI) {} @@ -265,7 +265,7 @@ std::string AsmString; /// Result - The result instruction. - DagInit *Result; + const DagInit *Result; /// ResultInst - The instruction generated by the alias (decoded from /// Result). @@ -311,7 +311,7 @@ CodeGenInstAlias(Record *R, CodeGenTarget &T); - bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, + bool tryAliasOpMatch(const DagInit *Result, unsigned AliasOpNo, Record *InstOpRec, bool hasSubOps, SMLoc Loc, CodeGenTarget &T, ResultOperand &ResOp); }; Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Mon Jul 11 13:25:51 2011 @@ -91,14 +91,15 @@ } // Process the composites. - ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); + const ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); for (unsigned i = 0, e = Comps->size(); i != e; ++i) { - DagInit *Pat = dynamic_cast(Comps->getElement(i)); + const DagInit *Pat = dynamic_cast(Comps->getElement(i)); if (!Pat) throw TGError(TheDef->getLoc(), "Invalid dag '" + Comps->getElement(i)->getAsString() + "' in CompositeIndices"); - DefInit *BaseIdxInit = dynamic_cast(Pat->getOperator()); + const DefInit *BaseIdxInit = + dynamic_cast(Pat->getOperator()); if (!BaseIdxInit || !BaseIdxInit->getDef()->isSubClassOf("SubRegIndex")) throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + Pat->getAsString()); @@ -107,7 +108,7 @@ CodeGenRegister *R2 = this; for (DagInit::const_arg_iterator di = Pat->arg_begin(), de = Pat->arg_end(); di != de; ++di) { - DefInit *IdxInit = dynamic_cast(*di); + const DefInit *IdxInit = dynamic_cast(*di); if (!IdxInit || !IdxInit->getDef()->isSubClassOf("SubRegIndex")) throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + Pat->getAsString()); @@ -163,7 +164,7 @@ void expand(SetTheory &ST, Record *Def, SetTheory::RecSet &Elts) { std::vector Indices = Def->getValueAsListOfDefs("SubRegIndices"); unsigned Dim = Indices.size(); - ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); + const ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); if (Dim != SubRegs->getSize()) throw TGError(Def->getLoc(), "SubRegIndices and SubRegs size mismatch"); if (Dim < 2) @@ -183,19 +184,19 @@ // Precompute some types. Record *RegisterCl = Def->getRecords().getClass("Register"); RecTy *RegisterRecTy = new RecordRecTy(RegisterCl); - StringInit *BlankName = new StringInit(""); + const StringInit *BlankName = StringInit::Create(""); // Zip them up. for (unsigned n = 0; n != Length; ++n) { std::string Name; Record *Proto = Lists[0][n]; - std::vector Tuple; + std::vector Tuple; unsigned CostPerUse = 0; for (unsigned i = 0; i != Dim; ++i) { Record *Reg = Lists[i][n]; if (i) Name += '_'; Name += Reg->getName(); - Tuple.push_back(new DefInit(Reg)); + Tuple.push_back(DefInit::Create(Reg)); CostPerUse = std::max(CostPerUse, unsigned(Reg->getValueAsInt("CostPerUse"))); } @@ -216,7 +217,7 @@ // Replace the sub-register list with Tuple. if (RV.getName() == "SubRegs") - RV.setValue(new ListInit(Tuple, RegisterRecTy)); + RV.setValue(ListInit::Create(Tuple, RegisterRecTy)); // Provide a blank AsmName. MC hacks are required anyway. if (RV.getName() == "AsmName") @@ -224,7 +225,7 @@ // CostPerUse is aggregated from all Tuple members. if (RV.getName() == "CostPerUse") - RV.setValue(new IntInit(CostPerUse)); + RV.setValue(IntInit::Create(CostPerUse)); // Copy fields from the RegisterTuples def. if (RV.getName() == "SubRegIndices" || @@ -278,7 +279,7 @@ Members.insert(RegBank.getReg((*Elements)[i])); // Alternative allocation orders may be subsets. - ListInit *Alts = R->getValueAsListInit("AltOrders"); + const ListInit *Alts = R->getValueAsListInit("AltOrders"); AltOrders.resize(Alts->size()); SetTheory::RecSet Order; for (unsigned i = 0, e = Alts->size(); i != e; ++i) { @@ -295,11 +296,11 @@ } // SubRegClasses is a list containing (RC, subregindex, ...) dags. - ListInit *SRC = R->getValueAsListInit("SubRegClasses"); + const ListInit *SRC = R->getValueAsListInit("SubRegClasses"); for (ListInit::const_iterator i = SRC->begin(), e = SRC->end(); i != e; ++i) { - DagInit *DAG = dynamic_cast(*i); + const DagInit *DAG = dynamic_cast(*i); if (!DAG) throw "SubRegClasses must contain DAGs"; - DefInit *DAGOp = dynamic_cast(DAG->getOperator()); + const DefInit *DAGOp = dynamic_cast(DAG->getOperator()); Record *RCRec; if (!DAGOp || !(RCRec = DAGOp->getDef())->isSubClassOf("RegisterClass")) throw "Operator '" + DAG->getOperator()->getAsString() + @@ -307,7 +308,7 @@ // Iterate over args, all SubRegIndex instances. for (DagInit::const_arg_iterator ai = DAG->arg_begin(), ae = DAG->arg_end(); ai != ae; ++ai) { - DefInit *Idx = dynamic_cast(*ai); + const DefInit *Idx = dynamic_cast(*ai); Record *IdxRec; if (!Idx || !(IdxRec = Idx->getDef())->isSubClassOf("SubRegIndex")) throw "Argument '" + (*ai)->getAsString() + Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Mon Jul 11 13:25:51 2011 @@ -402,7 +402,7 @@ // Parse the list of return types. std::vector OverloadedVTs; - ListInit *TypeList = R->getValueAsListInit("RetTypes"); + const ListInit *TypeList = R->getValueAsListInit("RetTypes"); for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { Record *TyEl = TypeList->getElementAsRecord(i); assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); @@ -470,7 +470,7 @@ } // Parse the intrinsic properties. - ListInit *PropList = R->getValueAsListInit("Properties"); + const ListInit *PropList = R->getValueAsListInit("Properties"); for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { Record *Property = PropList->getElementAsRecord(i); assert(Property->isSubClassOf("IntrinsicProperty") && Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Mon Jul 11 13:25:51 2011 @@ -203,7 +203,7 @@ assert(N->isLeaf() && "Not a leaf?"); // Direct match against an integer constant. - if (IntInit *II = dynamic_cast(N->getLeafValue())) { + if (const IntInit *II = dynamic_cast(N->getLeafValue())) { // If this is the root of the dag we're matching, we emit a redundant opcode // check to ensure that this gets folded into the normal top-level // OpcodeSwitch. @@ -215,7 +215,7 @@ return AddMatcher(new CheckIntegerMatcher(II->getValue())); } - DefInit *DI = dynamic_cast(N->getLeafValue()); + const DefInit *DI = dynamic_cast(N->getLeafValue()); if (DI == 0) { errs() << "Unknown leaf kind: " << *DI << "\n"; abort(); @@ -283,7 +283,8 @@ N->getOperator()->getName() == "or") && N->getChild(1)->isLeaf() && N->getChild(1)->getPredicateFns().empty() && N->getPredicateFns().empty()) { - if (IntInit *II = dynamic_cast(N->getChild(1)->getLeafValue())) { + if (const IntInit *II = + dynamic_cast(N->getChild(1)->getLeafValue())) { if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. // If this is at the root of the pattern, we emit a redundant // CheckOpcode so that the following checks get factored properly under @@ -496,7 +497,7 @@ --RecNodeEntry; // Entries in VariableMap are biased. const ComplexPattern &CP = - CGP.getComplexPattern(((DefInit*)N->getLeafValue())->getDef()); + CGP.getComplexPattern(((const DefInit*)N->getLeafValue())->getDef()); // Emit a CheckComplexPat operation, which does the match (aborting if it // fails) and pushes the matched operands onto the recorded nodes list. @@ -572,14 +573,14 @@ SmallVectorImpl &ResultOps) { assert(N->isLeaf() && "Must be a leaf"); - if (IntInit *II = dynamic_cast(N->getLeafValue())) { + if (const IntInit *II = dynamic_cast(N->getLeafValue())) { AddMatcher(new EmitIntegerMatcher(II->getValue(), N->getType(0))); ResultOps.push_back(NextRecordedOperandNo++); return; } // If this is an explicit register reference, handle it. - if (DefInit *DI = dynamic_cast(N->getLeafValue())) { + if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { Record *Def = DI->getDef(); if (Def->isSubClassOf("Register")) { const CodeGenRegister *Reg = Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -241,7 +241,7 @@ if (Op->getType(0) != VT) return false; - DefInit *OpDI = dynamic_cast(Op->getLeafValue()); + const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); if (!OpDI) return false; Record *OpLeafRec = OpDI->getDef(); @@ -401,12 +401,12 @@ if (!Op->isLeaf()) return PhysReg; - DefInit *OpDI = dynamic_cast(Op->getLeafValue()); + const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); Record *OpLeafRec = OpDI->getDef(); if (!OpLeafRec->isSubClassOf("Register")) return PhysReg; - PhysReg += static_cast(OpLeafRec->getValue( \ + PhysReg += static_cast(OpLeafRec->getValue( \ "Namespace")->getValue())->getValue(); PhysReg += "::"; PhysReg += Target.getRegBank().getReg(OpLeafRec)->getName(); @@ -468,7 +468,7 @@ // a bit too complicated for now. if (!Dst->getChild(1)->isLeaf()) continue; - DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); + const DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); if (SR) SubRegNo = getQualifiedName(SR->getDef()); else Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -48,15 +48,15 @@ static int Value(bit_value_t V) { return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); } -static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { - if (BitInit *bit = dynamic_cast(bits.getBit(index))) +static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { + if (const BitInit *bit = dynamic_cast(bits.getBit(index))) return bit->getValue() ? BIT_TRUE : BIT_FALSE; // The bit is uninitialized. return BIT_UNSET; } // Prints the bit value for each position. -static void dumpBits(raw_ostream &o, BitsInit &bits) { +static void dumpBits(raw_ostream &o, const BitsInit &bits) { unsigned index; for (index = bits.getNumBits(); index > 0; index--) { @@ -76,8 +76,8 @@ } } -static BitsInit &getBitsField(const Record &def, const char *str) { - BitsInit *bits = def.getValueAsBitsInit(str); +static const BitsInit &getBitsField(const Record &def, const char *str) { + const BitsInit *bits = def.getValueAsBitsInit(str); return *bits; } @@ -279,7 +279,8 @@ protected: // Populates the insn given the uid. void insnWithID(insn_t &Insn, unsigned Opcode) const { - BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); + const BitsInit &Bits = + getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); for (unsigned i = 0; i < BIT_WIDTH; ++i) Insn[i] = bitFromBits(Bits, i); @@ -1230,7 +1231,7 @@ Def.getValueAsBit("isCodeGenOnly")) return false; - BitsInit &Bits = getBitsField(Def, "Inst"); + const BitsInit &Bits = getBitsField(Def, "Inst"); if (Bits.allInComplete()) return false; std::vector InsnOperands; @@ -1251,16 +1252,16 @@ // Gather the outputs/inputs of the instruction, so we can find their // positions in the encoding. This assumes for now that they appear in the // MCInst in the order that they're listed. - std::vector > InOutOperands; - DagInit *Out = Def.getValueAsDag("OutOperandList"); - DagInit *In = Def.getValueAsDag("InOperandList"); + std::vector > InOutOperands; + const DagInit *Out = Def.getValueAsDag("OutOperandList"); + const DagInit *In = Def.getValueAsDag("InOperandList"); for (unsigned i = 0; i < Out->getNumArgs(); ++i) InOutOperands.push_back(std::make_pair(Out->getArg(i), Out->getArgName(i))); for (unsigned i = 0; i < In->getNumArgs(); ++i) InOutOperands.push_back(std::make_pair(In->getArg(i), In->getArgName(i))); // For each operand, see if we can figure out where it is encoded. - for (std::vector >::iterator + for (std::vector >::iterator NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) { unsigned PrevBit = ~0; unsigned Base = ~0; @@ -1268,10 +1269,10 @@ std::string Decoder = ""; for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) { - VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); + const VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); if (!BI) continue; - VarInit *Var = dynamic_cast(BI->getVariable()); + const VarInit *Var = dynamic_cast(BI->getVariable()); assert(Var); unsigned CurrBit = BI->getBitNum(); if (Var->getName() != NI->second) continue; @@ -1301,7 +1302,7 @@ // for decoding register classes. // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. - TypedInit *TI = dynamic_cast(NI->first); + const TypedInit *TI = dynamic_cast(NI->first); RecordRecTy *Type = dynamic_cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; @@ -1313,8 +1314,8 @@ } RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod"); - StringInit *String = DecoderString ? - dynamic_cast(DecoderString->getValue()) : + const StringInit *String = DecoderString ? + dynamic_cast(DecoderString->getValue()) : 0; if (!isReg && String && String->getValue() != "") Decoder = String->getValue(); Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -61,7 +61,7 @@ // registers in their multi-operand operands. It may also be an anonymous // operand, which has a single operand, but no declared class for the // operand. - DagInit *MIOI = Inst.Operands[i].MIOperandInfo; + const DagInit *MIOI = Inst.Operands[i].MIOperandInfo; if (!MIOI || MIOI->getNumArgs() == 0) { // Single, anonymous, operand. @@ -70,7 +70,7 @@ for (unsigned j = 0, e = Inst.Operands[i].MINumOperands; j != e; ++j) { OperandList.push_back(Inst.Operands[i]); - Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); + Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); OperandList.back().Rec = OpR; } } @@ -288,11 +288,11 @@ if (Inst.hasExtraDefRegAllocReq) OS << "|(1<getValueAsBitsInit("TSFlags"); + const BitsInit *TSF = Inst.TheDef->getValueAsBitsInit("TSFlags"); if (!TSF) throw "no TSFlags?"; uint64_t Value = 0; for (unsigned i = 0, e = TSF->getNumBits(); i != e; ++i) { - if (BitInit *Bit = dynamic_cast(TSF->getBit(i))) + if (const BitInit *Bit = dynamic_cast(TSF->getBit(i))) Value |= uint64_t(Bit->getValue()) << i; else throw "Invalid TSFlags bit in " + Inst.TheDef->getName(); Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -245,7 +245,7 @@ unsigned Flags; std::string Help; unsigned MultiVal; - Init* InitVal; + const Init* InitVal; OptionDescription(OptionType::OptionType t = OptionType::Switch, const std::string& n = "", @@ -589,7 +589,7 @@ } template -void InvokeDagInitHandler(FunctionObject* Obj, Init* I) { +void InvokeDagInitHandler(FunctionObject* Obj, const Init* I) { typedef void (FunctionObject::*Handler) (const DagInit&); const DagInit& Dag = InitPtrToDag(I); @@ -658,7 +658,7 @@ /// operator() - Just forwards to the corresponding property /// handler. - void operator() (Init* I) { + void operator() (const Init* I) { InvokeDagInitHandler(this, I); } @@ -705,10 +705,10 @@ void onInit (const DagInit& d) { CheckNumberOfArguments(d, 1); - Init* i = d.getArg(0); + const Init* i = d.getArg(0); const std::string& str = i->getAsString(); - bool correct = optDesc_.isParameter() && dynamic_cast(i); + bool correct = optDesc_.isParameter() && dynamic_cast(i); correct |= (optDesc_.isSwitch() && (str == "true" || str == "false")); if (!correct) @@ -821,7 +821,7 @@ for (RecordVector::const_iterator B = V.begin(), E = V.end(); B!=E; ++B) { // Throws an exception if the value does not exist. - ListInit* PropList = (*B)->getValueAsListInit("options"); + const ListInit* PropList = (*B)->getValueAsListInit("options"); // For every option description in this list: invoke AddOption. std::for_each(PropList->begin(), PropList->end(), AddOption(OptDescs)); @@ -836,8 +836,8 @@ struct ToolDescription : public RefCountedBase { std::string Name; - Init* CmdLine; - Init* Actions; + const Init* CmdLine; + const Init* Actions; StrVector InLanguage; std::string InFileOption; std::string OutFileOption; @@ -903,7 +903,7 @@ } } - void operator() (Init* I) { + void operator() (const Init* I) { InvokeDagInitHandler(this, I); } @@ -915,9 +915,9 @@ void onActions (const DagInit& d) { CheckNumberOfArguments(d, 1); - Init* Case = d.getArg(0); + const Init* Case = d.getArg(0); if (typeid(*Case) != typeid(DagInit) || - GetOperatorName(static_cast(*Case)) != "case") + GetOperatorName(static_cast(*Case)) != "case") throw "The argument to (actions) should be a 'case' construct!"; toolDesc_.Actions = Case; } @@ -954,7 +954,7 @@ isReallyJoin = true; } else { - Init* I = d.getArg(0); + const Init* I = d.getArg(0); isReallyJoin = InitPtrToBool(I); } @@ -1007,7 +1007,7 @@ E = Tools.end(); B!=E; ++B) { const Record* T = *B; // Throws an exception if the value does not exist. - ListInit* PropList = T->getValueAsListInit("properties"); + const ListInit* PropList = T->getValueAsListInit("properties"); IntrusiveRefCntPtr ToolDesc(new ToolDescription(T->getName())); @@ -1163,7 +1163,7 @@ unsigned i = 1; for (DagInit::const_arg_iterator B = d.arg_begin(), E = d.arg_end(); B != E; ++B) { - Init* arg = *B; + const Init* arg = *B; if (!even) { @@ -1181,8 +1181,8 @@ } else { - if (dynamic_cast(arg) - && GetOperatorName(static_cast(*arg)) == "case") { + if (dynamic_cast(arg) + && GetOperatorName(static_cast(*arg)) == "case") { // Nested 'case'. WalkCase(arg, TestCallback, StatementCallback, IndentLevel + Indent1); } @@ -1210,7 +1210,7 @@ ActionName == "parameter_equals" || ActionName == "element_in_list") { CheckNumberOfArguments(Stmt, 1); - Init* Arg = Stmt.getArg(0); + const Init* Arg = Stmt.getArg(0); if (typeid(*Arg) == typeid(StringInit)) OptionNames_.insert(InitPtrToString(Arg)); } @@ -1218,7 +1218,7 @@ ActionName == "any_not_empty" || ActionName == "any_empty" || ActionName == "not_empty" || ActionName == "empty") { for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) { - Init* Arg = Stmt.getArg(i); + const Init* Arg = Stmt.getArg(i); if (typeid(*Arg) == typeid(StringInit)) OptionNames_.insert(InitPtrToString(Arg)); } @@ -2613,7 +2613,7 @@ for (RecordVector::const_iterator B = OptionPreprocessors.begin(), E = OptionPreprocessors.end(); B!=E; ++B) { - DagInit* Case = (*B)->getValueAsDag("preprocessor"); + const DagInit* Case = (*B)->getValueAsDag("preprocessor"); EmitCaseConstructHandler(Case, Indent1, EmitPreprocessOptionsCallback(OptDecs), false, OptDecs, O); @@ -2645,7 +2645,7 @@ } } - void operator() (Init* I) { + void operator() (const Init* I) { InvokeDagInitHandler(this, I); } @@ -2655,7 +2655,7 @@ CheckNumberOfArguments(d, 2); const std::string& Lang = InitPtrToString(d.getArg(0)); - Init* Suffixes = d.getArg(1); + const Init* Suffixes = d.getArg(1); // Second argument to lang_to_suffixes is either a single string... if (typeid(*Suffixes) == typeid(StringInit)) { @@ -2688,7 +2688,7 @@ // Call DoEmitPopulateLanguageMap. for (RecordVector::const_iterator B = LangMaps.begin(), E = LangMaps.end(); B!=E; ++B) { - ListInit* LangMap = (*B)->getValueAsListInit("map"); + const ListInit* LangMap = (*B)->getValueAsListInit("map"); std::for_each(LangMap->begin(), LangMap->end(), DoEmitPopulateLanguageMap(O)); } @@ -2947,7 +2947,7 @@ // Look for hook invocations in 'cmd_line'. if (!D.CmdLine) continue; - if (dynamic_cast(D.CmdLine)) + if (dynamic_cast(D.CmdLine)) // This is a string. ExtractHookNames(HookNames, OptDescs).operator()(D.CmdLine); else Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -56,7 +56,7 @@ static const std::string getOptionName(const Record &R) { // Use the record name unless EnumName is defined. - if (dynamic_cast(R.getValueInit("EnumName"))) + if (dynamic_cast(R.getValueInit("EnumName"))) return R.getName(); return R.getValueAsString("EnumName"); @@ -105,7 +105,7 @@ // The containing option group (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; @@ -114,7 +114,7 @@ OS << ", INVALID, 0, 0"; // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { + if (!dynamic_cast(R.getValueInit("HelpText"))) { OS << ",\n"; OS << " "; write_cstring(OS, R.getValueAsString("HelpText")); @@ -145,14 +145,14 @@ // The containing option group (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; // The option alias (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; @@ -166,7 +166,7 @@ for (unsigned i = 0, e = LI->size(); i != e; ++i) { if (i) OS << " | "; - OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); + OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); } } @@ -174,7 +174,7 @@ OS << ", " << R.getValueAsInt("NumArgs"); // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { + if (!dynamic_cast(R.getValueInit("HelpText"))) { OS << ",\n"; OS << " "; write_cstring(OS, R.getValueAsString("HelpText")); @@ -183,7 +183,7 @@ // The option meta-variable name. OS << ", "; - if (!dynamic_cast(R.getValueInit("MetaVarName"))) + if (!dynamic_cast(R.getValueInit("MetaVarName"))) write_cstring(OS, R.getValueAsString("MetaVarName")); else OS << "0"; Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -24,11 +24,11 @@ // a single dag, so we can do fancier things. unsigned PseudoLoweringEmitter:: -addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn, +addDagOperandMapping(Record *Rec, const DagInit *Dag, CodeGenInstruction &Insn, IndexedMap &OperandMap, unsigned BaseIdx) { unsigned OpsAdded = 0; for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) { - if (DefInit *DI = dynamic_cast(Dag->getArg(i))) { + if (const DefInit *DI = dynamic_cast(Dag->getArg(i))) { // Physical register reference. Explicit check for the special case // "zero_reg" definition. if (DI->getDef()->isSubClassOf("Register") || @@ -54,11 +54,13 @@ for (unsigned I = 0, E = Insn.Operands[i].MINumOperands; I != E; ++I) OperandMap[BaseIdx + i + I].Kind = OpData::Operand; OpsAdded += Insn.Operands[i].MINumOperands; - } else if (IntInit *II = dynamic_cast(Dag->getArg(i))) { + } else if (const IntInit *II = + dynamic_cast(Dag->getArg(i))) { OperandMap[BaseIdx + i].Kind = OpData::Imm; OperandMap[BaseIdx + i].Data.Imm = II->getValue(); ++OpsAdded; - } else if (DagInit *SubDag = dynamic_cast(Dag->getArg(i))) { + } else if (const DagInit *SubDag = + dynamic_cast(Dag->getArg(i))) { // Just add the operands recursively. This is almost certainly // a constant value for a complex operand (> 1 MI operand). unsigned NewOps = @@ -77,11 +79,11 @@ // Validate that the result pattern has the corrent number and types // of arguments for the instruction it references. - DagInit *Dag = Rec->getValueAsDag("ResultInst"); + const DagInit *Dag = Rec->getValueAsDag("ResultInst"); assert(Dag && "Missing result instruction in pseudo expansion!"); DEBUG(dbgs() << " Result: " << *Dag << "\n"); - DefInit *OpDef = dynamic_cast(Dag->getOperator()); + const DefInit *OpDef = dynamic_cast(Dag->getOperator()); if (!OpDef) throw TGError(Rec->getLoc(), Rec->getName() + " has unexpected operator type!"); Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h (original) +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h Mon Jul 11 13:25:51 2011 @@ -47,7 +47,7 @@ SmallVector Expansions; - unsigned addDagOperandMapping(Record *Rec, DagInit *Dag, + unsigned addDagOperandMapping(Record *Rec, const DagInit *Dag, CodeGenInstruction &Insn, IndexedMap &OperandMap, unsigned BaseIdx); Modified: llvm/trunk/utils/TableGen/Record.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.cpp (original) +++ llvm/trunk/utils/TableGen/Record.cpp Mon Jul 11 13:25:51 2011 @@ -15,6 +15,8 @@ #include "Error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Format.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -25,7 +27,7 @@ void RecTy::dump() const { print(errs()); } -Init *BitRecTy::convertValue(BitsInit *BI) { +const Init *BitRecTy::convertValue(const BitsInit *BI) { if (BI->getNumBits() != 1) return 0; // Only accept if just one bit! return BI->getBit(0); } @@ -34,14 +36,14 @@ return RHS->getNumBits() == 1; } -Init *BitRecTy::convertValue(IntInit *II) { +const Init *BitRecTy::convertValue(const IntInit *II) { int64_t Val = II->getValue(); if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit! - return new BitInit(Val != 0); + return BitInit::Create(Val != 0); } -Init *BitRecTy::convertValue(TypedInit *VI) { +const Init *BitRecTy::convertValue(const TypedInit *VI) { if (dynamic_cast(VI->getType())) return VI; // Accept variable if it is already of bit type! return 0; @@ -51,19 +53,21 @@ return "bits<" + utostr(Size) + ">"; } -Init *BitsRecTy::convertValue(UnsetInit *UI) { - BitsInit *Ret = new BitsInit(Size); +const Init *BitsRecTy::convertValue(const UnsetInit *UI) { + SmallVector Bits(Size); for (unsigned i = 0; i != Size; ++i) - Ret->setBit(i, new UnsetInit()); - return Ret; + Bits[i] = UnsetInit::Create(); + + return BitsInit::Create(Bits.begin(), Bits.end()); } -Init *BitsRecTy::convertValue(BitInit *UI) { +const Init *BitsRecTy::convertValue(const BitInit *UI) { if (Size != 1) return 0; // Can only convert single bit. - BitsInit *Ret = new BitsInit(1); - Ret->setBit(0, UI); - return Ret; + + const Init *Bits[1] = { UI }; + + return BitsInit::Create(Bits, array_endof(Bits)); } /// canFitInBitfield - Return true if the number of bits is large enough to hold @@ -74,82 +78,85 @@ (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1); } -/// convertValue from Int initializer to bits type: Split the integer up into the -/// appropriate bits. +/// convertValue from Int initializer to bits type: Split the integer +/// up into the appropriate bits. /// -Init *BitsRecTy::convertValue(IntInit *II) { +const Init *BitsRecTy::convertValue(const IntInit *II) { int64_t Value = II->getValue(); // Make sure this bitfield is large enough to hold the integer value. if (!canFitInBitfield(Value, Size)) return 0; - BitsInit *Ret = new BitsInit(Size); + SmallVector Bits(Size); + for (unsigned i = 0; i != Size; ++i) - Ret->setBit(i, new BitInit(Value & (1LL << i))); + Bits[i] = BitInit::Create(Value & (1LL << i)); - return Ret; + return BitsInit::Create(Bits.begin(), Bits.end()); } -Init *BitsRecTy::convertValue(BitsInit *BI) { +const Init *BitsRecTy::convertValue(const BitsInit *BI) { // If the number of bits is right, return it. Otherwise we need to expand or // truncate. if (BI->getNumBits() == Size) return BI; return 0; } -Init *BitsRecTy::convertValue(TypedInit *VI) { +const Init *BitsRecTy::convertValue(const TypedInit *VI) { if (BitsRecTy *BRT = dynamic_cast(VI->getType())) if (BRT->Size == Size) { - BitsInit *Ret = new BitsInit(Size); + SmallVector Bits(Size); + for (unsigned i = 0; i != Size; ++i) - Ret->setBit(i, new VarBitInit(VI, i)); - return Ret; + Bits[i] = VarBitInit::Create(VI, i); + return BitsInit::Create(Bits.begin(), Bits.end()); } if (Size == 1 && dynamic_cast(VI->getType())) { - BitsInit *Ret = new BitsInit(1); - Ret->setBit(0, VI); - return Ret; + const Init *Bits[1] = { VI }; + + return BitsInit::Create(Bits, array_endof(Bits)); } - if (TernOpInit *Tern = dynamic_cast(VI)) { + if (const TernOpInit *Tern = dynamic_cast(VI)) { if (Tern->getOpcode() == TernOpInit::IF) { - Init *LHS = Tern->getLHS(); - Init *MHS = Tern->getMHS(); - Init *RHS = Tern->getRHS(); + const Init *LHS = Tern->getLHS(); + const Init *MHS = Tern->getMHS(); + const Init *RHS = Tern->getRHS(); - IntInit *MHSi = dynamic_cast(MHS); - IntInit *RHSi = dynamic_cast(RHS); + const IntInit *MHSi = dynamic_cast(MHS); + const IntInit *RHSi = dynamic_cast(RHS); if (MHSi && RHSi) { int64_t MHSVal = MHSi->getValue(); int64_t RHSVal = RHSi->getValue(); if (canFitInBitfield(MHSVal, Size) && canFitInBitfield(RHSVal, Size)) { - BitsInit *Ret = new BitsInit(Size); + SmallVector NewBits(Size); for (unsigned i = 0; i != Size; ++i) - Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, - new IntInit((MHSVal & (1LL << i)) ? 1 : 0), - new IntInit((RHSVal & (1LL << i)) ? 1 : 0), - VI->getType())); - - return Ret; + NewBits[i] = + TernOpInit::Create(TernOpInit::IF, LHS, + IntInit::Create((MHSVal & (1LL << i)) ? 1 : 0), + IntInit::Create((RHSVal & (1LL << i)) ? 1 : 0), + VI->getType()); + + return BitsInit::Create(NewBits.begin(), NewBits.end()); } } else { - BitsInit *MHSbs = dynamic_cast(MHS); - BitsInit *RHSbs = dynamic_cast(RHS); + const BitsInit *MHSbs = dynamic_cast(MHS); + const BitsInit *RHSbs = dynamic_cast(RHS); if (MHSbs && RHSbs) { - BitsInit *Ret = new BitsInit(Size); + SmallVector NewBits(Size); for (unsigned i = 0; i != Size; ++i) - Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, - MHSbs->getBit(i), - RHSbs->getBit(i), - VI->getType())); + NewBits[i] = TernOpInit::Create(TernOpInit::IF, LHS, + MHSbs->getBit(i), + RHSbs->getBit(i), + VI->getType()); - return Ret; + return BitsInit::Create(NewBits.begin(), NewBits.end()); } } } @@ -158,54 +165,54 @@ return 0; } -Init *IntRecTy::convertValue(BitInit *BI) { - return new IntInit(BI->getValue()); +const Init *IntRecTy::convertValue(const BitInit *BI) { + return IntInit::Create(BI->getValue()); } -Init *IntRecTy::convertValue(BitsInit *BI) { +const Init *IntRecTy::convertValue(const BitsInit *BI) { int64_t Result = 0; for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) - if (BitInit *Bit = dynamic_cast(BI->getBit(i))) { + if (const BitInit *Bit = dynamic_cast(BI->getBit(i))) { Result |= Bit->getValue() << i; } else { return 0; } - return new IntInit(Result); + return IntInit::Create(Result); } -Init *IntRecTy::convertValue(TypedInit *TI) { +const Init *IntRecTy::convertValue(const TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; // Accept variable if already of the right type! return 0; } -Init *StringRecTy::convertValue(UnOpInit *BO) { +const Init *StringRecTy::convertValue(const UnOpInit *BO) { if (BO->getOpcode() == UnOpInit::CAST) { - Init *L = BO->getOperand()->convertInitializerTo(this); + const Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return new UnOpInit(UnOpInit::CAST, L, new StringRecTy); + return UnOpInit::Create(UnOpInit::CAST, L, new StringRecTy); return BO; } - return convertValue((TypedInit*)BO); + return convertValue((const TypedInit*)BO); } -Init *StringRecTy::convertValue(BinOpInit *BO) { +const Init *StringRecTy::convertValue(const BinOpInit *BO) { if (BO->getOpcode() == BinOpInit::STRCONCAT) { - Init *L = BO->getLHS()->convertInitializerTo(this); - Init *R = BO->getRHS()->convertInitializerTo(this); + const Init *L = BO->getLHS()->convertInitializerTo(this); + const Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return new BinOpInit(BinOpInit::STRCONCAT, L, R, new StringRecTy); + return BinOpInit::Create(BinOpInit::STRCONCAT, L, R, new StringRecTy); return BO; } - return convertValue((TypedInit*)BO); + return convertValue((const TypedInit*)BO); } -Init *StringRecTy::convertValue(TypedInit *TI) { +const Init *StringRecTy::convertValue(const TypedInit *TI) { if (dynamic_cast(TI->getType())) return TI; // Accept variable if already of the right type! return 0; @@ -215,13 +222,13 @@ return "list<" + Ty->getAsString() + ">"; } -Init *ListRecTy::convertValue(ListInit *LI) { - std::vector Elements; +const Init *ListRecTy::convertValue(const ListInit *LI) { + std::vector Elements; // Verify that all of the elements of the list are subclasses of the // appropriate class! for (unsigned i = 0, e = LI->getSize(); i != e; ++i) - if (Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) + if (const Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) Elements.push_back(CI); else return 0; @@ -231,10 +238,10 @@ return 0; } - return new ListInit(Elements, new ListRecTy(Ty)); + return ListInit::Create(Elements, new ListRecTy(Ty)); } -Init *ListRecTy::convertValue(TypedInit *TI) { +const Init *ListRecTy::convertValue(const TypedInit *TI) { // Ensure that TI is compatible with our class. if (ListRecTy *LRT = dynamic_cast(TI->getType())) if (LRT->getElementType()->typeIsConvertibleTo(getElementType())) @@ -242,36 +249,36 @@ return 0; } -Init *CodeRecTy::convertValue(TypedInit *TI) { +const Init *CodeRecTy::convertValue(const TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; return 0; } -Init *DagRecTy::convertValue(TypedInit *TI) { +const Init *DagRecTy::convertValue(const TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; return 0; } -Init *DagRecTy::convertValue(UnOpInit *BO) { +const Init *DagRecTy::convertValue(const UnOpInit *BO) { if (BO->getOpcode() == UnOpInit::CAST) { - Init *L = BO->getOperand()->convertInitializerTo(this); + const Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return new UnOpInit(UnOpInit::CAST, L, new DagRecTy); + return UnOpInit::Create(UnOpInit::CAST, L, new DagRecTy); return BO; } return 0; } -Init *DagRecTy::convertValue(BinOpInit *BO) { +const Init *DagRecTy::convertValue(const BinOpInit *BO) { if (BO->getOpcode() == BinOpInit::CONCAT) { - Init *L = BO->getLHS()->convertInitializerTo(this); - Init *R = BO->getRHS()->convertInitializerTo(this); + const Init *L = BO->getLHS()->convertInitializerTo(this); + const Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy); + return BinOpInit::Create(BinOpInit::CONCAT, L, R, new DagRecTy); return BO; } return 0; @@ -281,14 +288,14 @@ return Rec->getName(); } -Init *RecordRecTy::convertValue(DefInit *DI) { +const Init *RecordRecTy::convertValue(const DefInit *DI) { // Ensure that DI is a subclass of Rec. if (!DI->getDef()->isSubClassOf(Rec)) return 0; return DI; } -Init *RecordRecTy::convertValue(TypedInit *TI) { +const Init *RecordRecTy::convertValue(const TypedInit *TI) { // Ensure that TI is compatible with Rec. if (RecordRecTy *RRT = dynamic_cast(TI->getType())) if (RRT->getRecord()->isSubClassOf(getRecord()) || @@ -367,25 +374,59 @@ // Initializer implementations //===----------------------------------------------------------------------===// +FoldingSet Init::UniqueInits; +BumpPtrAllocator Init::InitAllocator; + void Init::dump() const { return print(errs()); } -Init *BitsInit::convertInitializerBitRange(const std::vector &Bits) { - BitsInit *BI = new BitsInit(Bits.size()); +const UnsetInit *UnsetInit::Create() { + FoldingSetNodeID ID; + ID.AddInteger(initUnset); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + UnsetInit *I = InitAllocator.Allocate(); + new (I) UnsetInit(ID); + UniqueInits.InsertNode(I, IP); + return I; +} + +const BitInit *BitInit::Create(bool V) { + FoldingSetNodeID ID; + ID.AddInteger(initBit); + ID.AddBoolean(V); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + BitInit *I = InitAllocator.Allocate(); + new (I) BitInit(ID, V); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init * +BitsInit::convertInitializerBitRange(const std::vector &Bits) const { + SmallVector NewBits(Bits.size()); + for (unsigned i = 0, e = Bits.size(); i != e; ++i) { if (Bits[i] >= getNumBits()) { - delete BI; return 0; } - BI->setBit(i, getBit(Bits[i])); + NewBits[i] = getBit(Bits[i]); } - return BI; + + return BitsInit::Create(NewBits.begin(), NewBits.end()); } std::string BitsInit::getAsString() const { std::string Result = "{ "; for (unsigned i = 0, e = getNumBits(); i != e; ++i) { if (i) Result += ", "; - if (Init *Bit = getBit(e-i-1)) + if (const Init *Bit = getBit(e-i-1)) Result += Bit->getAsString(); else Result += "*"; @@ -396,70 +437,141 @@ // resolveReferences - If there are any field references that refer to fields // that have been filled in, we can propagate the values now. // -Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) { +const Init *BitsInit::resolveReferences(Record &R, + const RecordVal *RV) const { bool Changed = false; - BitsInit *New = new BitsInit(getNumBits()); - for (unsigned i = 0, e = Bits.size(); i != e; ++i) { - Init *B; - Init *CurBit = getBit(i); + SmallVector Bits(getNumBits()); + + for (unsigned i = 0, e = getNumBits(); i != e; ++i) { + const Init *B; + const Init *CurBit = getBit(i); do { B = CurBit; CurBit = CurBit->resolveReferences(R, RV); Changed |= B != CurBit; } while (B != CurBit); - New->setBit(i, CurBit); + Bits[i] = CurBit; } if (Changed) - return New; - delete New; + return BitsInit::Create(Bits.begin(), Bits.end()); + return this; } +const IntInit *IntInit::Create(int64_t V) { + FoldingSetNodeID ID; + ID.AddInteger(initInt); + ID.AddInteger(V); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + IntInit *I = InitAllocator.Allocate(); + new (I) IntInit(ID, V); + UniqueInits.InsertNode(I, IP); + return I; +} + std::string IntInit::getAsString() const { return itostr(Value); } -Init *IntInit::convertInitializerBitRange(const std::vector &Bits) { - BitsInit *BI = new BitsInit(Bits.size()); +const Init * +IntInit::convertInitializerBitRange(const std::vector &Bits) const { + SmallVector NewBits(Bits.size()); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { - if (Bits[i] >= 64) { - delete BI; + if (Bits[i] >= 64) return 0; - } - BI->setBit(i, new BitInit(Value & (INT64_C(1) << Bits[i]))); + + NewBits[i] = BitInit::Create(Value & (INT64_C(1) << Bits[i])); + } + + return BitsInit::Create(NewBits.begin(), NewBits.end()); +} + +const StringInit *StringInit::Create(const std::string &V) { + FoldingSetNodeID ID; + ID.AddInteger(initString); + ID.AddString(V); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + StringInit *I = InitAllocator.Allocate(); + new (I) StringInit(ID, V); + UniqueInits.InsertNode(I, IP); + return I; +} + +const CodeInit *CodeInit::Create(const std::string &V) { + FoldingSetNodeID ID; + ID.AddInteger(initCode); + ID.AddString(V); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + CodeInit *I = InitAllocator.Allocate(); + new (I) CodeInit(ID, V); + UniqueInits.InsertNode(I, IP); + return I; +} + +const ListInit *ListInit::Create(std::vector &Vs, RecTy *EltTy) { + FoldingSetNodeID ID; + ID.AddInteger(initList); + ID.AddString(EltTy->getAsString()); + + for (std::vector::iterator i = Vs.begin(), iend = Vs.end(); + i != iend; + ++i) { + ID.AddPointer(*i); } - return BI; + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + ListInit *I = InitAllocator.Allocate(); + new (I) ListInit(ID, Vs, EltTy); + UniqueInits.InsertNode(I, IP); + return I; } -Init *ListInit::convertInitListSlice(const std::vector &Elements) { - std::vector Vals; +const Init * +ListInit::convertInitListSlice(const std::vector &Elements) const { + std::vector Vals; for (unsigned i = 0, e = Elements.size(); i != e; ++i) { if (Elements[i] >= getSize()) return 0; Vals.push_back(getElement(Elements[i])); } - return new ListInit(Vals, getType()); + return ListInit::Create(Vals, getType()); } Record *ListInit::getElementAsRecord(unsigned i) const { assert(i < Values.size() && "List element index out of range!"); - DefInit *DI = dynamic_cast(Values[i]); + const DefInit *DI = dynamic_cast(Values[i]); if (DI == 0) throw "Expected record in list!"; return DI->getDef(); } -Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) { - std::vector Resolved; +const Init *ListInit::resolveReferences(Record &R, + const RecordVal *RV) const { + std::vector Resolved; Resolved.reserve(getSize()); bool Changed = false; for (unsigned i = 0, e = getSize(); i != e; ++i) { - Init *E; - Init *CurElt = getElement(i); + const Init *E; + const Init *CurElt = getElement(i); do { E = CurElt; @@ -470,20 +582,25 @@ } if (Changed) - return new ListInit(Resolved, getType()); + return ListInit::Create(Resolved, getType()); + return this; } -Init *ListInit::resolveListElementReference(Record &R, const RecordVal *IRV, - unsigned Elt) { +const Init *ListInit::resolveListElementReference(Record &R, + const RecordVal *IRV, + unsigned Elt) const { if (Elt >= getSize()) return 0; // Out of range reference. - Init *E = getElement(Elt); + + const Init *E = getElement(Elt); + // If the element is set to some value, or if we are resolving a reference // to a specific variable and that variable is explicitly unset, then // replace the VarListElementInit with it. - if (IRV || !dynamic_cast(E)) + if (IRV || !dynamic_cast(E)) return E; + return 0; } @@ -496,12 +613,12 @@ return Result + "]"; } -Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, - unsigned Bit) { - Init *Folded = Fold(&R, 0); +const Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, + unsigned Bit) const { + const Init *Folded = Fold(&R, 0); if (Folded != this) { - TypedInit *Typed = dynamic_cast(Folded); + const TypedInit *Typed = dynamic_cast(Folded); if (Typed) { return Typed->resolveBitReference(R, IRV, Bit); } @@ -510,12 +627,12 @@ return 0; } -Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, - unsigned Elt) { - Init *Folded = Fold(&R, 0); +const Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, + unsigned Elt) const { + const Init *Folded = Fold(&R, 0); if (Folded != this) { - TypedInit *Typed = dynamic_cast(Folded); + const TypedInit *Typed = dynamic_cast(Folded); if (Typed) { return Typed->resolveListElementReference(R, IRV, Elt); } @@ -524,22 +641,39 @@ return 0; } -Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { +const UnOpInit *UnOpInit::Create(UnaryOp opc, const Init *lhs, RecTy *Type) { + FoldingSetNodeID ID; + ID.AddInteger(initUnOp); + ID.AddInteger(opc); + ID.AddString(Type->getAsString()); + ID.AddPointer(lhs); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + UnOpInit *I = InitAllocator.Allocate(); + new (I) UnOpInit(ID, opc, lhs, Type); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { switch (getOpcode()) { default: assert(0 && "Unknown unop"); case CAST: { if (getType()->getAsString() == "string") { - StringInit *LHSs = dynamic_cast(LHS); + const StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { return LHSs; } - DefInit *LHSd = dynamic_cast(LHS); + const DefInit *LHSd = dynamic_cast(LHS); if (LHSd) { - return new StringInit(LHSd->getDef()->getName()); + return StringInit::Create(LHSd->getDef()->getName()); } } else { - StringInit *LHSs = dynamic_cast(LHS); + const StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { std::string Name = LHSs->getValue(); @@ -548,7 +682,7 @@ if (const RecordVal *RV = CurRec->getValue(Name)) { if (RV->getType() != getType()) throw "type mismatch in cast"; - return new VarInit(Name, RV->getType()); + return VarInit::Create(Name, RV->getType()); } std::string TemplateArgName = CurRec->getName()+":"+Name; @@ -559,7 +693,7 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return new VarInit(TemplateArgName, RV->getType()); + return VarInit::Create(TemplateArgName, RV->getType()); } } @@ -572,12 +706,12 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return new VarInit(MCName, RV->getType()); + return VarInit::Create(MCName, RV->getType()); } } if (Record *D = (CurRec->getRecords()).getDef(Name)) - return new DefInit(D); + return DefInit::Create(D); throw TGError(CurRec->getLoc(), "Undefined reference:'" + Name + "'\n"); } @@ -585,7 +719,7 @@ break; } case HEAD: { - ListInit *LHSl = dynamic_cast(LHS); + const ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { assert(0 && "Empty list in car"); @@ -596,33 +730,33 @@ break; } case TAIL: { - ListInit *LHSl = dynamic_cast(LHS); + const ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { assert(0 && "Empty list in cdr"); return 0; } - ListInit *Result = new ListInit(LHSl->begin()+1, LHSl->end(), - LHSl->getType()); + const ListInit *Result = ListInit::Create(LHSl->begin()+1, LHSl->end(), + LHSl->getType()); return Result; } break; } case EMPTY: { - ListInit *LHSl = dynamic_cast(LHS); + const ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { - return new IntInit(1); + return IntInit::Create(1); } else { - return new IntInit(0); + return IntInit::Create(0); } } - StringInit *LHSs = dynamic_cast(LHS); + const StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { if (LHSs->getValue().empty()) { - return new IntInit(1); + return IntInit::Create(1); } else { - return new IntInit(0); + return IntInit::Create(0); } } @@ -632,11 +766,12 @@ return this; } -Init *UnOpInit::resolveReferences(Record &R, const RecordVal *RV) { - Init *lhs = LHS->resolveReferences(R, RV); +const Init *UnOpInit::resolveReferences(Record &R, + const RecordVal *RV) const { + const Init *lhs = LHS->resolveReferences(R, RV); if (LHS != lhs) - return (new UnOpInit(getOpcode(), lhs, getType()))->Fold(&R, 0); + return (UnOpInit::Create(getOpcode(), lhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -651,18 +786,37 @@ return Result + "(" + LHS->getAsString() + ")"; } -Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { +const BinOpInit *BinOpInit::Create(BinaryOp opc, const Init *lhs, + const Init *rhs, RecTy *Type) { + FoldingSetNodeID ID; + ID.AddInteger(initBinOp); + ID.AddInteger(opc); + ID.AddString(Type->getAsString()); + ID.AddPointer(lhs); + ID.AddPointer(rhs); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + BinOpInit *I = InitAllocator.Allocate(); + new (I) BinOpInit(ID, opc, lhs, rhs, Type); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { switch (getOpcode()) { default: assert(0 && "Unknown binop"); case CONCAT: { - DagInit *LHSs = dynamic_cast(LHS); - DagInit *RHSs = dynamic_cast(RHS); + const DagInit *LHSs = dynamic_cast(LHS); + const DagInit *RHSs = dynamic_cast(RHS); if (LHSs && RHSs) { - DefInit *LOp = dynamic_cast(LHSs->getOperator()); - DefInit *ROp = dynamic_cast(RHSs->getOperator()); + const DefInit *LOp = dynamic_cast(LHSs->getOperator()); + const DefInit *ROp = dynamic_cast(RHSs->getOperator()); if (LOp == 0 || ROp == 0 || LOp->getDef() != ROp->getDef()) throw "Concated Dag operators do not match!"; - std::vector Args; + std::vector Args; std::vector ArgNames; for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) { Args.push_back(LHSs->getArg(i)); @@ -672,42 +826,42 @@ Args.push_back(RHSs->getArg(i)); ArgNames.push_back(RHSs->getArgName(i)); } - return new DagInit(LHSs->getOperator(), "", Args, ArgNames); + return DagInit::Create(LHSs->getOperator(), "", Args, ArgNames); } break; } case STRCONCAT: { - StringInit *LHSs = dynamic_cast(LHS); - StringInit *RHSs = dynamic_cast(RHS); + const StringInit *LHSs = dynamic_cast(LHS); + const StringInit *RHSs = dynamic_cast(RHS); if (LHSs && RHSs) - return new StringInit(LHSs->getValue() + RHSs->getValue()); + return StringInit::Create(LHSs->getValue() + RHSs->getValue()); break; } case EQ: { // try to fold eq comparison for 'bit' and 'int', otherwise fallback // to string objects. - IntInit* L = - dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); - IntInit* R = - dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); + const IntInit* L = + dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); + const IntInit* R = + dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); if (L && R) - return new IntInit(L->getValue() == R->getValue()); + return IntInit::Create(L->getValue() == R->getValue()); - StringInit *LHSs = dynamic_cast(LHS); - StringInit *RHSs = dynamic_cast(RHS); + const StringInit *LHSs = dynamic_cast(LHS); + const StringInit *RHSs = dynamic_cast(RHS); // Make sure we've resolved if (LHSs && RHSs) - return new IntInit(LHSs->getValue() == RHSs->getValue()); + return IntInit::Create(LHSs->getValue() == RHSs->getValue()); break; } case SHL: case SRA: case SRL: { - IntInit *LHSi = dynamic_cast(LHS); - IntInit *RHSi = dynamic_cast(RHS); + const IntInit *LHSi = dynamic_cast(LHS); + const IntInit *RHSi = dynamic_cast(RHS); if (LHSi && RHSi) { int64_t LHSv = LHSi->getValue(), RHSv = RHSi->getValue(); int64_t Result; @@ -717,7 +871,7 @@ case SRA: Result = LHSv >> RHSv; break; case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; } - return new IntInit(Result); + return IntInit::Create(Result); } break; } @@ -725,12 +879,13 @@ return this; } -Init *BinOpInit::resolveReferences(Record &R, const RecordVal *RV) { - Init *lhs = LHS->resolveReferences(R, RV); - Init *rhs = RHS->resolveReferences(R, RV); +const Init *BinOpInit::resolveReferences(Record &R, + const RecordVal *RV) const { + const Init *lhs = LHS->resolveReferences(R, RV); + const Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || RHS != rhs) - return (new BinOpInit(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); + return (BinOpInit::Create(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -747,20 +902,43 @@ return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; } -static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, - Record *CurRec, MultiClass *CurMultiClass); - -static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, - RecTy *Type, Record *CurRec, - MultiClass *CurMultiClass) { - std::vector NewOperands; +const TernOpInit *TernOpInit::Create(TernaryOp opc, const Init *lhs, + const Init *mhs, const Init *rhs, + RecTy *Type) { + FoldingSetNodeID ID; + ID.AddInteger(initTernOp); + ID.AddInteger(opc); + ID.AddString(Type->getAsString()); + ID.AddPointer(lhs); + ID.AddPointer(mhs); + ID.AddPointer(rhs); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + TernOpInit *I = InitAllocator.Allocate(); + new (I) TernOpInit(ID, opc, lhs, mhs, rhs, Type); + UniqueInits.InsertNode(I, IP); + return I; +} + +static const Init *ForeachHelper(const Init *LHS, const Init *MHS, + const Init *RHS, RecTy *Type, + Record *CurRec, MultiClass *CurMultiClass); + +static const Init *EvaluateOperation(const OpInit *RHSo, const Init *LHS, + const Init *Arg, RecTy *Type, + Record *CurRec, + MultiClass *CurMultiClass) { + std::vector NewOperands; - TypedInit *TArg = dynamic_cast(Arg); + const TypedInit *TArg = dynamic_cast(Arg); // If this is a dag, recurse if (TArg && TArg->getType()->getAsString() == "dag") { - Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, - CurRec, CurMultiClass); + const Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, + CurRec, CurMultiClass); if (Result != 0) { return Result; } else { @@ -768,18 +946,21 @@ } } + bool change = false; for (int i = 0; i < RHSo->getNumOperands(); ++i) { - OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); + const OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); if (RHSoo) { - Init *Result = EvaluateOperation(RHSoo, LHS, Arg, - Type, CurRec, CurMultiClass); + const Init *Result = EvaluateOperation(RHSoo, LHS, Arg, + Type, CurRec, CurMultiClass); if (Result != 0) { + change = true; NewOperands.push_back(Result); } else { NewOperands.push_back(Arg); } } else if (LHS->getAsString() == RHSo->getOperand(i)->getAsString()) { + change = true; NewOperands.push_back(Arg); } else { NewOperands.push_back(RHSo->getOperand(i)); @@ -787,30 +968,31 @@ } // Now run the operator and use its result as the new leaf - OpInit *NewOp = RHSo->clone(NewOperands); - Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); - if (NewVal != NewOp) { - delete NewOp; + const OpInit *NewOp = RHSo->clone(NewOperands); + const Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); + + if (change) { return NewVal; } return 0; } -static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, - Record *CurRec, MultiClass *CurMultiClass) { - DagInit *MHSd = dynamic_cast(MHS); - ListInit *MHSl = dynamic_cast(MHS); +static const Init *ForeachHelper(const Init *LHS, const Init *MHS, + const Init *RHS, RecTy *Type, + Record *CurRec, MultiClass *CurMultiClass) { + const DagInit *MHSd = dynamic_cast(MHS); + const ListInit *MHSl = dynamic_cast(MHS); DagRecTy *DagType = dynamic_cast(Type); ListRecTy *ListType = dynamic_cast(Type); - OpInit *RHSo = dynamic_cast(RHS); + const OpInit *RHSo = dynamic_cast(RHS); if (!RHSo) { throw TGError(CurRec->getLoc(), "!foreach requires an operator\n"); } - TypedInit *LHSt = dynamic_cast(LHS); + const TypedInit *LHSt = dynamic_cast(LHS); if (!LHSt) { throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n"); @@ -818,23 +1000,23 @@ if ((MHSd && DagType) || (MHSl && ListType)) { if (MHSd) { - Init *Val = MHSd->getOperator(); - Init *Result = EvaluateOperation(RHSo, LHS, Val, - Type, CurRec, CurMultiClass); + const Init *Val = MHSd->getOperator(); + const Init *Result = EvaluateOperation(RHSo, LHS, Val, + Type, CurRec, CurMultiClass); if (Result != 0) { Val = Result; } - std::vector > args; + std::vector > args; for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) { - Init *Arg; + const Init *Arg; std::string ArgName; Arg = MHSd->getArg(i); ArgName = MHSd->getArgName(i); // Process args - Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, - CurRec, CurMultiClass); + const Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, + CurRec, CurMultiClass); if (Result != 0) { Arg = Result; } @@ -843,17 +1025,17 @@ args.push_back(std::make_pair(Arg, ArgName)); } - return new DagInit(Val, "", args); + return DagInit::Create(Val, "", args); } if (MHSl) { - std::vector NewOperands; - std::vector NewList(MHSl->begin(), MHSl->end()); + std::vector NewOperands; + std::vector NewList(MHSl->begin(), MHSl->end()); - for (ListInit::iterator li = NewList.begin(), + for (std::vector::iterator li = NewList.begin(), liend = NewList.end(); li != liend; ++li) { - Init *Item = *li; + const Init *Item = *li; NewOperands.clear(); for(int i = 0; i < RHSo->getNumOperands(); ++i) { // First, replace the foreach variable with the list item @@ -865,34 +1047,33 @@ } // Now run the operator and use its result as the new list item - OpInit *NewOp = RHSo->clone(NewOperands); - Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); + const OpInit *NewOp = RHSo->clone(NewOperands); + const Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); if (NewItem != NewOp) { *li = NewItem; - delete NewOp; } } - return new ListInit(NewList, MHSl->getType()); + return ListInit::Create(NewList, MHSl->getType()); } } return 0; } -Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { +const Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { switch (getOpcode()) { default: assert(0 && "Unknown binop"); case SUBST: { - DefInit *LHSd = dynamic_cast(LHS); - VarInit *LHSv = dynamic_cast(LHS); - StringInit *LHSs = dynamic_cast(LHS); - - DefInit *MHSd = dynamic_cast(MHS); - VarInit *MHSv = dynamic_cast(MHS); - StringInit *MHSs = dynamic_cast(MHS); - - DefInit *RHSd = dynamic_cast(RHS); - VarInit *RHSv = dynamic_cast(RHS); - StringInit *RHSs = dynamic_cast(RHS); + const DefInit *LHSd = dynamic_cast(LHS); + const VarInit *LHSv = dynamic_cast(LHS); + const StringInit *LHSs = dynamic_cast(LHS); + + const DefInit *MHSd = dynamic_cast(MHS); + const VarInit *MHSv = dynamic_cast(MHS); + const StringInit *MHSs = dynamic_cast(MHS); + + const DefInit *RHSd = dynamic_cast(RHS); + const VarInit *RHSv = dynamic_cast(RHS); + const StringInit *RHSs = dynamic_cast(RHS); if ((LHSd && MHSd && RHSd) || (LHSv && MHSv && RHSv) @@ -902,14 +1083,14 @@ if (LHSd->getAsString() == RHSd->getAsString()) { Val = MHSd->getDef(); } - return new DefInit(Val); + return DefInit::Create(Val); } if (RHSv) { std::string Val = RHSv->getName(); if (LHSv->getAsString() == RHSv->getAsString()) { Val = MHSv->getName(); } - return new VarInit(Val, getType()); + return VarInit::Create(Val, getType()); } if (RHSs) { std::string Val = RHSs->getValue(); @@ -924,14 +1105,14 @@ idx = found + MHSs->getValue().size(); } while (found != std::string::npos); - return new StringInit(Val); + return StringInit::Create(Val); } } break; } case FOREACH: { - Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), + const Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), CurRec, CurMultiClass); if (Result != 0) { return Result; @@ -940,9 +1121,9 @@ } case IF: { - IntInit *LHSi = dynamic_cast(LHS); - if (Init *I = LHS->convertInitializerTo(new IntRecTy())) - LHSi = dynamic_cast(I); + const IntInit *LHSi = dynamic_cast(LHS); + if (const Init *I = LHS->convertInitializerTo(new IntRecTy())) + LHSi = dynamic_cast(I); if (LHSi) { if (LHSi->getValue()) { return MHS; @@ -957,32 +1138,35 @@ return this; } -Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) { - Init *lhs = LHS->resolveReferences(R, RV); +const Init * +TernOpInit::resolveReferences(Record &R, + const RecordVal *RV) const { + const Init *lhs = LHS->resolveReferences(R, RV); if (Opc == IF && lhs != LHS) { - IntInit *Value = dynamic_cast(lhs); - if (Init *I = lhs->convertInitializerTo(new IntRecTy())) - Value = dynamic_cast(I); + const IntInit *Value = dynamic_cast(lhs); + if (const Init *I = lhs->convertInitializerTo(new IntRecTy())) + Value = dynamic_cast(I); if (Value != 0) { // Short-circuit if (Value->getValue()) { - Init *mhs = MHS->resolveReferences(R, RV); - return (new TernOpInit(getOpcode(), lhs, mhs, - RHS, getType()))->Fold(&R, 0); + const Init *mhs = MHS->resolveReferences(R, RV); + return (TernOpInit::Create(getOpcode(), lhs, mhs, + RHS, getType()))->Fold(&R, 0); } else { - Init *rhs = RHS->resolveReferences(R, RV); - return (new TernOpInit(getOpcode(), lhs, MHS, - rhs, getType()))->Fold(&R, 0); + const Init *rhs = RHS->resolveReferences(R, RV); + return (TernOpInit::Create(getOpcode(), lhs, MHS, + rhs, getType()))->Fold(&R, 0); } } } - Init *mhs = MHS->resolveReferences(R, RV); - Init *rhs = RHS->resolveReferences(R, RV); + const Init *mhs = MHS->resolveReferences(R, RV); + const Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || MHS != mhs || RHS != rhs) - return (new TernOpInit(getOpcode(), lhs, mhs, rhs, getType()))->Fold(&R, 0); + return (TernOpInit::Create(getOpcode(), lhs, mhs, rhs, getType()))-> + Fold(&R, 0); return Fold(&R, 0); } @@ -1008,79 +1192,97 @@ return 0; } -Init *TypedInit::convertInitializerBitRange(const std::vector &Bits) { +const Init * +TypedInit::convertInitializerBitRange(const std::vector &Bits) const { BitsRecTy *T = dynamic_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-bits variable. unsigned NumBits = T->getNumBits(); - BitsInit *BI = new BitsInit(Bits.size()); + SmallVector NewBits(Bits.size()); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { if (Bits[i] >= NumBits) { - delete BI; return 0; } - BI->setBit(i, new VarBitInit(this, Bits[i])); + NewBits[i] = VarBitInit::Create(this, Bits[i]); } - return BI; + return BitsInit::Create(NewBits.begin(), NewBits.end()); } -Init *TypedInit::convertInitListSlice(const std::vector &Elements) { +const Init * +TypedInit::convertInitListSlice(const std::vector &Elements) const { ListRecTy *T = dynamic_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-list variable. if (Elements.size() == 1) - return new VarListElementInit(this, Elements[0]); + return VarListElementInit::Create(this, Elements[0]); - std::vector ListInits; + std::vector ListInits; ListInits.reserve(Elements.size()); for (unsigned i = 0, e = Elements.size(); i != e; ++i) - ListInits.push_back(new VarListElementInit(this, Elements[i])); - return new ListInit(ListInits, T); + ListInits.push_back(VarListElementInit::Create(this, Elements[i])); + return ListInit::Create(ListInits, T); } -Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, - unsigned Bit) { +const VarInit *VarInit::Create(const std::string &VN, RecTy *T) { + FoldingSetNodeID ID; + ID.AddInteger(initVar); + ID.AddString(VN); + ID.AddString(T->getAsString()); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + VarInit *I = InitAllocator.Allocate(); + new (I) VarInit(ID, VN, T); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, + unsigned Bit) const { if (R.isTemplateArg(getName())) return 0; if (IRV && IRV->getName() != getName()) return 0; RecordVal *RV = R.getValue(getName()); assert(RV && "Reference to a non-existent variable?"); - assert(dynamic_cast(RV->getValue())); - BitsInit *BI = (BitsInit*)RV->getValue(); + assert(dynamic_cast(RV->getValue())); + const BitsInit *BI = (const BitsInit*)RV->getValue(); assert(Bit < BI->getNumBits() && "Bit reference out of range!"); - Init *B = BI->getBit(Bit); + const Init *B = BI->getBit(Bit); // If the bit is set to some value, or if we are resolving a reference to a // specific variable and that variable is explicitly unset, then replace the // VarBitInit with it. - if (IRV || !dynamic_cast(B)) + if (IRV || !dynamic_cast(B)) return B; return 0; } -Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV, - unsigned Elt) { +const Init *VarInit::resolveListElementReference(Record &R, + const RecordVal *IRV, + unsigned Elt) const { if (R.isTemplateArg(getName())) return 0; if (IRV && IRV->getName() != getName()) return 0; RecordVal *RV = R.getValue(getName()); assert(RV && "Reference to a non-existent variable?"); - ListInit *LI = dynamic_cast(RV->getValue()); + const ListInit *LI = dynamic_cast(RV->getValue()); if (!LI) { - VarInit *VI = dynamic_cast(RV->getValue()); + const VarInit *VI = dynamic_cast(RV->getValue()); assert(VI && "Invalid list element!"); - return new VarListElementInit(VI, Elt); + return VarListElementInit::Create(VI, Elt); } if (Elt >= LI->getSize()) return 0; // Out of range reference. - Init *E = LI->getElement(Elt); + const Init *E = LI->getElement(Elt); // If the element is set to some value, or if we are resolving a reference // to a specific variable and that variable is explicitly unset, then // replace the VarListElementInit with it. - if (IRV || !dynamic_cast(E)) + if (IRV || !dynamic_cast(E)) return E; return 0; } @@ -1093,15 +1295,15 @@ return 0; } -Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { +const Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { if (dynamic_cast(getType())) if (const RecordVal *Val = R.getValue(VarName)) { - if (RV != Val && (RV || dynamic_cast(Val->getValue()))) + if (RV != Val && (RV || dynamic_cast(Val->getValue()))) return 0; - Init *TheInit = Val->getValue(); + const Init *TheInit = Val->getValue(); assert(TheInit != this && "Infinite loop detected!"); - if (Init *I = TheInit->getFieldInit(R, RV, FieldName)) + if (const Init *I = TheInit->getFieldInit(R, RV, FieldName)) return I; else return 0; @@ -1114,56 +1316,112 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// -Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) { +const Init *VarInit::resolveReferences(Record &R, + const RecordVal *RV) const { if (RecordVal *Val = R.getValue(VarName)) - if (RV == Val || (RV == 0 && !dynamic_cast(Val->getValue()))) + if (RV == Val || (RV == 0 + && !dynamic_cast(Val->getValue()))) return Val->getValue(); return this; } +const VarBitInit *VarBitInit::Create(const TypedInit *T, unsigned B) { + FoldingSetNodeID ID; + ID.AddInteger(initVarBit); + ID.AddPointer(T); + ID.AddInteger(B); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + VarBitInit *I = InitAllocator.Allocate(); + new (I) VarBitInit(ID, T, B); + UniqueInits.InsertNode(I, IP); + return I; +} + std::string VarBitInit::getAsString() const { return TI->getAsString() + "{" + utostr(Bit) + "}"; } -Init *VarBitInit::resolveReferences(Record &R, const RecordVal *RV) { - if (Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) +const Init * +VarBitInit::resolveReferences(Record &R, + const RecordVal *RV) const { + if (const Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) return I; return this; } +const VarListElementInit *VarListElementInit::Create(const TypedInit *T, + unsigned E) { + FoldingSetNodeID ID; + ID.AddInteger(initVarListElement); + ID.AddPointer(T); + ID.AddInteger(E); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + VarListElementInit *I = InitAllocator.Allocate(); + new (I) VarListElementInit(ID, T, E); + UniqueInits.InsertNode(I, IP); + return I; +} + std::string VarListElementInit::getAsString() const { return TI->getAsString() + "[" + utostr(Element) + "]"; } -Init *VarListElementInit::resolveReferences(Record &R, const RecordVal *RV) { - if (Init *I = getVariable()->resolveListElementReference(R, RV, - getElementNum())) +const Init *VarListElementInit::resolveReferences(Record &R, + const RecordVal *RV) const { + if (const Init *I = + getVariable()->resolveListElementReference(R, RV, getElementNum())) return I; return this; } -Init *VarListElementInit::resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { +const Init *VarListElementInit::resolveBitReference(Record &R, + const RecordVal *RV, + unsigned Bit) const { // FIXME: This should be implemented, to support references like: // bit B = AA[0]{1}; return 0; } -Init *VarListElementInit:: -resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) { +const Init * +VarListElementInit::resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { // FIXME: This should be implemented, to support references like: // int B = AA[0][1]; return 0; } +const DefInit *DefInit::Create(Record *D) { + FoldingSetNodeID ID; + ID.AddInteger(initDef); + ID.AddString(D->getName()); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + DefInit *I = InitAllocator.Allocate(); + new (I) DefInit(ID, D); + UniqueInits.InsertNode(I, IP); + return I; +} + RecTy *DefInit::getFieldType(const std::string &FieldName) const { if (const RecordVal *RV = Def->getValue(FieldName)) return RV->getType(); return 0; } -Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { +const Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { return Def->getValue(FieldName)->getValue(); } @@ -1172,59 +1430,134 @@ return Def->getName(); } -Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { - if (Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) - if (BitsInit *BI = dynamic_cast(BitsVal)) { +const FieldInit *FieldInit::Create(const Init *R, const std::string &FN) { + FoldingSetNodeID ID; + ID.AddInteger(initField); + ID.AddPointer(R); + ID.AddString(FN); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + FieldInit *I = InitAllocator.Allocate(); + new (I) FieldInit(ID, R, FN); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { + if (const Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) + if (const BitsInit *BI = dynamic_cast(BitsVal)) { assert(Bit < BI->getNumBits() && "Bit reference out of range!"); - Init *B = BI->getBit(Bit); + const Init *B = BI->getBit(Bit); - if (dynamic_cast(B)) // If the bit is set. + if (dynamic_cast(B)) // If the bit is set. return B; // Replace the VarBitInit with it. } return 0; } -Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) { - if (Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) - if (ListInit *LI = dynamic_cast(ListVal)) { +const Init *FieldInit::resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { + if (const Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) + if (const ListInit *LI = dynamic_cast(ListVal)) { if (Elt >= LI->getSize()) return 0; - Init *E = LI->getElement(Elt); + const Init *E = LI->getElement(Elt); // If the element is set to some value, or if we are resolving a // reference to a specific variable and that variable is explicitly // unset, then replace the VarListElementInit with it. - if (RV || !dynamic_cast(E)) + if (RV || !dynamic_cast(E)) return E; } return 0; } -Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) { - Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; +const Init *FieldInit::resolveReferences(Record &R, + const RecordVal *RV) const { + const Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; - Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); + const Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); if (BitsVal) { - Init *BVR = BitsVal->resolveReferences(R, RV); + const Init *BVR = BitsVal->resolveReferences(R, RV); return BVR->isComplete() ? BVR : this; } if (NewRec != Rec) { - return new FieldInit(NewRec, FieldName); + return FieldInit::Create(NewRec, FieldName); } return this; } -Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) { - std::vector NewArgs; +const DagInit * +DagInit::Create(const Init *V, const std::string &VN, + const std::vector > &args) { + FoldingSetNodeID ID; + ID.AddInteger(initDag); + ID.AddPointer(V); + ID.AddString(VN); + + for (std::vector >::const_iterator a + = args.begin(), + aend = args.end(); + a != aend; + ++a) { + ID.AddPointer(a->first); + ID.AddString(a->second); + } + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + DagInit *I = InitAllocator.Allocate(); + new (I) DagInit(ID, V, VN, args); + UniqueInits.InsertNode(I, IP); + return I; +} + +const DagInit * +DagInit::Create(const Init *V, const std::string &VN, + const std::vector &args, + const std::vector &argNames) { + FoldingSetNodeID ID; + ID.AddInteger(initDag); + ID.AddPointer(V); + ID.AddString(VN); + + std::vector::const_iterator s = argNames.begin(); + for (std::vector::const_iterator a + = args.begin(), + aend = args.end(); + a != aend; + ++a, ++s) { + ID.AddPointer(*a); + ID.AddString(*s); + } + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + DagInit *I = InitAllocator.Allocate(); + new (I) DagInit(ID, V, VN, args, argNames); + UniqueInits.InsertNode(I, IP); + return I; +} + +const Init *DagInit::resolveReferences(Record &R, + const RecordVal *RV) const { + std::vector NewArgs; for (unsigned i = 0, e = Args.size(); i != e; ++i) NewArgs.push_back(Args[i]->resolveReferences(R, RV)); - Init *Op = Val->resolveReferences(R, RV); + const Init *Op = Val->resolveReferences(R, RV); if (Args != NewArgs || Op != Val) - return new DagInit(Op, ValName, NewArgs, ArgNames); + return DagInit::Create(Op, ValName, NewArgs, ArgNames); return this; } @@ -1252,7 +1585,7 @@ RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P) : Name(N), Ty(T), Prefix(P) { - Value = Ty->convertValue(new UnsetInit()); + Value = Ty->convertValue(UnsetInit::Create()); assert(Value && "Cannot create unset value for current type!"); } @@ -1287,7 +1620,7 @@ /// references. void Record::resolveReferencesTo(const RecordVal *RV) { for (unsigned i = 0, e = Values.size(); i != e; ++i) { - if (Init *V = Values[i].getValue()) + if (const Init *V = Values[i].getValue()) Values[i].setValue(V->resolveReferences(*this, RV)); } } @@ -1332,7 +1665,7 @@ /// getValueInit - Return the initializer for a value with the specified name, /// or throw an exception if the field does not exist. /// -Init *Record::getValueInit(StringRef FieldName) const { +const Init *Record::getValueInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + @@ -1361,13 +1694,13 @@ /// its value as a BitsInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// -BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { +const BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (BitsInit *BI = dynamic_cast(R->getValue())) + if (const BitsInit *BI = dynamic_cast(R->getValue())) return BI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a BitsInit initializer!"; @@ -1377,13 +1710,13 @@ /// its value as a ListInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// -ListInit *Record::getValueAsListInit(StringRef FieldName) const { +const ListInit *Record::getValueAsListInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (ListInit *LI = dynamic_cast(R->getValue())) + if (const ListInit *LI = dynamic_cast(R->getValue())) return LI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a list initializer!"; @@ -1395,10 +1728,10 @@ /// std::vector Record::getValueAsListOfDefs(StringRef FieldName) const { - ListInit *List = getValueAsListInit(FieldName); + const ListInit *List = getValueAsListInit(FieldName); std::vector Defs; for (unsigned i = 0; i < List->getSize(); i++) { - if (DefInit *DI = dynamic_cast(List->getElement(i))) { + if (const DefInit *DI = dynamic_cast(List->getElement(i))) { Defs.push_back(DI->getDef()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1418,7 +1751,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (IntInit *II = dynamic_cast(R->getValue())) + if (const IntInit *II = dynamic_cast(R->getValue())) return II->getValue(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have an int initializer!"; @@ -1430,10 +1763,10 @@ /// std::vector Record::getValueAsListOfInts(StringRef FieldName) const { - ListInit *List = getValueAsListInit(FieldName); + const ListInit *List = getValueAsListInit(FieldName); std::vector Ints; for (unsigned i = 0; i < List->getSize(); i++) { - if (IntInit *II = dynamic_cast(List->getElement(i))) { + if (const IntInit *II = dynamic_cast(List->getElement(i))) { Ints.push_back(II->getValue()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1449,10 +1782,11 @@ /// std::vector Record::getValueAsListOfStrings(StringRef FieldName) const { - ListInit *List = getValueAsListInit(FieldName); + const ListInit *List = getValueAsListInit(FieldName); std::vector Strings; for (unsigned i = 0; i < List->getSize(); i++) { - if (StringInit *II = dynamic_cast(List->getElement(i))) { + if (const StringInit *II = + dynamic_cast(List->getElement(i))) { Strings.push_back(II->getValue()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1472,7 +1806,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (DefInit *DI = dynamic_cast(R->getValue())) + if (const DefInit *DI = dynamic_cast(R->getValue())) return DI->getDef(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a def initializer!"; @@ -1488,7 +1822,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (BitInit *BI = dynamic_cast(R->getValue())) + if (const BitInit *BI = dynamic_cast(R->getValue())) return BI->getValue(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a bit initializer!"; @@ -1498,13 +1832,13 @@ /// value as an Dag, throwing an exception if the field does not exist or if /// the value is not the right type. /// -DagInit *Record::getValueAsDag(StringRef FieldName) const { +const DagInit *Record::getValueAsDag(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (DagInit *DI = dynamic_cast(R->getValue())) + if (const DagInit *DI = dynamic_cast(R->getValue())) return DI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a dag initializer!"; Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Mon Jul 11 13:25:51 2011 @@ -15,6 +15,8 @@ #ifndef RECORD_H #define RECORD_H +#include "llvm/ADT/FoldingSet.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/raw_ostream.h" @@ -75,31 +77,31 @@ virtual bool typeIsConvertibleTo(const RecTy *RHS) const = 0; public: // These methods should only be called from subclasses of Init - virtual Init *convertValue( UnsetInit *UI) { return 0; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { - return convertValue((TypedInit*)UI); - } - virtual Init *convertValue( BinOpInit *UI) { - return convertValue((TypedInit*)UI); - } - virtual Init *convertValue( TernOpInit *UI) { - return convertValue((TypedInit*)UI); - } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( TypedInit *TI) { return 0; } - virtual Init *convertValue( VarInit *VI) { - return convertValue((TypedInit*)VI); + virtual const Init *convertValue(const UnsetInit *UI) { return 0; } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return convertValue((const TypedInit*)UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return convertValue((const TypedInit*)UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return convertValue((const TypedInit*)UI); + } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const TypedInit *TI) { return 0; } + virtual const Init *convertValue(const VarInit *VI) { + return convertValue((const TypedInit*)VI); } - virtual Init *convertValue( FieldInit *FI) { - return convertValue((TypedInit*)FI); + virtual const Init *convertValue(const FieldInit *FI) { + return convertValue((const TypedInit*)FI); } public: // These methods should only be called by subclasses of RecTy. @@ -125,22 +127,38 @@ /// class BitRecTy : public RecTy { public: - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return (Init*)BI; } - virtual Init *convertValue( BitsInit *BI); - virtual Init *convertValue( IntInit *II); - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return (Init*)VB; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { + return (const Init*)BI; + } + virtual const Init *convertValue(const BitsInit *BI); + virtual const Init *convertValue(const IntInit *II); + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { + return (const Init*)VB; + } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const { return "bit"; } @@ -169,22 +187,32 @@ unsigned getNumBits() const { return Size; } - virtual Init *convertValue( UnsetInit *UI); - virtual Init *convertValue( BitInit *UI); - virtual Init *convertValue( BitsInit *BI); - virtual Init *convertValue( IntInit *II); - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI); + virtual const Init *convertValue(const BitInit *UI); + virtual const Init *convertValue(const BitsInit *BI); + virtual const Init *convertValue(const IntInit *II); + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const; @@ -209,22 +237,36 @@ /// class IntRecTy : public RecTy { public: - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI); - virtual Init *convertValue( BitsInit *BI); - virtual Init *convertValue( IntInit *II) { return (Init*)II; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI); + virtual const Init *convertValue(const BitsInit *BI); + virtual const Init *convertValue(const IntInit *II) { + return (const Init*)II; + } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const { return "int"; } @@ -247,23 +289,33 @@ /// class StringRecTy : public RecTy { public: - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return (Init*)SI; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( UnOpInit *BO); - virtual Init *convertValue( BinOpInit *BO); - virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} - - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { + return (const Init*)SI; + } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const UnOpInit *BO); + virtual const Init *convertValue(const BinOpInit *BO); + virtual const Init *convertValue(const TernOpInit *BO) { + return RecTy::convertValue(BO); + } + + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const { return "string"; } @@ -293,22 +345,34 @@ RecTy *getElementType() const { return Ty; } - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI); - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI); + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const; @@ -332,22 +396,36 @@ /// class CodeRecTy : public RecTy { public: - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return (Init*)CI; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { + return (const Init*)CI; + } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const { return "code"; } @@ -368,22 +446,32 @@ /// class DagRecTy : public RecTy { public: - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( DefInit *DI) { return 0; } - virtual Init *convertValue( UnOpInit *BO); - virtual Init *convertValue( BinOpInit *BO); - virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} - virtual Init *convertValue( DagInit *CI) { return (Init*)CI; } - virtual Init *convertValue( TypedInit *TI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const DefInit *DI) { return 0; } + virtual const Init *convertValue(const UnOpInit *BO); + virtual const Init *convertValue(const BinOpInit *BO); + virtual const Init *convertValue(const TernOpInit *BO) { + return RecTy::convertValue(BO); + } + virtual const Init *convertValue(const DagInit *CI) { + return (const Init*)CI; + } + virtual const Init *convertValue(const TypedInit *TI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const { return "dag"; } @@ -412,22 +500,34 @@ Record *getRecord() const { return Rec; } - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } - virtual Init *convertValue( BitInit *BI) { return 0; } - virtual Init *convertValue( BitsInit *BI) { return 0; } - virtual Init *convertValue( IntInit *II) { return 0; } - virtual Init *convertValue(StringInit *SI) { return 0; } - virtual Init *convertValue( ListInit *LI) { return 0; } - virtual Init *convertValue( CodeInit *CI) { return 0; } - virtual Init *convertValue(VarBitInit *VB) { return 0; } - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} - virtual Init *convertValue( DefInit *DI); - virtual Init *convertValue( DagInit *DI) { return 0; } - virtual Init *convertValue( TypedInit *VI); - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} + virtual const Init *convertValue(const UnsetInit *UI) { + return (const Init*)UI; + } + virtual const Init *convertValue(const BitInit *BI) { return 0; } + virtual const Init *convertValue(const BitsInit *BI) { return 0; } + virtual const Init *convertValue(const IntInit *II) { return 0; } + virtual const Init *convertValue(const StringInit *SI) { return 0; } + virtual const Init *convertValue(const ListInit *LI) { return 0; } + virtual const Init *convertValue(const CodeInit *CI) { return 0; } + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } + virtual const Init *convertValue(const UnOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const BinOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const TernOpInit *UI) { + return RecTy::convertValue(UI); + } + virtual const Init *convertValue(const DefInit *DI); + virtual const Init *convertValue(const DagInit *DI) { return 0; } + virtual const Init *convertValue(const TypedInit *VI); + virtual const Init *convertValue(const VarInit *VI) { + return RecTy::convertValue(VI); + } + virtual const Init *convertValue(const FieldInit *FI) { + return RecTy::convertValue(FI); + } std::string getAsString() const; @@ -453,9 +553,43 @@ // Initializer Classes //===----------------------------------------------------------------------===// -struct Init { +class Init : public FastFoldingSetNode { + Init(const Init &); // Do not define. + Init &operator=(const Init &); // Do not define. + +protected: + Init(const FoldingSetNodeID &ID) : FastFoldingSetNode(ID) {} + + static FoldingSet UniqueInits; + static BumpPtrAllocator InitAllocator; + + enum Type { + initUnset, + initBit, + initBits, + initInt, + initString, + initCode, + initList, + initUnOp, + initBinOp, + initTernOp, + initQuadOp, + initVar, + initVarBit, + initVarListElement, + initDef, + initField, + initDag + }; + +public: virtual ~Init() {} + static void ReleaseMemory() { + InitAllocator.Reset(); + } + /// isComplete - This virtual method should be overridden by values that may /// not be completely specified yet. virtual bool isComplete() const { return true; } @@ -474,14 +608,15 @@ /// function that should be overridden to call the appropriate /// RecTy::convertValue method. /// - virtual Init *convertInitializerTo(RecTy *Ty) = 0; + virtual const Init *convertInitializerTo(RecTy *Ty) const = 0; /// convertInitializerBitRange - This method is used to implement the bitrange /// selection operator. Given an initializer, it selects the specified bits /// out, returning them as a new init of bits type. If it is not legal to use /// the bit subscript operator on this initializer, return null. /// - virtual Init *convertInitializerBitRange(const std::vector &Bits) { + virtual const Init * + convertInitializerBitRange(const std::vector &Bits) const { return 0; } @@ -490,7 +625,8 @@ /// elements, returning them as a new init of list type. If it is not legal /// to take a slice of this, return null. /// - virtual Init *convertInitListSlice(const std::vector &Elements) { + virtual const Init * + convertInitListSlice(const std::vector &Elements) const { return 0; } @@ -504,8 +640,8 @@ /// initializer for the specified field. If getFieldType returns non-null /// this method should return non-null, otherwise it returns null. /// - virtual Init *getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { return 0; } @@ -514,7 +650,8 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual Init *resolveReferences(Record &R, const RecordVal *RV) { + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const { return this; } }; @@ -528,13 +665,20 @@ /// class TypedInit : public Init { RecTy *Ty; -public: - explicit TypedInit(RecTy *T) : Ty(T) {} + TypedInit(const TypedInit &Other); // Do not define. + TypedInit &operator=(const TypedInit &Other); // Do not define. + +protected: + explicit TypedInit(const FoldingSetNodeID &ID, RecTy *T) : Init(ID), Ty(T) {} + +public: RecTy *getType() const { return Ty; } - virtual Init *convertInitializerBitRange(const std::vector &Bits); - virtual Init *convertInitListSlice(const std::vector &Elements); + virtual const Init * + convertInitializerBitRange(const std::vector &Bits) const; + virtual const Init * + convertInitListSlice(const std::vector &Elements) const; /// getFieldType - This method is used to implement the FieldInit class. /// Implementors of this method should return the type of the named field if @@ -546,22 +690,29 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) = 0; + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const = 0; /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) = 0; + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const = 0; }; /// UnsetInit - ? - Represents an uninitialized value /// class UnsetInit : public Init { + UnsetInit(const FoldingSetNodeID &ID) : Init(ID) {} + UnsetInit(const UnsetInit &); // Do not define. + UnsetInit &operator=(const UnsetInit &Other); // Do not define. + public: - virtual Init *convertInitializerTo(RecTy *Ty) { + static const UnsetInit *Create(); + + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } @@ -574,12 +725,17 @@ /// class BitInit : public Init { bool Value; + + explicit BitInit(const FoldingSetNodeID &ID, bool V) : Init(ID), Value(V) {} + BitInit(const BitInit &Other); // Do not define. + BitInit &operator=(BitInit &Other); // Do not define. + public: - explicit BitInit(bool V) : Value(V) {} + static const BitInit *Create(bool V); bool getValue() const { return Value; } - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } @@ -590,26 +746,56 @@ /// It contains a vector of bits, whose size is determined by the type. /// class BitsInit : public Init { - std::vector Bits; + std::vector Bits; + + BitsInit(const FoldingSetNodeID &ID, unsigned Size) + : Init(ID), Bits(Size) {} + + template + BitsInit(const FoldingSetNodeID &ID, InputIterator start, InputIterator end) + : Init(ID), Bits(start, end) {} + + BitsInit(const BitsInit &Other); // Do not define. + BitsInit &operator=(const BitsInit &Other); // Do not define. + public: - explicit BitsInit(unsigned Size) : Bits(Size) {} + template + static const BitsInit *Create(InputIterator Start, InputIterator End) { + FoldingSetNodeID ID; + ID.AddInteger(initBits); + ID.AddInteger(std::distance(Start, End)); + + InputIterator S = Start; + while (S != End) + ID.AddPointer(*S++); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + BitsInit *I = InitAllocator.Allocate(); + new (I) BitsInit(ID, Start, End); + UniqueInits.InsertNode(I, IP); + return I; + } unsigned getNumBits() const { return Bits.size(); } - Init *getBit(unsigned Bit) const { + const Init *getBit(unsigned Bit) const { assert(Bit < Bits.size() && "Bit index out of range!"); return Bits[Bit]; } - void setBit(unsigned Bit, Init *V) { + void setBit(unsigned Bit, const Init *V) { assert(Bit < Bits.size() && "Bit index out of range!"); assert(Bits[Bit] == 0 && "Bit already set!"); Bits[Bit] = V; } - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - virtual Init *convertInitializerBitRange(const std::vector &Bits); + virtual const Init * + convertInitializerBitRange(const std::vector &Bits) const; virtual bool isComplete() const { for (unsigned i = 0; i != getNumBits(); ++i) @@ -623,7 +809,8 @@ } virtual std::string getAsString() const; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; }; @@ -631,15 +818,23 @@ /// class IntInit : public TypedInit { int64_t Value; + + explicit IntInit(const FoldingSetNodeID &ID, int64_t V) + : TypedInit(ID, new IntRecTy), Value(V) {} + + IntInit(const IntInit &Other); // Do not define. + IntInit &operator=(const IntInit &Other); // Do note define. + public: - explicit IntInit(int64_t V) : TypedInit(new IntRecTy), Value(V) {} + static const IntInit *Create(int64_t V); int64_t getValue() const { return Value; } - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - virtual Init *convertInitializerBitRange(const std::vector &Bits); + virtual const Init * + convertInitializerBitRange(const std::vector &Bits) const; virtual std::string getAsString() const; @@ -647,8 +842,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { assert(0 && "Illegal bit reference off int"); return 0; } @@ -656,8 +851,9 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) { + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { assert(0 && "Illegal element reference off int"); return 0; } @@ -668,13 +864,19 @@ /// class StringInit : public TypedInit { std::string Value; + + explicit StringInit(const FoldingSetNodeID &ID, const std::string &V) + : TypedInit(ID, new StringRecTy), Value(V) {} + + StringInit(const StringInit &Other); // Do not define. + StringInit &operator=(const StringInit &Other); // Do not define. + public: - explicit StringInit(const std::string &V) - : TypedInit(new StringRecTy), Value(V) {} + static const StringInit *Create(const std::string &V); const std::string &getValue() const { return Value; } - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } @@ -684,8 +886,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { assert(0 && "Illegal bit reference off string"); return 0; } @@ -693,8 +895,9 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) { + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { assert(0 && "Illegal element reference off string"); return 0; } @@ -704,12 +907,19 @@ /// class CodeInit : public Init { std::string Value; + + explicit CodeInit(const FoldingSetNodeID &ID, const std::string &V) + : Init(ID), Value(V) {} + + CodeInit(const CodeInit &Other); // Do not define. + CodeInit &operator=(const CodeInit &Other); // Do not define. + public: - explicit CodeInit(const std::string &V) : Value(V) {} + static const CodeInit *Create(const std::string &V); const std::string &getValue() const { return Value; } - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } @@ -719,29 +929,61 @@ /// ListInit - [AL, AH, CL] - Represent a list of defs /// class ListInit : public TypedInit { - std::vector Values; + std::vector Values; + public: - typedef std::vector::iterator iterator; - typedef std::vector::const_iterator const_iterator; + typedef std::vector::const_iterator const_iterator; - explicit ListInit(std::vector &Vs, RecTy *EltTy) - : TypedInit(new ListRecTy(EltTy)) { +private: + ListInit(const FoldingSetNodeID &ID, std::vector &Vs, + RecTy *EltTy) + : TypedInit(ID, new ListRecTy(EltTy)) { Values.swap(Vs); } - explicit ListInit(iterator Start, iterator End, RecTy *EltTy) - : TypedInit(new ListRecTy(EltTy)), Values(Start, End) {} + + template + ListInit(const FoldingSetNodeID &ID, InputIterator Start, InputIterator End, + RecTy *EltTy) + : TypedInit(ID, new ListRecTy(EltTy)), Values(Start, End) {} + + ListInit(const ListInit &Other); // Do not define. + ListInit &operator=(const ListInit &Other); // Do not define. + +public: + static const ListInit *Create(std::vector &Vs, RecTy *EltTy); + + template + static const ListInit *Create(InputIterator Start, InputIterator End, + RecTy *EltTy) { + FoldingSetNodeID ID; + ID.AddInteger(initList); + ID.AddString(EltTy->getAsString()); + + InputIterator S = Start; + while (S != End) + ID.AddPointer(*S++); + + void *IP = 0; + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) + return static_cast(I); + + ListInit *I = InitAllocator.Allocate(); + new (I) ListInit(ID, Start, End, EltTy); + UniqueInits.InsertNode(I, IP); + return I; + } unsigned getSize() const { return Values.size(); } - Init *getElement(unsigned i) const { + const Init *getElement(unsigned i) const { assert(i < Values.size() && "List element index out of range!"); return Values[i]; } Record *getElementAsRecord(unsigned i) const; - Init *convertInitListSlice(const std::vector &Elements); + const Init *convertInitListSlice(const std::vector &Elements) const; - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } @@ -750,13 +992,12 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const; - inline iterator begin() { return Values.begin(); } inline const_iterator begin() const { return Values.begin(); } - inline iterator end () { return Values.end(); } inline const_iterator end () const { return Values.end(); } inline size_t size () const { return Values.size(); } @@ -766,8 +1007,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { assert(0 && "Illegal bit reference off list"); return 0; } @@ -775,35 +1016,42 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt); + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const; }; /// OpInit - Base class for operators /// class OpInit : public TypedInit { -public: - OpInit(RecTy *Type) : TypedInit(Type) {} + OpInit(const OpInit &Other); // Do not define. + OpInit &operator=(OpInit &Other); // Do not define. + +protected: + explicit OpInit(const FoldingSetNodeID &ID, RecTy *Type) + : TypedInit(ID, Type) {} +public: // Clone - Clone this operator, replacing arguments with the new list - virtual OpInit *clone(std::vector &Operands) = 0; + virtual const OpInit *clone(std::vector &Operands) const = 0; virtual int getNumOperands() const = 0; - virtual Init *getOperand(int i) = 0; + virtual const Init *getOperand(int i) const = 0; // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) = 0; + virtual const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0; - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit); - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt); + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const; + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const; }; @@ -814,33 +1062,40 @@ enum UnaryOp { CAST, HEAD, TAIL, EMPTY }; private: UnaryOp Opc; - Init *LHS; + const Init *LHS; + + UnOpInit(const FoldingSetNodeID &ID, UnaryOp opc, const Init *lhs, + RecTy *Type) + : OpInit(ID, Type), Opc(opc), LHS(lhs) {} + + UnOpInit(const UnOpInit &Other); // Do not define. + UnOpInit &operator=(const UnOpInit &Other); // Do not define. + public: - UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type) : - OpInit(Type), Opc(opc), LHS(lhs) { - } + static const UnOpInit *Create(UnaryOp opc, const Init *lhs, RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list - virtual OpInit *clone(std::vector &Operands) { + virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 1 && "Wrong number of operands for unary operation"); - return new UnOpInit(getOpcode(), *Operands.begin(), getType()); + return UnOpInit::Create(getOpcode(), *Operands.begin(), getType()); } int getNumOperands() const { return 1; } - Init *getOperand(int i) { + const Init *getOperand(int i) const { assert(i == 0 && "Invalid operand id for unary operator"); return getOperand(); } UnaryOp getOpcode() const { return Opc; } - Init *getOperand() const { return LHS; } + const Init *getOperand() const { return LHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass)const ; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const; }; @@ -852,21 +1107,28 @@ enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, EQ }; private: BinaryOp Opc; - Init *LHS, *RHS; + const Init *LHS, *RHS; + + BinOpInit(const FoldingSetNodeID &ID, BinaryOp opc, const Init *lhs, + const Init *rhs, RecTy *Type) : + OpInit(ID, Type), Opc(opc), LHS(lhs), RHS(rhs) {} + + BinOpInit(const BinOpInit &Other); // Do not define. + BinOpInit &operator=(const BinOpInit &Other); // Do not define. + public: - BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) : - OpInit(Type), Opc(opc), LHS(lhs), RHS(rhs) { - } + static const BinOpInit *Create(BinaryOp opc, const Init *lhs, const Init *rhs, + RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list - virtual OpInit *clone(std::vector &Operands) { + virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 2 && "Wrong number of operands for binary operation"); - return new BinOpInit(getOpcode(), Operands[0], Operands[1], getType()); + return BinOpInit::Create(getOpcode(), Operands[0], Operands[1], getType()); } int getNumOperands() const { return 2; } - Init *getOperand(int i) { + const Init *getOperand(int i) const { assert((i == 0 || i == 1) && "Invalid operand id for binary operator"); if (i == 0) { return getLHS(); @@ -876,14 +1138,15 @@ } BinaryOp getOpcode() const { return Opc; } - Init *getLHS() const { return LHS; } - Init *getRHS() const { return RHS; } + const Init *getLHS() const { return LHS; } + const Init *getRHS() const { return RHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const; }; @@ -895,22 +1158,30 @@ enum TernaryOp { SUBST, FOREACH, IF }; private: TernaryOp Opc; - Init *LHS, *MHS, *RHS; + const Init *LHS, *MHS, *RHS; + + TernOpInit(const FoldingSetNodeID &ID, TernaryOp opc, const Init *lhs, + const Init *mhs, const Init *rhs, RecTy *Type) : + OpInit(ID, Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) {} + + TernOpInit(const TernOpInit &Other); // Do not define. + TernOpInit &operator=(const TernOpInit &Other); // Do not define. + public: - TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type) : - OpInit(Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) { - } + static const TernOpInit *Create(TernaryOp opc, const Init *lhs, + const Init *mhs, const Init *rhs, + RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list - virtual OpInit *clone(std::vector &Operands) { + virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 3 && "Wrong number of operands for ternary operation"); - return new TernOpInit(getOpcode(), Operands[0], Operands[1], Operands[2], - getType()); + return TernOpInit::Create(getOpcode(), Operands[0], Operands[1], + Operands[2], getType()); } int getNumOperands() const { return 3; } - Init *getOperand(int i) { + const Init *getOperand(int i) const { assert((i == 0 || i == 1 || i == 2) && "Invalid operand id for ternary operator"); if (i == 0) { @@ -923,17 +1194,18 @@ } TernaryOp getOpcode() const { return Opc; } - Init *getLHS() const { return LHS; } - Init *getMHS() const { return MHS; } - Init *getRHS() const { return RHS; } + const Init *getLHS() const { return LHS; } + const Init *getMHS() const { return MHS; } + const Init *getRHS() const { return RHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; virtual bool isComplete() const { return false; } - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const; }; @@ -943,23 +1215,31 @@ /// class VarInit : public TypedInit { std::string VarName; + + explicit VarInit(const FoldingSetNodeID &ID, const std::string &VN, RecTy *T) + : TypedInit(ID, T), VarName(VN) {} + + VarInit(const VarInit &Other); // Do not define. + VarInit &operator=(const VarInit &Other); // Do not define. + public: - explicit VarInit(const std::string &VN, RecTy *T) - : TypedInit(T), VarName(VN) {} + static const VarInit *Create(const std::string &VN, RecTy *T); + static const VarInit *Create(const Init *VN, RecTy *T); - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } const std::string &getName() const { return VarName; } - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit); - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt); + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const; + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const; virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual Init *getFieldInit(Record &R, const RecordVal *RV, + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const; /// resolveReferences - This method is used by classes that refer to other @@ -967,7 +1247,8 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const { return VarName; } }; @@ -976,76 +1257,101 @@ /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field. /// class VarBitInit : public Init { - TypedInit *TI; + const TypedInit *TI; unsigned Bit; -public: - VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) { + + VarBitInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned B) + : Init(ID), TI(T), Bit(B) { assert(T->getType() && dynamic_cast(T->getType()) && ((BitsRecTy*)T->getType())->getNumBits() > B && "Illegal VarBitInit expression!"); } - virtual Init *convertInitializerTo(RecTy *Ty) { + VarBitInit(const VarBitInit &Other); // Do not define. + VarBitInit &operator=(const VarBitInit &Other); // Do not define. + +public: + static const VarBitInit *Create(const TypedInit *T, unsigned B); + + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - TypedInit *getVariable() const { return TI; } + const TypedInit *getVariable() const { return TI; } unsigned getBitNum() const { return Bit; } virtual std::string getAsString() const; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; }; /// VarListElementInit - List[4] - Represent access to one element of a var or /// field. class VarListElementInit : public TypedInit { - TypedInit *TI; + const TypedInit *TI; unsigned Element; -public: - VarListElementInit(TypedInit *T, unsigned E) - : TypedInit(dynamic_cast(T->getType())->getElementType()), + + VarListElementInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned E) + : TypedInit(ID, dynamic_cast(T->getType())->getElementType()), TI(T), Element(E) { assert(T->getType() && dynamic_cast(T->getType()) && "Illegal VarBitInit expression!"); } - virtual Init *convertInitializerTo(RecTy *Ty) { + VarListElementInit(const VarListElementInit &Other); // Do not define. + VarListElementInit &operator=(const VarListElementInit &Other); // Do + // not + // define. + +public: + static const VarListElementInit *Create(const TypedInit *T, unsigned E); + + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - TypedInit *getVariable() const { return TI; } + const TypedInit *getVariable() const { return TI; } unsigned getElementNum() const { return Element; } - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit); + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const; /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt); + virtual const Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) const; virtual std::string getAsString() const; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; }; /// DefInit - AL - Represent a reference to a 'def' in the description /// class DefInit : public TypedInit { Record *Def; + + explicit DefInit(const FoldingSetNodeID &ID, Record *D) + : TypedInit(ID, new RecordRecTy(D)), Def(D) {} + + DefInit(const DefInit &Other); // Do not define. + DefInit &operator=(const DefInit &Other); // Do not define. + public: - explicit DefInit(Record *D) : TypedInit(new RecordRecTy(D)), Def(D) {} + static const DefInit *Create(Record *D); - virtual Init *convertInitializerTo(RecTy *Ty) { + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } Record *getDef() const { return Def; } - //virtual Init *convertInitializerBitRange(const std::vector &Bits); + //virtual const Init * + //convertInitializerBitRange(const std::vector &Bits) const; virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual Init *getFieldInit(Record &R, const RecordVal *RV, + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const; virtual std::string getAsString() const; @@ -1054,8 +1360,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { assert(0 && "Illegal bit reference off def"); return 0; } @@ -1063,8 +1369,9 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) { + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { assert(0 && "Illegal element reference off def"); return 0; } @@ -1074,24 +1381,33 @@ /// FieldInit - X.Y - Represent a reference to a subfield of a variable /// class FieldInit : public TypedInit { - Init *Rec; // Record we are referring to + const Init *Rec; // Record we are referring to std::string FieldName; // Field we are accessing -public: - FieldInit(Init *R, const std::string &FN) - : TypedInit(R->getFieldType(FN)), Rec(R), FieldName(FN) { + + FieldInit(const FoldingSetNodeID &ID, const Init *R, const std::string &FN) + : TypedInit(ID, R->getFieldType(FN)), Rec(R), FieldName(FN) { assert(getType() && "FieldInit with non-record type!"); } - virtual Init *convertInitializerTo(RecTy *Ty) { + FieldInit(const FieldInit &Other); // Do not define. + FieldInit &operator=(const FieldInit &Other); // Do not define. + +public: + static const FieldInit *Create(const Init *R, const std::string &FN); + static const FieldInit *Create(const Init *R, const Init *FN); + + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit); - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt); + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const; + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const; - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const { return Rec->getAsString() + "." + FieldName; @@ -1103,14 +1419,14 @@ /// argument can have a name associated with it. /// class DagInit : public TypedInit { - Init *Val; + const Init *Val; std::string ValName; - std::vector Args; + std::vector Args; std::vector ArgNames; -public: - DagInit(Init *V, std::string VN, - const std::vector > &args) - : TypedInit(new DagRecTy), Val(V), ValName(VN) { + + DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, + const std::vector > &args) + : TypedInit(ID, new DagRecTy), Val(V), ValName(VN) { Args.reserve(args.size()); ArgNames.reserve(args.size()); for (unsigned i = 0, e = args.size(); i != e; ++i) { @@ -1118,21 +1434,33 @@ ArgNames.push_back(args[i].second); } } - DagInit(Init *V, std::string VN, const std::vector &args, + DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, + const std::vector &args, const std::vector &argNames) - : TypedInit(new DagRecTy), Val(V), ValName(VN), Args(args), + : TypedInit(ID, new DagRecTy), Val(V), ValName(VN), Args(args), ArgNames(argNames) { } - virtual Init *convertInitializerTo(RecTy *Ty) { + DagInit(const DagInit &Other); // Do not define. + DagInit &operator=(const DagInit &Other); // Do not define. + +public: + static const DagInit *Create(const Init *V, const std::string &VN, + const std::vector< + std::pair > &args); + static const DagInit *Create(const Init *V, const std::string &VN, + const std::vector &args, + const std::vector &argNames); + + virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); } - Init *getOperator() const { return Val; } + const Init *getOperator() const { return Val; } const std::string &getName() const { return ValName; } unsigned getNumArgs() const { return Args.size(); } - Init *getArg(unsigned Num) const { + const Init *getArg(unsigned Num) const { assert(Num < Args.size() && "Arg number out of range!"); return Args[Num]; } @@ -1141,17 +1469,18 @@ return ArgNames[Num]; } - void setArg(unsigned Num, Init *I) { + void setArg(unsigned Num, const Init *I) { assert(Num < Args.size() && "Arg number out of range!"); Args[Num] = I; } - virtual Init *resolveReferences(Record &R, const RecordVal *RV); + virtual const Init *resolveReferences(Record &R, + const RecordVal *RV) const; virtual std::string getAsString() const; - typedef std::vector::iterator arg_iterator; - typedef std::vector::const_iterator const_arg_iterator; + typedef std::vector::iterator arg_iterator; + typedef std::vector::const_iterator const_arg_iterator; typedef std::vector::iterator name_iterator; typedef std::vector::const_iterator const_name_iterator; @@ -1171,14 +1500,15 @@ inline size_t name_size () const { return ArgNames.size(); } inline bool name_empty() const { return ArgNames.empty(); } - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) { + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) const { assert(0 && "Illegal bit reference off dag"); return 0; } - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) { + virtual const Init *resolveListElementReference(Record &R, + const RecordVal *RV, + unsigned Elt) const { assert(0 && "Illegal element reference off dag"); return 0; } @@ -1192,7 +1522,7 @@ std::string Name; RecTy *Ty; unsigned Prefix; - Init *Value; + const Init *Value; public: RecordVal(const std::string &N, RecTy *T, unsigned P); @@ -1200,9 +1530,9 @@ unsigned getPrefix() const { return Prefix; } RecTy *getType() const { return Ty; } - Init *getValue() const { return Value; } + const Init *getValue() const { return Value; } - bool setValue(Init *V) { + bool setValue(const Init *V) { if (V) { Value = V->convertInitializerTo(Ty); return Value == 0; @@ -1336,7 +1666,7 @@ /// getValueInit - Return the initializer for a value with the specified name, /// or throw an exception if the field does not exist. /// - Init *getValueInit(StringRef FieldName) const; + const Init *getValueInit(StringRef FieldName) const; /// getValueAsString - This method looks up the specified field and returns /// its value as a string, throwing an exception if the field does not exist @@ -1348,13 +1678,13 @@ /// its value as a BitsInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// - BitsInit *getValueAsBitsInit(StringRef FieldName) const; + const BitsInit *getValueAsBitsInit(StringRef FieldName) const; /// getValueAsListInit - This method looks up the specified field and returns /// its value as a ListInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// - ListInit *getValueAsListInit(StringRef FieldName) const; + const ListInit *getValueAsListInit(StringRef FieldName) const; /// getValueAsListOfDefs - This method looks up the specified field and /// returns its value as a vector of records, throwing an exception if the @@ -1396,7 +1726,7 @@ /// value as an Dag, throwing an exception if the field does not exist or if /// the value is not the right type. /// - DagInit *getValueAsDag(StringRef FieldName) const; + const DagInit *getValueAsDag(StringRef FieldName) const; /// getValueAsCode - This method looks up the specified field and returns /// its value as the string data in a CodeInit, throwing an exception if the Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Mon Jul 11 13:25:51 2011 @@ -722,7 +722,7 @@ if (!V || !V->getValue()) continue; - DefInit *DI = dynamic_cast(V->getValue()); + const DefInit *DI = dynamic_cast(V->getValue()); Record *Alias = DI->getDef(); DwarfRegNums[Reg] = DwarfRegNums[Alias]; } Modified: llvm/trunk/utils/TableGen/SetTheory.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SetTheory.cpp (original) +++ llvm/trunk/utils/TableGen/SetTheory.cpp Mon Jul 11 13:25:51 2011 @@ -27,14 +27,14 @@ // (add a, b, ...) Evaluate and union all arguments. struct AddOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { ST.evaluate(Expr->arg_begin(), Expr->arg_end(), Elts); } }; // (sub Add, Sub, ...) Set difference. struct SubOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() < 2) throw "Set difference needs at least two arguments: " + Expr->getAsString(); @@ -49,7 +49,7 @@ // (and S1, S2) Set intersection. struct AndOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 2) throw "Set intersection requires two arguments: " + Expr->getAsString(); RecSet S1, S2; @@ -63,16 +63,16 @@ // SetIntBinOp - Abstract base class for (Op S, N) operators. struct SetIntBinOp : public SetTheory::Operator { - virtual void apply2(SetTheory &ST, DagInit *Expr, + virtual void apply2(SetTheory &ST, const DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) =0; - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 2) throw "Operator requires (Op Set, Int) arguments: " + Expr->getAsString(); RecSet Set; ST.evaluate(Expr->arg_begin()[0], Set); - IntInit *II = dynamic_cast(Expr->arg_begin()[1]); + const IntInit *II = dynamic_cast(Expr->arg_begin()[1]); if (!II) throw "Second argument must be an integer: " + Expr->getAsString(); apply2(ST, Expr, Set, II->getValue(), Elts); @@ -81,7 +81,7 @@ // (shl S, N) Shift left, remove the first N elements. struct ShlOp : public SetIntBinOp { - void apply2(SetTheory &ST, DagInit *Expr, + void apply2(SetTheory &ST, const DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N < 0) @@ -93,7 +93,7 @@ // (trunc S, N) Truncate after the first N elements. struct TruncOp : public SetIntBinOp { - void apply2(SetTheory &ST, DagInit *Expr, + void apply2(SetTheory &ST, const DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N < 0) @@ -110,7 +110,7 @@ RotOp(bool Rev) : Reverse(Rev) {} - void apply2(SetTheory &ST, DagInit *Expr, + void apply2(SetTheory &ST, const DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (Reverse) @@ -129,7 +129,7 @@ // (decimate S, N) Pick every N'th element of S. struct DecimateOp : public SetIntBinOp { - void apply2(SetTheory &ST, DagInit *Expr, + void apply2(SetTheory &ST, const DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N <= 0) @@ -141,25 +141,26 @@ // (sequence "Format", From, To) Generate a sequence of records by name. struct SequenceOp : public SetTheory::Operator { - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 3) throw "Bad args to (sequence \"Format\", From, To): " + Expr->getAsString(); std::string Format; - if (StringInit *SI = dynamic_cast(Expr->arg_begin()[0])) + if (const StringInit *SI = + dynamic_cast(Expr->arg_begin()[0])) Format = SI->getValue(); else throw "Format must be a string: " + Expr->getAsString(); int64_t From, To; - if (IntInit *II = dynamic_cast(Expr->arg_begin()[1])) + if (const IntInit *II = dynamic_cast(Expr->arg_begin()[1])) From = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); if (From < 0 || From >= (1 << 30)) throw "From out of range"; - if (IntInit *II = dynamic_cast(Expr->arg_begin()[2])) + if (const IntInit *II = dynamic_cast(Expr->arg_begin()[2])) To = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); @@ -167,7 +168,7 @@ throw "To out of range"; RecordKeeper &Records = - dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); + dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); int Step = From <= To ? 1 : -1; for (To += Step; From != To; From += Step) { @@ -222,9 +223,9 @@ addExpander(ClassName, new FieldExpander(FieldName)); } -void SetTheory::evaluate(Init *Expr, RecSet &Elts) { +void SetTheory::evaluate(const Init *Expr, RecSet &Elts) { // A def in a list can be a just an element, or it may expand. - if (DefInit *Def = dynamic_cast(Expr)) { + if (const DefInit *Def = dynamic_cast(Expr)) { if (const RecVec *Result = expand(Def->getDef())) return Elts.insert(Result->begin(), Result->end()); Elts.insert(Def->getDef()); @@ -232,14 +233,14 @@ } // Lists simply expand. - if (ListInit *LI = dynamic_cast(Expr)) + if (const ListInit *LI = dynamic_cast(Expr)) return evaluate(LI->begin(), LI->end(), Elts); // Anything else must be a DAG. - DagInit *DagExpr = dynamic_cast(Expr); + const DagInit *DagExpr = dynamic_cast(Expr); if (!DagExpr) throw "Invalid set element: " + Expr->getAsString(); - DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); + const DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); if (!OpInit) throw "Bad set expression: " + Expr->getAsString(); Operator *Op = Operators.lookup(OpInit->getDef()->getName()); Modified: llvm/trunk/utils/TableGen/SetTheory.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SetTheory.h (original) +++ llvm/trunk/utils/TableGen/SetTheory.h Mon Jul 11 13:25:51 2011 @@ -70,7 +70,7 @@ /// apply - Apply this operator to Expr's arguments and insert the result /// in Elts. - virtual void apply(SetTheory&, DagInit *Expr, RecSet &Elts) =0; + virtual void apply(SetTheory&, const DagInit *Expr, RecSet &Elts) =0; }; /// Expander - A callback function that can transform a Record representing a @@ -115,7 +115,7 @@ void addOperator(StringRef Name, Operator*); /// evaluate - Evaluate Expr and append the resulting set to Elts. - void evaluate(Init *Expr, RecSet &Elts); + void evaluate(const Init *Expr, RecSet &Elts); /// evaluate - Evaluate a sequence of Inits and append to Elts. template Modified: llvm/trunk/utils/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.cpp (original) +++ llvm/trunk/utils/TableGen/TGParser.cpp Mon Jul 11 13:25:51 2011 @@ -28,7 +28,7 @@ struct SubClassReference { SMLoc RefLoc; Record *Rec; - std::vector TemplateArgs; + std::vector TemplateArgs; SubClassReference() : Rec(0) {} bool isInvalid() const { return Rec == 0; } @@ -37,7 +37,7 @@ struct SubMultiClassReference { SMLoc RefLoc; MultiClass *MC; - std::vector TemplateArgs; + std::vector TemplateArgs; SubMultiClassReference() : MC(0) {} bool isInvalid() const { return MC == 0; } @@ -50,7 +50,7 @@ MC->dump(); errs() << "Template args:\n"; - for (std::vector::const_iterator i = TemplateArgs.begin(), + for (std::vector::const_iterator i = TemplateArgs.begin(), iend = TemplateArgs.end(); i != iend; ++i) { @@ -80,7 +80,7 @@ /// SetValue - /// Return true on error, false on success. bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName, - const std::vector &BitList, Init *V) { + const std::vector &BitList, const Init *V) { if (!V) return false; if (CurRec == 0) CurRec = &CurMultiClass->Rec; @@ -92,7 +92,7 @@ // Do not allow assignments like 'X = X'. This will just cause infinite loops // in the resolution machinery. if (BitList.empty()) - if (VarInit *VI = dynamic_cast(V)) + if (const VarInit *VI = dynamic_cast(V)) if (VI->getName() == ValName) return false; @@ -101,37 +101,37 @@ // initializer. // if (!BitList.empty()) { - BitsInit *CurVal = dynamic_cast(RV->getValue()); + const BitsInit *CurVal = dynamic_cast(RV->getValue()); if (CurVal == 0) return Error(Loc, "Value '" + ValName + "' is not a bits type"); // Convert the incoming value to a bits type of the appropriate size... - Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); + const Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); if (BI == 0) { V->convertInitializerTo(new BitsRecTy(BitList.size())); return Error(Loc, "Initializer is not compatible with bit range"); } // We should have a BitsInit type now. - BitsInit *BInit = dynamic_cast(BI); + const BitsInit *BInit = dynamic_cast(BI); assert(BInit != 0); - BitsInit *NewVal = new BitsInit(CurVal->getNumBits()); + SmallVector NewBits(CurVal->getNumBits()); // Loop over bits, assigning values as appropriate. for (unsigned i = 0, e = BitList.size(); i != e; ++i) { unsigned Bit = BitList[i]; - if (NewVal->getBit(Bit)) + if (NewBits[Bit]) return Error(Loc, "Cannot set bit #" + utostr(Bit) + " of value '" + ValName + "' more than once"); - NewVal->setBit(Bit, BInit->getBit(i)); + NewBits[Bit] = BInit->getBit(i); } for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i) - if (NewVal->getBit(i) == 0) - NewVal->setBit(i, CurVal->getBit(i)); + if (NewBits[i] == 0) + NewBits[i] = CurVal->getBit(i); - V = NewVal; + V = BitsInit::Create(NewBits.begin(), NewBits.end()); } if (RV->setValue(V)) @@ -633,7 +633,7 @@ /// IDValue ::= ID [multiclass template argument] /// IDValue ::= ID [def name] /// -Init *TGParser::ParseIDValue(Record *CurRec) { +const Init *TGParser::ParseIDValue(Record *CurRec) { assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue"); std::string Name = Lex.getCurStrVal(); SMLoc Loc = Lex.getLoc(); @@ -643,17 +643,17 @@ /// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID /// has already been read. -Init *TGParser::ParseIDValue(Record *CurRec, +const Init *TGParser::ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc) { if (CurRec) { if (const RecordVal *RV = CurRec->getValue(Name)) - return new VarInit(Name, RV->getType()); + return VarInit::Create(Name, RV->getType()); std::string TemplateArgName = CurRec->getName()+":"+Name; if (CurRec->isTemplateArg(TemplateArgName)) { const RecordVal *RV = CurRec->getValue(TemplateArgName); assert(RV && "Template arg doesn't exist??"); - return new VarInit(TemplateArgName, RV->getType()); + return VarInit::Create(TemplateArgName, RV->getType()); } } @@ -662,12 +662,12 @@ if (CurMultiClass->Rec.isTemplateArg(MCName)) { const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); assert(RV && "Template arg doesn't exist??"); - return new VarInit(MCName, RV->getType()); + return VarInit::Create(MCName, RV->getType()); } } if (Record *D = Records.getDef(Name)) - return new DefInit(D); + return DefInit::Create(D); Error(NameLoc, "Variable not defined: '" + Name + "'"); return 0; @@ -677,7 +677,7 @@ /// /// Operation ::= XOperator ['<' Type '>'] '(' Args ')' /// -Init *TGParser::ParseOperation(Record *CurRec) { +const Init *TGParser::ParseOperation(Record *CurRec) { switch (Lex.getCode()) { default: TokError("unknown operation"); @@ -724,15 +724,15 @@ } Lex.Lex(); // eat the '(' - Init *LHS = ParseValue(CurRec); + const Init *LHS = ParseValue(CurRec); if (LHS == 0) return 0; if (Code == UnOpInit::HEAD || Code == UnOpInit::TAIL || Code == UnOpInit::EMPTY) { - ListInit *LHSl = dynamic_cast(LHS); - StringInit *LHSs = dynamic_cast(LHS); - TypedInit *LHSt = dynamic_cast(LHS); + const ListInit *LHSl = dynamic_cast(LHS); + const StringInit *LHSs = dynamic_cast(LHS); + const TypedInit *LHSt = dynamic_cast(LHS); if (LHSl == 0 && LHSs == 0 && LHSt == 0) { TokError("expected list or string type argument in unary operator"); return 0; @@ -758,8 +758,8 @@ return 0; } if (LHSl) { - Init *Item = LHSl->getElement(0); - TypedInit *Itemt = dynamic_cast(Item); + const Init *Item = LHSl->getElement(0); + const TypedInit *Itemt = dynamic_cast(Item); if (Itemt == 0) { TokError("untyped list element in unary operator"); return 0; @@ -790,7 +790,7 @@ return 0; } Lex.Lex(); // eat the ')' - return (new UnOpInit(Code, LHS, Type))->Fold(CurRec, CurMultiClass); + return (UnOpInit::Create(Code, LHS, Type))->Fold(CurRec, CurMultiClass); } case tgtok::XConcat: @@ -825,7 +825,7 @@ } Lex.Lex(); // eat the '(' - SmallVector InitList; + SmallVector InitList; InitList.push_back(ParseValue(CurRec)); if (InitList.back() == 0) return 0; @@ -847,15 +847,15 @@ // shorthand for nesting them. if (Code == BinOpInit::STRCONCAT) { while (InitList.size() > 2) { - Init *RHS = InitList.pop_back_val(); - RHS = (new BinOpInit(Code, InitList.back(), RHS, Type)) + const Init *RHS = InitList.pop_back_val(); + RHS = (BinOpInit::Create(Code, InitList.back(), RHS, Type)) ->Fold(CurRec, CurMultiClass); InitList.back() = RHS; } } if (InitList.size() == 2) - return (new BinOpInit(Code, InitList[0], InitList[1], Type)) + return (BinOpInit::Create(Code, InitList[0], InitList[1], Type)) ->Fold(CurRec, CurMultiClass); Error(OpLoc, "expected two operands to operator"); @@ -888,7 +888,7 @@ } Lex.Lex(); // eat the '(' - Init *LHS = ParseValue(CurRec); + const Init *LHS = ParseValue(CurRec); if (LHS == 0) return 0; if (Lex.getCode() != tgtok::comma) { @@ -897,7 +897,7 @@ } Lex.Lex(); // eat the ',' - Init *MHS = ParseValue(CurRec); + const Init *MHS = ParseValue(CurRec); if (MHS == 0) return 0; if (Lex.getCode() != tgtok::comma) { @@ -906,7 +906,7 @@ } Lex.Lex(); // eat the ',' - Init *RHS = ParseValue(CurRec); + const Init *RHS = ParseValue(CurRec); if (RHS == 0) return 0; if (Lex.getCode() != tgtok::r_paren) { @@ -920,23 +920,23 @@ case tgtok::XIf: { // FIXME: The `!if' operator doesn't handle non-TypedInit well at // all. This can be made much more robust. - TypedInit *MHSt = dynamic_cast(MHS); - TypedInit *RHSt = dynamic_cast(RHS); + const TypedInit *MHSt = dynamic_cast(MHS); + const TypedInit *RHSt = dynamic_cast(RHS); RecTy *MHSTy = 0; RecTy *RHSTy = 0; if (MHSt == 0 && RHSt == 0) { - BitsInit *MHSbits = dynamic_cast(MHS); - BitsInit *RHSbits = dynamic_cast(RHS); + const BitsInit *MHSbits = dynamic_cast(MHS); + const BitsInit *RHSbits = dynamic_cast(RHS); if (MHSbits && RHSbits && MHSbits->getNumBits() == RHSbits->getNumBits()) { Type = new BitRecTy(); break; } else { - BitInit *MHSbit = dynamic_cast(MHS); - BitInit *RHSbit = dynamic_cast(RHS); + const BitInit *MHSbit = dynamic_cast(MHS); + const BitInit *RHSbit = dynamic_cast(RHS); if (MHSbit && RHSbit) { Type = new BitRecTy(); @@ -964,7 +964,7 @@ break; } case tgtok::XForEach: { - TypedInit *MHSt = dynamic_cast(MHS); + const TypedInit *MHSt = dynamic_cast(MHS); if (MHSt == 0) { TokError("could not get type for !foreach"); return 0; @@ -973,7 +973,7 @@ break; } case tgtok::XSubst: { - TypedInit *RHSt = dynamic_cast(RHS); + const TypedInit *RHSt = dynamic_cast(RHS); if (RHSt == 0) { TokError("could not get type for !subst"); return 0; @@ -982,7 +982,7 @@ break; } } - return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec, + return (TernOpInit::Create(Code, LHS, MHS, RHS, Type))->Fold(CurRec, CurMultiClass); } } @@ -1038,11 +1038,11 @@ /// SimpleValue ::= SRLTOK '(' Value ',' Value ')' /// SimpleValue ::= STRCONCATTOK '(' Value ',' Value ')' /// -Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { - Init *R = 0; +const Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { + const Init *R = 0; switch (Lex.getCode()) { default: TokError("Unknown token when parsing a value"); break; - case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break; + case tgtok::IntVal: R = IntInit::Create(Lex.getCurIntVal()); Lex.Lex(); break; case tgtok::StrVal: { std::string Val = Lex.getCurStrVal(); Lex.Lex(); @@ -1053,15 +1053,15 @@ Lex.Lex(); } - R = new StringInit(Val); + R = StringInit::Create(Val); break; } case tgtok::CodeFragment: - R = new CodeInit(Lex.getCurStrVal()); + R = CodeInit::Create(Lex.getCurStrVal()); Lex.Lex(); break; case tgtok::question: - R = new UnsetInit(); + R = UnsetInit::Create(); Lex.Lex(); break; case tgtok::Id: { @@ -1085,7 +1085,7 @@ return 0; } - std::vector ValueList = ParseValueList(CurRec, Class); + std::vector ValueList = ParseValueList(CurRec, Class); if (ValueList.empty()) return 0; if (Lex.getCode() != tgtok::greater) { @@ -1110,12 +1110,12 @@ Records.addDef(NewRec); // The result of the expression is a reference to the new record. - return new DefInit(NewRec); + return DefInit::Create(NewRec); } case tgtok::l_brace: { // Value ::= '{' ValueList '}' SMLoc BraceLoc = Lex.getLoc(); Lex.Lex(); // eat the '{' - std::vector Vals; + std::vector Vals; if (Lex.getCode() != tgtok::r_brace) { Vals = ParseValueList(CurRec); @@ -1127,21 +1127,22 @@ } Lex.Lex(); // eat the '}' - BitsInit *Result = new BitsInit(Vals.size()); + SmallVector NewBits(Vals.size()); + for (unsigned i = 0, e = Vals.size(); i != e; ++i) { - Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); + const Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); if (Bit == 0) { Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+ ") is not convertable to a bit"); return 0; } - Result->setBit(Vals.size()-i-1, Bit); + NewBits[Vals.size()-i-1] = Bit; } - return Result; + return BitsInit::Create(NewBits.begin(), NewBits.end()); } case tgtok::l_square: { // Value ::= '[' ValueList ']' Lex.Lex(); // eat the '[' - std::vector Vals; + std::vector Vals; RecTy *DeducedEltTy = 0; ListRecTy *GivenListTy = 0; @@ -1189,10 +1190,10 @@ // Check elements RecTy *EltTy = 0; - for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); + for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); i != ie; ++i) { - TypedInit *TArg = dynamic_cast(*i); + const TypedInit *TArg = dynamic_cast(*i); if (TArg == 0) { TokError("Untyped list element"); return 0; @@ -1236,7 +1237,7 @@ DeducedEltTy = EltTy; } - return new ListInit(Vals, DeducedEltTy); + return ListInit::Create(Vals, DeducedEltTy); } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' @@ -1245,7 +1246,7 @@ return 0; } - Init *Operator = ParseValue(CurRec); + const Init *Operator = ParseValue(CurRec); if (Operator == 0) return 0; // If the operator name is present, parse it. @@ -1259,7 +1260,7 @@ Lex.Lex(); // eat the VarName. } - std::vector > DagArgs; + std::vector > DagArgs; if (Lex.getCode() != tgtok::r_paren) { DagArgs = ParseDagArgList(CurRec); if (DagArgs.empty()) return 0; @@ -1271,7 +1272,7 @@ } Lex.Lex(); // eat the ')' - return new DagInit(Operator, OperatorName, DagArgs); + return DagInit::Create(Operator, OperatorName, DagArgs); } case tgtok::XHead: @@ -1301,8 +1302,8 @@ /// ValueSuffix ::= '[' BitList ']' /// ValueSuffix ::= '.' ID /// -Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { - Init *Result = ParseSimpleValue(CurRec, ItemType); +const Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { + const Init *Result = ParseSimpleValue(CurRec, ItemType); if (Result == 0) return 0; // Parse the suffixes now if present. @@ -1361,7 +1362,7 @@ Result->getAsString() + "'"); return 0; } - Result = new FieldInit(Result, Lex.getCurStrVal()); + Result = FieldInit::Create(Result, Lex.getCurStrVal()); Lex.Lex(); // eat field name break; } @@ -1372,20 +1373,20 @@ /// /// ParseDagArgList ::= Value (':' VARNAME)? /// ParseDagArgList ::= ParseDagArgList ',' Value (':' VARNAME)? -std::vector > +std::vector > TGParser::ParseDagArgList(Record *CurRec) { - std::vector > Result; + std::vector > Result; while (1) { - Init *Val = ParseValue(CurRec); - if (Val == 0) return std::vector >(); + const Init *Val = ParseValue(CurRec); + if (Val == 0) return std::vector >(); // If the variable name is present, add it. std::string VarName; if (Lex.getCode() == tgtok::colon) { if (Lex.Lex() != tgtok::VarName) { // eat the ':' TokError("expected variable name in dag literal"); - return std::vector >(); + return std::vector >(); } VarName = Lex.getCurStrVal(); Lex.Lex(); // eat the VarName. @@ -1407,9 +1408,10 @@ /// /// ValueList ::= Value (',' Value) /// -std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, - RecTy *EltTy) { - std::vector Result; +std::vector TGParser::ParseValueList(Record *CurRec, + Record *ArgsRec, + RecTy *EltTy) { + std::vector Result; RecTy *ItemType = EltTy; unsigned int ArgN = 0; if (ArgsRec != 0 && EltTy == 0) { @@ -1420,7 +1422,7 @@ ++ArgN; } Result.push_back(ParseValue(CurRec, ItemType)); - if (Result.back() == 0) return std::vector(); + if (Result.back() == 0) return std::vector(); while (Lex.getCode() == tgtok::comma) { Lex.Lex(); // Eat the comma @@ -1429,7 +1431,7 @@ const std::vector &TArgs = ArgsRec->getTemplateArgs(); if (ArgN >= TArgs.size()) { TokError("too many template arguments"); - return std::vector(); + return std::vector(); } const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); assert(RV && "Template argument record not found??"); @@ -1437,7 +1439,7 @@ ++ArgN; } Result.push_back(ParseValue(CurRec, ItemType)); - if (Result.back() == 0) return std::vector(); + if (Result.back() == 0) return std::vector(); } return Result; @@ -1490,7 +1492,7 @@ if (Lex.getCode() == tgtok::equal) { Lex.Lex(); SMLoc ValLoc = Lex.getLoc(); - Init *Val = ParseValue(CurRec, Type); + const Init *Val = ParseValue(CurRec, Type); if (Val == 0 || SetValue(CurRec, ValLoc, DeclName, std::vector(), Val)) return ""; @@ -1574,7 +1576,7 @@ RecTy *Type = Field->getType(); - Init *Val = ParseValue(CurRec, Type); + const Init *Val = ParseValue(CurRec, Type); if (Val == 0) return true; if (Lex.getCode() != tgtok::semi) @@ -1774,7 +1776,7 @@ } Lex.Lex(); // eat the '='. - Init *Val = ParseValue(0); + const Init *Val = ParseValue(0); if (Val == 0) return std::vector(); // Now that we have everything, add the record. @@ -1948,7 +1950,7 @@ // template parameters. MultiClass *MC = MultiClasses[Ref.Rec->getName()]; assert(MC && "Didn't lookup multiclass correctly?"); - std::vector &TemplateVals = Ref.TemplateArgs; + std::vector &TemplateVals = Ref.TemplateArgs; // Verify that the correct number of template arguments were specified. const std::vector &TArgs = MC->Rec.getTemplateArgs(); Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Mon Jul 11 13:25:51 2011 @@ -33,10 +33,10 @@ struct LetRecord { std::string Name; std::vector Bits; - Init *Value; + const Init *Value; SMLoc Loc; - LetRecord(const std::string &N, const std::vector &B, Init *V, - SMLoc L) + LetRecord(const std::string &N, const std::vector &B, + const Init *V, SMLoc L) : Name(N), Bits(B), Value(V), Loc(L) { } }; @@ -73,7 +73,7 @@ private: // Semantic analysis methods. bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName, - const std::vector &BitList, Init *V); + const std::vector &BitList, const Init *V); bool AddSubClass(Record *Rec, SubClassReference &SubClass); bool AddSubMultiClass(MultiClass *CurMC, SubMultiClassReference &SubMultiClass); @@ -98,18 +98,20 @@ SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); - Init *ParseIDValue(Record *CurRec); - Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); - Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); - Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); - std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); - std::vector > ParseDagArgList(Record *); + const Init *ParseIDValue(Record *CurRec); + const Init *ParseIDValue(Record *CurRec, const std::string &Name, + SMLoc NameLoc); + const Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); + const Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); + std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, + RecTy *EltTy = 0); + std::vector > ParseDagArgList(Record *); bool ParseOptionalRangeList(std::vector &Ranges); bool ParseOptionalBitList(std::vector &Ranges); std::vector ParseRangeList(); bool ParseRangePiece(std::vector &Ranges); RecTy *ParseType(); - Init *ParseOperation(Record *CurRec); + const Init *ParseOperation(Record *CurRec); RecTy *ParseOperatorType(); std::string ParseObjectName(); Record *ParseClassID(); Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Mon Jul 11 13:25:51 2011 @@ -208,6 +208,7 @@ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { errs() << "Could not open input file '" << InputFilename << "': " << ec.message() <<"\n"; + Init::ReleaseMemory(); return 1; } MemoryBuffer *F = File.take(); @@ -221,25 +222,30 @@ TGParser Parser(SrcMgr, Records); - if (Parser.ParseFile()) + if (Parser.ParseFile()) { + Init::ReleaseMemory(); return 1; + } std::string Error; tool_output_file Out(OutputFilename.c_str(), Error); if (!Error.empty()) { errs() << argv[0] << ": error opening " << OutputFilename << ":" << Error << "\n"; + Init::ReleaseMemory(); return 1; } if (!DependFilename.empty()) { if (OutputFilename == "-") { errs() << argv[0] << ": the option -d must be used together with -o\n"; + Init::ReleaseMemory(); return 1; } tool_output_file DepOut(DependFilename.c_str(), Error); if (!Error.empty()) { errs() << argv[0] << ": error opening " << DependFilename << ":" << Error << "\n"; + Init::ReleaseMemory(); return 1; } DepOut.os() << DependFilename << ":"; @@ -382,11 +388,14 @@ } default: assert(1 && "Invalid Action"); + Init::ReleaseMemory(); return 1; } // Declare success. Out.keep(); + + Init::ReleaseMemory(); return 0; } catch (const TGError &Error) { @@ -399,5 +408,7 @@ errs() << argv[0] << ": Unknown unexpected exception occurred.\n"; } + Init::ReleaseMemory(); + return 1; } Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=134907&r1=134906&r2=134907&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original) +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Mon Jul 11 13:25:51 2011 @@ -162,7 +162,7 @@ /// @param init - A reference to the BitsInit to be decoded. /// @return - The field, with the first bit in the BitsInit as the lowest /// order bit. -static uint8_t byteFromBitsInit(BitsInit &init) { +static uint8_t byteFromBitsInit(const BitsInit &init) { int width = init.getNumBits(); assert(width <= 8 && "Field is too large for uint8_t!"); @@ -173,7 +173,7 @@ uint8_t ret = 0; for (index = 0; index < width; index++) { - if (static_cast(init.getBit(index))->getValue()) + if (static_cast(init.getBit(index))->getValue()) ret |= mask; mask <<= 1; @@ -189,7 +189,7 @@ /// @param name - The name of the field in the record. /// @return - The field, as translated by byteFromBitsInit(). static uint8_t byteFromRec(const Record* rec, const std::string &name) { - BitsInit* bits = rec->getValueAsBitsInit(name); + const BitsInit* bits = rec->getValueAsBitsInit(name); return byteFromBitsInit(*bits); } From rafael.espindola at gmail.com Mon Jul 11 13:39:17 2011 From: rafael.espindola at gmail.com (=?ISO-8859-1?Q?Rafael_=C1vila_de_Esp=EDndola?=) Date: Mon, 11 Jul 2011 14:39:17 -0400 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <20110711182552.740612A6C12C@llvm.org> References: <20110711182552.740612A6C12C@llvm.org> Message-ID: <4E1B4355.2030804@gmail.com> I think this is causing: /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: struct 'Init' was previously declared as a class [-Wmismatched-tags] struct Init; ^ /home/espindola/llvm/llvm/utils/TableGen/Record.h:556:7: note: previous use is here class Init : public FastFoldingSetNode { From resistor at mac.com Mon Jul 11 13:42:28 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 11 Jul 2011 11:42:28 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <20110711182552.740612A6C12C@llvm.org> References: <20110711182552.740612A6C12C@llvm.org> Message-ID: I'm getting build failures from this. Something about a pure virtual method call? --Owen On Jul 11, 2011, at 11:25 AM, David Greene wrote: > Author: greened > Date: Mon Jul 11 13:25:51 2011 > New Revision: 134907 > > URL: http://llvm.org/viewvc/llvm-project?rev=134907&view=rev > Log: > [AVX] Make Inits Foldable > > Manage Inits in a FoldingSet. This provides several benefits: > > - Memory for Inits is properly managed > > - Duplicate Inits are folded into Flyweights, saving memory > > - It enforces const-correctness, protecting against certain classes > of bugs > > The above benefits allow Inits to be used in more contexts, which in > turn provides more dynamism to TableGen. This enhanced capability > will be used by the AVX code generator to a fold common patterns > together. > > Modified: > llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp > llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp > llvm/trunk/utils/TableGen/CallingConvEmitter.cpp > llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp > llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp > llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp > llvm/trunk/utils/TableGen/CodeEmitterGen.cpp > llvm/trunk/utils/TableGen/CodeEmitterGen.h > llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp > llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h > llvm/trunk/utils/TableGen/CodeGenInstruction.cpp > llvm/trunk/utils/TableGen/CodeGenInstruction.h > llvm/trunk/utils/TableGen/CodeGenRegisters.cpp > llvm/trunk/utils/TableGen/CodeGenTarget.cpp > llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp > llvm/trunk/utils/TableGen/FastISelEmitter.cpp > llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp > llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp > llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp > llvm/trunk/utils/TableGen/OptParserEmitter.cpp > llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp > llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h > llvm/trunk/utils/TableGen/Record.cpp > llvm/trunk/utils/TableGen/Record.h > llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp > llvm/trunk/utils/TableGen/SetTheory.cpp > llvm/trunk/utils/TableGen/SetTheory.h > llvm/trunk/utils/TableGen/TGParser.cpp > llvm/trunk/utils/TableGen/TGParser.h > llvm/trunk/utils/TableGen/TableGen.cpp > llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp > > Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -114,7 +114,7 @@ > > /// byteFromBitsInit - Return the byte value from a BitsInit. > /// Called from getByteField(). > -static uint8_t byteFromBitsInit(BitsInit &init) { > +static uint8_t byteFromBitsInit(const BitsInit &init) { > int width = init.getNumBits(); > > assert(width <= 8 && "Field is too large for uint8_t!"); > @@ -125,7 +125,7 @@ > uint8_t ret = 0; > > for (index = 0; index < width; index++) { > - if (static_cast(init.getBit(index))->getValue()) > + if (static_cast(init.getBit(index))->getValue()) > ret |= mask; > > mask <<= 1; > @@ -135,12 +135,12 @@ > } > > static uint8_t getByteField(const Record &def, const char *str) { > - BitsInit *bits = def.getValueAsBitsInit(str); > + const BitsInit *bits = def.getValueAsBitsInit(str); > return byteFromBitsInit(*bits); > } > > -static BitsInit &getBitsField(const Record &def, const char *str) { > - BitsInit *bits = def.getValueAsBitsInit(str); > +static const BitsInit &getBitsField(const Record &def, const char *str) { > + const BitsInit *bits = def.getValueAsBitsInit(str); > return *bits; > } > > @@ -183,15 +183,15 @@ > static int Value(bit_value_t V) { > return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); > } > -static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { > - if (BitInit *bit = dynamic_cast(bits.getBit(index))) > +static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { > + if (const BitInit *bit = dynamic_cast(bits.getBit(index))) > return bit->getValue() ? BIT_TRUE : BIT_FALSE; > > // The bit is uninitialized. > return BIT_UNSET; > } > // Prints the bit value for each position. > -static void dumpBits(raw_ostream &o, BitsInit &bits) { > +static void dumpBits(raw_ostream &o, const BitsInit &bits) { > unsigned index; > > for (index = bits.getNumBits(); index > 0; index--) { > @@ -424,7 +424,8 @@ > if (AllInstructions[Opcode]->isPseudo) > return; > > - BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); > + const BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, > + "Inst"); > > for (unsigned i = 0; i < BIT_WIDTH; ++i) > Insn[i] = bitFromBits(Bits, i); > @@ -1558,7 +1559,7 @@ > const StringRef Name = Def.getName(); > uint8_t Form = getByteField(Def, "Form"); > > - BitsInit &Bits = getBitsField(Def, "Inst"); > + const BitsInit &Bits = getBitsField(Def, "Inst"); > > // If all the bit positions are not specified; do not decode this instruction. > // We are bound to fail! For proper disassembly, the well-known encoding bits > > Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -869,7 +869,7 @@ > int SubOpIdx) { > Record *Rec = OI.Rec; > if (SubOpIdx != -1) > - Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); > + Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); > > if (Rec->isSubClassOf("RegisterOperand")) { > // RegisterOperand may have an associated ParserMatchClass. If it does, > @@ -879,7 +879,7 @@ > throw "Record `" + Rec->getName() + > "' does not have a ParserMatchClass!\n"; > > - if (DefInit *DI= dynamic_cast(R->getValue())) { > + if (const DefInit *DI= dynamic_cast(R->getValue())) { > Record *MatchClass = DI->getDef(); > if (ClassInfo *CI = AsmOperandClasses[MatchClass]) > return CI; > @@ -1046,9 +1046,9 @@ > ClassInfo *CI = AsmOperandClasses[*it]; > CI->Kind = ClassInfo::UserClass0 + Index; > > - ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); > + const ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); > for (unsigned i = 0, e = Supers->getSize(); i != e; ++i) { > - DefInit *DI = dynamic_cast(Supers->getElement(i)); > + const DefInit *DI = dynamic_cast(Supers->getElement(i)); > if (!DI) { > PrintError((*it)->getLoc(), "Invalid super class reference!"); > continue; > @@ -1065,28 +1065,28 @@ > CI->ValueName = (*it)->getName(); > > // Get or construct the predicate method name. > - Init *PMName = (*it)->getValueInit("PredicateMethod"); > - if (StringInit *SI = dynamic_cast(PMName)) { > + const Init *PMName = (*it)->getValueInit("PredicateMethod"); > + if (const StringInit *SI = dynamic_cast(PMName)) { > CI->PredicateMethod = SI->getValue(); > } else { > - assert(dynamic_cast(PMName) && > + assert(dynamic_cast(PMName) && > "Unexpected PredicateMethod field!"); > CI->PredicateMethod = "is" + CI->ClassName; > } > > // Get or construct the render method name. > - Init *RMName = (*it)->getValueInit("RenderMethod"); > - if (StringInit *SI = dynamic_cast(RMName)) { > + const Init *RMName = (*it)->getValueInit("RenderMethod"); > + if (const StringInit *SI = dynamic_cast(RMName)) { > CI->RenderMethod = SI->getValue(); > } else { > - assert(dynamic_cast(RMName) && > + assert(dynamic_cast(RMName) && > "Unexpected RenderMethod field!"); > CI->RenderMethod = "add" + CI->ClassName + "Operands"; > } > > // Get the parse method name or leave it as empty. > - Init *PRMName = (*it)->getValueInit("ParserMethod"); > - if (StringInit *SI = dynamic_cast(PRMName)) > + const Init *PRMName = (*it)->getValueInit("ParserMethod"); > + if (const StringInit *SI = dynamic_cast(PRMName)) > CI->ParserMethod = SI->getValue(); > > AsmOperandClasses[*it] = CI; > > Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -40,7 +40,7 @@ > > > void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) { > - ListInit *CCActions = CC->getValueAsListInit("Actions"); > + const ListInit *CCActions = CC->getValueAsListInit("Actions"); > Counter = 0; > > O << "\n\nstatic bool " << CC->getName() > @@ -67,7 +67,7 @@ > O << IndentStr << "if ("; > > if (Action->isSubClassOf("CCIfType")) { > - ListInit *VTs = Action->getValueAsListInit("VTs"); > + const ListInit *VTs = Action->getValueAsListInit("VTs"); > for (unsigned i = 0, e = VTs->getSize(); i != e; ++i) { > Record *VT = VTs->getElementAsRecord(i); > if (i != 0) O << " ||\n " << IndentStr; > @@ -91,7 +91,7 @@ > << "(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n" > << IndentStr << " return false;\n"; > } else if (Action->isSubClassOf("CCAssignToReg")) { > - ListInit *RegList = Action->getValueAsListInit("RegList"); > + const ListInit *RegList = Action->getValueAsListInit("RegList"); > if (RegList->getSize() == 1) { > O << IndentStr << "if (unsigned Reg = State.AllocateReg("; > O << getQualifiedName(RegList->getElementAsRecord(0)) << ")) {\n"; > @@ -112,8 +112,8 @@ > O << IndentStr << " return false;\n"; > O << IndentStr << "}\n"; > } else if (Action->isSubClassOf("CCAssignToRegWithShadow")) { > - ListInit *RegList = Action->getValueAsListInit("RegList"); > - ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); > + const ListInit *RegList = Action->getValueAsListInit("RegList"); > + const ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); > if (ShadowRegList->getSize() >0 && > ShadowRegList->getSize() != RegList->getSize()) > throw "Invalid length of list of shadowed registers"; > > Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -21,17 +21,19 @@ > > static const std::vector > getValueAsListOfStrings(Record &R, StringRef FieldName) { > - ListInit *List = R.getValueAsListInit(FieldName); > + const ListInit *List = R.getValueAsListInit(FieldName); > assert (List && "Got a null ListInit"); > > std::vector Strings; > Strings.reserve(List->getSize()); > > - for (ListInit::iterator i = List->begin(), e = List->end(); i != e; ++i) { > + for (ListInit::const_iterator i = List->begin(), e = List->end(); > + i != e; > + ++i) { > assert(*i && "Got a null element in a ListInit"); > - if (StringInit *S = dynamic_cast(*i)) > + if (const StringInit *S = dynamic_cast(*i)) > Strings.push_back(S->getValue()); > - else if (CodeInit *C = dynamic_cast(*i)) > + else if (const CodeInit *C = dynamic_cast(*i)) > Strings.push_back(C->getValue()); > else > assert(false && "Got a non-string, non-code element in a ListInit"); > > Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -74,7 +74,8 @@ > static std::string getDiagnosticCategory(const Record *R, > DiagGroupParentMap &DiagGroupParents) { > // If the diagnostic is in a group, and that group has a category, use it. > - if (DefInit *Group = dynamic_cast(R->getValueInit("Group"))) { > + if (const DefInit *Group = > + dynamic_cast(R->getValueInit("Group"))) { > // Check the diagnostic's diag group for a category. > std::string CatName = getCategoryFromDiagGroup(Group->getDef(), > DiagGroupParents); > @@ -159,7 +160,8 @@ > OS.write_escaped(R.getValueAsString("Text")) << '"'; > > // Warning associated with the diagnostic. > - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) { > + if (const DefInit *DI = > + dynamic_cast(R.getValueInit("Group"))) { > OS << ", \""; > OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; > } else { > @@ -225,7 +227,7 @@ > Records.getAllDerivedDefinitions("Diagnostic"); > for (unsigned i = 0, e = Diags.size(); i != e; ++i) { > const Record *R = Diags[i]; > - DefInit *DI = dynamic_cast(R->getValueInit("Group")); > + const DefInit *DI = dynamic_cast(R->getValueInit("Group")); > if (DI == 0) continue; > std::string GroupName = DI->getDef()->getValueAsString("GroupName"); > DiagsInGroup[GroupName].DiagsInGroup.push_back(R); > > Modified: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -28,7 +28,8 @@ > if (R.getValueAsBit("Hidden")) > return true; > // Not declared as hidden, check the parent package if it is hidden. > - if (DefInit *DI = dynamic_cast(R.getValueInit("ParentPackage"))) > + if (const DefInit *DI = > + dynamic_cast(R.getValueInit("ParentPackage"))) > return isHidden(*DI->getDef()); > > return false; > @@ -42,7 +43,8 @@ > > static std::string getParentPackageFullName(const Record *R) { > std::string name; > - if (DefInit *DI = dynamic_cast(R->getValueInit("ParentPackage"))) > + if (const DefInit *DI = > + dynamic_cast(R->getValueInit("ParentPackage"))) > name = getPackageFullName(DI->getDef()); > return name; > } > @@ -63,8 +65,8 @@ > } > > static std::string getStringValue(const Record &R, StringRef field) { > - if (StringInit * > - SI = dynamic_cast(R.getValueInit(field))) > + if (const StringInit * > + SI = dynamic_cast(R.getValueInit(field))) > return SI->getValue(); > return std::string(); > } > @@ -129,8 +131,8 @@ > for (unsigned i = 0, e = checkers.size(); i != e; ++i) { > Record *R = checkers[i]; > Record *package = 0; > - if (DefInit * > - DI = dynamic_cast(R->getValueInit("ParentPackage"))) > + if (const DefInit * > + DI = dynamic_cast(R->getValueInit("ParentPackage"))) > package = DI->getDef(); > if (!isCheckerNamed(R) && !package) > throw "Checker '" + R->getName() + "' is neither named, nor in a package!"; > @@ -149,21 +151,23 @@ > Record *currR = isCheckerNamed(R) ? R : package; > // Insert the checker and its parent packages into the subgroups set of > // the corresponding parent package. > - while (DefInit *DI > - = dynamic_cast(currR->getValueInit("ParentPackage"))) { > + while (const DefInit *DI = > + dynamic_cast(currR->getValueInit("ParentPackage"))) { > Record *parentPackage = DI->getDef(); > recordGroupMap[parentPackage]->SubGroups.insert(currR); > currR = parentPackage; > } > // Insert the checker into the set of its group. > - if (DefInit *DI = dynamic_cast(R->getValueInit("Group"))) > + if (const DefInit *DI = > + dynamic_cast(R->getValueInit("Group"))) > recordGroupMap[DI->getDef()]->Checkers.insert(R); > } > > // If a package is in group, add all its checkers and its sub-packages > // checkers into the group. > for (unsigned i = 0, e = packages.size(); i != e; ++i) > - if (DefInit *DI = dynamic_cast(packages[i]->getValueInit("Group"))) > + if (const DefInit *DI = > + dynamic_cast(packages[i]->getValueInit("Group"))) > addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap); > > typedef std::map SortedRecords; > @@ -204,7 +208,8 @@ > OS << "PACKAGE(" << "\""; > OS.write_escaped(getPackageFullName(&R)) << "\", "; > // Group index > - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > + if (const DefInit *DI = > + dynamic_cast(R.getValueInit("Group"))) > OS << groupToSortIndex[DI->getDef()] << ", "; > else > OS << "-1, "; > @@ -232,7 +237,8 @@ > OS << "\""; > OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; > // Group index > - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > + if (const DefInit *DI = > + dynamic_cast(R.getValueInit("Group"))) > OS << groupToSortIndex[DI->getDef()] << ", "; > else > OS << "-1, "; > > Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) > +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Mon Jul 11 13:25:51 2011 > @@ -38,21 +38,25 @@ > R->getValueAsBit("isPseudo")) > continue; > > - BitsInit *BI = R->getValueAsBitsInit("Inst"); > + const BitsInit *BI = R->getValueAsBitsInit("Inst"); > > unsigned numBits = BI->getNumBits(); > - BitsInit *NewBI = new BitsInit(numBits); > + > + SmallVector NewBits(numBits); > + > for (unsigned bit = 0, end = numBits / 2; bit != end; ++bit) { > unsigned bitSwapIdx = numBits - bit - 1; > - Init *OrigBit = BI->getBit(bit); > - Init *BitSwap = BI->getBit(bitSwapIdx); > - NewBI->setBit(bit, BitSwap); > - NewBI->setBit(bitSwapIdx, OrigBit); > + const Init *OrigBit = BI->getBit(bit); > + const Init *BitSwap = BI->getBit(bitSwapIdx); > + NewBits[bit] = BitSwap; > + NewBits[bitSwapIdx] = OrigBit; > } > if (numBits % 2) { > unsigned middle = (numBits + 1) / 2; > - NewBI->setBit(middle, BI->getBit(middle)); > + NewBits[middle] = BI->getBit(middle); > } > + > + const BitsInit *NewBI = BitsInit::Create(NewBits.begin(), NewBits.end()); > > // Update the bits in reversed order so that emitInstrOpBits will get the > // correct endianness. > @@ -63,12 +67,14 @@ > // If the VarBitInit at position 'bit' matches the specified variable then > // return the variable bit position. Otherwise return -1. > int CodeEmitterGen::getVariableBit(const std::string &VarName, > - BitsInit *BI, int bit) { > - if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { > - if (VarInit *VI = dynamic_cast(VBI->getVariable())) > + const BitsInit *BI, int bit) { > + if (const VarBitInit *VBI = > + dynamic_cast(BI->getBit(bit))) { > + if (const VarInit *VI = dynamic_cast(VBI->getVariable())) > if (VI->getName() == VarName) > return VBI->getBitNum(); > - } else if (VarInit *VI = dynamic_cast(BI->getBit(bit))) { > + } else if (const VarInit *VI = > + dynamic_cast(BI->getBit(bit))) { > if (VI->getName() == VarName) > return 0; > } > @@ -77,8 +83,8 @@ > } > > void CodeEmitterGen:: > -AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, > - unsigned &NumberedOp, > +AddCodeToMergeInOperand(Record *R, const BitsInit *BI, > + const std::string &VarName, unsigned &NumberedOp, > std::string &Case, CodeGenTarget &Target) { > CodeGenInstruction &CGI = Target.getInstruction(R); > > @@ -181,7 +187,7 @@ > CodeGenTarget &Target) { > std::string Case; > > - BitsInit *BI = R->getValueAsBitsInit("Inst"); > + const BitsInit *BI = R->getValueAsBitsInit("Inst"); > const std::vector &Vals = R->getValues(); > unsigned NumberedOp = 0; > > @@ -238,12 +244,12 @@ > continue; > } > > - BitsInit *BI = R->getValueAsBitsInit("Inst"); > + const BitsInit *BI = R->getValueAsBitsInit("Inst"); > > // Start by filling in fixed values. > unsigned Value = 0; > for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) { > - if (BitInit *B = dynamic_cast(BI->getBit(e-i-1))) > + if (const BitInit *B = dynamic_cast(BI->getBit(e-i-1))) > Value |= B->getValue() << (e-i-1); > } > o << " " << Value << "U," << '\t' << "// " << R->getName() << "\n"; > > Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeEmitterGen.h (original) > +++ llvm/trunk/utils/TableGen/CodeEmitterGen.h Mon Jul 11 13:25:51 2011 > @@ -35,11 +35,11 @@ > void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace); > void emitGetValueBit(raw_ostream &o, const std::string &Namespace); > void reverseBits(std::vector &Insts); > - int getVariableBit(const std::string &VarName, BitsInit *BI, int bit); > + int getVariableBit(const std::string &VarName, const BitsInit *BI, int bit); > std::string getInstructionCase(Record *R, CodeGenTarget &Target); > void > - AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, > - unsigned &NumberedOp, > + AddCodeToMergeInOperand(Record *R, const BitsInit *BI, > + const std::string &VarName, unsigned &NumberedOp, > std::string &Case, CodeGenTarget &Target); > > }; > > Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) > +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Mon Jul 11 13:25:51 2011 > @@ -583,7 +583,7 @@ > > static void FindDepVarsOf(TreePatternNode *N, DepVarMap &DepMap) { > if (N->isLeaf()) { > - if (dynamic_cast(N->getLeafValue()) != NULL) > + if (dynamic_cast(N->getLeafValue()) != NULL) > DepMap[N->getName()]++; > } else { > for (size_t i = 0, e = N->getNumChildren(); i != e; ++i) > @@ -692,7 +692,7 @@ > unsigned Size = 3; // The node itself. > // If the root node is a ConstantSDNode, increases its size. > // e.g. (set R32:$dst, 0). > - if (P->isLeaf() && dynamic_cast(P->getLeafValue())) > + if (P->isLeaf() && dynamic_cast(P->getLeafValue())) > Size += 2; > > // FIXME: This is a hack to statically increase the priority of patterns > @@ -716,7 +716,7 @@ > Child->getType(0) != MVT::Other) > Size += getPatternSize(Child, CGP); > else if (Child->isLeaf()) { > - if (dynamic_cast(Child->getLeafValue())) > + if (dynamic_cast(Child->getLeafValue())) > Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2). > else if (Child->getComplexPatternInfo(CGP)) > Size += getPatternSize(Child, CGP); > @@ -742,7 +742,8 @@ > std::string PatternToMatch::getPredicateCheck() const { > std::string PredicateCheck; > for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) { > - if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { > + if (const DefInit *Pred = > + dynamic_cast(Predicates->getElement(i))) { > Record *Def = Pred->getDef(); > if (!Def->isSubClassOf("Predicate")) { > #ifndef NDEBUG > @@ -866,12 +867,13 @@ > // The NodeToApply must be a leaf node that is a VT. OtherOperandNum must > // have an integer type that is smaller than the VT. > if (!NodeToApply->isLeaf() || > - !dynamic_cast(NodeToApply->getLeafValue()) || > - !static_cast(NodeToApply->getLeafValue())->getDef() > + !dynamic_cast(NodeToApply->getLeafValue()) || > + !static_cast(NodeToApply->getLeafValue())->getDef() > ->isSubClassOf("ValueType")) > TP.error(N->getOperator()->getName() + " expects a VT operand!"); > MVT::SimpleValueType VT = > - getValueType(static_cast(NodeToApply->getLeafValue())->getDef()); > + getValueType(static_cast(NodeToApply->getLeafValue()) > + ->getDef()); > > EEVT::TypeSet TypeListTmp(VT, TP); > > @@ -1021,10 +1023,10 @@ > return PFRec->getOnlyTree()->getNumTypes(); > > // Get the result tree. > - DagInit *Tree = Operator->getValueAsDag("Fragment"); > + const DagInit *Tree = Operator->getValueAsDag("Fragment"); > Record *Op = 0; > - if (Tree && dynamic_cast(Tree->getOperator())) > - Op = dynamic_cast(Tree->getOperator())->getDef(); > + if (Tree && dynamic_cast(Tree->getOperator())) > + Op = dynamic_cast(Tree->getOperator())->getDef(); > assert(Op && "Invalid Fragment"); > return GetNumNodeResults(Op, CDP); > } > @@ -1098,8 +1100,8 @@ > return false; > > if (isLeaf()) { > - if (DefInit *DI = dynamic_cast(getLeafValue())) { > - if (DefInit *NDI = dynamic_cast(N->getLeafValue())) { > + if (const DefInit *DI = dynamic_cast(getLeafValue())) { > + if (const DefInit *NDI = dynamic_cast(N->getLeafValue())) { > return ((DI->getDef() == NDI->getDef()) > && (DepVars.find(getName()) == DepVars.end() > || getName() == N->getName())); > @@ -1155,9 +1157,9 @@ > for (unsigned i = 0, e = getNumChildren(); i != e; ++i) { > TreePatternNode *Child = getChild(i); > if (Child->isLeaf()) { > - Init *Val = Child->getLeafValue(); > - if (dynamic_cast(Val) && > - static_cast(Val)->getDef()->getName() == "node") { > + const Init *Val = Child->getLeafValue(); > + if (dynamic_cast(Val) && > + static_cast(Val)->getDef()->getName() == "node") { > // We found a use of a formal argument, replace it with its value. > TreePatternNode *NewChild = ArgMap[Child->getName()]; > assert(NewChild && "Couldn't find formal argument!"); > @@ -1319,7 +1321,7 @@ > return 0; > > unsigned IID = > - dynamic_cast(getChild(0)->getLeafValue())->getValue(); > + dynamic_cast(getChild(0)->getLeafValue())->getValue(); > return &CDP.getIntrinsicInfo(IID); > } > > @@ -1329,7 +1331,7 @@ > TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const { > if (!isLeaf()) return 0; > > - DefInit *DI = dynamic_cast(getLeafValue()); > + const DefInit *DI = dynamic_cast(getLeafValue()); > if (DI && DI->getDef()->isSubClassOf("ComplexPattern")) > return &CGP.getComplexPattern(DI->getDef()); > return 0; > @@ -1382,7 +1384,7 @@ > bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { > CodeGenDAGPatterns &CDP = TP.getDAGPatterns(); > if (isLeaf()) { > - if (DefInit *DI = dynamic_cast(getLeafValue())) { > + if (const DefInit *DI = dynamic_cast(getLeafValue())) { > // If it's a regclass or something else known, include the type. > bool MadeChange = false; > for (unsigned i = 0, e = Types.size(); i != e; ++i) > @@ -1391,7 +1393,7 @@ > return MadeChange; > } > > - if (IntInit *II = dynamic_cast(getLeafValue())) { > + if (const IntInit *II = dynamic_cast(getLeafValue())) { > assert(Types.size() == 1 && "Invalid IntInit"); > > // Int inits are always integers. :) > @@ -1651,7 +1653,7 @@ > static bool OnlyOnRHSOfCommutative(TreePatternNode *N) { > if (!N->isLeaf() && N->getOperator()->getName() == "imm") > return true; > - if (N->isLeaf() && dynamic_cast(N->getLeafValue())) > + if (N->isLeaf() && dynamic_cast(N->getLeafValue())) > return true; > return false; > } > @@ -1701,14 +1703,14 @@ > // TreePattern implementation > // > > -TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, > +TreePattern::TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, > CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ > isInputPattern = isInput; > for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i) > Trees.push_back(ParseTreePattern(RawPat->getElement(i), "")); > } > > -TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput, > +TreePattern::TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, > CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ > isInputPattern = isInput; > Trees.push_back(ParseTreePattern(Pat, "")); > @@ -1739,16 +1741,17 @@ > } > > > -TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){ > - if (DefInit *DI = dynamic_cast(TheInit)) { > +TreePatternNode *TreePattern::ParseTreePattern(const Init *TheInit, > + StringRef OpName){ > + if (const DefInit *DI = dynamic_cast(TheInit)) { > Record *R = DI->getDef(); > > // Direct reference to a leaf DagNode or PatFrag? Turn it into a > // TreePatternNode of its own. For example: > /// (foo GPR, imm) -> (foo GPR, (imm)) > if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) > - return ParseTreePattern(new DagInit(DI, "", > - std::vector >()), > + return ParseTreePattern(DagInit::Create(DI, "", > + std::vector >()), > OpName); > > // Input argument? > @@ -1763,26 +1766,26 @@ > return Res; > } > > - if (IntInit *II = dynamic_cast(TheInit)) { > + if (const IntInit *II = dynamic_cast(TheInit)) { > if (!OpName.empty()) > error("Constant int argument should not have a name!"); > return new TreePatternNode(II, 1); > } > > - if (BitsInit *BI = dynamic_cast(TheInit)) { > + if (const BitsInit *BI = dynamic_cast(TheInit)) { > // Turn this into an IntInit. > - Init *II = BI->convertInitializerTo(new IntRecTy()); > - if (II == 0 || !dynamic_cast(II)) > + const Init *II = BI->convertInitializerTo(new IntRecTy()); > + if (II == 0 || !dynamic_cast(II)) > error("Bits value must be constants!"); > return ParseTreePattern(II, OpName); > } > > - DagInit *Dag = dynamic_cast(TheInit); > + const DagInit *Dag = dynamic_cast(TheInit); > if (!Dag) { > TheInit->dump(); > error("Pattern has unexpected init kind!"); > } > - DefInit *OpDef = dynamic_cast(Dag->getOperator()); > + const DefInit *OpDef = dynamic_cast(Dag->getOperator()); > if (!OpDef) error("Pattern has unexpected operator type!"); > Record *Operator = OpDef->getDef(); > > @@ -1860,7 +1863,7 @@ > else // Otherwise, no chain. > Operator = getDAGPatterns().get_intrinsic_wo_chain_sdnode(); > > - TreePatternNode *IIDNode = new TreePatternNode(new IntInit(IID), 1); > + TreePatternNode *IIDNode = new TreePatternNode(IntInit::Create(IID), 1); > Children.insert(Children.begin(), IIDNode); > } > > @@ -1947,7 +1950,8 @@ > // us to match things like: > // def : Pat<(v1i64 (bitconvert(v2i32 DPR:$src))), (v1i64 DPR:$src)>; > if (Nodes[i] == Trees[0] && Nodes[i]->isLeaf()) { > - DefInit *DI = dynamic_cast(Nodes[i]->getLeafValue()); > + const DefInit *DI = > + dynamic_cast(Nodes[i]->getLeafValue()); > if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || > DI->getDef()->isSubClassOf("RegisterOperand"))) > continue; > @@ -2096,7 +2100,7 @@ > > // First step, parse all of the fragments. > for (unsigned i = 0, e = Fragments.size(); i != e; ++i) { > - DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); > + const DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); > TreePattern *P = new TreePattern(Fragments[i], Tree, true, *this); > PatternFragments[Fragments[i]] = P; > > @@ -2108,8 +2112,8 @@ > P->error("Cannot have unnamed 'node' values in pattern fragment!"); > > // Parse the operands list. > - DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); > - DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); > + const DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); > + const DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); > // Special cases: ops == outs == ins. Different names are used to > // improve readability. > if (!OpsOp || > @@ -2121,8 +2125,8 @@ > // Copy over the arguments. > Args.clear(); > for (unsigned j = 0, e = OpsList->getNumArgs(); j != e; ++j) { > - if (!dynamic_cast(OpsList->getArg(j)) || > - static_cast(OpsList->getArg(j))-> > + if (!dynamic_cast(OpsList->getArg(j)) || > + static_cast(OpsList->getArg(j))-> > getDef()->getName() != "node") > P->error("Operands list should all be 'node' values."); > if (OpsList->getArgName(j).empty()) > @@ -2180,19 +2184,19 @@ > > // Find some SDNode. > assert(!SDNodes.empty() && "No SDNodes parsed?"); > - Init *SomeSDNode = new DefInit(SDNodes.begin()->first); > + const Init *SomeSDNode = DefInit::Create(SDNodes.begin()->first); > > for (unsigned iter = 0; iter != 2; ++iter) { > for (unsigned i = 0, e = DefaultOps[iter].size(); i != e; ++i) { > - DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); > + const DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); > > // Clone the DefaultInfo dag node, changing the operator from 'ops' to > // SomeSDnode so that we can parse this. > - std::vector > Ops; > + std::vector > Ops; > for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op) > Ops.push_back(std::make_pair(DefaultInfo->getArg(op), > DefaultInfo->getArgName(op))); > - DagInit *DI = new DagInit(SomeSDNode, "", Ops); > + const DagInit *DI = DagInit::Create(SomeSDNode, "", Ops); > > // Create a TreePattern to parse this. > TreePattern P(DefaultOps[iter][i], DI, false, *this); > @@ -2231,7 +2235,7 @@ > // No name -> not interesting. > if (Pat->getName().empty()) { > if (Pat->isLeaf()) { > - DefInit *DI = dynamic_cast(Pat->getLeafValue()); > + const DefInit *DI = dynamic_cast(Pat->getLeafValue()); > if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || > DI->getDef()->isSubClassOf("RegisterOperand"))) > I->error("Input " + DI->getDef()->getName() + " must be named!"); > @@ -2241,7 +2245,7 @@ > > Record *Rec; > if (Pat->isLeaf()) { > - DefInit *DI = dynamic_cast(Pat->getLeafValue()); > + const DefInit *DI = dynamic_cast(Pat->getLeafValue()); > if (!DI) I->error("Input $" + Pat->getName() + " must be an identifier!"); > Rec = DI->getDef(); > } else { > @@ -2259,7 +2263,7 @@ > } > Record *SlotRec; > if (Slot->isLeaf()) { > - SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); > + SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); > } else { > assert(Slot->getNumChildren() == 0 && "can't be a use with children!"); > SlotRec = Slot->getOperator(); > @@ -2294,7 +2298,7 @@ > if (!Dest->isLeaf()) > I->error("implicitly defined value should be a register!"); > > - DefInit *Val = dynamic_cast(Dest->getLeafValue()); > + const DefInit *Val = dynamic_cast(Dest->getLeafValue()); > if (!Val || !Val->getDef()->isSubClassOf("Register")) > I->error("implicitly defined value should be a register!"); > InstImpResults.push_back(Val->getDef()); > @@ -2335,7 +2339,7 @@ > if (!Dest->isLeaf()) > I->error("set destination should be a register!"); > > - DefInit *Val = dynamic_cast(Dest->getLeafValue()); > + const DefInit *Val = dynamic_cast(Dest->getLeafValue()); > if (!Val) > I->error("set destination should be a register!"); > > @@ -2401,7 +2405,7 @@ > return false; > > const TreePatternNode *N0 = N->getChild(0); > - if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) > + if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) > return false; > > const TreePatternNode *N1 = N->getChild(1); > @@ -2418,7 +2422,7 @@ > > void AnalyzeNode(const TreePatternNode *N) { > if (N->isLeaf()) { > - if (DefInit *DI = dynamic_cast(N->getLeafValue())) { > + if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { > Record *LeafRec = DI->getDef(); > // Handle ComplexPattern leaves. > if (LeafRec->isSubClassOf("ComplexPattern")) { > @@ -2525,9 +2529,9 @@ > std::vector Instrs = Records.getAllDerivedDefinitions("Instruction"); > > for (unsigned i = 0, e = Instrs.size(); i != e; ++i) { > - ListInit *LI = 0; > + const ListInit *LI = 0; > > - if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) > + if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) > LI = Instrs[i]->getValueAsListInit("Pattern"); > > // If there is no pattern, only collect minimal information about the > @@ -2619,7 +2623,7 @@ > > if (i == 0) > Res0Node = RNode; > - Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); > + Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); > if (R == 0) > I->error("Operand $" + OpName + " should be a set destination: all " > "outputs must occur before inputs in operand list!"); > @@ -2664,8 +2668,8 @@ > InstInputsCheck.erase(OpName); // It occurred, remove from map. > > if (InVal->isLeaf() && > - dynamic_cast(InVal->getLeafValue())) { > - Record *InRec = static_cast(InVal->getLeafValue())->getDef(); > + dynamic_cast(InVal->getLeafValue())) { > + Record *InRec = static_cast(InVal->getLeafValue())->getDef(); > if (Op.Rec != InRec && !InRec->isSubClassOf("ComplexPattern")) > I->error("Operand $" + OpName + "'s register class disagrees" > " between the operand and pattern"); > @@ -2865,13 +2869,13 @@ > > for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { > Record *CurPattern = Patterns[i]; > - DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); > + const DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); > TreePattern *Pattern = new TreePattern(CurPattern, Tree, true, *this); > > // Inline pattern fragments into it. > Pattern->InlinePatternFragments(); > > - ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); > + const ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); > if (LI->getSize() == 0) continue; // no pattern. > > // Parse the instruction. > @@ -3183,7 +3187,8 @@ > for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { > TreePatternNode *Child = N->getChild(i); > if (Child->isLeaf()) > - if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { > + if (const DefInit *DI = > + dynamic_cast(Child->getLeafValue())) { > Record *RR = DI->getDef(); > if (RR->isSubClassOf("Register")) > continue; > > Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) > +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Mon Jul 11 13:25:51 2011 > @@ -306,7 +306,7 @@ > > /// Val - The init value (e.g. the "GPRC" record, or "7") for a leaf. > /// > - Init *Val; > + const Init *Val; > > /// Name - The name given to this node with the :$foo notation. > /// > @@ -327,7 +327,7 @@ > : Operator(Op), Val(0), TransformFn(0), Children(Ch) { > Types.resize(NumResults); > } > - TreePatternNode(Init *val, unsigned NumResults) // leaf ctor > + TreePatternNode(const Init *val, unsigned NumResults) // leaf ctor > : Operator(0), Val(val), TransformFn(0) { > Types.resize(NumResults); > } > @@ -358,7 +358,7 @@ > return Types[ResNo].isDynamicallyResolved(); > } > > - Init *getLeafValue() const { assert(isLeaf()); return Val; } > + const Init *getLeafValue() const { assert(isLeaf()); return Val; } > Record *getOperator() const { assert(!isLeaf()); return Operator; } > > unsigned getNumChildren() const { return Children.size(); } > @@ -517,9 +517,9 @@ > > /// TreePattern constructor - Parse the specified DagInits into the > /// current record. > - TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, > + TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, > CodeGenDAGPatterns &ise); > - TreePattern(Record *TheRec, DagInit *Pat, bool isInput, > + TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, > CodeGenDAGPatterns &ise); > TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput, > CodeGenDAGPatterns &ise); > @@ -576,7 +576,7 @@ > void dump() const; > > private: > - TreePatternNode *ParseTreePattern(Init *DI, StringRef OpName); > + TreePatternNode *ParseTreePattern(const Init *DI, StringRef OpName); > void ComputeNamedNodes(); > void ComputeNamedNodes(TreePatternNode *N); > }; > @@ -631,7 +631,7 @@ > /// processed to produce isel. > class PatternToMatch { > public: > - PatternToMatch(Record *srcrecord, ListInit *preds, > + PatternToMatch(Record *srcrecord, const ListInit *preds, > TreePatternNode *src, TreePatternNode *dst, > const std::vector &dstregs, > unsigned complexity, unsigned uid) > @@ -639,7 +639,7 @@ > Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {} > > Record *SrcRecord; // Originating Record for the pattern. > - ListInit *Predicates; // Top level predicate conditions to match. > + const ListInit *Predicates; // Top level predicate conditions to match. > TreePatternNode *SrcPattern; // Source pattern to match. > TreePatternNode *DstPattern; // Resulting pattern. > std::vector Dstregs; // Physical register defs being matched. > @@ -647,7 +647,7 @@ > unsigned ID; // Unique ID for the record. > > Record *getSrcRecord() const { return SrcRecord; } > - ListInit *getPredicates() const { return Predicates; } > + const ListInit *getPredicates() const { return Predicates; } > TreePatternNode *getSrcPattern() const { return SrcPattern; } > TreePatternNode *getDstPattern() const { return DstPattern; } > const std::vector &getDstRegs() const { return Dstregs; } > > Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original) > +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Mon Jul 11 13:25:51 2011 > @@ -30,9 +30,10 @@ > hasOptionalDef = false; > isVariadic = false; > > - DagInit *OutDI = R->getValueAsDag("OutOperandList"); > + const DagInit *OutDI = R->getValueAsDag("OutOperandList"); > > - if (DefInit *Init = dynamic_cast(OutDI->getOperator())) { > + if (const DefInit *Init = > + dynamic_cast(OutDI->getOperator())) { > if (Init->getDef()->getName() != "outs") > throw R->getName() + ": invalid def name for output list: use 'outs'"; > } else > @@ -40,8 +41,8 @@ > > NumDefs = OutDI->getNumArgs(); > > - DagInit *InDI = R->getValueAsDag("InOperandList"); > - if (DefInit *Init = dynamic_cast(InDI->getOperator())) { > + const DagInit *InDI = R->getValueAsDag("InOperandList"); > + if (const DefInit *Init = dynamic_cast(InDI->getOperator())) { > if (Init->getDef()->getName() != "ins") > throw R->getName() + ": invalid def name for input list: use 'ins'"; > } else > @@ -50,7 +51,7 @@ > unsigned MIOperandNo = 0; > std::set OperandNames; > for (unsigned i = 0, e = InDI->getNumArgs()+OutDI->getNumArgs(); i != e; ++i){ > - Init *ArgInit; > + const Init *ArgInit; > std::string ArgName; > if (i < NumDefs) { > ArgInit = OutDI->getArg(i); > @@ -60,7 +61,7 @@ > ArgName = InDI->getArgName(i-NumDefs); > } > > - DefInit *Arg = dynamic_cast(ArgInit); > + const DefInit *Arg = dynamic_cast(ArgInit); > if (!Arg) > throw "Illegal operand for the '" + R->getName() + "' instruction!"; > > @@ -68,7 +69,7 @@ > std::string PrintMethod = "printOperand"; > std::string EncoderMethod; > unsigned NumOps = 1; > - DagInit *MIOpInfo = 0; > + const DagInit *MIOpInfo = 0; > if (Rec->isSubClassOf("RegisterOperand")) { > PrintMethod = Rec->getValueAsString("PrintMethod"); > } else if (Rec->isSubClassOf("Operand")) { > @@ -78,8 +79,8 @@ > MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); > > // Verify that MIOpInfo has an 'ops' root value. > - if (!dynamic_cast(MIOpInfo->getOperator()) || > - dynamic_cast(MIOpInfo->getOperator()) > + if (!dynamic_cast(MIOpInfo->getOperator()) || > + dynamic_cast(MIOpInfo->getOperator()) > ->getDef()->getName() != "ops") > throw "Bad value for MIOperandInfo in operand '" + Rec->getName() + > "'\n"; > @@ -178,7 +179,7 @@ > } > > // Find the suboperand number involved. > - DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; > + const DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; > if (MIOpInfo == 0) > throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; > > @@ -400,12 +401,13 @@ > /// constructor. It checks if an argument in an InstAlias pattern matches > /// the corresponding operand of the instruction. It returns true on a > /// successful match, with ResOp set to the result operand to be used. > -bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, > +bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, > + unsigned AliasOpNo, > Record *InstOpRec, bool hasSubOps, > SMLoc Loc, CodeGenTarget &T, > ResultOperand &ResOp) { > - Init *Arg = Result->getArg(AliasOpNo); > - DefInit *ADI = dynamic_cast(Arg); > + const Init *Arg = Result->getArg(AliasOpNo); > + const DefInit *ADI = dynamic_cast(Arg); > > if (ADI && ADI->getDef() == InstOpRec) { > // If the operand is a record, it must have a name, and the record type > @@ -451,7 +453,7 @@ > return true; > } > > - if (IntInit *II = dynamic_cast(Arg)) { > + if (const IntInit *II = dynamic_cast(Arg)) { > if (hasSubOps || !InstOpRec->isSubClassOf("Operand")) > return false; > // Integer arguments can't have names. > @@ -470,7 +472,7 @@ > Result = R->getValueAsDag("ResultInst"); > > // Verify that the root of the result is an instruction. > - DefInit *DI = dynamic_cast(Result->getOperator()); > + const DefInit *DI = dynamic_cast(Result->getOperator()); > if (DI == 0 || !DI->getDef()->isSubClassOf("Instruction")) > throw TGError(R->getLoc(), "result of inst alias should be an instruction"); > > @@ -480,7 +482,7 @@ > // the same class. > StringMap NameClass; > for (unsigned i = 0, e = Result->getNumArgs(); i != e; ++i) { > - DefInit *ADI = dynamic_cast(Result->getArg(i)); > + const DefInit *ADI = dynamic_cast(Result->getArg(i)); > if (!ADI || Result->getArgName(i).empty()) > continue; > // Verify we don't have something like: (someinst GR16:$foo, GR32:$foo) > @@ -519,11 +521,12 @@ > // If the argument did not match the instruction operand, and the operand > // is composed of multiple suboperands, try matching the suboperands. > if (NumSubOps > 1) { > - DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; > + const DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; > for (unsigned SubOp = 0; SubOp != NumSubOps; ++SubOp) { > if (AliasOpNo >= Result->getNumArgs()) > throw TGError(R->getLoc(), "not enough arguments for instruction!"); > - Record *SubRec = dynamic_cast(MIOI->getArg(SubOp))->getDef(); > + Record *SubRec = > + dynamic_cast(MIOI->getArg(SubOp))->getDef(); > if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false, > R->getLoc(), T, ResOp)) { > ResultOperands.push_back(ResOp); > > Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original) > +++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Mon Jul 11 13:25:51 2011 > @@ -94,7 +94,7 @@ > > /// MIOperandInfo - Default MI operand type. Note an operand may be made > /// up of multiple MI operands. > - DagInit *MIOperandInfo; > + const DagInit *MIOperandInfo; > > /// Constraint info for this operand. This operand can have pieces, so we > /// track constraint info for each. > @@ -102,7 +102,7 @@ > > OperandInfo(Record *R, const std::string &N, const std::string &PMN, > const std::string &EMN, unsigned MION, unsigned MINO, > - DagInit *MIOI) > + const DagInit *MIOI) > : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN), > MIOperandNo(MION), MINumOperands(MINO), MIOperandInfo(MIOI) {} > > @@ -265,7 +265,7 @@ > std::string AsmString; > > /// Result - The result instruction. > - DagInit *Result; > + const DagInit *Result; > > /// ResultInst - The instruction generated by the alias (decoded from > /// Result). > @@ -311,7 +311,7 @@ > > CodeGenInstAlias(Record *R, CodeGenTarget &T); > > - bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, > + bool tryAliasOpMatch(const DagInit *Result, unsigned AliasOpNo, > Record *InstOpRec, bool hasSubOps, SMLoc Loc, > CodeGenTarget &T, ResultOperand &ResOp); > }; > > Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) > +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Mon Jul 11 13:25:51 2011 > @@ -91,14 +91,15 @@ > } > > // Process the composites. > - ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); > + const ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); > for (unsigned i = 0, e = Comps->size(); i != e; ++i) { > - DagInit *Pat = dynamic_cast(Comps->getElement(i)); > + const DagInit *Pat = dynamic_cast(Comps->getElement(i)); > if (!Pat) > throw TGError(TheDef->getLoc(), "Invalid dag '" + > Comps->getElement(i)->getAsString() + > "' in CompositeIndices"); > - DefInit *BaseIdxInit = dynamic_cast(Pat->getOperator()); > + const DefInit *BaseIdxInit = > + dynamic_cast(Pat->getOperator()); > if (!BaseIdxInit || !BaseIdxInit->getDef()->isSubClassOf("SubRegIndex")) > throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + > Pat->getAsString()); > @@ -107,7 +108,7 @@ > CodeGenRegister *R2 = this; > for (DagInit::const_arg_iterator di = Pat->arg_begin(), > de = Pat->arg_end(); di != de; ++di) { > - DefInit *IdxInit = dynamic_cast(*di); > + const DefInit *IdxInit = dynamic_cast(*di); > if (!IdxInit || !IdxInit->getDef()->isSubClassOf("SubRegIndex")) > throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + > Pat->getAsString()); > @@ -163,7 +164,7 @@ > void expand(SetTheory &ST, Record *Def, SetTheory::RecSet &Elts) { > std::vector Indices = Def->getValueAsListOfDefs("SubRegIndices"); > unsigned Dim = Indices.size(); > - ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); > + const ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); > if (Dim != SubRegs->getSize()) > throw TGError(Def->getLoc(), "SubRegIndices and SubRegs size mismatch"); > if (Dim < 2) > @@ -183,19 +184,19 @@ > // Precompute some types. > Record *RegisterCl = Def->getRecords().getClass("Register"); > RecTy *RegisterRecTy = new RecordRecTy(RegisterCl); > - StringInit *BlankName = new StringInit(""); > + const StringInit *BlankName = StringInit::Create(""); > > // Zip them up. > for (unsigned n = 0; n != Length; ++n) { > std::string Name; > Record *Proto = Lists[0][n]; > - std::vector Tuple; > + std::vector Tuple; > unsigned CostPerUse = 0; > for (unsigned i = 0; i != Dim; ++i) { > Record *Reg = Lists[i][n]; > if (i) Name += '_'; > Name += Reg->getName(); > - Tuple.push_back(new DefInit(Reg)); > + Tuple.push_back(DefInit::Create(Reg)); > CostPerUse = std::max(CostPerUse, > unsigned(Reg->getValueAsInt("CostPerUse"))); > } > @@ -216,7 +217,7 @@ > > // Replace the sub-register list with Tuple. > if (RV.getName() == "SubRegs") > - RV.setValue(new ListInit(Tuple, RegisterRecTy)); > + RV.setValue(ListInit::Create(Tuple, RegisterRecTy)); > > // Provide a blank AsmName. MC hacks are required anyway. > if (RV.getName() == "AsmName") > @@ -224,7 +225,7 @@ > > // CostPerUse is aggregated from all Tuple members. > if (RV.getName() == "CostPerUse") > - RV.setValue(new IntInit(CostPerUse)); > + RV.setValue(IntInit::Create(CostPerUse)); > > // Copy fields from the RegisterTuples def. > if (RV.getName() == "SubRegIndices" || > @@ -278,7 +279,7 @@ > Members.insert(RegBank.getReg((*Elements)[i])); > > // Alternative allocation orders may be subsets. > - ListInit *Alts = R->getValueAsListInit("AltOrders"); > + const ListInit *Alts = R->getValueAsListInit("AltOrders"); > AltOrders.resize(Alts->size()); > SetTheory::RecSet Order; > for (unsigned i = 0, e = Alts->size(); i != e; ++i) { > @@ -295,11 +296,11 @@ > } > > // SubRegClasses is a list containing (RC, subregindex, ...) dags. > - ListInit *SRC = R->getValueAsListInit("SubRegClasses"); > + const ListInit *SRC = R->getValueAsListInit("SubRegClasses"); > for (ListInit::const_iterator i = SRC->begin(), e = SRC->end(); i != e; ++i) { > - DagInit *DAG = dynamic_cast(*i); > + const DagInit *DAG = dynamic_cast(*i); > if (!DAG) throw "SubRegClasses must contain DAGs"; > - DefInit *DAGOp = dynamic_cast(DAG->getOperator()); > + const DefInit *DAGOp = dynamic_cast(DAG->getOperator()); > Record *RCRec; > if (!DAGOp || !(RCRec = DAGOp->getDef())->isSubClassOf("RegisterClass")) > throw "Operator '" + DAG->getOperator()->getAsString() + > @@ -307,7 +308,7 @@ > // Iterate over args, all SubRegIndex instances. > for (DagInit::const_arg_iterator ai = DAG->arg_begin(), ae = DAG->arg_end(); > ai != ae; ++ai) { > - DefInit *Idx = dynamic_cast(*ai); > + const DefInit *Idx = dynamic_cast(*ai); > Record *IdxRec; > if (!Idx || !(IdxRec = Idx->getDef())->isSubClassOf("SubRegIndex")) > throw "Argument '" + (*ai)->getAsString() + > > Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original) > +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Mon Jul 11 13:25:51 2011 > @@ -402,7 +402,7 @@ > > // Parse the list of return types. > std::vector OverloadedVTs; > - ListInit *TypeList = R->getValueAsListInit("RetTypes"); > + const ListInit *TypeList = R->getValueAsListInit("RetTypes"); > for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { > Record *TyEl = TypeList->getElementAsRecord(i); > assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); > @@ -470,7 +470,7 @@ > } > > // Parse the intrinsic properties. > - ListInit *PropList = R->getValueAsListInit("Properties"); > + const ListInit *PropList = R->getValueAsListInit("Properties"); > for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { > Record *Property = PropList->getElementAsRecord(i); > assert(Property->isSubClassOf("IntrinsicProperty") && > > Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) > +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Mon Jul 11 13:25:51 2011 > @@ -203,7 +203,7 @@ > assert(N->isLeaf() && "Not a leaf?"); > > // Direct match against an integer constant. > - if (IntInit *II = dynamic_cast(N->getLeafValue())) { > + if (const IntInit *II = dynamic_cast(N->getLeafValue())) { > // If this is the root of the dag we're matching, we emit a redundant opcode > // check to ensure that this gets folded into the normal top-level > // OpcodeSwitch. > @@ -215,7 +215,7 @@ > return AddMatcher(new CheckIntegerMatcher(II->getValue())); > } > > - DefInit *DI = dynamic_cast(N->getLeafValue()); > + const DefInit *DI = dynamic_cast(N->getLeafValue()); > if (DI == 0) { > errs() << "Unknown leaf kind: " << *DI << "\n"; > abort(); > @@ -283,7 +283,8 @@ > N->getOperator()->getName() == "or") && > N->getChild(1)->isLeaf() && N->getChild(1)->getPredicateFns().empty() && > N->getPredicateFns().empty()) { > - if (IntInit *II = dynamic_cast(N->getChild(1)->getLeafValue())) { > + if (const IntInit *II = > + dynamic_cast(N->getChild(1)->getLeafValue())) { > if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. > // If this is at the root of the pattern, we emit a redundant > // CheckOpcode so that the following checks get factored properly under > @@ -496,7 +497,7 @@ > --RecNodeEntry; // Entries in VariableMap are biased. > > const ComplexPattern &CP = > - CGP.getComplexPattern(((DefInit*)N->getLeafValue())->getDef()); > + CGP.getComplexPattern(((const DefInit*)N->getLeafValue())->getDef()); > > // Emit a CheckComplexPat operation, which does the match (aborting if it > // fails) and pushes the matched operands onto the recorded nodes list. > @@ -572,14 +573,14 @@ > SmallVectorImpl &ResultOps) { > assert(N->isLeaf() && "Must be a leaf"); > > - if (IntInit *II = dynamic_cast(N->getLeafValue())) { > + if (const IntInit *II = dynamic_cast(N->getLeafValue())) { > AddMatcher(new EmitIntegerMatcher(II->getValue(), N->getType(0))); > ResultOps.push_back(NextRecordedOperandNo++); > return; > } > > // If this is an explicit register reference, handle it. > - if (DefInit *DI = dynamic_cast(N->getLeafValue())) { > + if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { > Record *Def = DI->getDef(); > if (Def->isSubClassOf("Register")) { > const CodeGenRegister *Reg = > > Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -241,7 +241,7 @@ > if (Op->getType(0) != VT) > return false; > > - DefInit *OpDI = dynamic_cast(Op->getLeafValue()); > + const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); > if (!OpDI) > return false; > Record *OpLeafRec = OpDI->getDef(); > @@ -401,12 +401,12 @@ > if (!Op->isLeaf()) > return PhysReg; > > - DefInit *OpDI = dynamic_cast(Op->getLeafValue()); > + const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); > Record *OpLeafRec = OpDI->getDef(); > if (!OpLeafRec->isSubClassOf("Register")) > return PhysReg; > > - PhysReg += static_cast(OpLeafRec->getValue( \ > + PhysReg += static_cast(OpLeafRec->getValue( \ > "Namespace")->getValue())->getValue(); > PhysReg += "::"; > PhysReg += Target.getRegBank().getReg(OpLeafRec)->getName(); > @@ -468,7 +468,7 @@ > // a bit too complicated for now. > if (!Dst->getChild(1)->isLeaf()) continue; > > - DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); > + const DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); > if (SR) > SubRegNo = getQualifiedName(SR->getDef()); > else > > Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -48,15 +48,15 @@ > static int Value(bit_value_t V) { > return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); > } > -static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { > - if (BitInit *bit = dynamic_cast(bits.getBit(index))) > +static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { > + if (const BitInit *bit = dynamic_cast(bits.getBit(index))) > return bit->getValue() ? BIT_TRUE : BIT_FALSE; > > // The bit is uninitialized. > return BIT_UNSET; > } > // Prints the bit value for each position. > -static void dumpBits(raw_ostream &o, BitsInit &bits) { > +static void dumpBits(raw_ostream &o, const BitsInit &bits) { > unsigned index; > > for (index = bits.getNumBits(); index > 0; index--) { > @@ -76,8 +76,8 @@ > } > } > > -static BitsInit &getBitsField(const Record &def, const char *str) { > - BitsInit *bits = def.getValueAsBitsInit(str); > +static const BitsInit &getBitsField(const Record &def, const char *str) { > + const BitsInit *bits = def.getValueAsBitsInit(str); > return *bits; > } > > @@ -279,7 +279,8 @@ > protected: > // Populates the insn given the uid. > void insnWithID(insn_t &Insn, unsigned Opcode) const { > - BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); > + const BitsInit &Bits = > + getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); > > for (unsigned i = 0; i < BIT_WIDTH; ++i) > Insn[i] = bitFromBits(Bits, i); > @@ -1230,7 +1231,7 @@ > Def.getValueAsBit("isCodeGenOnly")) > return false; > > - BitsInit &Bits = getBitsField(Def, "Inst"); > + const BitsInit &Bits = getBitsField(Def, "Inst"); > if (Bits.allInComplete()) return false; > > std::vector InsnOperands; > @@ -1251,16 +1252,16 @@ > // Gather the outputs/inputs of the instruction, so we can find their > // positions in the encoding. This assumes for now that they appear in the > // MCInst in the order that they're listed. > - std::vector > InOutOperands; > - DagInit *Out = Def.getValueAsDag("OutOperandList"); > - DagInit *In = Def.getValueAsDag("InOperandList"); > + std::vector > InOutOperands; > + const DagInit *Out = Def.getValueAsDag("OutOperandList"); > + const DagInit *In = Def.getValueAsDag("InOperandList"); > for (unsigned i = 0; i < Out->getNumArgs(); ++i) > InOutOperands.push_back(std::make_pair(Out->getArg(i), Out->getArgName(i))); > for (unsigned i = 0; i < In->getNumArgs(); ++i) > InOutOperands.push_back(std::make_pair(In->getArg(i), In->getArgName(i))); > > // For each operand, see if we can figure out where it is encoded. > - for (std::vector >::iterator > + for (std::vector >::iterator > NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) { > unsigned PrevBit = ~0; > unsigned Base = ~0; > @@ -1268,10 +1269,10 @@ > std::string Decoder = ""; > > for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) { > - VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); > + const VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); > if (!BI) continue; > > - VarInit *Var = dynamic_cast(BI->getVariable()); > + const VarInit *Var = dynamic_cast(BI->getVariable()); > assert(Var); > unsigned CurrBit = BI->getBitNum(); > if (Var->getName() != NI->second) continue; > @@ -1301,7 +1302,7 @@ > // for decoding register classes. > // FIXME: This need to be extended to handle instructions with custom > // decoder methods, and operands with (simple) MIOperandInfo's. > - TypedInit *TI = dynamic_cast(NI->first); > + const TypedInit *TI = dynamic_cast(NI->first); > RecordRecTy *Type = dynamic_cast(TI->getType()); > Record *TypeRecord = Type->getRecord(); > bool isReg = false; > @@ -1313,8 +1314,8 @@ > } > > RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod"); > - StringInit *String = DecoderString ? > - dynamic_cast(DecoderString->getValue()) : > + const StringInit *String = DecoderString ? > + dynamic_cast(DecoderString->getValue()) : > 0; > if (!isReg && String && String->getValue() != "") > Decoder = String->getValue(); > > Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -61,7 +61,7 @@ > // registers in their multi-operand operands. It may also be an anonymous > // operand, which has a single operand, but no declared class for the > // operand. > - DagInit *MIOI = Inst.Operands[i].MIOperandInfo; > + const DagInit *MIOI = Inst.Operands[i].MIOperandInfo; > > if (!MIOI || MIOI->getNumArgs() == 0) { > // Single, anonymous, operand. > @@ -70,7 +70,7 @@ > for (unsigned j = 0, e = Inst.Operands[i].MINumOperands; j != e; ++j) { > OperandList.push_back(Inst.Operands[i]); > > - Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); > + Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); > OperandList.back().Rec = OpR; > } > } > @@ -288,11 +288,11 @@ > if (Inst.hasExtraDefRegAllocReq) OS << "|(1< > // Emit all of the target-specific flags... > - BitsInit *TSF = Inst.TheDef->getValueAsBitsInit("TSFlags"); > + const BitsInit *TSF = Inst.TheDef->getValueAsBitsInit("TSFlags"); > if (!TSF) throw "no TSFlags?"; > uint64_t Value = 0; > for (unsigned i = 0, e = TSF->getNumBits(); i != e; ++i) { > - if (BitInit *Bit = dynamic_cast(TSF->getBit(i))) > + if (const BitInit *Bit = dynamic_cast(TSF->getBit(i))) > Value |= uint64_t(Bit->getValue()) << i; > else > throw "Invalid TSFlags bit in " + Inst.TheDef->getName(); > > Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -245,7 +245,7 @@ > unsigned Flags; > std::string Help; > unsigned MultiVal; > - Init* InitVal; > + const Init* InitVal; > > OptionDescription(OptionType::OptionType t = OptionType::Switch, > const std::string& n = "", > @@ -589,7 +589,7 @@ > } > > template > -void InvokeDagInitHandler(FunctionObject* Obj, Init* I) { > +void InvokeDagInitHandler(FunctionObject* Obj, const Init* I) { > typedef void (FunctionObject::*Handler) (const DagInit&); > > const DagInit& Dag = InitPtrToDag(I); > @@ -658,7 +658,7 @@ > > /// operator() - Just forwards to the corresponding property > /// handler. > - void operator() (Init* I) { > + void operator() (const Init* I) { > InvokeDagInitHandler(this, I); > } > > @@ -705,10 +705,10 @@ > > void onInit (const DagInit& d) { > CheckNumberOfArguments(d, 1); > - Init* i = d.getArg(0); > + const Init* i = d.getArg(0); > const std::string& str = i->getAsString(); > > - bool correct = optDesc_.isParameter() && dynamic_cast(i); > + bool correct = optDesc_.isParameter() && dynamic_cast(i); > correct |= (optDesc_.isSwitch() && (str == "true" || str == "false")); > > if (!correct) > @@ -821,7 +821,7 @@ > for (RecordVector::const_iterator B = V.begin(), E = V.end(); B!=E; ++B) > { > // Throws an exception if the value does not exist. > - ListInit* PropList = (*B)->getValueAsListInit("options"); > + const ListInit* PropList = (*B)->getValueAsListInit("options"); > > // For every option description in this list: invoke AddOption. > std::for_each(PropList->begin(), PropList->end(), AddOption(OptDescs)); > @@ -836,8 +836,8 @@ > > struct ToolDescription : public RefCountedBase { > std::string Name; > - Init* CmdLine; > - Init* Actions; > + const Init* CmdLine; > + const Init* Actions; > StrVector InLanguage; > std::string InFileOption; > std::string OutFileOption; > @@ -903,7 +903,7 @@ > } > } > > - void operator() (Init* I) { > + void operator() (const Init* I) { > InvokeDagInitHandler(this, I); > } > > @@ -915,9 +915,9 @@ > > void onActions (const DagInit& d) { > CheckNumberOfArguments(d, 1); > - Init* Case = d.getArg(0); > + const Init* Case = d.getArg(0); > if (typeid(*Case) != typeid(DagInit) || > - GetOperatorName(static_cast(*Case)) != "case") > + GetOperatorName(static_cast(*Case)) != "case") > throw "The argument to (actions) should be a 'case' construct!"; > toolDesc_.Actions = Case; > } > @@ -954,7 +954,7 @@ > isReallyJoin = true; > } > else { > - Init* I = d.getArg(0); > + const Init* I = d.getArg(0); > isReallyJoin = InitPtrToBool(I); > } > > @@ -1007,7 +1007,7 @@ > E = Tools.end(); B!=E; ++B) { > const Record* T = *B; > // Throws an exception if the value does not exist. > - ListInit* PropList = T->getValueAsListInit("properties"); > + const ListInit* PropList = T->getValueAsListInit("properties"); > > IntrusiveRefCntPtr > ToolDesc(new ToolDescription(T->getName())); > @@ -1163,7 +1163,7 @@ > unsigned i = 1; > for (DagInit::const_arg_iterator B = d.arg_begin(), E = d.arg_end(); > B != E; ++B) { > - Init* arg = *B; > + const Init* arg = *B; > > if (!even) > { > @@ -1181,8 +1181,8 @@ > } > else > { > - if (dynamic_cast(arg) > - && GetOperatorName(static_cast(*arg)) == "case") { > + if (dynamic_cast(arg) > + && GetOperatorName(static_cast(*arg)) == "case") { > // Nested 'case'. > WalkCase(arg, TestCallback, StatementCallback, IndentLevel + Indent1); > } > @@ -1210,7 +1210,7 @@ > ActionName == "parameter_equals" || ActionName == "element_in_list") { > CheckNumberOfArguments(Stmt, 1); > > - Init* Arg = Stmt.getArg(0); > + const Init* Arg = Stmt.getArg(0); > if (typeid(*Arg) == typeid(StringInit)) > OptionNames_.insert(InitPtrToString(Arg)); > } > @@ -1218,7 +1218,7 @@ > ActionName == "any_not_empty" || ActionName == "any_empty" || > ActionName == "not_empty" || ActionName == "empty") { > for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) { > - Init* Arg = Stmt.getArg(i); > + const Init* Arg = Stmt.getArg(i); > if (typeid(*Arg) == typeid(StringInit)) > OptionNames_.insert(InitPtrToString(Arg)); > } > @@ -2613,7 +2613,7 @@ > > for (RecordVector::const_iterator B = OptionPreprocessors.begin(), > E = OptionPreprocessors.end(); B!=E; ++B) { > - DagInit* Case = (*B)->getValueAsDag("preprocessor"); > + const DagInit* Case = (*B)->getValueAsDag("preprocessor"); > EmitCaseConstructHandler(Case, Indent1, > EmitPreprocessOptionsCallback(OptDecs), > false, OptDecs, O); > @@ -2645,7 +2645,7 @@ > } > } > > - void operator() (Init* I) { > + void operator() (const Init* I) { > InvokeDagInitHandler(this, I); > } > > @@ -2655,7 +2655,7 @@ > CheckNumberOfArguments(d, 2); > > const std::string& Lang = InitPtrToString(d.getArg(0)); > - Init* Suffixes = d.getArg(1); > + const Init* Suffixes = d.getArg(1); > > // Second argument to lang_to_suffixes is either a single string... > if (typeid(*Suffixes) == typeid(StringInit)) { > @@ -2688,7 +2688,7 @@ > // Call DoEmitPopulateLanguageMap. > for (RecordVector::const_iterator B = LangMaps.begin(), > E = LangMaps.end(); B!=E; ++B) { > - ListInit* LangMap = (*B)->getValueAsListInit("map"); > + const ListInit* LangMap = (*B)->getValueAsListInit("map"); > std::for_each(LangMap->begin(), LangMap->end(), > DoEmitPopulateLanguageMap(O)); > } > @@ -2947,7 +2947,7 @@ > // Look for hook invocations in 'cmd_line'. > if (!D.CmdLine) > continue; > - if (dynamic_cast(D.CmdLine)) > + if (dynamic_cast(D.CmdLine)) > // This is a string. > ExtractHookNames(HookNames, OptDescs).operator()(D.CmdLine); > else > > Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -56,7 +56,7 @@ > > static const std::string getOptionName(const Record &R) { > // Use the record name unless EnumName is defined. > - if (dynamic_cast(R.getValueInit("EnumName"))) > + if (dynamic_cast(R.getValueInit("EnumName"))) > return R.getName(); > > return R.getValueAsString("EnumName"); > @@ -105,7 +105,7 @@ > > // The containing option group (if any). > OS << ", "; > - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > OS << getOptionName(*DI->getDef()); > else > OS << "INVALID"; > @@ -114,7 +114,7 @@ > OS << ", INVALID, 0, 0"; > > // The option help text. > - if (!dynamic_cast(R.getValueInit("HelpText"))) { > + if (!dynamic_cast(R.getValueInit("HelpText"))) { > OS << ",\n"; > OS << " "; > write_cstring(OS, R.getValueAsString("HelpText")); > @@ -145,14 +145,14 @@ > > // The containing option group (if any). > OS << ", "; > - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) > OS << getOptionName(*DI->getDef()); > else > OS << "INVALID"; > > // The option alias (if any). > OS << ", "; > - if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) > + if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) > OS << getOptionName(*DI->getDef()); > else > OS << "INVALID"; > @@ -166,7 +166,7 @@ > for (unsigned i = 0, e = LI->size(); i != e; ++i) { > if (i) > OS << " | "; > - OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); > + OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); > } > } > > @@ -174,7 +174,7 @@ > OS << ", " << R.getValueAsInt("NumArgs"); > > // The option help text. > - if (!dynamic_cast(R.getValueInit("HelpText"))) { > + if (!dynamic_cast(R.getValueInit("HelpText"))) { > OS << ",\n"; > OS << " "; > write_cstring(OS, R.getValueAsString("HelpText")); > @@ -183,7 +183,7 @@ > > // The option meta-variable name. > OS << ", "; > - if (!dynamic_cast(R.getValueInit("MetaVarName"))) > + if (!dynamic_cast(R.getValueInit("MetaVarName"))) > write_cstring(OS, R.getValueAsString("MetaVarName")); > else > OS << "0"; > > Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -24,11 +24,11 @@ > // a single dag, so we can do fancier things. > > unsigned PseudoLoweringEmitter:: > -addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn, > +addDagOperandMapping(Record *Rec, const DagInit *Dag, CodeGenInstruction &Insn, > IndexedMap &OperandMap, unsigned BaseIdx) { > unsigned OpsAdded = 0; > for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) { > - if (DefInit *DI = dynamic_cast(Dag->getArg(i))) { > + if (const DefInit *DI = dynamic_cast(Dag->getArg(i))) { > // Physical register reference. Explicit check for the special case > // "zero_reg" definition. > if (DI->getDef()->isSubClassOf("Register") || > @@ -54,11 +54,13 @@ > for (unsigned I = 0, E = Insn.Operands[i].MINumOperands; I != E; ++I) > OperandMap[BaseIdx + i + I].Kind = OpData::Operand; > OpsAdded += Insn.Operands[i].MINumOperands; > - } else if (IntInit *II = dynamic_cast(Dag->getArg(i))) { > + } else if (const IntInit *II = > + dynamic_cast(Dag->getArg(i))) { > OperandMap[BaseIdx + i].Kind = OpData::Imm; > OperandMap[BaseIdx + i].Data.Imm = II->getValue(); > ++OpsAdded; > - } else if (DagInit *SubDag = dynamic_cast(Dag->getArg(i))) { > + } else if (const DagInit *SubDag = > + dynamic_cast(Dag->getArg(i))) { > // Just add the operands recursively. This is almost certainly > // a constant value for a complex operand (> 1 MI operand). > unsigned NewOps = > @@ -77,11 +79,11 @@ > > // Validate that the result pattern has the corrent number and types > // of arguments for the instruction it references. > - DagInit *Dag = Rec->getValueAsDag("ResultInst"); > + const DagInit *Dag = Rec->getValueAsDag("ResultInst"); > assert(Dag && "Missing result instruction in pseudo expansion!"); > DEBUG(dbgs() << " Result: " << *Dag << "\n"); > > - DefInit *OpDef = dynamic_cast(Dag->getOperator()); > + const DefInit *OpDef = dynamic_cast(Dag->getOperator()); > if (!OpDef) > throw TGError(Rec->getLoc(), Rec->getName() + > " has unexpected operator type!"); > > Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h (original) > +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h Mon Jul 11 13:25:51 2011 > @@ -47,7 +47,7 @@ > > SmallVector Expansions; > > - unsigned addDagOperandMapping(Record *Rec, DagInit *Dag, > + unsigned addDagOperandMapping(Record *Rec, const DagInit *Dag, > CodeGenInstruction &Insn, > IndexedMap &OperandMap, > unsigned BaseIdx); > > Modified: llvm/trunk/utils/TableGen/Record.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/Record.cpp (original) > +++ llvm/trunk/utils/TableGen/Record.cpp Mon Jul 11 13:25:51 2011 > @@ -15,6 +15,8 @@ > #include "Error.h" > #include "llvm/Support/DataTypes.h" > #include "llvm/Support/Format.h" > +#include "llvm/ADT/SmallVector.h" > +#include "llvm/ADT/STLExtras.h" > #include "llvm/ADT/StringExtras.h" > > using namespace llvm; > @@ -25,7 +27,7 @@ > > void RecTy::dump() const { print(errs()); } > > -Init *BitRecTy::convertValue(BitsInit *BI) { > +const Init *BitRecTy::convertValue(const BitsInit *BI) { > if (BI->getNumBits() != 1) return 0; // Only accept if just one bit! > return BI->getBit(0); > } > @@ -34,14 +36,14 @@ > return RHS->getNumBits() == 1; > } > > -Init *BitRecTy::convertValue(IntInit *II) { > +const Init *BitRecTy::convertValue(const IntInit *II) { > int64_t Val = II->getValue(); > if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit! > > - return new BitInit(Val != 0); > + return BitInit::Create(Val != 0); > } > > -Init *BitRecTy::convertValue(TypedInit *VI) { > +const Init *BitRecTy::convertValue(const TypedInit *VI) { > if (dynamic_cast(VI->getType())) > return VI; // Accept variable if it is already of bit type! > return 0; > @@ -51,19 +53,21 @@ > return "bits<" + utostr(Size) + ">"; > } > > -Init *BitsRecTy::convertValue(UnsetInit *UI) { > - BitsInit *Ret = new BitsInit(Size); > +const Init *BitsRecTy::convertValue(const UnsetInit *UI) { > + SmallVector Bits(Size); > > for (unsigned i = 0; i != Size; ++i) > - Ret->setBit(i, new UnsetInit()); > - return Ret; > + Bits[i] = UnsetInit::Create(); > + > + return BitsInit::Create(Bits.begin(), Bits.end()); > } > > -Init *BitsRecTy::convertValue(BitInit *UI) { > +const Init *BitsRecTy::convertValue(const BitInit *UI) { > if (Size != 1) return 0; // Can only convert single bit. > - BitsInit *Ret = new BitsInit(1); > - Ret->setBit(0, UI); > - return Ret; > + > + const Init *Bits[1] = { UI }; > + > + return BitsInit::Create(Bits, array_endof(Bits)); > } > > /// canFitInBitfield - Return true if the number of bits is large enough to hold > @@ -74,82 +78,85 @@ > (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1); > } > > -/// convertValue from Int initializer to bits type: Split the integer up into the > -/// appropriate bits. > +/// convertValue from Int initializer to bits type: Split the integer > +/// up into the appropriate bits. > /// > -Init *BitsRecTy::convertValue(IntInit *II) { > +const Init *BitsRecTy::convertValue(const IntInit *II) { > int64_t Value = II->getValue(); > // Make sure this bitfield is large enough to hold the integer value. > if (!canFitInBitfield(Value, Size)) > return 0; > > - BitsInit *Ret = new BitsInit(Size); > + SmallVector Bits(Size); > + > for (unsigned i = 0; i != Size; ++i) > - Ret->setBit(i, new BitInit(Value & (1LL << i))); > + Bits[i] = BitInit::Create(Value & (1LL << i)); > > - return Ret; > + return BitsInit::Create(Bits.begin(), Bits.end()); > } > > -Init *BitsRecTy::convertValue(BitsInit *BI) { > +const Init *BitsRecTy::convertValue(const BitsInit *BI) { > // If the number of bits is right, return it. Otherwise we need to expand or > // truncate. > if (BI->getNumBits() == Size) return BI; > return 0; > } > > -Init *BitsRecTy::convertValue(TypedInit *VI) { > +const Init *BitsRecTy::convertValue(const TypedInit *VI) { > if (BitsRecTy *BRT = dynamic_cast(VI->getType())) > if (BRT->Size == Size) { > - BitsInit *Ret = new BitsInit(Size); > + SmallVector Bits(Size); > + > for (unsigned i = 0; i != Size; ++i) > - Ret->setBit(i, new VarBitInit(VI, i)); > - return Ret; > + Bits[i] = VarBitInit::Create(VI, i); > + return BitsInit::Create(Bits.begin(), Bits.end()); > } > > if (Size == 1 && dynamic_cast(VI->getType())) { > - BitsInit *Ret = new BitsInit(1); > - Ret->setBit(0, VI); > - return Ret; > + const Init *Bits[1] = { VI }; > + > + return BitsInit::Create(Bits, array_endof(Bits)); > } > > - if (TernOpInit *Tern = dynamic_cast(VI)) { > + if (const TernOpInit *Tern = dynamic_cast(VI)) { > if (Tern->getOpcode() == TernOpInit::IF) { > - Init *LHS = Tern->getLHS(); > - Init *MHS = Tern->getMHS(); > - Init *RHS = Tern->getRHS(); > + const Init *LHS = Tern->getLHS(); > + const Init *MHS = Tern->getMHS(); > + const Init *RHS = Tern->getRHS(); > > - IntInit *MHSi = dynamic_cast(MHS); > - IntInit *RHSi = dynamic_cast(RHS); > + const IntInit *MHSi = dynamic_cast(MHS); > + const IntInit *RHSi = dynamic_cast(RHS); > > if (MHSi && RHSi) { > int64_t MHSVal = MHSi->getValue(); > int64_t RHSVal = RHSi->getValue(); > > if (canFitInBitfield(MHSVal, Size) && canFitInBitfield(RHSVal, Size)) { > - BitsInit *Ret = new BitsInit(Size); > + SmallVector NewBits(Size); > > for (unsigned i = 0; i != Size; ++i) > - Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, > - new IntInit((MHSVal & (1LL << i)) ? 1 : 0), > - new IntInit((RHSVal & (1LL << i)) ? 1 : 0), > - VI->getType())); > - > - return Ret; > + NewBits[i] = > + TernOpInit::Create(TernOpInit::IF, LHS, > + IntInit::Create((MHSVal & (1LL << i)) ? 1 : 0), > + IntInit::Create((RHSVal & (1LL << i)) ? 1 : 0), > + VI->getType()); > + > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > } > } else { > - BitsInit *MHSbs = dynamic_cast(MHS); > - BitsInit *RHSbs = dynamic_cast(RHS); > + const BitsInit *MHSbs = dynamic_cast(MHS); > + const BitsInit *RHSbs = dynamic_cast(RHS); > > if (MHSbs && RHSbs) { > - BitsInit *Ret = new BitsInit(Size); > + SmallVector NewBits(Size); > > for (unsigned i = 0; i != Size; ++i) > - Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, > - MHSbs->getBit(i), > - RHSbs->getBit(i), > - VI->getType())); > + NewBits[i] = TernOpInit::Create(TernOpInit::IF, LHS, > + MHSbs->getBit(i), > + RHSbs->getBit(i), > + VI->getType()); > > - return Ret; > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > } > } > } > @@ -158,54 +165,54 @@ > return 0; > } > > -Init *IntRecTy::convertValue(BitInit *BI) { > - return new IntInit(BI->getValue()); > +const Init *IntRecTy::convertValue(const BitInit *BI) { > + return IntInit::Create(BI->getValue()); > } > > -Init *IntRecTy::convertValue(BitsInit *BI) { > +const Init *IntRecTy::convertValue(const BitsInit *BI) { > int64_t Result = 0; > for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) > - if (BitInit *Bit = dynamic_cast(BI->getBit(i))) { > + if (const BitInit *Bit = dynamic_cast(BI->getBit(i))) { > Result |= Bit->getValue() << i; > } else { > return 0; > } > - return new IntInit(Result); > + return IntInit::Create(Result); > } > > -Init *IntRecTy::convertValue(TypedInit *TI) { > +const Init *IntRecTy::convertValue(const TypedInit *TI) { > if (TI->getType()->typeIsConvertibleTo(this)) > return TI; // Accept variable if already of the right type! > return 0; > } > > -Init *StringRecTy::convertValue(UnOpInit *BO) { > +const Init *StringRecTy::convertValue(const UnOpInit *BO) { > if (BO->getOpcode() == UnOpInit::CAST) { > - Init *L = BO->getOperand()->convertInitializerTo(this); > + const Init *L = BO->getOperand()->convertInitializerTo(this); > if (L == 0) return 0; > if (L != BO->getOperand()) > - return new UnOpInit(UnOpInit::CAST, L, new StringRecTy); > + return UnOpInit::Create(UnOpInit::CAST, L, new StringRecTy); > return BO; > } > > - return convertValue((TypedInit*)BO); > + return convertValue((const TypedInit*)BO); > } > > -Init *StringRecTy::convertValue(BinOpInit *BO) { > +const Init *StringRecTy::convertValue(const BinOpInit *BO) { > if (BO->getOpcode() == BinOpInit::STRCONCAT) { > - Init *L = BO->getLHS()->convertInitializerTo(this); > - Init *R = BO->getRHS()->convertInitializerTo(this); > + const Init *L = BO->getLHS()->convertInitializerTo(this); > + const Init *R = BO->getRHS()->convertInitializerTo(this); > if (L == 0 || R == 0) return 0; > if (L != BO->getLHS() || R != BO->getRHS()) > - return new BinOpInit(BinOpInit::STRCONCAT, L, R, new StringRecTy); > + return BinOpInit::Create(BinOpInit::STRCONCAT, L, R, new StringRecTy); > return BO; > } > > - return convertValue((TypedInit*)BO); > + return convertValue((const TypedInit*)BO); > } > > > -Init *StringRecTy::convertValue(TypedInit *TI) { > +const Init *StringRecTy::convertValue(const TypedInit *TI) { > if (dynamic_cast(TI->getType())) > return TI; // Accept variable if already of the right type! > return 0; > @@ -215,13 +222,13 @@ > return "list<" + Ty->getAsString() + ">"; > } > > -Init *ListRecTy::convertValue(ListInit *LI) { > - std::vector Elements; > +const Init *ListRecTy::convertValue(const ListInit *LI) { > + std::vector Elements; > > // Verify that all of the elements of the list are subclasses of the > // appropriate class! > for (unsigned i = 0, e = LI->getSize(); i != e; ++i) > - if (Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) > + if (const Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) > Elements.push_back(CI); > else > return 0; > @@ -231,10 +238,10 @@ > return 0; > } > > - return new ListInit(Elements, new ListRecTy(Ty)); > + return ListInit::Create(Elements, new ListRecTy(Ty)); > } > > -Init *ListRecTy::convertValue(TypedInit *TI) { > +const Init *ListRecTy::convertValue(const TypedInit *TI) { > // Ensure that TI is compatible with our class. > if (ListRecTy *LRT = dynamic_cast(TI->getType())) > if (LRT->getElementType()->typeIsConvertibleTo(getElementType())) > @@ -242,36 +249,36 @@ > return 0; > } > > -Init *CodeRecTy::convertValue(TypedInit *TI) { > +const Init *CodeRecTy::convertValue(const TypedInit *TI) { > if (TI->getType()->typeIsConvertibleTo(this)) > return TI; > return 0; > } > > -Init *DagRecTy::convertValue(TypedInit *TI) { > +const Init *DagRecTy::convertValue(const TypedInit *TI) { > if (TI->getType()->typeIsConvertibleTo(this)) > return TI; > return 0; > } > > -Init *DagRecTy::convertValue(UnOpInit *BO) { > +const Init *DagRecTy::convertValue(const UnOpInit *BO) { > if (BO->getOpcode() == UnOpInit::CAST) { > - Init *L = BO->getOperand()->convertInitializerTo(this); > + const Init *L = BO->getOperand()->convertInitializerTo(this); > if (L == 0) return 0; > if (L != BO->getOperand()) > - return new UnOpInit(UnOpInit::CAST, L, new DagRecTy); > + return UnOpInit::Create(UnOpInit::CAST, L, new DagRecTy); > return BO; > } > return 0; > } > > -Init *DagRecTy::convertValue(BinOpInit *BO) { > +const Init *DagRecTy::convertValue(const BinOpInit *BO) { > if (BO->getOpcode() == BinOpInit::CONCAT) { > - Init *L = BO->getLHS()->convertInitializerTo(this); > - Init *R = BO->getRHS()->convertInitializerTo(this); > + const Init *L = BO->getLHS()->convertInitializerTo(this); > + const Init *R = BO->getRHS()->convertInitializerTo(this); > if (L == 0 || R == 0) return 0; > if (L != BO->getLHS() || R != BO->getRHS()) > - return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy); > + return BinOpInit::Create(BinOpInit::CONCAT, L, R, new DagRecTy); > return BO; > } > return 0; > @@ -281,14 +288,14 @@ > return Rec->getName(); > } > > -Init *RecordRecTy::convertValue(DefInit *DI) { > +const Init *RecordRecTy::convertValue(const DefInit *DI) { > // Ensure that DI is a subclass of Rec. > if (!DI->getDef()->isSubClassOf(Rec)) > return 0; > return DI; > } > > -Init *RecordRecTy::convertValue(TypedInit *TI) { > +const Init *RecordRecTy::convertValue(const TypedInit *TI) { > // Ensure that TI is compatible with Rec. > if (RecordRecTy *RRT = dynamic_cast(TI->getType())) > if (RRT->getRecord()->isSubClassOf(getRecord()) || > @@ -367,25 +374,59 @@ > // Initializer implementations > //===----------------------------------------------------------------------===// > > +FoldingSet Init::UniqueInits; > +BumpPtrAllocator Init::InitAllocator; > + > void Init::dump() const { return print(errs()); } > > -Init *BitsInit::convertInitializerBitRange(const std::vector &Bits) { > - BitsInit *BI = new BitsInit(Bits.size()); > +const UnsetInit *UnsetInit::Create() { > + FoldingSetNodeID ID; > + ID.AddInteger(initUnset); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + UnsetInit *I = InitAllocator.Allocate(); > + new (I) UnsetInit(ID); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const BitInit *BitInit::Create(bool V) { > + FoldingSetNodeID ID; > + ID.AddInteger(initBit); > + ID.AddBoolean(V); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + BitInit *I = InitAllocator.Allocate(); > + new (I) BitInit(ID, V); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init * > +BitsInit::convertInitializerBitRange(const std::vector &Bits) const { > + SmallVector NewBits(Bits.size()); > + > for (unsigned i = 0, e = Bits.size(); i != e; ++i) { > if (Bits[i] >= getNumBits()) { > - delete BI; > return 0; > } > - BI->setBit(i, getBit(Bits[i])); > + NewBits[i] = getBit(Bits[i]); > } > - return BI; > + > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > } > > std::string BitsInit::getAsString() const { > std::string Result = "{ "; > for (unsigned i = 0, e = getNumBits(); i != e; ++i) { > if (i) Result += ", "; > - if (Init *Bit = getBit(e-i-1)) > + if (const Init *Bit = getBit(e-i-1)) > Result += Bit->getAsString(); > else > Result += "*"; > @@ -396,70 +437,141 @@ > // resolveReferences - If there are any field references that refer to fields > // that have been filled in, we can propagate the values now. > // > -Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) { > +const Init *BitsInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > bool Changed = false; > - BitsInit *New = new BitsInit(getNumBits()); > > - for (unsigned i = 0, e = Bits.size(); i != e; ++i) { > - Init *B; > - Init *CurBit = getBit(i); > + SmallVector Bits(getNumBits()); > + > + for (unsigned i = 0, e = getNumBits(); i != e; ++i) { > + const Init *B; > + const Init *CurBit = getBit(i); > > do { > B = CurBit; > CurBit = CurBit->resolveReferences(R, RV); > Changed |= B != CurBit; > } while (B != CurBit); > - New->setBit(i, CurBit); > + Bits[i] = CurBit; > } > > if (Changed) > - return New; > - delete New; > + return BitsInit::Create(Bits.begin(), Bits.end()); > + > return this; > } > > +const IntInit *IntInit::Create(int64_t V) { > + FoldingSetNodeID ID; > + ID.AddInteger(initInt); > + ID.AddInteger(V); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + IntInit *I = InitAllocator.Allocate(); > + new (I) IntInit(ID, V); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > std::string IntInit::getAsString() const { > return itostr(Value); > } > > -Init *IntInit::convertInitializerBitRange(const std::vector &Bits) { > - BitsInit *BI = new BitsInit(Bits.size()); > +const Init * > +IntInit::convertInitializerBitRange(const std::vector &Bits) const { > + SmallVector NewBits(Bits.size()); > > for (unsigned i = 0, e = Bits.size(); i != e; ++i) { > - if (Bits[i] >= 64) { > - delete BI; > + if (Bits[i] >= 64) > return 0; > - } > - BI->setBit(i, new BitInit(Value & (INT64_C(1) << Bits[i]))); > + > + NewBits[i] = BitInit::Create(Value & (INT64_C(1) << Bits[i])); > + } > + > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > +} > + > +const StringInit *StringInit::Create(const std::string &V) { > + FoldingSetNodeID ID; > + ID.AddInteger(initString); > + ID.AddString(V); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + StringInit *I = InitAllocator.Allocate(); > + new (I) StringInit(ID, V); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const CodeInit *CodeInit::Create(const std::string &V) { > + FoldingSetNodeID ID; > + ID.AddInteger(initCode); > + ID.AddString(V); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + CodeInit *I = InitAllocator.Allocate(); > + new (I) CodeInit(ID, V); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const ListInit *ListInit::Create(std::vector &Vs, RecTy *EltTy) { > + FoldingSetNodeID ID; > + ID.AddInteger(initList); > + ID.AddString(EltTy->getAsString()); > + > + for (std::vector::iterator i = Vs.begin(), iend = Vs.end(); > + i != iend; > + ++i) { > + ID.AddPointer(*i); > } > - return BI; > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + ListInit *I = InitAllocator.Allocate(); > + new (I) ListInit(ID, Vs, EltTy); > + UniqueInits.InsertNode(I, IP); > + return I; > } > > -Init *ListInit::convertInitListSlice(const std::vector &Elements) { > - std::vector Vals; > +const Init * > +ListInit::convertInitListSlice(const std::vector &Elements) const { > + std::vector Vals; > for (unsigned i = 0, e = Elements.size(); i != e; ++i) { > if (Elements[i] >= getSize()) > return 0; > Vals.push_back(getElement(Elements[i])); > } > - return new ListInit(Vals, getType()); > + return ListInit::Create(Vals, getType()); > } > > Record *ListInit::getElementAsRecord(unsigned i) const { > assert(i < Values.size() && "List element index out of range!"); > - DefInit *DI = dynamic_cast(Values[i]); > + const DefInit *DI = dynamic_cast(Values[i]); > if (DI == 0) throw "Expected record in list!"; > return DI->getDef(); > } > > -Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) { > - std::vector Resolved; > +const Init *ListInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + std::vector Resolved; > Resolved.reserve(getSize()); > bool Changed = false; > > for (unsigned i = 0, e = getSize(); i != e; ++i) { > - Init *E; > - Init *CurElt = getElement(i); > + const Init *E; > + const Init *CurElt = getElement(i); > > do { > E = CurElt; > @@ -470,20 +582,25 @@ > } > > if (Changed) > - return new ListInit(Resolved, getType()); > + return ListInit::Create(Resolved, getType()); > + > return this; > } > > -Init *ListInit::resolveListElementReference(Record &R, const RecordVal *IRV, > - unsigned Elt) { > +const Init *ListInit::resolveListElementReference(Record &R, > + const RecordVal *IRV, > + unsigned Elt) const { > if (Elt >= getSize()) > return 0; // Out of range reference. > - Init *E = getElement(Elt); > + > + const Init *E = getElement(Elt); > + > // If the element is set to some value, or if we are resolving a reference > // to a specific variable and that variable is explicitly unset, then > // replace the VarListElementInit with it. > - if (IRV || !dynamic_cast(E)) > + if (IRV || !dynamic_cast(E)) > return E; > + > return 0; > } > > @@ -496,12 +613,12 @@ > return Result + "]"; > } > > -Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, > - unsigned Bit) { > - Init *Folded = Fold(&R, 0); > +const Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, > + unsigned Bit) const { > + const Init *Folded = Fold(&R, 0); > > if (Folded != this) { > - TypedInit *Typed = dynamic_cast(Folded); > + const TypedInit *Typed = dynamic_cast(Folded); > if (Typed) { > return Typed->resolveBitReference(R, IRV, Bit); > } > @@ -510,12 +627,12 @@ > return 0; > } > > -Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, > - unsigned Elt) { > - Init *Folded = Fold(&R, 0); > +const Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, > + unsigned Elt) const { > + const Init *Folded = Fold(&R, 0); > > if (Folded != this) { > - TypedInit *Typed = dynamic_cast(Folded); > + const TypedInit *Typed = dynamic_cast(Folded); > if (Typed) { > return Typed->resolveListElementReference(R, IRV, Elt); > } > @@ -524,22 +641,39 @@ > return 0; > } > > -Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { > +const UnOpInit *UnOpInit::Create(UnaryOp opc, const Init *lhs, RecTy *Type) { > + FoldingSetNodeID ID; > + ID.AddInteger(initUnOp); > + ID.AddInteger(opc); > + ID.AddString(Type->getAsString()); > + ID.AddPointer(lhs); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + UnOpInit *I = InitAllocator.Allocate(); > + new (I) UnOpInit(ID, opc, lhs, Type); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { > switch (getOpcode()) { > default: assert(0 && "Unknown unop"); > case CAST: { > if (getType()->getAsString() == "string") { > - StringInit *LHSs = dynamic_cast(LHS); > + const StringInit *LHSs = dynamic_cast(LHS); > if (LHSs) { > return LHSs; > } > > - DefInit *LHSd = dynamic_cast(LHS); > + const DefInit *LHSd = dynamic_cast(LHS); > if (LHSd) { > - return new StringInit(LHSd->getDef()->getName()); > + return StringInit::Create(LHSd->getDef()->getName()); > } > } else { > - StringInit *LHSs = dynamic_cast(LHS); > + const StringInit *LHSs = dynamic_cast(LHS); > if (LHSs) { > std::string Name = LHSs->getValue(); > > @@ -548,7 +682,7 @@ > if (const RecordVal *RV = CurRec->getValue(Name)) { > if (RV->getType() != getType()) > throw "type mismatch in cast"; > - return new VarInit(Name, RV->getType()); > + return VarInit::Create(Name, RV->getType()); > } > > std::string TemplateArgName = CurRec->getName()+":"+Name; > @@ -559,7 +693,7 @@ > if (RV->getType() != getType()) > throw "type mismatch in cast"; > > - return new VarInit(TemplateArgName, RV->getType()); > + return VarInit::Create(TemplateArgName, RV->getType()); > } > } > > @@ -572,12 +706,12 @@ > if (RV->getType() != getType()) > throw "type mismatch in cast"; > > - return new VarInit(MCName, RV->getType()); > + return VarInit::Create(MCName, RV->getType()); > } > } > > if (Record *D = (CurRec->getRecords()).getDef(Name)) > - return new DefInit(D); > + return DefInit::Create(D); > > throw TGError(CurRec->getLoc(), "Undefined reference:'" + Name + "'\n"); > } > @@ -585,7 +719,7 @@ > break; > } > case HEAD: { > - ListInit *LHSl = dynamic_cast(LHS); > + const ListInit *LHSl = dynamic_cast(LHS); > if (LHSl) { > if (LHSl->getSize() == 0) { > assert(0 && "Empty list in car"); > @@ -596,33 +730,33 @@ > break; > } > case TAIL: { > - ListInit *LHSl = dynamic_cast(LHS); > + const ListInit *LHSl = dynamic_cast(LHS); > if (LHSl) { > if (LHSl->getSize() == 0) { > assert(0 && "Empty list in cdr"); > return 0; > } > - ListInit *Result = new ListInit(LHSl->begin()+1, LHSl->end(), > - LHSl->getType()); > + const ListInit *Result = ListInit::Create(LHSl->begin()+1, LHSl->end(), > + LHSl->getType()); > return Result; > } > break; > } > case EMPTY: { > - ListInit *LHSl = dynamic_cast(LHS); > + const ListInit *LHSl = dynamic_cast(LHS); > if (LHSl) { > if (LHSl->getSize() == 0) { > - return new IntInit(1); > + return IntInit::Create(1); > } else { > - return new IntInit(0); > + return IntInit::Create(0); > } > } > - StringInit *LHSs = dynamic_cast(LHS); > + const StringInit *LHSs = dynamic_cast(LHS); > if (LHSs) { > if (LHSs->getValue().empty()) { > - return new IntInit(1); > + return IntInit::Create(1); > } else { > - return new IntInit(0); > + return IntInit::Create(0); > } > } > > @@ -632,11 +766,12 @@ > return this; > } > > -Init *UnOpInit::resolveReferences(Record &R, const RecordVal *RV) { > - Init *lhs = LHS->resolveReferences(R, RV); > +const Init *UnOpInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + const Init *lhs = LHS->resolveReferences(R, RV); > > if (LHS != lhs) > - return (new UnOpInit(getOpcode(), lhs, getType()))->Fold(&R, 0); > + return (UnOpInit::Create(getOpcode(), lhs, getType()))->Fold(&R, 0); > return Fold(&R, 0); > } > > @@ -651,18 +786,37 @@ > return Result + "(" + LHS->getAsString() + ")"; > } > > -Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { > +const BinOpInit *BinOpInit::Create(BinaryOp opc, const Init *lhs, > + const Init *rhs, RecTy *Type) { > + FoldingSetNodeID ID; > + ID.AddInteger(initBinOp); > + ID.AddInteger(opc); > + ID.AddString(Type->getAsString()); > + ID.AddPointer(lhs); > + ID.AddPointer(rhs); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + BinOpInit *I = InitAllocator.Allocate(); > + new (I) BinOpInit(ID, opc, lhs, rhs, Type); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { > switch (getOpcode()) { > default: assert(0 && "Unknown binop"); > case CONCAT: { > - DagInit *LHSs = dynamic_cast(LHS); > - DagInit *RHSs = dynamic_cast(RHS); > + const DagInit *LHSs = dynamic_cast(LHS); > + const DagInit *RHSs = dynamic_cast(RHS); > if (LHSs && RHSs) { > - DefInit *LOp = dynamic_cast(LHSs->getOperator()); > - DefInit *ROp = dynamic_cast(RHSs->getOperator()); > + const DefInit *LOp = dynamic_cast(LHSs->getOperator()); > + const DefInit *ROp = dynamic_cast(RHSs->getOperator()); > if (LOp == 0 || ROp == 0 || LOp->getDef() != ROp->getDef()) > throw "Concated Dag operators do not match!"; > - std::vector Args; > + std::vector Args; > std::vector ArgNames; > for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) { > Args.push_back(LHSs->getArg(i)); > @@ -672,42 +826,42 @@ > Args.push_back(RHSs->getArg(i)); > ArgNames.push_back(RHSs->getArgName(i)); > } > - return new DagInit(LHSs->getOperator(), "", Args, ArgNames); > + return DagInit::Create(LHSs->getOperator(), "", Args, ArgNames); > } > break; > } > case STRCONCAT: { > - StringInit *LHSs = dynamic_cast(LHS); > - StringInit *RHSs = dynamic_cast(RHS); > + const StringInit *LHSs = dynamic_cast(LHS); > + const StringInit *RHSs = dynamic_cast(RHS); > if (LHSs && RHSs) > - return new StringInit(LHSs->getValue() + RHSs->getValue()); > + return StringInit::Create(LHSs->getValue() + RHSs->getValue()); > break; > } > case EQ: { > // try to fold eq comparison for 'bit' and 'int', otherwise fallback > // to string objects. > - IntInit* L = > - dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); > - IntInit* R = > - dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); > + const IntInit* L = > + dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); > + const IntInit* R = > + dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); > > if (L && R) > - return new IntInit(L->getValue() == R->getValue()); > + return IntInit::Create(L->getValue() == R->getValue()); > > - StringInit *LHSs = dynamic_cast(LHS); > - StringInit *RHSs = dynamic_cast(RHS); > + const StringInit *LHSs = dynamic_cast(LHS); > + const StringInit *RHSs = dynamic_cast(RHS); > > // Make sure we've resolved > if (LHSs && RHSs) > - return new IntInit(LHSs->getValue() == RHSs->getValue()); > + return IntInit::Create(LHSs->getValue() == RHSs->getValue()); > > break; > } > case SHL: > case SRA: > case SRL: { > - IntInit *LHSi = dynamic_cast(LHS); > - IntInit *RHSi = dynamic_cast(RHS); > + const IntInit *LHSi = dynamic_cast(LHS); > + const IntInit *RHSi = dynamic_cast(RHS); > if (LHSi && RHSi) { > int64_t LHSv = LHSi->getValue(), RHSv = RHSi->getValue(); > int64_t Result; > @@ -717,7 +871,7 @@ > case SRA: Result = LHSv >> RHSv; break; > case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; > } > - return new IntInit(Result); > + return IntInit::Create(Result); > } > break; > } > @@ -725,12 +879,13 @@ > return this; > } > > -Init *BinOpInit::resolveReferences(Record &R, const RecordVal *RV) { > - Init *lhs = LHS->resolveReferences(R, RV); > - Init *rhs = RHS->resolveReferences(R, RV); > +const Init *BinOpInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + const Init *lhs = LHS->resolveReferences(R, RV); > + const Init *rhs = RHS->resolveReferences(R, RV); > > if (LHS != lhs || RHS != rhs) > - return (new BinOpInit(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); > + return (BinOpInit::Create(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); > return Fold(&R, 0); > } > > @@ -747,20 +902,43 @@ > return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; > } > > -static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, > - Record *CurRec, MultiClass *CurMultiClass); > - > -static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, > - RecTy *Type, Record *CurRec, > - MultiClass *CurMultiClass) { > - std::vector NewOperands; > +const TernOpInit *TernOpInit::Create(TernaryOp opc, const Init *lhs, > + const Init *mhs, const Init *rhs, > + RecTy *Type) { > + FoldingSetNodeID ID; > + ID.AddInteger(initTernOp); > + ID.AddInteger(opc); > + ID.AddString(Type->getAsString()); > + ID.AddPointer(lhs); > + ID.AddPointer(mhs); > + ID.AddPointer(rhs); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + TernOpInit *I = InitAllocator.Allocate(); > + new (I) TernOpInit(ID, opc, lhs, mhs, rhs, Type); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +static const Init *ForeachHelper(const Init *LHS, const Init *MHS, > + const Init *RHS, RecTy *Type, > + Record *CurRec, MultiClass *CurMultiClass); > + > +static const Init *EvaluateOperation(const OpInit *RHSo, const Init *LHS, > + const Init *Arg, RecTy *Type, > + Record *CurRec, > + MultiClass *CurMultiClass) { > + std::vector NewOperands; > > - TypedInit *TArg = dynamic_cast(Arg); > + const TypedInit *TArg = dynamic_cast(Arg); > > // If this is a dag, recurse > if (TArg && TArg->getType()->getAsString() == "dag") { > - Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, > - CurRec, CurMultiClass); > + const Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, > + CurRec, CurMultiClass); > if (Result != 0) { > return Result; > } else { > @@ -768,18 +946,21 @@ > } > } > > + bool change = false; > for (int i = 0; i < RHSo->getNumOperands(); ++i) { > - OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); > + const OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); > > if (RHSoo) { > - Init *Result = EvaluateOperation(RHSoo, LHS, Arg, > - Type, CurRec, CurMultiClass); > + const Init *Result = EvaluateOperation(RHSoo, LHS, Arg, > + Type, CurRec, CurMultiClass); > if (Result != 0) { > + change = true; > NewOperands.push_back(Result); > } else { > NewOperands.push_back(Arg); > } > } else if (LHS->getAsString() == RHSo->getOperand(i)->getAsString()) { > + change = true; > NewOperands.push_back(Arg); > } else { > NewOperands.push_back(RHSo->getOperand(i)); > @@ -787,30 +968,31 @@ > } > > // Now run the operator and use its result as the new leaf > - OpInit *NewOp = RHSo->clone(NewOperands); > - Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); > - if (NewVal != NewOp) { > - delete NewOp; > + const OpInit *NewOp = RHSo->clone(NewOperands); > + const Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); > + > + if (change) { > return NewVal; > } > return 0; > } > > -static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, > - Record *CurRec, MultiClass *CurMultiClass) { > - DagInit *MHSd = dynamic_cast(MHS); > - ListInit *MHSl = dynamic_cast(MHS); > +static const Init *ForeachHelper(const Init *LHS, const Init *MHS, > + const Init *RHS, RecTy *Type, > + Record *CurRec, MultiClass *CurMultiClass) { > + const DagInit *MHSd = dynamic_cast(MHS); > + const ListInit *MHSl = dynamic_cast(MHS); > > DagRecTy *DagType = dynamic_cast(Type); > ListRecTy *ListType = dynamic_cast(Type); > > - OpInit *RHSo = dynamic_cast(RHS); > + const OpInit *RHSo = dynamic_cast(RHS); > > if (!RHSo) { > throw TGError(CurRec->getLoc(), "!foreach requires an operator\n"); > } > > - TypedInit *LHSt = dynamic_cast(LHS); > + const TypedInit *LHSt = dynamic_cast(LHS); > > if (!LHSt) { > throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n"); > @@ -818,23 +1000,23 @@ > > if ((MHSd && DagType) || (MHSl && ListType)) { > if (MHSd) { > - Init *Val = MHSd->getOperator(); > - Init *Result = EvaluateOperation(RHSo, LHS, Val, > - Type, CurRec, CurMultiClass); > + const Init *Val = MHSd->getOperator(); > + const Init *Result = EvaluateOperation(RHSo, LHS, Val, > + Type, CurRec, CurMultiClass); > if (Result != 0) { > Val = Result; > } > > - std::vector > args; > + std::vector > args; > for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) { > - Init *Arg; > + const Init *Arg; > std::string ArgName; > Arg = MHSd->getArg(i); > ArgName = MHSd->getArgName(i); > > // Process args > - Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, > - CurRec, CurMultiClass); > + const Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, > + CurRec, CurMultiClass); > if (Result != 0) { > Arg = Result; > } > @@ -843,17 +1025,17 @@ > args.push_back(std::make_pair(Arg, ArgName)); > } > > - return new DagInit(Val, "", args); > + return DagInit::Create(Val, "", args); > } > if (MHSl) { > - std::vector NewOperands; > - std::vector NewList(MHSl->begin(), MHSl->end()); > + std::vector NewOperands; > + std::vector NewList(MHSl->begin(), MHSl->end()); > > - for (ListInit::iterator li = NewList.begin(), > + for (std::vector::iterator li = NewList.begin(), > liend = NewList.end(); > li != liend; > ++li) { > - Init *Item = *li; > + const Init *Item = *li; > NewOperands.clear(); > for(int i = 0; i < RHSo->getNumOperands(); ++i) { > // First, replace the foreach variable with the list item > @@ -865,34 +1047,33 @@ > } > > // Now run the operator and use its result as the new list item > - OpInit *NewOp = RHSo->clone(NewOperands); > - Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); > + const OpInit *NewOp = RHSo->clone(NewOperands); > + const Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); > if (NewItem != NewOp) { > *li = NewItem; > - delete NewOp; > } > } > - return new ListInit(NewList, MHSl->getType()); > + return ListInit::Create(NewList, MHSl->getType()); > } > } > return 0; > } > > -Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { > +const Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { > switch (getOpcode()) { > default: assert(0 && "Unknown binop"); > case SUBST: { > - DefInit *LHSd = dynamic_cast(LHS); > - VarInit *LHSv = dynamic_cast(LHS); > - StringInit *LHSs = dynamic_cast(LHS); > - > - DefInit *MHSd = dynamic_cast(MHS); > - VarInit *MHSv = dynamic_cast(MHS); > - StringInit *MHSs = dynamic_cast(MHS); > - > - DefInit *RHSd = dynamic_cast(RHS); > - VarInit *RHSv = dynamic_cast(RHS); > - StringInit *RHSs = dynamic_cast(RHS); > + const DefInit *LHSd = dynamic_cast(LHS); > + const VarInit *LHSv = dynamic_cast(LHS); > + const StringInit *LHSs = dynamic_cast(LHS); > + > + const DefInit *MHSd = dynamic_cast(MHS); > + const VarInit *MHSv = dynamic_cast(MHS); > + const StringInit *MHSs = dynamic_cast(MHS); > + > + const DefInit *RHSd = dynamic_cast(RHS); > + const VarInit *RHSv = dynamic_cast(RHS); > + const StringInit *RHSs = dynamic_cast(RHS); > > if ((LHSd && MHSd && RHSd) > || (LHSv && MHSv && RHSv) > @@ -902,14 +1083,14 @@ > if (LHSd->getAsString() == RHSd->getAsString()) { > Val = MHSd->getDef(); > } > - return new DefInit(Val); > + return DefInit::Create(Val); > } > if (RHSv) { > std::string Val = RHSv->getName(); > if (LHSv->getAsString() == RHSv->getAsString()) { > Val = MHSv->getName(); > } > - return new VarInit(Val, getType()); > + return VarInit::Create(Val, getType()); > } > if (RHSs) { > std::string Val = RHSs->getValue(); > @@ -924,14 +1105,14 @@ > idx = found + MHSs->getValue().size(); > } while (found != std::string::npos); > > - return new StringInit(Val); > + return StringInit::Create(Val); > } > } > break; > } > > case FOREACH: { > - Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), > + const Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), > CurRec, CurMultiClass); > if (Result != 0) { > return Result; > @@ -940,9 +1121,9 @@ > } > > case IF: { > - IntInit *LHSi = dynamic_cast(LHS); > - if (Init *I = LHS->convertInitializerTo(new IntRecTy())) > - LHSi = dynamic_cast(I); > + const IntInit *LHSi = dynamic_cast(LHS); > + if (const Init *I = LHS->convertInitializerTo(new IntRecTy())) > + LHSi = dynamic_cast(I); > if (LHSi) { > if (LHSi->getValue()) { > return MHS; > @@ -957,32 +1138,35 @@ > return this; > } > > -Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) { > - Init *lhs = LHS->resolveReferences(R, RV); > +const Init * > +TernOpInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + const Init *lhs = LHS->resolveReferences(R, RV); > > if (Opc == IF && lhs != LHS) { > - IntInit *Value = dynamic_cast(lhs); > - if (Init *I = lhs->convertInitializerTo(new IntRecTy())) > - Value = dynamic_cast(I); > + const IntInit *Value = dynamic_cast(lhs); > + if (const Init *I = lhs->convertInitializerTo(new IntRecTy())) > + Value = dynamic_cast(I); > if (Value != 0) { > // Short-circuit > if (Value->getValue()) { > - Init *mhs = MHS->resolveReferences(R, RV); > - return (new TernOpInit(getOpcode(), lhs, mhs, > - RHS, getType()))->Fold(&R, 0); > + const Init *mhs = MHS->resolveReferences(R, RV); > + return (TernOpInit::Create(getOpcode(), lhs, mhs, > + RHS, getType()))->Fold(&R, 0); > } else { > - Init *rhs = RHS->resolveReferences(R, RV); > - return (new TernOpInit(getOpcode(), lhs, MHS, > - rhs, getType()))->Fold(&R, 0); > + const Init *rhs = RHS->resolveReferences(R, RV); > + return (TernOpInit::Create(getOpcode(), lhs, MHS, > + rhs, getType()))->Fold(&R, 0); > } > } > } > > - Init *mhs = MHS->resolveReferences(R, RV); > - Init *rhs = RHS->resolveReferences(R, RV); > + const Init *mhs = MHS->resolveReferences(R, RV); > + const Init *rhs = RHS->resolveReferences(R, RV); > > if (LHS != lhs || MHS != mhs || RHS != rhs) > - return (new TernOpInit(getOpcode(), lhs, mhs, rhs, getType()))->Fold(&R, 0); > + return (TernOpInit::Create(getOpcode(), lhs, mhs, rhs, getType()))-> > + Fold(&R, 0); > return Fold(&R, 0); > } > > @@ -1008,79 +1192,97 @@ > return 0; > } > > -Init *TypedInit::convertInitializerBitRange(const std::vector &Bits) { > +const Init * > +TypedInit::convertInitializerBitRange(const std::vector &Bits) const { > BitsRecTy *T = dynamic_cast(getType()); > if (T == 0) return 0; // Cannot subscript a non-bits variable. > unsigned NumBits = T->getNumBits(); > > - BitsInit *BI = new BitsInit(Bits.size()); > + SmallVector NewBits(Bits.size()); > for (unsigned i = 0, e = Bits.size(); i != e; ++i) { > if (Bits[i] >= NumBits) { > - delete BI; > return 0; > } > - BI->setBit(i, new VarBitInit(this, Bits[i])); > + NewBits[i] = VarBitInit::Create(this, Bits[i]); > } > - return BI; > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > } > > -Init *TypedInit::convertInitListSlice(const std::vector &Elements) { > +const Init * > +TypedInit::convertInitListSlice(const std::vector &Elements) const { > ListRecTy *T = dynamic_cast(getType()); > if (T == 0) return 0; // Cannot subscript a non-list variable. > > if (Elements.size() == 1) > - return new VarListElementInit(this, Elements[0]); > + return VarListElementInit::Create(this, Elements[0]); > > - std::vector ListInits; > + std::vector ListInits; > ListInits.reserve(Elements.size()); > for (unsigned i = 0, e = Elements.size(); i != e; ++i) > - ListInits.push_back(new VarListElementInit(this, Elements[i])); > - return new ListInit(ListInits, T); > + ListInits.push_back(VarListElementInit::Create(this, Elements[i])); > + return ListInit::Create(ListInits, T); > } > > > -Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, > - unsigned Bit) { > +const VarInit *VarInit::Create(const std::string &VN, RecTy *T) { > + FoldingSetNodeID ID; > + ID.AddInteger(initVar); > + ID.AddString(VN); > + ID.AddString(T->getAsString()); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + VarInit *I = InitAllocator.Allocate(); > + new (I) VarInit(ID, VN, T); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, > + unsigned Bit) const { > if (R.isTemplateArg(getName())) return 0; > if (IRV && IRV->getName() != getName()) return 0; > > RecordVal *RV = R.getValue(getName()); > assert(RV && "Reference to a non-existent variable?"); > - assert(dynamic_cast(RV->getValue())); > - BitsInit *BI = (BitsInit*)RV->getValue(); > + assert(dynamic_cast(RV->getValue())); > + const BitsInit *BI = (const BitsInit*)RV->getValue(); > > assert(Bit < BI->getNumBits() && "Bit reference out of range!"); > - Init *B = BI->getBit(Bit); > + const Init *B = BI->getBit(Bit); > > // If the bit is set to some value, or if we are resolving a reference to a > // specific variable and that variable is explicitly unset, then replace the > // VarBitInit with it. > - if (IRV || !dynamic_cast(B)) > + if (IRV || !dynamic_cast(B)) > return B; > return 0; > } > > -Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV, > - unsigned Elt) { > +const Init *VarInit::resolveListElementReference(Record &R, > + const RecordVal *IRV, > + unsigned Elt) const { > if (R.isTemplateArg(getName())) return 0; > if (IRV && IRV->getName() != getName()) return 0; > > RecordVal *RV = R.getValue(getName()); > assert(RV && "Reference to a non-existent variable?"); > - ListInit *LI = dynamic_cast(RV->getValue()); > + const ListInit *LI = dynamic_cast(RV->getValue()); > if (!LI) { > - VarInit *VI = dynamic_cast(RV->getValue()); > + const VarInit *VI = dynamic_cast(RV->getValue()); > assert(VI && "Invalid list element!"); > - return new VarListElementInit(VI, Elt); > + return VarListElementInit::Create(VI, Elt); > } > > if (Elt >= LI->getSize()) > return 0; // Out of range reference. > - Init *E = LI->getElement(Elt); > + const Init *E = LI->getElement(Elt); > // If the element is set to some value, or if we are resolving a reference > // to a specific variable and that variable is explicitly unset, then > // replace the VarListElementInit with it. > - if (IRV || !dynamic_cast(E)) > + if (IRV || !dynamic_cast(E)) > return E; > return 0; > } > @@ -1093,15 +1295,15 @@ > return 0; > } > > -Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, > - const std::string &FieldName) const { > +const Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, > + const std::string &FieldName) const { > if (dynamic_cast(getType())) > if (const RecordVal *Val = R.getValue(VarName)) { > - if (RV != Val && (RV || dynamic_cast(Val->getValue()))) > + if (RV != Val && (RV || dynamic_cast(Val->getValue()))) > return 0; > - Init *TheInit = Val->getValue(); > + const Init *TheInit = Val->getValue(); > assert(TheInit != this && "Infinite loop detected!"); > - if (Init *I = TheInit->getFieldInit(R, RV, FieldName)) > + if (const Init *I = TheInit->getFieldInit(R, RV, FieldName)) > return I; > else > return 0; > @@ -1114,56 +1316,112 @@ > /// If a value is set for the variable later, this method will be called on > /// users of the value to allow the value to propagate out. > /// > -Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) { > +const Init *VarInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > if (RecordVal *Val = R.getValue(VarName)) > - if (RV == Val || (RV == 0 && !dynamic_cast(Val->getValue()))) > + if (RV == Val || (RV == 0 > + && !dynamic_cast(Val->getValue()))) > return Val->getValue(); > return this; > } > > +const VarBitInit *VarBitInit::Create(const TypedInit *T, unsigned B) { > + FoldingSetNodeID ID; > + ID.AddInteger(initVarBit); > + ID.AddPointer(T); > + ID.AddInteger(B); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + VarBitInit *I = InitAllocator.Allocate(); > + new (I) VarBitInit(ID, T, B); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > std::string VarBitInit::getAsString() const { > return TI->getAsString() + "{" + utostr(Bit) + "}"; > } > > -Init *VarBitInit::resolveReferences(Record &R, const RecordVal *RV) { > - if (Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) > +const Init * > +VarBitInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + if (const Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) > return I; > return this; > } > > +const VarListElementInit *VarListElementInit::Create(const TypedInit *T, > + unsigned E) { > + FoldingSetNodeID ID; > + ID.AddInteger(initVarListElement); > + ID.AddPointer(T); > + ID.AddInteger(E); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + VarListElementInit *I = InitAllocator.Allocate(); > + new (I) VarListElementInit(ID, T, E); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > std::string VarListElementInit::getAsString() const { > return TI->getAsString() + "[" + utostr(Element) + "]"; > } > > -Init *VarListElementInit::resolveReferences(Record &R, const RecordVal *RV) { > - if (Init *I = getVariable()->resolveListElementReference(R, RV, > - getElementNum())) > +const Init *VarListElementInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + if (const Init *I = > + getVariable()->resolveListElementReference(R, RV, getElementNum())) > return I; > return this; > } > > -Init *VarListElementInit::resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > +const Init *VarListElementInit::resolveBitReference(Record &R, > + const RecordVal *RV, > + unsigned Bit) const { > // FIXME: This should be implemented, to support references like: > // bit B = AA[0]{1}; > return 0; > } > > -Init *VarListElementInit:: > -resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) { > +const Init * > +VarListElementInit::resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > // FIXME: This should be implemented, to support references like: > // int B = AA[0][1]; > return 0; > } > > +const DefInit *DefInit::Create(Record *D) { > + FoldingSetNodeID ID; > + ID.AddInteger(initDef); > + ID.AddString(D->getName()); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + DefInit *I = InitAllocator.Allocate(); > + new (I) DefInit(ID, D); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > RecTy *DefInit::getFieldType(const std::string &FieldName) const { > if (const RecordVal *RV = Def->getValue(FieldName)) > return RV->getType(); > return 0; > } > > -Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, > - const std::string &FieldName) const { > +const Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, > + const std::string &FieldName) const { > return Def->getValue(FieldName)->getValue(); > } > > @@ -1172,59 +1430,134 @@ > return Def->getName(); > } > > -Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > - if (Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) > - if (BitsInit *BI = dynamic_cast(BitsVal)) { > +const FieldInit *FieldInit::Create(const Init *R, const std::string &FN) { > + FoldingSetNodeID ID; > + ID.AddInteger(initField); > + ID.AddPointer(R); > + ID.AddString(FN); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + FieldInit *I = InitAllocator.Allocate(); > + new (I) FieldInit(ID, R, FN); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > + if (const Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) > + if (const BitsInit *BI = dynamic_cast(BitsVal)) { > assert(Bit < BI->getNumBits() && "Bit reference out of range!"); > - Init *B = BI->getBit(Bit); > + const Init *B = BI->getBit(Bit); > > - if (dynamic_cast(B)) // If the bit is set. > + if (dynamic_cast(B)) // If the bit is set. > return B; // Replace the VarBitInit with it. > } > return 0; > } > > -Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) { > - if (Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) > - if (ListInit *LI = dynamic_cast(ListVal)) { > +const Init *FieldInit::resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > + if (const Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) > + if (const ListInit *LI = dynamic_cast(ListVal)) { > if (Elt >= LI->getSize()) return 0; > - Init *E = LI->getElement(Elt); > + const Init *E = LI->getElement(Elt); > > // If the element is set to some value, or if we are resolving a > // reference to a specific variable and that variable is explicitly > // unset, then replace the VarListElementInit with it. > - if (RV || !dynamic_cast(E)) > + if (RV || !dynamic_cast(E)) > return E; > } > return 0; > } > > -Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) { > - Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; > +const Init *FieldInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + const Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; > > - Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); > + const Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); > if (BitsVal) { > - Init *BVR = BitsVal->resolveReferences(R, RV); > + const Init *BVR = BitsVal->resolveReferences(R, RV); > return BVR->isComplete() ? BVR : this; > } > > if (NewRec != Rec) { > - return new FieldInit(NewRec, FieldName); > + return FieldInit::Create(NewRec, FieldName); > } > return this; > } > > -Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) { > - std::vector NewArgs; > +const DagInit * > +DagInit::Create(const Init *V, const std::string &VN, > + const std::vector > &args) { > + FoldingSetNodeID ID; > + ID.AddInteger(initDag); > + ID.AddPointer(V); > + ID.AddString(VN); > + > + for (std::vector >::const_iterator a > + = args.begin(), > + aend = args.end(); > + a != aend; > + ++a) { > + ID.AddPointer(a->first); > + ID.AddString(a->second); > + } > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + DagInit *I = InitAllocator.Allocate(); > + new (I) DagInit(ID, V, VN, args); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const DagInit * > +DagInit::Create(const Init *V, const std::string &VN, > + const std::vector &args, > + const std::vector &argNames) { > + FoldingSetNodeID ID; > + ID.AddInteger(initDag); > + ID.AddPointer(V); > + ID.AddString(VN); > + > + std::vector::const_iterator s = argNames.begin(); > + for (std::vector::const_iterator a > + = args.begin(), > + aend = args.end(); > + a != aend; > + ++a, ++s) { > + ID.AddPointer(*a); > + ID.AddString(*s); > + } > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + DagInit *I = InitAllocator.Allocate(); > + new (I) DagInit(ID, V, VN, args, argNames); > + UniqueInits.InsertNode(I, IP); > + return I; > +} > + > +const Init *DagInit::resolveReferences(Record &R, > + const RecordVal *RV) const { > + std::vector NewArgs; > for (unsigned i = 0, e = Args.size(); i != e; ++i) > NewArgs.push_back(Args[i]->resolveReferences(R, RV)); > > - Init *Op = Val->resolveReferences(R, RV); > + const Init *Op = Val->resolveReferences(R, RV); > > if (Args != NewArgs || Op != Val) > - return new DagInit(Op, ValName, NewArgs, ArgNames); > + return DagInit::Create(Op, ValName, NewArgs, ArgNames); > > return this; > } > @@ -1252,7 +1585,7 @@ > > RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P) > : Name(N), Ty(T), Prefix(P) { > - Value = Ty->convertValue(new UnsetInit()); > + Value = Ty->convertValue(UnsetInit::Create()); > assert(Value && "Cannot create unset value for current type!"); > } > > @@ -1287,7 +1620,7 @@ > /// references. > void Record::resolveReferencesTo(const RecordVal *RV) { > for (unsigned i = 0, e = Values.size(); i != e; ++i) { > - if (Init *V = Values[i].getValue()) > + if (const Init *V = Values[i].getValue()) > Values[i].setValue(V->resolveReferences(*this, RV)); > } > } > @@ -1332,7 +1665,7 @@ > /// getValueInit - Return the initializer for a value with the specified name, > /// or throw an exception if the field does not exist. > /// > -Init *Record::getValueInit(StringRef FieldName) const { > +const Init *Record::getValueInit(StringRef FieldName) const { > const RecordVal *R = getValue(FieldName); > if (R == 0 || R->getValue() == 0) > throw "Record `" + getName() + "' does not have a field named `" + > @@ -1361,13 +1694,13 @@ > /// its value as a BitsInit, throwing an exception if the field does not exist > /// or if the value is not the right type. > /// > -BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { > +const BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { > const RecordVal *R = getValue(FieldName); > if (R == 0 || R->getValue() == 0) > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (BitsInit *BI = dynamic_cast(R->getValue())) > + if (const BitsInit *BI = dynamic_cast(R->getValue())) > return BI; > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have a BitsInit initializer!"; > @@ -1377,13 +1710,13 @@ > /// its value as a ListInit, throwing an exception if the field does not exist > /// or if the value is not the right type. > /// > -ListInit *Record::getValueAsListInit(StringRef FieldName) const { > +const ListInit *Record::getValueAsListInit(StringRef FieldName) const { > const RecordVal *R = getValue(FieldName); > if (R == 0 || R->getValue() == 0) > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (ListInit *LI = dynamic_cast(R->getValue())) > + if (const ListInit *LI = dynamic_cast(R->getValue())) > return LI; > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have a list initializer!"; > @@ -1395,10 +1728,10 @@ > /// > std::vector > Record::getValueAsListOfDefs(StringRef FieldName) const { > - ListInit *List = getValueAsListInit(FieldName); > + const ListInit *List = getValueAsListInit(FieldName); > std::vector Defs; > for (unsigned i = 0; i < List->getSize(); i++) { > - if (DefInit *DI = dynamic_cast(List->getElement(i))) { > + if (const DefInit *DI = dynamic_cast(List->getElement(i))) { > Defs.push_back(DI->getDef()); > } else { > throw "Record `" + getName() + "', field `" + FieldName.str() + > @@ -1418,7 +1751,7 @@ > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (IntInit *II = dynamic_cast(R->getValue())) > + if (const IntInit *II = dynamic_cast(R->getValue())) > return II->getValue(); > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have an int initializer!"; > @@ -1430,10 +1763,10 @@ > /// > std::vector > Record::getValueAsListOfInts(StringRef FieldName) const { > - ListInit *List = getValueAsListInit(FieldName); > + const ListInit *List = getValueAsListInit(FieldName); > std::vector Ints; > for (unsigned i = 0; i < List->getSize(); i++) { > - if (IntInit *II = dynamic_cast(List->getElement(i))) { > + if (const IntInit *II = dynamic_cast(List->getElement(i))) { > Ints.push_back(II->getValue()); > } else { > throw "Record `" + getName() + "', field `" + FieldName.str() + > @@ -1449,10 +1782,11 @@ > /// > std::vector > Record::getValueAsListOfStrings(StringRef FieldName) const { > - ListInit *List = getValueAsListInit(FieldName); > + const ListInit *List = getValueAsListInit(FieldName); > std::vector Strings; > for (unsigned i = 0; i < List->getSize(); i++) { > - if (StringInit *II = dynamic_cast(List->getElement(i))) { > + if (const StringInit *II = > + dynamic_cast(List->getElement(i))) { > Strings.push_back(II->getValue()); > } else { > throw "Record `" + getName() + "', field `" + FieldName.str() + > @@ -1472,7 +1806,7 @@ > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (DefInit *DI = dynamic_cast(R->getValue())) > + if (const DefInit *DI = dynamic_cast(R->getValue())) > return DI->getDef(); > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have a def initializer!"; > @@ -1488,7 +1822,7 @@ > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (BitInit *BI = dynamic_cast(R->getValue())) > + if (const BitInit *BI = dynamic_cast(R->getValue())) > return BI->getValue(); > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have a bit initializer!"; > @@ -1498,13 +1832,13 @@ > /// value as an Dag, throwing an exception if the field does not exist or if > /// the value is not the right type. > /// > -DagInit *Record::getValueAsDag(StringRef FieldName) const { > +const DagInit *Record::getValueAsDag(StringRef FieldName) const { > const RecordVal *R = getValue(FieldName); > if (R == 0 || R->getValue() == 0) > throw "Record `" + getName() + "' does not have a field named `" + > FieldName.str() + "'!\n"; > > - if (DagInit *DI = dynamic_cast(R->getValue())) > + if (const DagInit *DI = dynamic_cast(R->getValue())) > return DI; > throw "Record `" + getName() + "', field `" + FieldName.str() + > "' does not have a dag initializer!"; > > Modified: llvm/trunk/utils/TableGen/Record.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/Record.h (original) > +++ llvm/trunk/utils/TableGen/Record.h Mon Jul 11 13:25:51 2011 > @@ -15,6 +15,8 @@ > #ifndef RECORD_H > #define RECORD_H > > +#include "llvm/ADT/FoldingSet.h" > +#include "llvm/Support/Allocator.h" > #include "llvm/Support/SourceMgr.h" > #include "llvm/Support/DataTypes.h" > #include "llvm/Support/raw_ostream.h" > @@ -75,31 +77,31 @@ > virtual bool typeIsConvertibleTo(const RecTy *RHS) const = 0; > > public: // These methods should only be called from subclasses of Init > - virtual Init *convertValue( UnsetInit *UI) { return 0; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { > - return convertValue((TypedInit*)UI); > - } > - virtual Init *convertValue( BinOpInit *UI) { > - return convertValue((TypedInit*)UI); > - } > - virtual Init *convertValue( TernOpInit *UI) { > - return convertValue((TypedInit*)UI); > - } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( TypedInit *TI) { return 0; } > - virtual Init *convertValue( VarInit *VI) { > - return convertValue((TypedInit*)VI); > + virtual const Init *convertValue(const UnsetInit *UI) { return 0; } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return convertValue((const TypedInit*)UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return convertValue((const TypedInit*)UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return convertValue((const TypedInit*)UI); > + } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const TypedInit *TI) { return 0; } > + virtual const Init *convertValue(const VarInit *VI) { > + return convertValue((const TypedInit*)VI); > } > - virtual Init *convertValue( FieldInit *FI) { > - return convertValue((TypedInit*)FI); > + virtual const Init *convertValue(const FieldInit *FI) { > + return convertValue((const TypedInit*)FI); > } > > public: // These methods should only be called by subclasses of RecTy. > @@ -125,22 +127,38 @@ > /// > class BitRecTy : public RecTy { > public: > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return (Init*)BI; } > - virtual Init *convertValue( BitsInit *BI); > - virtual Init *convertValue( IntInit *II); > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return (Init*)VB; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { > + return (const Init*)BI; > + } > + virtual const Init *convertValue(const BitsInit *BI); > + virtual const Init *convertValue(const IntInit *II); > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { > + return (const Init*)VB; > + } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const { return "bit"; } > > @@ -169,22 +187,32 @@ > > unsigned getNumBits() const { return Size; } > > - virtual Init *convertValue( UnsetInit *UI); > - virtual Init *convertValue( BitInit *UI); > - virtual Init *convertValue( BitsInit *BI); > - virtual Init *convertValue( IntInit *II); > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI); > + virtual const Init *convertValue(const BitInit *UI); > + virtual const Init *convertValue(const BitsInit *BI); > + virtual const Init *convertValue(const IntInit *II); > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const; > > @@ -209,22 +237,36 @@ > /// > class IntRecTy : public RecTy { > public: > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI); > - virtual Init *convertValue( BitsInit *BI); > - virtual Init *convertValue( IntInit *II) { return (Init*)II; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI); > + virtual const Init *convertValue(const BitsInit *BI); > + virtual const Init *convertValue(const IntInit *II) { > + return (const Init*)II; > + } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const { return "int"; } > > @@ -247,23 +289,33 @@ > /// > class StringRecTy : public RecTy { > public: > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return (Init*)SI; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( UnOpInit *BO); > - virtual Init *convertValue( BinOpInit *BO); > - virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} > - > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { > + return (const Init*)SI; > + } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *BO); > + virtual const Init *convertValue(const BinOpInit *BO); > + virtual const Init *convertValue(const TernOpInit *BO) { > + return RecTy::convertValue(BO); > + } > + > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const { return "string"; } > > @@ -293,22 +345,34 @@ > > RecTy *getElementType() const { return Ty; } > > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI); > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI); > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const; > > @@ -332,22 +396,36 @@ > /// > class CodeRecTy : public RecTy { > public: > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return (Init*)CI; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { > + return (const Init*)CI; > + } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const { return "code"; } > > @@ -368,22 +446,32 @@ > /// > class DagRecTy : public RecTy { > public: > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( DefInit *DI) { return 0; } > - virtual Init *convertValue( UnOpInit *BO); > - virtual Init *convertValue( BinOpInit *BO); > - virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} > - virtual Init *convertValue( DagInit *CI) { return (Init*)CI; } > - virtual Init *convertValue( TypedInit *TI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const DefInit *DI) { return 0; } > + virtual const Init *convertValue(const UnOpInit *BO); > + virtual const Init *convertValue(const BinOpInit *BO); > + virtual const Init *convertValue(const TernOpInit *BO) { > + return RecTy::convertValue(BO); > + } > + virtual const Init *convertValue(const DagInit *CI) { > + return (const Init*)CI; > + } > + virtual const Init *convertValue(const TypedInit *TI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const { return "dag"; } > > @@ -412,22 +500,34 @@ > > Record *getRecord() const { return Rec; } > > - virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } > - virtual Init *convertValue( BitInit *BI) { return 0; } > - virtual Init *convertValue( BitsInit *BI) { return 0; } > - virtual Init *convertValue( IntInit *II) { return 0; } > - virtual Init *convertValue(StringInit *SI) { return 0; } > - virtual Init *convertValue( ListInit *LI) { return 0; } > - virtual Init *convertValue( CodeInit *CI) { return 0; } > - virtual Init *convertValue(VarBitInit *VB) { return 0; } > - virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} > - virtual Init *convertValue( DefInit *DI); > - virtual Init *convertValue( DagInit *DI) { return 0; } > - virtual Init *convertValue( TypedInit *VI); > - virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} > - virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} > + virtual const Init *convertValue(const UnsetInit *UI) { > + return (const Init*)UI; > + } > + virtual const Init *convertValue(const BitInit *BI) { return 0; } > + virtual const Init *convertValue(const BitsInit *BI) { return 0; } > + virtual const Init *convertValue(const IntInit *II) { return 0; } > + virtual const Init *convertValue(const StringInit *SI) { return 0; } > + virtual const Init *convertValue(const ListInit *LI) { return 0; } > + virtual const Init *convertValue(const CodeInit *CI) { return 0; } > + virtual const Init *convertValue(const VarBitInit *VB) { return 0; } > + virtual const Init *convertValue(const UnOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const BinOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const TernOpInit *UI) { > + return RecTy::convertValue(UI); > + } > + virtual const Init *convertValue(const DefInit *DI); > + virtual const Init *convertValue(const DagInit *DI) { return 0; } > + virtual const Init *convertValue(const TypedInit *VI); > + virtual const Init *convertValue(const VarInit *VI) { > + return RecTy::convertValue(VI); > + } > + virtual const Init *convertValue(const FieldInit *FI) { > + return RecTy::convertValue(FI); > + } > > std::string getAsString() const; > > @@ -453,9 +553,43 @@ > // Initializer Classes > //===----------------------------------------------------------------------===// > > -struct Init { > +class Init : public FastFoldingSetNode { > + Init(const Init &); // Do not define. > + Init &operator=(const Init &); // Do not define. > + > +protected: > + Init(const FoldingSetNodeID &ID) : FastFoldingSetNode(ID) {} > + > + static FoldingSet UniqueInits; > + static BumpPtrAllocator InitAllocator; > + > + enum Type { > + initUnset, > + initBit, > + initBits, > + initInt, > + initString, > + initCode, > + initList, > + initUnOp, > + initBinOp, > + initTernOp, > + initQuadOp, > + initVar, > + initVarBit, > + initVarListElement, > + initDef, > + initField, > + initDag > + }; > + > +public: > virtual ~Init() {} > > + static void ReleaseMemory() { > + InitAllocator.Reset(); > + } > + > /// isComplete - This virtual method should be overridden by values that may > /// not be completely specified yet. > virtual bool isComplete() const { return true; } > @@ -474,14 +608,15 @@ > /// function that should be overridden to call the appropriate > /// RecTy::convertValue method. > /// > - virtual Init *convertInitializerTo(RecTy *Ty) = 0; > + virtual const Init *convertInitializerTo(RecTy *Ty) const = 0; > > /// convertInitializerBitRange - This method is used to implement the bitrange > /// selection operator. Given an initializer, it selects the specified bits > /// out, returning them as a new init of bits type. If it is not legal to use > /// the bit subscript operator on this initializer, return null. > /// > - virtual Init *convertInitializerBitRange(const std::vector &Bits) { > + virtual const Init * > + convertInitializerBitRange(const std::vector &Bits) const { > return 0; > } > > @@ -490,7 +625,8 @@ > /// elements, returning them as a new init of list type. If it is not legal > /// to take a slice of this, return null. > /// > - virtual Init *convertInitListSlice(const std::vector &Elements) { > + virtual const Init * > + convertInitListSlice(const std::vector &Elements) const { > return 0; > } > > @@ -504,8 +640,8 @@ > /// initializer for the specified field. If getFieldType returns non-null > /// this method should return non-null, otherwise it returns null. > /// > - virtual Init *getFieldInit(Record &R, const RecordVal *RV, > - const std::string &FieldName) const { > + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, > + const std::string &FieldName) const { > return 0; > } > > @@ -514,7 +650,8 @@ > /// If a value is set for the variable later, this method will be called on > /// users of the value to allow the value to propagate out. > /// > - virtual Init *resolveReferences(Record &R, const RecordVal *RV) { > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const { > return this; > } > }; > @@ -528,13 +665,20 @@ > /// > class TypedInit : public Init { > RecTy *Ty; > -public: > - explicit TypedInit(RecTy *T) : Ty(T) {} > > + TypedInit(const TypedInit &Other); // Do not define. > + TypedInit &operator=(const TypedInit &Other); // Do not define. > + > +protected: > + explicit TypedInit(const FoldingSetNodeID &ID, RecTy *T) : Init(ID), Ty(T) {} > + > +public: > RecTy *getType() const { return Ty; } > > - virtual Init *convertInitializerBitRange(const std::vector &Bits); > - virtual Init *convertInitListSlice(const std::vector &Elements); > + virtual const Init * > + convertInitializerBitRange(const std::vector &Bits) const; > + virtual const Init * > + convertInitListSlice(const std::vector &Elements) const; > > /// getFieldType - This method is used to implement the FieldInit class. > /// Implementors of this method should return the type of the named field if > @@ -546,22 +690,29 @@ > /// VarBitInit::resolveReferences. If the bit is able to be resolved, we > /// simply return the resolved value, otherwise we return null. > /// > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) = 0; > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const = 0; > > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) = 0; > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const = 0; > }; > > > /// UnsetInit - ? - Represents an uninitialized value > /// > class UnsetInit : public Init { > + UnsetInit(const FoldingSetNodeID &ID) : Init(ID) {} > + UnsetInit(const UnsetInit &); // Do not define. > + UnsetInit &operator=(const UnsetInit &Other); // Do not define. > + > public: > - virtual Init *convertInitializerTo(RecTy *Ty) { > + static const UnsetInit *Create(); > + > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > @@ -574,12 +725,17 @@ > /// > class BitInit : public Init { > bool Value; > + > + explicit BitInit(const FoldingSetNodeID &ID, bool V) : Init(ID), Value(V) {} > + BitInit(const BitInit &Other); // Do not define. > + BitInit &operator=(BitInit &Other); // Do not define. > + > public: > - explicit BitInit(bool V) : Value(V) {} > + static const BitInit *Create(bool V); > > bool getValue() const { return Value; } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > @@ -590,26 +746,56 @@ > /// It contains a vector of bits, whose size is determined by the type. > /// > class BitsInit : public Init { > - std::vector Bits; > + std::vector Bits; > + > + BitsInit(const FoldingSetNodeID &ID, unsigned Size) > + : Init(ID), Bits(Size) {} > + > + template > + BitsInit(const FoldingSetNodeID &ID, InputIterator start, InputIterator end) > + : Init(ID), Bits(start, end) {} > + > + BitsInit(const BitsInit &Other); // Do not define. > + BitsInit &operator=(const BitsInit &Other); // Do not define. > + > public: > - explicit BitsInit(unsigned Size) : Bits(Size) {} > + template > + static const BitsInit *Create(InputIterator Start, InputIterator End) { > + FoldingSetNodeID ID; > + ID.AddInteger(initBits); > + ID.AddInteger(std::distance(Start, End)); > + > + InputIterator S = Start; > + while (S != End) > + ID.AddPointer(*S++); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + BitsInit *I = InitAllocator.Allocate(); > + new (I) BitsInit(ID, Start, End); > + UniqueInits.InsertNode(I, IP); > + return I; > + } > > unsigned getNumBits() const { return Bits.size(); } > > - Init *getBit(unsigned Bit) const { > + const Init *getBit(unsigned Bit) const { > assert(Bit < Bits.size() && "Bit index out of range!"); > return Bits[Bit]; > } > - void setBit(unsigned Bit, Init *V) { > + void setBit(unsigned Bit, const Init *V) { > assert(Bit < Bits.size() && "Bit index out of range!"); > assert(Bits[Bit] == 0 && "Bit already set!"); > Bits[Bit] = V; > } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > - virtual Init *convertInitializerBitRange(const std::vector &Bits); > + virtual const Init * > + convertInitializerBitRange(const std::vector &Bits) const; > > virtual bool isComplete() const { > for (unsigned i = 0; i != getNumBits(); ++i) > @@ -623,7 +809,8 @@ > } > virtual std::string getAsString() const; > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > }; > > > @@ -631,15 +818,23 @@ > /// > class IntInit : public TypedInit { > int64_t Value; > + > + explicit IntInit(const FoldingSetNodeID &ID, int64_t V) > + : TypedInit(ID, new IntRecTy), Value(V) {} > + > + IntInit(const IntInit &Other); // Do not define. > + IntInit &operator=(const IntInit &Other); // Do note define. > + > public: > - explicit IntInit(int64_t V) : TypedInit(new IntRecTy), Value(V) {} > + static const IntInit *Create(int64_t V); > > int64_t getValue() const { return Value; } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > - virtual Init *convertInitializerBitRange(const std::vector &Bits); > + virtual const Init * > + convertInitializerBitRange(const std::vector &Bits) const; > > virtual std::string getAsString() const; > > @@ -647,8 +842,8 @@ > /// VarBitInit::resolveReferences. If the bit is able to be resolved, we > /// simply return the resolved value, otherwise we return null. > /// > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > assert(0 && "Illegal bit reference off int"); > return 0; > } > @@ -656,8 +851,9 @@ > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) { > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > assert(0 && "Illegal element reference off int"); > return 0; > } > @@ -668,13 +864,19 @@ > /// > class StringInit : public TypedInit { > std::string Value; > + > + explicit StringInit(const FoldingSetNodeID &ID, const std::string &V) > + : TypedInit(ID, new StringRecTy), Value(V) {} > + > + StringInit(const StringInit &Other); // Do not define. > + StringInit &operator=(const StringInit &Other); // Do not define. > + > public: > - explicit StringInit(const std::string &V) > - : TypedInit(new StringRecTy), Value(V) {} > + static const StringInit *Create(const std::string &V); > > const std::string &getValue() const { return Value; } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > @@ -684,8 +886,8 @@ > /// VarBitInit::resolveReferences. If the bit is able to be resolved, we > /// simply return the resolved value, otherwise we return null. > /// > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > assert(0 && "Illegal bit reference off string"); > return 0; > } > @@ -693,8 +895,9 @@ > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) { > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > assert(0 && "Illegal element reference off string"); > return 0; > } > @@ -704,12 +907,19 @@ > /// > class CodeInit : public Init { > std::string Value; > + > + explicit CodeInit(const FoldingSetNodeID &ID, const std::string &V) > + : Init(ID), Value(V) {} > + > + CodeInit(const CodeInit &Other); // Do not define. > + CodeInit &operator=(const CodeInit &Other); // Do not define. > + > public: > - explicit CodeInit(const std::string &V) : Value(V) {} > + static const CodeInit *Create(const std::string &V); > > const std::string &getValue() const { return Value; } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > @@ -719,29 +929,61 @@ > /// ListInit - [AL, AH, CL] - Represent a list of defs > /// > class ListInit : public TypedInit { > - std::vector Values; > + std::vector Values; > + > public: > - typedef std::vector::iterator iterator; > - typedef std::vector::const_iterator const_iterator; > + typedef std::vector::const_iterator const_iterator; > > - explicit ListInit(std::vector &Vs, RecTy *EltTy) > - : TypedInit(new ListRecTy(EltTy)) { > +private: > + ListInit(const FoldingSetNodeID &ID, std::vector &Vs, > + RecTy *EltTy) > + : TypedInit(ID, new ListRecTy(EltTy)) { > Values.swap(Vs); > } > - explicit ListInit(iterator Start, iterator End, RecTy *EltTy) > - : TypedInit(new ListRecTy(EltTy)), Values(Start, End) {} > + > + template > + ListInit(const FoldingSetNodeID &ID, InputIterator Start, InputIterator End, > + RecTy *EltTy) > + : TypedInit(ID, new ListRecTy(EltTy)), Values(Start, End) {} > + > + ListInit(const ListInit &Other); // Do not define. > + ListInit &operator=(const ListInit &Other); // Do not define. > + > +public: > + static const ListInit *Create(std::vector &Vs, RecTy *EltTy); > + > + template > + static const ListInit *Create(InputIterator Start, InputIterator End, > + RecTy *EltTy) { > + FoldingSetNodeID ID; > + ID.AddInteger(initList); > + ID.AddString(EltTy->getAsString()); > + > + InputIterator S = Start; > + while (S != End) > + ID.AddPointer(*S++); > + > + void *IP = 0; > + if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) > + return static_cast(I); > + > + ListInit *I = InitAllocator.Allocate(); > + new (I) ListInit(ID, Start, End, EltTy); > + UniqueInits.InsertNode(I, IP); > + return I; > + } > > unsigned getSize() const { return Values.size(); } > - Init *getElement(unsigned i) const { > + const Init *getElement(unsigned i) const { > assert(i < Values.size() && "List element index out of range!"); > return Values[i]; > } > > Record *getElementAsRecord(unsigned i) const; > > - Init *convertInitListSlice(const std::vector &Elements); > + const Init *convertInitListSlice(const std::vector &Elements) const; > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > @@ -750,13 +992,12 @@ > /// If a value is set for the variable later, this method will be called on > /// users of the value to allow the value to propagate out. > /// > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const; > > - inline iterator begin() { return Values.begin(); } > inline const_iterator begin() const { return Values.begin(); } > - inline iterator end () { return Values.end(); } > inline const_iterator end () const { return Values.end(); } > > inline size_t size () const { return Values.size(); } > @@ -766,8 +1007,8 @@ > /// VarBitInit::resolveReferences. If the bit is able to be resolved, we > /// simply return the resolved value, otherwise we return null. > /// > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > assert(0 && "Illegal bit reference off list"); > return 0; > } > @@ -775,35 +1016,42 @@ > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt); > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const; > }; > > > /// OpInit - Base class for operators > /// > class OpInit : public TypedInit { > -public: > - OpInit(RecTy *Type) : TypedInit(Type) {} > + OpInit(const OpInit &Other); // Do not define. > + OpInit &operator=(OpInit &Other); // Do not define. > + > +protected: > + explicit OpInit(const FoldingSetNodeID &ID, RecTy *Type) > + : TypedInit(ID, Type) {} > > +public: > // Clone - Clone this operator, replacing arguments with the new list > - virtual OpInit *clone(std::vector &Operands) = 0; > + virtual const OpInit *clone(std::vector &Operands) const = 0; > > virtual int getNumOperands() const = 0; > - virtual Init *getOperand(int i) = 0; > + virtual const Init *getOperand(int i) const = 0; > > // Fold - If possible, fold this to a simpler init. Return this if not > // possible to fold. > - virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) = 0; > + virtual const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0; > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit); > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt); > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const; > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const; > }; > > > @@ -814,33 +1062,40 @@ > enum UnaryOp { CAST, HEAD, TAIL, EMPTY }; > private: > UnaryOp Opc; > - Init *LHS; > + const Init *LHS; > + > + UnOpInit(const FoldingSetNodeID &ID, UnaryOp opc, const Init *lhs, > + RecTy *Type) > + : OpInit(ID, Type), Opc(opc), LHS(lhs) {} > + > + UnOpInit(const UnOpInit &Other); // Do not define. > + UnOpInit &operator=(const UnOpInit &Other); // Do not define. > + > public: > - UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type) : > - OpInit(Type), Opc(opc), LHS(lhs) { > - } > + static const UnOpInit *Create(UnaryOp opc, const Init *lhs, RecTy *Type); > > // Clone - Clone this operator, replacing arguments with the new list > - virtual OpInit *clone(std::vector &Operands) { > + virtual const OpInit *clone(std::vector &Operands) const { > assert(Operands.size() == 1 && > "Wrong number of operands for unary operation"); > - return new UnOpInit(getOpcode(), *Operands.begin(), getType()); > + return UnOpInit::Create(getOpcode(), *Operands.begin(), getType()); > } > > int getNumOperands() const { return 1; } > - Init *getOperand(int i) { > + const Init *getOperand(int i) const { > assert(i == 0 && "Invalid operand id for unary operator"); > return getOperand(); > } > > UnaryOp getOpcode() const { return Opc; } > - Init *getOperand() const { return LHS; } > + const Init *getOperand() const { return LHS; } > > // Fold - If possible, fold this to a simpler init. Return this if not > // possible to fold. > - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); > + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass)const ; > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const; > }; > @@ -852,21 +1107,28 @@ > enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, EQ }; > private: > BinaryOp Opc; > - Init *LHS, *RHS; > + const Init *LHS, *RHS; > + > + BinOpInit(const FoldingSetNodeID &ID, BinaryOp opc, const Init *lhs, > + const Init *rhs, RecTy *Type) : > + OpInit(ID, Type), Opc(opc), LHS(lhs), RHS(rhs) {} > + > + BinOpInit(const BinOpInit &Other); // Do not define. > + BinOpInit &operator=(const BinOpInit &Other); // Do not define. > + > public: > - BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) : > - OpInit(Type), Opc(opc), LHS(lhs), RHS(rhs) { > - } > + static const BinOpInit *Create(BinaryOp opc, const Init *lhs, const Init *rhs, > + RecTy *Type); > > // Clone - Clone this operator, replacing arguments with the new list > - virtual OpInit *clone(std::vector &Operands) { > + virtual const OpInit *clone(std::vector &Operands) const { > assert(Operands.size() == 2 && > "Wrong number of operands for binary operation"); > - return new BinOpInit(getOpcode(), Operands[0], Operands[1], getType()); > + return BinOpInit::Create(getOpcode(), Operands[0], Operands[1], getType()); > } > > int getNumOperands() const { return 2; } > - Init *getOperand(int i) { > + const Init *getOperand(int i) const { > assert((i == 0 || i == 1) && "Invalid operand id for binary operator"); > if (i == 0) { > return getLHS(); > @@ -876,14 +1138,15 @@ > } > > BinaryOp getOpcode() const { return Opc; } > - Init *getLHS() const { return LHS; } > - Init *getRHS() const { return RHS; } > + const Init *getLHS() const { return LHS; } > + const Init *getRHS() const { return RHS; } > > // Fold - If possible, fold this to a simpler init. Return this if not > // possible to fold. > - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); > + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const; > }; > @@ -895,22 +1158,30 @@ > enum TernaryOp { SUBST, FOREACH, IF }; > private: > TernaryOp Opc; > - Init *LHS, *MHS, *RHS; > + const Init *LHS, *MHS, *RHS; > + > + TernOpInit(const FoldingSetNodeID &ID, TernaryOp opc, const Init *lhs, > + const Init *mhs, const Init *rhs, RecTy *Type) : > + OpInit(ID, Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) {} > + > + TernOpInit(const TernOpInit &Other); // Do not define. > + TernOpInit &operator=(const TernOpInit &Other); // Do not define. > + > public: > - TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type) : > - OpInit(Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) { > - } > + static const TernOpInit *Create(TernaryOp opc, const Init *lhs, > + const Init *mhs, const Init *rhs, > + RecTy *Type); > > // Clone - Clone this operator, replacing arguments with the new list > - virtual OpInit *clone(std::vector &Operands) { > + virtual const OpInit *clone(std::vector &Operands) const { > assert(Operands.size() == 3 && > "Wrong number of operands for ternary operation"); > - return new TernOpInit(getOpcode(), Operands[0], Operands[1], Operands[2], > - getType()); > + return TernOpInit::Create(getOpcode(), Operands[0], Operands[1], > + Operands[2], getType()); > } > > int getNumOperands() const { return 3; } > - Init *getOperand(int i) { > + const Init *getOperand(int i) const { > assert((i == 0 || i == 1 || i == 2) && > "Invalid operand id for ternary operator"); > if (i == 0) { > @@ -923,17 +1194,18 @@ > } > > TernaryOp getOpcode() const { return Opc; } > - Init *getLHS() const { return LHS; } > - Init *getMHS() const { return MHS; } > - Init *getRHS() const { return RHS; } > + const Init *getLHS() const { return LHS; } > + const Init *getMHS() const { return MHS; } > + const Init *getRHS() const { return RHS; } > > // Fold - If possible, fold this to a simpler init. Return this if not > // possible to fold. > - Init *Fold(Record *CurRec, MultiClass *CurMultiClass); > + const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; > > virtual bool isComplete() const { return false; } > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const; > }; > @@ -943,23 +1215,31 @@ > /// > class VarInit : public TypedInit { > std::string VarName; > + > + explicit VarInit(const FoldingSetNodeID &ID, const std::string &VN, RecTy *T) > + : TypedInit(ID, T), VarName(VN) {} > + > + VarInit(const VarInit &Other); // Do not define. > + VarInit &operator=(const VarInit &Other); // Do not define. > + > public: > - explicit VarInit(const std::string &VN, RecTy *T) > - : TypedInit(T), VarName(VN) {} > + static const VarInit *Create(const std::string &VN, RecTy *T); > + static const VarInit *Create(const Init *VN, RecTy *T); > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > const std::string &getName() const { return VarName; } > > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit); > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt); > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const; > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const; > > virtual RecTy *getFieldType(const std::string &FieldName) const; > - virtual Init *getFieldInit(Record &R, const RecordVal *RV, > + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, > const std::string &FieldName) const; > > /// resolveReferences - This method is used by classes that refer to other > @@ -967,7 +1247,8 @@ > /// If a value is set for the variable later, this method will be called on > /// users of the value to allow the value to propagate out. > /// > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const { return VarName; } > }; > @@ -976,76 +1257,101 @@ > /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field. > /// > class VarBitInit : public Init { > - TypedInit *TI; > + const TypedInit *TI; > unsigned Bit; > -public: > - VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) { > + > + VarBitInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned B) > + : Init(ID), TI(T), Bit(B) { > assert(T->getType() && dynamic_cast(T->getType()) && > ((BitsRecTy*)T->getType())->getNumBits() > B && > "Illegal VarBitInit expression!"); > } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + VarBitInit(const VarBitInit &Other); // Do not define. > + VarBitInit &operator=(const VarBitInit &Other); // Do not define. > + > +public: > + static const VarBitInit *Create(const TypedInit *T, unsigned B); > + > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > - TypedInit *getVariable() const { return TI; } > + const TypedInit *getVariable() const { return TI; } > unsigned getBitNum() const { return Bit; } > > virtual std::string getAsString() const; > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > }; > > /// VarListElementInit - List[4] - Represent access to one element of a var or > /// field. > class VarListElementInit : public TypedInit { > - TypedInit *TI; > + const TypedInit *TI; > unsigned Element; > -public: > - VarListElementInit(TypedInit *T, unsigned E) > - : TypedInit(dynamic_cast(T->getType())->getElementType()), > + > + VarListElementInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned E) > + : TypedInit(ID, dynamic_cast(T->getType())->getElementType()), > TI(T), Element(E) { > assert(T->getType() && dynamic_cast(T->getType()) && > "Illegal VarBitInit expression!"); > } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + VarListElementInit(const VarListElementInit &Other); // Do not define. > + VarListElementInit &operator=(const VarListElementInit &Other); // Do > + // not > + // define. > + > +public: > + static const VarListElementInit *Create(const TypedInit *T, unsigned E); > + > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > - TypedInit *getVariable() const { return TI; } > + const TypedInit *getVariable() const { return TI; } > unsigned getElementNum() const { return Element; } > > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit); > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const; > > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt); > + virtual const Init *resolveListElementReference(Record &R, const RecordVal *RV, > + unsigned Elt) const; > > virtual std::string getAsString() const; > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > }; > > /// DefInit - AL - Represent a reference to a 'def' in the description > /// > class DefInit : public TypedInit { > Record *Def; > + > + explicit DefInit(const FoldingSetNodeID &ID, Record *D) > + : TypedInit(ID, new RecordRecTy(D)), Def(D) {} > + > + DefInit(const DefInit &Other); // Do not define. > + DefInit &operator=(const DefInit &Other); // Do not define. > + > public: > - explicit DefInit(Record *D) : TypedInit(new RecordRecTy(D)), Def(D) {} > + static const DefInit *Create(Record *D); > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > Record *getDef() const { return Def; } > > - //virtual Init *convertInitializerBitRange(const std::vector &Bits); > + //virtual const Init * > + //convertInitializerBitRange(const std::vector &Bits) const; > > virtual RecTy *getFieldType(const std::string &FieldName) const; > - virtual Init *getFieldInit(Record &R, const RecordVal *RV, > + virtual const Init *getFieldInit(Record &R, const RecordVal *RV, > const std::string &FieldName) const; > > virtual std::string getAsString() const; > @@ -1054,8 +1360,8 @@ > /// VarBitInit::resolveReferences. If the bit is able to be resolved, we > /// simply return the resolved value, otherwise we return null. > /// > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > assert(0 && "Illegal bit reference off def"); > return 0; > } > @@ -1063,8 +1369,9 @@ > /// resolveListElementReference - This method is used to implement > /// VarListElementInit::resolveReferences. If the list element is resolvable > /// now, we return the resolved value, otherwise we return null. > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) { > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > assert(0 && "Illegal element reference off def"); > return 0; > } > @@ -1074,24 +1381,33 @@ > /// FieldInit - X.Y - Represent a reference to a subfield of a variable > /// > class FieldInit : public TypedInit { > - Init *Rec; // Record we are referring to > + const Init *Rec; // Record we are referring to > std::string FieldName; // Field we are accessing > -public: > - FieldInit(Init *R, const std::string &FN) > - : TypedInit(R->getFieldType(FN)), Rec(R), FieldName(FN) { > + > + FieldInit(const FoldingSetNodeID &ID, const Init *R, const std::string &FN) > + : TypedInit(ID, R->getFieldType(FN)), Rec(R), FieldName(FN) { > assert(getType() && "FieldInit with non-record type!"); > } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + FieldInit(const FieldInit &Other); // Do not define. > + FieldInit &operator=(const FieldInit &Other); // Do not define. > + > +public: > + static const FieldInit *Create(const Init *R, const std::string &FN); > + static const FieldInit *Create(const Init *R, const Init *FN); > + > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit); > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt); > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const; > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const; > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const { > return Rec->getAsString() + "." + FieldName; > @@ -1103,14 +1419,14 @@ > /// argument can have a name associated with it. > /// > class DagInit : public TypedInit { > - Init *Val; > + const Init *Val; > std::string ValName; > - std::vector Args; > + std::vector Args; > std::vector ArgNames; > -public: > - DagInit(Init *V, std::string VN, > - const std::vector > &args) > - : TypedInit(new DagRecTy), Val(V), ValName(VN) { > + > + DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, > + const std::vector > &args) > + : TypedInit(ID, new DagRecTy), Val(V), ValName(VN) { > Args.reserve(args.size()); > ArgNames.reserve(args.size()); > for (unsigned i = 0, e = args.size(); i != e; ++i) { > @@ -1118,21 +1434,33 @@ > ArgNames.push_back(args[i].second); > } > } > - DagInit(Init *V, std::string VN, const std::vector &args, > + DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, > + const std::vector &args, > const std::vector &argNames) > - : TypedInit(new DagRecTy), Val(V), ValName(VN), Args(args), > + : TypedInit(ID, new DagRecTy), Val(V), ValName(VN), Args(args), > ArgNames(argNames) { } > > - virtual Init *convertInitializerTo(RecTy *Ty) { > + DagInit(const DagInit &Other); // Do not define. > + DagInit &operator=(const DagInit &Other); // Do not define. > + > +public: > + static const DagInit *Create(const Init *V, const std::string &VN, > + const std::vector< > + std::pair > &args); > + static const DagInit *Create(const Init *V, const std::string &VN, > + const std::vector &args, > + const std::vector &argNames); > + > + virtual const Init *convertInitializerTo(RecTy *Ty) const { > return Ty->convertValue(this); > } > > - Init *getOperator() const { return Val; } > + const Init *getOperator() const { return Val; } > > const std::string &getName() const { return ValName; } > > unsigned getNumArgs() const { return Args.size(); } > - Init *getArg(unsigned Num) const { > + const Init *getArg(unsigned Num) const { > assert(Num < Args.size() && "Arg number out of range!"); > return Args[Num]; > } > @@ -1141,17 +1469,18 @@ > return ArgNames[Num]; > } > > - void setArg(unsigned Num, Init *I) { > + void setArg(unsigned Num, const Init *I) { > assert(Num < Args.size() && "Arg number out of range!"); > Args[Num] = I; > } > > - virtual Init *resolveReferences(Record &R, const RecordVal *RV); > + virtual const Init *resolveReferences(Record &R, > + const RecordVal *RV) const; > > virtual std::string getAsString() const; > > - typedef std::vector::iterator arg_iterator; > - typedef std::vector::const_iterator const_arg_iterator; > + typedef std::vector::iterator arg_iterator; > + typedef std::vector::const_iterator const_arg_iterator; > typedef std::vector::iterator name_iterator; > typedef std::vector::const_iterator const_name_iterator; > > @@ -1171,14 +1500,15 @@ > inline size_t name_size () const { return ArgNames.size(); } > inline bool name_empty() const { return ArgNames.empty(); } > > - virtual Init *resolveBitReference(Record &R, const RecordVal *RV, > - unsigned Bit) { > + virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, > + unsigned Bit) const { > assert(0 && "Illegal bit reference off dag"); > return 0; > } > > - virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, > - unsigned Elt) { > + virtual const Init *resolveListElementReference(Record &R, > + const RecordVal *RV, > + unsigned Elt) const { > assert(0 && "Illegal element reference off dag"); > return 0; > } > @@ -1192,7 +1522,7 @@ > std::string Name; > RecTy *Ty; > unsigned Prefix; > - Init *Value; > + const Init *Value; > public: > RecordVal(const std::string &N, RecTy *T, unsigned P); > > @@ -1200,9 +1530,9 @@ > > unsigned getPrefix() const { return Prefix; } > RecTy *getType() const { return Ty; } > - Init *getValue() const { return Value; } > + const Init *getValue() const { return Value; } > > - bool setValue(Init *V) { > + bool setValue(const Init *V) { > if (V) { > Value = V->convertInitializerTo(Ty); > return Value == 0; > @@ -1336,7 +1666,7 @@ > /// getValueInit - Return the initializer for a value with the specified name, > /// or throw an exception if the field does not exist. > /// > - Init *getValueInit(StringRef FieldName) const; > + const Init *getValueInit(StringRef FieldName) const; > > /// getValueAsString - This method looks up the specified field and returns > /// its value as a string, throwing an exception if the field does not exist > @@ -1348,13 +1678,13 @@ > /// its value as a BitsInit, throwing an exception if the field does not exist > /// or if the value is not the right type. > /// > - BitsInit *getValueAsBitsInit(StringRef FieldName) const; > + const BitsInit *getValueAsBitsInit(StringRef FieldName) const; > > /// getValueAsListInit - This method looks up the specified field and returns > /// its value as a ListInit, throwing an exception if the field does not exist > /// or if the value is not the right type. > /// > - ListInit *getValueAsListInit(StringRef FieldName) const; > + const ListInit *getValueAsListInit(StringRef FieldName) const; > > /// getValueAsListOfDefs - This method looks up the specified field and > /// returns its value as a vector of records, throwing an exception if the > @@ -1396,7 +1726,7 @@ > /// value as an Dag, throwing an exception if the field does not exist or if > /// the value is not the right type. > /// > - DagInit *getValueAsDag(StringRef FieldName) const; > + const DagInit *getValueAsDag(StringRef FieldName) const; > > /// getValueAsCode - This method looks up the specified field and returns > /// its value as the string data in a CodeInit, throwing an exception if the > > Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) > +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Mon Jul 11 13:25:51 2011 > @@ -722,7 +722,7 @@ > if (!V || !V->getValue()) > continue; > > - DefInit *DI = dynamic_cast(V->getValue()); > + const DefInit *DI = dynamic_cast(V->getValue()); > Record *Alias = DI->getDef(); > DwarfRegNums[Reg] = DwarfRegNums[Alias]; > } > > Modified: llvm/trunk/utils/TableGen/SetTheory.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/SetTheory.cpp (original) > +++ llvm/trunk/utils/TableGen/SetTheory.cpp Mon Jul 11 13:25:51 2011 > @@ -27,14 +27,14 @@ > > // (add a, b, ...) Evaluate and union all arguments. > struct AddOp : public SetTheory::Operator { > - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { > + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { > ST.evaluate(Expr->arg_begin(), Expr->arg_end(), Elts); > } > }; > > // (sub Add, Sub, ...) Set difference. > struct SubOp : public SetTheory::Operator { > - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { > + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { > if (Expr->arg_size() < 2) > throw "Set difference needs at least two arguments: " + > Expr->getAsString(); > @@ -49,7 +49,7 @@ > > // (and S1, S2) Set intersection. > struct AndOp : public SetTheory::Operator { > - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { > + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { > if (Expr->arg_size() != 2) > throw "Set intersection requires two arguments: " + Expr->getAsString(); > RecSet S1, S2; > @@ -63,16 +63,16 @@ > > // SetIntBinOp - Abstract base class for (Op S, N) operators. > struct SetIntBinOp : public SetTheory::Operator { > - virtual void apply2(SetTheory &ST, DagInit *Expr, > + virtual void apply2(SetTheory &ST, const DagInit *Expr, > RecSet &Set, int64_t N, > RecSet &Elts) =0; > > - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { > + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { > if (Expr->arg_size() != 2) > throw "Operator requires (Op Set, Int) arguments: " + Expr->getAsString(); > RecSet Set; > ST.evaluate(Expr->arg_begin()[0], Set); > - IntInit *II = dynamic_cast(Expr->arg_begin()[1]); > + const IntInit *II = dynamic_cast(Expr->arg_begin()[1]); > if (!II) > throw "Second argument must be an integer: " + Expr->getAsString(); > apply2(ST, Expr, Set, II->getValue(), Elts); > @@ -81,7 +81,7 @@ > > // (shl S, N) Shift left, remove the first N elements. > struct ShlOp : public SetIntBinOp { > - void apply2(SetTheory &ST, DagInit *Expr, > + void apply2(SetTheory &ST, const DagInit *Expr, > RecSet &Set, int64_t N, > RecSet &Elts) { > if (N < 0) > @@ -93,7 +93,7 @@ > > // (trunc S, N) Truncate after the first N elements. > struct TruncOp : public SetIntBinOp { > - void apply2(SetTheory &ST, DagInit *Expr, > + void apply2(SetTheory &ST, const DagInit *Expr, > RecSet &Set, int64_t N, > RecSet &Elts) { > if (N < 0) > @@ -110,7 +110,7 @@ > > RotOp(bool Rev) : Reverse(Rev) {} > > - void apply2(SetTheory &ST, DagInit *Expr, > + void apply2(SetTheory &ST, const DagInit *Expr, > RecSet &Set, int64_t N, > RecSet &Elts) { > if (Reverse) > @@ -129,7 +129,7 @@ > > // (decimate S, N) Pick every N'th element of S. > struct DecimateOp : public SetIntBinOp { > - void apply2(SetTheory &ST, DagInit *Expr, > + void apply2(SetTheory &ST, const DagInit *Expr, > RecSet &Set, int64_t N, > RecSet &Elts) { > if (N <= 0) > @@ -141,25 +141,26 @@ > > // (sequence "Format", From, To) Generate a sequence of records by name. > struct SequenceOp : public SetTheory::Operator { > - void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { > + void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { > if (Expr->arg_size() != 3) > throw "Bad args to (sequence \"Format\", From, To): " + > Expr->getAsString(); > std::string Format; > - if (StringInit *SI = dynamic_cast(Expr->arg_begin()[0])) > + if (const StringInit *SI = > + dynamic_cast(Expr->arg_begin()[0])) > Format = SI->getValue(); > else > throw "Format must be a string: " + Expr->getAsString(); > > int64_t From, To; > - if (IntInit *II = dynamic_cast(Expr->arg_begin()[1])) > + if (const IntInit *II = dynamic_cast(Expr->arg_begin()[1])) > From = II->getValue(); > else > throw "From must be an integer: " + Expr->getAsString(); > if (From < 0 || From >= (1 << 30)) > throw "From out of range"; > > - if (IntInit *II = dynamic_cast(Expr->arg_begin()[2])) > + if (const IntInit *II = dynamic_cast(Expr->arg_begin()[2])) > To = II->getValue(); > else > throw "From must be an integer: " + Expr->getAsString(); > @@ -167,7 +168,7 @@ > throw "To out of range"; > > RecordKeeper &Records = > - dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); > + dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); > > int Step = From <= To ? 1 : -1; > for (To += Step; From != To; From += Step) { > @@ -222,9 +223,9 @@ > addExpander(ClassName, new FieldExpander(FieldName)); > } > > -void SetTheory::evaluate(Init *Expr, RecSet &Elts) { > +void SetTheory::evaluate(const Init *Expr, RecSet &Elts) { > // A def in a list can be a just an element, or it may expand. > - if (DefInit *Def = dynamic_cast(Expr)) { > + if (const DefInit *Def = dynamic_cast(Expr)) { > if (const RecVec *Result = expand(Def->getDef())) > return Elts.insert(Result->begin(), Result->end()); > Elts.insert(Def->getDef()); > @@ -232,14 +233,14 @@ > } > > // Lists simply expand. > - if (ListInit *LI = dynamic_cast(Expr)) > + if (const ListInit *LI = dynamic_cast(Expr)) > return evaluate(LI->begin(), LI->end(), Elts); > > // Anything else must be a DAG. > - DagInit *DagExpr = dynamic_cast(Expr); > + const DagInit *DagExpr = dynamic_cast(Expr); > if (!DagExpr) > throw "Invalid set element: " + Expr->getAsString(); > - DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); > + const DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); > if (!OpInit) > throw "Bad set expression: " + Expr->getAsString(); > Operator *Op = Operators.lookup(OpInit->getDef()->getName()); > > Modified: llvm/trunk/utils/TableGen/SetTheory.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/SetTheory.h (original) > +++ llvm/trunk/utils/TableGen/SetTheory.h Mon Jul 11 13:25:51 2011 > @@ -70,7 +70,7 @@ > > /// apply - Apply this operator to Expr's arguments and insert the result > /// in Elts. > - virtual void apply(SetTheory&, DagInit *Expr, RecSet &Elts) =0; > + virtual void apply(SetTheory&, const DagInit *Expr, RecSet &Elts) =0; > }; > > /// Expander - A callback function that can transform a Record representing a > @@ -115,7 +115,7 @@ > void addOperator(StringRef Name, Operator*); > > /// evaluate - Evaluate Expr and append the resulting set to Elts. > - void evaluate(Init *Expr, RecSet &Elts); > + void evaluate(const Init *Expr, RecSet &Elts); > > /// evaluate - Evaluate a sequence of Inits and append to Elts. > template > > Modified: llvm/trunk/utils/TableGen/TGParser.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/TGParser.cpp (original) > +++ llvm/trunk/utils/TableGen/TGParser.cpp Mon Jul 11 13:25:51 2011 > @@ -28,7 +28,7 @@ > struct SubClassReference { > SMLoc RefLoc; > Record *Rec; > - std::vector TemplateArgs; > + std::vector TemplateArgs; > SubClassReference() : Rec(0) {} > > bool isInvalid() const { return Rec == 0; } > @@ -37,7 +37,7 @@ > struct SubMultiClassReference { > SMLoc RefLoc; > MultiClass *MC; > - std::vector TemplateArgs; > + std::vector TemplateArgs; > SubMultiClassReference() : MC(0) {} > > bool isInvalid() const { return MC == 0; } > @@ -50,7 +50,7 @@ > MC->dump(); > > errs() << "Template args:\n"; > - for (std::vector::const_iterator i = TemplateArgs.begin(), > + for (std::vector::const_iterator i = TemplateArgs.begin(), > iend = TemplateArgs.end(); > i != iend; > ++i) { > @@ -80,7 +80,7 @@ > /// SetValue - > /// Return true on error, false on success. > bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName, > - const std::vector &BitList, Init *V) { > + const std::vector &BitList, const Init *V) { > if (!V) return false; > > if (CurRec == 0) CurRec = &CurMultiClass->Rec; > @@ -92,7 +92,7 @@ > // Do not allow assignments like 'X = X'. This will just cause infinite loops > // in the resolution machinery. > if (BitList.empty()) > - if (VarInit *VI = dynamic_cast(V)) > + if (const VarInit *VI = dynamic_cast(V)) > if (VI->getName() == ValName) > return false; > > @@ -101,37 +101,37 @@ > // initializer. > // > if (!BitList.empty()) { > - BitsInit *CurVal = dynamic_cast(RV->getValue()); > + const BitsInit *CurVal = dynamic_cast(RV->getValue()); > if (CurVal == 0) > return Error(Loc, "Value '" + ValName + "' is not a bits type"); > > // Convert the incoming value to a bits type of the appropriate size... > - Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); > + const Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); > if (BI == 0) { > V->convertInitializerTo(new BitsRecTy(BitList.size())); > return Error(Loc, "Initializer is not compatible with bit range"); > } > > // We should have a BitsInit type now. > - BitsInit *BInit = dynamic_cast(BI); > + const BitsInit *BInit = dynamic_cast(BI); > assert(BInit != 0); > > - BitsInit *NewVal = new BitsInit(CurVal->getNumBits()); > + SmallVector NewBits(CurVal->getNumBits()); > > // Loop over bits, assigning values as appropriate. > for (unsigned i = 0, e = BitList.size(); i != e; ++i) { > unsigned Bit = BitList[i]; > - if (NewVal->getBit(Bit)) > + if (NewBits[Bit]) > return Error(Loc, "Cannot set bit #" + utostr(Bit) + " of value '" + > ValName + "' more than once"); > - NewVal->setBit(Bit, BInit->getBit(i)); > + NewBits[Bit] = BInit->getBit(i); > } > > for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i) > - if (NewVal->getBit(i) == 0) > - NewVal->setBit(i, CurVal->getBit(i)); > + if (NewBits[i] == 0) > + NewBits[i] = CurVal->getBit(i); > > - V = NewVal; > + V = BitsInit::Create(NewBits.begin(), NewBits.end()); > } > > if (RV->setValue(V)) > @@ -633,7 +633,7 @@ > /// IDValue ::= ID [multiclass template argument] > /// IDValue ::= ID [def name] > /// > -Init *TGParser::ParseIDValue(Record *CurRec) { > +const Init *TGParser::ParseIDValue(Record *CurRec) { > assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue"); > std::string Name = Lex.getCurStrVal(); > SMLoc Loc = Lex.getLoc(); > @@ -643,17 +643,17 @@ > > /// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID > /// has already been read. > -Init *TGParser::ParseIDValue(Record *CurRec, > +const Init *TGParser::ParseIDValue(Record *CurRec, > const std::string &Name, SMLoc NameLoc) { > if (CurRec) { > if (const RecordVal *RV = CurRec->getValue(Name)) > - return new VarInit(Name, RV->getType()); > + return VarInit::Create(Name, RV->getType()); > > std::string TemplateArgName = CurRec->getName()+":"+Name; > if (CurRec->isTemplateArg(TemplateArgName)) { > const RecordVal *RV = CurRec->getValue(TemplateArgName); > assert(RV && "Template arg doesn't exist??"); > - return new VarInit(TemplateArgName, RV->getType()); > + return VarInit::Create(TemplateArgName, RV->getType()); > } > } > > @@ -662,12 +662,12 @@ > if (CurMultiClass->Rec.isTemplateArg(MCName)) { > const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); > assert(RV && "Template arg doesn't exist??"); > - return new VarInit(MCName, RV->getType()); > + return VarInit::Create(MCName, RV->getType()); > } > } > > if (Record *D = Records.getDef(Name)) > - return new DefInit(D); > + return DefInit::Create(D); > > Error(NameLoc, "Variable not defined: '" + Name + "'"); > return 0; > @@ -677,7 +677,7 @@ > /// > /// Operation ::= XOperator ['<' Type '>'] '(' Args ')' > /// > -Init *TGParser::ParseOperation(Record *CurRec) { > +const Init *TGParser::ParseOperation(Record *CurRec) { > switch (Lex.getCode()) { > default: > TokError("unknown operation"); > @@ -724,15 +724,15 @@ > } > Lex.Lex(); // eat the '(' > > - Init *LHS = ParseValue(CurRec); > + const Init *LHS = ParseValue(CurRec); > if (LHS == 0) return 0; > > if (Code == UnOpInit::HEAD > || Code == UnOpInit::TAIL > || Code == UnOpInit::EMPTY) { > - ListInit *LHSl = dynamic_cast(LHS); > - StringInit *LHSs = dynamic_cast(LHS); > - TypedInit *LHSt = dynamic_cast(LHS); > + const ListInit *LHSl = dynamic_cast(LHS); > + const StringInit *LHSs = dynamic_cast(LHS); > + const TypedInit *LHSt = dynamic_cast(LHS); > if (LHSl == 0 && LHSs == 0 && LHSt == 0) { > TokError("expected list or string type argument in unary operator"); > return 0; > @@ -758,8 +758,8 @@ > return 0; > } > if (LHSl) { > - Init *Item = LHSl->getElement(0); > - TypedInit *Itemt = dynamic_cast(Item); > + const Init *Item = LHSl->getElement(0); > + const TypedInit *Itemt = dynamic_cast(Item); > if (Itemt == 0) { > TokError("untyped list element in unary operator"); > return 0; > @@ -790,7 +790,7 @@ > return 0; > } > Lex.Lex(); // eat the ')' > - return (new UnOpInit(Code, LHS, Type))->Fold(CurRec, CurMultiClass); > + return (UnOpInit::Create(Code, LHS, Type))->Fold(CurRec, CurMultiClass); > } > > case tgtok::XConcat: > @@ -825,7 +825,7 @@ > } > Lex.Lex(); // eat the '(' > > - SmallVector InitList; > + SmallVector InitList; > > InitList.push_back(ParseValue(CurRec)); > if (InitList.back() == 0) return 0; > @@ -847,15 +847,15 @@ > // shorthand for nesting them. > if (Code == BinOpInit::STRCONCAT) { > while (InitList.size() > 2) { > - Init *RHS = InitList.pop_back_val(); > - RHS = (new BinOpInit(Code, InitList.back(), RHS, Type)) > + const Init *RHS = InitList.pop_back_val(); > + RHS = (BinOpInit::Create(Code, InitList.back(), RHS, Type)) > ->Fold(CurRec, CurMultiClass); > InitList.back() = RHS; > } > } > > if (InitList.size() == 2) > - return (new BinOpInit(Code, InitList[0], InitList[1], Type)) > + return (BinOpInit::Create(Code, InitList[0], InitList[1], Type)) > ->Fold(CurRec, CurMultiClass); > > Error(OpLoc, "expected two operands to operator"); > @@ -888,7 +888,7 @@ > } > Lex.Lex(); // eat the '(' > > - Init *LHS = ParseValue(CurRec); > + const Init *LHS = ParseValue(CurRec); > if (LHS == 0) return 0; > > if (Lex.getCode() != tgtok::comma) { > @@ -897,7 +897,7 @@ > } > Lex.Lex(); // eat the ',' > > - Init *MHS = ParseValue(CurRec); > + const Init *MHS = ParseValue(CurRec); > if (MHS == 0) return 0; > > if (Lex.getCode() != tgtok::comma) { > @@ -906,7 +906,7 @@ > } > Lex.Lex(); // eat the ',' > > - Init *RHS = ParseValue(CurRec); > + const Init *RHS = ParseValue(CurRec); > if (RHS == 0) return 0; > > if (Lex.getCode() != tgtok::r_paren) { > @@ -920,23 +920,23 @@ > case tgtok::XIf: { > // FIXME: The `!if' operator doesn't handle non-TypedInit well at > // all. This can be made much more robust. > - TypedInit *MHSt = dynamic_cast(MHS); > - TypedInit *RHSt = dynamic_cast(RHS); > + const TypedInit *MHSt = dynamic_cast(MHS); > + const TypedInit *RHSt = dynamic_cast(RHS); > > RecTy *MHSTy = 0; > RecTy *RHSTy = 0; > > if (MHSt == 0 && RHSt == 0) { > - BitsInit *MHSbits = dynamic_cast(MHS); > - BitsInit *RHSbits = dynamic_cast(RHS); > + const BitsInit *MHSbits = dynamic_cast(MHS); > + const BitsInit *RHSbits = dynamic_cast(RHS); > > if (MHSbits && RHSbits && > MHSbits->getNumBits() == RHSbits->getNumBits()) { > Type = new BitRecTy(); > break; > } else { > - BitInit *MHSbit = dynamic_cast(MHS); > - BitInit *RHSbit = dynamic_cast(RHS); > + const BitInit *MHSbit = dynamic_cast(MHS); > + const BitInit *RHSbit = dynamic_cast(RHS); > > if (MHSbit && RHSbit) { > Type = new BitRecTy(); > @@ -964,7 +964,7 @@ > break; > } > case tgtok::XForEach: { > - TypedInit *MHSt = dynamic_cast(MHS); > + const TypedInit *MHSt = dynamic_cast(MHS); > if (MHSt == 0) { > TokError("could not get type for !foreach"); > return 0; > @@ -973,7 +973,7 @@ > break; > } > case tgtok::XSubst: { > - TypedInit *RHSt = dynamic_cast(RHS); > + const TypedInit *RHSt = dynamic_cast(RHS); > if (RHSt == 0) { > TokError("could not get type for !subst"); > return 0; > @@ -982,7 +982,7 @@ > break; > } > } > - return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec, > + return (TernOpInit::Create(Code, LHS, MHS, RHS, Type))->Fold(CurRec, > CurMultiClass); > } > } > @@ -1038,11 +1038,11 @@ > /// SimpleValue ::= SRLTOK '(' Value ',' Value ')' > /// SimpleValue ::= STRCONCATTOK '(' Value ',' Value ')' > /// > -Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { > - Init *R = 0; > +const Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { > + const Init *R = 0; > switch (Lex.getCode()) { > default: TokError("Unknown token when parsing a value"); break; > - case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break; > + case tgtok::IntVal: R = IntInit::Create(Lex.getCurIntVal()); Lex.Lex(); break; > case tgtok::StrVal: { > std::string Val = Lex.getCurStrVal(); > Lex.Lex(); > @@ -1053,15 +1053,15 @@ > Lex.Lex(); > } > > - R = new StringInit(Val); > + R = StringInit::Create(Val); > break; > } > case tgtok::CodeFragment: > - R = new CodeInit(Lex.getCurStrVal()); > + R = CodeInit::Create(Lex.getCurStrVal()); > Lex.Lex(); > break; > case tgtok::question: > - R = new UnsetInit(); > + R = UnsetInit::Create(); > Lex.Lex(); > break; > case tgtok::Id: { > @@ -1085,7 +1085,7 @@ > return 0; > } > > - std::vector ValueList = ParseValueList(CurRec, Class); > + std::vector ValueList = ParseValueList(CurRec, Class); > if (ValueList.empty()) return 0; > > if (Lex.getCode() != tgtok::greater) { > @@ -1110,12 +1110,12 @@ > Records.addDef(NewRec); > > // The result of the expression is a reference to the new record. > - return new DefInit(NewRec); > + return DefInit::Create(NewRec); > } > case tgtok::l_brace: { // Value ::= '{' ValueList '}' > SMLoc BraceLoc = Lex.getLoc(); > Lex.Lex(); // eat the '{' > - std::vector Vals; > + std::vector Vals; > > if (Lex.getCode() != tgtok::r_brace) { > Vals = ParseValueList(CurRec); > @@ -1127,21 +1127,22 @@ > } > Lex.Lex(); // eat the '}' > > - BitsInit *Result = new BitsInit(Vals.size()); > + SmallVector NewBits(Vals.size()); > + > for (unsigned i = 0, e = Vals.size(); i != e; ++i) { > - Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); > + const Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); > if (Bit == 0) { > Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+ > ") is not convertable to a bit"); > return 0; > } > - Result->setBit(Vals.size()-i-1, Bit); > + NewBits[Vals.size()-i-1] = Bit; > } > - return Result; > + return BitsInit::Create(NewBits.begin(), NewBits.end()); > } > case tgtok::l_square: { // Value ::= '[' ValueList ']' > Lex.Lex(); // eat the '[' > - std::vector Vals; > + std::vector Vals; > > RecTy *DeducedEltTy = 0; > ListRecTy *GivenListTy = 0; > @@ -1189,10 +1190,10 @@ > > // Check elements > RecTy *EltTy = 0; > - for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); > + for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); > i != ie; > ++i) { > - TypedInit *TArg = dynamic_cast(*i); > + const TypedInit *TArg = dynamic_cast(*i); > if (TArg == 0) { > TokError("Untyped list element"); > return 0; > @@ -1236,7 +1237,7 @@ > DeducedEltTy = EltTy; > } > > - return new ListInit(Vals, DeducedEltTy); > + return ListInit::Create(Vals, DeducedEltTy); > } > case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' > Lex.Lex(); // eat the '(' > @@ -1245,7 +1246,7 @@ > return 0; > } > > - Init *Operator = ParseValue(CurRec); > + const Init *Operator = ParseValue(CurRec); > if (Operator == 0) return 0; > > // If the operator name is present, parse it. > @@ -1259,7 +1260,7 @@ > Lex.Lex(); // eat the VarName. > } > > - std::vector > DagArgs; > + std::vector > DagArgs; > if (Lex.getCode() != tgtok::r_paren) { > DagArgs = ParseDagArgList(CurRec); > if (DagArgs.empty()) return 0; > @@ -1271,7 +1272,7 @@ > } > Lex.Lex(); // eat the ')' > > - return new DagInit(Operator, OperatorName, DagArgs); > + return DagInit::Create(Operator, OperatorName, DagArgs); > } > > case tgtok::XHead: > @@ -1301,8 +1302,8 @@ > /// ValueSuffix ::= '[' BitList ']' > /// ValueSuffix ::= '.' ID > /// > -Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { > - Init *Result = ParseSimpleValue(CurRec, ItemType); > +const Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { > + const Init *Result = ParseSimpleValue(CurRec, ItemType); > if (Result == 0) return 0; > > // Parse the suffixes now if present. > @@ -1361,7 +1362,7 @@ > Result->getAsString() + "'"); > return 0; > } > - Result = new FieldInit(Result, Lex.getCurStrVal()); > + Result = FieldInit::Create(Result, Lex.getCurStrVal()); > Lex.Lex(); // eat field name > break; > } > @@ -1372,20 +1373,20 @@ > /// > /// ParseDagArgList ::= Value (':' VARNAME)? > /// ParseDagArgList ::= ParseDagArgList ',' Value (':' VARNAME)? > -std::vector > > +std::vector > > TGParser::ParseDagArgList(Record *CurRec) { > - std::vector > Result; > + std::vector > Result; > > while (1) { > - Init *Val = ParseValue(CurRec); > - if (Val == 0) return std::vector >(); > + const Init *Val = ParseValue(CurRec); > + if (Val == 0) return std::vector >(); > > // If the variable name is present, add it. > std::string VarName; > if (Lex.getCode() == tgtok::colon) { > if (Lex.Lex() != tgtok::VarName) { // eat the ':' > TokError("expected variable name in dag literal"); > - return std::vector >(); > + return std::vector >(); > } > VarName = Lex.getCurStrVal(); > Lex.Lex(); // eat the VarName. > @@ -1407,9 +1408,10 @@ > /// > /// ValueList ::= Value (',' Value) > /// > -std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, > - RecTy *EltTy) { > - std::vector Result; > +std::vector TGParser::ParseValueList(Record *CurRec, > + Record *ArgsRec, > + RecTy *EltTy) { > + std::vector Result; > RecTy *ItemType = EltTy; > unsigned int ArgN = 0; > if (ArgsRec != 0 && EltTy == 0) { > @@ -1420,7 +1422,7 @@ > ++ArgN; > } > Result.push_back(ParseValue(CurRec, ItemType)); > - if (Result.back() == 0) return std::vector(); > + if (Result.back() == 0) return std::vector(); > > while (Lex.getCode() == tgtok::comma) { > Lex.Lex(); // Eat the comma > @@ -1429,7 +1431,7 @@ > const std::vector &TArgs = ArgsRec->getTemplateArgs(); > if (ArgN >= TArgs.size()) { > TokError("too many template arguments"); > - return std::vector(); > + return std::vector(); > } > const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); > assert(RV && "Template argument record not found??"); > @@ -1437,7 +1439,7 @@ > ++ArgN; > } > Result.push_back(ParseValue(CurRec, ItemType)); > - if (Result.back() == 0) return std::vector(); > + if (Result.back() == 0) return std::vector(); > } > > return Result; > @@ -1490,7 +1492,7 @@ > if (Lex.getCode() == tgtok::equal) { > Lex.Lex(); > SMLoc ValLoc = Lex.getLoc(); > - Init *Val = ParseValue(CurRec, Type); > + const Init *Val = ParseValue(CurRec, Type); > if (Val == 0 || > SetValue(CurRec, ValLoc, DeclName, std::vector(), Val)) > return ""; > @@ -1574,7 +1576,7 @@ > > RecTy *Type = Field->getType(); > > - Init *Val = ParseValue(CurRec, Type); > + const Init *Val = ParseValue(CurRec, Type); > if (Val == 0) return true; > > if (Lex.getCode() != tgtok::semi) > @@ -1774,7 +1776,7 @@ > } > Lex.Lex(); // eat the '='. > > - Init *Val = ParseValue(0); > + const Init *Val = ParseValue(0); > if (Val == 0) return std::vector(); > > // Now that we have everything, add the record. > @@ -1948,7 +1950,7 @@ > // template parameters. > MultiClass *MC = MultiClasses[Ref.Rec->getName()]; > assert(MC && "Didn't lookup multiclass correctly?"); > - std::vector &TemplateVals = Ref.TemplateArgs; > + std::vector &TemplateVals = Ref.TemplateArgs; > > // Verify that the correct number of template arguments were specified. > const std::vector &TArgs = MC->Rec.getTemplateArgs(); > > Modified: llvm/trunk/utils/TableGen/TGParser.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/TGParser.h (original) > +++ llvm/trunk/utils/TableGen/TGParser.h Mon Jul 11 13:25:51 2011 > @@ -33,10 +33,10 @@ > struct LetRecord { > std::string Name; > std::vector Bits; > - Init *Value; > + const Init *Value; > SMLoc Loc; > - LetRecord(const std::string &N, const std::vector &B, Init *V, > - SMLoc L) > + LetRecord(const std::string &N, const std::vector &B, > + const Init *V, SMLoc L) > : Name(N), Bits(B), Value(V), Loc(L) { > } > }; > @@ -73,7 +73,7 @@ > private: // Semantic analysis methods. > bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); > bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName, > - const std::vector &BitList, Init *V); > + const std::vector &BitList, const Init *V); > bool AddSubClass(Record *Rec, SubClassReference &SubClass); > bool AddSubMultiClass(MultiClass *CurMC, > SubMultiClassReference &SubMultiClass); > @@ -98,18 +98,20 @@ > SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); > SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); > > - Init *ParseIDValue(Record *CurRec); > - Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); > - Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); > - Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); > - std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); > - std::vector > ParseDagArgList(Record *); > + const Init *ParseIDValue(Record *CurRec); > + const Init *ParseIDValue(Record *CurRec, const std::string &Name, > + SMLoc NameLoc); > + const Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); > + const Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); > + std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, > + RecTy *EltTy = 0); > + std::vector > ParseDagArgList(Record *); > bool ParseOptionalRangeList(std::vector &Ranges); > bool ParseOptionalBitList(std::vector &Ranges); > std::vector ParseRangeList(); > bool ParseRangePiece(std::vector &Ranges); > RecTy *ParseType(); > - Init *ParseOperation(Record *CurRec); > + const Init *ParseOperation(Record *CurRec); > RecTy *ParseOperatorType(); > std::string ParseObjectName(); > Record *ParseClassID(); > > Modified: llvm/trunk/utils/TableGen/TableGen.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/TableGen.cpp (original) > +++ llvm/trunk/utils/TableGen/TableGen.cpp Mon Jul 11 13:25:51 2011 > @@ -208,6 +208,7 @@ > if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { > errs() << "Could not open input file '" << InputFilename << "': " > << ec.message() <<"\n"; > + Init::ReleaseMemory(); > return 1; > } > MemoryBuffer *F = File.take(); > @@ -221,25 +222,30 @@ > > TGParser Parser(SrcMgr, Records); > > - if (Parser.ParseFile()) > + if (Parser.ParseFile()) { > + Init::ReleaseMemory(); > return 1; > + } > > std::string Error; > tool_output_file Out(OutputFilename.c_str(), Error); > if (!Error.empty()) { > errs() << argv[0] << ": error opening " << OutputFilename > << ":" << Error << "\n"; > + Init::ReleaseMemory(); > return 1; > } > if (!DependFilename.empty()) { > if (OutputFilename == "-") { > errs() << argv[0] << ": the option -d must be used together with -o\n"; > + Init::ReleaseMemory(); > return 1; > } > tool_output_file DepOut(DependFilename.c_str(), Error); > if (!Error.empty()) { > errs() << argv[0] << ": error opening " << DependFilename > << ":" << Error << "\n"; > + Init::ReleaseMemory(); > return 1; > } > DepOut.os() << DependFilename << ":"; > @@ -382,11 +388,14 @@ > } > default: > assert(1 && "Invalid Action"); > + Init::ReleaseMemory(); > return 1; > } > > // Declare success. > Out.keep(); > + > + Init::ReleaseMemory(); > return 0; > > } catch (const TGError &Error) { > @@ -399,5 +408,7 @@ > errs() << argv[0] << ": Unknown unexpected exception occurred.\n"; > } > > + Init::ReleaseMemory(); > + > return 1; > } > > Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=134907&r1=134906&r2=134907&view=diff > ============================================================================== > --- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original) > +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Mon Jul 11 13:25:51 2011 > @@ -162,7 +162,7 @@ > /// @param init - A reference to the BitsInit to be decoded. > /// @return - The field, with the first bit in the BitsInit as the lowest > /// order bit. > -static uint8_t byteFromBitsInit(BitsInit &init) { > +static uint8_t byteFromBitsInit(const BitsInit &init) { > int width = init.getNumBits(); > > assert(width <= 8 && "Field is too large for uint8_t!"); > @@ -173,7 +173,7 @@ > uint8_t ret = 0; > > for (index = 0; index < width; index++) { > - if (static_cast(init.getBit(index))->getValue()) > + if (static_cast(init.getBit(index))->getValue()) > ret |= mask; > > mask <<= 1; > @@ -189,7 +189,7 @@ > /// @param name - The name of the field in the record. > /// @return - The field, as translated by byteFromBitsInit(). > static uint8_t byteFromRec(const Record* rec, const std::string &name) { > - BitsInit* bits = rec->getValueAsBitsInit(name); > + const BitsInit* bits = rec->getValueAsBitsInit(name); > return byteFromBitsInit(*bits); > } > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Mon Jul 11 13:49:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 11:49:01 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <20110711182552.740612A6C12C@llvm.org> References: <20110711182552.740612A6C12C@llvm.org> Message-ID: On Jul 11, 2011, at 11:25 AM, David Greene wrote: > Author: greened > Date: Mon Jul 11 13:25:51 2011 > New Revision: 134907 > > URL: http://llvm.org/viewvc/llvm-project?rev=134907&view=rev > Log: > [AVX] Make Inits Foldable > > Manage Inits in a FoldingSet. This provides several benefits: > > - Memory for Inits is properly managed > > - Duplicate Inits are folded into Flyweights, saving memory > > - It enforces const-correctness, protecting against certain classes > of bugs > > The above benefits allow Inits to be used in more contexts, which in > turn provides more dynamism to TableGen. This enhanced capability > will be used by the AVX code generator to a fold common patterns > together. David, please revert this. You are ignoring code review, violating the coding standards, and there are mismatched tags. /jakob From greened at obbligato.org Mon Jul 11 13:53:18 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 13:53:18 -0500 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: (Jakob Stoklund Olesen's message of "Mon, 11 Jul 2011 10:11:03 -0700") References: Message-ID: Jakob Stoklund Olesen writes: > Please move all of the mechanical const-ness to a separate patch. It > is very hard to figure out what is going on with all that noise. I can't. It's needed to maintain const-correctness. LLVM won't build without it. -Dave From greened at obbligato.org Mon Jul 11 13:53:46 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 13:53:46 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <4E1B4355.2030804@gmail.com> ("Rafael =?utf-8?Q?=C3=81vila?= de =?utf-8?Q?Esp=C3=ADndola=22's?= message of "Mon, 11 Jul 2011 14:39:17 -0400") References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> Message-ID: Rafael ?vila de Esp?ndola writes: > I think this is causing: > > /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: > struct 'Init' was previously > declared as a class [-Wmismatched-tags] > struct Init; > ^ > /home/espindola/llvm/llvm/utils/TableGen/Record.h:556:7: note: previous > use is here > class Init : public FastFoldingSetNode { Odd. I just updated and built without problems. I'll investigate. -Dave From greened at obbligato.org Mon Jul 11 13:59:30 2011 From: greened at obbligato.org (David Greene) Date: Mon, 11 Jul 2011 18:59:30 -0000 Subject: [llvm-commits] [llvm] r134908 - /llvm/trunk/utils/TableGen/SetTheory.h Message-ID: <20110711185930.1C8BB2A6C12C@llvm.org> Author: greened Date: Mon Jul 11 13:59:29 2011 New Revision: 134908 URL: http://llvm.org/viewvc/llvm-project?rev=134908&view=rev Log: Fix Build Update the tag for Init to match how it's defined. Modified: llvm/trunk/utils/TableGen/SetTheory.h Modified: llvm/trunk/utils/TableGen/SetTheory.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.h?rev=134908&r1=134907&r2=134908&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SetTheory.h (original) +++ llvm/trunk/utils/TableGen/SetTheory.h Mon Jul 11 13:59:29 2011 @@ -55,7 +55,7 @@ namespace llvm { class DagInit; -struct Init; +class Init; class Record; class RecordKeeper; From greened at obbligato.org Mon Jul 11 14:00:23 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 14:00:23 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <4E1B4355.2030804@gmail.com> ("Rafael =?utf-8?Q?=C3=81vila?= de =?utf-8?Q?Esp=C3=ADndola=22's?= message of "Mon, 11 Jul 2011 14:39:17 -0400") References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> Message-ID: Rafael ?vila de Esp?ndola writes: > I think this is causing: > > /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: > struct 'Init' was previously > declared as a class [-Wmismatched-tags] > struct Init; > ^ Fixed in 134908. Thanks for the heads-up! -Dave From greened at obbligato.org Mon Jul 11 14:02:02 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 14:02:02 -0500 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: (Jakob Stoklund Olesen's message of "Mon, 11 Jul 2011 10:11:03 -0700") References: Message-ID: Jakob Stoklund Olesen writes: > On Jul 8, 2011, at 9:41 AM, David Greene wrote: > > Here's a patch to manage TableGen Inits using a FoldingSet. This allows > us to clean up all of the allocated Inits on TableGen exit, saves memory > and makes TableGen run a bit faster due to elimination of duplicate > objects. > > Very nice. Please use get() instead of Create(). Is there a naming convention here? I've seen Create() used in other places, which is why I used it. :) -Dave From rjmccall at apple.com Mon Jul 11 14:16:55 2011 From: rjmccall at apple.com (John McCall) Date: Mon, 11 Jul 2011 12:16:55 -0700 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: References: Message-ID: On Jul 11, 2011, at 12:02 PM, David A. Greene wrote: > Jakob Stoklund Olesen writes: >> On Jul 8, 2011, at 9:41 AM, David Greene wrote: >> >> Here's a patch to manage TableGen Inits using a FoldingSet. This allows >> us to clean up all of the allocated Inits on TableGen exit, saves memory >> and makes TableGen run a bit faster due to elimination of duplicate >> objects. >> >> Very nice. Please use get() instead of Create(). > > Is there a naming convention here? I've seen Create() used in other > places, which is why I used it. :) The convention, as I see it, is to use 'create' for factory methods that return a non-uniqued object and 'get' for factory methods that return a uniqued object. Note that I have no idea which category this falls into. John. From stoklund at 2pi.dk Mon Jul 11 14:59:00 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 12:59:00 -0700 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: References: Message-ID: On Jul 11, 2011, at 12:16 PM, John McCall wrote: > On Jul 11, 2011, at 12:02 PM, David A. Greene wrote: >> Jakob Stoklund Olesen writes: >>> On Jul 8, 2011, at 9:41 AM, David Greene wrote: >>> >>> Here's a patch to manage TableGen Inits using a FoldingSet. This allows >>> us to clean up all of the allocated Inits on TableGen exit, saves memory >>> and makes TableGen run a bit faster due to elimination of duplicate >>> objects. >>> >>> Very nice. Please use get() instead of Create(). >> >> Is there a naming convention here? I've seen Create() used in other >> places, which is why I used it. :) > > The convention, as I see it, is to use 'create' for factory methods that > return a non-uniqued object and 'get' for factory methods that return > a uniqued object. Note that I have no idea which category this falls > into. It's the latter. And function names begin with a lower-case letter. /jakob From stoklund at 2pi.dk Mon Jul 11 15:17:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 13:17:36 -0700 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: References: Message-ID: On Jul 11, 2011, at 11:53 AM, David A. Greene wrote: > Jakob Stoklund Olesen writes: > >> Please move all of the mechanical const-ness to a separate patch. It >> is very hard to figure out what is going on with all that noise. > > I can't. It's needed to maintain const-correctness. LLVM won't build > without it. Sure you can. Let's discuss after you revert your patches. /jakob From mailing-list at martin-whitaker.me.uk Mon Jul 11 14:24:55 2011 From: mailing-list at martin-whitaker.me.uk (Martin Whitaker) Date: Mon, 11 Jul 2011 20:24:55 +0100 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers Message-ID: <4E1B4E07.3090408@martin-whitaker.me.uk> This patch adds a SPARC code generator feature that allows the code generator to optionally use the global registers that are reserved for application use by the SPARC ABI (g2,g3,g4). It also changes the preferred register allocation order to give preference to the global and input registers, to increase the chances of being able to eliminate the frame save/restore in leaf functions (when that optimisation is added). I'm doing this now because it also makes the regression test for this patch simpler (and less likely to break in the future). Please review. Martin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0001-Enable-use-of-SPARC-g2-g4-global-registers.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110711/af409f62/attachment.pl From evan.cheng at apple.com Mon Jul 11 15:23:13 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 20:23:13 -0000 Subject: [llvm-commits] [llvm] r134917 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.h Record.h TGParser.h Message-ID: <20110711202313.C39B02A6C12C@llvm.org> Author: evancheng Date: Mon Jul 11 15:23:13 2011 New Revision: 134917 URL: http://llvm.org/viewvc/llvm-project?rev=134917&view=rev Log: struct Init -> class Init. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/TGParser.h Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=134917&r1=134916&r2=134917&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Mon Jul 11 15:23:13 2011 @@ -26,7 +26,7 @@ namespace llvm { class Record; - struct Init; + class Init; class ListInit; class DagInit; class SDNodeInfo; Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=134917&r1=134916&r2=134917&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Mon Jul 11 15:23:13 2011 @@ -36,7 +36,7 @@ class RecordRecTy; // Init subclasses. -struct Init; +class Init; class UnsetInit; class BitInit; class BitsInit; Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=134917&r1=134916&r2=134917&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Mon Jul 11 15:23:13 2011 @@ -25,7 +25,7 @@ class RecordVal; class RecordKeeper; struct RecTy; - struct Init; + class Init; struct MultiClass; struct SubClassReference; struct SubMultiClassReference; From evan.cheng at apple.com Mon Jul 11 15:24:08 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 13:24:08 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> Message-ID: <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic pure virtual method called terminate called without an active exception Evan On Jul 11, 2011, at 12:00 PM, David A. Greene wrote: > Rafael ?vila de Esp?ndola writes: > >> I think this is causing: >> >> /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: >> struct 'Init' was previously >> declared as a class [-Wmismatched-tags] >> struct Init; >> ^ > > Fixed in 134908. Thanks for the heads-up! > > -Dave > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From stoklund at 2pi.dk Mon Jul 11 15:36:58 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 13:36:58 -0700 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <4E1B4E07.3090408@martin-whitaker.me.uk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> Message-ID: <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> On Jul 11, 2011, at 12:24 PM, Martin Whitaker wrote: > This patch adds a SPARC code generator feature that allows the code generator to optionally use the global registers that are reserved for application use by the SPARC ABI (g2,g3,g4). > > It also changes the preferred register allocation order to give preference to the global and input registers, to increase the chances of being able to eliminate the frame save/restore in leaf functions (when that optimisation is added). I'm doing this now because it also makes the regression test for this patch simpler (and less likely to break in the future). > > Please review. There register stuff looks good to me, but someone who is familiar with SPARC should comment. +define void @test(i32* %ptr) nounwind { +entry: +; CHECK_N: ld [%i0], %i3 +; CHECK_N: ld [%i0], %i2 +; CHECK_N: ld [%i0], %i1 +; CHECK_Y: ld [%i0], %g4 +; CHECK_Y: ld [%i0], %g3 +; CHECK_Y: ld [%i0], %g2 Please don't write tests that depend on the exact details of register allocation. There is no reason these registers would be allocated in exactly that order. Check for the absence or presence of frame save/restore code instead. /jakob From evan.cheng at apple.com Mon Jul 11 15:40:56 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 20:40:56 -0000 Subject: [llvm-commits] [llvm] r134920 - /llvm/trunk/tools/llvm-mc/llvm-mc.cpp Message-ID: <20110711204056.388702A6C12C@llvm.org> Author: evancheng Date: Mon Jul 11 15:40:56 2011 New Revision: 134920 URL: http://llvm.org/viewvc/llvm-project?rev=134920&view=rev Log: Disassembler doesn't need TargetMachine anymore. Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=134920&r1=134919&r2=134920&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Mon Jul 11 15:40:56 2011 @@ -415,23 +415,6 @@ Res = Disassembler::disassembleEnhanced(TripleName, *Buffer.take(), Out->os()); } else { - // Package up features to be passed to target/subtarget - std::string FeaturesStr; - - // FIXME: We shouldn't need to do this (and link in codegen). - // When we split this out, we should do it in a way that makes - // it straightforward to switch subtargets on the fly (.e.g, - // the .cpu and .code16 directives). - OwningPtr TM(TheTarget->createTargetMachine(TripleName, - MCPU, - FeaturesStr)); - - if (!TM) { - errs() << ProgName << ": error: could not create target for triple '" - << TripleName << "'.\n"; - return 1; - } - Res = Disassembler::disassemble(*TheTarget, TripleName, *Buffer.take(), Out->os()); } From greened at obbligato.org Mon Jul 11 15:41:06 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 15:41:06 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: (Owen Anderson's message of "Mon, 11 Jul 2011 11:42:28 -0700") References: <20110711182552.740612A6C12C@llvm.org> Message-ID: Owen Anderson writes: > I'm getting build failures from this. Something about a pure virtual method call? Hmm...Not seen that before. What are you building when this happens? -Dave From greened at obbligato.org Mon Jul 11 15:44:45 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 15:44:45 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: (Jakob Stoklund Olesen's message of "Mon, 11 Jul 2011 11:49:01 -0700") References: <20110711182552.740612A6C12C@llvm.org> Message-ID: Jakob Stoklund Olesen writes: > On Jul 11, 2011, at 11:25 AM, David Greene wrote: > >> Author: greened >> Date: Mon Jul 11 13:25:51 2011 >> New Revision: 134907 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134907&view=rev >> Log: >> [AVX] Make Inits Foldable > David, please revert this. > > You are ignoring code review, How so? Your review came in after the commit. > violating the coding standards, Which standards? > and there are mismatched tags. Which are not caught by the default build nor by the Buildbot. How is one supposed to catch errors that aren't caught? -Dave From greened at obbligato.org Mon Jul 11 15:55:22 2011 From: greened at obbligato.org (David Greene) Date: Mon, 11 Jul 2011 20:55:22 -0000 Subject: [llvm-commits] [llvm] r134921 - in /llvm/trunk/utils/TableGen: CodeEmitterGen.cpp CodeGenDAGPatterns.cpp CodeGenRegisters.cpp Record.cpp Record.h TGParser.cpp Message-ID: <20110711205523.180032A6C12C@llvm.org> Author: greened Date: Mon Jul 11 15:55:22 2011 New Revision: 134921 URL: http://llvm.org/viewvc/llvm-project?rev=134921&view=rev Log: Use get(0 Instead of Create() Respond to some feedback asking for a name change. Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp llvm/trunk/utils/TableGen/CodeGenRegisters.cpp llvm/trunk/utils/TableGen/Record.cpp llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/TGParser.cpp Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Mon Jul 11 15:55:22 2011 @@ -56,7 +56,7 @@ NewBits[middle] = BI->getBit(middle); } - const BitsInit *NewBI = BitsInit::Create(NewBits.begin(), NewBits.end()); + const BitsInit *NewBI = BitsInit::get(NewBits.begin(), NewBits.end()); // Update the bits in reversed order so that emitInstrOpBits will get the // correct endianness. Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Mon Jul 11 15:55:22 2011 @@ -1750,7 +1750,7 @@ // TreePatternNode of its own. For example: /// (foo GPR, imm) -> (foo GPR, (imm)) if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) - return ParseTreePattern(DagInit::Create(DI, "", + return ParseTreePattern(DagInit::get(DI, "", std::vector >()), OpName); @@ -1863,7 +1863,7 @@ else // Otherwise, no chain. Operator = getDAGPatterns().get_intrinsic_wo_chain_sdnode(); - TreePatternNode *IIDNode = new TreePatternNode(IntInit::Create(IID), 1); + TreePatternNode *IIDNode = new TreePatternNode(IntInit::get(IID), 1); Children.insert(Children.begin(), IIDNode); } @@ -2184,7 +2184,7 @@ // Find some SDNode. assert(!SDNodes.empty() && "No SDNodes parsed?"); - const Init *SomeSDNode = DefInit::Create(SDNodes.begin()->first); + const Init *SomeSDNode = DefInit::get(SDNodes.begin()->first); for (unsigned iter = 0; iter != 2; ++iter) { for (unsigned i = 0, e = DefaultOps[iter].size(); i != e; ++i) { @@ -2196,7 +2196,7 @@ for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op) Ops.push_back(std::make_pair(DefaultInfo->getArg(op), DefaultInfo->getArgName(op))); - const DagInit *DI = DagInit::Create(SomeSDNode, "", Ops); + const DagInit *DI = DagInit::get(SomeSDNode, "", Ops); // Create a TreePattern to parse this. TreePattern P(DefaultOps[iter][i], DI, false, *this); Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Mon Jul 11 15:55:22 2011 @@ -184,7 +184,7 @@ // Precompute some types. Record *RegisterCl = Def->getRecords().getClass("Register"); RecTy *RegisterRecTy = new RecordRecTy(RegisterCl); - const StringInit *BlankName = StringInit::Create(""); + const StringInit *BlankName = StringInit::get(""); // Zip them up. for (unsigned n = 0; n != Length; ++n) { @@ -196,7 +196,7 @@ Record *Reg = Lists[i][n]; if (i) Name += '_'; Name += Reg->getName(); - Tuple.push_back(DefInit::Create(Reg)); + Tuple.push_back(DefInit::get(Reg)); CostPerUse = std::max(CostPerUse, unsigned(Reg->getValueAsInt("CostPerUse"))); } @@ -217,7 +217,7 @@ // Replace the sub-register list with Tuple. if (RV.getName() == "SubRegs") - RV.setValue(ListInit::Create(Tuple, RegisterRecTy)); + RV.setValue(ListInit::get(Tuple, RegisterRecTy)); // Provide a blank AsmName. MC hacks are required anyway. if (RV.getName() == "AsmName") @@ -225,7 +225,7 @@ // CostPerUse is aggregated from all Tuple members. if (RV.getName() == "CostPerUse") - RV.setValue(IntInit::Create(CostPerUse)); + RV.setValue(IntInit::get(CostPerUse)); // Copy fields from the RegisterTuples def. if (RV.getName() == "SubRegIndices" || Modified: llvm/trunk/utils/TableGen/Record.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.cpp (original) +++ llvm/trunk/utils/TableGen/Record.cpp Mon Jul 11 15:55:22 2011 @@ -40,7 +40,7 @@ int64_t Val = II->getValue(); if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit! - return BitInit::Create(Val != 0); + return BitInit::get(Val != 0); } const Init *BitRecTy::convertValue(const TypedInit *VI) { @@ -57,9 +57,9 @@ SmallVector Bits(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = UnsetInit::Create(); + Bits[i] = UnsetInit::get(); - return BitsInit::Create(Bits.begin(), Bits.end()); + return BitsInit::get(Bits.begin(), Bits.end()); } const Init *BitsRecTy::convertValue(const BitInit *UI) { @@ -67,7 +67,7 @@ const Init *Bits[1] = { UI }; - return BitsInit::Create(Bits, array_endof(Bits)); + return BitsInit::get(Bits, array_endof(Bits)); } /// canFitInBitfield - Return true if the number of bits is large enough to hold @@ -90,9 +90,9 @@ SmallVector Bits(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = BitInit::Create(Value & (1LL << i)); + Bits[i] = BitInit::get(Value & (1LL << i)); - return BitsInit::Create(Bits.begin(), Bits.end()); + return BitsInit::get(Bits.begin(), Bits.end()); } const Init *BitsRecTy::convertValue(const BitsInit *BI) { @@ -108,14 +108,14 @@ SmallVector Bits(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = VarBitInit::Create(VI, i); - return BitsInit::Create(Bits.begin(), Bits.end()); + Bits[i] = VarBitInit::get(VI, i); + return BitsInit::get(Bits.begin(), Bits.end()); } if (Size == 1 && dynamic_cast(VI->getType())) { const Init *Bits[1] = { VI }; - return BitsInit::Create(Bits, array_endof(Bits)); + return BitsInit::get(Bits, array_endof(Bits)); } if (const TernOpInit *Tern = dynamic_cast(VI)) { @@ -136,12 +136,12 @@ for (unsigned i = 0; i != Size; ++i) NewBits[i] = - TernOpInit::Create(TernOpInit::IF, LHS, - IntInit::Create((MHSVal & (1LL << i)) ? 1 : 0), - IntInit::Create((RHSVal & (1LL << i)) ? 1 : 0), + TernOpInit::get(TernOpInit::IF, LHS, + IntInit::get((MHSVal & (1LL << i)) ? 1 : 0), + IntInit::get((RHSVal & (1LL << i)) ? 1 : 0), VI->getType()); - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } } else { const BitsInit *MHSbs = dynamic_cast(MHS); @@ -151,12 +151,12 @@ SmallVector NewBits(Size); for (unsigned i = 0; i != Size; ++i) - NewBits[i] = TernOpInit::Create(TernOpInit::IF, LHS, + NewBits[i] = TernOpInit::get(TernOpInit::IF, LHS, MHSbs->getBit(i), RHSbs->getBit(i), VI->getType()); - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } } } @@ -166,7 +166,7 @@ } const Init *IntRecTy::convertValue(const BitInit *BI) { - return IntInit::Create(BI->getValue()); + return IntInit::get(BI->getValue()); } const Init *IntRecTy::convertValue(const BitsInit *BI) { @@ -177,7 +177,7 @@ } else { return 0; } - return IntInit::Create(Result); + return IntInit::get(Result); } const Init *IntRecTy::convertValue(const TypedInit *TI) { @@ -191,7 +191,7 @@ const Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return UnOpInit::Create(UnOpInit::CAST, L, new StringRecTy); + return UnOpInit::get(UnOpInit::CAST, L, new StringRecTy); return BO; } @@ -204,7 +204,7 @@ const Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return BinOpInit::Create(BinOpInit::STRCONCAT, L, R, new StringRecTy); + return BinOpInit::get(BinOpInit::STRCONCAT, L, R, new StringRecTy); return BO; } @@ -238,7 +238,7 @@ return 0; } - return ListInit::Create(Elements, new ListRecTy(Ty)); + return ListInit::get(Elements, new ListRecTy(Ty)); } const Init *ListRecTy::convertValue(const TypedInit *TI) { @@ -266,7 +266,7 @@ const Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return UnOpInit::Create(UnOpInit::CAST, L, new DagRecTy); + return UnOpInit::get(UnOpInit::CAST, L, new DagRecTy); return BO; } return 0; @@ -278,7 +278,7 @@ const Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return BinOpInit::Create(BinOpInit::CONCAT, L, R, new DagRecTy); + return BinOpInit::get(BinOpInit::CONCAT, L, R, new DagRecTy); return BO; } return 0; @@ -379,7 +379,7 @@ void Init::dump() const { return print(errs()); } -const UnsetInit *UnsetInit::Create() { +const UnsetInit *UnsetInit::get() { FoldingSetNodeID ID; ID.AddInteger(initUnset); @@ -393,7 +393,7 @@ return I; } -const BitInit *BitInit::Create(bool V) { +const BitInit *BitInit::get(bool V) { FoldingSetNodeID ID; ID.AddInteger(initBit); ID.AddBoolean(V); @@ -419,7 +419,7 @@ NewBits[i] = getBit(Bits[i]); } - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } std::string BitsInit::getAsString() const { @@ -456,12 +456,12 @@ } if (Changed) - return BitsInit::Create(Bits.begin(), Bits.end()); + return BitsInit::get(Bits.begin(), Bits.end()); return this; } -const IntInit *IntInit::Create(int64_t V) { +const IntInit *IntInit::get(int64_t V) { FoldingSetNodeID ID; ID.AddInteger(initInt); ID.AddInteger(V); @@ -488,13 +488,13 @@ if (Bits[i] >= 64) return 0; - NewBits[i] = BitInit::Create(Value & (INT64_C(1) << Bits[i])); + NewBits[i] = BitInit::get(Value & (INT64_C(1) << Bits[i])); } - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } -const StringInit *StringInit::Create(const std::string &V) { +const StringInit *StringInit::get(const std::string &V) { FoldingSetNodeID ID; ID.AddInteger(initString); ID.AddString(V); @@ -509,7 +509,7 @@ return I; } -const CodeInit *CodeInit::Create(const std::string &V) { +const CodeInit *CodeInit::get(const std::string &V) { FoldingSetNodeID ID; ID.AddInteger(initCode); ID.AddString(V); @@ -524,7 +524,7 @@ return I; } -const ListInit *ListInit::Create(std::vector &Vs, RecTy *EltTy) { +const ListInit *ListInit::get(std::vector &Vs, RecTy *EltTy) { FoldingSetNodeID ID; ID.AddInteger(initList); ID.AddString(EltTy->getAsString()); @@ -553,7 +553,7 @@ return 0; Vals.push_back(getElement(Elements[i])); } - return ListInit::Create(Vals, getType()); + return ListInit::get(Vals, getType()); } Record *ListInit::getElementAsRecord(unsigned i) const { @@ -582,7 +582,7 @@ } if (Changed) - return ListInit::Create(Resolved, getType()); + return ListInit::get(Resolved, getType()); return this; } @@ -641,7 +641,7 @@ return 0; } -const UnOpInit *UnOpInit::Create(UnaryOp opc, const Init *lhs, RecTy *Type) { +const UnOpInit *UnOpInit::get(UnaryOp opc, const Init *lhs, RecTy *Type) { FoldingSetNodeID ID; ID.AddInteger(initUnOp); ID.AddInteger(opc); @@ -670,7 +670,7 @@ const DefInit *LHSd = dynamic_cast(LHS); if (LHSd) { - return StringInit::Create(LHSd->getDef()->getName()); + return StringInit::get(LHSd->getDef()->getName()); } } else { const StringInit *LHSs = dynamic_cast(LHS); @@ -682,7 +682,7 @@ if (const RecordVal *RV = CurRec->getValue(Name)) { if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::Create(Name, RV->getType()); + return VarInit::get(Name, RV->getType()); } std::string TemplateArgName = CurRec->getName()+":"+Name; @@ -693,7 +693,7 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::Create(TemplateArgName, RV->getType()); + return VarInit::get(TemplateArgName, RV->getType()); } } @@ -706,12 +706,12 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::Create(MCName, RV->getType()); + return VarInit::get(MCName, RV->getType()); } } if (Record *D = (CurRec->getRecords()).getDef(Name)) - return DefInit::Create(D); + return DefInit::get(D); throw TGError(CurRec->getLoc(), "Undefined reference:'" + Name + "'\n"); } @@ -736,7 +736,7 @@ assert(0 && "Empty list in cdr"); return 0; } - const ListInit *Result = ListInit::Create(LHSl->begin()+1, LHSl->end(), + const ListInit *Result = ListInit::get(LHSl->begin()+1, LHSl->end(), LHSl->getType()); return Result; } @@ -746,17 +746,17 @@ const ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { - return IntInit::Create(1); + return IntInit::get(1); } else { - return IntInit::Create(0); + return IntInit::get(0); } } const StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { if (LHSs->getValue().empty()) { - return IntInit::Create(1); + return IntInit::get(1); } else { - return IntInit::Create(0); + return IntInit::get(0); } } @@ -771,7 +771,7 @@ const Init *lhs = LHS->resolveReferences(R, RV); if (LHS != lhs) - return (UnOpInit::Create(getOpcode(), lhs, getType()))->Fold(&R, 0); + return (UnOpInit::get(getOpcode(), lhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -786,7 +786,7 @@ return Result + "(" + LHS->getAsString() + ")"; } -const BinOpInit *BinOpInit::Create(BinaryOp opc, const Init *lhs, +const BinOpInit *BinOpInit::get(BinaryOp opc, const Init *lhs, const Init *rhs, RecTy *Type) { FoldingSetNodeID ID; ID.AddInteger(initBinOp); @@ -826,7 +826,7 @@ Args.push_back(RHSs->getArg(i)); ArgNames.push_back(RHSs->getArgName(i)); } - return DagInit::Create(LHSs->getOperator(), "", Args, ArgNames); + return DagInit::get(LHSs->getOperator(), "", Args, ArgNames); } break; } @@ -834,7 +834,7 @@ const StringInit *LHSs = dynamic_cast(LHS); const StringInit *RHSs = dynamic_cast(RHS); if (LHSs && RHSs) - return StringInit::Create(LHSs->getValue() + RHSs->getValue()); + return StringInit::get(LHSs->getValue() + RHSs->getValue()); break; } case EQ: { @@ -846,14 +846,14 @@ dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); if (L && R) - return IntInit::Create(L->getValue() == R->getValue()); + return IntInit::get(L->getValue() == R->getValue()); const StringInit *LHSs = dynamic_cast(LHS); const StringInit *RHSs = dynamic_cast(RHS); // Make sure we've resolved if (LHSs && RHSs) - return IntInit::Create(LHSs->getValue() == RHSs->getValue()); + return IntInit::get(LHSs->getValue() == RHSs->getValue()); break; } @@ -871,7 +871,7 @@ case SRA: Result = LHSv >> RHSv; break; case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; } - return IntInit::Create(Result); + return IntInit::get(Result); } break; } @@ -885,7 +885,7 @@ const Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || RHS != rhs) - return (BinOpInit::Create(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); + return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -902,7 +902,7 @@ return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; } -const TernOpInit *TernOpInit::Create(TernaryOp opc, const Init *lhs, +const TernOpInit *TernOpInit::get(TernaryOp opc, const Init *lhs, const Init *mhs, const Init *rhs, RecTy *Type) { FoldingSetNodeID ID; @@ -1025,7 +1025,7 @@ args.push_back(std::make_pair(Arg, ArgName)); } - return DagInit::Create(Val, "", args); + return DagInit::get(Val, "", args); } if (MHSl) { std::vector NewOperands; @@ -1053,7 +1053,7 @@ *li = NewItem; } } - return ListInit::Create(NewList, MHSl->getType()); + return ListInit::get(NewList, MHSl->getType()); } } return 0; @@ -1083,14 +1083,14 @@ if (LHSd->getAsString() == RHSd->getAsString()) { Val = MHSd->getDef(); } - return DefInit::Create(Val); + return DefInit::get(Val); } if (RHSv) { std::string Val = RHSv->getName(); if (LHSv->getAsString() == RHSv->getAsString()) { Val = MHSv->getName(); } - return VarInit::Create(Val, getType()); + return VarInit::get(Val, getType()); } if (RHSs) { std::string Val = RHSs->getValue(); @@ -1105,7 +1105,7 @@ idx = found + MHSs->getValue().size(); } while (found != std::string::npos); - return StringInit::Create(Val); + return StringInit::get(Val); } } break; @@ -1151,11 +1151,11 @@ // Short-circuit if (Value->getValue()) { const Init *mhs = MHS->resolveReferences(R, RV); - return (TernOpInit::Create(getOpcode(), lhs, mhs, + return (TernOpInit::get(getOpcode(), lhs, mhs, RHS, getType()))->Fold(&R, 0); } else { const Init *rhs = RHS->resolveReferences(R, RV); - return (TernOpInit::Create(getOpcode(), lhs, MHS, + return (TernOpInit::get(getOpcode(), lhs, MHS, rhs, getType()))->Fold(&R, 0); } } @@ -1165,7 +1165,7 @@ const Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || MHS != mhs || RHS != rhs) - return (TernOpInit::Create(getOpcode(), lhs, mhs, rhs, getType()))-> + return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType()))-> Fold(&R, 0); return Fold(&R, 0); } @@ -1203,9 +1203,9 @@ if (Bits[i] >= NumBits) { return 0; } - NewBits[i] = VarBitInit::Create(this, Bits[i]); + NewBits[i] = VarBitInit::get(this, Bits[i]); } - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } const Init * @@ -1214,17 +1214,17 @@ if (T == 0) return 0; // Cannot subscript a non-list variable. if (Elements.size() == 1) - return VarListElementInit::Create(this, Elements[0]); + return VarListElementInit::get(this, Elements[0]); std::vector ListInits; ListInits.reserve(Elements.size()); for (unsigned i = 0, e = Elements.size(); i != e; ++i) - ListInits.push_back(VarListElementInit::Create(this, Elements[i])); - return ListInit::Create(ListInits, T); + ListInits.push_back(VarListElementInit::get(this, Elements[i])); + return ListInit::get(ListInits, T); } -const VarInit *VarInit::Create(const std::string &VN, RecTy *T) { +const VarInit *VarInit::get(const std::string &VN, RecTy *T) { FoldingSetNodeID ID; ID.AddInteger(initVar); ID.AddString(VN); @@ -1273,7 +1273,7 @@ if (!LI) { const VarInit *VI = dynamic_cast(RV->getValue()); assert(VI && "Invalid list element!"); - return VarListElementInit::Create(VI, Elt); + return VarListElementInit::get(VI, Elt); } if (Elt >= LI->getSize()) @@ -1325,7 +1325,7 @@ return this; } -const VarBitInit *VarBitInit::Create(const TypedInit *T, unsigned B) { +const VarBitInit *VarBitInit::get(const TypedInit *T, unsigned B) { FoldingSetNodeID ID; ID.AddInteger(initVarBit); ID.AddPointer(T); @@ -1353,7 +1353,7 @@ return this; } -const VarListElementInit *VarListElementInit::Create(const TypedInit *T, +const VarListElementInit *VarListElementInit::get(const TypedInit *T, unsigned E) { FoldingSetNodeID ID; ID.AddInteger(initVarListElement); @@ -1399,7 +1399,7 @@ return 0; } -const DefInit *DefInit::Create(Record *D) { +const DefInit *DefInit::get(Record *D) { FoldingSetNodeID ID; ID.AddInteger(initDef); ID.AddString(D->getName()); @@ -1430,7 +1430,7 @@ return Def->getName(); } -const FieldInit *FieldInit::Create(const Init *R, const std::string &FN) { +const FieldInit *FieldInit::get(const Init *R, const std::string &FN) { FoldingSetNodeID ID; ID.AddInteger(initField); ID.AddPointer(R); @@ -1487,13 +1487,13 @@ } if (NewRec != Rec) { - return FieldInit::Create(NewRec, FieldName); + return FieldInit::get(NewRec, FieldName); } return this; } const DagInit * -DagInit::Create(const Init *V, const std::string &VN, +DagInit::get(const Init *V, const std::string &VN, const std::vector > &args) { FoldingSetNodeID ID; ID.AddInteger(initDag); @@ -1520,7 +1520,7 @@ } const DagInit * -DagInit::Create(const Init *V, const std::string &VN, +DagInit::get(const Init *V, const std::string &VN, const std::vector &args, const std::vector &argNames) { FoldingSetNodeID ID; @@ -1557,7 +1557,7 @@ const Init *Op = Val->resolveReferences(R, RV); if (Args != NewArgs || Op != Val) - return DagInit::Create(Op, ValName, NewArgs, ArgNames); + return DagInit::get(Op, ValName, NewArgs, ArgNames); return this; } @@ -1585,7 +1585,7 @@ RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P) : Name(N), Ty(T), Prefix(P) { - Value = Ty->convertValue(UnsetInit::Create()); + Value = Ty->convertValue(UnsetInit::get()); assert(Value && "Cannot create unset value for current type!"); } Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Mon Jul 11 15:55:22 2011 @@ -710,7 +710,7 @@ UnsetInit &operator=(const UnsetInit &Other); // Do not define. public: - static const UnsetInit *Create(); + static const UnsetInit *get(); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -731,7 +731,7 @@ BitInit &operator=(BitInit &Other); // Do not define. public: - static const BitInit *Create(bool V); + static const BitInit *get(bool V); bool getValue() const { return Value; } @@ -760,7 +760,7 @@ public: template - static const BitsInit *Create(InputIterator Start, InputIterator End) { + static const BitsInit *get(InputIterator Start, InputIterator End) { FoldingSetNodeID ID; ID.AddInteger(initBits); ID.AddInteger(std::distance(Start, End)); @@ -826,7 +826,7 @@ IntInit &operator=(const IntInit &Other); // Do note define. public: - static const IntInit *Create(int64_t V); + static const IntInit *get(int64_t V); int64_t getValue() const { return Value; } @@ -872,7 +872,7 @@ StringInit &operator=(const StringInit &Other); // Do not define. public: - static const StringInit *Create(const std::string &V); + static const StringInit *get(const std::string &V); const std::string &getValue() const { return Value; } @@ -915,7 +915,7 @@ CodeInit &operator=(const CodeInit &Other); // Do not define. public: - static const CodeInit *Create(const std::string &V); + static const CodeInit *get(const std::string &V); const std::string &getValue() const { return Value; } @@ -950,11 +950,11 @@ ListInit &operator=(const ListInit &Other); // Do not define. public: - static const ListInit *Create(std::vector &Vs, RecTy *EltTy); + static const ListInit *get(std::vector &Vs, RecTy *EltTy); template - static const ListInit *Create(InputIterator Start, InputIterator End, - RecTy *EltTy) { + static const ListInit *get(InputIterator Start, InputIterator End, + RecTy *EltTy) { FoldingSetNodeID ID; ID.AddInteger(initList); ID.AddString(EltTy->getAsString()); @@ -1072,13 +1072,13 @@ UnOpInit &operator=(const UnOpInit &Other); // Do not define. public: - static const UnOpInit *Create(UnaryOp opc, const Init *lhs, RecTy *Type); + static const UnOpInit *get(UnaryOp opc, const Init *lhs, RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 1 && "Wrong number of operands for unary operation"); - return UnOpInit::Create(getOpcode(), *Operands.begin(), getType()); + return UnOpInit::get(getOpcode(), *Operands.begin(), getType()); } int getNumOperands() const { return 1; } @@ -1117,14 +1117,14 @@ BinOpInit &operator=(const BinOpInit &Other); // Do not define. public: - static const BinOpInit *Create(BinaryOp opc, const Init *lhs, const Init *rhs, - RecTy *Type); + static const BinOpInit *get(BinaryOp opc, const Init *lhs, const Init *rhs, + RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 2 && "Wrong number of operands for binary operation"); - return BinOpInit::Create(getOpcode(), Operands[0], Operands[1], getType()); + return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType()); } int getNumOperands() const { return 2; } @@ -1168,16 +1168,16 @@ TernOpInit &operator=(const TernOpInit &Other); // Do not define. public: - static const TernOpInit *Create(TernaryOp opc, const Init *lhs, - const Init *mhs, const Init *rhs, - RecTy *Type); + static const TernOpInit *get(TernaryOp opc, const Init *lhs, + const Init *mhs, const Init *rhs, + RecTy *Type); // Clone - Clone this operator, replacing arguments with the new list virtual const OpInit *clone(std::vector &Operands) const { assert(Operands.size() == 3 && "Wrong number of operands for ternary operation"); - return TernOpInit::Create(getOpcode(), Operands[0], Operands[1], - Operands[2], getType()); + return TernOpInit::get(getOpcode(), Operands[0], Operands[1], + Operands[2], getType()); } int getNumOperands() const { return 3; } @@ -1223,8 +1223,8 @@ VarInit &operator=(const VarInit &Other); // Do not define. public: - static const VarInit *Create(const std::string &VN, RecTy *T); - static const VarInit *Create(const Init *VN, RecTy *T); + static const VarInit *get(const std::string &VN, RecTy *T); + static const VarInit *get(const Init *VN, RecTy *T); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -1271,7 +1271,7 @@ VarBitInit &operator=(const VarBitInit &Other); // Do not define. public: - static const VarBitInit *Create(const TypedInit *T, unsigned B); + static const VarBitInit *get(const TypedInit *T, unsigned B); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -1304,7 +1304,7 @@ // define. public: - static const VarListElementInit *Create(const TypedInit *T, unsigned E); + static const VarListElementInit *get(const TypedInit *T, unsigned E); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -1339,7 +1339,7 @@ DefInit &operator=(const DefInit &Other); // Do not define. public: - static const DefInit *Create(Record *D); + static const DefInit *get(Record *D); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -1393,8 +1393,8 @@ FieldInit &operator=(const FieldInit &Other); // Do not define. public: - static const FieldInit *Create(const Init *R, const std::string &FN); - static const FieldInit *Create(const Init *R, const Init *FN); + static const FieldInit *get(const Init *R, const std::string &FN); + static const FieldInit *get(const Init *R, const Init *FN); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); @@ -1444,12 +1444,12 @@ DagInit &operator=(const DagInit &Other); // Do not define. public: - static const DagInit *Create(const Init *V, const std::string &VN, - const std::vector< - std::pair > &args); - static const DagInit *Create(const Init *V, const std::string &VN, - const std::vector &args, - const std::vector &argNames); + static const DagInit *get(const Init *V, const std::string &VN, + const std::vector< + std::pair > &args); + static const DagInit *get(const Init *V, const std::string &VN, + const std::vector &args, + const std::vector &argNames); virtual const Init *convertInitializerTo(RecTy *Ty) const { return Ty->convertValue(this); Modified: llvm/trunk/utils/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=134921&r1=134920&r2=134921&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.cpp (original) +++ llvm/trunk/utils/TableGen/TGParser.cpp Mon Jul 11 15:55:22 2011 @@ -131,7 +131,7 @@ if (NewBits[i] == 0) NewBits[i] = CurVal->getBit(i); - V = BitsInit::Create(NewBits.begin(), NewBits.end()); + V = BitsInit::get(NewBits.begin(), NewBits.end()); } if (RV->setValue(V)) @@ -647,13 +647,13 @@ const std::string &Name, SMLoc NameLoc) { if (CurRec) { if (const RecordVal *RV = CurRec->getValue(Name)) - return VarInit::Create(Name, RV->getType()); + return VarInit::get(Name, RV->getType()); std::string TemplateArgName = CurRec->getName()+":"+Name; if (CurRec->isTemplateArg(TemplateArgName)) { const RecordVal *RV = CurRec->getValue(TemplateArgName); assert(RV && "Template arg doesn't exist??"); - return VarInit::Create(TemplateArgName, RV->getType()); + return VarInit::get(TemplateArgName, RV->getType()); } } @@ -662,12 +662,12 @@ if (CurMultiClass->Rec.isTemplateArg(MCName)) { const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); assert(RV && "Template arg doesn't exist??"); - return VarInit::Create(MCName, RV->getType()); + return VarInit::get(MCName, RV->getType()); } } if (Record *D = Records.getDef(Name)) - return DefInit::Create(D); + return DefInit::get(D); Error(NameLoc, "Variable not defined: '" + Name + "'"); return 0; @@ -790,7 +790,7 @@ return 0; } Lex.Lex(); // eat the ')' - return (UnOpInit::Create(Code, LHS, Type))->Fold(CurRec, CurMultiClass); + return (UnOpInit::get(Code, LHS, Type))->Fold(CurRec, CurMultiClass); } case tgtok::XConcat: @@ -848,14 +848,14 @@ if (Code == BinOpInit::STRCONCAT) { while (InitList.size() > 2) { const Init *RHS = InitList.pop_back_val(); - RHS = (BinOpInit::Create(Code, InitList.back(), RHS, Type)) + RHS = (BinOpInit::get(Code, InitList.back(), RHS, Type)) ->Fold(CurRec, CurMultiClass); InitList.back() = RHS; } } if (InitList.size() == 2) - return (BinOpInit::Create(Code, InitList[0], InitList[1], Type)) + return (BinOpInit::get(Code, InitList[0], InitList[1], Type)) ->Fold(CurRec, CurMultiClass); Error(OpLoc, "expected two operands to operator"); @@ -982,7 +982,7 @@ break; } } - return (TernOpInit::Create(Code, LHS, MHS, RHS, Type))->Fold(CurRec, + return (TernOpInit::get(Code, LHS, MHS, RHS, Type))->Fold(CurRec, CurMultiClass); } } @@ -1042,7 +1042,7 @@ const Init *R = 0; switch (Lex.getCode()) { default: TokError("Unknown token when parsing a value"); break; - case tgtok::IntVal: R = IntInit::Create(Lex.getCurIntVal()); Lex.Lex(); break; + case tgtok::IntVal: R = IntInit::get(Lex.getCurIntVal()); Lex.Lex(); break; case tgtok::StrVal: { std::string Val = Lex.getCurStrVal(); Lex.Lex(); @@ -1053,15 +1053,15 @@ Lex.Lex(); } - R = StringInit::Create(Val); + R = StringInit::get(Val); break; } case tgtok::CodeFragment: - R = CodeInit::Create(Lex.getCurStrVal()); + R = CodeInit::get(Lex.getCurStrVal()); Lex.Lex(); break; case tgtok::question: - R = UnsetInit::Create(); + R = UnsetInit::get(); Lex.Lex(); break; case tgtok::Id: { @@ -1110,7 +1110,7 @@ Records.addDef(NewRec); // The result of the expression is a reference to the new record. - return DefInit::Create(NewRec); + return DefInit::get(NewRec); } case tgtok::l_brace: { // Value ::= '{' ValueList '}' SMLoc BraceLoc = Lex.getLoc(); @@ -1138,7 +1138,7 @@ } NewBits[Vals.size()-i-1] = Bit; } - return BitsInit::Create(NewBits.begin(), NewBits.end()); + return BitsInit::get(NewBits.begin(), NewBits.end()); } case tgtok::l_square: { // Value ::= '[' ValueList ']' Lex.Lex(); // eat the '[' @@ -1237,7 +1237,7 @@ DeducedEltTy = EltTy; } - return ListInit::Create(Vals, DeducedEltTy); + return ListInit::get(Vals, DeducedEltTy); } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' @@ -1272,7 +1272,7 @@ } Lex.Lex(); // eat the ')' - return DagInit::Create(Operator, OperatorName, DagArgs); + return DagInit::get(Operator, OperatorName, DagArgs); } case tgtok::XHead: @@ -1362,7 +1362,7 @@ Result->getAsString() + "'"); return 0; } - Result = FieldInit::Create(Result, Lex.getCurStrVal()); + Result = FieldInit::get(Result, Lex.getCurStrVal()); Lex.Lex(); // eat field name break; } From evan.cheng at apple.com Mon Jul 11 15:59:55 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 13:59:55 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> Message-ID: /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic pure virtual method called terminate called without an active exception On Jul 11, 2011, at 1:41 PM, David A. Greene wrote: > Owen Anderson writes: > >> I'm getting build failures from this. Something about a pure virtual method call? > > Hmm...Not seen that before. What are you building when this happens? > > -Dave > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110711/c3944af6/attachment.html From zwarich at apple.com Mon Jul 11 16:00:27 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Mon, 11 Jul 2011 14:00:27 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> Message-ID: Everything builds fine for me with r134919 using Debug+Asserts and Release+Asserts. Cameron On Jul 11, 2011, at 1:24 PM, Evan Cheng wrote: > There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: > > /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic > pure virtual method called > terminate called without an active exception > > > Evan > > On Jul 11, 2011, at 12:00 PM, David A. Greene wrote: > >> Rafael ?vila de Esp?ndola writes: >> >>> I think this is causing: >>> >>> /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: >>> struct 'Init' was previously >>> declared as a class [-Wmismatched-tags] >>> struct Init; >>> ^ >> >> Fixed in 134908. Thanks for the heads-up! >> >> -Dave >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From greened at obbligato.org Mon Jul 11 16:00:01 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:00:01 -0500 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: (John McCall's message of "Mon, 11 Jul 2011 12:16:55 -0700") References: Message-ID: John McCall writes: >> Is there a naming convention here? I've seen Create() used in other >> places, which is why I used it. :) > > The convention, as I see it, is to use 'create' for factory methods that > return a non-uniqued object and 'get' for factory methods that return > a uniqued object. Note that I have no idea which category this falls > into. This should be documented in CodingStandards.html. From greened at obbligato.org Mon Jul 11 16:01:21 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:01:21 -0500 Subject: [llvm-commits] [llvm] r134917 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.h Record.h TGParser.h In-Reply-To: <20110711202313.C39B02A6C12C@llvm.org> (Evan Cheng's message of "Mon, 11 Jul 2011 20:23:13 -0000") References: <20110711202313.C39B02A6C12C@llvm.org> Message-ID: Evan Cheng writes: > Author: evancheng > Date: Mon Jul 11 15:23:13 2011 > New Revision: 134917 > > URL: http://llvm.org/viewvc/llvm-project?rev=134917&view=rev > Log: > struct Init -> class Init. Thanks, Evan! It seems the buildbots should be updated to include -Werror and a set of warnings people care about. Who is able to do that? I did not see any warnings at all with a default build. -Dave From mailing-list at martin-whitaker.me.uk Mon Jul 11 16:05:34 2011 From: mailing-list at martin-whitaker.me.uk (Martin Whitaker) Date: Mon, 11 Jul 2011 22:05:34 +0100 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> Message-ID: <4E1B659E.4000909@martin-whitaker.me.uk> Jakob Stoklund Olesen wrote: > > On Jul 11, 2011, at 12:24 PM, Martin Whitaker wrote: > >> This patch adds a SPARC code generator feature that allows the code generator to optionally use the global registers that are reserved for application use by the SPARC ABI (g2,g3,g4). >> >> It also changes the preferred register allocation order to give preference to the global and input registers, to increase the chances of being able to eliminate the frame save/restore in leaf functions (when that optimisation is added). I'm doing this now because it also makes the regression test for this patch simpler (and less likely to break in the future). >> >> Please review. > > There register stuff looks good to me, but someone who is familiar with SPARC should comment. > > +define void @test(i32* %ptr) nounwind { > +entry: > +; CHECK_N: ld [%i0], %i3 > +; CHECK_N: ld [%i0], %i2 > +; CHECK_N: ld [%i0], %i1 > +; CHECK_Y: ld [%i0], %g4 > +; CHECK_Y: ld [%i0], %g3 > +; CHECK_Y: ld [%i0], %g2 > > Please don't write tests that depend on the exact details of register allocation. There is no reason these registers would be allocated in exactly that order. > This test is checking whether the feature of enabling/disabling use of the global registers g2-g4 is working. I spent some time thinking about this, but can't think of a way to test this that doesn't depend on the exact details of register allocation. Just had a thought - is it possible to use regular expressions in the patterns to be matched? > Check for the absence or presence of frame save/restore code instead. > That optimisation is not yet performed - it will (I hope) be the subject of a future patch. I changed the preferred register allocation order now to minimise the chances of the regression test associated with this patch breaking when that optimisation is added. Martin From stoklund at 2pi.dk Mon Jul 11 16:07:52 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 14:07:52 -0700 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <4E1B659E.4000909@martin-whitaker.me.uk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> <4E1B659E.4000909@martin-whitaker.me.uk> Message-ID: <85EB61D6-AABA-4298-BD60-DC63B875404E@2pi.dk> On Jul 11, 2011, at 2:05 PM, Martin Whitaker wrote: > Jakob Stoklund Olesen wrote: >> >> On Jul 11, 2011, at 12:24 PM, Martin Whitaker wrote: >> >>> This patch adds a SPARC code generator feature that allows the code generator to optionally use the global registers that are reserved for application use by the SPARC ABI (g2,g3,g4). >>> >>> It also changes the preferred register allocation order to give preference to the global and input registers, to increase the chances of being able to eliminate the frame save/restore in leaf functions (when that optimisation is added). I'm doing this now because it also makes the regression test for this patch simpler (and less likely to break in the future). >>> >>> Please review. >> >> There register stuff looks good to me, but someone who is familiar with SPARC should comment. >> >> +define void @test(i32* %ptr) nounwind { >> +entry: >> +; CHECK_N: ld [%i0], %i3 >> +; CHECK_N: ld [%i0], %i2 >> +; CHECK_N: ld [%i0], %i1 >> +; CHECK_Y: ld [%i0], %g4 >> +; CHECK_Y: ld [%i0], %g3 >> +; CHECK_Y: ld [%i0], %g2 >> >> Please don't write tests that depend on the exact details of register allocation. There is no reason these registers would be allocated in exactly that order. >> > This test is checking whether the feature of enabling/disabling use of the global registers g2-g4 is working. I spent some time thinking about this, but can't think of a way to test this that doesn't depend on the exact details of register allocation. > > Just had a thought - is it possible to use regular expressions in the patterns to be matched? Yes, and you can use CHECK-NOT. See the man-page for FileCheck/ /jakob From evan.cheng at apple.com Mon Jul 11 16:10:46 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 14:10:46 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> Message-ID: <1C8EB4E4-E99E-43FE-92C7-AE46435D34C8@apple.com> Interesting. The clang from a couple of months ago definitely doesn't like it. I had to move up to a week old clang to get pass this problem. Evan On Jul 11, 2011, at 2:00 PM, Cameron Zwarich wrote: > Everything builds fine for me with r134919 using Debug+Asserts and Release+Asserts. > > Cameron > > On Jul 11, 2011, at 1:24 PM, Evan Cheng wrote: > >> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: >> >> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >> pure virtual method called >> terminate called without an active exception >> >> >> Evan >> >> On Jul 11, 2011, at 12:00 PM, David A. Greene wrote: >> >>> Rafael ?vila de Esp?ndola writes: >>> >>>> I think this is causing: >>>> >>>> /home/espindola/llvm/llvm/utils/TableGen/SetTheory.h:58:1: warning: >>>> struct 'Init' was previously >>>> declared as a class [-Wmismatched-tags] >>>> struct Init; >>>> ^ >>> >>> Fixed in 134908. Thanks for the heads-up! >>> >>> -Dave >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From greened at obbligato.org Mon Jul 11 16:11:30 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:11:30 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: (Evan Cheng's message of "Mon, 11 Jul 2011 13:59:55 -0700") References: <20110711182552.740612A6C12C@llvm.org> Message-ID: Evan Cheng writes: > /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/ > echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/ > VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic > pure virtual method called > terminate called without an active exception Still don't see it: dag at lamba:/ptmp/dag/build/llvm/official$ ./Debug+Asserts/bin/tblgen -I /ptmp/dag/llvm/llvm-svn/lib/VMCore -I /ptmp/dag/llvm/llvm-svn/include -I /ptmp/dag/llvm/llvm-svn/lib/Target /ptmp/dag/llvm/llvm-svn/include/llvm/Intrinsics.td -o lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic dag at lamba:/ptmp/dag/build/llvm/official$ What host and target? How did you run configure? -Dave From greened at obbligato.org Mon Jul 11 16:16:03 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:16:03 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: (David A. Greene's message of "Mon, 11 Jul 2011 16:11:30 -0500") References: <20110711182552.740612A6C12C@llvm.org> Message-ID: greened at obbligato.org (David A. Greene) writes: > Evan Cheng writes: > >> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/ >> echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/ >> VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >> pure virtual method called >> terminate called without an active exception > > Still don't see it: > > dag at lamba:/ptmp/dag/build/llvm/official$ ./Debug+Asserts/bin/tblgen -I /ptmp/dag/llvm/llvm-svn/lib/VMCore -I /ptmp/dag/llvm/llvm-svn/include -I /ptmp/dag/llvm/llvm-svn/lib/Target /ptmp/dag/llvm/llvm-svn/include/llvm/Intrinsics.td -o lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic dag at lamba:/ptmp/dag/build/llvm/official$ > > What host and target? How did you run configure? And which compiler did you use to build? I'm more than happy to track this down once I can reproduce the problem. I'll try some other versions of gcc to see if I can get it to fire here. -Dave From evan.cheng at apple.com Mon Jul 11 16:24:16 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 21:24:16 -0000 Subject: [llvm-commits] [llvm] r134922 - in /llvm/trunk/lib/Target: ARM/ARMMCCodeEmitter.cpp MBlaze/MBlazeMCCodeEmitter.cpp PowerPC/PPCMCCodeEmitter.cpp Message-ID: <20110711212416.23B792A6C12C@llvm.org> Author: evancheng Date: Mon Jul 11 16:24:15 2011 New Revision: 134922 URL: http://llvm.org/viewvc/llvm-project?rev=134922&view=rev Log: Most MCCodeEmitter's don't meed MCContext. Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp llvm/trunk/lib/Target/PowerPC/PPCMCCodeEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp?rev=134922&r1=134921&r2=134922&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMMCCodeEmitter.cpp Mon Jul 11 16:24:15 2011 @@ -40,12 +40,11 @@ void operator=(const ARMMCCodeEmitter &); // DO NOT IMPLEMENT const MCInstrInfo &MCII; const MCSubtargetInfo &STI; - MCContext &Ctx; public: ARMMCCodeEmitter(const MCInstrInfo &mcii, const MCSubtargetInfo &sti, MCContext &ctx) - : MCII(mcii), STI(sti), Ctx(ctx) { + : MCII(mcii), STI(sti) { } ~ARMMCCodeEmitter() {} Modified: llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp?rev=134922&r1=134921&r2=134922&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeMCCodeEmitter.cpp Mon Jul 11 16:24:15 2011 @@ -30,12 +30,11 @@ MBlazeMCCodeEmitter(const MBlazeMCCodeEmitter &); // DO NOT IMPLEMENT void operator=(const MBlazeMCCodeEmitter &); // DO NOT IMPLEMENT const MCInstrInfo &MCII; - MCContext &Ctx; public: MBlazeMCCodeEmitter(const MCInstrInfo &mcii, const MCSubtargetInfo &sti, MCContext &ctx) - : MCII(mcii), Ctx(ctx) { + : MCII(mcii) { } ~MBlazeMCCodeEmitter() {} Modified: llvm/trunk/lib/Target/PowerPC/PPCMCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCMCCodeEmitter.cpp?rev=134922&r1=134921&r2=134922&view=diff ============================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCMCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/PowerPC/PPCMCCodeEmitter.cpp Mon Jul 11 16:24:15 2011 @@ -28,12 +28,10 @@ class PPCMCCodeEmitter : public MCCodeEmitter { PPCMCCodeEmitter(const PPCMCCodeEmitter &); // DO NOT IMPLEMENT void operator=(const PPCMCCodeEmitter &); // DO NOT IMPLEMENT - MCContext &Ctx; public: PPCMCCodeEmitter(const MCInstrInfo &mcii, const MCSubtargetInfo &sti, - MCContext &ctx) - : Ctx(ctx) { + MCContext &ctx) { } ~PPCMCCodeEmitter() {} From greened at obbligato.org Mon Jul 11 16:25:53 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:25:53 -0500 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: (Jakob Stoklund Olesen's message of "Mon, 11 Jul 2011 13:17:36 -0700") References: Message-ID: Jakob Stoklund Olesen writes: >> I can't. It's needed to maintain const-correctness. LLVM won't build >> without it. > > Sure you can. How? get() should return a const Init *. As soon as you do that, it has to be const everywhere. Otherwise there is a big risk of getting the patch wrong. Having "const" there caught a lot of bugs as I developed this patch. > Let's discuss after you revert your patches. I've committed the name change from Create() to get(). What else needs to be done? -Dave From stoklund at 2pi.dk Mon Jul 11 16:30:26 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 14:30:26 -0700 Subject: [llvm-commits] [PATCH] Make TableGen Inits FoldingSetNodes In-Reply-To: References: Message-ID: <5A6199A5-1F53-4E36-8AE4-58CADA65C5EE@2pi.dk> On Jul 11, 2011, at 2:25 PM, David A. Greene wrote: > Jakob Stoklund Olesen writes: > >>> I can't. It's needed to maintain const-correctness. LLVM won't build >>> without it. >> >> Sure you can. > > How? get() should return a const Init *. As soon as you do that, > it has to be const everywhere. > > Otherwise there is a big risk of getting the patch wrong. Having > "const" there caught a lot of bugs as I developed this patch. So you could have added the const-ness first and applied the actual changes later. >> Let's discuss after you revert your patches. > > I've committed the name change from Create() to get(). What else > needs to be done? Your patch still needs to be broken into two parts - one with the mechanical const changes, and one that we can actually review. /jakob From greened at obbligato.org Mon Jul 11 16:33:53 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 16:33:53 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> (Evan Cheng's message of "Mon, 11 Jul 2011 13:24:08 -0700") References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> Message-ID: Evan Cheng writes: > There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: > > /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic > pure virtual method called > terminate called without an active exception I've tried multiple gcc versions and I still don't see this. What compiler are you using to build? Can you send me your configure line? Thanks! -Dave From mailing-list at martin-whitaker.me.uk Mon Jul 11 16:59:53 2011 From: mailing-list at martin-whitaker.me.uk (Martin Whitaker) Date: Mon, 11 Jul 2011 22:59:53 +0100 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <85EB61D6-AABA-4298-BD60-DC63B875404E@2pi.dk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> <4E1B659E.4000909@martin-whitaker.me.uk> <85EB61D6-AABA-4298-BD60-DC63B875404E@2pi.dk> Message-ID: <4E1B7259.4080306@martin-whitaker.me.uk> Jakob Stoklund Olesen wrote: > > On Jul 11, 2011, at 2:05 PM, Martin Whitaker wrote: > >> Jakob Stoklund Olesen wrote: >>> [...] >>> There register stuff looks good to me, but someone who is familiar with SPARC should comment. >>> >>> +define void @test(i32* %ptr) nounwind { >>> +entry: >>> +; CHECK_N: ld [%i0], %i3 >>> +; CHECK_N: ld [%i0], %i2 >>> +; CHECK_N: ld [%i0], %i1 >>> +; CHECK_Y: ld [%i0], %g4 >>> +; CHECK_Y: ld [%i0], %g3 >>> +; CHECK_Y: ld [%i0], %g2 >>> >>> Please don't write tests that depend on the exact details of register allocation. There is no reason these registers would be allocated in exactly that order. >>> >> This test is checking whether the feature of enabling/disabling use of the global registers g2-g4 is working. I spent some time thinking about this, but can't think of a way to test this that doesn't depend on the exact details of register allocation. >> >> Just had a thought - is it possible to use regular expressions in the patterns to be matched? > > Yes, and you can use CHECK-NOT. See the man-page for FileCheck/ > OK, revised patch attached, with > +; CHECK_N: ld [%i0], %i{{[1-3]}} > +; CHECK_N: ld [%i0], %i{{[1-3]}} > +; CHECK_N: ld [%i0], %i{{[1-3]}} > +; CHECK_Y: ld [%i0], %g{{[2-4]}} > +; CHECK_Y: ld [%i0], %g{{[2-4]}} > +; CHECK_Y: ld [%i0], %g{{[2-4]}} This makes the test independent of the exact order that the registers are allocated, although it does still require that the registers are allocated using the preferred order. I hope the register allocator does observe the preferred order, otherwise we won't be able to do a good job of optimising leaf functions on the SPARC. Martin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: 0001-Enable-use-of-SPARC-g2-g4-global-registers.patch Url: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110711/1171596e/attachment.pl From stoklund at 2pi.dk Mon Jul 11 17:07:00 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 11 Jul 2011 15:07:00 -0700 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <4E1B7259.4080306@martin-whitaker.me.uk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> <4E1B659E.4000909@martin-whitaker.me.uk> <85EB61D6-AABA-4298-BD60-DC63B875404E@2pi.dk> <4E1B7259.4080306@martin-whitaker.me.uk> Message-ID: <78D15243-C2F7-4BE9-ADCA-877F9A670026@2pi.dk> On Jul 11, 2011, at 2:59 PM, Martin Whitaker wrote: > OK, revised patch attached, with > > > +; CHECK_N: ld [%i0], %i{{[1-3]}} > > +; CHECK_N: ld [%i0], %i{{[1-3]}} > > +; CHECK_N: ld [%i0], %i{{[1-3]}} > > +; CHECK_Y: ld [%i0], %g{{[2-4]}} > > +; CHECK_Y: ld [%i0], %g{{[2-4]}} > > +; CHECK_Y: ld [%i0], %g{{[2-4]}} > > This makes the test independent of the exact order that the registers are allocated, although it does still require that the registers are allocated using the preferred order. I hope the register allocator does observe the preferred order, otherwise we won't be able to do a good job of optimising leaf functions on the SPARC. The register allocator follows the preferred order as long as it doesn't need to use all the available registers, so I think your patch is fine. In the not so distant future, it will treat all volatile registers as 'free', i.e. it may allocate more volatile registers than is strictly needed. Should G2-G4 be treated as callee-saved registers? /jakob From evan.cheng at apple.com Mon Jul 11 17:16:56 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 15:16:56 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> Message-ID: <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> I use clang and building for all targets on Mac OS X 10.6. ./configure CC=/Developer/usr/bin/clang CXX=/Developer/usr/bin/clang++ Evan On Jul 11, 2011, at 2:33 PM, David A. Greene wrote: > Evan Cheng writes: > >> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: >> >> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >> pure virtual method called >> terminate called without an active exception > > I've tried multiple gcc versions and I still don't see this. > > What compiler are you using to build? > > Can you send me your configure line? Thanks! > > -Dave From mailing-list at martin-whitaker.me.uk Mon Jul 11 17:19:04 2011 From: mailing-list at martin-whitaker.me.uk (Martin Whitaker) Date: Mon, 11 Jul 2011 23:19:04 +0100 Subject: [llvm-commits] [PATCH] Enable use of SPARC g2-g4 global registers In-Reply-To: <78D15243-C2F7-4BE9-ADCA-877F9A670026@2pi.dk> References: <4E1B4E07.3090408@martin-whitaker.me.uk> <53BB11CC-A939-49B9-8495-7B7A8AC2AF29@2pi.dk> <4E1B659E.4000909@martin-whitaker.me.uk> <85EB61D6-AABA-4298-BD60-DC63B875404E@2pi.dk> <4E1B7259.4080306@martin-whitaker.me.uk> <78D15243-C2F7-4BE9-ADCA-877F9A670026@2pi.dk> Message-ID: <4E1B76D8.8040408@martin-whitaker.me.uk> Jakob Stoklund Olesen wrote: > > On Jul 11, 2011, at 2:59 PM, Martin Whitaker wrote: > >> OK, revised patch attached, with >> >>> +; CHECK_N: ld [%i0], %i{{[1-3]}} >>> +; CHECK_N: ld [%i0], %i{{[1-3]}} >>> +; CHECK_N: ld [%i0], %i{{[1-3]}} >>> +; CHECK_Y: ld [%i0], %g{{[2-4]}} >>> +; CHECK_Y: ld [%i0], %g{{[2-4]}} >>> +; CHECK_Y: ld [%i0], %g{{[2-4]}} >> >> This makes the test independent of the exact order that the registers are allocated, although it does still require that the registers are allocated using the preferred order. I hope the register allocator does observe the preferred order, otherwise we won't be able to do a good job of optimising leaf functions on the SPARC. > > The register allocator follows the preferred order as long as it doesn't need to use all the available registers, so I think your patch is fine. > > In the not so distant future, it will treat all volatile registers as 'free', i.e. it may allocate more volatile registers than is strictly needed. > > Should G2-G4 be treated as callee-saved registers? > In my experience, no. You gain much more by having them as additional volatile registers. Martin From zwarich at apple.com Mon Jul 11 17:19:52 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Mon, 11 Jul 2011 22:19:52 -0000 Subject: [llvm-commits] [llvm] r134930 - in /llvm/trunk/tools/lto: LTOCodeGenerator.cpp LTOModule.cpp Message-ID: <20110711221952.0B11F2A6C12C@llvm.org> Author: zwarich Date: Mon Jul 11 17:19:51 2011 New Revision: 134930 URL: http://llvm.org/viewvc/llvm-project?rev=134930&view=rev Log: Fix LTO after the recent MC subtarget refactoring. Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=134930&r1=134929&r2=134930&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Mon Jul 11 17:19:51 2011 @@ -73,6 +73,7 @@ _nativeObjectFile(NULL) { InitializeAllTargets(); + InitializeAllMCSubtargetInfos(); InitializeAllAsmPrinters(); } Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=134930&r1=134929&r2=134930&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Mon Jul 11 17:19:51 2011 @@ -135,6 +135,7 @@ static bool Initialized = false; if (!Initialized) { InitializeAllTargets(); + InitializeAllMCSubtargetInfos(); InitializeAllAsmParsers(); Initialized = true; } From resistor at mac.com Mon Jul 11 17:24:28 2011 From: resistor at mac.com (Owen Anderson) Date: Mon, 11 Jul 2011 15:24:28 -0700 Subject: [llvm-commits] [llvm] r134917 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.h Record.h TGParser.h In-Reply-To: References: <20110711202313.C39B02A6C12C@llvm.org> Message-ID: <408586D0-F633-4BEE-84EF-227E5175F824@mac.com> On Jul 11, 2011, at 2:01 PM, David A. Greene wrote: > Evan Cheng writes: > >> Author: evancheng >> Date: Mon Jul 11 15:23:13 2011 >> New Revision: 134917 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134917&view=rev >> Log: >> struct Init -> class Init. > > Thanks, Evan! > > It seems the buildbots should be updated to include -Werror and a > set of warnings people care about. Who is able to do that? I > did not see any warnings at all with a default build. A lot of us are building LLVM with Clang nowadays, with which this warning appears by default. --Owen From pichet2000 at gmail.com Mon Jul 11 17:31:03 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Mon, 11 Jul 2011 18:31:03 -0400 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> Message-ID: hi people... I am getting a pure virtual call too with MSVC.. On Mon, Jul 11, 2011 at 6:16 PM, Evan Cheng wrote: > I use clang and building for all targets on Mac OS X 10.6. > ./configure CC=/Developer/usr/bin/clang CXX=/Developer/usr/bin/clang++ > > Evan > > On Jul 11, 2011, at 2:33 PM, David A. Greene wrote: > >> Evan Cheng writes: >> >>> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: >>> >>> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I ?/Volumes/Ebi/echeng/llvm/lib/VMCore -I ?/Volumes/Ebi/echeng/llvm/include -I ?/Volumes/Ebi/echeng/llvm/include -I ?/Volumes/Ebi/echeng/llvm/lib/Target ?/Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o ?/Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >>> pure virtual method called >>> terminate called without an active exception >> >> I've tried multiple gcc versions and I still don't see this. >> >> What compiler are you using to build? >> >> Can you send me your configure line? ?Thanks! >> >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-Dave > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From pichet2000 at gmail.com Mon Jul 11 17:47:27 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Mon, 11 Jul 2011 18:47:27 -0400 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> Message-ID: I started the VC++ debugger on tblgen and the pure function call is on line 71 of file Support\Allocator.cpp: > Allocator.Deallocate(Slab); This is during doexit() after main has finished.. static variable destructor i suppose. I suspect a memory corruption. On Mon, Jul 11, 2011 at 6:31 PM, Francois Pichet wrote: > hi people... > > I am getting a pure virtual call too with MSVC.. > > On Mon, Jul 11, 2011 at 6:16 PM, Evan Cheng wrote: >> I use clang and building for all targets on Mac OS X 10.6. >> ./configure CC=/Developer/usr/bin/clang CXX=/Developer/usr/bin/clang++ >> >> Evan >> >> On Jul 11, 2011, at 2:33 PM, David A. Greene wrote: >> >>> Evan Cheng writes: >>> >>>> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: >>>> >>>> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I ?/Volumes/Ebi/echeng/llvm/lib/VMCore -I ?/Volumes/Ebi/echeng/llvm/include -I ?/Volumes/Ebi/echeng/llvm/include -I ?/Volumes/Ebi/echeng/llvm/lib/Target ?/Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o ?/Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >>>> pure virtual method called >>>> terminate called without an active exception >>> >>> I've tried multiple gcc versions and I still don't see this. >>> >>> What compiler are you using to build? >>> >>> Can you send me your configure line? ?Thanks! >>> >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-Dave >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From echristo at apple.com Mon Jul 11 18:06:52 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 11 Jul 2011 23:06:52 -0000 Subject: [llvm-commits] [llvm] r134936 - /llvm/trunk/utils/TableGen/ Message-ID: <20110711230653.7DA112A6C12C@llvm.org> Author: echristo Date: Mon Jul 11 18:06:52 2011 New Revision: 134936 URL: http://llvm.org/viewvc/llvm-project?rev=134936&view=rev Log: Revert r134921, 134917, 134908 and 134907. They're causing failures in multiple buildbots. Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp llvm/trunk/utils/TableGen/CallingConvEmitter.cpp llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.cpp llvm/trunk/utils/TableGen/CodeEmitterGen.h llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h llvm/trunk/utils/TableGen/CodeGenInstruction.cpp llvm/trunk/utils/TableGen/CodeGenInstruction.h llvm/trunk/utils/TableGen/CodeGenRegisters.cpp llvm/trunk/utils/TableGen/CodeGenTarget.cpp llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp llvm/trunk/utils/TableGen/FastISelEmitter.cpp llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp llvm/trunk/utils/TableGen/OptParserEmitter.cpp llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h llvm/trunk/utils/TableGen/Record.cpp llvm/trunk/utils/TableGen/Record.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp llvm/trunk/utils/TableGen/SetTheory.cpp llvm/trunk/utils/TableGen/SetTheory.h llvm/trunk/utils/TableGen/TGParser.cpp llvm/trunk/utils/TableGen/TGParser.h llvm/trunk/utils/TableGen/TableGen.cpp llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -114,7 +114,7 @@ /// byteFromBitsInit - Return the byte value from a BitsInit. /// Called from getByteField(). -static uint8_t byteFromBitsInit(const BitsInit &init) { +static uint8_t byteFromBitsInit(BitsInit &init) { int width = init.getNumBits(); assert(width <= 8 && "Field is too large for uint8_t!"); @@ -125,7 +125,7 @@ uint8_t ret = 0; for (index = 0; index < width; index++) { - if (static_cast(init.getBit(index))->getValue()) + if (static_cast(init.getBit(index))->getValue()) ret |= mask; mask <<= 1; @@ -135,12 +135,12 @@ } static uint8_t getByteField(const Record &def, const char *str) { - const BitsInit *bits = def.getValueAsBitsInit(str); + BitsInit *bits = def.getValueAsBitsInit(str); return byteFromBitsInit(*bits); } -static const BitsInit &getBitsField(const Record &def, const char *str) { - const BitsInit *bits = def.getValueAsBitsInit(str); +static BitsInit &getBitsField(const Record &def, const char *str) { + BitsInit *bits = def.getValueAsBitsInit(str); return *bits; } @@ -183,15 +183,15 @@ static int Value(bit_value_t V) { return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); } -static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { - if (const BitInit *bit = dynamic_cast(bits.getBit(index))) +static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { + if (BitInit *bit = dynamic_cast(bits.getBit(index))) return bit->getValue() ? BIT_TRUE : BIT_FALSE; // The bit is uninitialized. return BIT_UNSET; } // Prints the bit value for each position. -static void dumpBits(raw_ostream &o, const BitsInit &bits) { +static void dumpBits(raw_ostream &o, BitsInit &bits) { unsigned index; for (index = bits.getNumBits(); index > 0; index--) { @@ -424,8 +424,7 @@ if (AllInstructions[Opcode]->isPseudo) return; - const BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, - "Inst"); + BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); for (unsigned i = 0; i < BIT_WIDTH; ++i) Insn[i] = bitFromBits(Bits, i); @@ -1559,7 +1558,7 @@ const StringRef Name = Def.getName(); uint8_t Form = getByteField(Def, "Form"); - const BitsInit &Bits = getBitsField(Def, "Inst"); + BitsInit &Bits = getBitsField(Def, "Inst"); // If all the bit positions are not specified; do not decode this instruction. // We are bound to fail! For proper disassembly, the well-known encoding bits Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -869,7 +869,7 @@ int SubOpIdx) { Record *Rec = OI.Rec; if (SubOpIdx != -1) - Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); + Rec = dynamic_cast(OI.MIOperandInfo->getArg(SubOpIdx))->getDef(); if (Rec->isSubClassOf("RegisterOperand")) { // RegisterOperand may have an associated ParserMatchClass. If it does, @@ -879,7 +879,7 @@ throw "Record `" + Rec->getName() + "' does not have a ParserMatchClass!\n"; - if (const DefInit *DI= dynamic_cast(R->getValue())) { + if (DefInit *DI= dynamic_cast(R->getValue())) { Record *MatchClass = DI->getDef(); if (ClassInfo *CI = AsmOperandClasses[MatchClass]) return CI; @@ -1046,9 +1046,9 @@ ClassInfo *CI = AsmOperandClasses[*it]; CI->Kind = ClassInfo::UserClass0 + Index; - const ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); + ListInit *Supers = (*it)->getValueAsListInit("SuperClasses"); for (unsigned i = 0, e = Supers->getSize(); i != e; ++i) { - const DefInit *DI = dynamic_cast(Supers->getElement(i)); + DefInit *DI = dynamic_cast(Supers->getElement(i)); if (!DI) { PrintError((*it)->getLoc(), "Invalid super class reference!"); continue; @@ -1065,28 +1065,28 @@ CI->ValueName = (*it)->getName(); // Get or construct the predicate method name. - const Init *PMName = (*it)->getValueInit("PredicateMethod"); - if (const StringInit *SI = dynamic_cast(PMName)) { + Init *PMName = (*it)->getValueInit("PredicateMethod"); + if (StringInit *SI = dynamic_cast(PMName)) { CI->PredicateMethod = SI->getValue(); } else { - assert(dynamic_cast(PMName) && + assert(dynamic_cast(PMName) && "Unexpected PredicateMethod field!"); CI->PredicateMethod = "is" + CI->ClassName; } // Get or construct the render method name. - const Init *RMName = (*it)->getValueInit("RenderMethod"); - if (const StringInit *SI = dynamic_cast(RMName)) { + Init *RMName = (*it)->getValueInit("RenderMethod"); + if (StringInit *SI = dynamic_cast(RMName)) { CI->RenderMethod = SI->getValue(); } else { - assert(dynamic_cast(RMName) && + assert(dynamic_cast(RMName) && "Unexpected RenderMethod field!"); CI->RenderMethod = "add" + CI->ClassName + "Operands"; } // Get the parse method name or leave it as empty. - const Init *PRMName = (*it)->getValueInit("ParserMethod"); - if (const StringInit *SI = dynamic_cast(PRMName)) + Init *PRMName = (*it)->getValueInit("ParserMethod"); + if (StringInit *SI = dynamic_cast(PRMName)) CI->ParserMethod = SI->getValue(); AsmOperandClasses[*it] = CI; Modified: llvm/trunk/utils/TableGen/CallingConvEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CallingConvEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CallingConvEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/CallingConvEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -40,7 +40,7 @@ void CallingConvEmitter::EmitCallingConv(Record *CC, raw_ostream &O) { - const ListInit *CCActions = CC->getValueAsListInit("Actions"); + ListInit *CCActions = CC->getValueAsListInit("Actions"); Counter = 0; O << "\n\nstatic bool " << CC->getName() @@ -67,7 +67,7 @@ O << IndentStr << "if ("; if (Action->isSubClassOf("CCIfType")) { - const ListInit *VTs = Action->getValueAsListInit("VTs"); + ListInit *VTs = Action->getValueAsListInit("VTs"); for (unsigned i = 0, e = VTs->getSize(); i != e; ++i) { Record *VT = VTs->getElementAsRecord(i); if (i != 0) O << " ||\n " << IndentStr; @@ -91,7 +91,7 @@ << "(ValNo, ValVT, LocVT, LocInfo, ArgFlags, State))\n" << IndentStr << " return false;\n"; } else if (Action->isSubClassOf("CCAssignToReg")) { - const ListInit *RegList = Action->getValueAsListInit("RegList"); + ListInit *RegList = Action->getValueAsListInit("RegList"); if (RegList->getSize() == 1) { O << IndentStr << "if (unsigned Reg = State.AllocateReg("; O << getQualifiedName(RegList->getElementAsRecord(0)) << ")) {\n"; @@ -112,8 +112,8 @@ O << IndentStr << " return false;\n"; O << IndentStr << "}\n"; } else if (Action->isSubClassOf("CCAssignToRegWithShadow")) { - const ListInit *RegList = Action->getValueAsListInit("RegList"); - const ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); + ListInit *RegList = Action->getValueAsListInit("RegList"); + ListInit *ShadowRegList = Action->getValueAsListInit("ShadowRegList"); if (ShadowRegList->getSize() >0 && ShadowRegList->getSize() != RegList->getSize()) throw "Invalid length of list of shadowed registers"; Modified: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -21,19 +21,17 @@ static const std::vector getValueAsListOfStrings(Record &R, StringRef FieldName) { - const ListInit *List = R.getValueAsListInit(FieldName); + ListInit *List = R.getValueAsListInit(FieldName); assert (List && "Got a null ListInit"); std::vector Strings; Strings.reserve(List->getSize()); - for (ListInit::const_iterator i = List->begin(), e = List->end(); - i != e; - ++i) { + for (ListInit::iterator i = List->begin(), e = List->end(); i != e; ++i) { assert(*i && "Got a null element in a ListInit"); - if (const StringInit *S = dynamic_cast(*i)) + if (StringInit *S = dynamic_cast(*i)) Strings.push_back(S->getValue()); - else if (const CodeInit *C = dynamic_cast(*i)) + else if (CodeInit *C = dynamic_cast(*i)) Strings.push_back(C->getValue()); else assert(false && "Got a non-string, non-code element in a ListInit"); Modified: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -74,8 +74,7 @@ static std::string getDiagnosticCategory(const Record *R, DiagGroupParentMap &DiagGroupParents) { // If the diagnostic is in a group, and that group has a category, use it. - if (const DefInit *Group = - dynamic_cast(R->getValueInit("Group"))) { + if (DefInit *Group = dynamic_cast(R->getValueInit("Group"))) { // Check the diagnostic's diag group for a category. std::string CatName = getCategoryFromDiagGroup(Group->getDef(), DiagGroupParents); @@ -160,8 +159,7 @@ OS.write_escaped(R.getValueAsString("Text")) << '"'; // Warning associated with the diagnostic. - if (const DefInit *DI = - dynamic_cast(R.getValueInit("Group"))) { + if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) { OS << ", \""; OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; } else { @@ -227,7 +225,7 @@ Records.getAllDerivedDefinitions("Diagnostic"); for (unsigned i = 0, e = Diags.size(); i != e; ++i) { const Record *R = Diags[i]; - const DefInit *DI = dynamic_cast(R->getValueInit("Group")); + DefInit *DI = dynamic_cast(R->getValueInit("Group")); if (DI == 0) continue; std::string GroupName = DI->getDef()->getValueAsString("GroupName"); DiagsInGroup[GroupName].DiagsInGroup.push_back(R); Modified: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -28,8 +28,7 @@ if (R.getValueAsBit("Hidden")) return true; // Not declared as hidden, check the parent package if it is hidden. - if (const DefInit *DI = - dynamic_cast(R.getValueInit("ParentPackage"))) + if (DefInit *DI = dynamic_cast(R.getValueInit("ParentPackage"))) return isHidden(*DI->getDef()); return false; @@ -43,8 +42,7 @@ static std::string getParentPackageFullName(const Record *R) { std::string name; - if (const DefInit *DI = - dynamic_cast(R->getValueInit("ParentPackage"))) + if (DefInit *DI = dynamic_cast(R->getValueInit("ParentPackage"))) name = getPackageFullName(DI->getDef()); return name; } @@ -65,8 +63,8 @@ } static std::string getStringValue(const Record &R, StringRef field) { - if (const StringInit * - SI = dynamic_cast(R.getValueInit(field))) + if (StringInit * + SI = dynamic_cast(R.getValueInit(field))) return SI->getValue(); return std::string(); } @@ -131,8 +129,8 @@ for (unsigned i = 0, e = checkers.size(); i != e; ++i) { Record *R = checkers[i]; Record *package = 0; - if (const DefInit * - DI = dynamic_cast(R->getValueInit("ParentPackage"))) + if (DefInit * + DI = dynamic_cast(R->getValueInit("ParentPackage"))) package = DI->getDef(); if (!isCheckerNamed(R) && !package) throw "Checker '" + R->getName() + "' is neither named, nor in a package!"; @@ -151,23 +149,21 @@ Record *currR = isCheckerNamed(R) ? R : package; // Insert the checker and its parent packages into the subgroups set of // the corresponding parent package. - while (const DefInit *DI = - dynamic_cast(currR->getValueInit("ParentPackage"))) { + while (DefInit *DI + = dynamic_cast(currR->getValueInit("ParentPackage"))) { Record *parentPackage = DI->getDef(); recordGroupMap[parentPackage]->SubGroups.insert(currR); currR = parentPackage; } // Insert the checker into the set of its group. - if (const DefInit *DI = - dynamic_cast(R->getValueInit("Group"))) + if (DefInit *DI = dynamic_cast(R->getValueInit("Group"))) recordGroupMap[DI->getDef()]->Checkers.insert(R); } // If a package is in group, add all its checkers and its sub-packages // checkers into the group. for (unsigned i = 0, e = packages.size(); i != e; ++i) - if (const DefInit *DI = - dynamic_cast(packages[i]->getValueInit("Group"))) + if (DefInit *DI = dynamic_cast(packages[i]->getValueInit("Group"))) addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap); typedef std::map SortedRecords; @@ -208,8 +204,7 @@ OS << "PACKAGE(" << "\""; OS.write_escaped(getPackageFullName(&R)) << "\", "; // Group index - if (const DefInit *DI = - dynamic_cast(R.getValueInit("Group"))) + if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << groupToSortIndex[DI->getDef()] << ", "; else OS << "-1, "; @@ -237,8 +232,7 @@ OS << "\""; OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; // Group index - if (const DefInit *DI = - dynamic_cast(R.getValueInit("Group"))) + if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << groupToSortIndex[DI->getDef()] << ", "; else OS << "-1, "; Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.cpp (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.cpp Mon Jul 11 18:06:52 2011 @@ -38,25 +38,21 @@ R->getValueAsBit("isPseudo")) continue; - const BitsInit *BI = R->getValueAsBitsInit("Inst"); + BitsInit *BI = R->getValueAsBitsInit("Inst"); unsigned numBits = BI->getNumBits(); - - SmallVector NewBits(numBits); - + BitsInit *NewBI = new BitsInit(numBits); for (unsigned bit = 0, end = numBits / 2; bit != end; ++bit) { unsigned bitSwapIdx = numBits - bit - 1; - const Init *OrigBit = BI->getBit(bit); - const Init *BitSwap = BI->getBit(bitSwapIdx); - NewBits[bit] = BitSwap; - NewBits[bitSwapIdx] = OrigBit; + Init *OrigBit = BI->getBit(bit); + Init *BitSwap = BI->getBit(bitSwapIdx); + NewBI->setBit(bit, BitSwap); + NewBI->setBit(bitSwapIdx, OrigBit); } if (numBits % 2) { unsigned middle = (numBits + 1) / 2; - NewBits[middle] = BI->getBit(middle); + NewBI->setBit(middle, BI->getBit(middle)); } - - const BitsInit *NewBI = BitsInit::get(NewBits.begin(), NewBits.end()); // Update the bits in reversed order so that emitInstrOpBits will get the // correct endianness. @@ -67,14 +63,12 @@ // If the VarBitInit at position 'bit' matches the specified variable then // return the variable bit position. Otherwise return -1. int CodeEmitterGen::getVariableBit(const std::string &VarName, - const BitsInit *BI, int bit) { - if (const VarBitInit *VBI = - dynamic_cast(BI->getBit(bit))) { - if (const VarInit *VI = dynamic_cast(VBI->getVariable())) + BitsInit *BI, int bit) { + if (VarBitInit *VBI = dynamic_cast(BI->getBit(bit))) { + if (VarInit *VI = dynamic_cast(VBI->getVariable())) if (VI->getName() == VarName) return VBI->getBitNum(); - } else if (const VarInit *VI = - dynamic_cast(BI->getBit(bit))) { + } else if (VarInit *VI = dynamic_cast(BI->getBit(bit))) { if (VI->getName() == VarName) return 0; } @@ -83,8 +77,8 @@ } void CodeEmitterGen:: -AddCodeToMergeInOperand(Record *R, const BitsInit *BI, - const std::string &VarName, unsigned &NumberedOp, +AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, + unsigned &NumberedOp, std::string &Case, CodeGenTarget &Target) { CodeGenInstruction &CGI = Target.getInstruction(R); @@ -187,7 +181,7 @@ CodeGenTarget &Target) { std::string Case; - const BitsInit *BI = R->getValueAsBitsInit("Inst"); + BitsInit *BI = R->getValueAsBitsInit("Inst"); const std::vector &Vals = R->getValues(); unsigned NumberedOp = 0; @@ -244,12 +238,12 @@ continue; } - const BitsInit *BI = R->getValueAsBitsInit("Inst"); + BitsInit *BI = R->getValueAsBitsInit("Inst"); // Start by filling in fixed values. unsigned Value = 0; for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) { - if (const BitInit *B = dynamic_cast(BI->getBit(e-i-1))) + if (BitInit *B = dynamic_cast(BI->getBit(e-i-1))) Value |= B->getValue() << (e-i-1); } o << " " << Value << "U," << '\t' << "// " << R->getName() << "\n"; Modified: llvm/trunk/utils/TableGen/CodeEmitterGen.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeEmitterGen.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeEmitterGen.h (original) +++ llvm/trunk/utils/TableGen/CodeEmitterGen.h Mon Jul 11 18:06:52 2011 @@ -35,11 +35,11 @@ void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace); void emitGetValueBit(raw_ostream &o, const std::string &Namespace); void reverseBits(std::vector &Insts); - int getVariableBit(const std::string &VarName, const BitsInit *BI, int bit); + int getVariableBit(const std::string &VarName, BitsInit *BI, int bit); std::string getInstructionCase(Record *R, CodeGenTarget &Target); void - AddCodeToMergeInOperand(Record *R, const BitsInit *BI, - const std::string &VarName, unsigned &NumberedOp, + AddCodeToMergeInOperand(Record *R, BitsInit *BI, const std::string &VarName, + unsigned &NumberedOp, std::string &Case, CodeGenTarget &Target); }; Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Mon Jul 11 18:06:52 2011 @@ -583,7 +583,7 @@ static void FindDepVarsOf(TreePatternNode *N, DepVarMap &DepMap) { if (N->isLeaf()) { - if (dynamic_cast(N->getLeafValue()) != NULL) + if (dynamic_cast(N->getLeafValue()) != NULL) DepMap[N->getName()]++; } else { for (size_t i = 0, e = N->getNumChildren(); i != e; ++i) @@ -692,7 +692,7 @@ unsigned Size = 3; // The node itself. // If the root node is a ConstantSDNode, increases its size. // e.g. (set R32:$dst, 0). - if (P->isLeaf() && dynamic_cast(P->getLeafValue())) + if (P->isLeaf() && dynamic_cast(P->getLeafValue())) Size += 2; // FIXME: This is a hack to statically increase the priority of patterns @@ -716,7 +716,7 @@ Child->getType(0) != MVT::Other) Size += getPatternSize(Child, CGP); else if (Child->isLeaf()) { - if (dynamic_cast(Child->getLeafValue())) + if (dynamic_cast(Child->getLeafValue())) Size += 5; // Matches a ConstantSDNode (+3) and a specific value (+2). else if (Child->getComplexPatternInfo(CGP)) Size += getPatternSize(Child, CGP); @@ -742,8 +742,7 @@ std::string PatternToMatch::getPredicateCheck() const { std::string PredicateCheck; for (unsigned i = 0, e = Predicates->getSize(); i != e; ++i) { - if (const DefInit *Pred = - dynamic_cast(Predicates->getElement(i))) { + if (DefInit *Pred = dynamic_cast(Predicates->getElement(i))) { Record *Def = Pred->getDef(); if (!Def->isSubClassOf("Predicate")) { #ifndef NDEBUG @@ -867,13 +866,12 @@ // The NodeToApply must be a leaf node that is a VT. OtherOperandNum must // have an integer type that is smaller than the VT. if (!NodeToApply->isLeaf() || - !dynamic_cast(NodeToApply->getLeafValue()) || - !static_cast(NodeToApply->getLeafValue())->getDef() + !dynamic_cast(NodeToApply->getLeafValue()) || + !static_cast(NodeToApply->getLeafValue())->getDef() ->isSubClassOf("ValueType")) TP.error(N->getOperator()->getName() + " expects a VT operand!"); MVT::SimpleValueType VT = - getValueType(static_cast(NodeToApply->getLeafValue()) - ->getDef()); + getValueType(static_cast(NodeToApply->getLeafValue())->getDef()); EEVT::TypeSet TypeListTmp(VT, TP); @@ -1023,10 +1021,10 @@ return PFRec->getOnlyTree()->getNumTypes(); // Get the result tree. - const DagInit *Tree = Operator->getValueAsDag("Fragment"); + DagInit *Tree = Operator->getValueAsDag("Fragment"); Record *Op = 0; - if (Tree && dynamic_cast(Tree->getOperator())) - Op = dynamic_cast(Tree->getOperator())->getDef(); + if (Tree && dynamic_cast(Tree->getOperator())) + Op = dynamic_cast(Tree->getOperator())->getDef(); assert(Op && "Invalid Fragment"); return GetNumNodeResults(Op, CDP); } @@ -1100,8 +1098,8 @@ return false; if (isLeaf()) { - if (const DefInit *DI = dynamic_cast(getLeafValue())) { - if (const DefInit *NDI = dynamic_cast(N->getLeafValue())) { + if (DefInit *DI = dynamic_cast(getLeafValue())) { + if (DefInit *NDI = dynamic_cast(N->getLeafValue())) { return ((DI->getDef() == NDI->getDef()) && (DepVars.find(getName()) == DepVars.end() || getName() == N->getName())); @@ -1157,9 +1155,9 @@ for (unsigned i = 0, e = getNumChildren(); i != e; ++i) { TreePatternNode *Child = getChild(i); if (Child->isLeaf()) { - const Init *Val = Child->getLeafValue(); - if (dynamic_cast(Val) && - static_cast(Val)->getDef()->getName() == "node") { + Init *Val = Child->getLeafValue(); + if (dynamic_cast(Val) && + static_cast(Val)->getDef()->getName() == "node") { // We found a use of a formal argument, replace it with its value. TreePatternNode *NewChild = ArgMap[Child->getName()]; assert(NewChild && "Couldn't find formal argument!"); @@ -1321,7 +1319,7 @@ return 0; unsigned IID = - dynamic_cast(getChild(0)->getLeafValue())->getValue(); + dynamic_cast(getChild(0)->getLeafValue())->getValue(); return &CDP.getIntrinsicInfo(IID); } @@ -1331,7 +1329,7 @@ TreePatternNode::getComplexPatternInfo(const CodeGenDAGPatterns &CGP) const { if (!isLeaf()) return 0; - const DefInit *DI = dynamic_cast(getLeafValue()); + DefInit *DI = dynamic_cast(getLeafValue()); if (DI && DI->getDef()->isSubClassOf("ComplexPattern")) return &CGP.getComplexPattern(DI->getDef()); return 0; @@ -1384,7 +1382,7 @@ bool TreePatternNode::ApplyTypeConstraints(TreePattern &TP, bool NotRegisters) { CodeGenDAGPatterns &CDP = TP.getDAGPatterns(); if (isLeaf()) { - if (const DefInit *DI = dynamic_cast(getLeafValue())) { + if (DefInit *DI = dynamic_cast(getLeafValue())) { // If it's a regclass or something else known, include the type. bool MadeChange = false; for (unsigned i = 0, e = Types.size(); i != e; ++i) @@ -1393,7 +1391,7 @@ return MadeChange; } - if (const IntInit *II = dynamic_cast(getLeafValue())) { + if (IntInit *II = dynamic_cast(getLeafValue())) { assert(Types.size() == 1 && "Invalid IntInit"); // Int inits are always integers. :) @@ -1653,7 +1651,7 @@ static bool OnlyOnRHSOfCommutative(TreePatternNode *N) { if (!N->isLeaf() && N->getOperator()->getName() == "imm") return true; - if (N->isLeaf() && dynamic_cast(N->getLeafValue())) + if (N->isLeaf() && dynamic_cast(N->getLeafValue())) return true; return false; } @@ -1703,14 +1701,14 @@ // TreePattern implementation // -TreePattern::TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, +TreePattern::TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ isInputPattern = isInput; for (unsigned i = 0, e = RawPat->getSize(); i != e; ++i) Trees.push_back(ParseTreePattern(RawPat->getElement(i), "")); } -TreePattern::TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, +TreePattern::TreePattern(Record *TheRec, DagInit *Pat, bool isInput, CodeGenDAGPatterns &cdp) : TheRecord(TheRec), CDP(cdp){ isInputPattern = isInput; Trees.push_back(ParseTreePattern(Pat, "")); @@ -1741,17 +1739,16 @@ } -TreePatternNode *TreePattern::ParseTreePattern(const Init *TheInit, - StringRef OpName){ - if (const DefInit *DI = dynamic_cast(TheInit)) { +TreePatternNode *TreePattern::ParseTreePattern(Init *TheInit, StringRef OpName){ + if (DefInit *DI = dynamic_cast(TheInit)) { Record *R = DI->getDef(); // Direct reference to a leaf DagNode or PatFrag? Turn it into a // TreePatternNode of its own. For example: /// (foo GPR, imm) -> (foo GPR, (imm)) if (R->isSubClassOf("SDNode") || R->isSubClassOf("PatFrag")) - return ParseTreePattern(DagInit::get(DI, "", - std::vector >()), + return ParseTreePattern(new DagInit(DI, "", + std::vector >()), OpName); // Input argument? @@ -1766,26 +1763,26 @@ return Res; } - if (const IntInit *II = dynamic_cast(TheInit)) { + if (IntInit *II = dynamic_cast(TheInit)) { if (!OpName.empty()) error("Constant int argument should not have a name!"); return new TreePatternNode(II, 1); } - if (const BitsInit *BI = dynamic_cast(TheInit)) { + if (BitsInit *BI = dynamic_cast(TheInit)) { // Turn this into an IntInit. - const Init *II = BI->convertInitializerTo(new IntRecTy()); - if (II == 0 || !dynamic_cast(II)) + Init *II = BI->convertInitializerTo(new IntRecTy()); + if (II == 0 || !dynamic_cast(II)) error("Bits value must be constants!"); return ParseTreePattern(II, OpName); } - const DagInit *Dag = dynamic_cast(TheInit); + DagInit *Dag = dynamic_cast(TheInit); if (!Dag) { TheInit->dump(); error("Pattern has unexpected init kind!"); } - const DefInit *OpDef = dynamic_cast(Dag->getOperator()); + DefInit *OpDef = dynamic_cast(Dag->getOperator()); if (!OpDef) error("Pattern has unexpected operator type!"); Record *Operator = OpDef->getDef(); @@ -1863,7 +1860,7 @@ else // Otherwise, no chain. Operator = getDAGPatterns().get_intrinsic_wo_chain_sdnode(); - TreePatternNode *IIDNode = new TreePatternNode(IntInit::get(IID), 1); + TreePatternNode *IIDNode = new TreePatternNode(new IntInit(IID), 1); Children.insert(Children.begin(), IIDNode); } @@ -1950,8 +1947,7 @@ // us to match things like: // def : Pat<(v1i64 (bitconvert(v2i32 DPR:$src))), (v1i64 DPR:$src)>; if (Nodes[i] == Trees[0] && Nodes[i]->isLeaf()) { - const DefInit *DI = - dynamic_cast(Nodes[i]->getLeafValue()); + DefInit *DI = dynamic_cast(Nodes[i]->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) continue; @@ -2100,7 +2096,7 @@ // First step, parse all of the fragments. for (unsigned i = 0, e = Fragments.size(); i != e; ++i) { - const DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); + DagInit *Tree = Fragments[i]->getValueAsDag("Fragment"); TreePattern *P = new TreePattern(Fragments[i], Tree, true, *this); PatternFragments[Fragments[i]] = P; @@ -2112,8 +2108,8 @@ P->error("Cannot have unnamed 'node' values in pattern fragment!"); // Parse the operands list. - const DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); - const DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); + DagInit *OpsList = Fragments[i]->getValueAsDag("Operands"); + DefInit *OpsOp = dynamic_cast(OpsList->getOperator()); // Special cases: ops == outs == ins. Different names are used to // improve readability. if (!OpsOp || @@ -2125,8 +2121,8 @@ // Copy over the arguments. Args.clear(); for (unsigned j = 0, e = OpsList->getNumArgs(); j != e; ++j) { - if (!dynamic_cast(OpsList->getArg(j)) || - static_cast(OpsList->getArg(j))-> + if (!dynamic_cast(OpsList->getArg(j)) || + static_cast(OpsList->getArg(j))-> getDef()->getName() != "node") P->error("Operands list should all be 'node' values."); if (OpsList->getArgName(j).empty()) @@ -2184,19 +2180,19 @@ // Find some SDNode. assert(!SDNodes.empty() && "No SDNodes parsed?"); - const Init *SomeSDNode = DefInit::get(SDNodes.begin()->first); + Init *SomeSDNode = new DefInit(SDNodes.begin()->first); for (unsigned iter = 0; iter != 2; ++iter) { for (unsigned i = 0, e = DefaultOps[iter].size(); i != e; ++i) { - const DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); + DagInit *DefaultInfo = DefaultOps[iter][i]->getValueAsDag("DefaultOps"); // Clone the DefaultInfo dag node, changing the operator from 'ops' to // SomeSDnode so that we can parse this. - std::vector > Ops; + std::vector > Ops; for (unsigned op = 0, e = DefaultInfo->getNumArgs(); op != e; ++op) Ops.push_back(std::make_pair(DefaultInfo->getArg(op), DefaultInfo->getArgName(op))); - const DagInit *DI = DagInit::get(SomeSDNode, "", Ops); + DagInit *DI = new DagInit(SomeSDNode, "", Ops); // Create a TreePattern to parse this. TreePattern P(DefaultOps[iter][i], DI, false, *this); @@ -2235,7 +2231,7 @@ // No name -> not interesting. if (Pat->getName().empty()) { if (Pat->isLeaf()) { - const DefInit *DI = dynamic_cast(Pat->getLeafValue()); + DefInit *DI = dynamic_cast(Pat->getLeafValue()); if (DI && (DI->getDef()->isSubClassOf("RegisterClass") || DI->getDef()->isSubClassOf("RegisterOperand"))) I->error("Input " + DI->getDef()->getName() + " must be named!"); @@ -2245,7 +2241,7 @@ Record *Rec; if (Pat->isLeaf()) { - const DefInit *DI = dynamic_cast(Pat->getLeafValue()); + DefInit *DI = dynamic_cast(Pat->getLeafValue()); if (!DI) I->error("Input $" + Pat->getName() + " must be an identifier!"); Rec = DI->getDef(); } else { @@ -2263,7 +2259,7 @@ } Record *SlotRec; if (Slot->isLeaf()) { - SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); + SlotRec = dynamic_cast(Slot->getLeafValue())->getDef(); } else { assert(Slot->getNumChildren() == 0 && "can't be a use with children!"); SlotRec = Slot->getOperator(); @@ -2298,7 +2294,7 @@ if (!Dest->isLeaf()) I->error("implicitly defined value should be a register!"); - const DefInit *Val = dynamic_cast(Dest->getLeafValue()); + DefInit *Val = dynamic_cast(Dest->getLeafValue()); if (!Val || !Val->getDef()->isSubClassOf("Register")) I->error("implicitly defined value should be a register!"); InstImpResults.push_back(Val->getDef()); @@ -2339,7 +2335,7 @@ if (!Dest->isLeaf()) I->error("set destination should be a register!"); - const DefInit *Val = dynamic_cast(Dest->getLeafValue()); + DefInit *Val = dynamic_cast(Dest->getLeafValue()); if (!Val) I->error("set destination should be a register!"); @@ -2405,7 +2401,7 @@ return false; const TreePatternNode *N0 = N->getChild(0); - if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) + if (!N0->isLeaf() || !dynamic_cast(N0->getLeafValue())) return false; const TreePatternNode *N1 = N->getChild(1); @@ -2422,7 +2418,7 @@ void AnalyzeNode(const TreePatternNode *N) { if (N->isLeaf()) { - if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { + if (DefInit *DI = dynamic_cast(N->getLeafValue())) { Record *LeafRec = DI->getDef(); // Handle ComplexPattern leaves. if (LeafRec->isSubClassOf("ComplexPattern")) { @@ -2529,9 +2525,9 @@ std::vector Instrs = Records.getAllDerivedDefinitions("Instruction"); for (unsigned i = 0, e = Instrs.size(); i != e; ++i) { - const ListInit *LI = 0; + ListInit *LI = 0; - if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) + if (dynamic_cast(Instrs[i]->getValueInit("Pattern"))) LI = Instrs[i]->getValueAsListInit("Pattern"); // If there is no pattern, only collect minimal information about the @@ -2623,7 +2619,7 @@ if (i == 0) Res0Node = RNode; - Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); + Record *R = dynamic_cast(RNode->getLeafValue())->getDef(); if (R == 0) I->error("Operand $" + OpName + " should be a set destination: all " "outputs must occur before inputs in operand list!"); @@ -2668,8 +2664,8 @@ InstInputsCheck.erase(OpName); // It occurred, remove from map. if (InVal->isLeaf() && - dynamic_cast(InVal->getLeafValue())) { - Record *InRec = static_cast(InVal->getLeafValue())->getDef(); + dynamic_cast(InVal->getLeafValue())) { + Record *InRec = static_cast(InVal->getLeafValue())->getDef(); if (Op.Rec != InRec && !InRec->isSubClassOf("ComplexPattern")) I->error("Operand $" + OpName + "'s register class disagrees" " between the operand and pattern"); @@ -2869,13 +2865,13 @@ for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { Record *CurPattern = Patterns[i]; - const DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); + DagInit *Tree = CurPattern->getValueAsDag("PatternToMatch"); TreePattern *Pattern = new TreePattern(CurPattern, Tree, true, *this); // Inline pattern fragments into it. Pattern->InlinePatternFragments(); - const ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); + ListInit *LI = CurPattern->getValueAsListInit("ResultInstrs"); if (LI->getSize() == 0) continue; // no pattern. // Parse the instruction. @@ -3187,8 +3183,7 @@ for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i) { TreePatternNode *Child = N->getChild(i); if (Child->isLeaf()) - if (const DefInit *DI = - dynamic_cast(Child->getLeafValue())) { + if (DefInit *DI = dynamic_cast(Child->getLeafValue())) { Record *RR = DI->getDef(); if (RR->isSubClassOf("Register")) continue; Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original) +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Mon Jul 11 18:06:52 2011 @@ -26,7 +26,7 @@ namespace llvm { class Record; - class Init; + struct Init; class ListInit; class DagInit; class SDNodeInfo; @@ -306,7 +306,7 @@ /// Val - The init value (e.g. the "GPRC" record, or "7") for a leaf. /// - const Init *Val; + Init *Val; /// Name - The name given to this node with the :$foo notation. /// @@ -327,7 +327,7 @@ : Operator(Op), Val(0), TransformFn(0), Children(Ch) { Types.resize(NumResults); } - TreePatternNode(const Init *val, unsigned NumResults) // leaf ctor + TreePatternNode(Init *val, unsigned NumResults) // leaf ctor : Operator(0), Val(val), TransformFn(0) { Types.resize(NumResults); } @@ -358,7 +358,7 @@ return Types[ResNo].isDynamicallyResolved(); } - const Init *getLeafValue() const { assert(isLeaf()); return Val; } + Init *getLeafValue() const { assert(isLeaf()); return Val; } Record *getOperator() const { assert(!isLeaf()); return Operator; } unsigned getNumChildren() const { return Children.size(); } @@ -517,9 +517,9 @@ /// TreePattern constructor - Parse the specified DagInits into the /// current record. - TreePattern(Record *TheRec, const ListInit *RawPat, bool isInput, + TreePattern(Record *TheRec, ListInit *RawPat, bool isInput, CodeGenDAGPatterns &ise); - TreePattern(Record *TheRec, const DagInit *Pat, bool isInput, + TreePattern(Record *TheRec, DagInit *Pat, bool isInput, CodeGenDAGPatterns &ise); TreePattern(Record *TheRec, TreePatternNode *Pat, bool isInput, CodeGenDAGPatterns &ise); @@ -576,7 +576,7 @@ void dump() const; private: - TreePatternNode *ParseTreePattern(const Init *DI, StringRef OpName); + TreePatternNode *ParseTreePattern(Init *DI, StringRef OpName); void ComputeNamedNodes(); void ComputeNamedNodes(TreePatternNode *N); }; @@ -631,7 +631,7 @@ /// processed to produce isel. class PatternToMatch { public: - PatternToMatch(Record *srcrecord, const ListInit *preds, + PatternToMatch(Record *srcrecord, ListInit *preds, TreePatternNode *src, TreePatternNode *dst, const std::vector &dstregs, unsigned complexity, unsigned uid) @@ -639,7 +639,7 @@ Dstregs(dstregs), AddedComplexity(complexity), ID(uid) {} Record *SrcRecord; // Originating Record for the pattern. - const ListInit *Predicates; // Top level predicate conditions to match. + ListInit *Predicates; // Top level predicate conditions to match. TreePatternNode *SrcPattern; // Source pattern to match. TreePatternNode *DstPattern; // Resulting pattern. std::vector Dstregs; // Physical register defs being matched. @@ -647,7 +647,7 @@ unsigned ID; // Unique ID for the record. Record *getSrcRecord() const { return SrcRecord; } - const ListInit *getPredicates() const { return Predicates; } + ListInit *getPredicates() const { return Predicates; } TreePatternNode *getSrcPattern() const { return SrcPattern; } TreePatternNode *getDstPattern() const { return DstPattern; } const std::vector &getDstRegs() const { return Dstregs; } Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenInstruction.cpp Mon Jul 11 18:06:52 2011 @@ -30,10 +30,9 @@ hasOptionalDef = false; isVariadic = false; - const DagInit *OutDI = R->getValueAsDag("OutOperandList"); + DagInit *OutDI = R->getValueAsDag("OutOperandList"); - if (const DefInit *Init = - dynamic_cast(OutDI->getOperator())) { + if (DefInit *Init = dynamic_cast(OutDI->getOperator())) { if (Init->getDef()->getName() != "outs") throw R->getName() + ": invalid def name for output list: use 'outs'"; } else @@ -41,8 +40,8 @@ NumDefs = OutDI->getNumArgs(); - const DagInit *InDI = R->getValueAsDag("InOperandList"); - if (const DefInit *Init = dynamic_cast(InDI->getOperator())) { + DagInit *InDI = R->getValueAsDag("InOperandList"); + if (DefInit *Init = dynamic_cast(InDI->getOperator())) { if (Init->getDef()->getName() != "ins") throw R->getName() + ": invalid def name for input list: use 'ins'"; } else @@ -51,7 +50,7 @@ unsigned MIOperandNo = 0; std::set OperandNames; for (unsigned i = 0, e = InDI->getNumArgs()+OutDI->getNumArgs(); i != e; ++i){ - const Init *ArgInit; + Init *ArgInit; std::string ArgName; if (i < NumDefs) { ArgInit = OutDI->getArg(i); @@ -61,7 +60,7 @@ ArgName = InDI->getArgName(i-NumDefs); } - const DefInit *Arg = dynamic_cast(ArgInit); + DefInit *Arg = dynamic_cast(ArgInit); if (!Arg) throw "Illegal operand for the '" + R->getName() + "' instruction!"; @@ -69,7 +68,7 @@ std::string PrintMethod = "printOperand"; std::string EncoderMethod; unsigned NumOps = 1; - const DagInit *MIOpInfo = 0; + DagInit *MIOpInfo = 0; if (Rec->isSubClassOf("RegisterOperand")) { PrintMethod = Rec->getValueAsString("PrintMethod"); } else if (Rec->isSubClassOf("Operand")) { @@ -79,8 +78,8 @@ MIOpInfo = Rec->getValueAsDag("MIOperandInfo"); // Verify that MIOpInfo has an 'ops' root value. - if (!dynamic_cast(MIOpInfo->getOperator()) || - dynamic_cast(MIOpInfo->getOperator()) + if (!dynamic_cast(MIOpInfo->getOperator()) || + dynamic_cast(MIOpInfo->getOperator()) ->getDef()->getName() != "ops") throw "Bad value for MIOperandInfo in operand '" + Rec->getName() + "'\n"; @@ -179,7 +178,7 @@ } // Find the suboperand number involved. - const DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; + DagInit *MIOpInfo = OperandList[OpIdx].MIOperandInfo; if (MIOpInfo == 0) throw TheDef->getName() + ": unknown suboperand name in '" + Op + "'"; @@ -401,13 +400,12 @@ /// constructor. It checks if an argument in an InstAlias pattern matches /// the corresponding operand of the instruction. It returns true on a /// successful match, with ResOp set to the result operand to be used. -bool CodeGenInstAlias::tryAliasOpMatch(const DagInit *Result, - unsigned AliasOpNo, +bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, Record *InstOpRec, bool hasSubOps, SMLoc Loc, CodeGenTarget &T, ResultOperand &ResOp) { - const Init *Arg = Result->getArg(AliasOpNo); - const DefInit *ADI = dynamic_cast(Arg); + Init *Arg = Result->getArg(AliasOpNo); + DefInit *ADI = dynamic_cast(Arg); if (ADI && ADI->getDef() == InstOpRec) { // If the operand is a record, it must have a name, and the record type @@ -453,7 +451,7 @@ return true; } - if (const IntInit *II = dynamic_cast(Arg)) { + if (IntInit *II = dynamic_cast(Arg)) { if (hasSubOps || !InstOpRec->isSubClassOf("Operand")) return false; // Integer arguments can't have names. @@ -472,7 +470,7 @@ Result = R->getValueAsDag("ResultInst"); // Verify that the root of the result is an instruction. - const DefInit *DI = dynamic_cast(Result->getOperator()); + DefInit *DI = dynamic_cast(Result->getOperator()); if (DI == 0 || !DI->getDef()->isSubClassOf("Instruction")) throw TGError(R->getLoc(), "result of inst alias should be an instruction"); @@ -482,7 +480,7 @@ // the same class. StringMap NameClass; for (unsigned i = 0, e = Result->getNumArgs(); i != e; ++i) { - const DefInit *ADI = dynamic_cast(Result->getArg(i)); + DefInit *ADI = dynamic_cast(Result->getArg(i)); if (!ADI || Result->getArgName(i).empty()) continue; // Verify we don't have something like: (someinst GR16:$foo, GR32:$foo) @@ -521,12 +519,11 @@ // If the argument did not match the instruction operand, and the operand // is composed of multiple suboperands, try matching the suboperands. if (NumSubOps > 1) { - const DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; + DagInit *MIOI = ResultInst->Operands[i].MIOperandInfo; for (unsigned SubOp = 0; SubOp != NumSubOps; ++SubOp) { if (AliasOpNo >= Result->getNumArgs()) throw TGError(R->getLoc(), "not enough arguments for instruction!"); - Record *SubRec = - dynamic_cast(MIOI->getArg(SubOp))->getDef(); + Record *SubRec = dynamic_cast(MIOI->getArg(SubOp))->getDef(); if (tryAliasOpMatch(Result, AliasOpNo, SubRec, false, R->getLoc(), T, ResOp)) { ResultOperands.push_back(ResOp); Modified: llvm/trunk/utils/TableGen/CodeGenInstruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenInstruction.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenInstruction.h (original) +++ llvm/trunk/utils/TableGen/CodeGenInstruction.h Mon Jul 11 18:06:52 2011 @@ -94,7 +94,7 @@ /// MIOperandInfo - Default MI operand type. Note an operand may be made /// up of multiple MI operands. - const DagInit *MIOperandInfo; + DagInit *MIOperandInfo; /// Constraint info for this operand. This operand can have pieces, so we /// track constraint info for each. @@ -102,7 +102,7 @@ OperandInfo(Record *R, const std::string &N, const std::string &PMN, const std::string &EMN, unsigned MION, unsigned MINO, - const DagInit *MIOI) + DagInit *MIOI) : Rec(R), Name(N), PrinterMethodName(PMN), EncoderMethodName(EMN), MIOperandNo(MION), MINumOperands(MINO), MIOperandInfo(MIOI) {} @@ -265,7 +265,7 @@ std::string AsmString; /// Result - The result instruction. - const DagInit *Result; + DagInit *Result; /// ResultInst - The instruction generated by the alias (decoded from /// Result). @@ -311,7 +311,7 @@ CodeGenInstAlias(Record *R, CodeGenTarget &T); - bool tryAliasOpMatch(const DagInit *Result, unsigned AliasOpNo, + bool tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo, Record *InstOpRec, bool hasSubOps, SMLoc Loc, CodeGenTarget &T, ResultOperand &ResOp); }; Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Mon Jul 11 18:06:52 2011 @@ -91,15 +91,14 @@ } // Process the composites. - const ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); + ListInit *Comps = TheDef->getValueAsListInit("CompositeIndices"); for (unsigned i = 0, e = Comps->size(); i != e; ++i) { - const DagInit *Pat = dynamic_cast(Comps->getElement(i)); + DagInit *Pat = dynamic_cast(Comps->getElement(i)); if (!Pat) throw TGError(TheDef->getLoc(), "Invalid dag '" + Comps->getElement(i)->getAsString() + "' in CompositeIndices"); - const DefInit *BaseIdxInit = - dynamic_cast(Pat->getOperator()); + DefInit *BaseIdxInit = dynamic_cast(Pat->getOperator()); if (!BaseIdxInit || !BaseIdxInit->getDef()->isSubClassOf("SubRegIndex")) throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + Pat->getAsString()); @@ -108,7 +107,7 @@ CodeGenRegister *R2 = this; for (DagInit::const_arg_iterator di = Pat->arg_begin(), de = Pat->arg_end(); di != de; ++di) { - const DefInit *IdxInit = dynamic_cast(*di); + DefInit *IdxInit = dynamic_cast(*di); if (!IdxInit || !IdxInit->getDef()->isSubClassOf("SubRegIndex")) throw TGError(TheDef->getLoc(), "Invalid SubClassIndex in " + Pat->getAsString()); @@ -164,7 +163,7 @@ void expand(SetTheory &ST, Record *Def, SetTheory::RecSet &Elts) { std::vector Indices = Def->getValueAsListOfDefs("SubRegIndices"); unsigned Dim = Indices.size(); - const ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); + ListInit *SubRegs = Def->getValueAsListInit("SubRegs"); if (Dim != SubRegs->getSize()) throw TGError(Def->getLoc(), "SubRegIndices and SubRegs size mismatch"); if (Dim < 2) @@ -184,19 +183,19 @@ // Precompute some types. Record *RegisterCl = Def->getRecords().getClass("Register"); RecTy *RegisterRecTy = new RecordRecTy(RegisterCl); - const StringInit *BlankName = StringInit::get(""); + StringInit *BlankName = new StringInit(""); // Zip them up. for (unsigned n = 0; n != Length; ++n) { std::string Name; Record *Proto = Lists[0][n]; - std::vector Tuple; + std::vector Tuple; unsigned CostPerUse = 0; for (unsigned i = 0; i != Dim; ++i) { Record *Reg = Lists[i][n]; if (i) Name += '_'; Name += Reg->getName(); - Tuple.push_back(DefInit::get(Reg)); + Tuple.push_back(new DefInit(Reg)); CostPerUse = std::max(CostPerUse, unsigned(Reg->getValueAsInt("CostPerUse"))); } @@ -217,7 +216,7 @@ // Replace the sub-register list with Tuple. if (RV.getName() == "SubRegs") - RV.setValue(ListInit::get(Tuple, RegisterRecTy)); + RV.setValue(new ListInit(Tuple, RegisterRecTy)); // Provide a blank AsmName. MC hacks are required anyway. if (RV.getName() == "AsmName") @@ -225,7 +224,7 @@ // CostPerUse is aggregated from all Tuple members. if (RV.getName() == "CostPerUse") - RV.setValue(IntInit::get(CostPerUse)); + RV.setValue(new IntInit(CostPerUse)); // Copy fields from the RegisterTuples def. if (RV.getName() == "SubRegIndices" || @@ -279,7 +278,7 @@ Members.insert(RegBank.getReg((*Elements)[i])); // Alternative allocation orders may be subsets. - const ListInit *Alts = R->getValueAsListInit("AltOrders"); + ListInit *Alts = R->getValueAsListInit("AltOrders"); AltOrders.resize(Alts->size()); SetTheory::RecSet Order; for (unsigned i = 0, e = Alts->size(); i != e; ++i) { @@ -296,11 +295,11 @@ } // SubRegClasses is a list containing (RC, subregindex, ...) dags. - const ListInit *SRC = R->getValueAsListInit("SubRegClasses"); + ListInit *SRC = R->getValueAsListInit("SubRegClasses"); for (ListInit::const_iterator i = SRC->begin(), e = SRC->end(); i != e; ++i) { - const DagInit *DAG = dynamic_cast(*i); + DagInit *DAG = dynamic_cast(*i); if (!DAG) throw "SubRegClasses must contain DAGs"; - const DefInit *DAGOp = dynamic_cast(DAG->getOperator()); + DefInit *DAGOp = dynamic_cast(DAG->getOperator()); Record *RCRec; if (!DAGOp || !(RCRec = DAGOp->getDef())->isSubClassOf("RegisterClass")) throw "Operator '" + DAG->getOperator()->getAsString() + @@ -308,7 +307,7 @@ // Iterate over args, all SubRegIndex instances. for (DagInit::const_arg_iterator ai = DAG->arg_begin(), ae = DAG->arg_end(); ai != ae; ++ai) { - const DefInit *Idx = dynamic_cast(*ai); + DefInit *Idx = dynamic_cast(*ai); Record *IdxRec; if (!Idx || !(IdxRec = Idx->getDef())->isSubClassOf("SubRegIndex")) throw "Argument '" + (*ai)->getAsString() + Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Mon Jul 11 18:06:52 2011 @@ -402,7 +402,7 @@ // Parse the list of return types. std::vector OverloadedVTs; - const ListInit *TypeList = R->getValueAsListInit("RetTypes"); + ListInit *TypeList = R->getValueAsListInit("RetTypes"); for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { Record *TyEl = TypeList->getElementAsRecord(i); assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); @@ -470,7 +470,7 @@ } // Parse the intrinsic properties. - const ListInit *PropList = R->getValueAsListInit("Properties"); + ListInit *PropList = R->getValueAsListInit("Properties"); for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { Record *Property = PropList->getElementAsRecord(i); assert(Property->isSubClassOf("IntrinsicProperty") && Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Mon Jul 11 18:06:52 2011 @@ -203,7 +203,7 @@ assert(N->isLeaf() && "Not a leaf?"); // Direct match against an integer constant. - if (const IntInit *II = dynamic_cast(N->getLeafValue())) { + if (IntInit *II = dynamic_cast(N->getLeafValue())) { // If this is the root of the dag we're matching, we emit a redundant opcode // check to ensure that this gets folded into the normal top-level // OpcodeSwitch. @@ -215,7 +215,7 @@ return AddMatcher(new CheckIntegerMatcher(II->getValue())); } - const DefInit *DI = dynamic_cast(N->getLeafValue()); + DefInit *DI = dynamic_cast(N->getLeafValue()); if (DI == 0) { errs() << "Unknown leaf kind: " << *DI << "\n"; abort(); @@ -283,8 +283,7 @@ N->getOperator()->getName() == "or") && N->getChild(1)->isLeaf() && N->getChild(1)->getPredicateFns().empty() && N->getPredicateFns().empty()) { - if (const IntInit *II = - dynamic_cast(N->getChild(1)->getLeafValue())) { + if (IntInit *II = dynamic_cast(N->getChild(1)->getLeafValue())) { if (!isPowerOf2_32(II->getValue())) { // Don't bother with single bits. // If this is at the root of the pattern, we emit a redundant // CheckOpcode so that the following checks get factored properly under @@ -497,7 +496,7 @@ --RecNodeEntry; // Entries in VariableMap are biased. const ComplexPattern &CP = - CGP.getComplexPattern(((const DefInit*)N->getLeafValue())->getDef()); + CGP.getComplexPattern(((DefInit*)N->getLeafValue())->getDef()); // Emit a CheckComplexPat operation, which does the match (aborting if it // fails) and pushes the matched operands onto the recorded nodes list. @@ -573,14 +572,14 @@ SmallVectorImpl &ResultOps) { assert(N->isLeaf() && "Must be a leaf"); - if (const IntInit *II = dynamic_cast(N->getLeafValue())) { + if (IntInit *II = dynamic_cast(N->getLeafValue())) { AddMatcher(new EmitIntegerMatcher(II->getValue(), N->getType(0))); ResultOps.push_back(NextRecordedOperandNo++); return; } // If this is an explicit register reference, handle it. - if (const DefInit *DI = dynamic_cast(N->getLeafValue())) { + if (DefInit *DI = dynamic_cast(N->getLeafValue())) { Record *Def = DI->getDef(); if (Def->isSubClassOf("Register")) { const CodeGenRegister *Reg = Modified: llvm/trunk/utils/TableGen/FastISelEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FastISelEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FastISelEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FastISelEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -241,7 +241,7 @@ if (Op->getType(0) != VT) return false; - const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); + DefInit *OpDI = dynamic_cast(Op->getLeafValue()); if (!OpDI) return false; Record *OpLeafRec = OpDI->getDef(); @@ -401,12 +401,12 @@ if (!Op->isLeaf()) return PhysReg; - const DefInit *OpDI = dynamic_cast(Op->getLeafValue()); + DefInit *OpDI = dynamic_cast(Op->getLeafValue()); Record *OpLeafRec = OpDI->getDef(); if (!OpLeafRec->isSubClassOf("Register")) return PhysReg; - PhysReg += static_cast(OpLeafRec->getValue( \ + PhysReg += static_cast(OpLeafRec->getValue( \ "Namespace")->getValue())->getValue(); PhysReg += "::"; PhysReg += Target.getRegBank().getReg(OpLeafRec)->getName(); @@ -468,7 +468,7 @@ // a bit too complicated for now. if (!Dst->getChild(1)->isLeaf()) continue; - const DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); + DefInit *SR = dynamic_cast(Dst->getChild(1)->getLeafValue()); if (SR) SubRegNo = getQualifiedName(SR->getDef()); else Modified: llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/FixedLenDecoderEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -48,15 +48,15 @@ static int Value(bit_value_t V) { return ValueNotSet(V) ? -1 : (V == BIT_FALSE ? 0 : 1); } -static bit_value_t bitFromBits(const BitsInit &bits, unsigned index) { - if (const BitInit *bit = dynamic_cast(bits.getBit(index))) +static bit_value_t bitFromBits(BitsInit &bits, unsigned index) { + if (BitInit *bit = dynamic_cast(bits.getBit(index))) return bit->getValue() ? BIT_TRUE : BIT_FALSE; // The bit is uninitialized. return BIT_UNSET; } // Prints the bit value for each position. -static void dumpBits(raw_ostream &o, const BitsInit &bits) { +static void dumpBits(raw_ostream &o, BitsInit &bits) { unsigned index; for (index = bits.getNumBits(); index > 0; index--) { @@ -76,8 +76,8 @@ } } -static const BitsInit &getBitsField(const Record &def, const char *str) { - const BitsInit *bits = def.getValueAsBitsInit(str); +static BitsInit &getBitsField(const Record &def, const char *str) { + BitsInit *bits = def.getValueAsBitsInit(str); return *bits; } @@ -279,8 +279,7 @@ protected: // Populates the insn given the uid. void insnWithID(insn_t &Insn, unsigned Opcode) const { - const BitsInit &Bits = - getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); + BitsInit &Bits = getBitsField(*AllInstructions[Opcode]->TheDef, "Inst"); for (unsigned i = 0; i < BIT_WIDTH; ++i) Insn[i] = bitFromBits(Bits, i); @@ -1231,7 +1230,7 @@ Def.getValueAsBit("isCodeGenOnly")) return false; - const BitsInit &Bits = getBitsField(Def, "Inst"); + BitsInit &Bits = getBitsField(Def, "Inst"); if (Bits.allInComplete()) return false; std::vector InsnOperands; @@ -1252,16 +1251,16 @@ // Gather the outputs/inputs of the instruction, so we can find their // positions in the encoding. This assumes for now that they appear in the // MCInst in the order that they're listed. - std::vector > InOutOperands; - const DagInit *Out = Def.getValueAsDag("OutOperandList"); - const DagInit *In = Def.getValueAsDag("InOperandList"); + std::vector > InOutOperands; + DagInit *Out = Def.getValueAsDag("OutOperandList"); + DagInit *In = Def.getValueAsDag("InOperandList"); for (unsigned i = 0; i < Out->getNumArgs(); ++i) InOutOperands.push_back(std::make_pair(Out->getArg(i), Out->getArgName(i))); for (unsigned i = 0; i < In->getNumArgs(); ++i) InOutOperands.push_back(std::make_pair(In->getArg(i), In->getArgName(i))); // For each operand, see if we can figure out where it is encoded. - for (std::vector >::iterator + for (std::vector >::iterator NI = InOutOperands.begin(), NE = InOutOperands.end(); NI != NE; ++NI) { unsigned PrevBit = ~0; unsigned Base = ~0; @@ -1269,10 +1268,10 @@ std::string Decoder = ""; for (unsigned bi = 0; bi < Bits.getNumBits(); ++bi) { - const VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); + VarBitInit *BI = dynamic_cast(Bits.getBit(bi)); if (!BI) continue; - const VarInit *Var = dynamic_cast(BI->getVariable()); + VarInit *Var = dynamic_cast(BI->getVariable()); assert(Var); unsigned CurrBit = BI->getBitNum(); if (Var->getName() != NI->second) continue; @@ -1302,7 +1301,7 @@ // for decoding register classes. // FIXME: This need to be extended to handle instructions with custom // decoder methods, and operands with (simple) MIOperandInfo's. - const TypedInit *TI = dynamic_cast(NI->first); + TypedInit *TI = dynamic_cast(NI->first); RecordRecTy *Type = dynamic_cast(TI->getType()); Record *TypeRecord = Type->getRecord(); bool isReg = false; @@ -1314,8 +1313,8 @@ } RecordVal *DecoderString = TypeRecord->getValue("DecoderMethod"); - const StringInit *String = DecoderString ? - dynamic_cast(DecoderString->getValue()) : + StringInit *String = DecoderString ? + dynamic_cast(DecoderString->getValue()) : 0; if (!isReg && String && String->getValue() != "") Decoder = String->getValue(); Modified: llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/InstrInfoEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -61,7 +61,7 @@ // registers in their multi-operand operands. It may also be an anonymous // operand, which has a single operand, but no declared class for the // operand. - const DagInit *MIOI = Inst.Operands[i].MIOperandInfo; + DagInit *MIOI = Inst.Operands[i].MIOperandInfo; if (!MIOI || MIOI->getNumArgs() == 0) { // Single, anonymous, operand. @@ -70,7 +70,7 @@ for (unsigned j = 0, e = Inst.Operands[i].MINumOperands; j != e; ++j) { OperandList.push_back(Inst.Operands[i]); - Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); + Record *OpR = dynamic_cast(MIOI->getArg(j))->getDef(); OperandList.back().Rec = OpR; } } @@ -288,11 +288,11 @@ if (Inst.hasExtraDefRegAllocReq) OS << "|(1<getValueAsBitsInit("TSFlags"); + BitsInit *TSF = Inst.TheDef->getValueAsBitsInit("TSFlags"); if (!TSF) throw "no TSFlags?"; uint64_t Value = 0; for (unsigned i = 0, e = TSF->getNumBits(); i != e; ++i) { - if (const BitInit *Bit = dynamic_cast(TSF->getBit(i))) + if (BitInit *Bit = dynamic_cast(TSF->getBit(i))) Value |= uint64_t(Bit->getValue()) << i; else throw "Invalid TSFlags bit in " + Inst.TheDef->getName(); Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -245,7 +245,7 @@ unsigned Flags; std::string Help; unsigned MultiVal; - const Init* InitVal; + Init* InitVal; OptionDescription(OptionType::OptionType t = OptionType::Switch, const std::string& n = "", @@ -589,7 +589,7 @@ } template -void InvokeDagInitHandler(FunctionObject* Obj, const Init* I) { +void InvokeDagInitHandler(FunctionObject* Obj, Init* I) { typedef void (FunctionObject::*Handler) (const DagInit&); const DagInit& Dag = InitPtrToDag(I); @@ -658,7 +658,7 @@ /// operator() - Just forwards to the corresponding property /// handler. - void operator() (const Init* I) { + void operator() (Init* I) { InvokeDagInitHandler(this, I); } @@ -705,10 +705,10 @@ void onInit (const DagInit& d) { CheckNumberOfArguments(d, 1); - const Init* i = d.getArg(0); + Init* i = d.getArg(0); const std::string& str = i->getAsString(); - bool correct = optDesc_.isParameter() && dynamic_cast(i); + bool correct = optDesc_.isParameter() && dynamic_cast(i); correct |= (optDesc_.isSwitch() && (str == "true" || str == "false")); if (!correct) @@ -821,7 +821,7 @@ for (RecordVector::const_iterator B = V.begin(), E = V.end(); B!=E; ++B) { // Throws an exception if the value does not exist. - const ListInit* PropList = (*B)->getValueAsListInit("options"); + ListInit* PropList = (*B)->getValueAsListInit("options"); // For every option description in this list: invoke AddOption. std::for_each(PropList->begin(), PropList->end(), AddOption(OptDescs)); @@ -836,8 +836,8 @@ struct ToolDescription : public RefCountedBase { std::string Name; - const Init* CmdLine; - const Init* Actions; + Init* CmdLine; + Init* Actions; StrVector InLanguage; std::string InFileOption; std::string OutFileOption; @@ -903,7 +903,7 @@ } } - void operator() (const Init* I) { + void operator() (Init* I) { InvokeDagInitHandler(this, I); } @@ -915,9 +915,9 @@ void onActions (const DagInit& d) { CheckNumberOfArguments(d, 1); - const Init* Case = d.getArg(0); + Init* Case = d.getArg(0); if (typeid(*Case) != typeid(DagInit) || - GetOperatorName(static_cast(*Case)) != "case") + GetOperatorName(static_cast(*Case)) != "case") throw "The argument to (actions) should be a 'case' construct!"; toolDesc_.Actions = Case; } @@ -954,7 +954,7 @@ isReallyJoin = true; } else { - const Init* I = d.getArg(0); + Init* I = d.getArg(0); isReallyJoin = InitPtrToBool(I); } @@ -1007,7 +1007,7 @@ E = Tools.end(); B!=E; ++B) { const Record* T = *B; // Throws an exception if the value does not exist. - const ListInit* PropList = T->getValueAsListInit("properties"); + ListInit* PropList = T->getValueAsListInit("properties"); IntrusiveRefCntPtr ToolDesc(new ToolDescription(T->getName())); @@ -1163,7 +1163,7 @@ unsigned i = 1; for (DagInit::const_arg_iterator B = d.arg_begin(), E = d.arg_end(); B != E; ++B) { - const Init* arg = *B; + Init* arg = *B; if (!even) { @@ -1181,8 +1181,8 @@ } else { - if (dynamic_cast(arg) - && GetOperatorName(static_cast(*arg)) == "case") { + if (dynamic_cast(arg) + && GetOperatorName(static_cast(*arg)) == "case") { // Nested 'case'. WalkCase(arg, TestCallback, StatementCallback, IndentLevel + Indent1); } @@ -1210,7 +1210,7 @@ ActionName == "parameter_equals" || ActionName == "element_in_list") { CheckNumberOfArguments(Stmt, 1); - const Init* Arg = Stmt.getArg(0); + Init* Arg = Stmt.getArg(0); if (typeid(*Arg) == typeid(StringInit)) OptionNames_.insert(InitPtrToString(Arg)); } @@ -1218,7 +1218,7 @@ ActionName == "any_not_empty" || ActionName == "any_empty" || ActionName == "not_empty" || ActionName == "empty") { for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) { - const Init* Arg = Stmt.getArg(i); + Init* Arg = Stmt.getArg(i); if (typeid(*Arg) == typeid(StringInit)) OptionNames_.insert(InitPtrToString(Arg)); } @@ -2613,7 +2613,7 @@ for (RecordVector::const_iterator B = OptionPreprocessors.begin(), E = OptionPreprocessors.end(); B!=E; ++B) { - const DagInit* Case = (*B)->getValueAsDag("preprocessor"); + DagInit* Case = (*B)->getValueAsDag("preprocessor"); EmitCaseConstructHandler(Case, Indent1, EmitPreprocessOptionsCallback(OptDecs), false, OptDecs, O); @@ -2645,7 +2645,7 @@ } } - void operator() (const Init* I) { + void operator() (Init* I) { InvokeDagInitHandler(this, I); } @@ -2655,7 +2655,7 @@ CheckNumberOfArguments(d, 2); const std::string& Lang = InitPtrToString(d.getArg(0)); - const Init* Suffixes = d.getArg(1); + Init* Suffixes = d.getArg(1); // Second argument to lang_to_suffixes is either a single string... if (typeid(*Suffixes) == typeid(StringInit)) { @@ -2688,7 +2688,7 @@ // Call DoEmitPopulateLanguageMap. for (RecordVector::const_iterator B = LangMaps.begin(), E = LangMaps.end(); B!=E; ++B) { - const ListInit* LangMap = (*B)->getValueAsListInit("map"); + ListInit* LangMap = (*B)->getValueAsListInit("map"); std::for_each(LangMap->begin(), LangMap->end(), DoEmitPopulateLanguageMap(O)); } @@ -2947,7 +2947,7 @@ // Look for hook invocations in 'cmd_line'. if (!D.CmdLine) continue; - if (dynamic_cast(D.CmdLine)) + if (dynamic_cast(D.CmdLine)) // This is a string. ExtractHookNames(HookNames, OptDescs).operator()(D.CmdLine); else Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -56,7 +56,7 @@ static const std::string getOptionName(const Record &R) { // Use the record name unless EnumName is defined. - if (dynamic_cast(R.getValueInit("EnumName"))) + if (dynamic_cast(R.getValueInit("EnumName"))) return R.getName(); return R.getValueAsString("EnumName"); @@ -105,7 +105,7 @@ // The containing option group (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; @@ -114,7 +114,7 @@ OS << ", INVALID, 0, 0"; // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { + if (!dynamic_cast(R.getValueInit("HelpText"))) { OS << ",\n"; OS << " "; write_cstring(OS, R.getValueAsString("HelpText")); @@ -145,14 +145,14 @@ // The containing option group (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; // The option alias (if any). OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) + if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) OS << getOptionName(*DI->getDef()); else OS << "INVALID"; @@ -166,7 +166,7 @@ for (unsigned i = 0, e = LI->size(); i != e; ++i) { if (i) OS << " | "; - OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); + OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); } } @@ -174,7 +174,7 @@ OS << ", " << R.getValueAsInt("NumArgs"); // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { + if (!dynamic_cast(R.getValueInit("HelpText"))) { OS << ",\n"; OS << " "; write_cstring(OS, R.getValueAsString("HelpText")); @@ -183,7 +183,7 @@ // The option meta-variable name. OS << ", "; - if (!dynamic_cast(R.getValueInit("MetaVarName"))) + if (!dynamic_cast(R.getValueInit("MetaVarName"))) write_cstring(OS, R.getValueAsString("MetaVarName")); else OS << "0"; Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -24,11 +24,11 @@ // a single dag, so we can do fancier things. unsigned PseudoLoweringEmitter:: -addDagOperandMapping(Record *Rec, const DagInit *Dag, CodeGenInstruction &Insn, +addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn, IndexedMap &OperandMap, unsigned BaseIdx) { unsigned OpsAdded = 0; for (unsigned i = 0, e = Dag->getNumArgs(); i != e; ++i) { - if (const DefInit *DI = dynamic_cast(Dag->getArg(i))) { + if (DefInit *DI = dynamic_cast(Dag->getArg(i))) { // Physical register reference. Explicit check for the special case // "zero_reg" definition. if (DI->getDef()->isSubClassOf("Register") || @@ -54,13 +54,11 @@ for (unsigned I = 0, E = Insn.Operands[i].MINumOperands; I != E; ++I) OperandMap[BaseIdx + i + I].Kind = OpData::Operand; OpsAdded += Insn.Operands[i].MINumOperands; - } else if (const IntInit *II = - dynamic_cast(Dag->getArg(i))) { + } else if (IntInit *II = dynamic_cast(Dag->getArg(i))) { OperandMap[BaseIdx + i].Kind = OpData::Imm; OperandMap[BaseIdx + i].Data.Imm = II->getValue(); ++OpsAdded; - } else if (const DagInit *SubDag = - dynamic_cast(Dag->getArg(i))) { + } else if (DagInit *SubDag = dynamic_cast(Dag->getArg(i))) { // Just add the operands recursively. This is almost certainly // a constant value for a complex operand (> 1 MI operand). unsigned NewOps = @@ -79,11 +77,11 @@ // Validate that the result pattern has the corrent number and types // of arguments for the instruction it references. - const DagInit *Dag = Rec->getValueAsDag("ResultInst"); + DagInit *Dag = Rec->getValueAsDag("ResultInst"); assert(Dag && "Missing result instruction in pseudo expansion!"); DEBUG(dbgs() << " Result: " << *Dag << "\n"); - const DefInit *OpDef = dynamic_cast(Dag->getOperator()); + DefInit *OpDef = dynamic_cast(Dag->getOperator()); if (!OpDef) throw TGError(Rec->getLoc(), Rec->getName() + " has unexpected operator type!"); Modified: llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h (original) +++ llvm/trunk/utils/TableGen/PseudoLoweringEmitter.h Mon Jul 11 18:06:52 2011 @@ -47,7 +47,7 @@ SmallVector Expansions; - unsigned addDagOperandMapping(Record *Rec, const DagInit *Dag, + unsigned addDagOperandMapping(Record *Rec, DagInit *Dag, CodeGenInstruction &Insn, IndexedMap &OperandMap, unsigned BaseIdx); Modified: llvm/trunk/utils/TableGen/Record.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.cpp (original) +++ llvm/trunk/utils/TableGen/Record.cpp Mon Jul 11 18:06:52 2011 @@ -15,8 +15,6 @@ #include "Error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Format.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" using namespace llvm; @@ -27,7 +25,7 @@ void RecTy::dump() const { print(errs()); } -const Init *BitRecTy::convertValue(const BitsInit *BI) { +Init *BitRecTy::convertValue(BitsInit *BI) { if (BI->getNumBits() != 1) return 0; // Only accept if just one bit! return BI->getBit(0); } @@ -36,14 +34,14 @@ return RHS->getNumBits() == 1; } -const Init *BitRecTy::convertValue(const IntInit *II) { +Init *BitRecTy::convertValue(IntInit *II) { int64_t Val = II->getValue(); if (Val != 0 && Val != 1) return 0; // Only accept 0 or 1 for a bit! - return BitInit::get(Val != 0); + return new BitInit(Val != 0); } -const Init *BitRecTy::convertValue(const TypedInit *VI) { +Init *BitRecTy::convertValue(TypedInit *VI) { if (dynamic_cast(VI->getType())) return VI; // Accept variable if it is already of bit type! return 0; @@ -53,21 +51,19 @@ return "bits<" + utostr(Size) + ">"; } -const Init *BitsRecTy::convertValue(const UnsetInit *UI) { - SmallVector Bits(Size); +Init *BitsRecTy::convertValue(UnsetInit *UI) { + BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = UnsetInit::get(); - - return BitsInit::get(Bits.begin(), Bits.end()); + Ret->setBit(i, new UnsetInit()); + return Ret; } -const Init *BitsRecTy::convertValue(const BitInit *UI) { +Init *BitsRecTy::convertValue(BitInit *UI) { if (Size != 1) return 0; // Can only convert single bit. - - const Init *Bits[1] = { UI }; - - return BitsInit::get(Bits, array_endof(Bits)); + BitsInit *Ret = new BitsInit(1); + Ret->setBit(0, UI); + return Ret; } /// canFitInBitfield - Return true if the number of bits is large enough to hold @@ -78,85 +74,82 @@ (Value >> NumBits == 0) || (Value >> (NumBits-1) == -1); } -/// convertValue from Int initializer to bits type: Split the integer -/// up into the appropriate bits. +/// convertValue from Int initializer to bits type: Split the integer up into the +/// appropriate bits. /// -const Init *BitsRecTy::convertValue(const IntInit *II) { +Init *BitsRecTy::convertValue(IntInit *II) { int64_t Value = II->getValue(); // Make sure this bitfield is large enough to hold the integer value. if (!canFitInBitfield(Value, Size)) return 0; - SmallVector Bits(Size); - + BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = BitInit::get(Value & (1LL << i)); + Ret->setBit(i, new BitInit(Value & (1LL << i))); - return BitsInit::get(Bits.begin(), Bits.end()); + return Ret; } -const Init *BitsRecTy::convertValue(const BitsInit *BI) { +Init *BitsRecTy::convertValue(BitsInit *BI) { // If the number of bits is right, return it. Otherwise we need to expand or // truncate. if (BI->getNumBits() == Size) return BI; return 0; } -const Init *BitsRecTy::convertValue(const TypedInit *VI) { +Init *BitsRecTy::convertValue(TypedInit *VI) { if (BitsRecTy *BRT = dynamic_cast(VI->getType())) if (BRT->Size == Size) { - SmallVector Bits(Size); - + BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) - Bits[i] = VarBitInit::get(VI, i); - return BitsInit::get(Bits.begin(), Bits.end()); + Ret->setBit(i, new VarBitInit(VI, i)); + return Ret; } if (Size == 1 && dynamic_cast(VI->getType())) { - const Init *Bits[1] = { VI }; - - return BitsInit::get(Bits, array_endof(Bits)); + BitsInit *Ret = new BitsInit(1); + Ret->setBit(0, VI); + return Ret; } - if (const TernOpInit *Tern = dynamic_cast(VI)) { + if (TernOpInit *Tern = dynamic_cast(VI)) { if (Tern->getOpcode() == TernOpInit::IF) { - const Init *LHS = Tern->getLHS(); - const Init *MHS = Tern->getMHS(); - const Init *RHS = Tern->getRHS(); + Init *LHS = Tern->getLHS(); + Init *MHS = Tern->getMHS(); + Init *RHS = Tern->getRHS(); - const IntInit *MHSi = dynamic_cast(MHS); - const IntInit *RHSi = dynamic_cast(RHS); + IntInit *MHSi = dynamic_cast(MHS); + IntInit *RHSi = dynamic_cast(RHS); if (MHSi && RHSi) { int64_t MHSVal = MHSi->getValue(); int64_t RHSVal = RHSi->getValue(); if (canFitInBitfield(MHSVal, Size) && canFitInBitfield(RHSVal, Size)) { - SmallVector NewBits(Size); + BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) - NewBits[i] = - TernOpInit::get(TernOpInit::IF, LHS, - IntInit::get((MHSVal & (1LL << i)) ? 1 : 0), - IntInit::get((RHSVal & (1LL << i)) ? 1 : 0), - VI->getType()); - - return BitsInit::get(NewBits.begin(), NewBits.end()); + Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, + new IntInit((MHSVal & (1LL << i)) ? 1 : 0), + new IntInit((RHSVal & (1LL << i)) ? 1 : 0), + VI->getType())); + + return Ret; } } else { - const BitsInit *MHSbs = dynamic_cast(MHS); - const BitsInit *RHSbs = dynamic_cast(RHS); + BitsInit *MHSbs = dynamic_cast(MHS); + BitsInit *RHSbs = dynamic_cast(RHS); if (MHSbs && RHSbs) { - SmallVector NewBits(Size); + BitsInit *Ret = new BitsInit(Size); for (unsigned i = 0; i != Size; ++i) - NewBits[i] = TernOpInit::get(TernOpInit::IF, LHS, - MHSbs->getBit(i), - RHSbs->getBit(i), - VI->getType()); + Ret->setBit(i, new TernOpInit(TernOpInit::IF, LHS, + MHSbs->getBit(i), + RHSbs->getBit(i), + VI->getType())); - return BitsInit::get(NewBits.begin(), NewBits.end()); + return Ret; } } } @@ -165,54 +158,54 @@ return 0; } -const Init *IntRecTy::convertValue(const BitInit *BI) { - return IntInit::get(BI->getValue()); +Init *IntRecTy::convertValue(BitInit *BI) { + return new IntInit(BI->getValue()); } -const Init *IntRecTy::convertValue(const BitsInit *BI) { +Init *IntRecTy::convertValue(BitsInit *BI) { int64_t Result = 0; for (unsigned i = 0, e = BI->getNumBits(); i != e; ++i) - if (const BitInit *Bit = dynamic_cast(BI->getBit(i))) { + if (BitInit *Bit = dynamic_cast(BI->getBit(i))) { Result |= Bit->getValue() << i; } else { return 0; } - return IntInit::get(Result); + return new IntInit(Result); } -const Init *IntRecTy::convertValue(const TypedInit *TI) { +Init *IntRecTy::convertValue(TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; // Accept variable if already of the right type! return 0; } -const Init *StringRecTy::convertValue(const UnOpInit *BO) { +Init *StringRecTy::convertValue(UnOpInit *BO) { if (BO->getOpcode() == UnOpInit::CAST) { - const Init *L = BO->getOperand()->convertInitializerTo(this); + Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return UnOpInit::get(UnOpInit::CAST, L, new StringRecTy); + return new UnOpInit(UnOpInit::CAST, L, new StringRecTy); return BO; } - return convertValue((const TypedInit*)BO); + return convertValue((TypedInit*)BO); } -const Init *StringRecTy::convertValue(const BinOpInit *BO) { +Init *StringRecTy::convertValue(BinOpInit *BO) { if (BO->getOpcode() == BinOpInit::STRCONCAT) { - const Init *L = BO->getLHS()->convertInitializerTo(this); - const Init *R = BO->getRHS()->convertInitializerTo(this); + Init *L = BO->getLHS()->convertInitializerTo(this); + Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return BinOpInit::get(BinOpInit::STRCONCAT, L, R, new StringRecTy); + return new BinOpInit(BinOpInit::STRCONCAT, L, R, new StringRecTy); return BO; } - return convertValue((const TypedInit*)BO); + return convertValue((TypedInit*)BO); } -const Init *StringRecTy::convertValue(const TypedInit *TI) { +Init *StringRecTy::convertValue(TypedInit *TI) { if (dynamic_cast(TI->getType())) return TI; // Accept variable if already of the right type! return 0; @@ -222,13 +215,13 @@ return "list<" + Ty->getAsString() + ">"; } -const Init *ListRecTy::convertValue(const ListInit *LI) { - std::vector Elements; +Init *ListRecTy::convertValue(ListInit *LI) { + std::vector Elements; // Verify that all of the elements of the list are subclasses of the // appropriate class! for (unsigned i = 0, e = LI->getSize(); i != e; ++i) - if (const Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) + if (Init *CI = LI->getElement(i)->convertInitializerTo(Ty)) Elements.push_back(CI); else return 0; @@ -238,10 +231,10 @@ return 0; } - return ListInit::get(Elements, new ListRecTy(Ty)); + return new ListInit(Elements, new ListRecTy(Ty)); } -const Init *ListRecTy::convertValue(const TypedInit *TI) { +Init *ListRecTy::convertValue(TypedInit *TI) { // Ensure that TI is compatible with our class. if (ListRecTy *LRT = dynamic_cast(TI->getType())) if (LRT->getElementType()->typeIsConvertibleTo(getElementType())) @@ -249,36 +242,36 @@ return 0; } -const Init *CodeRecTy::convertValue(const TypedInit *TI) { +Init *CodeRecTy::convertValue(TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; return 0; } -const Init *DagRecTy::convertValue(const TypedInit *TI) { +Init *DagRecTy::convertValue(TypedInit *TI) { if (TI->getType()->typeIsConvertibleTo(this)) return TI; return 0; } -const Init *DagRecTy::convertValue(const UnOpInit *BO) { +Init *DagRecTy::convertValue(UnOpInit *BO) { if (BO->getOpcode() == UnOpInit::CAST) { - const Init *L = BO->getOperand()->convertInitializerTo(this); + Init *L = BO->getOperand()->convertInitializerTo(this); if (L == 0) return 0; if (L != BO->getOperand()) - return UnOpInit::get(UnOpInit::CAST, L, new DagRecTy); + return new UnOpInit(UnOpInit::CAST, L, new DagRecTy); return BO; } return 0; } -const Init *DagRecTy::convertValue(const BinOpInit *BO) { +Init *DagRecTy::convertValue(BinOpInit *BO) { if (BO->getOpcode() == BinOpInit::CONCAT) { - const Init *L = BO->getLHS()->convertInitializerTo(this); - const Init *R = BO->getRHS()->convertInitializerTo(this); + Init *L = BO->getLHS()->convertInitializerTo(this); + Init *R = BO->getRHS()->convertInitializerTo(this); if (L == 0 || R == 0) return 0; if (L != BO->getLHS() || R != BO->getRHS()) - return BinOpInit::get(BinOpInit::CONCAT, L, R, new DagRecTy); + return new BinOpInit(BinOpInit::CONCAT, L, R, new DagRecTy); return BO; } return 0; @@ -288,14 +281,14 @@ return Rec->getName(); } -const Init *RecordRecTy::convertValue(const DefInit *DI) { +Init *RecordRecTy::convertValue(DefInit *DI) { // Ensure that DI is a subclass of Rec. if (!DI->getDef()->isSubClassOf(Rec)) return 0; return DI; } -const Init *RecordRecTy::convertValue(const TypedInit *TI) { +Init *RecordRecTy::convertValue(TypedInit *TI) { // Ensure that TI is compatible with Rec. if (RecordRecTy *RRT = dynamic_cast(TI->getType())) if (RRT->getRecord()->isSubClassOf(getRecord()) || @@ -374,59 +367,25 @@ // Initializer implementations //===----------------------------------------------------------------------===// -FoldingSet Init::UniqueInits; -BumpPtrAllocator Init::InitAllocator; - void Init::dump() const { return print(errs()); } -const UnsetInit *UnsetInit::get() { - FoldingSetNodeID ID; - ID.AddInteger(initUnset); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - UnsetInit *I = InitAllocator.Allocate(); - new (I) UnsetInit(ID); - UniqueInits.InsertNode(I, IP); - return I; -} - -const BitInit *BitInit::get(bool V) { - FoldingSetNodeID ID; - ID.AddInteger(initBit); - ID.AddBoolean(V); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - BitInit *I = InitAllocator.Allocate(); - new (I) BitInit(ID, V); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init * -BitsInit::convertInitializerBitRange(const std::vector &Bits) const { - SmallVector NewBits(Bits.size()); - +Init *BitsInit::convertInitializerBitRange(const std::vector &Bits) { + BitsInit *BI = new BitsInit(Bits.size()); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { if (Bits[i] >= getNumBits()) { + delete BI; return 0; } - NewBits[i] = getBit(Bits[i]); + BI->setBit(i, getBit(Bits[i])); } - - return BitsInit::get(NewBits.begin(), NewBits.end()); + return BI; } std::string BitsInit::getAsString() const { std::string Result = "{ "; for (unsigned i = 0, e = getNumBits(); i != e; ++i) { if (i) Result += ", "; - if (const Init *Bit = getBit(e-i-1)) + if (Init *Bit = getBit(e-i-1)) Result += Bit->getAsString(); else Result += "*"; @@ -437,141 +396,70 @@ // resolveReferences - If there are any field references that refer to fields // that have been filled in, we can propagate the values now. // -const Init *BitsInit::resolveReferences(Record &R, - const RecordVal *RV) const { +Init *BitsInit::resolveReferences(Record &R, const RecordVal *RV) { bool Changed = false; + BitsInit *New = new BitsInit(getNumBits()); - SmallVector Bits(getNumBits()); - - for (unsigned i = 0, e = getNumBits(); i != e; ++i) { - const Init *B; - const Init *CurBit = getBit(i); + for (unsigned i = 0, e = Bits.size(); i != e; ++i) { + Init *B; + Init *CurBit = getBit(i); do { B = CurBit; CurBit = CurBit->resolveReferences(R, RV); Changed |= B != CurBit; } while (B != CurBit); - Bits[i] = CurBit; + New->setBit(i, CurBit); } if (Changed) - return BitsInit::get(Bits.begin(), Bits.end()); - + return New; + delete New; return this; } -const IntInit *IntInit::get(int64_t V) { - FoldingSetNodeID ID; - ID.AddInteger(initInt); - ID.AddInteger(V); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - IntInit *I = InitAllocator.Allocate(); - new (I) IntInit(ID, V); - UniqueInits.InsertNode(I, IP); - return I; -} - std::string IntInit::getAsString() const { return itostr(Value); } -const Init * -IntInit::convertInitializerBitRange(const std::vector &Bits) const { - SmallVector NewBits(Bits.size()); +Init *IntInit::convertInitializerBitRange(const std::vector &Bits) { + BitsInit *BI = new BitsInit(Bits.size()); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { - if (Bits[i] >= 64) + if (Bits[i] >= 64) { + delete BI; return 0; - - NewBits[i] = BitInit::get(Value & (INT64_C(1) << Bits[i])); - } - - return BitsInit::get(NewBits.begin(), NewBits.end()); -} - -const StringInit *StringInit::get(const std::string &V) { - FoldingSetNodeID ID; - ID.AddInteger(initString); - ID.AddString(V); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - StringInit *I = InitAllocator.Allocate(); - new (I) StringInit(ID, V); - UniqueInits.InsertNode(I, IP); - return I; -} - -const CodeInit *CodeInit::get(const std::string &V) { - FoldingSetNodeID ID; - ID.AddInteger(initCode); - ID.AddString(V); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - CodeInit *I = InitAllocator.Allocate(); - new (I) CodeInit(ID, V); - UniqueInits.InsertNode(I, IP); - return I; -} - -const ListInit *ListInit::get(std::vector &Vs, RecTy *EltTy) { - FoldingSetNodeID ID; - ID.AddInteger(initList); - ID.AddString(EltTy->getAsString()); - - for (std::vector::iterator i = Vs.begin(), iend = Vs.end(); - i != iend; - ++i) { - ID.AddPointer(*i); + } + BI->setBit(i, new BitInit(Value & (INT64_C(1) << Bits[i]))); } - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - ListInit *I = InitAllocator.Allocate(); - new (I) ListInit(ID, Vs, EltTy); - UniqueInits.InsertNode(I, IP); - return I; + return BI; } -const Init * -ListInit::convertInitListSlice(const std::vector &Elements) const { - std::vector Vals; +Init *ListInit::convertInitListSlice(const std::vector &Elements) { + std::vector Vals; for (unsigned i = 0, e = Elements.size(); i != e; ++i) { if (Elements[i] >= getSize()) return 0; Vals.push_back(getElement(Elements[i])); } - return ListInit::get(Vals, getType()); + return new ListInit(Vals, getType()); } Record *ListInit::getElementAsRecord(unsigned i) const { assert(i < Values.size() && "List element index out of range!"); - const DefInit *DI = dynamic_cast(Values[i]); + DefInit *DI = dynamic_cast(Values[i]); if (DI == 0) throw "Expected record in list!"; return DI->getDef(); } -const Init *ListInit::resolveReferences(Record &R, - const RecordVal *RV) const { - std::vector Resolved; +Init *ListInit::resolveReferences(Record &R, const RecordVal *RV) { + std::vector Resolved; Resolved.reserve(getSize()); bool Changed = false; for (unsigned i = 0, e = getSize(); i != e; ++i) { - const Init *E; - const Init *CurElt = getElement(i); + Init *E; + Init *CurElt = getElement(i); do { E = CurElt; @@ -582,25 +470,20 @@ } if (Changed) - return ListInit::get(Resolved, getType()); - + return new ListInit(Resolved, getType()); return this; } -const Init *ListInit::resolveListElementReference(Record &R, - const RecordVal *IRV, - unsigned Elt) const { +Init *ListInit::resolveListElementReference(Record &R, const RecordVal *IRV, + unsigned Elt) { if (Elt >= getSize()) return 0; // Out of range reference. - - const Init *E = getElement(Elt); - + Init *E = getElement(Elt); // If the element is set to some value, or if we are resolving a reference // to a specific variable and that variable is explicitly unset, then // replace the VarListElementInit with it. - if (IRV || !dynamic_cast(E)) + if (IRV || !dynamic_cast(E)) return E; - return 0; } @@ -613,12 +496,12 @@ return Result + "]"; } -const Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, - unsigned Bit) const { - const Init *Folded = Fold(&R, 0); +Init *OpInit::resolveBitReference(Record &R, const RecordVal *IRV, + unsigned Bit) { + Init *Folded = Fold(&R, 0); if (Folded != this) { - const TypedInit *Typed = dynamic_cast(Folded); + TypedInit *Typed = dynamic_cast(Folded); if (Typed) { return Typed->resolveBitReference(R, IRV, Bit); } @@ -627,12 +510,12 @@ return 0; } -const Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, - unsigned Elt) const { - const Init *Folded = Fold(&R, 0); +Init *OpInit::resolveListElementReference(Record &R, const RecordVal *IRV, + unsigned Elt) { + Init *Folded = Fold(&R, 0); if (Folded != this) { - const TypedInit *Typed = dynamic_cast(Folded); + TypedInit *Typed = dynamic_cast(Folded); if (Typed) { return Typed->resolveListElementReference(R, IRV, Elt); } @@ -641,39 +524,22 @@ return 0; } -const UnOpInit *UnOpInit::get(UnaryOp opc, const Init *lhs, RecTy *Type) { - FoldingSetNodeID ID; - ID.AddInteger(initUnOp); - ID.AddInteger(opc); - ID.AddString(Type->getAsString()); - ID.AddPointer(lhs); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - UnOpInit *I = InitAllocator.Allocate(); - new (I) UnOpInit(ID, opc, lhs, Type); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { +Init *UnOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { switch (getOpcode()) { default: assert(0 && "Unknown unop"); case CAST: { if (getType()->getAsString() == "string") { - const StringInit *LHSs = dynamic_cast(LHS); + StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { return LHSs; } - const DefInit *LHSd = dynamic_cast(LHS); + DefInit *LHSd = dynamic_cast(LHS); if (LHSd) { - return StringInit::get(LHSd->getDef()->getName()); + return new StringInit(LHSd->getDef()->getName()); } } else { - const StringInit *LHSs = dynamic_cast(LHS); + StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { std::string Name = LHSs->getValue(); @@ -682,7 +548,7 @@ if (const RecordVal *RV = CurRec->getValue(Name)) { if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::get(Name, RV->getType()); + return new VarInit(Name, RV->getType()); } std::string TemplateArgName = CurRec->getName()+":"+Name; @@ -693,7 +559,7 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::get(TemplateArgName, RV->getType()); + return new VarInit(TemplateArgName, RV->getType()); } } @@ -706,12 +572,12 @@ if (RV->getType() != getType()) throw "type mismatch in cast"; - return VarInit::get(MCName, RV->getType()); + return new VarInit(MCName, RV->getType()); } } if (Record *D = (CurRec->getRecords()).getDef(Name)) - return DefInit::get(D); + return new DefInit(D); throw TGError(CurRec->getLoc(), "Undefined reference:'" + Name + "'\n"); } @@ -719,7 +585,7 @@ break; } case HEAD: { - const ListInit *LHSl = dynamic_cast(LHS); + ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { assert(0 && "Empty list in car"); @@ -730,33 +596,33 @@ break; } case TAIL: { - const ListInit *LHSl = dynamic_cast(LHS); + ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { assert(0 && "Empty list in cdr"); return 0; } - const ListInit *Result = ListInit::get(LHSl->begin()+1, LHSl->end(), - LHSl->getType()); + ListInit *Result = new ListInit(LHSl->begin()+1, LHSl->end(), + LHSl->getType()); return Result; } break; } case EMPTY: { - const ListInit *LHSl = dynamic_cast(LHS); + ListInit *LHSl = dynamic_cast(LHS); if (LHSl) { if (LHSl->getSize() == 0) { - return IntInit::get(1); + return new IntInit(1); } else { - return IntInit::get(0); + return new IntInit(0); } } - const StringInit *LHSs = dynamic_cast(LHS); + StringInit *LHSs = dynamic_cast(LHS); if (LHSs) { if (LHSs->getValue().empty()) { - return IntInit::get(1); + return new IntInit(1); } else { - return IntInit::get(0); + return new IntInit(0); } } @@ -766,12 +632,11 @@ return this; } -const Init *UnOpInit::resolveReferences(Record &R, - const RecordVal *RV) const { - const Init *lhs = LHS->resolveReferences(R, RV); +Init *UnOpInit::resolveReferences(Record &R, const RecordVal *RV) { + Init *lhs = LHS->resolveReferences(R, RV); if (LHS != lhs) - return (UnOpInit::get(getOpcode(), lhs, getType()))->Fold(&R, 0); + return (new UnOpInit(getOpcode(), lhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -786,37 +651,18 @@ return Result + "(" + LHS->getAsString() + ")"; } -const BinOpInit *BinOpInit::get(BinaryOp opc, const Init *lhs, - const Init *rhs, RecTy *Type) { - FoldingSetNodeID ID; - ID.AddInteger(initBinOp); - ID.AddInteger(opc); - ID.AddString(Type->getAsString()); - ID.AddPointer(lhs); - ID.AddPointer(rhs); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - BinOpInit *I = InitAllocator.Allocate(); - new (I) BinOpInit(ID, opc, lhs, rhs, Type); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { +Init *BinOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { switch (getOpcode()) { default: assert(0 && "Unknown binop"); case CONCAT: { - const DagInit *LHSs = dynamic_cast(LHS); - const DagInit *RHSs = dynamic_cast(RHS); + DagInit *LHSs = dynamic_cast(LHS); + DagInit *RHSs = dynamic_cast(RHS); if (LHSs && RHSs) { - const DefInit *LOp = dynamic_cast(LHSs->getOperator()); - const DefInit *ROp = dynamic_cast(RHSs->getOperator()); + DefInit *LOp = dynamic_cast(LHSs->getOperator()); + DefInit *ROp = dynamic_cast(RHSs->getOperator()); if (LOp == 0 || ROp == 0 || LOp->getDef() != ROp->getDef()) throw "Concated Dag operators do not match!"; - std::vector Args; + std::vector Args; std::vector ArgNames; for (unsigned i = 0, e = LHSs->getNumArgs(); i != e; ++i) { Args.push_back(LHSs->getArg(i)); @@ -826,42 +672,42 @@ Args.push_back(RHSs->getArg(i)); ArgNames.push_back(RHSs->getArgName(i)); } - return DagInit::get(LHSs->getOperator(), "", Args, ArgNames); + return new DagInit(LHSs->getOperator(), "", Args, ArgNames); } break; } case STRCONCAT: { - const StringInit *LHSs = dynamic_cast(LHS); - const StringInit *RHSs = dynamic_cast(RHS); + StringInit *LHSs = dynamic_cast(LHS); + StringInit *RHSs = dynamic_cast(RHS); if (LHSs && RHSs) - return StringInit::get(LHSs->getValue() + RHSs->getValue()); + return new StringInit(LHSs->getValue() + RHSs->getValue()); break; } case EQ: { // try to fold eq comparison for 'bit' and 'int', otherwise fallback // to string objects. - const IntInit* L = - dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); - const IntInit* R = - dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); + IntInit* L = + dynamic_cast(LHS->convertInitializerTo(new IntRecTy())); + IntInit* R = + dynamic_cast(RHS->convertInitializerTo(new IntRecTy())); if (L && R) - return IntInit::get(L->getValue() == R->getValue()); + return new IntInit(L->getValue() == R->getValue()); - const StringInit *LHSs = dynamic_cast(LHS); - const StringInit *RHSs = dynamic_cast(RHS); + StringInit *LHSs = dynamic_cast(LHS); + StringInit *RHSs = dynamic_cast(RHS); // Make sure we've resolved if (LHSs && RHSs) - return IntInit::get(LHSs->getValue() == RHSs->getValue()); + return new IntInit(LHSs->getValue() == RHSs->getValue()); break; } case SHL: case SRA: case SRL: { - const IntInit *LHSi = dynamic_cast(LHS); - const IntInit *RHSi = dynamic_cast(RHS); + IntInit *LHSi = dynamic_cast(LHS); + IntInit *RHSi = dynamic_cast(RHS); if (LHSi && RHSi) { int64_t LHSv = LHSi->getValue(), RHSv = RHSi->getValue(); int64_t Result; @@ -871,7 +717,7 @@ case SRA: Result = LHSv >> RHSv; break; case SRL: Result = (uint64_t)LHSv >> (uint64_t)RHSv; break; } - return IntInit::get(Result); + return new IntInit(Result); } break; } @@ -879,13 +725,12 @@ return this; } -const Init *BinOpInit::resolveReferences(Record &R, - const RecordVal *RV) const { - const Init *lhs = LHS->resolveReferences(R, RV); - const Init *rhs = RHS->resolveReferences(R, RV); +Init *BinOpInit::resolveReferences(Record &R, const RecordVal *RV) { + Init *lhs = LHS->resolveReferences(R, RV); + Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || RHS != rhs) - return (BinOpInit::get(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); + return (new BinOpInit(getOpcode(), lhs, rhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -902,43 +747,20 @@ return Result + "(" + LHS->getAsString() + ", " + RHS->getAsString() + ")"; } -const TernOpInit *TernOpInit::get(TernaryOp opc, const Init *lhs, - const Init *mhs, const Init *rhs, - RecTy *Type) { - FoldingSetNodeID ID; - ID.AddInteger(initTernOp); - ID.AddInteger(opc); - ID.AddString(Type->getAsString()); - ID.AddPointer(lhs); - ID.AddPointer(mhs); - ID.AddPointer(rhs); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - TernOpInit *I = InitAllocator.Allocate(); - new (I) TernOpInit(ID, opc, lhs, mhs, rhs, Type); - UniqueInits.InsertNode(I, IP); - return I; -} - -static const Init *ForeachHelper(const Init *LHS, const Init *MHS, - const Init *RHS, RecTy *Type, - Record *CurRec, MultiClass *CurMultiClass); - -static const Init *EvaluateOperation(const OpInit *RHSo, const Init *LHS, - const Init *Arg, RecTy *Type, - Record *CurRec, - MultiClass *CurMultiClass) { - std::vector NewOperands; +static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, + Record *CurRec, MultiClass *CurMultiClass); + +static Init *EvaluateOperation(OpInit *RHSo, Init *LHS, Init *Arg, + RecTy *Type, Record *CurRec, + MultiClass *CurMultiClass) { + std::vector NewOperands; - const TypedInit *TArg = dynamic_cast(Arg); + TypedInit *TArg = dynamic_cast(Arg); // If this is a dag, recurse if (TArg && TArg->getType()->getAsString() == "dag") { - const Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, - CurRec, CurMultiClass); + Init *Result = ForeachHelper(LHS, Arg, RHSo, Type, + CurRec, CurMultiClass); if (Result != 0) { return Result; } else { @@ -946,21 +768,18 @@ } } - bool change = false; for (int i = 0; i < RHSo->getNumOperands(); ++i) { - const OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); + OpInit *RHSoo = dynamic_cast(RHSo->getOperand(i)); if (RHSoo) { - const Init *Result = EvaluateOperation(RHSoo, LHS, Arg, - Type, CurRec, CurMultiClass); + Init *Result = EvaluateOperation(RHSoo, LHS, Arg, + Type, CurRec, CurMultiClass); if (Result != 0) { - change = true; NewOperands.push_back(Result); } else { NewOperands.push_back(Arg); } } else if (LHS->getAsString() == RHSo->getOperand(i)->getAsString()) { - change = true; NewOperands.push_back(Arg); } else { NewOperands.push_back(RHSo->getOperand(i)); @@ -968,31 +787,30 @@ } // Now run the operator and use its result as the new leaf - const OpInit *NewOp = RHSo->clone(NewOperands); - const Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); - - if (change) { + OpInit *NewOp = RHSo->clone(NewOperands); + Init *NewVal = NewOp->Fold(CurRec, CurMultiClass); + if (NewVal != NewOp) { + delete NewOp; return NewVal; } return 0; } -static const Init *ForeachHelper(const Init *LHS, const Init *MHS, - const Init *RHS, RecTy *Type, - Record *CurRec, MultiClass *CurMultiClass) { - const DagInit *MHSd = dynamic_cast(MHS); - const ListInit *MHSl = dynamic_cast(MHS); +static Init *ForeachHelper(Init *LHS, Init *MHS, Init *RHS, RecTy *Type, + Record *CurRec, MultiClass *CurMultiClass) { + DagInit *MHSd = dynamic_cast(MHS); + ListInit *MHSl = dynamic_cast(MHS); DagRecTy *DagType = dynamic_cast(Type); ListRecTy *ListType = dynamic_cast(Type); - const OpInit *RHSo = dynamic_cast(RHS); + OpInit *RHSo = dynamic_cast(RHS); if (!RHSo) { throw TGError(CurRec->getLoc(), "!foreach requires an operator\n"); } - const TypedInit *LHSt = dynamic_cast(LHS); + TypedInit *LHSt = dynamic_cast(LHS); if (!LHSt) { throw TGError(CurRec->getLoc(), "!foreach requires typed variable\n"); @@ -1000,23 +818,23 @@ if ((MHSd && DagType) || (MHSl && ListType)) { if (MHSd) { - const Init *Val = MHSd->getOperator(); - const Init *Result = EvaluateOperation(RHSo, LHS, Val, - Type, CurRec, CurMultiClass); + Init *Val = MHSd->getOperator(); + Init *Result = EvaluateOperation(RHSo, LHS, Val, + Type, CurRec, CurMultiClass); if (Result != 0) { Val = Result; } - std::vector > args; + std::vector > args; for (unsigned int i = 0; i < MHSd->getNumArgs(); ++i) { - const Init *Arg; + Init *Arg; std::string ArgName; Arg = MHSd->getArg(i); ArgName = MHSd->getArgName(i); // Process args - const Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, - CurRec, CurMultiClass); + Init *Result = EvaluateOperation(RHSo, LHS, Arg, Type, + CurRec, CurMultiClass); if (Result != 0) { Arg = Result; } @@ -1025,17 +843,17 @@ args.push_back(std::make_pair(Arg, ArgName)); } - return DagInit::get(Val, "", args); + return new DagInit(Val, "", args); } if (MHSl) { - std::vector NewOperands; - std::vector NewList(MHSl->begin(), MHSl->end()); + std::vector NewOperands; + std::vector NewList(MHSl->begin(), MHSl->end()); - for (std::vector::iterator li = NewList.begin(), + for (ListInit::iterator li = NewList.begin(), liend = NewList.end(); li != liend; ++li) { - const Init *Item = *li; + Init *Item = *li; NewOperands.clear(); for(int i = 0; i < RHSo->getNumOperands(); ++i) { // First, replace the foreach variable with the list item @@ -1047,33 +865,34 @@ } // Now run the operator and use its result as the new list item - const OpInit *NewOp = RHSo->clone(NewOperands); - const Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); + OpInit *NewOp = RHSo->clone(NewOperands); + Init *NewItem = NewOp->Fold(CurRec, CurMultiClass); if (NewItem != NewOp) { *li = NewItem; + delete NewOp; } } - return ListInit::get(NewList, MHSl->getType()); + return new ListInit(NewList, MHSl->getType()); } } return 0; } -const Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) const { +Init *TernOpInit::Fold(Record *CurRec, MultiClass *CurMultiClass) { switch (getOpcode()) { default: assert(0 && "Unknown binop"); case SUBST: { - const DefInit *LHSd = dynamic_cast(LHS); - const VarInit *LHSv = dynamic_cast(LHS); - const StringInit *LHSs = dynamic_cast(LHS); - - const DefInit *MHSd = dynamic_cast(MHS); - const VarInit *MHSv = dynamic_cast(MHS); - const StringInit *MHSs = dynamic_cast(MHS); - - const DefInit *RHSd = dynamic_cast(RHS); - const VarInit *RHSv = dynamic_cast(RHS); - const StringInit *RHSs = dynamic_cast(RHS); + DefInit *LHSd = dynamic_cast(LHS); + VarInit *LHSv = dynamic_cast(LHS); + StringInit *LHSs = dynamic_cast(LHS); + + DefInit *MHSd = dynamic_cast(MHS); + VarInit *MHSv = dynamic_cast(MHS); + StringInit *MHSs = dynamic_cast(MHS); + + DefInit *RHSd = dynamic_cast(RHS); + VarInit *RHSv = dynamic_cast(RHS); + StringInit *RHSs = dynamic_cast(RHS); if ((LHSd && MHSd && RHSd) || (LHSv && MHSv && RHSv) @@ -1083,14 +902,14 @@ if (LHSd->getAsString() == RHSd->getAsString()) { Val = MHSd->getDef(); } - return DefInit::get(Val); + return new DefInit(Val); } if (RHSv) { std::string Val = RHSv->getName(); if (LHSv->getAsString() == RHSv->getAsString()) { Val = MHSv->getName(); } - return VarInit::get(Val, getType()); + return new VarInit(Val, getType()); } if (RHSs) { std::string Val = RHSs->getValue(); @@ -1105,14 +924,14 @@ idx = found + MHSs->getValue().size(); } while (found != std::string::npos); - return StringInit::get(Val); + return new StringInit(Val); } } break; } case FOREACH: { - const Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), + Init *Result = ForeachHelper(LHS, MHS, RHS, getType(), CurRec, CurMultiClass); if (Result != 0) { return Result; @@ -1121,9 +940,9 @@ } case IF: { - const IntInit *LHSi = dynamic_cast(LHS); - if (const Init *I = LHS->convertInitializerTo(new IntRecTy())) - LHSi = dynamic_cast(I); + IntInit *LHSi = dynamic_cast(LHS); + if (Init *I = LHS->convertInitializerTo(new IntRecTy())) + LHSi = dynamic_cast(I); if (LHSi) { if (LHSi->getValue()) { return MHS; @@ -1138,35 +957,32 @@ return this; } -const Init * -TernOpInit::resolveReferences(Record &R, - const RecordVal *RV) const { - const Init *lhs = LHS->resolveReferences(R, RV); +Init *TernOpInit::resolveReferences(Record &R, const RecordVal *RV) { + Init *lhs = LHS->resolveReferences(R, RV); if (Opc == IF && lhs != LHS) { - const IntInit *Value = dynamic_cast(lhs); - if (const Init *I = lhs->convertInitializerTo(new IntRecTy())) - Value = dynamic_cast(I); + IntInit *Value = dynamic_cast(lhs); + if (Init *I = lhs->convertInitializerTo(new IntRecTy())) + Value = dynamic_cast(I); if (Value != 0) { // Short-circuit if (Value->getValue()) { - const Init *mhs = MHS->resolveReferences(R, RV); - return (TernOpInit::get(getOpcode(), lhs, mhs, - RHS, getType()))->Fold(&R, 0); + Init *mhs = MHS->resolveReferences(R, RV); + return (new TernOpInit(getOpcode(), lhs, mhs, + RHS, getType()))->Fold(&R, 0); } else { - const Init *rhs = RHS->resolveReferences(R, RV); - return (TernOpInit::get(getOpcode(), lhs, MHS, - rhs, getType()))->Fold(&R, 0); + Init *rhs = RHS->resolveReferences(R, RV); + return (new TernOpInit(getOpcode(), lhs, MHS, + rhs, getType()))->Fold(&R, 0); } } } - const Init *mhs = MHS->resolveReferences(R, RV); - const Init *rhs = RHS->resolveReferences(R, RV); + Init *mhs = MHS->resolveReferences(R, RV); + Init *rhs = RHS->resolveReferences(R, RV); if (LHS != lhs || MHS != mhs || RHS != rhs) - return (TernOpInit::get(getOpcode(), lhs, mhs, rhs, getType()))-> - Fold(&R, 0); + return (new TernOpInit(getOpcode(), lhs, mhs, rhs, getType()))->Fold(&R, 0); return Fold(&R, 0); } @@ -1192,97 +1008,79 @@ return 0; } -const Init * -TypedInit::convertInitializerBitRange(const std::vector &Bits) const { +Init *TypedInit::convertInitializerBitRange(const std::vector &Bits) { BitsRecTy *T = dynamic_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-bits variable. unsigned NumBits = T->getNumBits(); - SmallVector NewBits(Bits.size()); + BitsInit *BI = new BitsInit(Bits.size()); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { if (Bits[i] >= NumBits) { + delete BI; return 0; } - NewBits[i] = VarBitInit::get(this, Bits[i]); + BI->setBit(i, new VarBitInit(this, Bits[i])); } - return BitsInit::get(NewBits.begin(), NewBits.end()); + return BI; } -const Init * -TypedInit::convertInitListSlice(const std::vector &Elements) const { +Init *TypedInit::convertInitListSlice(const std::vector &Elements) { ListRecTy *T = dynamic_cast(getType()); if (T == 0) return 0; // Cannot subscript a non-list variable. if (Elements.size() == 1) - return VarListElementInit::get(this, Elements[0]); + return new VarListElementInit(this, Elements[0]); - std::vector ListInits; + std::vector ListInits; ListInits.reserve(Elements.size()); for (unsigned i = 0, e = Elements.size(); i != e; ++i) - ListInits.push_back(VarListElementInit::get(this, Elements[i])); - return ListInit::get(ListInits, T); + ListInits.push_back(new VarListElementInit(this, Elements[i])); + return new ListInit(ListInits, T); } -const VarInit *VarInit::get(const std::string &VN, RecTy *T) { - FoldingSetNodeID ID; - ID.AddInteger(initVar); - ID.AddString(VN); - ID.AddString(T->getAsString()); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - VarInit *I = InitAllocator.Allocate(); - new (I) VarInit(ID, VN, T); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, - unsigned Bit) const { +Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV, + unsigned Bit) { if (R.isTemplateArg(getName())) return 0; if (IRV && IRV->getName() != getName()) return 0; RecordVal *RV = R.getValue(getName()); assert(RV && "Reference to a non-existent variable?"); - assert(dynamic_cast(RV->getValue())); - const BitsInit *BI = (const BitsInit*)RV->getValue(); + assert(dynamic_cast(RV->getValue())); + BitsInit *BI = (BitsInit*)RV->getValue(); assert(Bit < BI->getNumBits() && "Bit reference out of range!"); - const Init *B = BI->getBit(Bit); + Init *B = BI->getBit(Bit); // If the bit is set to some value, or if we are resolving a reference to a // specific variable and that variable is explicitly unset, then replace the // VarBitInit with it. - if (IRV || !dynamic_cast(B)) + if (IRV || !dynamic_cast(B)) return B; return 0; } -const Init *VarInit::resolveListElementReference(Record &R, - const RecordVal *IRV, - unsigned Elt) const { +Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV, + unsigned Elt) { if (R.isTemplateArg(getName())) return 0; if (IRV && IRV->getName() != getName()) return 0; RecordVal *RV = R.getValue(getName()); assert(RV && "Reference to a non-existent variable?"); - const ListInit *LI = dynamic_cast(RV->getValue()); + ListInit *LI = dynamic_cast(RV->getValue()); if (!LI) { - const VarInit *VI = dynamic_cast(RV->getValue()); + VarInit *VI = dynamic_cast(RV->getValue()); assert(VI && "Invalid list element!"); - return VarListElementInit::get(VI, Elt); + return new VarListElementInit(VI, Elt); } if (Elt >= LI->getSize()) return 0; // Out of range reference. - const Init *E = LI->getElement(Elt); + Init *E = LI->getElement(Elt); // If the element is set to some value, or if we are resolving a reference // to a specific variable and that variable is explicitly unset, then // replace the VarListElementInit with it. - if (IRV || !dynamic_cast(E)) + if (IRV || !dynamic_cast(E)) return E; return 0; } @@ -1295,15 +1093,15 @@ return 0; } -const Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { +Init *VarInit::getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { if (dynamic_cast(getType())) if (const RecordVal *Val = R.getValue(VarName)) { - if (RV != Val && (RV || dynamic_cast(Val->getValue()))) + if (RV != Val && (RV || dynamic_cast(Val->getValue()))) return 0; - const Init *TheInit = Val->getValue(); + Init *TheInit = Val->getValue(); assert(TheInit != this && "Infinite loop detected!"); - if (const Init *I = TheInit->getFieldInit(R, RV, FieldName)) + if (Init *I = TheInit->getFieldInit(R, RV, FieldName)) return I; else return 0; @@ -1316,112 +1114,56 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// -const Init *VarInit::resolveReferences(Record &R, - const RecordVal *RV) const { +Init *VarInit::resolveReferences(Record &R, const RecordVal *RV) { if (RecordVal *Val = R.getValue(VarName)) - if (RV == Val || (RV == 0 - && !dynamic_cast(Val->getValue()))) + if (RV == Val || (RV == 0 && !dynamic_cast(Val->getValue()))) return Val->getValue(); return this; } -const VarBitInit *VarBitInit::get(const TypedInit *T, unsigned B) { - FoldingSetNodeID ID; - ID.AddInteger(initVarBit); - ID.AddPointer(T); - ID.AddInteger(B); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - VarBitInit *I = InitAllocator.Allocate(); - new (I) VarBitInit(ID, T, B); - UniqueInits.InsertNode(I, IP); - return I; -} - std::string VarBitInit::getAsString() const { return TI->getAsString() + "{" + utostr(Bit) + "}"; } -const Init * -VarBitInit::resolveReferences(Record &R, - const RecordVal *RV) const { - if (const Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) +Init *VarBitInit::resolveReferences(Record &R, const RecordVal *RV) { + if (Init *I = getVariable()->resolveBitReference(R, RV, getBitNum())) return I; return this; } -const VarListElementInit *VarListElementInit::get(const TypedInit *T, - unsigned E) { - FoldingSetNodeID ID; - ID.AddInteger(initVarListElement); - ID.AddPointer(T); - ID.AddInteger(E); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - VarListElementInit *I = InitAllocator.Allocate(); - new (I) VarListElementInit(ID, T, E); - UniqueInits.InsertNode(I, IP); - return I; -} - std::string VarListElementInit::getAsString() const { return TI->getAsString() + "[" + utostr(Element) + "]"; } -const Init *VarListElementInit::resolveReferences(Record &R, - const RecordVal *RV) const { - if (const Init *I = - getVariable()->resolveListElementReference(R, RV, getElementNum())) +Init *VarListElementInit::resolveReferences(Record &R, const RecordVal *RV) { + if (Init *I = getVariable()->resolveListElementReference(R, RV, + getElementNum())) return I; return this; } -const Init *VarListElementInit::resolveBitReference(Record &R, - const RecordVal *RV, - unsigned Bit) const { +Init *VarListElementInit::resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { // FIXME: This should be implemented, to support references like: // bit B = AA[0]{1}; return 0; } -const Init * -VarListElementInit::resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { +Init *VarListElementInit:: +resolveListElementReference(Record &R, const RecordVal *RV, unsigned Elt) { // FIXME: This should be implemented, to support references like: // int B = AA[0][1]; return 0; } -const DefInit *DefInit::get(Record *D) { - FoldingSetNodeID ID; - ID.AddInteger(initDef); - ID.AddString(D->getName()); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - DefInit *I = InitAllocator.Allocate(); - new (I) DefInit(ID, D); - UniqueInits.InsertNode(I, IP); - return I; -} - RecTy *DefInit::getFieldType(const std::string &FieldName) const { if (const RecordVal *RV = Def->getValue(FieldName)) return RV->getType(); return 0; } -const Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { +Init *DefInit::getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { return Def->getValue(FieldName)->getValue(); } @@ -1430,134 +1172,59 @@ return Def->getName(); } -const FieldInit *FieldInit::get(const Init *R, const std::string &FN) { - FoldingSetNodeID ID; - ID.AddInteger(initField); - ID.AddPointer(R); - ID.AddString(FN); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - FieldInit *I = InitAllocator.Allocate(); - new (I) FieldInit(ID, R, FN); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { - if (const Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) - if (const BitsInit *BI = dynamic_cast(BitsVal)) { +Init *FieldInit::resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { + if (Init *BitsVal = Rec->getFieldInit(R, RV, FieldName)) + if (BitsInit *BI = dynamic_cast(BitsVal)) { assert(Bit < BI->getNumBits() && "Bit reference out of range!"); - const Init *B = BI->getBit(Bit); + Init *B = BI->getBit(Bit); - if (dynamic_cast(B)) // If the bit is set. + if (dynamic_cast(B)) // If the bit is set. return B; // Replace the VarBitInit with it. } return 0; } -const Init *FieldInit::resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { - if (const Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) - if (const ListInit *LI = dynamic_cast(ListVal)) { +Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) { + if (Init *ListVal = Rec->getFieldInit(R, RV, FieldName)) + if (ListInit *LI = dynamic_cast(ListVal)) { if (Elt >= LI->getSize()) return 0; - const Init *E = LI->getElement(Elt); + Init *E = LI->getElement(Elt); // If the element is set to some value, or if we are resolving a // reference to a specific variable and that variable is explicitly // unset, then replace the VarListElementInit with it. - if (RV || !dynamic_cast(E)) + if (RV || !dynamic_cast(E)) return E; } return 0; } -const Init *FieldInit::resolveReferences(Record &R, - const RecordVal *RV) const { - const Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; +Init *FieldInit::resolveReferences(Record &R, const RecordVal *RV) { + Init *NewRec = RV ? Rec->resolveReferences(R, RV) : Rec; - const Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); + Init *BitsVal = NewRec->getFieldInit(R, RV, FieldName); if (BitsVal) { - const Init *BVR = BitsVal->resolveReferences(R, RV); + Init *BVR = BitsVal->resolveReferences(R, RV); return BVR->isComplete() ? BVR : this; } if (NewRec != Rec) { - return FieldInit::get(NewRec, FieldName); + return new FieldInit(NewRec, FieldName); } return this; } -const DagInit * -DagInit::get(const Init *V, const std::string &VN, - const std::vector > &args) { - FoldingSetNodeID ID; - ID.AddInteger(initDag); - ID.AddPointer(V); - ID.AddString(VN); - - for (std::vector >::const_iterator a - = args.begin(), - aend = args.end(); - a != aend; - ++a) { - ID.AddPointer(a->first); - ID.AddString(a->second); - } - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - DagInit *I = InitAllocator.Allocate(); - new (I) DagInit(ID, V, VN, args); - UniqueInits.InsertNode(I, IP); - return I; -} - -const DagInit * -DagInit::get(const Init *V, const std::string &VN, - const std::vector &args, - const std::vector &argNames) { - FoldingSetNodeID ID; - ID.AddInteger(initDag); - ID.AddPointer(V); - ID.AddString(VN); - - std::vector::const_iterator s = argNames.begin(); - for (std::vector::const_iterator a - = args.begin(), - aend = args.end(); - a != aend; - ++a, ++s) { - ID.AddPointer(*a); - ID.AddString(*s); - } - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - DagInit *I = InitAllocator.Allocate(); - new (I) DagInit(ID, V, VN, args, argNames); - UniqueInits.InsertNode(I, IP); - return I; -} - -const Init *DagInit::resolveReferences(Record &R, - const RecordVal *RV) const { - std::vector NewArgs; +Init *DagInit::resolveReferences(Record &R, const RecordVal *RV) { + std::vector NewArgs; for (unsigned i = 0, e = Args.size(); i != e; ++i) NewArgs.push_back(Args[i]->resolveReferences(R, RV)); - const Init *Op = Val->resolveReferences(R, RV); + Init *Op = Val->resolveReferences(R, RV); if (Args != NewArgs || Op != Val) - return DagInit::get(Op, ValName, NewArgs, ArgNames); + return new DagInit(Op, ValName, NewArgs, ArgNames); return this; } @@ -1585,7 +1252,7 @@ RecordVal::RecordVal(const std::string &N, RecTy *T, unsigned P) : Name(N), Ty(T), Prefix(P) { - Value = Ty->convertValue(UnsetInit::get()); + Value = Ty->convertValue(new UnsetInit()); assert(Value && "Cannot create unset value for current type!"); } @@ -1620,7 +1287,7 @@ /// references. void Record::resolveReferencesTo(const RecordVal *RV) { for (unsigned i = 0, e = Values.size(); i != e; ++i) { - if (const Init *V = Values[i].getValue()) + if (Init *V = Values[i].getValue()) Values[i].setValue(V->resolveReferences(*this, RV)); } } @@ -1665,7 +1332,7 @@ /// getValueInit - Return the initializer for a value with the specified name, /// or throw an exception if the field does not exist. /// -const Init *Record::getValueInit(StringRef FieldName) const { +Init *Record::getValueInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + @@ -1694,13 +1361,13 @@ /// its value as a BitsInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// -const BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { +BitsInit *Record::getValueAsBitsInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const BitsInit *BI = dynamic_cast(R->getValue())) + if (BitsInit *BI = dynamic_cast(R->getValue())) return BI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a BitsInit initializer!"; @@ -1710,13 +1377,13 @@ /// its value as a ListInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// -const ListInit *Record::getValueAsListInit(StringRef FieldName) const { +ListInit *Record::getValueAsListInit(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const ListInit *LI = dynamic_cast(R->getValue())) + if (ListInit *LI = dynamic_cast(R->getValue())) return LI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a list initializer!"; @@ -1728,10 +1395,10 @@ /// std::vector Record::getValueAsListOfDefs(StringRef FieldName) const { - const ListInit *List = getValueAsListInit(FieldName); + ListInit *List = getValueAsListInit(FieldName); std::vector Defs; for (unsigned i = 0; i < List->getSize(); i++) { - if (const DefInit *DI = dynamic_cast(List->getElement(i))) { + if (DefInit *DI = dynamic_cast(List->getElement(i))) { Defs.push_back(DI->getDef()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1751,7 +1418,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const IntInit *II = dynamic_cast(R->getValue())) + if (IntInit *II = dynamic_cast(R->getValue())) return II->getValue(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have an int initializer!"; @@ -1763,10 +1430,10 @@ /// std::vector Record::getValueAsListOfInts(StringRef FieldName) const { - const ListInit *List = getValueAsListInit(FieldName); + ListInit *List = getValueAsListInit(FieldName); std::vector Ints; for (unsigned i = 0; i < List->getSize(); i++) { - if (const IntInit *II = dynamic_cast(List->getElement(i))) { + if (IntInit *II = dynamic_cast(List->getElement(i))) { Ints.push_back(II->getValue()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1782,11 +1449,10 @@ /// std::vector Record::getValueAsListOfStrings(StringRef FieldName) const { - const ListInit *List = getValueAsListInit(FieldName); + ListInit *List = getValueAsListInit(FieldName); std::vector Strings; for (unsigned i = 0; i < List->getSize(); i++) { - if (const StringInit *II = - dynamic_cast(List->getElement(i))) { + if (StringInit *II = dynamic_cast(List->getElement(i))) { Strings.push_back(II->getValue()); } else { throw "Record `" + getName() + "', field `" + FieldName.str() + @@ -1806,7 +1472,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const DefInit *DI = dynamic_cast(R->getValue())) + if (DefInit *DI = dynamic_cast(R->getValue())) return DI->getDef(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a def initializer!"; @@ -1822,7 +1488,7 @@ throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const BitInit *BI = dynamic_cast(R->getValue())) + if (BitInit *BI = dynamic_cast(R->getValue())) return BI->getValue(); throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a bit initializer!"; @@ -1832,13 +1498,13 @@ /// value as an Dag, throwing an exception if the field does not exist or if /// the value is not the right type. /// -const DagInit *Record::getValueAsDag(StringRef FieldName) const { +DagInit *Record::getValueAsDag(StringRef FieldName) const { const RecordVal *R = getValue(FieldName); if (R == 0 || R->getValue() == 0) throw "Record `" + getName() + "' does not have a field named `" + FieldName.str() + "'!\n"; - if (const DagInit *DI = dynamic_cast(R->getValue())) + if (DagInit *DI = dynamic_cast(R->getValue())) return DI; throw "Record `" + getName() + "', field `" + FieldName.str() + "' does not have a dag initializer!"; Modified: llvm/trunk/utils/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/Record.h (original) +++ llvm/trunk/utils/TableGen/Record.h Mon Jul 11 18:06:52 2011 @@ -15,8 +15,6 @@ #ifndef RECORD_H #define RECORD_H -#include "llvm/ADT/FoldingSet.h" -#include "llvm/Support/Allocator.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/raw_ostream.h" @@ -36,7 +34,7 @@ class RecordRecTy; // Init subclasses. -class Init; +struct Init; class UnsetInit; class BitInit; class BitsInit; @@ -77,31 +75,31 @@ virtual bool typeIsConvertibleTo(const RecTy *RHS) const = 0; public: // These methods should only be called from subclasses of Init - virtual const Init *convertValue(const UnsetInit *UI) { return 0; } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return convertValue((const TypedInit*)UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return convertValue((const TypedInit*)UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return convertValue((const TypedInit*)UI); - } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const TypedInit *TI) { return 0; } - virtual const Init *convertValue(const VarInit *VI) { - return convertValue((const TypedInit*)VI); + virtual Init *convertValue( UnsetInit *UI) { return 0; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { + return convertValue((TypedInit*)UI); + } + virtual Init *convertValue( BinOpInit *UI) { + return convertValue((TypedInit*)UI); + } + virtual Init *convertValue( TernOpInit *UI) { + return convertValue((TypedInit*)UI); + } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( TypedInit *TI) { return 0; } + virtual Init *convertValue( VarInit *VI) { + return convertValue((TypedInit*)VI); } - virtual const Init *convertValue(const FieldInit *FI) { - return convertValue((const TypedInit*)FI); + virtual Init *convertValue( FieldInit *FI) { + return convertValue((TypedInit*)FI); } public: // These methods should only be called by subclasses of RecTy. @@ -127,38 +125,22 @@ /// class BitRecTy : public RecTy { public: - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { - return (const Init*)BI; - } - virtual const Init *convertValue(const BitsInit *BI); - virtual const Init *convertValue(const IntInit *II); - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { - return (const Init*)VB; - } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return (Init*)BI; } + virtual Init *convertValue( BitsInit *BI); + virtual Init *convertValue( IntInit *II); + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return (Init*)VB; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const { return "bit"; } @@ -187,32 +169,22 @@ unsigned getNumBits() const { return Size; } - virtual const Init *convertValue(const UnsetInit *UI); - virtual const Init *convertValue(const BitInit *UI); - virtual const Init *convertValue(const BitsInit *BI); - virtual const Init *convertValue(const IntInit *II); - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI); + virtual Init *convertValue( BitInit *UI); + virtual Init *convertValue( BitsInit *BI); + virtual Init *convertValue( IntInit *II); + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const; @@ -237,36 +209,22 @@ /// class IntRecTy : public RecTy { public: - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI); - virtual const Init *convertValue(const BitsInit *BI); - virtual const Init *convertValue(const IntInit *II) { - return (const Init*)II; - } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI); + virtual Init *convertValue( BitsInit *BI); + virtual Init *convertValue( IntInit *II) { return (Init*)II; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const { return "int"; } @@ -289,33 +247,23 @@ /// class StringRecTy : public RecTy { public: - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { - return (const Init*)SI; - } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const UnOpInit *BO); - virtual const Init *convertValue(const BinOpInit *BO); - virtual const Init *convertValue(const TernOpInit *BO) { - return RecTy::convertValue(BO); - } - - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return (Init*)SI; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( UnOpInit *BO); + virtual Init *convertValue( BinOpInit *BO); + virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} + + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const { return "string"; } @@ -345,34 +293,22 @@ RecTy *getElementType() const { return Ty; } - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI); - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI); + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const; @@ -396,36 +332,22 @@ /// class CodeRecTy : public RecTy { public: - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { - return (const Init*)CI; - } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return (Init*)CI; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const { return "code"; } @@ -446,32 +368,22 @@ /// class DagRecTy : public RecTy { public: - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const DefInit *DI) { return 0; } - virtual const Init *convertValue(const UnOpInit *BO); - virtual const Init *convertValue(const BinOpInit *BO); - virtual const Init *convertValue(const TernOpInit *BO) { - return RecTy::convertValue(BO); - } - virtual const Init *convertValue(const DagInit *CI) { - return (const Init*)CI; - } - virtual const Init *convertValue(const TypedInit *TI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( DefInit *DI) { return 0; } + virtual Init *convertValue( UnOpInit *BO); + virtual Init *convertValue( BinOpInit *BO); + virtual Init *convertValue( TernOpInit *BO) { return RecTy::convertValue(BO);} + virtual Init *convertValue( DagInit *CI) { return (Init*)CI; } + virtual Init *convertValue( TypedInit *TI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const { return "dag"; } @@ -500,34 +412,22 @@ Record *getRecord() const { return Rec; } - virtual const Init *convertValue(const UnsetInit *UI) { - return (const Init*)UI; - } - virtual const Init *convertValue(const BitInit *BI) { return 0; } - virtual const Init *convertValue(const BitsInit *BI) { return 0; } - virtual const Init *convertValue(const IntInit *II) { return 0; } - virtual const Init *convertValue(const StringInit *SI) { return 0; } - virtual const Init *convertValue(const ListInit *LI) { return 0; } - virtual const Init *convertValue(const CodeInit *CI) { return 0; } - virtual const Init *convertValue(const VarBitInit *VB) { return 0; } - virtual const Init *convertValue(const UnOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const BinOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const TernOpInit *UI) { - return RecTy::convertValue(UI); - } - virtual const Init *convertValue(const DefInit *DI); - virtual const Init *convertValue(const DagInit *DI) { return 0; } - virtual const Init *convertValue(const TypedInit *VI); - virtual const Init *convertValue(const VarInit *VI) { - return RecTy::convertValue(VI); - } - virtual const Init *convertValue(const FieldInit *FI) { - return RecTy::convertValue(FI); - } + virtual Init *convertValue( UnsetInit *UI) { return (Init*)UI; } + virtual Init *convertValue( BitInit *BI) { return 0; } + virtual Init *convertValue( BitsInit *BI) { return 0; } + virtual Init *convertValue( IntInit *II) { return 0; } + virtual Init *convertValue(StringInit *SI) { return 0; } + virtual Init *convertValue( ListInit *LI) { return 0; } + virtual Init *convertValue( CodeInit *CI) { return 0; } + virtual Init *convertValue(VarBitInit *VB) { return 0; } + virtual Init *convertValue( UnOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( BinOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( TernOpInit *UI) { return RecTy::convertValue(UI);} + virtual Init *convertValue( DefInit *DI); + virtual Init *convertValue( DagInit *DI) { return 0; } + virtual Init *convertValue( TypedInit *VI); + virtual Init *convertValue( VarInit *VI) { return RecTy::convertValue(VI);} + virtual Init *convertValue( FieldInit *FI) { return RecTy::convertValue(FI);} std::string getAsString() const; @@ -553,43 +453,9 @@ // Initializer Classes //===----------------------------------------------------------------------===// -class Init : public FastFoldingSetNode { - Init(const Init &); // Do not define. - Init &operator=(const Init &); // Do not define. - -protected: - Init(const FoldingSetNodeID &ID) : FastFoldingSetNode(ID) {} - - static FoldingSet UniqueInits; - static BumpPtrAllocator InitAllocator; - - enum Type { - initUnset, - initBit, - initBits, - initInt, - initString, - initCode, - initList, - initUnOp, - initBinOp, - initTernOp, - initQuadOp, - initVar, - initVarBit, - initVarListElement, - initDef, - initField, - initDag - }; - -public: +struct Init { virtual ~Init() {} - static void ReleaseMemory() { - InitAllocator.Reset(); - } - /// isComplete - This virtual method should be overridden by values that may /// not be completely specified yet. virtual bool isComplete() const { return true; } @@ -608,15 +474,14 @@ /// function that should be overridden to call the appropriate /// RecTy::convertValue method. /// - virtual const Init *convertInitializerTo(RecTy *Ty) const = 0; + virtual Init *convertInitializerTo(RecTy *Ty) = 0; /// convertInitializerBitRange - This method is used to implement the bitrange /// selection operator. Given an initializer, it selects the specified bits /// out, returning them as a new init of bits type. If it is not legal to use /// the bit subscript operator on this initializer, return null. /// - virtual const Init * - convertInitializerBitRange(const std::vector &Bits) const { + virtual Init *convertInitializerBitRange(const std::vector &Bits) { return 0; } @@ -625,8 +490,7 @@ /// elements, returning them as a new init of list type. If it is not legal /// to take a slice of this, return null. /// - virtual const Init * - convertInitListSlice(const std::vector &Elements) const { + virtual Init *convertInitListSlice(const std::vector &Elements) { return 0; } @@ -640,8 +504,8 @@ /// initializer for the specified field. If getFieldType returns non-null /// this method should return non-null, otherwise it returns null. /// - virtual const Init *getFieldInit(Record &R, const RecordVal *RV, - const std::string &FieldName) const { + virtual Init *getFieldInit(Record &R, const RecordVal *RV, + const std::string &FieldName) const { return 0; } @@ -650,8 +514,7 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const { + virtual Init *resolveReferences(Record &R, const RecordVal *RV) { return this; } }; @@ -665,20 +528,13 @@ /// class TypedInit : public Init { RecTy *Ty; - - TypedInit(const TypedInit &Other); // Do not define. - TypedInit &operator=(const TypedInit &Other); // Do not define. - -protected: - explicit TypedInit(const FoldingSetNodeID &ID, RecTy *T) : Init(ID), Ty(T) {} - public: + explicit TypedInit(RecTy *T) : Ty(T) {} + RecTy *getType() const { return Ty; } - virtual const Init * - convertInitializerBitRange(const std::vector &Bits) const; - virtual const Init * - convertInitListSlice(const std::vector &Elements) const; + virtual Init *convertInitializerBitRange(const std::vector &Bits); + virtual Init *convertInitListSlice(const std::vector &Elements); /// getFieldType - This method is used to implement the FieldInit class. /// Implementors of this method should return the type of the named field if @@ -690,29 +546,22 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const = 0; + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) = 0; /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const = 0; + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) = 0; }; /// UnsetInit - ? - Represents an uninitialized value /// class UnsetInit : public Init { - UnsetInit(const FoldingSetNodeID &ID) : Init(ID) {} - UnsetInit(const UnsetInit &); // Do not define. - UnsetInit &operator=(const UnsetInit &Other); // Do not define. - public: - static const UnsetInit *get(); - - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } @@ -725,17 +574,12 @@ /// class BitInit : public Init { bool Value; - - explicit BitInit(const FoldingSetNodeID &ID, bool V) : Init(ID), Value(V) {} - BitInit(const BitInit &Other); // Do not define. - BitInit &operator=(BitInit &Other); // Do not define. - public: - static const BitInit *get(bool V); + explicit BitInit(bool V) : Value(V) {} bool getValue() const { return Value; } - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } @@ -746,56 +590,26 @@ /// It contains a vector of bits, whose size is determined by the type. /// class BitsInit : public Init { - std::vector Bits; - - BitsInit(const FoldingSetNodeID &ID, unsigned Size) - : Init(ID), Bits(Size) {} - - template - BitsInit(const FoldingSetNodeID &ID, InputIterator start, InputIterator end) - : Init(ID), Bits(start, end) {} - - BitsInit(const BitsInit &Other); // Do not define. - BitsInit &operator=(const BitsInit &Other); // Do not define. - + std::vector Bits; public: - template - static const BitsInit *get(InputIterator Start, InputIterator End) { - FoldingSetNodeID ID; - ID.AddInteger(initBits); - ID.AddInteger(std::distance(Start, End)); - - InputIterator S = Start; - while (S != End) - ID.AddPointer(*S++); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - BitsInit *I = InitAllocator.Allocate(); - new (I) BitsInit(ID, Start, End); - UniqueInits.InsertNode(I, IP); - return I; - } + explicit BitsInit(unsigned Size) : Bits(Size) {} unsigned getNumBits() const { return Bits.size(); } - const Init *getBit(unsigned Bit) const { + Init *getBit(unsigned Bit) const { assert(Bit < Bits.size() && "Bit index out of range!"); return Bits[Bit]; } - void setBit(unsigned Bit, const Init *V) { + void setBit(unsigned Bit, Init *V) { assert(Bit < Bits.size() && "Bit index out of range!"); assert(Bits[Bit] == 0 && "Bit already set!"); Bits[Bit] = V; } - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - virtual const Init * - convertInitializerBitRange(const std::vector &Bits) const; + virtual Init *convertInitializerBitRange(const std::vector &Bits); virtual bool isComplete() const { for (unsigned i = 0; i != getNumBits(); ++i) @@ -809,8 +623,7 @@ } virtual std::string getAsString() const; - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); }; @@ -818,23 +631,15 @@ /// class IntInit : public TypedInit { int64_t Value; - - explicit IntInit(const FoldingSetNodeID &ID, int64_t V) - : TypedInit(ID, new IntRecTy), Value(V) {} - - IntInit(const IntInit &Other); // Do not define. - IntInit &operator=(const IntInit &Other); // Do note define. - public: - static const IntInit *get(int64_t V); + explicit IntInit(int64_t V) : TypedInit(new IntRecTy), Value(V) {} int64_t getValue() const { return Value; } - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - virtual const Init * - convertInitializerBitRange(const std::vector &Bits) const; + virtual Init *convertInitializerBitRange(const std::vector &Bits); virtual std::string getAsString() const; @@ -842,8 +647,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { assert(0 && "Illegal bit reference off int"); return 0; } @@ -851,9 +656,8 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) { assert(0 && "Illegal element reference off int"); return 0; } @@ -864,19 +668,13 @@ /// class StringInit : public TypedInit { std::string Value; - - explicit StringInit(const FoldingSetNodeID &ID, const std::string &V) - : TypedInit(ID, new StringRecTy), Value(V) {} - - StringInit(const StringInit &Other); // Do not define. - StringInit &operator=(const StringInit &Other); // Do not define. - public: - static const StringInit *get(const std::string &V); + explicit StringInit(const std::string &V) + : TypedInit(new StringRecTy), Value(V) {} const std::string &getValue() const { return Value; } - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } @@ -886,8 +684,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { assert(0 && "Illegal bit reference off string"); return 0; } @@ -895,9 +693,8 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) { assert(0 && "Illegal element reference off string"); return 0; } @@ -907,19 +704,12 @@ /// class CodeInit : public Init { std::string Value; - - explicit CodeInit(const FoldingSetNodeID &ID, const std::string &V) - : Init(ID), Value(V) {} - - CodeInit(const CodeInit &Other); // Do not define. - CodeInit &operator=(const CodeInit &Other); // Do not define. - public: - static const CodeInit *get(const std::string &V); + explicit CodeInit(const std::string &V) : Value(V) {} const std::string &getValue() const { return Value; } - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } @@ -929,61 +719,29 @@ /// ListInit - [AL, AH, CL] - Represent a list of defs /// class ListInit : public TypedInit { - std::vector Values; - + std::vector Values; public: - typedef std::vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; -private: - ListInit(const FoldingSetNodeID &ID, std::vector &Vs, - RecTy *EltTy) - : TypedInit(ID, new ListRecTy(EltTy)) { + explicit ListInit(std::vector &Vs, RecTy *EltTy) + : TypedInit(new ListRecTy(EltTy)) { Values.swap(Vs); } - - template - ListInit(const FoldingSetNodeID &ID, InputIterator Start, InputIterator End, - RecTy *EltTy) - : TypedInit(ID, new ListRecTy(EltTy)), Values(Start, End) {} - - ListInit(const ListInit &Other); // Do not define. - ListInit &operator=(const ListInit &Other); // Do not define. - -public: - static const ListInit *get(std::vector &Vs, RecTy *EltTy); - - template - static const ListInit *get(InputIterator Start, InputIterator End, - RecTy *EltTy) { - FoldingSetNodeID ID; - ID.AddInteger(initList); - ID.AddString(EltTy->getAsString()); - - InputIterator S = Start; - while (S != End) - ID.AddPointer(*S++); - - void *IP = 0; - if (const Init *I = UniqueInits.FindNodeOrInsertPos(ID, IP)) - return static_cast(I); - - ListInit *I = InitAllocator.Allocate(); - new (I) ListInit(ID, Start, End, EltTy); - UniqueInits.InsertNode(I, IP); - return I; - } + explicit ListInit(iterator Start, iterator End, RecTy *EltTy) + : TypedInit(new ListRecTy(EltTy)), Values(Start, End) {} unsigned getSize() const { return Values.size(); } - const Init *getElement(unsigned i) const { + Init *getElement(unsigned i) const { assert(i < Values.size() && "List element index out of range!"); return Values[i]; } Record *getElementAsRecord(unsigned i) const; - const Init *convertInitListSlice(const std::vector &Elements) const; + Init *convertInitListSlice(const std::vector &Elements); - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } @@ -992,12 +750,13 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const; + inline iterator begin() { return Values.begin(); } inline const_iterator begin() const { return Values.begin(); } + inline iterator end () { return Values.end(); } inline const_iterator end () const { return Values.end(); } inline size_t size () const { return Values.size(); } @@ -1007,8 +766,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { assert(0 && "Illegal bit reference off list"); return 0; } @@ -1016,42 +775,35 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const; + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt); }; /// OpInit - Base class for operators /// class OpInit : public TypedInit { - OpInit(const OpInit &Other); // Do not define. - OpInit &operator=(OpInit &Other); // Do not define. - -protected: - explicit OpInit(const FoldingSetNodeID &ID, RecTy *Type) - : TypedInit(ID, Type) {} - public: + OpInit(RecTy *Type) : TypedInit(Type) {} + // Clone - Clone this operator, replacing arguments with the new list - virtual const OpInit *clone(std::vector &Operands) const = 0; + virtual OpInit *clone(std::vector &Operands) = 0; virtual int getNumOperands() const = 0; - virtual const Init *getOperand(int i) const = 0; + virtual Init *getOperand(int i) = 0; // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - virtual const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const = 0; + virtual Init *Fold(Record *CurRec, MultiClass *CurMultiClass) = 0; - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const; - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const; + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit); + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt); }; @@ -1062,40 +814,33 @@ enum UnaryOp { CAST, HEAD, TAIL, EMPTY }; private: UnaryOp Opc; - const Init *LHS; - - UnOpInit(const FoldingSetNodeID &ID, UnaryOp opc, const Init *lhs, - RecTy *Type) - : OpInit(ID, Type), Opc(opc), LHS(lhs) {} - - UnOpInit(const UnOpInit &Other); // Do not define. - UnOpInit &operator=(const UnOpInit &Other); // Do not define. - + Init *LHS; public: - static const UnOpInit *get(UnaryOp opc, const Init *lhs, RecTy *Type); + UnOpInit(UnaryOp opc, Init *lhs, RecTy *Type) : + OpInit(Type), Opc(opc), LHS(lhs) { + } // Clone - Clone this operator, replacing arguments with the new list - virtual const OpInit *clone(std::vector &Operands) const { + virtual OpInit *clone(std::vector &Operands) { assert(Operands.size() == 1 && "Wrong number of operands for unary operation"); - return UnOpInit::get(getOpcode(), *Operands.begin(), getType()); + return new UnOpInit(getOpcode(), *Operands.begin(), getType()); } int getNumOperands() const { return 1; } - const Init *getOperand(int i) const { + Init *getOperand(int i) { assert(i == 0 && "Invalid operand id for unary operator"); return getOperand(); } UnaryOp getOpcode() const { return Opc; } - const Init *getOperand() const { return LHS; } + Init *getOperand() const { return LHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - const Init *Fold(Record *CurRec, MultiClass *CurMultiClass)const ; + Init *Fold(Record *CurRec, MultiClass *CurMultiClass); - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const; }; @@ -1107,28 +852,21 @@ enum BinaryOp { SHL, SRA, SRL, STRCONCAT, CONCAT, EQ }; private: BinaryOp Opc; - const Init *LHS, *RHS; - - BinOpInit(const FoldingSetNodeID &ID, BinaryOp opc, const Init *lhs, - const Init *rhs, RecTy *Type) : - OpInit(ID, Type), Opc(opc), LHS(lhs), RHS(rhs) {} - - BinOpInit(const BinOpInit &Other); // Do not define. - BinOpInit &operator=(const BinOpInit &Other); // Do not define. - + Init *LHS, *RHS; public: - static const BinOpInit *get(BinaryOp opc, const Init *lhs, const Init *rhs, - RecTy *Type); + BinOpInit(BinaryOp opc, Init *lhs, Init *rhs, RecTy *Type) : + OpInit(Type), Opc(opc), LHS(lhs), RHS(rhs) { + } // Clone - Clone this operator, replacing arguments with the new list - virtual const OpInit *clone(std::vector &Operands) const { + virtual OpInit *clone(std::vector &Operands) { assert(Operands.size() == 2 && "Wrong number of operands for binary operation"); - return BinOpInit::get(getOpcode(), Operands[0], Operands[1], getType()); + return new BinOpInit(getOpcode(), Operands[0], Operands[1], getType()); } int getNumOperands() const { return 2; } - const Init *getOperand(int i) const { + Init *getOperand(int i) { assert((i == 0 || i == 1) && "Invalid operand id for binary operator"); if (i == 0) { return getLHS(); @@ -1138,15 +876,14 @@ } BinaryOp getOpcode() const { return Opc; } - const Init *getLHS() const { return LHS; } - const Init *getRHS() const { return RHS; } + Init *getLHS() const { return LHS; } + Init *getRHS() const { return RHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; + Init *Fold(Record *CurRec, MultiClass *CurMultiClass); - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const; }; @@ -1158,30 +895,22 @@ enum TernaryOp { SUBST, FOREACH, IF }; private: TernaryOp Opc; - const Init *LHS, *MHS, *RHS; - - TernOpInit(const FoldingSetNodeID &ID, TernaryOp opc, const Init *lhs, - const Init *mhs, const Init *rhs, RecTy *Type) : - OpInit(ID, Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) {} - - TernOpInit(const TernOpInit &Other); // Do not define. - TernOpInit &operator=(const TernOpInit &Other); // Do not define. - + Init *LHS, *MHS, *RHS; public: - static const TernOpInit *get(TernaryOp opc, const Init *lhs, - const Init *mhs, const Init *rhs, - RecTy *Type); + TernOpInit(TernaryOp opc, Init *lhs, Init *mhs, Init *rhs, RecTy *Type) : + OpInit(Type), Opc(opc), LHS(lhs), MHS(mhs), RHS(rhs) { + } // Clone - Clone this operator, replacing arguments with the new list - virtual const OpInit *clone(std::vector &Operands) const { + virtual OpInit *clone(std::vector &Operands) { assert(Operands.size() == 3 && "Wrong number of operands for ternary operation"); - return TernOpInit::get(getOpcode(), Operands[0], Operands[1], - Operands[2], getType()); + return new TernOpInit(getOpcode(), Operands[0], Operands[1], Operands[2], + getType()); } int getNumOperands() const { return 3; } - const Init *getOperand(int i) const { + Init *getOperand(int i) { assert((i == 0 || i == 1 || i == 2) && "Invalid operand id for ternary operator"); if (i == 0) { @@ -1194,18 +923,17 @@ } TernaryOp getOpcode() const { return Opc; } - const Init *getLHS() const { return LHS; } - const Init *getMHS() const { return MHS; } - const Init *getRHS() const { return RHS; } + Init *getLHS() const { return LHS; } + Init *getMHS() const { return MHS; } + Init *getRHS() const { return RHS; } // Fold - If possible, fold this to a simpler init. Return this if not // possible to fold. - const Init *Fold(Record *CurRec, MultiClass *CurMultiClass) const; + Init *Fold(Record *CurRec, MultiClass *CurMultiClass); virtual bool isComplete() const { return false; } - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const; }; @@ -1215,31 +943,23 @@ /// class VarInit : public TypedInit { std::string VarName; - - explicit VarInit(const FoldingSetNodeID &ID, const std::string &VN, RecTy *T) - : TypedInit(ID, T), VarName(VN) {} - - VarInit(const VarInit &Other); // Do not define. - VarInit &operator=(const VarInit &Other); // Do not define. - public: - static const VarInit *get(const std::string &VN, RecTy *T); - static const VarInit *get(const Init *VN, RecTy *T); + explicit VarInit(const std::string &VN, RecTy *T) + : TypedInit(T), VarName(VN) {} - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } const std::string &getName() const { return VarName; } - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const; - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const; + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit); + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt); virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual const Init *getFieldInit(Record &R, const RecordVal *RV, + virtual Init *getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const; /// resolveReferences - This method is used by classes that refer to other @@ -1247,8 +967,7 @@ /// If a value is set for the variable later, this method will be called on /// users of the value to allow the value to propagate out. /// - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const { return VarName; } }; @@ -1257,101 +976,76 @@ /// VarBitInit - Opcode{0} - Represent access to one bit of a variable or field. /// class VarBitInit : public Init { - const TypedInit *TI; + TypedInit *TI; unsigned Bit; - - VarBitInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned B) - : Init(ID), TI(T), Bit(B) { +public: + VarBitInit(TypedInit *T, unsigned B) : TI(T), Bit(B) { assert(T->getType() && dynamic_cast(T->getType()) && ((BitsRecTy*)T->getType())->getNumBits() > B && "Illegal VarBitInit expression!"); } - VarBitInit(const VarBitInit &Other); // Do not define. - VarBitInit &operator=(const VarBitInit &Other); // Do not define. - -public: - static const VarBitInit *get(const TypedInit *T, unsigned B); - - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - const TypedInit *getVariable() const { return TI; } + TypedInit *getVariable() const { return TI; } unsigned getBitNum() const { return Bit; } virtual std::string getAsString() const; - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); }; /// VarListElementInit - List[4] - Represent access to one element of a var or /// field. class VarListElementInit : public TypedInit { - const TypedInit *TI; + TypedInit *TI; unsigned Element; - - VarListElementInit(const FoldingSetNodeID &ID, const TypedInit *T, unsigned E) - : TypedInit(ID, dynamic_cast(T->getType())->getElementType()), +public: + VarListElementInit(TypedInit *T, unsigned E) + : TypedInit(dynamic_cast(T->getType())->getElementType()), TI(T), Element(E) { assert(T->getType() && dynamic_cast(T->getType()) && "Illegal VarBitInit expression!"); } - VarListElementInit(const VarListElementInit &Other); // Do not define. - VarListElementInit &operator=(const VarListElementInit &Other); // Do - // not - // define. - -public: - static const VarListElementInit *get(const TypedInit *T, unsigned E); - - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - const TypedInit *getVariable() const { return TI; } + TypedInit *getVariable() const { return TI; } unsigned getElementNum() const { return Element; } - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const; + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit); /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, const RecordVal *RV, - unsigned Elt) const; + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt); virtual std::string getAsString() const; - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); }; /// DefInit - AL - Represent a reference to a 'def' in the description /// class DefInit : public TypedInit { Record *Def; - - explicit DefInit(const FoldingSetNodeID &ID, Record *D) - : TypedInit(ID, new RecordRecTy(D)), Def(D) {} - - DefInit(const DefInit &Other); // Do not define. - DefInit &operator=(const DefInit &Other); // Do not define. - public: - static const DefInit *get(Record *D); + explicit DefInit(Record *D) : TypedInit(new RecordRecTy(D)), Def(D) {} - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } Record *getDef() const { return Def; } - //virtual const Init * - //convertInitializerBitRange(const std::vector &Bits) const; + //virtual Init *convertInitializerBitRange(const std::vector &Bits); virtual RecTy *getFieldType(const std::string &FieldName) const; - virtual const Init *getFieldInit(Record &R, const RecordVal *RV, + virtual Init *getFieldInit(Record &R, const RecordVal *RV, const std::string &FieldName) const; virtual std::string getAsString() const; @@ -1360,8 +1054,8 @@ /// VarBitInit::resolveReferences. If the bit is able to be resolved, we /// simply return the resolved value, otherwise we return null. /// - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { assert(0 && "Illegal bit reference off def"); return 0; } @@ -1369,9 +1063,8 @@ /// resolveListElementReference - This method is used to implement /// VarListElementInit::resolveReferences. If the list element is resolvable /// now, we return the resolved value, otherwise we return null. - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) { assert(0 && "Illegal element reference off def"); return 0; } @@ -1381,33 +1074,24 @@ /// FieldInit - X.Y - Represent a reference to a subfield of a variable /// class FieldInit : public TypedInit { - const Init *Rec; // Record we are referring to + Init *Rec; // Record we are referring to std::string FieldName; // Field we are accessing - - FieldInit(const FoldingSetNodeID &ID, const Init *R, const std::string &FN) - : TypedInit(ID, R->getFieldType(FN)), Rec(R), FieldName(FN) { +public: + FieldInit(Init *R, const std::string &FN) + : TypedInit(R->getFieldType(FN)), Rec(R), FieldName(FN) { assert(getType() && "FieldInit with non-record type!"); } - FieldInit(const FieldInit &Other); // Do not define. - FieldInit &operator=(const FieldInit &Other); // Do not define. - -public: - static const FieldInit *get(const Init *R, const std::string &FN); - static const FieldInit *get(const Init *R, const Init *FN); - - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const; - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const; + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit); + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt); - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const { return Rec->getAsString() + "." + FieldName; @@ -1419,14 +1103,14 @@ /// argument can have a name associated with it. /// class DagInit : public TypedInit { - const Init *Val; + Init *Val; std::string ValName; - std::vector Args; + std::vector Args; std::vector ArgNames; - - DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, - const std::vector > &args) - : TypedInit(ID, new DagRecTy), Val(V), ValName(VN) { +public: + DagInit(Init *V, std::string VN, + const std::vector > &args) + : TypedInit(new DagRecTy), Val(V), ValName(VN) { Args.reserve(args.size()); ArgNames.reserve(args.size()); for (unsigned i = 0, e = args.size(); i != e; ++i) { @@ -1434,33 +1118,21 @@ ArgNames.push_back(args[i].second); } } - DagInit(const FoldingSetNodeID &ID, const Init *V, const std::string &VN, - const std::vector &args, + DagInit(Init *V, std::string VN, const std::vector &args, const std::vector &argNames) - : TypedInit(ID, new DagRecTy), Val(V), ValName(VN), Args(args), + : TypedInit(new DagRecTy), Val(V), ValName(VN), Args(args), ArgNames(argNames) { } - DagInit(const DagInit &Other); // Do not define. - DagInit &operator=(const DagInit &Other); // Do not define. - -public: - static const DagInit *get(const Init *V, const std::string &VN, - const std::vector< - std::pair > &args); - static const DagInit *get(const Init *V, const std::string &VN, - const std::vector &args, - const std::vector &argNames); - - virtual const Init *convertInitializerTo(RecTy *Ty) const { + virtual Init *convertInitializerTo(RecTy *Ty) { return Ty->convertValue(this); } - const Init *getOperator() const { return Val; } + Init *getOperator() const { return Val; } const std::string &getName() const { return ValName; } unsigned getNumArgs() const { return Args.size(); } - const Init *getArg(unsigned Num) const { + Init *getArg(unsigned Num) const { assert(Num < Args.size() && "Arg number out of range!"); return Args[Num]; } @@ -1469,18 +1141,17 @@ return ArgNames[Num]; } - void setArg(unsigned Num, const Init *I) { + void setArg(unsigned Num, Init *I) { assert(Num < Args.size() && "Arg number out of range!"); Args[Num] = I; } - virtual const Init *resolveReferences(Record &R, - const RecordVal *RV) const; + virtual Init *resolveReferences(Record &R, const RecordVal *RV); virtual std::string getAsString() const; - typedef std::vector::iterator arg_iterator; - typedef std::vector::const_iterator const_arg_iterator; + typedef std::vector::iterator arg_iterator; + typedef std::vector::const_iterator const_arg_iterator; typedef std::vector::iterator name_iterator; typedef std::vector::const_iterator const_name_iterator; @@ -1500,15 +1171,14 @@ inline size_t name_size () const { return ArgNames.size(); } inline bool name_empty() const { return ArgNames.empty(); } - virtual const Init *resolveBitReference(Record &R, const RecordVal *RV, - unsigned Bit) const { + virtual Init *resolveBitReference(Record &R, const RecordVal *RV, + unsigned Bit) { assert(0 && "Illegal bit reference off dag"); return 0; } - virtual const Init *resolveListElementReference(Record &R, - const RecordVal *RV, - unsigned Elt) const { + virtual Init *resolveListElementReference(Record &R, const RecordVal *RV, + unsigned Elt) { assert(0 && "Illegal element reference off dag"); return 0; } @@ -1522,7 +1192,7 @@ std::string Name; RecTy *Ty; unsigned Prefix; - const Init *Value; + Init *Value; public: RecordVal(const std::string &N, RecTy *T, unsigned P); @@ -1530,9 +1200,9 @@ unsigned getPrefix() const { return Prefix; } RecTy *getType() const { return Ty; } - const Init *getValue() const { return Value; } + Init *getValue() const { return Value; } - bool setValue(const Init *V) { + bool setValue(Init *V) { if (V) { Value = V->convertInitializerTo(Ty); return Value == 0; @@ -1666,7 +1336,7 @@ /// getValueInit - Return the initializer for a value with the specified name, /// or throw an exception if the field does not exist. /// - const Init *getValueInit(StringRef FieldName) const; + Init *getValueInit(StringRef FieldName) const; /// getValueAsString - This method looks up the specified field and returns /// its value as a string, throwing an exception if the field does not exist @@ -1678,13 +1348,13 @@ /// its value as a BitsInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// - const BitsInit *getValueAsBitsInit(StringRef FieldName) const; + BitsInit *getValueAsBitsInit(StringRef FieldName) const; /// getValueAsListInit - This method looks up the specified field and returns /// its value as a ListInit, throwing an exception if the field does not exist /// or if the value is not the right type. /// - const ListInit *getValueAsListInit(StringRef FieldName) const; + ListInit *getValueAsListInit(StringRef FieldName) const; /// getValueAsListOfDefs - This method looks up the specified field and /// returns its value as a vector of records, throwing an exception if the @@ -1726,7 +1396,7 @@ /// value as an Dag, throwing an exception if the field does not exist or if /// the value is not the right type. /// - const DagInit *getValueAsDag(StringRef FieldName) const; + DagInit *getValueAsDag(StringRef FieldName) const; /// getValueAsCode - This method looks up the specified field and returns /// its value as the string data in a CodeInit, throwing an exception if the Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Mon Jul 11 18:06:52 2011 @@ -722,7 +722,7 @@ if (!V || !V->getValue()) continue; - const DefInit *DI = dynamic_cast(V->getValue()); + DefInit *DI = dynamic_cast(V->getValue()); Record *Alias = DI->getDef(); DwarfRegNums[Reg] = DwarfRegNums[Alias]; } Modified: llvm/trunk/utils/TableGen/SetTheory.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SetTheory.cpp (original) +++ llvm/trunk/utils/TableGen/SetTheory.cpp Mon Jul 11 18:06:52 2011 @@ -27,14 +27,14 @@ // (add a, b, ...) Evaluate and union all arguments. struct AddOp : public SetTheory::Operator { - void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { ST.evaluate(Expr->arg_begin(), Expr->arg_end(), Elts); } }; // (sub Add, Sub, ...) Set difference. struct SubOp : public SetTheory::Operator { - void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() < 2) throw "Set difference needs at least two arguments: " + Expr->getAsString(); @@ -49,7 +49,7 @@ // (and S1, S2) Set intersection. struct AndOp : public SetTheory::Operator { - void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 2) throw "Set intersection requires two arguments: " + Expr->getAsString(); RecSet S1, S2; @@ -63,16 +63,16 @@ // SetIntBinOp - Abstract base class for (Op S, N) operators. struct SetIntBinOp : public SetTheory::Operator { - virtual void apply2(SetTheory &ST, const DagInit *Expr, + virtual void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) =0; - void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 2) throw "Operator requires (Op Set, Int) arguments: " + Expr->getAsString(); RecSet Set; ST.evaluate(Expr->arg_begin()[0], Set); - const IntInit *II = dynamic_cast(Expr->arg_begin()[1]); + IntInit *II = dynamic_cast(Expr->arg_begin()[1]); if (!II) throw "Second argument must be an integer: " + Expr->getAsString(); apply2(ST, Expr, Set, II->getValue(), Elts); @@ -81,7 +81,7 @@ // (shl S, N) Shift left, remove the first N elements. struct ShlOp : public SetIntBinOp { - void apply2(SetTheory &ST, const DagInit *Expr, + void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N < 0) @@ -93,7 +93,7 @@ // (trunc S, N) Truncate after the first N elements. struct TruncOp : public SetIntBinOp { - void apply2(SetTheory &ST, const DagInit *Expr, + void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N < 0) @@ -110,7 +110,7 @@ RotOp(bool Rev) : Reverse(Rev) {} - void apply2(SetTheory &ST, const DagInit *Expr, + void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (Reverse) @@ -129,7 +129,7 @@ // (decimate S, N) Pick every N'th element of S. struct DecimateOp : public SetIntBinOp { - void apply2(SetTheory &ST, const DagInit *Expr, + void apply2(SetTheory &ST, DagInit *Expr, RecSet &Set, int64_t N, RecSet &Elts) { if (N <= 0) @@ -141,26 +141,25 @@ // (sequence "Format", From, To) Generate a sequence of records by name. struct SequenceOp : public SetTheory::Operator { - void apply(SetTheory &ST, const DagInit *Expr, RecSet &Elts) { + void apply(SetTheory &ST, DagInit *Expr, RecSet &Elts) { if (Expr->arg_size() != 3) throw "Bad args to (sequence \"Format\", From, To): " + Expr->getAsString(); std::string Format; - if (const StringInit *SI = - dynamic_cast(Expr->arg_begin()[0])) + if (StringInit *SI = dynamic_cast(Expr->arg_begin()[0])) Format = SI->getValue(); else throw "Format must be a string: " + Expr->getAsString(); int64_t From, To; - if (const IntInit *II = dynamic_cast(Expr->arg_begin()[1])) + if (IntInit *II = dynamic_cast(Expr->arg_begin()[1])) From = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); if (From < 0 || From >= (1 << 30)) throw "From out of range"; - if (const IntInit *II = dynamic_cast(Expr->arg_begin()[2])) + if (IntInit *II = dynamic_cast(Expr->arg_begin()[2])) To = II->getValue(); else throw "From must be an integer: " + Expr->getAsString(); @@ -168,7 +167,7 @@ throw "To out of range"; RecordKeeper &Records = - dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); + dynamic_cast(*Expr->getOperator()).getDef()->getRecords(); int Step = From <= To ? 1 : -1; for (To += Step; From != To; From += Step) { @@ -223,9 +222,9 @@ addExpander(ClassName, new FieldExpander(FieldName)); } -void SetTheory::evaluate(const Init *Expr, RecSet &Elts) { +void SetTheory::evaluate(Init *Expr, RecSet &Elts) { // A def in a list can be a just an element, or it may expand. - if (const DefInit *Def = dynamic_cast(Expr)) { + if (DefInit *Def = dynamic_cast(Expr)) { if (const RecVec *Result = expand(Def->getDef())) return Elts.insert(Result->begin(), Result->end()); Elts.insert(Def->getDef()); @@ -233,14 +232,14 @@ } // Lists simply expand. - if (const ListInit *LI = dynamic_cast(Expr)) + if (ListInit *LI = dynamic_cast(Expr)) return evaluate(LI->begin(), LI->end(), Elts); // Anything else must be a DAG. - const DagInit *DagExpr = dynamic_cast(Expr); + DagInit *DagExpr = dynamic_cast(Expr); if (!DagExpr) throw "Invalid set element: " + Expr->getAsString(); - const DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); + DefInit *OpInit = dynamic_cast(DagExpr->getOperator()); if (!OpInit) throw "Bad set expression: " + Expr->getAsString(); Operator *Op = Operators.lookup(OpInit->getDef()->getName()); Modified: llvm/trunk/utils/TableGen/SetTheory.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SetTheory.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/SetTheory.h (original) +++ llvm/trunk/utils/TableGen/SetTheory.h Mon Jul 11 18:06:52 2011 @@ -55,7 +55,7 @@ namespace llvm { class DagInit; -class Init; +struct Init; class Record; class RecordKeeper; @@ -70,7 +70,7 @@ /// apply - Apply this operator to Expr's arguments and insert the result /// in Elts. - virtual void apply(SetTheory&, const DagInit *Expr, RecSet &Elts) =0; + virtual void apply(SetTheory&, DagInit *Expr, RecSet &Elts) =0; }; /// Expander - A callback function that can transform a Record representing a @@ -115,7 +115,7 @@ void addOperator(StringRef Name, Operator*); /// evaluate - Evaluate Expr and append the resulting set to Elts. - void evaluate(const Init *Expr, RecSet &Elts); + void evaluate(Init *Expr, RecSet &Elts); /// evaluate - Evaluate a sequence of Inits and append to Elts. template Modified: llvm/trunk/utils/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.cpp (original) +++ llvm/trunk/utils/TableGen/TGParser.cpp Mon Jul 11 18:06:52 2011 @@ -28,7 +28,7 @@ struct SubClassReference { SMLoc RefLoc; Record *Rec; - std::vector TemplateArgs; + std::vector TemplateArgs; SubClassReference() : Rec(0) {} bool isInvalid() const { return Rec == 0; } @@ -37,7 +37,7 @@ struct SubMultiClassReference { SMLoc RefLoc; MultiClass *MC; - std::vector TemplateArgs; + std::vector TemplateArgs; SubMultiClassReference() : MC(0) {} bool isInvalid() const { return MC == 0; } @@ -50,7 +50,7 @@ MC->dump(); errs() << "Template args:\n"; - for (std::vector::const_iterator i = TemplateArgs.begin(), + for (std::vector::const_iterator i = TemplateArgs.begin(), iend = TemplateArgs.end(); i != iend; ++i) { @@ -80,7 +80,7 @@ /// SetValue - /// Return true on error, false on success. bool TGParser::SetValue(Record *CurRec, SMLoc Loc, const std::string &ValName, - const std::vector &BitList, const Init *V) { + const std::vector &BitList, Init *V) { if (!V) return false; if (CurRec == 0) CurRec = &CurMultiClass->Rec; @@ -92,7 +92,7 @@ // Do not allow assignments like 'X = X'. This will just cause infinite loops // in the resolution machinery. if (BitList.empty()) - if (const VarInit *VI = dynamic_cast(V)) + if (VarInit *VI = dynamic_cast(V)) if (VI->getName() == ValName) return false; @@ -101,37 +101,37 @@ // initializer. // if (!BitList.empty()) { - const BitsInit *CurVal = dynamic_cast(RV->getValue()); + BitsInit *CurVal = dynamic_cast(RV->getValue()); if (CurVal == 0) return Error(Loc, "Value '" + ValName + "' is not a bits type"); // Convert the incoming value to a bits type of the appropriate size... - const Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); + Init *BI = V->convertInitializerTo(new BitsRecTy(BitList.size())); if (BI == 0) { V->convertInitializerTo(new BitsRecTy(BitList.size())); return Error(Loc, "Initializer is not compatible with bit range"); } // We should have a BitsInit type now. - const BitsInit *BInit = dynamic_cast(BI); + BitsInit *BInit = dynamic_cast(BI); assert(BInit != 0); - SmallVector NewBits(CurVal->getNumBits()); + BitsInit *NewVal = new BitsInit(CurVal->getNumBits()); // Loop over bits, assigning values as appropriate. for (unsigned i = 0, e = BitList.size(); i != e; ++i) { unsigned Bit = BitList[i]; - if (NewBits[Bit]) + if (NewVal->getBit(Bit)) return Error(Loc, "Cannot set bit #" + utostr(Bit) + " of value '" + ValName + "' more than once"); - NewBits[Bit] = BInit->getBit(i); + NewVal->setBit(Bit, BInit->getBit(i)); } for (unsigned i = 0, e = CurVal->getNumBits(); i != e; ++i) - if (NewBits[i] == 0) - NewBits[i] = CurVal->getBit(i); + if (NewVal->getBit(i) == 0) + NewVal->setBit(i, CurVal->getBit(i)); - V = BitsInit::get(NewBits.begin(), NewBits.end()); + V = NewVal; } if (RV->setValue(V)) @@ -633,7 +633,7 @@ /// IDValue ::= ID [multiclass template argument] /// IDValue ::= ID [def name] /// -const Init *TGParser::ParseIDValue(Record *CurRec) { +Init *TGParser::ParseIDValue(Record *CurRec) { assert(Lex.getCode() == tgtok::Id && "Expected ID in ParseIDValue"); std::string Name = Lex.getCurStrVal(); SMLoc Loc = Lex.getLoc(); @@ -643,17 +643,17 @@ /// ParseIDValue - This is just like ParseIDValue above, but it assumes the ID /// has already been read. -const Init *TGParser::ParseIDValue(Record *CurRec, +Init *TGParser::ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc) { if (CurRec) { if (const RecordVal *RV = CurRec->getValue(Name)) - return VarInit::get(Name, RV->getType()); + return new VarInit(Name, RV->getType()); std::string TemplateArgName = CurRec->getName()+":"+Name; if (CurRec->isTemplateArg(TemplateArgName)) { const RecordVal *RV = CurRec->getValue(TemplateArgName); assert(RV && "Template arg doesn't exist??"); - return VarInit::get(TemplateArgName, RV->getType()); + return new VarInit(TemplateArgName, RV->getType()); } } @@ -662,12 +662,12 @@ if (CurMultiClass->Rec.isTemplateArg(MCName)) { const RecordVal *RV = CurMultiClass->Rec.getValue(MCName); assert(RV && "Template arg doesn't exist??"); - return VarInit::get(MCName, RV->getType()); + return new VarInit(MCName, RV->getType()); } } if (Record *D = Records.getDef(Name)) - return DefInit::get(D); + return new DefInit(D); Error(NameLoc, "Variable not defined: '" + Name + "'"); return 0; @@ -677,7 +677,7 @@ /// /// Operation ::= XOperator ['<' Type '>'] '(' Args ')' /// -const Init *TGParser::ParseOperation(Record *CurRec) { +Init *TGParser::ParseOperation(Record *CurRec) { switch (Lex.getCode()) { default: TokError("unknown operation"); @@ -724,15 +724,15 @@ } Lex.Lex(); // eat the '(' - const Init *LHS = ParseValue(CurRec); + Init *LHS = ParseValue(CurRec); if (LHS == 0) return 0; if (Code == UnOpInit::HEAD || Code == UnOpInit::TAIL || Code == UnOpInit::EMPTY) { - const ListInit *LHSl = dynamic_cast(LHS); - const StringInit *LHSs = dynamic_cast(LHS); - const TypedInit *LHSt = dynamic_cast(LHS); + ListInit *LHSl = dynamic_cast(LHS); + StringInit *LHSs = dynamic_cast(LHS); + TypedInit *LHSt = dynamic_cast(LHS); if (LHSl == 0 && LHSs == 0 && LHSt == 0) { TokError("expected list or string type argument in unary operator"); return 0; @@ -758,8 +758,8 @@ return 0; } if (LHSl) { - const Init *Item = LHSl->getElement(0); - const TypedInit *Itemt = dynamic_cast(Item); + Init *Item = LHSl->getElement(0); + TypedInit *Itemt = dynamic_cast(Item); if (Itemt == 0) { TokError("untyped list element in unary operator"); return 0; @@ -790,7 +790,7 @@ return 0; } Lex.Lex(); // eat the ')' - return (UnOpInit::get(Code, LHS, Type))->Fold(CurRec, CurMultiClass); + return (new UnOpInit(Code, LHS, Type))->Fold(CurRec, CurMultiClass); } case tgtok::XConcat: @@ -825,7 +825,7 @@ } Lex.Lex(); // eat the '(' - SmallVector InitList; + SmallVector InitList; InitList.push_back(ParseValue(CurRec)); if (InitList.back() == 0) return 0; @@ -847,15 +847,15 @@ // shorthand for nesting them. if (Code == BinOpInit::STRCONCAT) { while (InitList.size() > 2) { - const Init *RHS = InitList.pop_back_val(); - RHS = (BinOpInit::get(Code, InitList.back(), RHS, Type)) + Init *RHS = InitList.pop_back_val(); + RHS = (new BinOpInit(Code, InitList.back(), RHS, Type)) ->Fold(CurRec, CurMultiClass); InitList.back() = RHS; } } if (InitList.size() == 2) - return (BinOpInit::get(Code, InitList[0], InitList[1], Type)) + return (new BinOpInit(Code, InitList[0], InitList[1], Type)) ->Fold(CurRec, CurMultiClass); Error(OpLoc, "expected two operands to operator"); @@ -888,7 +888,7 @@ } Lex.Lex(); // eat the '(' - const Init *LHS = ParseValue(CurRec); + Init *LHS = ParseValue(CurRec); if (LHS == 0) return 0; if (Lex.getCode() != tgtok::comma) { @@ -897,7 +897,7 @@ } Lex.Lex(); // eat the ',' - const Init *MHS = ParseValue(CurRec); + Init *MHS = ParseValue(CurRec); if (MHS == 0) return 0; if (Lex.getCode() != tgtok::comma) { @@ -906,7 +906,7 @@ } Lex.Lex(); // eat the ',' - const Init *RHS = ParseValue(CurRec); + Init *RHS = ParseValue(CurRec); if (RHS == 0) return 0; if (Lex.getCode() != tgtok::r_paren) { @@ -920,23 +920,23 @@ case tgtok::XIf: { // FIXME: The `!if' operator doesn't handle non-TypedInit well at // all. This can be made much more robust. - const TypedInit *MHSt = dynamic_cast(MHS); - const TypedInit *RHSt = dynamic_cast(RHS); + TypedInit *MHSt = dynamic_cast(MHS); + TypedInit *RHSt = dynamic_cast(RHS); RecTy *MHSTy = 0; RecTy *RHSTy = 0; if (MHSt == 0 && RHSt == 0) { - const BitsInit *MHSbits = dynamic_cast(MHS); - const BitsInit *RHSbits = dynamic_cast(RHS); + BitsInit *MHSbits = dynamic_cast(MHS); + BitsInit *RHSbits = dynamic_cast(RHS); if (MHSbits && RHSbits && MHSbits->getNumBits() == RHSbits->getNumBits()) { Type = new BitRecTy(); break; } else { - const BitInit *MHSbit = dynamic_cast(MHS); - const BitInit *RHSbit = dynamic_cast(RHS); + BitInit *MHSbit = dynamic_cast(MHS); + BitInit *RHSbit = dynamic_cast(RHS); if (MHSbit && RHSbit) { Type = new BitRecTy(); @@ -964,7 +964,7 @@ break; } case tgtok::XForEach: { - const TypedInit *MHSt = dynamic_cast(MHS); + TypedInit *MHSt = dynamic_cast(MHS); if (MHSt == 0) { TokError("could not get type for !foreach"); return 0; @@ -973,7 +973,7 @@ break; } case tgtok::XSubst: { - const TypedInit *RHSt = dynamic_cast(RHS); + TypedInit *RHSt = dynamic_cast(RHS); if (RHSt == 0) { TokError("could not get type for !subst"); return 0; @@ -982,7 +982,7 @@ break; } } - return (TernOpInit::get(Code, LHS, MHS, RHS, Type))->Fold(CurRec, + return (new TernOpInit(Code, LHS, MHS, RHS, Type))->Fold(CurRec, CurMultiClass); } } @@ -1038,11 +1038,11 @@ /// SimpleValue ::= SRLTOK '(' Value ',' Value ')' /// SimpleValue ::= STRCONCATTOK '(' Value ',' Value ')' /// -const Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { - const Init *R = 0; +Init *TGParser::ParseSimpleValue(Record *CurRec, RecTy *ItemType) { + Init *R = 0; switch (Lex.getCode()) { default: TokError("Unknown token when parsing a value"); break; - case tgtok::IntVal: R = IntInit::get(Lex.getCurIntVal()); Lex.Lex(); break; + case tgtok::IntVal: R = new IntInit(Lex.getCurIntVal()); Lex.Lex(); break; case tgtok::StrVal: { std::string Val = Lex.getCurStrVal(); Lex.Lex(); @@ -1053,15 +1053,15 @@ Lex.Lex(); } - R = StringInit::get(Val); + R = new StringInit(Val); break; } case tgtok::CodeFragment: - R = CodeInit::get(Lex.getCurStrVal()); + R = new CodeInit(Lex.getCurStrVal()); Lex.Lex(); break; case tgtok::question: - R = UnsetInit::get(); + R = new UnsetInit(); Lex.Lex(); break; case tgtok::Id: { @@ -1085,7 +1085,7 @@ return 0; } - std::vector ValueList = ParseValueList(CurRec, Class); + std::vector ValueList = ParseValueList(CurRec, Class); if (ValueList.empty()) return 0; if (Lex.getCode() != tgtok::greater) { @@ -1110,12 +1110,12 @@ Records.addDef(NewRec); // The result of the expression is a reference to the new record. - return DefInit::get(NewRec); + return new DefInit(NewRec); } case tgtok::l_brace: { // Value ::= '{' ValueList '}' SMLoc BraceLoc = Lex.getLoc(); Lex.Lex(); // eat the '{' - std::vector Vals; + std::vector Vals; if (Lex.getCode() != tgtok::r_brace) { Vals = ParseValueList(CurRec); @@ -1127,22 +1127,21 @@ } Lex.Lex(); // eat the '}' - SmallVector NewBits(Vals.size()); - + BitsInit *Result = new BitsInit(Vals.size()); for (unsigned i = 0, e = Vals.size(); i != e; ++i) { - const Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); + Init *Bit = Vals[i]->convertInitializerTo(new BitRecTy()); if (Bit == 0) { Error(BraceLoc, "Element #" + utostr(i) + " (" + Vals[i]->getAsString()+ ") is not convertable to a bit"); return 0; } - NewBits[Vals.size()-i-1] = Bit; + Result->setBit(Vals.size()-i-1, Bit); } - return BitsInit::get(NewBits.begin(), NewBits.end()); + return Result; } case tgtok::l_square: { // Value ::= '[' ValueList ']' Lex.Lex(); // eat the '[' - std::vector Vals; + std::vector Vals; RecTy *DeducedEltTy = 0; ListRecTy *GivenListTy = 0; @@ -1190,10 +1189,10 @@ // Check elements RecTy *EltTy = 0; - for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); + for (std::vector::iterator i = Vals.begin(), ie = Vals.end(); i != ie; ++i) { - const TypedInit *TArg = dynamic_cast(*i); + TypedInit *TArg = dynamic_cast(*i); if (TArg == 0) { TokError("Untyped list element"); return 0; @@ -1237,7 +1236,7 @@ DeducedEltTy = EltTy; } - return ListInit::get(Vals, DeducedEltTy); + return new ListInit(Vals, DeducedEltTy); } case tgtok::l_paren: { // Value ::= '(' IDValue DagArgList ')' Lex.Lex(); // eat the '(' @@ -1246,7 +1245,7 @@ return 0; } - const Init *Operator = ParseValue(CurRec); + Init *Operator = ParseValue(CurRec); if (Operator == 0) return 0; // If the operator name is present, parse it. @@ -1260,7 +1259,7 @@ Lex.Lex(); // eat the VarName. } - std::vector > DagArgs; + std::vector > DagArgs; if (Lex.getCode() != tgtok::r_paren) { DagArgs = ParseDagArgList(CurRec); if (DagArgs.empty()) return 0; @@ -1272,7 +1271,7 @@ } Lex.Lex(); // eat the ')' - return DagInit::get(Operator, OperatorName, DagArgs); + return new DagInit(Operator, OperatorName, DagArgs); } case tgtok::XHead: @@ -1302,8 +1301,8 @@ /// ValueSuffix ::= '[' BitList ']' /// ValueSuffix ::= '.' ID /// -const Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { - const Init *Result = ParseSimpleValue(CurRec, ItemType); +Init *TGParser::ParseValue(Record *CurRec, RecTy *ItemType) { + Init *Result = ParseSimpleValue(CurRec, ItemType); if (Result == 0) return 0; // Parse the suffixes now if present. @@ -1362,7 +1361,7 @@ Result->getAsString() + "'"); return 0; } - Result = FieldInit::get(Result, Lex.getCurStrVal()); + Result = new FieldInit(Result, Lex.getCurStrVal()); Lex.Lex(); // eat field name break; } @@ -1373,20 +1372,20 @@ /// /// ParseDagArgList ::= Value (':' VARNAME)? /// ParseDagArgList ::= ParseDagArgList ',' Value (':' VARNAME)? -std::vector > +std::vector > TGParser::ParseDagArgList(Record *CurRec) { - std::vector > Result; + std::vector > Result; while (1) { - const Init *Val = ParseValue(CurRec); - if (Val == 0) return std::vector >(); + Init *Val = ParseValue(CurRec); + if (Val == 0) return std::vector >(); // If the variable name is present, add it. std::string VarName; if (Lex.getCode() == tgtok::colon) { if (Lex.Lex() != tgtok::VarName) { // eat the ':' TokError("expected variable name in dag literal"); - return std::vector >(); + return std::vector >(); } VarName = Lex.getCurStrVal(); Lex.Lex(); // eat the VarName. @@ -1408,10 +1407,9 @@ /// /// ValueList ::= Value (',' Value) /// -std::vector TGParser::ParseValueList(Record *CurRec, - Record *ArgsRec, - RecTy *EltTy) { - std::vector Result; +std::vector TGParser::ParseValueList(Record *CurRec, Record *ArgsRec, + RecTy *EltTy) { + std::vector Result; RecTy *ItemType = EltTy; unsigned int ArgN = 0; if (ArgsRec != 0 && EltTy == 0) { @@ -1422,7 +1420,7 @@ ++ArgN; } Result.push_back(ParseValue(CurRec, ItemType)); - if (Result.back() == 0) return std::vector(); + if (Result.back() == 0) return std::vector(); while (Lex.getCode() == tgtok::comma) { Lex.Lex(); // Eat the comma @@ -1431,7 +1429,7 @@ const std::vector &TArgs = ArgsRec->getTemplateArgs(); if (ArgN >= TArgs.size()) { TokError("too many template arguments"); - return std::vector(); + return std::vector(); } const RecordVal *RV = ArgsRec->getValue(TArgs[ArgN]); assert(RV && "Template argument record not found??"); @@ -1439,7 +1437,7 @@ ++ArgN; } Result.push_back(ParseValue(CurRec, ItemType)); - if (Result.back() == 0) return std::vector(); + if (Result.back() == 0) return std::vector(); } return Result; @@ -1492,7 +1490,7 @@ if (Lex.getCode() == tgtok::equal) { Lex.Lex(); SMLoc ValLoc = Lex.getLoc(); - const Init *Val = ParseValue(CurRec, Type); + Init *Val = ParseValue(CurRec, Type); if (Val == 0 || SetValue(CurRec, ValLoc, DeclName, std::vector(), Val)) return ""; @@ -1576,7 +1574,7 @@ RecTy *Type = Field->getType(); - const Init *Val = ParseValue(CurRec, Type); + Init *Val = ParseValue(CurRec, Type); if (Val == 0) return true; if (Lex.getCode() != tgtok::semi) @@ -1776,7 +1774,7 @@ } Lex.Lex(); // eat the '='. - const Init *Val = ParseValue(0); + Init *Val = ParseValue(0); if (Val == 0) return std::vector(); // Now that we have everything, add the record. @@ -1950,7 +1948,7 @@ // template parameters. MultiClass *MC = MultiClasses[Ref.Rec->getName()]; assert(MC && "Didn't lookup multiclass correctly?"); - std::vector &TemplateVals = Ref.TemplateArgs; + std::vector &TemplateVals = Ref.TemplateArgs; // Verify that the correct number of template arguments were specified. const std::vector &TArgs = MC->Rec.getTemplateArgs(); Modified: llvm/trunk/utils/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TGParser.h?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TGParser.h (original) +++ llvm/trunk/utils/TableGen/TGParser.h Mon Jul 11 18:06:52 2011 @@ -25,7 +25,7 @@ class RecordVal; class RecordKeeper; struct RecTy; - class Init; + struct Init; struct MultiClass; struct SubClassReference; struct SubMultiClassReference; @@ -33,10 +33,10 @@ struct LetRecord { std::string Name; std::vector Bits; - const Init *Value; + Init *Value; SMLoc Loc; - LetRecord(const std::string &N, const std::vector &B, - const Init *V, SMLoc L) + LetRecord(const std::string &N, const std::vector &B, Init *V, + SMLoc L) : Name(N), Bits(B), Value(V), Loc(L) { } }; @@ -73,7 +73,7 @@ private: // Semantic analysis methods. bool AddValue(Record *TheRec, SMLoc Loc, const RecordVal &RV); bool SetValue(Record *TheRec, SMLoc Loc, const std::string &ValName, - const std::vector &BitList, const Init *V); + const std::vector &BitList, Init *V); bool AddSubClass(Record *Rec, SubClassReference &SubClass); bool AddSubMultiClass(MultiClass *CurMC, SubMultiClassReference &SubMultiClass); @@ -98,20 +98,18 @@ SubClassReference ParseSubClassReference(Record *CurRec, bool isDefm); SubMultiClassReference ParseSubMultiClassReference(MultiClass *CurMC); - const Init *ParseIDValue(Record *CurRec); - const Init *ParseIDValue(Record *CurRec, const std::string &Name, - SMLoc NameLoc); - const Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); - const Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); - std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, - RecTy *EltTy = 0); - std::vector > ParseDagArgList(Record *); + Init *ParseIDValue(Record *CurRec); + Init *ParseIDValue(Record *CurRec, const std::string &Name, SMLoc NameLoc); + Init *ParseSimpleValue(Record *CurRec, RecTy *ItemType = 0); + Init *ParseValue(Record *CurRec, RecTy *ItemType = 0); + std::vector ParseValueList(Record *CurRec, Record *ArgsRec = 0, RecTy *EltTy = 0); + std::vector > ParseDagArgList(Record *); bool ParseOptionalRangeList(std::vector &Ranges); bool ParseOptionalBitList(std::vector &Ranges); std::vector ParseRangeList(); bool ParseRangePiece(std::vector &Ranges); RecTy *ParseType(); - const Init *ParseOperation(Record *CurRec); + Init *ParseOperation(Record *CurRec); RecTy *ParseOperatorType(); std::string ParseObjectName(); Record *ParseClassID(); Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Mon Jul 11 18:06:52 2011 @@ -208,7 +208,6 @@ if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) { errs() << "Could not open input file '" << InputFilename << "': " << ec.message() <<"\n"; - Init::ReleaseMemory(); return 1; } MemoryBuffer *F = File.take(); @@ -222,30 +221,25 @@ TGParser Parser(SrcMgr, Records); - if (Parser.ParseFile()) { - Init::ReleaseMemory(); + if (Parser.ParseFile()) return 1; - } std::string Error; tool_output_file Out(OutputFilename.c_str(), Error); if (!Error.empty()) { errs() << argv[0] << ": error opening " << OutputFilename << ":" << Error << "\n"; - Init::ReleaseMemory(); return 1; } if (!DependFilename.empty()) { if (OutputFilename == "-") { errs() << argv[0] << ": the option -d must be used together with -o\n"; - Init::ReleaseMemory(); return 1; } tool_output_file DepOut(DependFilename.c_str(), Error); if (!Error.empty()) { errs() << argv[0] << ": error opening " << DependFilename << ":" << Error << "\n"; - Init::ReleaseMemory(); return 1; } DepOut.os() << DependFilename << ":"; @@ -388,14 +382,11 @@ } default: assert(1 && "Invalid Action"); - Init::ReleaseMemory(); return 1; } // Declare success. Out.keep(); - - Init::ReleaseMemory(); return 0; } catch (const TGError &Error) { @@ -408,7 +399,5 @@ errs() << argv[0] << ": Unknown unexpected exception occurred.\n"; } - Init::ReleaseMemory(); - return 1; } Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=134936&r1=134935&r2=134936&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original) +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Mon Jul 11 18:06:52 2011 @@ -162,7 +162,7 @@ /// @param init - A reference to the BitsInit to be decoded. /// @return - The field, with the first bit in the BitsInit as the lowest /// order bit. -static uint8_t byteFromBitsInit(const BitsInit &init) { +static uint8_t byteFromBitsInit(BitsInit &init) { int width = init.getNumBits(); assert(width <= 8 && "Field is too large for uint8_t!"); @@ -173,7 +173,7 @@ uint8_t ret = 0; for (index = 0; index < width; index++) { - if (static_cast(init.getBit(index))->getValue()) + if (static_cast(init.getBit(index))->getValue()) ret |= mask; mask <<= 1; @@ -189,7 +189,7 @@ /// @param name - The name of the field in the record. /// @return - The field, as translated by byteFromBitsInit(). static uint8_t byteFromRec(const Record* rec, const std::string &name) { - const BitsInit* bits = rec->getValueAsBitsInit(name); + BitsInit* bits = rec->getValueAsBitsInit(name); return byteFromBitsInit(*bits); } From echristo at apple.com Mon Jul 11 18:09:01 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 11 Jul 2011 16:09:01 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> Message-ID: <7731534C-A3B3-4F86-9A0F-C31E1DAC62A5@apple.com> On Jul 11, 2011, at 2:33 PM, David A. Greene wrote: > Evan Cheng writes: > >> There are several other "struct Init". I've fixed them. Unfortunately the build is still broken: >> >> /Volumes/Ebi/echeng/llvm/Debug+Asserts/bin/tblgen -I /Volumes/Ebi/echeng/llvm/lib/VMCore -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/include -I /Volumes/Ebi/echeng/llvm/lib/Target /Volumes/Ebi/echeng/llvm/include/llvm/Intrinsics.td -o /Volumes/Ebi/echeng/llvm/lib/VMCore/Debug+Asserts/Intrinsics.gen.tmp -gen-intrinsic >> pure virtual method called >> terminate called without an active exception > > I've tried multiple gcc versions and I still don't see this. > > What compiler are you using to build? > > Can you send me your configure line? Thanks! > Hi David, Lots of people are seeing this with multiple compilers and buildbots. I'd appreciate you working with them to get this ironed out if you'd like to put the patch back in, but in the meantime I've reverted r134921, r134917, r134908 and r134907. Thanks! -eric From greened at obbligato.org Mon Jul 11 18:48:08 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 18:48:08 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: (Francois Pichet's message of "Mon, 11 Jul 2011 18:47:27 -0400") References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> Message-ID: Francois Pichet writes: > I started the VC++ debugger on tblgen and the pure function call is on > line 71 of file Support\Allocator.cpp: >> Allocator.Deallocate(Slab); > > This is during doexit() after main has finished.. static variable > destructor i suppose. > > I suspect a memory corruption. I ran valgrind on a gcc-compiled tblgen on Linux and didn't see any obvious errors. Lots of leaks, but that's a separate issue. It doesn't mean there's not a problem, just that I can't see it at all. Is there a similar memory analysis tool available for Windows that you could run? Evan, could you go back to the old version of Clang you were using to build and do a valgrind run on the resulting executable? That might help us track this down. -Dave From greened at obbligato.org Mon Jul 11 18:50:52 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 18:50:52 -0500 Subject: [llvm-commits] [llvm] r134936 - /llvm/trunk/utils/TableGen/ In-Reply-To: <20110711230653.7DA112A6C12C@llvm.org> (Eric Christopher's message of "Mon, 11 Jul 2011 23:06:52 -0000") References: <20110711230653.7DA112A6C12C@llvm.org> Message-ID: Eric Christopher writes: > Author: echristo > Date: Mon Jul 11 18:06:52 2011 > New Revision: 134936 > > URL: http://llvm.org/viewvc/llvm-project?rev=134936&view=rev > Log: > Revert r134921, 134917, 134908 and 134907. They're causing failures > in multiple buildbots. Just to clarify, are you referring to the "pure virtual called" errors or is there something additional going on? The messages I got from the buildbot were not immediately helpful. One was for the "pure virtual" problem which I think is exposed or caused by this patch. Another was for some clang test failures that I somewhat doubt are connected to this patch and the last was a buildbot slave hangup problem. -Dave From greened at obbligato.org Mon Jul 11 18:52:02 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 18:52:02 -0500 Subject: [llvm-commits] [llvm] r134917 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.h Record.h TGParser.h In-Reply-To: <408586D0-F633-4BEE-84EF-227E5175F824@mac.com> (Owen Anderson's message of "Mon, 11 Jul 2011 15:24:28 -0700") References: <20110711202313.C39B02A6C12C@llvm.org> <408586D0-F633-4BEE-84EF-227E5175F824@mac.com> Message-ID: Owen Anderson writes: >> It seems the buildbots should be updated to include -Werror and a set >> of warnings people care about. Who is able to do that? I did not >> see any warnings at all with a default build. > > A lot of us are building LLVM with Clang nowadays, with which this > warning appears by default. Unfortunately, that doesn't help those of us not building with Clang. Can we turn on a similar warning for other builds? -Dave From echristo at apple.com Mon Jul 11 18:52:54 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 11 Jul 2011 16:52:54 -0700 Subject: [llvm-commits] [llvm] r134936 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711230653.7DA112A6C12C@llvm.org> Message-ID: On Jul 11, 2011, at 4:50 PM, David A. Greene wrote: > Eric Christopher writes: > >> Author: echristo >> Date: Mon Jul 11 18:06:52 2011 >> New Revision: 134936 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134936&view=rev >> Log: >> Revert r134921, 134917, 134908 and 134907. They're causing failures >> in multiple buildbots. > > Just to clarify, are you referring to the "pure virtual called" errors > or is there something additional going on? The messages I got from the > buildbot were not immediately helpful. One was for the "pure virtual" > problem which I think is exposed or caused by this patch. Another was > for some clang test failures that I somewhat doubt are connected to this > patch and the last was a buildbot slave hangup problem. Anecdotally reverting your patch has made everything go green again. -eric From greened at obbligato.org Mon Jul 11 19:01:43 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 19:01:43 -0500 Subject: [llvm-commits] [llvm] r134936 - /llvm/trunk/utils/TableGen/ In-Reply-To: (Eric Christopher's message of "Mon, 11 Jul 2011 16:52:54 -0700") References: <20110711230653.7DA112A6C12C@llvm.org> Message-ID: Eric Christopher writes: >> Just to clarify, are you referring to the "pure virtual called" errors >> or is there something additional going on? The messages I got from the >> buildbot were not immediately helpful. One was for the "pure virtual" >> problem which I think is exposed or caused by this patch. Another was >> for some clang test failures that I somewhat doubt are connected to this >> patch and the last was a buildbot slave hangup problem. > > Anecdotally reverting your patch has made everything go green again. How can you say? I'm seeing a lot of builds in progress and slaves offline. Maybe I'm using this buildbot thing wrong. :) What page are you looking at? -Dave From atrick at apple.com Mon Jul 11 19:08:50 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 12 Jul 2011 00:08:50 -0000 Subject: [llvm-commits] [llvm] r134941 - /llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Message-ID: <20110712000850.480672A6C12C@llvm.org> Author: atrick Date: Mon Jul 11 19:08:50 2011 New Revision: 134941 URL: http://llvm.org/viewvc/llvm-project?rev=134941&view=rev Log: indvars: Code reorganization in preparation for LinearFunctionTestReplace rewrite. No functionality. I've been wanting to group the indvar subphases into sections and order them by their logical sequence. My next checkin adds functions related to LFTR, and doing the reorg now should help reviewers. Since, most of the code in IndVarSimplify.cpp has recently been replaced or will be replaced soon, obscuring blame should not be an issue. This seems like an ideal time to shuffle the code around. I'm happy to take more suggestions for cleaning up the code. Or if you've been wanting to cleanup anything in this file yourself, now is a good time. Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Modified: llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp?rev=134941&r1=134940&r2=134941&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/IndVarSimplify.cpp Mon Jul 11 19:08:50 2011 @@ -126,6 +126,11 @@ bool isValidRewrite(Value *FromVal, Value *ToVal); + void HandleFloatingPointIV(Loop *L, PHINode *PH); + void RewriteNonIntegerIVs(Loop *L); + + void RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter); + void SimplifyIVUsers(SCEVExpander &Rewriter); void SimplifyIVUsersNoRewrite(Loop *L, SCEVExpander &Rewriter); @@ -134,22 +139,16 @@ void EliminateIVRemainder(BinaryOperator *Rem, Value *IVOperand, bool IsSigned); - bool isSimpleIVUser(Instruction *I, const Loop *L); - void RewriteNonIntegerIVs(Loop *L); - - ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV *BackedgeTakenCount, - PHINode *IndVar, - SCEVExpander &Rewriter); - - void RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter); void SimplifyCongruentIVs(Loop *L); void RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter); - void SinkUnusedInvariants(Loop *L); + ICmpInst *LinearFunctionTestReplace(Loop *L, const SCEV *IVLimit, + PHINode *IndVar, + SCEVExpander &Rewriter); - void HandleFloatingPointIV(Loop *L, PHINode *PH); + void SinkUnusedInvariants(Loop *L); }; } @@ -216,172 +215,278 @@ return true; } -/// canExpandBackedgeTakenCount - Return true if this loop's backedge taken -/// count expression can be safely and cheaply expanded into an instruction -/// sequence that can be used by LinearFunctionTestReplace. -static bool canExpandBackedgeTakenCount(Loop *L, ScalarEvolution *SE) { - const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); - if (isa(BackedgeTakenCount) || - BackedgeTakenCount->isZero()) - return false; +//===----------------------------------------------------------------------===// +// RewriteNonIntegerIVs and helpers. Prefer integer IVs. +//===----------------------------------------------------------------------===// - if (!L->getExitingBlock()) +/// ConvertToSInt - Convert APF to an integer, if possible. +static bool ConvertToSInt(const APFloat &APF, int64_t &IntVal) { + bool isExact = false; + if (&APF.getSemantics() == &APFloat::PPCDoubleDouble) return false; - - // Can't rewrite non-branch yet. - BranchInst *BI = dyn_cast(L->getExitingBlock()->getTerminator()); - if (!BI) + // See if we can convert this to an int64_t + uint64_t UIntVal; + if (APF.convertToInteger(&UIntVal, 64, true, APFloat::rmTowardZero, + &isExact) != APFloat::opOK || !isExact) return false; - - // Special case: If the backedge-taken count is a UDiv, it's very likely a - // UDiv that ScalarEvolution produced in order to compute a precise - // expression, rather than a UDiv from the user's code. If we can't find a - // UDiv in the code with some simple searching, assume the former and forego - // rewriting the loop. - if (isa(BackedgeTakenCount)) { - ICmpInst *OrigCond = dyn_cast(BI->getCondition()); - if (!OrigCond) return false; - const SCEV *R = SE->getSCEV(OrigCond->getOperand(1)); - R = SE->getMinusSCEV(R, SE->getConstant(R->getType(), 1)); - if (R != BackedgeTakenCount) { - const SCEV *L = SE->getSCEV(OrigCond->getOperand(0)); - L = SE->getMinusSCEV(L, SE->getConstant(L->getType(), 1)); - if (L != BackedgeTakenCount) - return false; - } - } + IntVal = UIntVal; return true; } -/// getBackedgeIVType - Get the widest type used by the loop test after peeking -/// through Truncs. +/// HandleFloatingPointIV - If the loop has floating induction variable +/// then insert corresponding integer induction variable if possible. +/// For example, +/// for(double i = 0; i < 10000; ++i) +/// bar(i) +/// is converted into +/// for(int i = 0; i < 10000; ++i) +/// bar((double)i); /// -/// TODO: Unnecessary once LinearFunctionTestReplace is removed. -static const Type *getBackedgeIVType(Loop *L) { - if (!L->getExitingBlock()) - return 0; - - // Can't rewrite non-branch yet. - BranchInst *BI = dyn_cast(L->getExitingBlock()->getTerminator()); - if (!BI) - return 0; +void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PN) { + unsigned IncomingEdge = L->contains(PN->getIncomingBlock(0)); + unsigned BackEdge = IncomingEdge^1; - ICmpInst *Cond = dyn_cast(BI->getCondition()); - if (!Cond) - return 0; + // Check incoming value. + ConstantFP *InitValueVal = + dyn_cast(PN->getIncomingValue(IncomingEdge)); - const Type *Ty = 0; - for(User::op_iterator OI = Cond->op_begin(), OE = Cond->op_end(); - OI != OE; ++OI) { - assert((!Ty || Ty == (*OI)->getType()) && "bad icmp operand types"); - TruncInst *Trunc = dyn_cast(*OI); - if (!Trunc) - continue; + int64_t InitValue; + if (!InitValueVal || !ConvertToSInt(InitValueVal->getValueAPF(), InitValue)) + return; - return Trunc->getSrcTy(); - } - return Ty; -} + // Check IV increment. Reject this PN if increment operation is not + // an add or increment value can not be represented by an integer. + BinaryOperator *Incr = + dyn_cast(PN->getIncomingValue(BackEdge)); + if (Incr == 0 || Incr->getOpcode() != Instruction::FAdd) return; -/// LinearFunctionTestReplace - This method rewrites the exit condition of the -/// loop to be a canonical != comparison against the incremented loop induction -/// variable. This pass is able to rewrite the exit tests of any loop where the -/// SCEV analysis can determine a loop-invariant trip count of the loop, which -/// is actually a much broader range than just linear tests. -ICmpInst *IndVarSimplify:: -LinearFunctionTestReplace(Loop *L, - const SCEV *BackedgeTakenCount, - PHINode *IndVar, - SCEVExpander &Rewriter) { - assert(canExpandBackedgeTakenCount(L, SE) && "precondition"); - BranchInst *BI = cast(L->getExitingBlock()->getTerminator()); + // If this is not an add of the PHI with a constantfp, or if the constant fp + // is not an integer, bail out. + ConstantFP *IncValueVal = dyn_cast(Incr->getOperand(1)); + int64_t IncValue; + if (IncValueVal == 0 || Incr->getOperand(0) != PN || + !ConvertToSInt(IncValueVal->getValueAPF(), IncValue)) + return; - // If the exiting block is not the same as the backedge block, we must compare - // against the preincremented value, otherwise we prefer to compare against - // the post-incremented value. - Value *CmpIndVar; - const SCEV *RHS = BackedgeTakenCount; - if (L->getExitingBlock() == L->getLoopLatch()) { - // Add one to the "backedge-taken" count to get the trip count. - // If this addition may overflow, we have to be more pessimistic and - // cast the induction variable before doing the add. - const SCEV *Zero = SE->getConstant(BackedgeTakenCount->getType(), 0); - const SCEV *N = - SE->getAddExpr(BackedgeTakenCount, - SE->getConstant(BackedgeTakenCount->getType(), 1)); - if ((isa(N) && !N->isZero()) || - SE->isLoopEntryGuardedByCond(L, ICmpInst::ICMP_NE, N, Zero)) { - // No overflow. Cast the sum. - RHS = SE->getTruncateOrZeroExtend(N, IndVar->getType()); - } else { - // Potential overflow. Cast before doing the add. - RHS = SE->getTruncateOrZeroExtend(BackedgeTakenCount, - IndVar->getType()); - RHS = SE->getAddExpr(RHS, - SE->getConstant(IndVar->getType(), 1)); - } + // Check Incr uses. One user is PN and the other user is an exit condition + // used by the conditional terminator. + Value::use_iterator IncrUse = Incr->use_begin(); + Instruction *U1 = cast(*IncrUse++); + if (IncrUse == Incr->use_end()) return; + Instruction *U2 = cast(*IncrUse++); + if (IncrUse != Incr->use_end()) return; - // The BackedgeTaken expression contains the number of times that the - // backedge branches to the loop header. This is one less than the - // number of times the loop executes, so use the incremented indvar. - CmpIndVar = IndVar->getIncomingValueForBlock(L->getExitingBlock()); - } else { - // We have to use the preincremented value... - RHS = SE->getTruncateOrZeroExtend(BackedgeTakenCount, - IndVar->getType()); - CmpIndVar = IndVar; - } + // Find exit condition, which is an fcmp. If it doesn't exist, or if it isn't + // only used by a branch, we can't transform it. + FCmpInst *Compare = dyn_cast(U1); + if (!Compare) + Compare = dyn_cast(U2); + if (Compare == 0 || !Compare->hasOneUse() || + !isa(Compare->use_back())) + return; - // Expand the code for the iteration count. - assert(SE->isLoopInvariant(RHS, L) && - "Computed iteration count is not loop invariant!"); - Value *ExitCnt = Rewriter.expandCodeFor(RHS, IndVar->getType(), BI); + BranchInst *TheBr = cast(Compare->use_back()); - // Insert a new icmp_ne or icmp_eq instruction before the branch. - ICmpInst::Predicate Opcode; - if (L->contains(BI->getSuccessor(0))) - Opcode = ICmpInst::ICMP_NE; - else - Opcode = ICmpInst::ICMP_EQ; + // We need to verify that the branch actually controls the iteration count + // of the loop. If not, the new IV can overflow and no one will notice. + // The branch block must be in the loop and one of the successors must be out + // of the loop. + assert(TheBr->isConditional() && "Can't use fcmp if not conditional"); + if (!L->contains(TheBr->getParent()) || + (L->contains(TheBr->getSuccessor(0)) && + L->contains(TheBr->getSuccessor(1)))) + return; - DEBUG(dbgs() << "INDVARS: Rewriting loop exit condition to:\n" - << " LHS:" << *CmpIndVar << '\n' - << " op:\t" - << (Opcode == ICmpInst::ICMP_NE ? "!=" : "==") << "\n" - << " RHS:\t" << *RHS << "\n"); - ICmpInst *Cond = new ICmpInst(BI, Opcode, CmpIndVar, ExitCnt, "exitcond"); - Cond->setDebugLoc(BI->getDebugLoc()); - Value *OrigCond = BI->getCondition(); - // It's tempting to use replaceAllUsesWith here to fully replace the old - // comparison, but that's not immediately safe, since users of the old - // comparison may not be dominated by the new comparison. Instead, just - // update the branch to use the new comparison; in the common case this - // will make old comparison dead. - BI->setCondition(Cond); - DeadInsts.push_back(OrigCond); + // If it isn't a comparison with an integer-as-fp (the exit value), we can't + // transform it. + ConstantFP *ExitValueVal = dyn_cast(Compare->getOperand(1)); + int64_t ExitValue; + if (ExitValueVal == 0 || + !ConvertToSInt(ExitValueVal->getValueAPF(), ExitValue)) + return; - ++NumLFTR; - Changed = true; - return Cond; -} + // Find new predicate for integer comparison. + CmpInst::Predicate NewPred = CmpInst::BAD_ICMP_PREDICATE; + switch (Compare->getPredicate()) { + default: return; // Unknown comparison. + case CmpInst::FCMP_OEQ: + case CmpInst::FCMP_UEQ: NewPred = CmpInst::ICMP_EQ; break; + case CmpInst::FCMP_ONE: + case CmpInst::FCMP_UNE: NewPred = CmpInst::ICMP_NE; break; + case CmpInst::FCMP_OGT: + case CmpInst::FCMP_UGT: NewPred = CmpInst::ICMP_SGT; break; + case CmpInst::FCMP_OGE: + case CmpInst::FCMP_UGE: NewPred = CmpInst::ICMP_SGE; break; + case CmpInst::FCMP_OLT: + case CmpInst::FCMP_ULT: NewPred = CmpInst::ICMP_SLT; break; + case CmpInst::FCMP_OLE: + case CmpInst::FCMP_ULE: NewPred = CmpInst::ICMP_SLE; break; + } -/// RewriteLoopExitValues - Check to see if this loop has a computable -/// loop-invariant execution count. If so, this means that we can compute the -/// final value of any expressions that are recurrent in the loop, and -/// substitute the exit values from the loop into any instructions outside of -/// the loop that use the final values of the current expressions. -/// -/// This is mostly redundant with the regular IndVarSimplify activities that -/// happen later, except that it's more powerful in some cases, because it's -/// able to brute-force evaluate arbitrary instructions as long as they have -/// constant operands at the beginning of the loop. -void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) { - // Verify the input to the pass in already in LCSSA form. - assert(L->isLCSSAForm(*DT)); + // We convert the floating point induction variable to a signed i32 value if + // we can. This is only safe if the comparison will not overflow in a way + // that won't be trapped by the integer equivalent operations. Check for this + // now. + // TODO: We could use i64 if it is native and the range requires it. - SmallVector ExitBlocks; - L->getUniqueExitBlocks(ExitBlocks); + // The start/stride/exit values must all fit in signed i32. + if (!isInt<32>(InitValue) || !isInt<32>(IncValue) || !isInt<32>(ExitValue)) + return; + + // If not actually striding (add x, 0.0), avoid touching the code. + if (IncValue == 0) + return; + + // Positive and negative strides have different safety conditions. + if (IncValue > 0) { + // If we have a positive stride, we require the init to be less than the + // exit value and an equality or less than comparison. + if (InitValue >= ExitValue || + NewPred == CmpInst::ICMP_SGT || NewPred == CmpInst::ICMP_SGE) + return; + + uint32_t Range = uint32_t(ExitValue-InitValue); + if (NewPred == CmpInst::ICMP_SLE) { + // Normalize SLE -> SLT, check for infinite loop. + if (++Range == 0) return; // Range overflows. + } + + unsigned Leftover = Range % uint32_t(IncValue); + + // If this is an equality comparison, we require that the strided value + // exactly land on the exit value, otherwise the IV condition will wrap + // around and do things the fp IV wouldn't. + if ((NewPred == CmpInst::ICMP_EQ || NewPred == CmpInst::ICMP_NE) && + Leftover != 0) + return; + + // If the stride would wrap around the i32 before exiting, we can't + // transform the IV. + if (Leftover != 0 && int32_t(ExitValue+IncValue) < ExitValue) + return; + + } else { + // If we have a negative stride, we require the init to be greater than the + // exit value and an equality or greater than comparison. + if (InitValue >= ExitValue || + NewPred == CmpInst::ICMP_SLT || NewPred == CmpInst::ICMP_SLE) + return; + + uint32_t Range = uint32_t(InitValue-ExitValue); + if (NewPred == CmpInst::ICMP_SGE) { + // Normalize SGE -> SGT, check for infinite loop. + if (++Range == 0) return; // Range overflows. + } + + unsigned Leftover = Range % uint32_t(-IncValue); + + // If this is an equality comparison, we require that the strided value + // exactly land on the exit value, otherwise the IV condition will wrap + // around and do things the fp IV wouldn't. + if ((NewPred == CmpInst::ICMP_EQ || NewPred == CmpInst::ICMP_NE) && + Leftover != 0) + return; + + // If the stride would wrap around the i32 before exiting, we can't + // transform the IV. + if (Leftover != 0 && int32_t(ExitValue+IncValue) > ExitValue) + return; + } + + const IntegerType *Int32Ty = Type::getInt32Ty(PN->getContext()); + + // Insert new integer induction variable. + PHINode *NewPHI = PHINode::Create(Int32Ty, 2, PN->getName()+".int", PN); + NewPHI->addIncoming(ConstantInt::get(Int32Ty, InitValue), + PN->getIncomingBlock(IncomingEdge)); + + Value *NewAdd = + BinaryOperator::CreateAdd(NewPHI, ConstantInt::get(Int32Ty, IncValue), + Incr->getName()+".int", Incr); + NewPHI->addIncoming(NewAdd, PN->getIncomingBlock(BackEdge)); + + ICmpInst *NewCompare = new ICmpInst(TheBr, NewPred, NewAdd, + ConstantInt::get(Int32Ty, ExitValue), + Compare->getName()); + + // In the following deletions, PN may become dead and may be deleted. + // Use a WeakVH to observe whether this happens. + WeakVH WeakPH = PN; + + // Delete the old floating point exit comparison. The branch starts using the + // new comparison. + NewCompare->takeName(Compare); + Compare->replaceAllUsesWith(NewCompare); + RecursivelyDeleteTriviallyDeadInstructions(Compare); + + // Delete the old floating point increment. + Incr->replaceAllUsesWith(UndefValue::get(Incr->getType())); + RecursivelyDeleteTriviallyDeadInstructions(Incr); + + // If the FP induction variable still has uses, this is because something else + // in the loop uses its value. In order to canonicalize the induction + // variable, we chose to eliminate the IV and rewrite it in terms of an + // int->fp cast. + // + // We give preference to sitofp over uitofp because it is faster on most + // platforms. + if (WeakPH) { + Value *Conv = new SIToFPInst(NewPHI, PN->getType(), "indvar.conv", + PN->getParent()->getFirstNonPHI()); + PN->replaceAllUsesWith(Conv); + RecursivelyDeleteTriviallyDeadInstructions(PN); + } + + // Add a new IVUsers entry for the newly-created integer PHI. + if (IU) + IU->AddUsersIfInteresting(NewPHI); +} + +void IndVarSimplify::RewriteNonIntegerIVs(Loop *L) { + // First step. Check to see if there are any floating-point recurrences. + // If there are, change them into integer recurrences, permitting analysis by + // the SCEV routines. + // + BasicBlock *Header = L->getHeader(); + + SmallVector PHIs; + for (BasicBlock::iterator I = Header->begin(); + PHINode *PN = dyn_cast(I); ++I) + PHIs.push_back(PN); + + for (unsigned i = 0, e = PHIs.size(); i != e; ++i) + if (PHINode *PN = dyn_cast_or_null(&*PHIs[i])) + HandleFloatingPointIV(L, PN); + + // If the loop previously had floating-point IV, ScalarEvolution + // may not have been able to compute a trip count. Now that we've done some + // re-writing, the trip count may be computable. + if (Changed) + SE->forgetLoop(L); +} + +//===----------------------------------------------------------------------===// +// RewriteLoopExitValues - Optimize IV users outside the loop. +// As a side effect, reduces the amount of IV processing within the loop. +//===----------------------------------------------------------------------===// + +/// RewriteLoopExitValues - Check to see if this loop has a computable +/// loop-invariant execution count. If so, this means that we can compute the +/// final value of any expressions that are recurrent in the loop, and +/// substitute the exit values from the loop into any instructions outside of +/// the loop that use the final values of the current expressions. +/// +/// This is mostly redundant with the regular IndVarSimplify activities that +/// happen later, except that it's more powerful in some cases, because it's +/// able to brute-force evaluate arbitrary instructions as long as they have +/// constant operands at the beginning of the loop. +void IndVarSimplify::RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter) { + // Verify the input to the pass in already in LCSSA form. + assert(L->isLCSSAForm(*DT)); + + SmallVector ExitBlocks; + L->getUniqueExitBlocks(ExitBlocks); // Find all values that are computed inside the loop, but used outside of it. // Because of LCSSA, these values will only occur in LCSSA PHI Nodes. Scan @@ -479,28 +584,10 @@ Rewriter.clearInsertPoint(); } -void IndVarSimplify::RewriteNonIntegerIVs(Loop *L) { - // First step. Check to see if there are any floating-point recurrences. - // If there are, change them into integer recurrences, permitting analysis by - // the SCEV routines. - // - BasicBlock *Header = L->getHeader(); - - SmallVector PHIs; - for (BasicBlock::iterator I = Header->begin(); - PHINode *PN = dyn_cast(I); ++I) - PHIs.push_back(PN); - - for (unsigned i = 0, e = PHIs.size(); i != e; ++i) - if (PHINode *PN = dyn_cast_or_null(&*PHIs[i])) - HandleFloatingPointIV(L, PN); - - // If the loop previously had floating-point IV, ScalarEvolution - // may not have been able to compute a trip count. Now that we've done some - // re-writing, the trip count may be computable. - if (Changed) - SE->forgetLoop(L); -} +//===----------------------------------------------------------------------===// +// Rewrite IV users based on a canonical IV. +// To be replaced by -disable-iv-rewrite. +//===----------------------------------------------------------------------===// /// SimplifyIVUsers - Iteratively perform simplification on IVUsers within this /// loop. IVUsers is treated as a worklist. Each successive simplification may @@ -532,65 +619,192 @@ } } -namespace { - // Collect information about induction variables that are used by sign/zero - // extend operations. This information is recorded by CollectExtend and - // provides the input to WidenIV. - struct WideIVInfo { - const Type *WidestNativeType; // Widest integer type created [sz]ext - bool IsSigned; // Was an sext user seen before a zext? - - WideIVInfo() : WidestNativeType(0), IsSigned(false) {} - }; -} +// FIXME: It is an extremely bad idea to indvar substitute anything more +// complex than affine induction variables. Doing so will put expensive +// polynomial evaluations inside of the loop, and the str reduction pass +// currently can only reduce affine polynomials. For now just disable +// indvar subst on anything more complex than an affine addrec, unless +// it can be expanded to a trivial value. +static bool isSafe(const SCEV *S, const Loop *L, ScalarEvolution *SE) { + // Loop-invariant values are safe. + if (SE->isLoopInvariant(S, L)) return true; -/// CollectExtend - Update information about the induction variable that is -/// extended by this sign or zero extend operation. This is used to determine -/// the final width of the IV before actually widening it. -static void CollectExtend(CastInst *Cast, bool IsSigned, WideIVInfo &WI, - ScalarEvolution *SE, const TargetData *TD) { - const Type *Ty = Cast->getType(); - uint64_t Width = SE->getTypeSizeInBits(Ty); - if (TD && !TD->isLegalInteger(Width)) - return; + // Affine addrecs are safe. Non-affine are not, because LSR doesn't know how + // to transform them into efficient code. + if (const SCEVAddRecExpr *AR = dyn_cast(S)) + return AR->isAffine(); - if (!WI.WidestNativeType) { - WI.WidestNativeType = SE->getEffectiveSCEVType(Ty); - WI.IsSigned = IsSigned; - return; + // An add is safe it all its operands are safe. + if (const SCEVCommutativeExpr *Commutative = dyn_cast(S)) { + for (SCEVCommutativeExpr::op_iterator I = Commutative->op_begin(), + E = Commutative->op_end(); I != E; ++I) + if (!isSafe(*I, L, SE)) return false; + return true; } - // We extend the IV to satisfy the sign of its first user, arbitrarily. - if (WI.IsSigned != IsSigned) - return; - - if (Width > SE->getTypeSizeInBits(WI.WidestNativeType)) - WI.WidestNativeType = SE->getEffectiveSCEVType(Ty); -} + // A cast is safe if its operand is. + if (const SCEVCastExpr *C = dyn_cast(S)) + return isSafe(C->getOperand(), L, SE); -namespace { -/// WidenIV - The goal of this transform is to remove sign and zero extends -/// without creating any new induction variables. To do this, it creates a new -/// phi of the wider type and redirects all users, either removing extends or -/// inserting truncs whenever we stop propagating the type. -/// -class WidenIV { - // Parameters - PHINode *OrigPhi; - const Type *WideType; - bool IsSigned; + // A udiv is safe if its operands are. + if (const SCEVUDivExpr *UD = dyn_cast(S)) + return isSafe(UD->getLHS(), L, SE) && + isSafe(UD->getRHS(), L, SE); - // Context - LoopInfo *LI; - Loop *L; - ScalarEvolution *SE; - DominatorTree *DT; + // SCEVUnknown is always safe. + if (isa(S)) + return true; - // Result - PHINode *WidePhi; - Instruction *WideInc; - const SCEV *WideIncExpr; - SmallVectorImpl &DeadInsts; + // Nothing else is safe. + return false; +} + +void IndVarSimplify::RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter) { + // Rewrite all induction variable expressions in terms of the canonical + // induction variable. + // + // If there were induction variables of other sizes or offsets, manually + // add the offsets to the primary induction variable and cast, avoiding + // the need for the code evaluation methods to insert induction variables + // of different sizes. + for (IVUsers::iterator UI = IU->begin(), E = IU->end(); UI != E; ++UI) { + Value *Op = UI->getOperandValToReplace(); + const Type *UseTy = Op->getType(); + Instruction *User = UI->getUser(); + + // Compute the final addrec to expand into code. + const SCEV *AR = IU->getReplacementExpr(*UI); + + // Evaluate the expression out of the loop, if possible. + if (!L->contains(UI->getUser())) { + const SCEV *ExitVal = SE->getSCEVAtScope(AR, L->getParentLoop()); + if (SE->isLoopInvariant(ExitVal, L)) + AR = ExitVal; + } + + // FIXME: It is an extremely bad idea to indvar substitute anything more + // complex than affine induction variables. Doing so will put expensive + // polynomial evaluations inside of the loop, and the str reduction pass + // currently can only reduce affine polynomials. For now just disable + // indvar subst on anything more complex than an affine addrec, unless + // it can be expanded to a trivial value. + if (!isSafe(AR, L, SE)) + continue; + + // Determine the insertion point for this user. By default, insert + // immediately before the user. The SCEVExpander class will automatically + // hoist loop invariants out of the loop. For PHI nodes, there may be + // multiple uses, so compute the nearest common dominator for the + // incoming blocks. + Instruction *InsertPt = User; + if (PHINode *PHI = dyn_cast(InsertPt)) + for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) + if (PHI->getIncomingValue(i) == Op) { + if (InsertPt == User) + InsertPt = PHI->getIncomingBlock(i)->getTerminator(); + else + InsertPt = + DT->findNearestCommonDominator(InsertPt->getParent(), + PHI->getIncomingBlock(i)) + ->getTerminator(); + } + + // Now expand it into actual Instructions and patch it into place. + Value *NewVal = Rewriter.expandCodeFor(AR, UseTy, InsertPt); + + DEBUG(dbgs() << "INDVARS: Rewrote IV '" << *AR << "' " << *Op << '\n' + << " into = " << *NewVal << "\n"); + + if (!isValidRewrite(Op, NewVal)) { + DeadInsts.push_back(NewVal); + continue; + } + // Inform ScalarEvolution that this value is changing. The change doesn't + // affect its value, but it does potentially affect which use lists the + // value will be on after the replacement, which affects ScalarEvolution's + // ability to walk use lists and drop dangling pointers when a value is + // deleted. + SE->forgetValue(User); + + // Patch the new value into place. + if (Op->hasName()) + NewVal->takeName(Op); + if (Instruction *NewValI = dyn_cast(NewVal)) + NewValI->setDebugLoc(User->getDebugLoc()); + User->replaceUsesOfWith(Op, NewVal); + UI->setOperandValToReplace(NewVal); + + ++NumRemoved; + Changed = true; + + // The old value may be dead now. + DeadInsts.push_back(Op); + } +} + +//===----------------------------------------------------------------------===// +// IV Widening - Extend the width of an IV to cover its widest uses. +//===----------------------------------------------------------------------===// + +namespace { + // Collect information about induction variables that are used by sign/zero + // extend operations. This information is recorded by CollectExtend and + // provides the input to WidenIV. + struct WideIVInfo { + const Type *WidestNativeType; // Widest integer type created [sz]ext + bool IsSigned; // Was an sext user seen before a zext? + + WideIVInfo() : WidestNativeType(0), IsSigned(false) {} + }; +} + +/// CollectExtend - Update information about the induction variable that is +/// extended by this sign or zero extend operation. This is used to determine +/// the final width of the IV before actually widening it. +static void CollectExtend(CastInst *Cast, bool IsSigned, WideIVInfo &WI, + ScalarEvolution *SE, const TargetData *TD) { + const Type *Ty = Cast->getType(); + uint64_t Width = SE->getTypeSizeInBits(Ty); + if (TD && !TD->isLegalInteger(Width)) + return; + + if (!WI.WidestNativeType) { + WI.WidestNativeType = SE->getEffectiveSCEVType(Ty); + WI.IsSigned = IsSigned; + return; + } + + // We extend the IV to satisfy the sign of its first user, arbitrarily. + if (WI.IsSigned != IsSigned) + return; + + if (Width > SE->getTypeSizeInBits(WI.WidestNativeType)) + WI.WidestNativeType = SE->getEffectiveSCEVType(Ty); +} + +namespace { +/// WidenIV - The goal of this transform is to remove sign and zero extends +/// without creating any new induction variables. To do this, it creates a new +/// phi of the wider type and redirects all users, either removing extends or +/// inserting truncs whenever we stop propagating the type. +/// +class WidenIV { + // Parameters + PHINode *OrigPhi; + const Type *WideType; + bool IsSigned; + + // Context + LoopInfo *LI; + Loop *L; + ScalarEvolution *SE; + DominatorTree *DT; + + // Result + PHINode *WidePhi; + Instruction *WideInc; + const SCEV *WideIncExpr; + SmallVectorImpl &DeadInsts; SmallPtrSet Widened; SmallVector, 8> NarrowIVUsers; @@ -935,6 +1149,10 @@ return WidePhi; } +//===----------------------------------------------------------------------===// +// Simplification of IV users based on SCEV evaluation. +//===----------------------------------------------------------------------===// + void IndVarSimplify::EliminateIVComparison(ICmpInst *ICmp, Value *IVOperand) { unsigned IVOperIdx = 0; ICmpInst::Predicate Pred = ICmp->getPredicate(); @@ -1081,7 +1299,7 @@ /// This is similar to IVUsers' isInsteresting() but processes each instruction /// non-recursively when the operand is already known to be a simpleIVUser. /// -bool IndVarSimplify::isSimpleIVUser(Instruction *I, const Loop *L) { +static bool isSimpleIVUser(Instruction *I, const Loop *L, ScalarEvolution *SE) { if (!SE->isSCEVable(I->getType())) return false; @@ -1166,7 +1384,7 @@ } continue; } - if (isSimpleIVUser(UseInst, L)) { + if (isSimpleIVUser(UseInst, L, SE)) { pushIVUsers(UseInst, Simplified, SimpleIVUsers); } } @@ -1193,6 +1411,9 @@ void IndVarSimplify::SimplifyCongruentIVs(Loop *L) { for (BasicBlock::iterator I = L->getHeader()->begin(); isa(I); ++I) { PHINode *Phi = cast(I); + if (!SE->isSCEVable(Phi->getType())) + continue; + const SCEV *S = SE->getSCEV(Phi); ExprToIVMapTy::const_iterator Pos; bool Inserted; @@ -1226,68 +1447,311 @@ } } -bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { - // If LoopSimplify form is not available, stay out of trouble. Some notes: - // - LSR currently only supports LoopSimplify-form loops. Indvars' - // canonicalization can be a pessimization without LSR to "clean up" - // afterwards. - // - We depend on having a preheader; in particular, - // Loop::getCanonicalInductionVariable only supports loops with preheaders, - // and we're in trouble if we can't find the induction variable even when - // we've manually inserted one. - if (!L->isLoopSimplifyForm()) - return false; +//===----------------------------------------------------------------------===// +// LinearFunctionTestReplace and its kin. Rewrite the loop exit condition. +//===----------------------------------------------------------------------===// - if (!DisableIVRewrite) - IU = &getAnalysis(); - LI = &getAnalysis(); - SE = &getAnalysis(); - DT = &getAnalysis(); - TD = getAnalysisIfAvailable(); +/// canExpandBackedgeTakenCount - Return true if this loop's backedge taken +/// count expression can be safely and cheaply expanded into an instruction +/// sequence that can be used by LinearFunctionTestReplace. +static bool canExpandBackedgeTakenCount(Loop *L, ScalarEvolution *SE) { + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); + if (isa(BackedgeTakenCount) || + BackedgeTakenCount->isZero()) + return false; - ExprToIVMap.clear(); - DeadInsts.clear(); - Changed = false; + if (!L->getExitingBlock()) + return false; - // If there are any floating-point recurrences, attempt to - // transform them to use integer recurrences. - RewriteNonIntegerIVs(L); + // Can't rewrite non-branch yet. + BranchInst *BI = dyn_cast(L->getExitingBlock()->getTerminator()); + if (!BI) + return false; - const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); + // Special case: If the backedge-taken count is a UDiv, it's very likely a + // UDiv that ScalarEvolution produced in order to compute a precise + // expression, rather than a UDiv from the user's code. If we can't find a + // UDiv in the code with some simple searching, assume the former and forego + // rewriting the loop. + if (isa(BackedgeTakenCount)) { + ICmpInst *OrigCond = dyn_cast(BI->getCondition()); + if (!OrigCond) return false; + const SCEV *R = SE->getSCEV(OrigCond->getOperand(1)); + R = SE->getMinusSCEV(R, SE->getConstant(R->getType(), 1)); + if (R != BackedgeTakenCount) { + const SCEV *L = SE->getSCEV(OrigCond->getOperand(0)); + L = SE->getMinusSCEV(L, SE->getConstant(L->getType(), 1)); + if (L != BackedgeTakenCount) + return false; + } + } + return true; +} - // Create a rewriter object which we'll use to transform the code with. - SCEVExpander Rewriter(*SE, "indvars"); +/// getBackedgeIVType - Get the widest type used by the loop test after peeking +/// through Truncs. +/// +/// TODO: Unnecessary if LFTR does not force a canonical IV. +static const Type *getBackedgeIVType(Loop *L) { + if (!L->getExitingBlock()) + return 0; - // Eliminate redundant IV users. - // - // Simplification works best when run before other consumers of SCEV. We - // attempt to avoid evaluating SCEVs for sign/zero extend operations until - // other expressions involving loop IVs have been evaluated. This helps SCEV - // set no-wrap flags before normalizing sign/zero extension. - if (DisableIVRewrite) { - Rewriter.disableCanonicalMode(); - SimplifyIVUsersNoRewrite(L, Rewriter); - } + // Can't rewrite non-branch yet. + BranchInst *BI = dyn_cast(L->getExitingBlock()->getTerminator()); + if (!BI) + return 0; - // Check to see if this loop has a computable loop-invariant execution count. - // If so, this means that we can compute the final value of any expressions - // that are recurrent in the loop, and substitute the exit values from the - // loop into any instructions outside of the loop that use the final values of - // the current expressions. - // - if (!isa(BackedgeTakenCount)) - RewriteLoopExitValues(L, Rewriter); + ICmpInst *Cond = dyn_cast(BI->getCondition()); + if (!Cond) + return 0; - // Eliminate redundant IV users. - if (!DisableIVRewrite) - SimplifyIVUsers(Rewriter); + const Type *Ty = 0; + for(User::op_iterator OI = Cond->op_begin(), OE = Cond->op_end(); + OI != OE; ++OI) { + assert((!Ty || Ty == (*OI)->getType()) && "bad icmp operand types"); + TruncInst *Trunc = dyn_cast(*OI); + if (!Trunc) + continue; - // Eliminate redundant IV cycles and populate ExprToIVMap. - // TODO: use ExprToIVMap to allow LFTR without canonical IVs - if (DisableIVRewrite) - SimplifyCongruentIVs(L); + return Trunc->getSrcTy(); + } + return Ty; +} - // Compute the type of the largest recurrence expression, and decide whether +/// LinearFunctionTestReplace - This method rewrites the exit condition of the +/// loop to be a canonical != comparison against the incremented loop induction +/// variable. This pass is able to rewrite the exit tests of any loop where the +/// SCEV analysis can determine a loop-invariant trip count of the loop, which +/// is actually a much broader range than just linear tests. +ICmpInst *IndVarSimplify:: +LinearFunctionTestReplace(Loop *L, + const SCEV *BackedgeTakenCount, + PHINode *IndVar, + SCEVExpander &Rewriter) { + assert(canExpandBackedgeTakenCount(L, SE) && "precondition"); + BranchInst *BI = cast(L->getExitingBlock()->getTerminator()); + + // If the exiting block is not the same as the backedge block, we must compare + // against the preincremented value, otherwise we prefer to compare against + // the post-incremented value. + Value *CmpIndVar; + const SCEV *RHS = BackedgeTakenCount; + if (L->getExitingBlock() == L->getLoopLatch()) { + // Add one to the "backedge-taken" count to get the trip count. + // If this addition may overflow, we have to be more pessimistic and + // cast the induction variable before doing the add. + const SCEV *Zero = SE->getConstant(BackedgeTakenCount->getType(), 0); + const SCEV *N = + SE->getAddExpr(BackedgeTakenCount, + SE->getConstant(BackedgeTakenCount->getType(), 1)); + if ((isa(N) && !N->isZero()) || + SE->isLoopEntryGuardedByCond(L, ICmpInst::ICMP_NE, N, Zero)) { + // No overflow. Cast the sum. + RHS = SE->getTruncateOrZeroExtend(N, IndVar->getType()); + } else { + // Potential overflow. Cast before doing the add. + RHS = SE->getTruncateOrZeroExtend(BackedgeTakenCount, + IndVar->getType()); + RHS = SE->getAddExpr(RHS, + SE->getConstant(IndVar->getType(), 1)); + } + + // The BackedgeTaken expression contains the number of times that the + // backedge branches to the loop header. This is one less than the + // number of times the loop executes, so use the incremented indvar. + CmpIndVar = IndVar->getIncomingValueForBlock(L->getExitingBlock()); + } else { + // We have to use the preincremented value... + RHS = SE->getTruncateOrZeroExtend(BackedgeTakenCount, + IndVar->getType()); + CmpIndVar = IndVar; + } + + // Expand the code for the iteration count. + assert(SE->isLoopInvariant(RHS, L) && + "Computed iteration count is not loop invariant!"); + Value *ExitCnt = Rewriter.expandCodeFor(RHS, IndVar->getType(), BI); + + // Insert a new icmp_ne or icmp_eq instruction before the branch. + ICmpInst::Predicate Opcode; + if (L->contains(BI->getSuccessor(0))) + Opcode = ICmpInst::ICMP_NE; + else + Opcode = ICmpInst::ICMP_EQ; + + DEBUG(dbgs() << "INDVARS: Rewriting loop exit condition to:\n" + << " LHS:" << *CmpIndVar << '\n' + << " op:\t" + << (Opcode == ICmpInst::ICMP_NE ? "!=" : "==") << "\n" + << " RHS:\t" << *RHS << "\n"); + + ICmpInst *Cond = new ICmpInst(BI, Opcode, CmpIndVar, ExitCnt, "exitcond"); + Cond->setDebugLoc(BI->getDebugLoc()); + Value *OrigCond = BI->getCondition(); + // It's tempting to use replaceAllUsesWith here to fully replace the old + // comparison, but that's not immediately safe, since users of the old + // comparison may not be dominated by the new comparison. Instead, just + // update the branch to use the new comparison; in the common case this + // will make old comparison dead. + BI->setCondition(Cond); + DeadInsts.push_back(OrigCond); + + ++NumLFTR; + Changed = true; + return Cond; +} + +//===----------------------------------------------------------------------===// +// SinkUnusedInvariants. A late subpass to cleanup loop preheaders. +//===----------------------------------------------------------------------===// + +/// If there's a single exit block, sink any loop-invariant values that +/// were defined in the preheader but not used inside the loop into the +/// exit block to reduce register pressure in the loop. +void IndVarSimplify::SinkUnusedInvariants(Loop *L) { + BasicBlock *ExitBlock = L->getExitBlock(); + if (!ExitBlock) return; + + BasicBlock *Preheader = L->getLoopPreheader(); + if (!Preheader) return; + + Instruction *InsertPt = ExitBlock->getFirstNonPHI(); + BasicBlock::iterator I = Preheader->getTerminator(); + while (I != Preheader->begin()) { + --I; + // New instructions were inserted at the end of the preheader. + if (isa(I)) + break; + + // Don't move instructions which might have side effects, since the side + // effects need to complete before instructions inside the loop. Also don't + // move instructions which might read memory, since the loop may modify + // memory. Note that it's okay if the instruction might have undefined + // behavior: LoopSimplify guarantees that the preheader dominates the exit + // block. + if (I->mayHaveSideEffects() || I->mayReadFromMemory()) + continue; + + // Skip debug info intrinsics. + if (isa(I)) + continue; + + // Don't sink static AllocaInsts out of the entry block, which would + // turn them into dynamic allocas! + if (AllocaInst *AI = dyn_cast(I)) + if (AI->isStaticAlloca()) + continue; + + // Determine if there is a use in or before the loop (direct or + // otherwise). + bool UsedInLoop = false; + for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); + UI != UE; ++UI) { + User *U = *UI; + BasicBlock *UseBB = cast(U)->getParent(); + if (PHINode *P = dyn_cast(U)) { + unsigned i = + PHINode::getIncomingValueNumForOperand(UI.getOperandNo()); + UseBB = P->getIncomingBlock(i); + } + if (UseBB == Preheader || L->contains(UseBB)) { + UsedInLoop = true; + break; + } + } + + // If there is, the def must remain in the preheader. + if (UsedInLoop) + continue; + + // Otherwise, sink it to the exit block. + Instruction *ToMove = I; + bool Done = false; + + if (I != Preheader->begin()) { + // Skip debug info intrinsics. + do { + --I; + } while (isa(I) && I != Preheader->begin()); + + if (isa(I) && I == Preheader->begin()) + Done = true; + } else { + Done = true; + } + + ToMove->moveBefore(InsertPt); + if (Done) break; + InsertPt = ToMove; + } +} + +//===----------------------------------------------------------------------===// +// IndVarSimplify driver. Manage several subpasses of IV simplification. +//===----------------------------------------------------------------------===// + +bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { + // If LoopSimplify form is not available, stay out of trouble. Some notes: + // - LSR currently only supports LoopSimplify-form loops. Indvars' + // canonicalization can be a pessimization without LSR to "clean up" + // afterwards. + // - We depend on having a preheader; in particular, + // Loop::getCanonicalInductionVariable only supports loops with preheaders, + // and we're in trouble if we can't find the induction variable even when + // we've manually inserted one. + if (!L->isLoopSimplifyForm()) + return false; + + if (!DisableIVRewrite) + IU = &getAnalysis(); + LI = &getAnalysis(); + SE = &getAnalysis(); + DT = &getAnalysis(); + TD = getAnalysisIfAvailable(); + + ExprToIVMap.clear(); + DeadInsts.clear(); + Changed = false; + + // If there are any floating-point recurrences, attempt to + // transform them to use integer recurrences. + RewriteNonIntegerIVs(L); + + const SCEV *BackedgeTakenCount = SE->getBackedgeTakenCount(L); + + // Create a rewriter object which we'll use to transform the code with. + SCEVExpander Rewriter(*SE, "indvars"); + + // Eliminate redundant IV users. + // + // Simplification works best when run before other consumers of SCEV. We + // attempt to avoid evaluating SCEVs for sign/zero extend operations until + // other expressions involving loop IVs have been evaluated. This helps SCEV + // set no-wrap flags before normalizing sign/zero extension. + if (DisableIVRewrite) { + Rewriter.disableCanonicalMode(); + SimplifyIVUsersNoRewrite(L, Rewriter); + } + + // Check to see if this loop has a computable loop-invariant execution count. + // If so, this means that we can compute the final value of any expressions + // that are recurrent in the loop, and substitute the exit values from the + // loop into any instructions outside of the loop that use the final values of + // the current expressions. + // + if (!isa(BackedgeTakenCount)) + RewriteLoopExitValues(L, Rewriter); + + // Eliminate redundant IV users. + if (!DisableIVRewrite) + SimplifyIVUsers(Rewriter); + + // Eliminate redundant IV cycles and populate ExprToIVMap. + // TODO: use ExprToIVMap to allow LFTR without canonical IVs + if (DisableIVRewrite) + SimplifyCongruentIVs(L); + + // Compute the type of the largest recurrence expression, and decide whether // a canonical induction variable should be inserted. const Type *LargestType = 0; bool NeedCannIV = false; @@ -1364,8 +1828,7 @@ "canonical IV disrupted BackedgeTaken expansion"); assert(NeedCannIV && "LinearFunctionTestReplace requires a canonical induction variable"); - NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, - Rewriter); + NewICmp = LinearFunctionTestReplace(L, BackedgeTakenCount, IndVar, Rewriter); } // Rewrite IV-derived expressions. if (!DisableIVRewrite) @@ -1401,431 +1864,3 @@ assert(L->isLCSSAForm(*DT) && "Indvars did not leave the loop in lcssa form!"); return Changed; } - -// FIXME: It is an extremely bad idea to indvar substitute anything more -// complex than affine induction variables. Doing so will put expensive -// polynomial evaluations inside of the loop, and the str reduction pass -// currently can only reduce affine polynomials. For now just disable -// indvar subst on anything more complex than an affine addrec, unless -// it can be expanded to a trivial value. -static bool isSafe(const SCEV *S, const Loop *L, ScalarEvolution *SE) { - // Loop-invariant values are safe. - if (SE->isLoopInvariant(S, L)) return true; - - // Affine addrecs are safe. Non-affine are not, because LSR doesn't know how - // to transform them into efficient code. - if (const SCEVAddRecExpr *AR = dyn_cast(S)) - return AR->isAffine(); - - // An add is safe it all its operands are safe. - if (const SCEVCommutativeExpr *Commutative = dyn_cast(S)) { - for (SCEVCommutativeExpr::op_iterator I = Commutative->op_begin(), - E = Commutative->op_end(); I != E; ++I) - if (!isSafe(*I, L, SE)) return false; - return true; - } - - // A cast is safe if its operand is. - if (const SCEVCastExpr *C = dyn_cast(S)) - return isSafe(C->getOperand(), L, SE); - - // A udiv is safe if its operands are. - if (const SCEVUDivExpr *UD = dyn_cast(S)) - return isSafe(UD->getLHS(), L, SE) && - isSafe(UD->getRHS(), L, SE); - - // SCEVUnknown is always safe. - if (isa(S)) - return true; - - // Nothing else is safe. - return false; -} - -void IndVarSimplify::RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter) { - // Rewrite all induction variable expressions in terms of the canonical - // induction variable. - // - // If there were induction variables of other sizes or offsets, manually - // add the offsets to the primary induction variable and cast, avoiding - // the need for the code evaluation methods to insert induction variables - // of different sizes. - for (IVUsers::iterator UI = IU->begin(), E = IU->end(); UI != E; ++UI) { - Value *Op = UI->getOperandValToReplace(); - const Type *UseTy = Op->getType(); - Instruction *User = UI->getUser(); - - // Compute the final addrec to expand into code. - const SCEV *AR = IU->getReplacementExpr(*UI); - - // Evaluate the expression out of the loop, if possible. - if (!L->contains(UI->getUser())) { - const SCEV *ExitVal = SE->getSCEVAtScope(AR, L->getParentLoop()); - if (SE->isLoopInvariant(ExitVal, L)) - AR = ExitVal; - } - - // FIXME: It is an extremely bad idea to indvar substitute anything more - // complex than affine induction variables. Doing so will put expensive - // polynomial evaluations inside of the loop, and the str reduction pass - // currently can only reduce affine polynomials. For now just disable - // indvar subst on anything more complex than an affine addrec, unless - // it can be expanded to a trivial value. - if (!isSafe(AR, L, SE)) - continue; - - // Determine the insertion point for this user. By default, insert - // immediately before the user. The SCEVExpander class will automatically - // hoist loop invariants out of the loop. For PHI nodes, there may be - // multiple uses, so compute the nearest common dominator for the - // incoming blocks. - Instruction *InsertPt = User; - if (PHINode *PHI = dyn_cast(InsertPt)) - for (unsigned i = 0, e = PHI->getNumIncomingValues(); i != e; ++i) - if (PHI->getIncomingValue(i) == Op) { - if (InsertPt == User) - InsertPt = PHI->getIncomingBlock(i)->getTerminator(); - else - InsertPt = - DT->findNearestCommonDominator(InsertPt->getParent(), - PHI->getIncomingBlock(i)) - ->getTerminator(); - } - - // Now expand it into actual Instructions and patch it into place. - Value *NewVal = Rewriter.expandCodeFor(AR, UseTy, InsertPt); - - DEBUG(dbgs() << "INDVARS: Rewrote IV '" << *AR << "' " << *Op << '\n' - << " into = " << *NewVal << "\n"); - - if (!isValidRewrite(Op, NewVal)) { - DeadInsts.push_back(NewVal); - continue; - } - // Inform ScalarEvolution that this value is changing. The change doesn't - // affect its value, but it does potentially affect which use lists the - // value will be on after the replacement, which affects ScalarEvolution's - // ability to walk use lists and drop dangling pointers when a value is - // deleted. - SE->forgetValue(User); - - // Patch the new value into place. - if (Op->hasName()) - NewVal->takeName(Op); - if (Instruction *NewValI = dyn_cast(NewVal)) - NewValI->setDebugLoc(User->getDebugLoc()); - User->replaceUsesOfWith(Op, NewVal); - UI->setOperandValToReplace(NewVal); - - ++NumRemoved; - Changed = true; - - // The old value may be dead now. - DeadInsts.push_back(Op); - } -} - -/// If there's a single exit block, sink any loop-invariant values that -/// were defined in the preheader but not used inside the loop into the -/// exit block to reduce register pressure in the loop. -void IndVarSimplify::SinkUnusedInvariants(Loop *L) { - BasicBlock *ExitBlock = L->getExitBlock(); - if (!ExitBlock) return; - - BasicBlock *Preheader = L->getLoopPreheader(); - if (!Preheader) return; - - Instruction *InsertPt = ExitBlock->getFirstNonPHI(); - BasicBlock::iterator I = Preheader->getTerminator(); - while (I != Preheader->begin()) { - --I; - // New instructions were inserted at the end of the preheader. - if (isa(I)) - break; - - // Don't move instructions which might have side effects, since the side - // effects need to complete before instructions inside the loop. Also don't - // move instructions which might read memory, since the loop may modify - // memory. Note that it's okay if the instruction might have undefined - // behavior: LoopSimplify guarantees that the preheader dominates the exit - // block. - if (I->mayHaveSideEffects() || I->mayReadFromMemory()) - continue; - - // Skip debug info intrinsics. - if (isa(I)) - continue; - - // Don't sink static AllocaInsts out of the entry block, which would - // turn them into dynamic allocas! - if (AllocaInst *AI = dyn_cast(I)) - if (AI->isStaticAlloca()) - continue; - - // Determine if there is a use in or before the loop (direct or - // otherwise). - bool UsedInLoop = false; - for (Value::use_iterator UI = I->use_begin(), UE = I->use_end(); - UI != UE; ++UI) { - User *U = *UI; - BasicBlock *UseBB = cast(U)->getParent(); - if (PHINode *P = dyn_cast(U)) { - unsigned i = - PHINode::getIncomingValueNumForOperand(UI.getOperandNo()); - UseBB = P->getIncomingBlock(i); - } - if (UseBB == Preheader || L->contains(UseBB)) { - UsedInLoop = true; - break; - } - } - - // If there is, the def must remain in the preheader. - if (UsedInLoop) - continue; - - // Otherwise, sink it to the exit block. - Instruction *ToMove = I; - bool Done = false; - - if (I != Preheader->begin()) { - // Skip debug info intrinsics. - do { - --I; - } while (isa(I) && I != Preheader->begin()); - - if (isa(I) && I == Preheader->begin()) - Done = true; - } else { - Done = true; - } - - ToMove->moveBefore(InsertPt); - if (Done) break; - InsertPt = ToMove; - } -} - -/// ConvertToSInt - Convert APF to an integer, if possible. -static bool ConvertToSInt(const APFloat &APF, int64_t &IntVal) { - bool isExact = false; - if (&APF.getSemantics() == &APFloat::PPCDoubleDouble) - return false; - // See if we can convert this to an int64_t - uint64_t UIntVal; - if (APF.convertToInteger(&UIntVal, 64, true, APFloat::rmTowardZero, - &isExact) != APFloat::opOK || !isExact) - return false; - IntVal = UIntVal; - return true; -} - -/// HandleFloatingPointIV - If the loop has floating induction variable -/// then insert corresponding integer induction variable if possible. -/// For example, -/// for(double i = 0; i < 10000; ++i) -/// bar(i) -/// is converted into -/// for(int i = 0; i < 10000; ++i) -/// bar((double)i); -/// -void IndVarSimplify::HandleFloatingPointIV(Loop *L, PHINode *PN) { - unsigned IncomingEdge = L->contains(PN->getIncomingBlock(0)); - unsigned BackEdge = IncomingEdge^1; - - // Check incoming value. - ConstantFP *InitValueVal = - dyn_cast(PN->getIncomingValue(IncomingEdge)); - - int64_t InitValue; - if (!InitValueVal || !ConvertToSInt(InitValueVal->getValueAPF(), InitValue)) - return; - - // Check IV increment. Reject this PN if increment operation is not - // an add or increment value can not be represented by an integer. - BinaryOperator *Incr = - dyn_cast(PN->getIncomingValue(BackEdge)); - if (Incr == 0 || Incr->getOpcode() != Instruction::FAdd) return; - - // If this is not an add of the PHI with a constantfp, or if the constant fp - // is not an integer, bail out. - ConstantFP *IncValueVal = dyn_cast(Incr->getOperand(1)); - int64_t IncValue; - if (IncValueVal == 0 || Incr->getOperand(0) != PN || - !ConvertToSInt(IncValueVal->getValueAPF(), IncValue)) - return; - - // Check Incr uses. One user is PN and the other user is an exit condition - // used by the conditional terminator. - Value::use_iterator IncrUse = Incr->use_begin(); - Instruction *U1 = cast(*IncrUse++); - if (IncrUse == Incr->use_end()) return; - Instruction *U2 = cast(*IncrUse++); - if (IncrUse != Incr->use_end()) return; - - // Find exit condition, which is an fcmp. If it doesn't exist, or if it isn't - // only used by a branch, we can't transform it. - FCmpInst *Compare = dyn_cast(U1); - if (!Compare) - Compare = dyn_cast(U2); - if (Compare == 0 || !Compare->hasOneUse() || - !isa(Compare->use_back())) - return; - - BranchInst *TheBr = cast(Compare->use_back()); - - // We need to verify that the branch actually controls the iteration count - // of the loop. If not, the new IV can overflow and no one will notice. - // The branch block must be in the loop and one of the successors must be out - // of the loop. - assert(TheBr->isConditional() && "Can't use fcmp if not conditional"); - if (!L->contains(TheBr->getParent()) || - (L->contains(TheBr->getSuccessor(0)) && - L->contains(TheBr->getSuccessor(1)))) - return; - - - // If it isn't a comparison with an integer-as-fp (the exit value), we can't - // transform it. - ConstantFP *ExitValueVal = dyn_cast(Compare->getOperand(1)); - int64_t ExitValue; - if (ExitValueVal == 0 || - !ConvertToSInt(ExitValueVal->getValueAPF(), ExitValue)) - return; - - // Find new predicate for integer comparison. - CmpInst::Predicate NewPred = CmpInst::BAD_ICMP_PREDICATE; - switch (Compare->getPredicate()) { - default: return; // Unknown comparison. - case CmpInst::FCMP_OEQ: - case CmpInst::FCMP_UEQ: NewPred = CmpInst::ICMP_EQ; break; - case CmpInst::FCMP_ONE: - case CmpInst::FCMP_UNE: NewPred = CmpInst::ICMP_NE; break; - case CmpInst::FCMP_OGT: - case CmpInst::FCMP_UGT: NewPred = CmpInst::ICMP_SGT; break; - case CmpInst::FCMP_OGE: - case CmpInst::FCMP_UGE: NewPred = CmpInst::ICMP_SGE; break; - case CmpInst::FCMP_OLT: - case CmpInst::FCMP_ULT: NewPred = CmpInst::ICMP_SLT; break; - case CmpInst::FCMP_OLE: - case CmpInst::FCMP_ULE: NewPred = CmpInst::ICMP_SLE; break; - } - - // We convert the floating point induction variable to a signed i32 value if - // we can. This is only safe if the comparison will not overflow in a way - // that won't be trapped by the integer equivalent operations. Check for this - // now. - // TODO: We could use i64 if it is native and the range requires it. - - // The start/stride/exit values must all fit in signed i32. - if (!isInt<32>(InitValue) || !isInt<32>(IncValue) || !isInt<32>(ExitValue)) - return; - - // If not actually striding (add x, 0.0), avoid touching the code. - if (IncValue == 0) - return; - - // Positive and negative strides have different safety conditions. - if (IncValue > 0) { - // If we have a positive stride, we require the init to be less than the - // exit value and an equality or less than comparison. - if (InitValue >= ExitValue || - NewPred == CmpInst::ICMP_SGT || NewPred == CmpInst::ICMP_SGE) - return; - - uint32_t Range = uint32_t(ExitValue-InitValue); - if (NewPred == CmpInst::ICMP_SLE) { - // Normalize SLE -> SLT, check for infinite loop. - if (++Range == 0) return; // Range overflows. - } - - unsigned Leftover = Range % uint32_t(IncValue); - - // If this is an equality comparison, we require that the strided value - // exactly land on the exit value, otherwise the IV condition will wrap - // around and do things the fp IV wouldn't. - if ((NewPred == CmpInst::ICMP_EQ || NewPred == CmpInst::ICMP_NE) && - Leftover != 0) - return; - - // If the stride would wrap around the i32 before exiting, we can't - // transform the IV. - if (Leftover != 0 && int32_t(ExitValue+IncValue) < ExitValue) - return; - - } else { - // If we have a negative stride, we require the init to be greater than the - // exit value and an equality or greater than comparison. - if (InitValue >= ExitValue || - NewPred == CmpInst::ICMP_SLT || NewPred == CmpInst::ICMP_SLE) - return; - - uint32_t Range = uint32_t(InitValue-ExitValue); - if (NewPred == CmpInst::ICMP_SGE) { - // Normalize SGE -> SGT, check for infinite loop. - if (++Range == 0) return; // Range overflows. - } - - unsigned Leftover = Range % uint32_t(-IncValue); - - // If this is an equality comparison, we require that the strided value - // exactly land on the exit value, otherwise the IV condition will wrap - // around and do things the fp IV wouldn't. - if ((NewPred == CmpInst::ICMP_EQ || NewPred == CmpInst::ICMP_NE) && - Leftover != 0) - return; - - // If the stride would wrap around the i32 before exiting, we can't - // transform the IV. - if (Leftover != 0 && int32_t(ExitValue+IncValue) > ExitValue) - return; - } - - const IntegerType *Int32Ty = Type::getInt32Ty(PN->getContext()); - - // Insert new integer induction variable. - PHINode *NewPHI = PHINode::Create(Int32Ty, 2, PN->getName()+".int", PN); - NewPHI->addIncoming(ConstantInt::get(Int32Ty, InitValue), - PN->getIncomingBlock(IncomingEdge)); - - Value *NewAdd = - BinaryOperator::CreateAdd(NewPHI, ConstantInt::get(Int32Ty, IncValue), - Incr->getName()+".int", Incr); - NewPHI->addIncoming(NewAdd, PN->getIncomingBlock(BackEdge)); - - ICmpInst *NewCompare = new ICmpInst(TheBr, NewPred, NewAdd, - ConstantInt::get(Int32Ty, ExitValue), - Compare->getName()); - - // In the following deletions, PN may become dead and may be deleted. - // Use a WeakVH to observe whether this happens. - WeakVH WeakPH = PN; - - // Delete the old floating point exit comparison. The branch starts using the - // new comparison. - NewCompare->takeName(Compare); - Compare->replaceAllUsesWith(NewCompare); - RecursivelyDeleteTriviallyDeadInstructions(Compare); - - // Delete the old floating point increment. - Incr->replaceAllUsesWith(UndefValue::get(Incr->getType())); - RecursivelyDeleteTriviallyDeadInstructions(Incr); - - // If the FP induction variable still has uses, this is because something else - // in the loop uses its value. In order to canonicalize the induction - // variable, we chose to eliminate the IV and rewrite it in terms of an - // int->fp cast. - // - // We give preference to sitofp over uitofp because it is faster on most - // platforms. - if (WeakPH) { - Value *Conv = new SIToFPInst(NewPHI, PN->getType(), "indvar.conv", - PN->getParent()->getFirstNonPHI()); - PN->replaceAllUsesWith(Conv); - RecursivelyDeleteTriviallyDeadInstructions(PN); - } - - // Add a new IVUsers entry for the newly-created integer PHI. - if (IU) - IU->AddUsersIfInteresting(NewPHI); -} From gkistanova at gmail.com Mon Jul 11 19:10:48 2011 From: gkistanova at gmail.com (Galina Kistanova) Date: Mon, 11 Jul 2011 17:10:48 -0700 Subject: [llvm-commits] [llvm] r134888 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumenta Message-ID: Hello Jay, Just to make sure you've seen that this had broken few builds: http://google1.osuosl.org:8011/builders/llvm-gcc-native-mingw32, http://google1.osuosl.org:8011/builders/llvm-gcc-i686-pc-linux-gnu-cross-arm-eabi-soft-float etc. on step.make_llvmgcc. Thanks Galina On Mon, Jul 11, 2011 at 12:56 AM, Jay Foad wrote: > Author: foad > Date: Mon Jul 11 02:56:41 2011 > New Revision: 134888 > > URL: http://llvm.org/viewvc/llvm-project?rev=134888&view=rev > Log: > De-constify Types in FunctionType::get(). > > Modified: > ? ?llvm/trunk/include/llvm/DerivedTypes.h > ? ?llvm/trunk/include/llvm/Intrinsics.h > ? ?llvm/trunk/include/llvm/Support/TypeBuilder.h > ? ?llvm/trunk/lib/AsmParser/LLParser.cpp > ? ?llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > ? ?llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp > ? ?llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp > ? ?llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp > ? ?llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp > ? ?llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp > ? ?llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp > ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp > ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp > ? ?llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp > ? ?llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > ? ?llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp > ? ?llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp > ? ?llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > ? ?llvm/trunk/lib/VMCore/Core.cpp > ? ?llvm/trunk/lib/VMCore/Function.cpp > ? ?llvm/trunk/lib/VMCore/IRBuilder.cpp > ? ?llvm/trunk/lib/VMCore/Module.cpp > ? ?llvm/trunk/lib/VMCore/Type.cpp > ? ?llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp > ? ?llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp > ? ?llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > ? ?llvm/trunk/unittests/Support/TypeBuilderTest.cpp > ? ?llvm/trunk/unittests/VMCore/PassManagerTest.cpp > > Modified: llvm/trunk/include/llvm/DerivedTypes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/DerivedTypes.h (original) > +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 02:56:41 2011 > @@ -103,8 +103,6 @@ > ? /// a FunctionType. > ? /// > ? static FunctionType *get(const Type *Result, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ArrayRef Params, bool isVarArg); > - ?static FunctionType *get(const Type *Result, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArrayRef Params, bool isVarArg); > > ? /// FunctionType::get - Create a FunctionType taking no parameters. > > Modified: llvm/trunk/include/llvm/Intrinsics.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Intrinsics.h (original) > +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 02:56:41 2011 > @@ -44,12 +44,12 @@ > > ? /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as > ? /// "llvm.ppc.altivec.lvx". > - ?std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); > + ?std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); > > ? /// Intrinsic::getType(ID) - Return the function type for an intrinsic. > ? /// > ? const FunctionType *getType(LLVMContext &Context, ID id, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Type **Tys = 0, unsigned numTys = 0); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type **Tys = 0, unsigned numTys = 0); > > ? /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be > ? /// overloaded. > @@ -67,7 +67,7 @@ > ? /// overloaded intrinsic, Tys should point to an array of numTys pointers to > ? /// Type, and must provide exactly one type for each overloaded type in the > ? /// intrinsic. > - ?Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, > + ?Function *getDeclaration(Module *M, ID id, Type **Tys = 0, > ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned numTys = 0); > > ? /// Map a GCC builtin name to an intrinsic ID. > > Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 02:56:41 2011 > @@ -51,7 +51,7 @@ > ?/// ? namespace llvm { > ?/// ? template class TypeBuilder { > ?/// ? public: > -/// ? ? static const StructType *get(LLVMContext &Context) { > +/// ? ? static StructType *get(LLVMContext &Context) { > ?/// ? ? ? // If you cache this result, be sure to cache it separately > ?/// ? ? ? // for each LLVMContext. > ?/// ? ? ? return StructType::get( > @@ -104,7 +104,7 @@ > ?// Pointers > ?template class TypeBuilder { > ?public: > - ?static const PointerType *get(LLVMContext &Context) { > + ?static PointerType *get(LLVMContext &Context) { > ? ? return PointerType::getUnqual(TypeBuilder::get(Context)); > ? } > ?}; > @@ -115,14 +115,14 @@ > ?// Arrays > ?template class TypeBuilder { > ?public: > - ?static const ArrayType *get(LLVMContext &Context) { > + ?static ArrayType *get(LLVMContext &Context) { > ? ? return ArrayType::get(TypeBuilder::get(Context), N); > ? } > ?}; > ?/// LLVM uses an array of length 0 to represent an unknown-length array. > ?template class TypeBuilder { > ?public: > - ?static const ArrayType *get(LLVMContext &Context) { > + ?static ArrayType *get(LLVMContext &Context) { > ? ? return ArrayType::get(TypeBuilder::get(Context), 0); > ? } > ?}; > @@ -152,7 +152,7 @@ > ?#define DEFINE_INTEGRAL_TYPEBUILDER(T) \ > ?template<> class TypeBuilder { \ > ?public: \ > - ?static const IntegerType *get(LLVMContext &Context) { \ > + ?static IntegerType *get(LLVMContext &Context) { \ > ? ? return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ > ? } \ > ?}; \ > @@ -181,14 +181,14 @@ > ?template > ?class TypeBuilder, cross> { > ?public: > - ?static const IntegerType *get(LLVMContext &C) { > + ?static IntegerType *get(LLVMContext &C) { > ? ? return IntegerType::get(C, num_bits); > ? } > ?}; > > ?template<> class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { > + ?static Type *get(LLVMContext& C) { > ? ? return Type::getFloatTy(C); > ? } > ?}; > @@ -196,7 +196,7 @@ > > ?template<> class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { > + ?static Type *get(LLVMContext& C) { > ? ? return Type::getDoubleTy(C); > ? } > ?}; > @@ -204,32 +204,32 @@ > > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } > + ?static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } > + ?static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } > + ?static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } > + ?static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } > + ?static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } > + ?static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } > ?}; > > ?template class TypeBuilder { > ?public: > - ?static const Type *get(LLVMContext &C) { > + ?static Type *get(LLVMContext &C) { > ? ? return Type::getVoidTy(C); > ? } > ?}; > @@ -247,14 +247,14 @@ > > ?template class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > + ?static FunctionType *get(LLVMContext &Context) { > ? ? return FunctionType::get(TypeBuilder::get(Context), false); > ? } > ?}; > ?template class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(1); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? return FunctionType::get(TypeBuilder::get(Context), > @@ -264,8 +264,8 @@ > ?template > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(2); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -276,8 +276,8 @@ > ?template > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(3); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -291,8 +291,8 @@ > ? ? ? ? ?bool cross> > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(4); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -307,8 +307,8 @@ > ? ? ? ? ?typename A5, bool cross> > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(5); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -322,15 +322,15 @@ > > ?template class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > + ?static FunctionType *get(LLVMContext &Context) { > ? ? return FunctionType::get(TypeBuilder::get(Context), true); > ? } > ?}; > ?template > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(1); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? return FunctionType::get(TypeBuilder::get(Context), params, true); > @@ -339,8 +339,8 @@ > ?template > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(2); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -351,8 +351,8 @@ > ?template > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(3); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -366,8 +366,8 @@ > ? ? ? ? ?bool cross> > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(4); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > @@ -382,8 +382,8 @@ > ? ? ? ? ?typename A5, bool cross> > ?class TypeBuilder { > ?public: > - ?static const FunctionType *get(LLVMContext &Context) { > - ? ?std::vector params; > + ?static FunctionType *get(LLVMContext &Context) { > + ? ?std::vector params; > ? ? params.reserve(5); > ? ? params.push_back(TypeBuilder::get(Context)); > ? ? params.push_back(TypeBuilder::get(Context)); > > Modified: llvm/trunk/lib/AsmParser/LLParser.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) > +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 02:56:41 2011 > @@ -1442,7 +1442,7 @@ > ? ? ? ? ? ? ? ? ? ?"argument attributes invalid in function type"); > ? } > > - ?SmallVector ArgListTy; > + ?SmallVector ArgListTy; > ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ? ? ArgListTy.push_back(ArgList[i].Ty); > > @@ -2655,7 +2655,7 @@ > > ? // Okay, if we got here, the function is syntactically valid. ?Convert types > ? // and do semantic checks. > - ?std::vector ParamTypeList; > + ?std::vector ParamTypeList; > ? SmallVector Attrs; > > ? if (RetAttrs != Attribute::None) > @@ -3171,7 +3171,7 @@ > ? if (!(PFTy = dyn_cast(RetType)) || > ? ? ? !(Ty = dyn_cast(PFTy->getElementType()))) { > ? ? // Pull out the types of all of the arguments... > - ? ?std::vector ParamTypes; > + ? ?std::vector ParamTypes; > ? ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ? ? ? ParamTypes.push_back(ArgList[i].V->getType()); > > @@ -3508,7 +3508,7 @@ > ? if (!(PFTy = dyn_cast(RetType)) || > ? ? ? !(Ty = dyn_cast(PFTy->getElementType()))) { > ? ? // Pull out the types of all of the arguments... > - ? ?std::vector ParamTypes; > + ? ?std::vector ParamTypes; > ? ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ? ? ? ParamTypes.push_back(ArgList[i].V->getType()); > > > Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) > +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 02:56:41 2011 > @@ -582,7 +582,7 @@ > ? ? ? // FUNCTION: [vararg, attrid, retty, paramty x N] > ? ? ? if (Record.size() < 3) > ? ? ? ? return Error("Invalid FUNCTION type record"); > - ? ? ?std::vector ArgTys; > + ? ? ?std::vector ArgTys; > ? ? ? for (unsigned i = 3, e = Record.size(); i != e; ++i) { > ? ? ? ? if (Type *T = getTypeByID(Record[i])) > ? ? ? ? ? ArgTys.push_back(T); > @@ -838,7 +838,7 @@ > ? ? ? // FUNCTION: [vararg, attrid, retty, paramty x N] > ? ? ? if (Record.size() < 3) > ? ? ? ? return Error("Invalid FUNCTION type record"); > - ? ? ?std::vector ArgTys; > + ? ? ?std::vector ArgTys; > ? ? ? for (unsigned i = 3, e = Record.size(); i != e; ++i) { > ? ? ? ? if (Type *Elt = getTypeByIDOrNull(Record[i])) > ? ? ? ? ? ArgTys.push_back(Elt); > > Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) > +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 02:56:41 2011 > @@ -497,10 +497,8 @@ > ? // Find the rewind function if we didn't already. > ? if (!RewindFunction) { > ? ? LLVMContext &Ctx = ResumeInsts[0]->getContext(); > - ? ?std::vector > - ? ? ?Params(1, Type::getInt8PtrTy(Ctx)); > ? ? FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Params, false); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt8PtrTy(Ctx), false); > ? ? const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); > ? ? RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); > ? } > > Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) > +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 02:56:41 2011 > @@ -29,7 +29,7 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArgIt ArgBegin, ArgIt ArgEnd, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Type *RetTy) { > ? // Insert a correctly-typed definition now. > - ?std::vector ParamTys; > + ?std::vector ParamTys; > ? for (ArgIt I = ArgBegin; I != ArgEnd; ++I) > ? ? ParamTys.push_back(I->getType()); > ? M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); > @@ -69,7 +69,7 @@ > ? // program already contains a function with this name. > ? Module *M = CI->getParent()->getParent()->getParent(); > ? // Get or insert the definition now. > - ?std::vector ParamTys; > + ?std::vector ParamTys; > ? for (ArgIt I = ArgBegin; I != ArgEnd; ++I) > ? ? ParamTys.push_back((*I)->getType()); > ? Constant* FCache = M->getOrInsertFunction(NewFn, > @@ -553,12 +553,12 @@ > ? ? ? !CI->getType()->isIntegerTy()) > ? ? return false; > > - ?const IntegerType *Ty = dyn_cast(CI->getType()); > + ?IntegerType *Ty = dyn_cast(CI->getType()); > ? if (!Ty) > ? ? return false; > > ? // Okay, we can do this xform, do so now. > - ?const Type *Tys[] = { Ty }; > + ?Type *Tys[] = { Ty }; > ? Module *M = CI->getParent()->getParent()->getParent(); > ? Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); > > > Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) > +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 > @@ -83,7 +83,7 @@ > > ?static const FunctionType *getType(LLVMContext &Context, unsigned id) { > ? const Type *ResultTy = NULL; > - ?std::vector ArgTys; > + ?std::vector ArgTys; > ? bool IsVarArg = false; > > ?#define GET_INTRINSIC_GENERATOR > > Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) > +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 > @@ -92,7 +92,7 @@ > > ?static const FunctionType *getType(LLVMContext &Context, unsigned id) { > ? const Type *ResultTy = NULL; > - ?std::vector ArgTys; > + ?std::vector ArgTys; > ? bool IsVarArg = false; > > ?#define GET_INTRINSIC_GENERATOR > > Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 02:56:41 2011 > @@ -493,7 +493,7 @@ > ? // Start by computing a new prototype for the function, which is the same as > ? // the old function, but has modified arguments. > ? const FunctionType *FTy = F->getFunctionType(); > - ?std::vector Params; > + ?std::vector Params; > > ? typedef std::set ScalarizeTable; > > > Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 02:56:41 2011 > @@ -208,7 +208,7 @@ > ? // the old function, but doesn't have isVarArg set. > ? const FunctionType *FTy = Fn.getFunctionType(); > > - ?std::vector Params(FTy->param_begin(), FTy->param_end()); > + ?std::vector Params(FTy->param_begin(), FTy->param_end()); > ? FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Params, false); > ? unsigned NumArgs = Params.size(); > @@ -647,7 +647,7 @@ > ? // Start by computing a new prototype for the function, which is the same as > ? // the old function, but has fewer arguments and a different return type. > ? const FunctionType *FTy = F->getFunctionType(); > - ?std::vector Params; > + ?std::vector Params; > > ? // Set up to build a new list of parameter attributes. > ? SmallVector AttributesVec; > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 02:56:41 2011 > @@ -1400,7 +1400,7 @@ > ?/// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. > ?/// If so, insert the new bswap intrinsic and return it. > ?Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { > - ?const IntegerType *ITy = dyn_cast(I.getType()); > + ?IntegerType *ITy = dyn_cast(I.getType()); > ? if (!ITy || ITy->getBitWidth() % 16 || > ? ? ? // ByteMask only allows up to 32-byte values. > ? ? ? ITy->getBitWidth() > 32*8) > @@ -1424,7 +1424,7 @@ > ? for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) > ? ? if (ByteValues[i] != V) > ? ? ? return 0; > - ?const Type *Tys[] = { ITy }; > + ?Type *Tys[] = { ITy }; > ? Module *M = I.getParent()->getParent()->getParent(); > ? Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); > ? return CallInst::Create(F, V); > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 02:56:41 2011 > @@ -217,9 +217,9 @@ > ? ? ? ? if (GVSrc->isConstant()) { > ? ? ? ? ? Module *M = CI.getParent()->getParent()->getParent(); > ? ? ? ? ? Intrinsic::ID MemCpyID = Intrinsic::memcpy; > - ? ? ? ? ?const Type *Tys[3] = { CI.getArgOperand(0)->getType(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(1)->getType(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(2)->getType() }; > + ? ? ? ? ?Type *Tys[3] = { CI.getArgOperand(0)->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(1)->getType(), > + ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(2)->getType() }; > ? ? ? ? ? CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); > ? ? ? ? ? Changed = true; > ? ? ? ? } > @@ -1187,7 +1187,7 @@ > ? const AttrListPtr &NestAttrs = NestF->getAttributes(); > ? if (!NestAttrs.isEmpty()) { > ? ? unsigned NestIdx = 1; > - ? ?const Type *NestTy = 0; > + ? ?Type *NestTy = 0; > ? ? Attributes NestAttr = Attribute::None; > > ? ? // Look for a parameter marked with the 'nest' attribute. > @@ -1249,7 +1249,7 @@ > ? ? ? // Handle this by synthesizing a new function type, equal to FTy > ? ? ? // with the chain parameter inserted. > > - ? ? ?std::vector NewTypes; > + ? ? ?std::vector NewTypes; > ? ? ? NewTypes.reserve(FTy->getNumParams()+1); > > ? ? ? // Insert the chain's type into the list of parameter types, which may > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 02:56:41 2011 > @@ -1683,7 +1683,7 @@ > ? // result and the overflow bit. > ? Module *M = I.getParent()->getParent()->getParent(); > > - ?const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); > + ?Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); > ? Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&NewType, 1); > > @@ -1725,7 +1725,7 @@ > ? Builder->SetInsertPoint(OrigAdd); > > ? Module *M = I.getParent()->getParent()->getParent(); > - ?const Type *Ty = LHS->getType(); > + ?Type *Ty = LHS->getType(); > ? Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); > ? CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); > ? Value *Add = Builder->CreateExtractValue(Call, 0); > > Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) > +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 02:56:41 2011 > @@ -572,14 +572,13 @@ > ?} > > ?Constant *GCOVProfiler::getStartFileFunc() { > - ?const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; > ? const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Args, false); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt8PtrTy(*Ctx), false); > ? return M->getOrInsertFunction("llvm_gcda_start_file", FTy); > ?} > > ?Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { > - ?const Type *Args[] = { > + ?Type *Args[] = { > ? ? Type::getInt32PtrTy(*Ctx), ? ? ? ? ? ? ? ? ?// uint32_t *predecessor > ? ? Type::getInt64PtrTy(*Ctx)->getPointerTo(), ?// uint64_t **state_table_row > ? }; > @@ -589,7 +588,7 @@ > ?} > > ?Constant *GCOVProfiler::getEmitFunctionFunc() { > - ?const Type *Args[2] = { > + ?Type *Args[2] = { > ? ? Type::getInt32Ty(*Ctx), ? ?// uint32_t ident > ? ? Type::getInt8PtrTy(*Ctx), ?// const char *function_name > ? }; > @@ -599,7 +598,7 @@ > ?} > > ?Constant *GCOVProfiler::getEmitArcsFunc() { > - ?const Type *Args[] = { > + ?Type *Args[] = { > ? ? Type::getInt32Ty(*Ctx), ? ? // uint32_t num_counters > ? ? Type::getInt64PtrTy(*Ctx), ?// uint64_t *counters > ? }; > > Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 02:56:41 2011 > @@ -840,9 +840,9 @@ > > ? // If not, then we know we can transform this. > ? Module *Mod = M->getParent()->getParent()->getParent(); > - ?const Type *ArgTys[3] = { M->getRawDest()->getType(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getRawSource()->getType(), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; > + ?Type *ArgTys[3] = { M->getRawDest()->getType(), > + ? ? ? ? ? ? ? ? ? ? ?M->getRawSource()->getType(), > + ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; > ? M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArgTys, 3)); > > > Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 02:56:41 2011 > @@ -1498,8 +1498,8 @@ > ?Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { > ? if (!RetainRVCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - ? ?std::vector Params; > + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + ? ?std::vector Params; > ? ? Params.push_back(I8X); > ? ? const FunctionType *FTy = > ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -1515,8 +1515,8 @@ > ?Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { > ? if (!AutoreleaseRVCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - ? ?std::vector Params; > + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + ? ?std::vector Params; > ? ? Params.push_back(I8X); > ? ? const FunctionType *FTy = > ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -1532,7 +1532,7 @@ > ?Constant *ObjCARCOpt::getReleaseCallee(Module *M) { > ? if (!ReleaseCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?std::vector Params; > + ? ?std::vector Params; > ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > ? ? AttrListPtr Attributes; > ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -1548,7 +1548,7 @@ > ?Constant *ObjCARCOpt::getRetainCallee(Module *M) { > ? if (!RetainCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?std::vector Params; > + ? ?std::vector Params; > ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > ? ? AttrListPtr Attributes; > ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -1564,7 +1564,7 @@ > ?Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { > ? if (!AutoreleaseCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?std::vector Params; > + ? ?std::vector Params; > ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > ? ? AttrListPtr Attributes; > ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -3269,9 +3269,9 @@ > ?Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { > ? if (!StoreStrongCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - ? ?const Type *I8XX = PointerType::getUnqual(I8X); > - ? ?std::vector Params; > + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + ? ?Type *I8XX = PointerType::getUnqual(I8X); > + ? ?std::vector Params; > ? ? Params.push_back(I8XX); > ? ? Params.push_back(I8X); > > @@ -3291,8 +3291,8 @@ > ?Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { > ? if (!RetainAutoreleaseCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - ? ?std::vector Params; > + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + ? ?std::vector Params; > ? ? Params.push_back(I8X); > ? ? const FunctionType *FTy = > ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -3307,8 +3307,8 @@ > ?Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { > ? if (!RetainAutoreleaseRVCallee) { > ? ? LLVMContext &C = M->getContext(); > - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - ? ?std::vector Params; > + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + ? ?std::vector Params; > ? ? Params.push_back(I8X); > ? ? const FunctionType *FTy = > ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); > > Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 02:56:41 2011 > @@ -992,7 +992,7 @@ > ? ? } > > ? ? // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 > - ? ?const Type *ArgType = Op->getType(); > + ? ?Type *ArgType = Op->getType(); > ? ? Value *F = Intrinsic::getDeclaration(Callee->getParent(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::cttz, &ArgType, 1); > ? ? Value *V = B.CreateCall(F, Op, "cttz"); > > Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 02:56:41 2011 > @@ -140,7 +140,7 @@ > ?Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool ModuleLevelChanges, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ClonedCodeInfo *CodeInfo) { > - ?std::vector ArgTypes; > + ?std::vector ArgTypes; > > ? // The user might be deleting arguments to the function by specifying them in > ? // the VMap. ?If so, we need to not add the arguments to the arg ty vector > > Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 02:56:41 2011 > @@ -258,7 +258,7 @@ > ? default: RetTy = Type::getInt16Ty(header->getContext()); break; > ? } > > - ?std::vector paramTy; > + ?std::vector paramTy; > > ? // Add the types of the input values to the function's argument list > ? for (Values::const_iterator i = inputs.begin(), > @@ -279,7 +279,7 @@ > ? } > > ? DEBUG(dbgs() << "Function type: " << *RetTy << " f("); > - ?for (std::vector::iterator i = paramTy.begin(), > + ?for (std::vector::iterator i = paramTy.begin(), > ? ? ? ? ?e = paramTy.end(); i != e; ++i) > ? ? DEBUG(dbgs() << **i << ", "); > ? DEBUG(dbgs() << ")\n"); > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 02:56:41 2011 > @@ -663,7 +663,7 @@ > > ? LLVMContext &Context = Arg->getContext(); > > - ?const Type *VoidPtrTy = Type::getInt8PtrTy(Context); > + ?Type *VoidPtrTy = Type::getInt8PtrTy(Context); > > ? // Create the alloca. ?If we have TargetData, use nice alignment. > ? unsigned Align = 1; > @@ -680,7 +680,7 @@ > ? Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &*Caller->begin()->begin()); > ? // Emit a memcpy. > - ?const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > + ?Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > ? Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::memcpy, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Tys, 3); > > Modified: llvm/trunk/lib/VMCore/Core.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Core.cpp (original) > +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 02:56:41 2011 > @@ -260,7 +260,7 @@ > ?LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?LLVMTypeRef *ParamTypes, unsigned ParamCount, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?LLVMBool IsVarArg) { > - ?std::vector Tys; > + ?std::vector Tys; > ? for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) > ? ? Tys.push_back(unwrap(*I)); > > > Modified: llvm/trunk/lib/VMCore/Function.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Function.cpp (original) > +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 02:56:41 2011 > @@ -333,7 +333,7 @@ > ? return 0; > ?} > > -std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { > +std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { > ? assert(id < num_intrinsics && "Invalid intrinsic ID!"); > ? static const char * const Table[] = { > ? ? "not_intrinsic", > @@ -356,10 +356,10 @@ > ?} > > ?const FunctionType *Intrinsic::getType(LLVMContext &Context, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ID id, const Type **Tys, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ID id, Type **Tys, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned numTys) { > ? const Type *ResultTy = NULL; > - ?std::vector ArgTys; > + ?std::vector ArgTys; > ? bool IsVarArg = false; > > ?#define GET_INTRINSIC_GENERATOR > @@ -384,7 +384,7 @@ > ?#include "llvm/Intrinsics.gen" > ?#undef GET_INTRINSIC_ATTRIBUTES > > -Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, > +Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned numTys) { > ? // There can never be multiple globals with the same name of different types, > ? // because intrinsics must be a specific type. > > Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) > +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 02:56:41 2011 > @@ -65,7 +65,7 @@ > ? ? ? ? ? ? ?bool isVolatile, MDNode *TBAATag) { > ? Ptr = getCastedInt8PtrValue(Ptr); > ? Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; > - ?const Type *Tys[] = { Ptr->getType(), Size->getType() }; > + ?Type *Tys[] = { Ptr->getType(), Size->getType() }; > ? Module *M = BB->getParent()->getParent(); > ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > > @@ -85,7 +85,7 @@ > ? Src = getCastedInt8PtrValue(Src); > > ? Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; > - ?const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > + ?Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > ? Module *M = BB->getParent()->getParent(); > ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); > > @@ -105,7 +105,7 @@ > ? Src = getCastedInt8PtrValue(Src); > > ? Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; > - ?const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > + ?Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > ? Module *M = BB->getParent()->getParent(); > ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); > > > Modified: llvm/trunk/lib/VMCore/Module.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Module.cpp (original) > +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 02:56:41 2011 > @@ -216,8 +216,8 @@ > ? va_start(Args, RetTy); > > ? // Build the list of argument types... > - ?std::vector ArgTys; > - ?while (const Type *ArgTy = va_arg(Args, const Type*)) > + ?std::vector ArgTys; > + ?while (Type *ArgTy = va_arg(Args, Type*)) > ? ? ArgTys.push_back(ArgTy); > > ? va_end(Args); > @@ -234,8 +234,8 @@ > ? va_start(Args, RetTy); > > ? // Build the list of argument types... > - ?std::vector ArgTys; > - ?while (const Type *ArgTy = va_arg(Args, const Type*)) > + ?std::vector ArgTys; > + ?while (Type *ArgTy = va_arg(Args, Type*)) > ? ? ArgTys.push_back(ArgTy); > > ? va_end(Args); > > Modified: llvm/trunk/lib/VMCore/Type.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Type.cpp (original) > +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 02:56:41 2011 > @@ -325,13 +325,6 @@ > ? NumContainedTys = Params.size() + 1; // + 1 for result type > ?} > > -// FIXME: Remove this version. > -FunctionType *FunctionType::get(const Type *ReturnType, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArrayRef Params, bool isVarArg) { > - ?return get(ReturnType, ArrayRef(const_cast(Params.data()), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Params.size()), isVarArg); > -} > - > ?// FunctionType::get - The factory function for the FunctionType class. > ?FunctionType *FunctionType::get(const Type *ReturnType, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ArrayRef Params, bool isVarArg) { > @@ -357,7 +350,7 @@ > > > ?FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { > - ?return get(Result, ArrayRef(), isVarArg); > + ?return get(Result, ArrayRef(), isVarArg); > ?} > > > > Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) > +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 02:56:41 2011 > @@ -23,7 +23,7 @@ > ? Module M("world", Context); > > ? const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::vector(), false); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::vector(), false); > ? Function *F = cast(M.getOrInsertFunction("f", FTy)); > ? BasicBlock *BB = BasicBlock::Create(Context, "entry", F); > ? ReturnInst::Create(Context, 0, BB); > > Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) > +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 02:56:41 2011 > @@ -21,7 +21,7 @@ > ?namespace { > > ?Function *makeFakeFunction() { > - ?std::vector params; > + ?std::vector params; > ? const FunctionType *FTy = > ? ? ? FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); > ? return Function::Create(FTy, GlobalValue::ExternalLinkage); > > Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) > +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 02:56:41 2011 > @@ -37,7 +37,7 @@ > ?namespace { > > ?Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { > - ?std::vector params; > + ?std::vector params; > ? const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? params, false); > ? Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); > @@ -322,7 +322,7 @@ > > ? const FunctionType *Func1Ty = > ? ? ? cast(TypeBuilder::get(Context)); > - ?std::vector arg_types; > + ?std::vector arg_types; > ? arg_types.push_back(Type::getInt1Ty(Context)); > ? const FunctionType *FuncTy = FunctionType::get( > ? ? ? Type::getVoidTy(Context), arg_types, false); > > Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) > +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 02:56:41 2011 > @@ -120,7 +120,7 @@ > ?} > > ?TEST(TypeBuilderTest, Functions) { > - ?std::vector params; > + ?std::vector params; > ? EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), > ? ? ? ? ? ? (TypeBuilder::get(getGlobalContext()))); > ? EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), > > Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) > +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 02:56:41 2011 > @@ -405,13 +405,13 @@ > ? ? ? mod->setTargetTriple("x86_64-unknown-linux-gnu"); > > ? ? ? // Type Definitions > - ? ? ?std::vectorFuncTy_0_args; > + ? ? ?std::vectorFuncTy_0_args; > ? ? ? FunctionType* FuncTy_0 = FunctionType::get( > ? ? ? ? /*Result=*/IntegerType::get(getGlobalContext(), 32), > ? ? ? ? /*Params=*/FuncTy_0_args, > ? ? ? ? /*isVarArg=*/false); > > - ? ? ?std::vectorFuncTy_2_args; > + ? ? ?std::vectorFuncTy_2_args; > ? ? ? FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); > ? ? ? FunctionType* FuncTy_2 = FunctionType::get( > ? ? ? ? /*Result=*/Type::getVoidTy(getGlobalContext()), > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From greened at obbligato.org Mon Jul 11 19:12:36 2011 From: greened at obbligato.org (David A. Greene) Date: Mon, 11 Jul 2011 19:12:36 -0500 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: <7731534C-A3B3-4F86-9A0F-C31E1DAC62A5@apple.com> (Eric Christopher's message of "Mon, 11 Jul 2011 16:09:01 -0700") References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <7731534C-A3B3-4F86-9A0F-C31E1DAC62A5@apple.com> Message-ID: Eric Christopher writes: >> I've tried multiple gcc versions and I still don't see this. > Lots of people are seeing this with multiple compilers and > buildbots. I'd appreciate you working with them to get this ironed out > if you'd like to put the patch back in, but in the meantime I've > reverted r134921, r134917, r134908 and r134907. I have no doubt there's an issue, but there's not much I can do without some help. Evan, if you can give me the revision of clang you were building with before, I can build that and do some build tests with it. -Dave From nicholas at mxc.ca Mon Jul 11 19:26:08 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 12 Jul 2011 00:26:08 -0000 Subject: [llvm-commits] [llvm] r134945 - /llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Message-ID: <20110712002608.853292A6C12C@llvm.org> Author: nicholas Date: Mon Jul 11 19:26:08 2011 New Revision: 134945 URL: http://llvm.org/viewvc/llvm-project?rev=134945&view=rev Log: TypeMap had a destructor that destroyed the types it held. DenseMap did not, so destroy those types in ~LLVMContext. Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.cpp?rev=134945&r1=134944&r2=134945&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/LLVMContextImpl.cpp (original) +++ llvm/trunk/lib/VMCore/LLVMContextImpl.cpp Mon Jul 11 19:26:08 2011 @@ -13,6 +13,7 @@ #include "LLVMContextImpl.h" #include "llvm/Module.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; @@ -54,9 +55,7 @@ // will try to remove itself from OwnedModules set. This would cause // iterator invalidation if we iterated on the set directly. std::vector Modules(OwnedModules.begin(), OwnedModules.end()); - for (std::vector::iterator I = Modules.begin(), E = Modules.end(); - I != E; ++I) - delete *I; + DeleteContainerPointers(Modules); std::for_each(ExprConstants.map_begin(), ExprConstants.map_end(), DropReferences()); @@ -74,14 +73,8 @@ NullPtrConstants.freeConstants(); UndefValueConstants.freeConstants(); InlineAsms.freeConstants(); - for (IntMapTy::iterator I = IntConstants.begin(), E = IntConstants.end(); - I != E; ++I) { - delete I->second; - } - for (FPMapTy::iterator I = FPConstants.begin(), E = FPConstants.end(); - I != E; ++I) { - delete I->second; - } + DeleteContainerSeconds(IntConstants); + DeleteContainerSeconds(FPConstants); // Destroy MDNodes. ~MDNode can move and remove nodes between the MDNodeSet // and the NonUniquedMDNodes sets, so copy the values out first. @@ -99,7 +92,18 @@ assert(MDNodeSet.empty() && NonUniquedMDNodes.empty() && "Destroying all MDNodes didn't empty the Context's sets."); // Destroy MDStrings. - for (StringMap::iterator I = MDStringCache.begin(), - E = MDStringCache.end(); I != E; ++I) - delete I->second; + DeleteContainerSeconds(MDStringCache); + + // Destroy types. + DeleteContainerSeconds(IntegerTypes); + DeleteContainerSeconds(FunctionTypes); + DeleteContainerSeconds(AnonStructTypes); + DeleteContainerSeconds(ArrayTypes); + DeleteContainerSeconds(VectorTypes); + DeleteContainerSeconds(PointerTypes); + DeleteContainerSeconds(ASPointerTypes); + + for (StringMap::iterator I = NamedStructTypes.begin(), E = NamedStructTypes.end(); I != E; ++I) { + delete I->getValue(); + } } From evan.cheng at apple.com Mon Jul 11 19:56:30 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 11 Jul 2011 17:56:30 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <7731534C-A3B3-4F86-9A0F-C31E1DAC62A5@apple.com> Message-ID: <4ACF057F-CCBD-4BAB-A6E0-A4032D8A32A0@apple.com> On Jul 11, 2011, at 5:12 PM, David A. Greene wrote: > Eric Christopher writes: > >>> I've tried multiple gcc versions and I still don't see this. > >> Lots of people are seeing this with multiple compilers and >> buildbots. I'd appreciate you working with them to get this ironed out >> if you'd like to put the patch back in, but in the meantime I've >> reverted r134921, r134917, r134908 and r134907. > > I have no doubt there's an issue, but there's not much I can do without > some help. > > Evan, if you can give me the revision of clang you were building with > before, I can build that and do some build tests with it. Sorry, I was using a two month old Apple internal release Clang so no revision is available. Perhaps you can try using 2.9 release? Evan > > -Dave From isanbard at gmail.com Mon Jul 11 20:15:03 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 12 Jul 2011 01:15:03 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r134948 - in /llvm-gcc-4.2/trunk/gcc: config/alpha/llvm-alpha.cpp config/arm/llvm-arm-target.h config/arm/llvm-arm.cpp config/i386/llvm-i386-target.h config/i386/llvm-i386.cpp config/mips/llvm-mips.cpp config/rs6000/llvm-rs6000.cpp config/rs6000/rs6000.h llvm-abi-default.cpp llvm-abi.h llvm-backend.cpp llvm-convert.cpp llvm-internal.h llvm-types.cpp Message-ID: <20110712011503.A3B3F2A6C12C@llvm.org> Author: void Date: Mon Jul 11 20:15:03 2011 New Revision: 134948 URL: http://llvm.org/viewvc/llvm-project?rev=134948&view=rev Log: Revert r134895 and r134894 (and related patches in other trees). It was causing an assert on Darwin llvm-gcc builds. Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, line 2067. etc. http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354 --- Reverse-merging r134895 into '.': U gcc/config/rs6000/llvm-rs6000.cpp U gcc/config/rs6000/rs6000.h U gcc/config/mips/llvm-mips.cpp --- Reverse-merging r134894 into '.': U gcc/llvm-backend.cpp U gcc/llvm-convert.cpp U gcc/llvm-internal.h U gcc/llvm-types.cpp U gcc/llvm-abi-default.cpp U gcc/llvm-abi.h U gcc/config/alpha/llvm-alpha.cpp U gcc/config/i386/llvm-i386.cpp U gcc/config/i386/llvm-i386-target.h G gcc/config/rs6000/llvm-rs6000.cpp U gcc/config/arm/llvm-arm-target.h U gcc/config/arm/llvm-arm.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp llvm-gcc-4.2/trunk/gcc/llvm-abi.h llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp llvm-gcc-4.2/trunk/gcc/llvm-internal.h llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Modified: llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/alpha/llvm-alpha.cpp Mon Jul 11 20:15:03 2011 @@ -102,7 +102,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - Type *ResultType, + const Type *ResultType, std::vector &Ops) { switch (FnCode) { case ALPHA_BUILTIN_UMULH: { Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm-target.h Mon Jul 11 20:15:03 2011 @@ -48,16 +48,16 @@ #ifdef LLVM_ABI_H extern bool -llvm_arm_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, +llvm_arm_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, CallingConv::ID&, - std::vector&); + std::vector&); #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ llvm_arm_should_pass_aggregate_in_mixed_regs((T), (TY), (CC), (E)) struct DefaultABIClient; extern bool -llvm_arm_try_pass_aggregate_custom(tree, std::vector&, +llvm_arm_try_pass_aggregate_custom(tree, std::vector&, CallingConv::ID&, struct DefaultABIClient*); @@ -65,8 +65,8 @@ llvm_arm_try_pass_aggregate_custom((T), (E), (CC), (C)) extern -bool llvm_arm_aggregate_partially_passed_in_regs(std::vector&, - std::vector&, +bool llvm_arm_aggregate_partially_passed_in_regs(std::vector&, + std::vector&, CallingConv::ID&); #define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, CC) \ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/llvm-arm.cpp Mon Jul 11 20:15:03 2011 @@ -246,13 +246,13 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - Type *ResultType, + const Type *ResultType, std::vector &Ops) { neon_datatype datatype = neon_datatype_unspecified; bool isRounded = false; Intrinsic::ID intID = Intrinsic::not_intrinsic; Function *intFn; - Type* intOpTypes[2]; + const Type* intOpTypes[2]; if (FnCode < ARM_BUILTIN_NEON_BASE) return false; @@ -1415,7 +1415,7 @@ const VectorType *VTy = dyn_cast(ResultType); assert(VTy && "expected a vector type for vabdl result"); - llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); + const llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); intFn = Intrinsic::getDeclaration(TheModule, intID, &DTy, 1); Ops[0] = Builder.CreateCall2(intFn, Ops[0], Ops[1]); Result = Builder.CreateZExt(Ops[0], ResultType); @@ -1445,7 +1445,7 @@ const VectorType *VTy = dyn_cast(ResultType); assert(VTy && "expected a vector type for vabal result"); - llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); + const llvm::Type *DTy = VectorType::getTruncatedElementVectorType(VTy); intFn = Intrinsic::getDeclaration(TheModule, intID, &DTy, 1); Ops[1] = Builder.CreateCall2(intFn, Ops[1], Ops[2]); Ops[1] = Builder.CreateZExt(Ops[1], ResultType); @@ -2033,7 +2033,7 @@ case NEON_BUILTIN_vld4: { const StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - Type *VTy = STy->getElementType(0); + const Type *VTy = STy->getElementType(0); switch (neon_code) { case NEON_BUILTIN_vld2: intID = Intrinsic::arm_neon_vld2; break; case NEON_BUILTIN_vld3: intID = Intrinsic::arm_neon_vld3; break; @@ -2062,9 +2062,9 @@ case NEON_BUILTIN_vld2_lane: case NEON_BUILTIN_vld3_lane: case NEON_BUILTIN_vld4_lane: { - StructType *STy = dyn_cast(ResultType); + const StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - VectorType *VTy = dyn_cast(STy->getElementType(0)); + const VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); if (!isValidLane(Ops[2], VTy->getNumElements())) return UnexpectedError("%Hinvalid lane number", exp, Result); @@ -2105,9 +2105,9 @@ case NEON_BUILTIN_vld2_dup: case NEON_BUILTIN_vld3_dup: case NEON_BUILTIN_vld4_dup: { - StructType *STy = dyn_cast(ResultType); + const StructType *STy = dyn_cast(ResultType); assert(STy && "expected a struct type"); - VectorType *VTy = dyn_cast(STy->getElementType(0)); + const VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); intOpTypes[0] = VTy; @@ -2168,7 +2168,7 @@ } case NEON_BUILTIN_vst1: { - Type *VTy = Ops[1]->getType(); + const Type *VTy = Ops[1]->getType(); intID = Intrinsic::arm_neon_vst1; intFn = Intrinsic::getDeclaration(TheModule, intID, &VTy, 1); Type *VPTy = PointerType::getUnqual(Type::getInt8Ty(Context)); @@ -2184,7 +2184,7 @@ case NEON_BUILTIN_vst4: { const StructType *STy = dyn_cast(Ops[1]->getType()); assert(STy && "expected a struct type"); - Type *VTy = STy->getElementType(0); + const Type *VTy = STy->getElementType(0); switch (neon_code) { case NEON_BUILTIN_vst2: intID = Intrinsic::arm_neon_vst2; break; case NEON_BUILTIN_vst3: intID = Intrinsic::arm_neon_vst3; break; @@ -2224,9 +2224,9 @@ case NEON_BUILTIN_vst2_lane: case NEON_BUILTIN_vst3_lane: case NEON_BUILTIN_vst4_lane: { - StructType *STy = dyn_cast(Ops[1]->getType()); + const StructType *STy = dyn_cast(Ops[1]->getType()); assert(STy && "expected a struct type"); - VectorType *VTy = dyn_cast(STy->getElementType(0)); + const VectorType *VTy = dyn_cast(STy->getElementType(0)); assert(VTy && "expected a vector type"); if (!isValidLane(Ops[2], VTy->getNumElements())) return UnexpectedError("%Hinvalid lane number", exp, Result); @@ -2521,11 +2521,11 @@ // Walk over an LLVM Type that we know is a homogeneous aggregate and // push the proper LLVM Types that represent the register types to pass // that struct member in. -static void push_elts(const Type *Ty, std::vector &Elts) +static void push_elts(const Type *Ty, std::vector &Elts) { for (Type::subtype_iterator I = Ty->subtype_begin(), E = Ty->subtype_end(); I != E; ++I) { - Type *STy = *I; + const Type *STy = *I; if (const VectorType *VTy = dyn_cast(STy)) { switch (VTy->getBitWidth()) { @@ -2538,8 +2538,8 @@ default: assert (0 && "invalid vector type"); } - } else if (ArrayType *ATy = dyn_cast(STy)) { - Type *ETy = ATy->getElementType(); + } else if (const ArrayType *ATy = dyn_cast(STy)) { + const Type *ETy = ATy->getElementType(); for (uint64_t i = ATy->getNumElements(); i > 0; --i) Elts.push_back(ETy); @@ -2550,7 +2550,7 @@ } } -static unsigned count_num_words(std::vector &ScalarElts) { +static unsigned count_num_words(std::vector &ScalarElts) { unsigned NumWords = 0; for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -2574,7 +2574,7 @@ // the IL a bit more explicit about how arguments are handled. extern bool llvm_arm_try_pass_aggregate_custom(tree type, - std::vector& ScalarElts, + std::vector& ScalarElts, CallingConv::ID& CC, struct DefaultABIClient* C) { if (CC != CallingConv::ARM_AAPCS && CC != CallingConv::C) @@ -2596,14 +2596,14 @@ // First, build a type that will be bitcast to the original one and // from where elements will be extracted. - std::vector Elts; - Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); + std::vector Elts; + const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); const unsigned NumRegularArgs = Size / 4; for (unsigned i = 0; i < NumRegularArgs; ++i) { Elts.push_back(Int32Ty); } const unsigned RestSize = Size % 4; - llvm::Type *RestType = NULL; + const llvm::Type *RestType = NULL; if (RestSize> 2) { RestType = Type::getInt32Ty(getGlobalContext()); } else if (RestSize > 1) { @@ -2641,9 +2641,9 @@ // for parameter passing. This only applies to AAPCS-VFP "homogeneous // aggregates" as specified in 4.3.5 of the AAPCS spec. bool -llvm_arm_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, +llvm_arm_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, CallingConv::ID &CC, - std::vector &Elts) { + std::vector &Elts) { if (!llvm_arm_should_pass_or_return_aggregate_in_regs(TreeType, CC)) return false; @@ -2686,7 +2686,7 @@ // count_num_registers_uses - Simulate argument passing reg allocation in SPRs. // Caller is expected to zero out SPRs. Returns true if all of ScalarElts fit // in registers. -static bool count_num_registers_uses(std::vector &ScalarElts, +static bool count_num_registers_uses(std::vector &ScalarElts, bool *SPRs) { for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -2734,8 +2734,8 @@ // part of the aggregate, return true. That means the aggregate should instead // be passed in memory. bool -llvm_arm_aggregate_partially_passed_in_regs(std::vector &Elts, - std::vector &ScalarElts, +llvm_arm_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts, CallingConv::ID &CC) { // Homogeneous aggregates are an AAPCS-VFP feature. if ((CC != CallingConv::ARM_AAPCS_VFP) || @@ -2763,7 +2763,7 @@ // Walk Ty and push LLVM types corresponding to register types onto // Elts. - std::vector Elts; + std::vector Elts; const Type *Ty = ConvertType(TreeType); push_elts(Ty, Elts); Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386-target.h Mon Jul 11 20:15:03 2011 @@ -225,18 +225,18 @@ llvm_x86_should_pass_aggregate_as_fca(X, TY) #endif -extern bool llvm_x86_should_pass_aggregate_in_memory(tree, Type *); +extern bool llvm_x86_should_pass_aggregate_in_memory(tree, const Type *); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_x86_should_pass_aggregate_in_memory(X, TY) extern bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, - std::vector&); +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, + std::vector&); extern bool -llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, Type *Ty, - std::vector&); +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree, const Type *Ty, + std::vector&); #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ (TARGET_64BIT ? \ @@ -244,8 +244,8 @@ llvm_x86_32_should_pass_aggregate_in_mixed_regs((T), (TY), (E))) extern -bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, - std::vector&); +bool llvm_x86_64_aggregate_partially_passed_in_regs(std::vector&, + std::vector&); #define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, CC) \ (TARGET_64BIT ? \ Modified: llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/llvm-i386.cpp Mon Jul 11 20:15:03 2011 @@ -95,7 +95,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - Type *ResultType, + const Type *ResultType, std::vector &Ops) { switch (FnCode) { default: break; @@ -1108,8 +1108,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. This is only called for x86-32. */ bool -llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, - std::vector &Elts){ +llvm_x86_32_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, + std::vector &Elts){ // If this is a small fixed size type, investigate it. HOST_WIDE_INT SrcSize = int_size_in_bytes(TreeType); if (SrcSize <= 0 || SrcSize > 16) @@ -1125,7 +1125,7 @@ if (!STy || STy->isPacked()) return false; for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) { - Type *EltTy = STy->getElementType(i); + const Type *EltTy = STy->getElementType(i); // 32 and 64-bit integers are fine, as are float and double. Long double // (which can be picked as the type for a union of 16 bytes) is not fine, // as loads and stores of it get only 10 bytes. @@ -1165,7 +1165,7 @@ /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed in memory. */ -bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, Type *Ty) { +bool llvm_x86_should_pass_aggregate_in_memory(tree TreeType, const Type *Ty) { if (llvm_x86_should_pass_aggregate_as_fca(TreeType, Ty)) return false; @@ -1178,7 +1178,7 @@ return false; if (!TARGET_64BIT) { - std::vector Elts; + std::vector Elts; return !llvm_x86_32_should_pass_aggregate_in_mixed_regs(TreeType, Ty, Elts); } return llvm_x86_64_should_pass_aggregate_in_memory(TreeType, Mode); @@ -1186,7 +1186,7 @@ /* count_num_registers_uses - Return the number of GPRs and XMMs parameter register used so far. Caller is responsible for initializing outputs. */ -static void count_num_registers_uses(std::vector &ScalarElts, +static void count_num_registers_uses(std::vector &ScalarElts, unsigned &NumGPRs, unsigned &NumXMMs) { for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { const Type *Ty = ScalarElts[i]; @@ -1220,8 +1220,8 @@ part of the aggregate, return true. That means the aggregate should instead be passed in memory. */ bool -llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, - std::vector &ScalarElts) { +llvm_x86_64_aggregate_partially_passed_in_regs(std::vector &Elts, + std::vector &ScalarElts) { // Counting number of GPRs and XMMs used so far. According to AMD64 ABI // document: "If there are no registers available for any eightbyte of an // argument, the whole argument is passed on the stack." X86-64 uses 6 @@ -1266,8 +1266,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. This is only called for x86-64. */ bool -llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, Type *Ty, - std::vector &Elts){ +llvm_x86_64_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type *Ty, + std::vector &Elts){ if (llvm_x86_should_pass_aggregate_as_fca(TreeType, Ty)) return false; @@ -1633,7 +1633,7 @@ /// llvm_x86_64_should_pass_aggregate_in_mixed_regs code. void llvm_x86_64_get_multiple_return_reg_classes(tree TreeType, const Type *Ty, - std::vector &Elts){ + std::vector &Elts){ enum x86_64_reg_class Class[MAX_CLASSES]; enum machine_mode Mode = ix86_getNaturalModeForType(TreeType); HOST_WIDE_INT Bytes = @@ -1774,7 +1774,7 @@ return NULL; const StructType *STy = cast(Ty); - std::vector ElementTypes; + std::vector ElementTypes; // Special handling for _Complex. if (llvm_x86_should_not_return_complex_in_memory(type)) { @@ -1783,7 +1783,7 @@ return StructType::get(Context, ElementTypes, STy->isPacked()); } - std::vector GCCElts; + std::vector GCCElts; llvm_x86_64_get_multiple_return_reg_classes(type, Ty, GCCElts); return StructType::get(Context, GCCElts, false); } Modified: llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/mips/llvm-mips.cpp Mon Jul 11 20:15:03 2011 @@ -67,7 +67,7 @@ const Type *Ty = ConvertType(type); const StructType *STy = cast(Ty); - std::vector ElementTypes; + std::vector ElementTypes; // Special handling for _Complex. if (llvm_mips_should_not_return_complex_in_memory(type)) { Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/llvm-rs6000.cpp Mon Jul 11 20:15:03 2011 @@ -94,7 +94,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - Type *ResultType, + const Type *ResultType, std::vector &Ops) { switch (FnCode) { default: break; @@ -391,7 +391,7 @@ return false; } -static unsigned count_num_registers_uses(std::vector &ScalarElts) { +static unsigned count_num_registers_uses(std::vector &ScalarElts) { unsigned NumGPRs = 0; for (unsigned i = 0, e = ScalarElts.size(); i != e; ++i) { if (NumGPRs >= 8) @@ -423,7 +423,7 @@ /// arguments are always passed in general purpose registers, never in /// Floating-point registers or vector registers. bool llvm_rs6000_try_pass_aggregate_custom(tree type, - std::vector &ScalarElts, + std::vector &ScalarElts, const CallingConv::ID &CC, struct DefaultABIClient* C) { if (!isSVR4ABI()) @@ -432,8 +432,8 @@ // Eight GPR's are availabe for parameter passing. const unsigned NumArgRegs = 8; unsigned NumGPR = count_num_registers_uses(ScalarElts); - Type *Ty = ConvertType(type); - Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); + const Type *Ty = ConvertType(type); + const Type* Int32Ty = Type::getInt32Ty(getGlobalContext()); if (Ty->isSingleValueType()) { if (Ty->isIntegerTy()) { unsigned TypeSize = Ty->getPrimitiveSizeInBits(); @@ -469,7 +469,7 @@ if (TREE_CODE(type) == COMPLEX_TYPE) { unsigned SrcSize = int_size_in_bytes(type); unsigned NumRegs = (SrcSize + 3) / 4; - std::vector Elts; + std::vector Elts; // This looks very strange, but matches the old code. if (SrcSize == 8) { @@ -505,7 +505,7 @@ /* Target hook for llvm-abi.h. It returns true if an aggregate of the specified type should be passed using the byval mechanism. */ -bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, Type *Ty) { +bool llvm_rs6000_should_pass_aggregate_byval(tree TreeType, const Type *Ty) { /* FIXME byval not implemented for ppc64. */ if (TARGET_64BIT) return false; @@ -554,8 +554,8 @@ It also returns a vector of types that correspond to the registers used for parameter passing. */ bool -llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree TreeType, Type* Ty, - std::vector&Elts) { +llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree TreeType, const Type* Ty, + std::vector&Elts) { // FIXME there are plenty of ppc64 cases that need this. if (TARGET_64BIT) return false; Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/rs6000.h Mon Jul 11 20:15:03 2011 @@ -3490,14 +3490,14 @@ #ifdef LLVM_ABI_H extern bool llvm_rs6000_try_pass_aggregate_custom(tree, - std::vector&, + std::vector&, const CallingConv::ID &, struct DefaultABIClient*); #define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \ llvm_rs6000_try_pass_aggregate_custom((T), (E), (CC), (C)) -extern bool llvm_rs6000_should_pass_aggregate_byval(tree, Type *); +extern bool llvm_rs6000_should_pass_aggregate_byval(tree, const Type *); #define LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(X, TY, CC) \ llvm_rs6000_should_pass_aggregate_byval((X), (TY)) @@ -3508,8 +3508,8 @@ #define LLVM_SHOULD_PASS_VECTOR_IN_INTEGER_REGS(X) \ llvm_rs6000_should_pass_vector_in_integer_regs((X)) -extern bool llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree, Type*, - std::vector&); +extern bool llvm_rs6000_should_pass_aggregate_in_mixed_regs(tree, const Type*, + std::vector&); /* FIXME this is needed for 64-bit */ #define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \ Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi-default.cpp Mon Jul 11 20:15:03 2011 @@ -9,7 +9,7 @@ /// on the client that indicate how its pieces should be handled. This /// handles things like returning structures via hidden parameters. void DefaultABI::HandleReturnType(tree type, tree fn, bool isBuiltin, - std::vector &ScalarElts) { + std::vector &ScalarElts) { unsigned Offset = 0; const Type *Ty = ConvertType(type); if (Ty->isVectorTy()) { @@ -53,7 +53,7 @@ // FIXME: should return the hidden first argument for some targets // (e.g. ELF i386). - PointerType *PTy = Ty->getPointerTo(); + const PointerType *PTy = Ty->getPointerTo(); C.HandleAggregateShadowResult(PTy, false); ScalarElts.push_back(PTy); } @@ -64,21 +64,21 @@ /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. -void DefaultABI::HandleArgument(tree type, std::vector &ScalarElts, +void DefaultABI::HandleArgument(tree type, std::vector &ScalarElts, Attributes *Attributes) { unsigned Size = 0; bool DontCheckAlignment = false; - Type *Ty = ConvertType(type); + const Type *Ty = ConvertType(type); // Figure out if this field is zero bits wide, e.g. {} or [0 x int]. Do // not include variable sized fields here. - std::vector Elts; + std::vector Elts; if (Ty->isVoidTy()) { // Handle void explicitly as a {} type. - Type *OpTy = StructType::get(getGlobalContext()); + const Type *OpTy = StructType::get(getGlobalContext()); C.HandleScalarArgument(OpTy, type); ScalarElts.push_back(OpTy); } else if (isPassedByInvisibleReference(type)) { // variable size -> by-ref. - Type *PtrTy = Ty->getPointerTo(); + const Type *PtrTy = Ty->getPointerTo(); C.HandleByInvisibleReferenceArgument(PtrTy, type); ScalarElts.push_back(PtrTy); } else if (Ty->isVectorTy()) { @@ -134,7 +134,7 @@ for (tree Field = TYPE_FIELDS(type); Field; Field = TREE_CHAIN(Field)) if (TREE_CODE(Field) == FIELD_DECL) { const tree Ftype = getDeclaredType(Field); - Type *FTy = ConvertType(Ftype); + const Type *FTy = ConvertType(Ftype); unsigned FNo = GET_LLVM_FIELD_INDEX(Field); assert(FNo != ~0U && "Case not handled yet!"); @@ -174,7 +174,7 @@ } /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. -void DefaultABI::HandleUnion(tree type, std::vector &ScalarElts) { +void DefaultABI::HandleUnion(tree type, std::vector &ScalarElts) { if (TYPE_TRANSPARENT_UNION(type)) { tree Field = TYPE_FIELDS(type); assert(Field && "Transparent union must have some elements!"); @@ -218,7 +218,7 @@ /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. If Size is set we pass only that many bytes. void DefaultABI::PassInIntegerRegisters(tree type, - std::vector &ScalarElts, + std::vector &ScalarElts, unsigned origSize, bool DontCheckAlignment) { unsigned Size; @@ -240,8 +240,8 @@ unsigned ArraySize = Size / ElementSize; // Put as much of the aggregate as possible into an array. - Type *ATy = NULL; - Type *ArrayElementType = NULL; + const Type *ATy = NULL; + const Type *ArrayElementType = NULL; if (ArraySize) { Size = Size % ElementSize; ArrayElementType = (UseInt64 ? @@ -252,7 +252,7 @@ // Pass any leftover bytes as a separate element following the array. unsigned LastEltRealSize = 0; - llvm::Type *LastEltTy = 0; + const llvm::Type *LastEltTy = 0; if (Size > 4) { LastEltTy = Type::getInt64Ty(getGlobalContext()); } else if (Size > 2) { @@ -267,7 +267,7 @@ LastEltRealSize = Size; } - std::vector Elts; + std::vector Elts; if (ATy) Elts.push_back(ATy); if (LastEltTy) @@ -298,13 +298,13 @@ /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. void DefaultABI::PassInMixedRegisters(const Type *Ty, - std::vector &OrigElts, - std::vector &ScalarElts) { + std::vector &OrigElts, + std::vector &ScalarElts) { // We use VoidTy in OrigElts to mean "this is a word in the aggregate // that occupies storage but has no useful information, and is not passed // anywhere". Happens on x86-64. - std::vector Elts(OrigElts); - Type* wordType = getTargetData().getPointerSize() == 4 ? + std::vector Elts(OrigElts); + const Type* wordType = getTargetData().getPointerSize() == 4 ? Type::getInt32Ty(getGlobalContext()) : Type::getInt64Ty(getGlobalContext()); for (unsigned i=0, e=Elts.size(); i!=e; ++i) if (OrigElts[i]->isVoidTy()) Modified: llvm-gcc-4.2/trunk/gcc/llvm-abi.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-abi.h?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-abi.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-abi.h Mon Jul 11 20:15:03 2011 @@ -407,31 +407,31 @@ /// on the client that indicate how its pieces should be handled. This /// handles things like returning structures via hidden parameters. void HandleReturnType(tree type, tree fn, bool isBuiltin, - std::vector &ScalarElts); + std::vector &ScalarElts); /// HandleArgument - This is invoked by the target-independent code for each /// argument type passed into the function. It potentially breaks down the /// argument and invokes methods on the client that indicate how its pieces /// should be handled. This handles things like decimating structures into /// their fields. - void HandleArgument(tree type, std::vector &ScalarElts, + void HandleArgument(tree type, std::vector &ScalarElts, Attributes *Attributes = NULL); /// HandleUnion - Handle a UNION_TYPE or QUAL_UNION_TYPE tree. /// - void HandleUnion(tree type, std::vector &ScalarElts); + void HandleUnion(tree type, std::vector &ScalarElts); /// PassInIntegerRegisters - Given an aggregate value that should be passed in /// integer registers, convert it to a structure containing ints and pass all /// of the struct elements in. If Size is set we pass only that many bytes. - void PassInIntegerRegisters(tree type, std::vector &ScalarElts, + void PassInIntegerRegisters(tree type, std::vector &ScalarElts, unsigned origSize, bool DontCheckAlignment); /// PassInMixedRegisters - Given an aggregate value that should be passed in /// mixed integer, floating point, and vector registers, convert it to a /// structure containing the specified struct elements in. - void PassInMixedRegisters(const Type *Ty, std::vector &OrigElts, - std::vector &ScalarElts); + void PassInMixedRegisters(const Type *Ty, std::vector &OrigElts, + std::vector &ScalarElts); }; #endif /* LLVM_ABI_H */ Modified: llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-backend.cpp Mon Jul 11 20:15:03 2011 @@ -915,7 +915,8 @@ LLVMContext &Context = getGlobalContext(); const Type *FPTy = - FunctionType::get(Type::getVoidTy(Context), std::vector(), false); + FunctionType::get(Type::getVoidTy(Context), + std::vector(), false); FPTy = FPTy->getPointerTo(); for (unsigned i = 0, e = Tors.size(); i != e; ++i) { Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Jul 11 20:15:03 2011 @@ -381,8 +381,8 @@ // bytes, but only 10 are copied. If the object is really a union // we might need the other bytes. We must also be careful to use // the smaller alignment. - Type *SBP = Type::getInt8PtrTy(Context); - Type *IntPtr = getTargetData().getIntPtrType(Context); + const Type *SBP = Type::getInt8PtrTy(Context); + const Type *IntPtr = getTargetData().getIntPtrType(Context); Value *Ops[5] = { Builder.CreateCast(Instruction::BitCast, Loc, SBP), Builder.CreateCast(Instruction::BitCast, AI, SBP), @@ -392,7 +392,7 @@ LLVM_BYVAL_ALIGNMENT(type)), ConstantInt::get(Type::getInt1Ty(Context), false) }; - Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, ArgTypes, 3), Ops, Ops+5); @@ -434,13 +434,13 @@ // isPassedByVal - Return true if an aggregate of the specified type will be // passed in memory byval. -static bool isPassedByVal(tree type, Type *Ty, - std::vector &ScalarArgs, +static bool isPassedByVal(tree type, const Type *Ty, + std::vector &ScalarArgs, CallingConv::ID &CC) { if (LLVM_SHOULD_PASS_AGGREGATE_USING_BYVAL_ATTR(type, Ty, CC)) return true; - std::vector Args; + std::vector Args; if (LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(type, Ty, CC, Args) && LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(Args, ScalarArgs, CC)) @@ -677,7 +677,7 @@ DefaultABI ABIConverter(Client); // Scalar arguments processed so far. - std::vector ScalarArgs; + std::vector ScalarArgs; // Handle the DECL_RESULT. ABIConverter.HandleReturnType(TREE_TYPE(TREE_TYPE(FnDecl)), FnDecl, @@ -693,7 +693,7 @@ const char *Name = "unnamed_arg"; if (DECL_NAME(Args)) Name = IDENTIFIER_POINTER(DECL_NAME(Args)); - Type *ArgTy = ConvertType(TREE_TYPE(Args)); + const Type *ArgTy = ConvertType(TREE_TYPE(Args)); bool isInvRef = isPassedByInvisibleReference(TREE_TYPE(Args)); if (isInvRef || (ArgTy->isVectorTy() && @@ -1655,8 +1655,8 @@ Value *TreeToLLVM::EmitMemCpy(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - Type *SBP = Type::getInt8PtrTy(Context); - Type *IntPtr = TD.getIntPtrType(Context); + const Type *SBP = Type::getInt8PtrTy(Context); + const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), @@ -1665,7 +1665,7 @@ ConstantInt::get(Type::getInt1Ty(Context), false) }; - Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memcpy, ArgTypes, 3), Ops, Ops+5); return Ops[0]; @@ -1673,8 +1673,8 @@ Value *TreeToLLVM::EmitMemMove(Value *DestPtr, Value *SrcPtr, Value *Size, unsigned Align) { - Type *SBP = Type::getInt8PtrTy(Context); - Type *IntPtr = TD.getIntPtrType(Context); + const Type *SBP = Type::getInt8PtrTy(Context); + const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), BitCastToType(SrcPtr, SBP), @@ -1682,7 +1682,7 @@ ConstantInt::get(Type::getInt32Ty(Context), Align), ConstantInt::get(Type::getInt1Ty(Context), false) }; - Type *ArgTypes[3] = {SBP, SBP, IntPtr }; + const Type *ArgTypes[3] = {SBP, SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memmove, ArgTypes, 3), Ops, Ops+5); @@ -1691,8 +1691,8 @@ Value *TreeToLLVM::EmitMemSet(Value *DestPtr, Value *SrcVal, Value *Size, unsigned Align) { - Type *SBP = Type::getInt8PtrTy(Context); - Type *IntPtr = TD.getIntPtrType(Context); + const Type *SBP = Type::getInt8PtrTy(Context); + const Type *IntPtr = TD.getIntPtrType(Context); Value *Ops[5] = { BitCastToType(DestPtr, SBP), CastToSIntType(SrcVal, Type::getInt8Ty(Context)), @@ -1701,7 +1701,7 @@ ConstantInt::get(Type::getInt1Ty(Context), false) }; - Type *ArgTypes[2] = {SBP, IntPtr }; + const Type *ArgTypes[2] = {SBP, IntPtr }; Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::memset, ArgTypes, 2), Ops, Ops+5); return Ops[0]; @@ -3034,7 +3034,7 @@ DefaultABI ABIConverter(Client); // Handle the result, including struct returns. - std::vector ScalarArgs; + std::vector ScalarArgs; ABIConverter.HandleReturnType(TREE_TYPE(exp), fndecl ? fndecl : exp, fndecl ? DECL_BUILT_IN(fndecl) : false, @@ -4354,7 +4354,7 @@ } // Turn this into a 'tmp = call Ty asm "", "={reg}"()'. - FunctionType *FTy = FunctionType::get(Ty, std::vector(),false); + FunctionType *FTy = FunctionType::get(Ty, std::vector(),false); const char *Name = extractRegisterName(decl); int RegNum = decode_reg_name(Name); @@ -4370,7 +4370,7 @@ /// that copies the value out of the specified register. Value *TreeToLLVM::EmitMoveOfRegVariableToRightReg(Instruction *I, tree var) { // Create a 'call void asm sideeffect "", "{reg}"(Ty %RHS)'. - Type *Ty = I->getType(); + const Type *Ty = I->getType(); // If there was an error, return something bogus. if (ValidateRegisterVariable(var)) { @@ -4379,7 +4379,7 @@ return 0; // Just don't copy something into DestLoc. } - std::vector ArgTys; + std::vector ArgTys; ArgTys.push_back(Ty); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), ArgTys, false); @@ -4392,7 +4392,7 @@ Call->setDoesNotThrow(); // Create another asm with the same reg, this time producing an output. // Turn this into a 'tmp = call Ty asm "", "={reg}"()'. - FunctionType *FTy2 = FunctionType::get(Ty, std::vector(), + FunctionType *FTy2 = FunctionType::get(Ty, std::vector(), false); InlineAsm *IA2 = InlineAsm::get(FTy2, "", "={"+std::string(Name)+"}", true); @@ -4409,8 +4409,8 @@ return; // Turn this into a 'call void asm sideeffect "", "{reg}"(Ty %RHS)'. - std::vector ArgTys; - Type* Ty = ConvertType(TREE_TYPE(decl)); + std::vector ArgTys; + const Type* Ty = ConvertType(TREE_TYPE(decl)); if (LLVM_IS_DECL_MMX_REGISTER(decl)) Ty = Type::getX86_MMXTy(Context); ArgTys.push_back(Ty); @@ -4869,14 +4869,14 @@ } std::vector CallOps; - std::vector CallArgTypes; + std::vector CallArgTypes; std::string NewAsmStr = ConvertInlineAsmStr(exp, NumOutputs+NumInputs); std::string ConstraintStr; bool HasSideEffects = ASM_VOLATILE_P(exp) || !ASM_OUTPUTS(exp); // StoreCallResultAddr - The pointer to store the result of the call through. SmallVector StoreCallResultAddrs; - SmallVector CallResultTypes; + SmallVector CallResultTypes; SmallVector CallResultIsSigned; SmallVector, 4> OutputLocations; @@ -4936,7 +4936,8 @@ } LValue Dest = EmitLV(Operand); - Type *DestValTy = cast(Dest.Ptr->getType())->getElementType(); + const Type *DestValTy = + cast(Dest.Ptr->getType())->getElementType(); assert(!Dest.isBitfield() && "Cannot assign into a bitfield!"); if (!AllowsMem && DestValTy->isSingleValueType()) {// Reg dest -> asm return @@ -5076,7 +5077,7 @@ } } - Type* AdjTy = LLVM_ADJUST_MMX_INLINE_PARAMETER_TYPE( + const Type* AdjTy = LLVM_ADJUST_MMX_INLINE_PARAMETER_TYPE( Constraint, Op->getType()); if (AdjTy != Op->getType()) Op = BitCastToType(Op, AdjTy); @@ -5157,7 +5158,9 @@ case 0: CallResultType = Type::getVoidTy(Context); break; case 1: CallResultType = CallResultTypes[0]; break; default: - CallResultType = StructType::get(Context, CallResultTypes); + std::vector TmpVec(CallResultTypes.begin(), + CallResultTypes.end()); + CallResultType = StructType::get(Context, TmpVec); break; } @@ -5305,7 +5308,7 @@ Value *&Result) { #ifdef LLVM_TARGET_INTRINSIC_LOWER // Get the result type and operand line in an easy to consume format. - Type *ResultType = ConvertType(TREE_TYPE(TREE_TYPE(fndecl))); + const Type *ResultType = ConvertType(TREE_TYPE(TREE_TYPE(fndecl))); std::vector Operands; for (tree Op = TREE_OPERAND(exp, 1); Op; Op = TREE_CHAIN(Op)) { tree OpVal = TREE_VALUE(Op); @@ -5349,13 +5352,13 @@ Value * TreeToLLVM::BuildBinaryAtomicBuiltin(tree exp, Intrinsic::ID id) { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5388,14 +5391,14 @@ Value * TreeToLLVM::BuildCmpAndSwapAtomicBuiltin(tree exp, tree type, bool isBool) { - Type *ResultTy = ConvertType(type); + const Type *ResultTy = ConvertType(type); tree arglist = TREE_OPERAND(exp, 1); Value* C[3] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0), Emit(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(arglist))), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5568,7 +5571,7 @@ }; // Grab the current return type. - Type* Ty; + const Type* Ty; Ty = ConvertType(TREE_TYPE(exp)); // Manually coerce the arg to the correct pointer type. @@ -5764,7 +5767,7 @@ // Get arguments. tree arglist = TREE_OPERAND(exp, 1); Value *ExprVal = Emit(TREE_VALUE(arglist), 0); - Type *Ty = ExprVal->getType(); + const Type *Ty = ExprVal->getType(); Value *StrVal = Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0); SmallVector Args; @@ -5924,13 +5927,13 @@ case BUILT_IN_ADD_AND_FETCH_1: case BUILT_IN_ADD_AND_FETCH_2: case BUILT_IN_ADD_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -5971,13 +5974,13 @@ case BUILT_IN_SUB_AND_FETCH_1: case BUILT_IN_SUB_AND_FETCH_2: case BUILT_IN_SUB_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6018,13 +6021,13 @@ case BUILT_IN_OR_AND_FETCH_1: case BUILT_IN_OR_AND_FETCH_2: case BUILT_IN_OR_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6065,13 +6068,13 @@ case BUILT_IN_AND_AND_FETCH_1: case BUILT_IN_AND_AND_FETCH_2: case BUILT_IN_AND_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6112,13 +6115,13 @@ case BUILT_IN_XOR_AND_FETCH_1: case BUILT_IN_XOR_AND_FETCH_2: case BUILT_IN_XOR_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6159,13 +6162,13 @@ case BUILT_IN_NAND_AND_FETCH_1: case BUILT_IN_NAND_AND_FETCH_2: case BUILT_IN_NAND_AND_FETCH_4: { - Type *ResultTy = ConvertType(TREE_TYPE(exp)); + const Type *ResultTy = ConvertType(TREE_TYPE(exp)); tree arglist = TREE_OPERAND(exp, 1); Value* C[2] = { Emit(TREE_VALUE(arglist), 0), Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0) }; - Type* Ty[2]; + const Type* Ty[2]; Ty[0] = ResultTy; Ty[1] = ResultTy->getPointerTo(); C[0] = Builder.CreateBitCast(C[0], Ty[1]); @@ -6290,7 +6293,7 @@ // varying type. Make sure that we specify the actual type for "iAny" // by passing it as the 3rd and 4th parameters. This isn't needed for // most intrinsics, but is needed for ctpop, cttz, ctlz. - Type *Ty = InVal->getType(); + const Type *Ty = InVal->getType(); Result = Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Id, &Ty, 1), InVal); return true; @@ -6298,7 +6301,7 @@ Value *TreeToLLVM::EmitBuiltinSQRT(tree exp) { Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0); - Type* Ty = Amt->getType(); + const Type* Ty = Amt->getType(); return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Intrinsic::sqrt, &Ty, 1), @@ -6312,7 +6315,7 @@ Value *Val = Emit(TREE_VALUE(ArgList), 0); Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); - Type *Ty = Val->getType(); + const Type *Ty = Val->getType(); Pow = CastToSIntType(Pow, Type::getInt32Ty(Context)); SmallVector Args; @@ -6330,7 +6333,7 @@ Value *Val = Emit(TREE_VALUE(ArgList), 0); Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0); - Type *Ty = Val->getType(); + const Type *Ty = Val->getType(); SmallVector Args; Args.push_back(Val); @@ -7076,7 +7079,7 @@ Value *TreeToLLVM::EmitFieldAnnotation(Value *FieldPtr, tree FieldDecl) { tree AnnotateAttr = lookup_attribute("annotate", DECL_ATTRIBUTES(FieldDecl)); - Type *SBP = Type::getInt8PtrTy(Context); + const Type *SBP = Type::getInt8PtrTy(Context); Function *Fn = Intrinsic::getDeclaration(TheModule, Intrinsic::ptr_annotation, Modified: llvm-gcc-4.2/trunk/gcc/llvm-internal.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-internal.h?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-internal.h (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-internal.h Mon Jul 11 20:15:03 2011 @@ -129,7 +129,7 @@ public: TypeConverter() : RecursionStatus(CS_Normal) {} - Type *ConvertType(tree_node *type); + const Type *ConvertType(tree_node *type); /// GCCTypeOverlapsWithLLVMTypePadding - Return true if the specified GCC type /// has any data that overlaps with structure padding in the specified LLVM @@ -140,11 +140,11 @@ /// ConvertFunctionType - Convert the specified FUNCTION_TYPE or METHOD_TYPE /// tree to an LLVM type. This does the same thing that ConvertType does, but /// it also returns the function's LLVM calling convention and attributes. - FunctionType *ConvertFunctionType(tree_node *type, - tree_node *decl, - tree_node *static_chain, - CallingConv::ID &CallingConv, - AttrListPtr &PAL); + const FunctionType *ConvertFunctionType(tree_node *type, + tree_node *decl, + tree_node *static_chain, + CallingConv::ID &CallingConv, + AttrListPtr &PAL); /// ConvertArgListToFnType - Given a DECL_ARGUMENTS list on an GCC tree, /// return the LLVM type corresponding to the function. This is useful for @@ -156,8 +156,8 @@ AttrListPtr &PAL); private: - Type *ConvertRECORD(tree_node *type, tree_node *orig_type); - Type *ConvertUNION(tree_node *type, tree_node *orig_type); + const Type *ConvertRECORD(tree_node *type, tree_node *orig_type); + const Type *ConvertUNION(tree_node *type, tree_node *orig_type); bool DecodeStructFields(tree_node *Field, StructTypeConversionInfo &Info); void DecodeStructBitField(tree_node *Field, StructTypeConversionInfo &Info); void SelectUnionMember(tree_node *type, StructTypeConversionInfo &Info); @@ -167,7 +167,7 @@ /// ConvertType - Convert the specified tree type to an LLVM type. /// -inline Type *ConvertType(tree_node *type) { +inline const Type *ConvertType(tree_node *type) { return TheTypeConverter->ConvertType(type); } @@ -615,7 +615,7 @@ unsigned FnCode, const MemRef *DestLoc, Value *&Result, - Type *ResultType, + const Type *ResultType, std::vector &Ops); public: Modified: llvm-gcc-4.2/trunk/gcc/llvm-types.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-types.cpp?rev=134948&r1=134947&r2=134948&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-types.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-types.cpp Mon Jul 11 20:15:03 2011 @@ -59,8 +59,8 @@ // a map. // Collection of LLVM Types -static std::vector LTypes; -typedef DenseMap LTypesMapTy; +static std::vector LTypes; +typedef DenseMap LTypesMapTy; static LTypesMapTy LTypesMap; static LLVMContext &Context = getGlobalContext(); @@ -72,7 +72,7 @@ (TYPE_CHECK (NODE)->type.symtab.llvm = index) // Note down LLVM type for GCC tree node. -static Type * llvm_set_type(tree Tr, Type *Ty) { +static const Type * llvm_set_type(tree Tr, const Type *Ty) { #ifndef NDEBUG // For x86 long double, llvm records the size of the data (80) while // gcc's TYPE_SIZE including alignment padding. getTypeAllocSizeInBits @@ -107,12 +107,12 @@ return Ty; } -#define SET_TYPE_LLVM(NODE, TYPE) llvm_set_type(NODE, TYPE) +#define SET_TYPE_LLVM(NODE, TYPE) (const Type *)llvm_set_type(NODE, TYPE) // Get LLVM Type for the GCC tree node based on LTypes vector index. // When GCC tree node is initialized, it has 0 as the index value. This is // why all recorded indexes are offset by 1. -extern "C" Type *llvm_get_type(unsigned Index) { +extern "C" const Type *llvm_get_type(unsigned Index) { if (Index == 0) return NULL; assert ((Index - 1) < LTypes.size() && "Invalid LLVM Type index"); @@ -120,10 +120,10 @@ } #define GET_TYPE_LLVM(NODE) \ - llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm) + (const Type *)llvm_get_type( TYPE_CHECK (NODE)->type.symtab.llvm) // Erase type from LTypes vector -static void llvmEraseLType(Type *Ty) { +static void llvmEraseLType(const Type *Ty) { LTypesMapTy::iterator I = LTypesMap.find(Ty); if (I != LTypesMap.end()) { @@ -161,7 +161,7 @@ return; // Convert the LTypes list to a list of pointers. - std::vector PTys; + std::vector PTys; for (unsigned i = 0, e = LTypes.size(); i != e; ++i) { // Cannot form pointer to void. Use i8 as a sentinel. if (LTypes[i]->isVoidTy()) @@ -488,7 +488,7 @@ // Main Type Conversion Routines //===----------------------------------------------------------------------===// -Type *TypeConverter::ConvertType(tree orig_type) { +const Type *TypeConverter::ConvertType(tree orig_type) { if (orig_type == error_mark_node) return Type::getInt32Ty(Context); // LLVM doesn't care about variants such as const, volatile, or restrict. @@ -504,7 +504,7 @@ case QUAL_UNION_TYPE: case UNION_TYPE: return ConvertRECORD(type, orig_type); case BOOLEAN_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; return SET_TYPE_LLVM(type, IntegerType::get(Context, TREE_INT_CST_LOW(TYPE_SIZE(type)))); @@ -513,25 +513,25 @@ // Use of an enum that is implicitly declared? if (TYPE_SIZE(orig_type) == 0) { // If we already compiled this type, use the old type. - if (Type *Ty = GET_TYPE_LLVM(orig_type)) + if (const Type *Ty = GET_TYPE_LLVM(orig_type)) return Ty; // Just mark it as a named type for now. - Type *Ty = StructType::createNamed(Context, - GetTypeName("enum.", orig_type)); + const Type *Ty = StructType::createNamed(Context, + GetTypeName("enum.", orig_type)); return SET_TYPE_LLVM(orig_type, Ty); } // FALL THROUGH. type = orig_type; case INTEGER_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; // The ARM port defines __builtin_neon_xi as a 511-bit type because GCC's // type precision field has only 9 bits. Treat this as a special case. int precision = TYPE_PRECISION(type) == 511 ? 512 : TYPE_PRECISION(type); return SET_TYPE_LLVM(type, IntegerType::get(Context, precision)); } case REAL_TYPE: - if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; switch (TYPE_PRECISION(type)) { default: fprintf(stderr, "Unknown FP type!\n"); @@ -557,13 +557,13 @@ } case COMPLEX_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; - Type *Ty = ConvertType(TREE_TYPE(type)); + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; + const Type *Ty = ConvertType(TREE_TYPE(type)); return SET_TYPE_LLVM(type, StructType::get(Ty, Ty, NULL)); } case VECTOR_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) return Ty; - Type *Ty = ConvertType(TREE_TYPE(type)); + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; + const Type *Ty = ConvertType(TREE_TYPE(type)); Ty = VectorType::get(Ty, TYPE_VECTOR_SUBPARTS(type)); return SET_TYPE_LLVM(type, Ty); } @@ -576,7 +576,7 @@ if (RecursionStatus == CS_Struct) RecursionStatus = CS_StructPtr; - Type *Ty = ConvertType(TREE_TYPE(type)); + const Type *Ty = ConvertType(TREE_TYPE(type)); RecursionStatus = SavedCS; @@ -587,7 +587,7 @@ case METHOD_TYPE: case FUNCTION_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; // No declaration to pass through, passing NULL. @@ -597,7 +597,7 @@ CallingConv, PAL)); } case ARRAY_TYPE: { - if (Type *Ty = GET_TYPE_LLVM(type)) + if (const Type *Ty = GET_TYPE_LLVM(type)) return Ty; uint64_t ElementSize; @@ -665,13 +665,13 @@ namespace { class FunctionTypeConversion : public DefaultABIClient { const Type *&RetTy; - std::vector &ArgTypes; + std::vector &ArgTypes; CallingConv::ID &CallingConv; bool isShadowRet; bool KNRPromotion; unsigned Offset; public: - FunctionTypeConversion(const Type *&retty, std::vector &AT, + FunctionTypeConversion(const Type *&retty, std::vector &AT, CallingConv::ID &CC, bool KNR) : RetTy(retty), ArgTypes(AT), CallingConv(CC), KNRPromotion(KNR), Offset(0) { CallingConv = CallingConv::C; @@ -704,7 +704,7 @@ } /// HandleShadowResult - Handle an aggregate or scalar shadow argument. - void HandleShadowResult(PointerType *PtrArgTy, bool RetPtr) { + void HandleShadowResult(const PointerType *PtrArgTy, bool RetPtr) { // This function either returns void or the shadow argument, // depending on the target. RetTy = RetPtr ? PtrArgTy : Type::getVoidTy(Context); @@ -720,7 +720,8 @@ /// returns an aggregate value by using a "shadow" first parameter, which is /// a pointer to the aggregate, of type PtrArgTy. If RetPtr is set to true, /// the pointer argument itself is returned from the function. - void HandleAggregateShadowResult(PointerType *PtrArgTy, bool RetPtr) { + void HandleAggregateShadowResult(const PointerType *PtrArgTy, + bool RetPtr) { HandleShadowResult(PtrArgTy, RetPtr); } @@ -728,15 +729,15 @@ /// returns a scalar value by using a "shadow" first parameter, which is a /// pointer to the scalar, of type PtrArgTy. If RetPtr is set to true, /// the pointer argument itself is returned from the function. - void HandleScalarShadowResult(PointerType *PtrArgTy, bool RetPtr) { + void HandleScalarShadowResult(const PointerType *PtrArgTy, bool RetPtr) { HandleShadowResult(PtrArgTy, RetPtr); } - void HandlePad(llvm::Type *LLVMTy) { + void HandlePad(const llvm::Type *LLVMTy) { HandleScalarArgument(LLVMTy, 0, 0); } - void HandleScalarArgument(llvm::Type *LLVMTy, tree type, + void HandleScalarArgument(const llvm::Type *LLVMTy, tree type, unsigned RealSize = 0) { if (KNRPromotion) { if (type == float_type_node) @@ -751,7 +752,7 @@ /// HandleByInvisibleReferenceArgument - This callback is invoked if a pointer /// (of type PtrTy) to the argument is passed rather than the argument itself. - void HandleByInvisibleReferenceArgument(llvm::Type *PtrTy, tree type) { + void HandleByInvisibleReferenceArgument(const llvm::Type *PtrTy, tree type) { ArgTypes.push_back(PtrTy); } @@ -764,7 +765,7 @@ /// HandleFCAArgument - This callback is invoked if the aggregate function /// argument is a first class aggregate passed by value. - void HandleFCAArgument(llvm::Type *LLVMTy, + void HandleFCAArgument(const llvm::Type *LLVMTy, tree type ATTRIBUTE_UNUSED) { ArgTypes.push_back(LLVMTy); } @@ -797,7 +798,7 @@ ConvertArgListToFnType(tree type, tree Args, tree static_chain, CallingConv::ID &CallingConv, AttrListPtr &PAL) { tree ReturnType = TREE_TYPE(type); - std::vector ArgTys; + std::vector ArgTys; const Type *RetTy = Type::getVoidTy(Context); FunctionTypeConversion Client(RetTy, ArgTys, CallingConv, true /*K&R*/); @@ -807,7 +808,7 @@ TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif - std::vector ScalarArgs; + std::vector ScalarArgs; // Builtins are always prototyped, so this isn't one. ABIConverter.HandleReturnType(ReturnType, current_function_decl, false, ScalarArgs); @@ -864,11 +865,11 @@ return FunctionType::get(RetTy, ArgTys, false); } -FunctionType *TypeConverter:: +const FunctionType *TypeConverter:: ConvertFunctionType(tree type, tree decl, tree static_chain, CallingConv::ID &CallingConv, AttrListPtr &PAL) { const Type *RetTy = Type::getVoidTy(Context); - std::vector ArgTypes; + std::vector ArgTypes; bool isVarArg = false; FunctionTypeConversion Client(RetTy, ArgTypes, CallingConv, false/*not K&R*/); DefaultABI ABIConverter(Client); @@ -878,7 +879,7 @@ TARGET_ADJUST_LLVM_CC(CallingConv, type); #endif - std::vector ScalarArgs; + std::vector ScalarArgs; ABIConverter.HandleReturnType(TREE_TYPE(type), current_function_decl, decl ? DECL_BUILT_IN(decl) : false, ScalarArgs); @@ -972,7 +973,7 @@ for (; Args && TREE_VALUE(Args) != void_type_node; Args = TREE_CHAIN(Args)){ tree ArgTy = TREE_VALUE(Args); if (!isPassedByInvisibleReference(ArgTy)) - if (StructType *STy = dyn_cast(ConvertType(ArgTy))) + if (const StructType *STy = dyn_cast(ConvertType(ArgTy))) if (STy->isOpaque()) { // If we are passing an opaque struct by value, we don't know how many // arguments it will turn into. Because we can't handle this yet, @@ -1648,7 +1649,7 @@ // If Field has user defined alignment and it does not match Ty alignment // then convert to a packed struct and try again. if (TYPE_USER_ALIGN(DECL_BIT_FIELD_TYPE(Field))) { - Type *Ty = ConvertType(getDeclaredType(Field)); + const Type *Ty = ConvertType(getDeclaredType(Field)); if (TYPE_ALIGN(DECL_BIT_FIELD_TYPE(Field)) != 8 * Info.getTypeAlignment(Ty)) return false; @@ -1665,7 +1666,7 @@ assert((StartOffsetInBits & 7) == 0 && "Non-bit-field has non-byte offset!"); uint64_t StartOffsetInBytes = StartOffsetInBits/8; - Type *Ty = ConvertType(getDeclaredType(Field)); + const Type *Ty = ConvertType(getDeclaredType(Field)); // If this field is packed then the struct may need padding fields // before this field. @@ -1874,7 +1875,7 @@ TREE_INT_CST_LOW(DECL_SIZE(Field)) == 0) continue; - Type *TheTy = ConvertType(TheGccTy); + const Type *TheTy = ConvertType(TheGccTy); unsigned Size = Info.getTypeSize(TheTy); unsigned Align = Info.getTypeAlignment(TheTy); @@ -1938,9 +1939,9 @@ // // For LLVM purposes, we build a new type for B-within-D that // has the correct size and layout for that usage. -Type *TypeConverter::ConvertRECORD(tree type, tree orig_type) { +const Type *TypeConverter::ConvertRECORD(tree type, tree orig_type) { bool IsStruct = TREE_CODE(type) == RECORD_TYPE; - if (StructType *Ty = cast_or_null(GET_TYPE_LLVM(type))) { + if (const StructType *Ty = cast_or_null(GET_TYPE_LLVM(type))) { // If we already compiled this type, and if it was not a forward // definition that is now defined, use the old type. if (!Ty->isOpaque() || TYPE_SIZE(type) == 0) @@ -2059,7 +2060,7 @@ } else { uint64_t FieldOffsetInBits = getFieldOffsetInBits(Field); tree FieldType = getDeclaredType(Field); - Type *FieldTy = ConvertType(FieldType); + const Type *FieldTy = ConvertType(FieldType); // If this is a bitfield, we may want to adjust the FieldOffsetInBits // to produce safe code. In particular, bitfields will be @@ -2100,7 +2101,7 @@ if (IsStruct) RestoreOriginalFields(type); - StructType *ResultTy = cast(GET_TYPE_LLVM(type)); + const StructType *ResultTy = cast(GET_TYPE_LLVM(type)); Info->fillInLLVMType((StructType*)ResultTy); StructTypeInfoMap[type] = Info; From isanbard at gmail.com Mon Jul 11 20:15:52 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 12 Jul 2011 01:15:52 -0000 Subject: [llvm-commits] [llvm] r134949 - in /llvm/trunk: include/llvm/ include/llvm/Support/ include/llvm/Target/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/ lib/Target/ARM/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ unittests/Analysis/ unittests/ExecutionEngine/JIT/ unittests/Support/ unittests/VMCore/ Message-ID: <20110712011553.737442A6C12C@llvm.org> Author: void Date: Mon Jul 11 20:15:52 2011 New Revision: 134949 URL: http://llvm.org/viewvc/llvm-project?rev=134949&view=rev Log: Revert r134893 and r134888 (and related patches in other trees). It was causing an assert on Darwin llvm-gcc builds. Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file /Users/buildslave/zorg/buildbot/smooshlab/slave-0.8/build.llvm-gcc-i386-darwin9-RA/llvm.src/lib/VMCore/Instructions.cpp, li\ ne 2067. etc. http://smooshlab.apple.com:8013/builders/llvm-gcc-i386-darwin9-RA/builds/2354 --- Reverse-merging r134893 into '.': U include/llvm/Target/TargetData.h U include/llvm/DerivedTypes.h U tools/bugpoint/ExtractFunction.cpp U unittests/Support/TypeBuilderTest.cpp U lib/Target/ARM/ARMGlobalMerge.cpp U lib/Target/TargetData.cpp U lib/VMCore/Constants.cpp U lib/VMCore/Type.cpp U lib/VMCore/Core.cpp U lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Instrumentation/ProfilingUtils.cpp U lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/CodeGen/SjLjEHPrepare.cpp --- Reverse-merging r134888 into '.': G include/llvm/DerivedTypes.h U include/llvm/Support/TypeBuilder.h U include/llvm/Intrinsics.h U unittests/Analysis/ScalarEvolutionTest.cpp U unittests/ExecutionEngine/JIT/JITTest.cpp U unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp U unittests/VMCore/PassManagerTest.cpp G unittests/Support/TypeBuilderTest.cpp U lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp U lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp U lib/VMCore/IRBuilder.cpp G lib/VMCore/Type.cpp U lib/VMCore/Function.cpp G lib/VMCore/Core.cpp U lib/VMCore/Module.cpp U lib/AsmParser/LLParser.cpp U lib/Transforms/Utils/CloneFunction.cpp G lib/Transforms/Utils/CodeExtractor.cpp U lib/Transforms/Utils/InlineFunction.cpp U lib/Transforms/Instrumentation/GCOVProfiling.cpp U lib/Transforms/Scalar/ObjCARC.cpp U lib/Transforms/Scalar/SimplifyLibCalls.cpp U lib/Transforms/Scalar/MemCpyOptimizer.cpp G lib/Transforms/IPO/DeadArgumentElimination.cpp U lib/Transforms/IPO/ArgumentPromotion.cpp U lib/Transforms/InstCombine/InstCombineCompares.cpp U lib/Transforms/InstCombine/InstCombineAndOrXor.cpp U lib/Transforms/InstCombine/InstCombineCalls.cpp U lib/CodeGen/DwarfEHPrepare.cpp U lib/CodeGen/IntrinsicLowering.cpp U lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/include/llvm/DerivedTypes.h llvm/trunk/include/llvm/Intrinsics.h llvm/trunk/include/llvm/Support/TypeBuilder.h llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp llvm/trunk/lib/Target/TargetData.cpp llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp llvm/trunk/lib/VMCore/Constants.cpp llvm/trunk/lib/VMCore/Core.cpp llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/lib/VMCore/IRBuilder.cpp llvm/trunk/lib/VMCore/Module.cpp llvm/trunk/lib/VMCore/Type.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp llvm/trunk/unittests/Support/TypeBuilderTest.cpp llvm/trunk/unittests/VMCore/PassManagerTest.cpp Modified: llvm/trunk/include/llvm/DerivedTypes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/include/llvm/DerivedTypes.h (original) +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 20:15:52 2011 @@ -103,6 +103,8 @@ /// a FunctionType. /// static FunctionType *get(const Type *Result, + ArrayRef Params, bool isVarArg); + static FunctionType *get(const Type *Result, ArrayRef Params, bool isVarArg); /// FunctionType::get - Create a FunctionType taking no parameters. @@ -204,6 +206,11 @@ /// StructType::get - This static method is the primary way to create a /// StructType. + /// + /// FIXME: Remove the 'const Type*' version of this when types are pervasively + /// de-constified. + static StructType *get(LLVMContext &Context, ArrayRef Elements, + bool isPacked = false); static StructType *get(LLVMContext &Context, ArrayRef Elements, bool isPacked = false); @@ -215,7 +222,7 @@ /// structure types by specifying the elements as arguments. Note that this /// method always returns a non-packed struct, and requires at least one /// element type. - static StructType *get(Type *elt1, ...) END_WITH_NULL; + static StructType *get(const Type *elt1, ...) END_WITH_NULL; bool isPacked() const { return (getSubclassData() & SCDB_Packed) != 0; } Modified: llvm/trunk/include/llvm/Intrinsics.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/include/llvm/Intrinsics.h (original) +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 20:15:52 2011 @@ -44,12 +44,12 @@ /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as /// "llvm.ppc.altivec.lvx". - std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); + std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::getType(ID) - Return the function type for an intrinsic. /// const FunctionType *getType(LLVMContext &Context, ID id, - Type **Tys = 0, unsigned numTys = 0); + const Type **Tys = 0, unsigned numTys = 0); /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be /// overloaded. @@ -67,7 +67,7 @@ /// overloaded intrinsic, Tys should point to an array of numTys pointers to /// Type, and must provide exactly one type for each overloaded type in the /// intrinsic. - Function *getDeclaration(Module *M, ID id, Type **Tys = 0, + Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, unsigned numTys = 0); /// Map a GCC builtin name to an intrinsic ID. Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 20:15:52 2011 @@ -51,7 +51,7 @@ /// namespace llvm { /// template class TypeBuilder { /// public: -/// static StructType *get(LLVMContext &Context) { +/// static const StructType *get(LLVMContext &Context) { /// // If you cache this result, be sure to cache it separately /// // for each LLVMContext. /// return StructType::get( @@ -104,7 +104,7 @@ // Pointers template class TypeBuilder { public: - static PointerType *get(LLVMContext &Context) { + static const PointerType *get(LLVMContext &Context) { return PointerType::getUnqual(TypeBuilder::get(Context)); } }; @@ -115,14 +115,14 @@ // Arrays template class TypeBuilder { public: - static ArrayType *get(LLVMContext &Context) { + static const ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), N); } }; /// LLVM uses an array of length 0 to represent an unknown-length array. template class TypeBuilder { public: - static ArrayType *get(LLVMContext &Context) { + static const ArrayType *get(LLVMContext &Context) { return ArrayType::get(TypeBuilder::get(Context), 0); } }; @@ -152,7 +152,7 @@ #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ template<> class TypeBuilder { \ public: \ - static IntegerType *get(LLVMContext &Context) { \ + static const IntegerType *get(LLVMContext &Context) { \ return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ } \ }; \ @@ -181,14 +181,14 @@ template class TypeBuilder, cross> { public: - static IntegerType *get(LLVMContext &C) { + static const IntegerType *get(LLVMContext &C) { return IntegerType::get(C, num_bits); } }; template<> class TypeBuilder { public: - static Type *get(LLVMContext& C) { + static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; @@ -196,7 +196,7 @@ template<> class TypeBuilder { public: - static Type *get(LLVMContext& C) { + static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; @@ -204,32 +204,32 @@ template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } + static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } + static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } + static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } + static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } }; template class TypeBuilder { public: - static Type *get(LLVMContext &C) { + static const Type *get(LLVMContext &C) { return Type::getVoidTy(C); } }; @@ -247,14 +247,14 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { + static const FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), false); } }; template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), @@ -264,8 +264,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -276,8 +276,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -291,8 +291,8 @@ bool cross> class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -307,8 +307,8 @@ typename A5, bool cross> class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -322,15 +322,15 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { + static const FunctionType *get(LLVMContext &Context) { return FunctionType::get(TypeBuilder::get(Context), true); } }; template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(1); params.push_back(TypeBuilder::get(Context)); return FunctionType::get(TypeBuilder::get(Context), params, true); @@ -339,8 +339,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(2); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -351,8 +351,8 @@ template class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(3); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -366,8 +366,8 @@ bool cross> class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(4); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); @@ -382,8 +382,8 @@ typename A5, bool cross> class TypeBuilder { public: - static FunctionType *get(LLVMContext &Context) { - std::vector params; + static const FunctionType *get(LLVMContext &Context) { + std::vector params; params.reserve(5); params.push_back(TypeBuilder::get(Context)); params.push_back(TypeBuilder::get(Context)); Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Mon Jul 11 20:15:52 2011 @@ -259,7 +259,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. /// - IntegerType *getIntPtrType(LLVMContext &C) const; + const IntegerType *getIntPtrType(LLVMContext &C) const; /// getIndexedOffset - return the offset from the beginning of the type for /// the specified indices. This is used to implement getelementptr. Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 20:15:52 2011 @@ -1442,7 +1442,7 @@ "argument attributes invalid in function type"); } - SmallVector ArgListTy; + SmallVector ArgListTy; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ArgListTy.push_back(ArgList[i].Ty); @@ -2655,7 +2655,7 @@ // Okay, if we got here, the function is syntactically valid. Convert types // and do semantic checks. - std::vector ParamTypeList; + std::vector ParamTypeList; SmallVector Attrs; if (RetAttrs != Attribute::None) @@ -3171,7 +3171,7 @@ if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); @@ -3508,7 +3508,7 @@ if (!(PFTy = dyn_cast(RetType)) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... - std::vector ParamTypes; + std::vector ParamTypes; for (unsigned i = 0, e = ArgList.size(); i != e; ++i) ParamTypes.push_back(ArgList[i].V->getType()); Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 20:15:52 2011 @@ -582,7 +582,7 @@ // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *T = getTypeByID(Record[i])) ArgTys.push_back(T); @@ -838,7 +838,7 @@ // FUNCTION: [vararg, attrid, retty, paramty x N] if (Record.size() < 3) return Error("Invalid FUNCTION type record"); - std::vector ArgTys; + std::vector ArgTys; for (unsigned i = 3, e = Record.size(); i != e; ++i) { if (Type *Elt = getTypeByIDOrNull(Record[i])) ArgTys.push_back(Elt); Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 20:15:52 2011 @@ -497,8 +497,10 @@ // Find the rewind function if we didn't already. if (!RewindFunction) { LLVMContext &Ctx = ResumeInsts[0]->getContext(); + std::vector + Params(1, Type::getInt8PtrTy(Ctx)); FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), - Type::getInt8PtrTy(Ctx), false); + Params, false); const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); } Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 20:15:52 2011 @@ -29,7 +29,7 @@ ArgIt ArgBegin, ArgIt ArgEnd, const Type *RetTy) { // Insert a correctly-typed definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back(I->getType()); M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); @@ -69,7 +69,7 @@ // program already contains a function with this name. Module *M = CI->getParent()->getParent()->getParent(); // Get or insert the definition now. - std::vector ParamTys; + std::vector ParamTys; for (ArgIt I = ArgBegin; I != ArgEnd; ++I) ParamTys.push_back((*I)->getType()); Constant* FCache = M->getOrInsertFunction(NewFn, @@ -553,12 +553,12 @@ !CI->getType()->isIntegerTy()) return false; - IntegerType *Ty = dyn_cast(CI->getType()); + const IntegerType *Ty = dyn_cast(CI->getType()); if (!Ty) return false; // Okay, we can do this xform, do so now. - Type *Tys[] = { Ty }; + const Type *Tys[] = { Ty }; Module *M = CI->getParent()->getParent()->getParent(); Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Jul 11 20:15:52 2011 @@ -87,8 +87,9 @@ bool SjLjEHPass::doInitialization(Module &M) { // Build the function context structure. // builtin_setjmp uses a five word jbuf - Type *VoidPtrTy = Type::getInt8PtrTy(M.getContext()); - Type *Int32Ty = Type::getInt32Ty(M.getContext()); + const Type *VoidPtrTy = + Type::getInt8PtrTy(M.getContext()); + const Type *Int32Ty = Type::getInt32Ty(M.getContext()); FunctionContextTy = StructType::get(VoidPtrTy, // __prev Int32Ty, // call_site Modified: llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMGlobalMerge.cpp Mon Jul 11 20:15:52 2011 @@ -128,10 +128,10 @@ for (size_t i = 0, e = Globals.size(); i != e; ) { size_t j = 0; uint64_t MergedSize = 0; - std::vector Tys; + std::vector Tys; std::vector Inits; for (j = i; j != e; ++j) { - Type *Ty = Globals[j]->getType()->getElementType(); + const Type *Ty = Globals[j]->getType()->getElementType(); MergedSize += TD->getTypeAllocSize(Ty); if (MergedSize > MaxOffset) { break; Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 20:15:52 2011 @@ -83,7 +83,7 @@ static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 20:15:52 2011 @@ -92,7 +92,7 @@ static const FunctionType *getType(LLVMContext &Context, unsigned id) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Mon Jul 11 20:15:52 2011 @@ -535,7 +535,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. -IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { +const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { return IntegerType::get(C, getPointerSizeInBits()); } Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 20:15:52 2011 @@ -493,7 +493,7 @@ // Start by computing a new prototype for the function, which is the same as // the old function, but has modified arguments. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; typedef std::set ScalarizeTable; Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 20:15:52 2011 @@ -208,7 +208,7 @@ // the old function, but doesn't have isVarArg set. const FunctionType *FTy = Fn.getFunctionType(); - std::vector Params(FTy->param_begin(), FTy->param_end()); + std::vector Params(FTy->param_begin(), FTy->param_end()); FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), Params, false); unsigned NumArgs = Params.size(); @@ -647,7 +647,7 @@ // Start by computing a new prototype for the function, which is the same as // the old function, but has fewer arguments and a different return type. const FunctionType *FTy = F->getFunctionType(); - std::vector Params; + std::vector Params; // Set up to build a new list of parameter attributes. SmallVector AttributesVec; @@ -659,13 +659,13 @@ // Find out the new return value. - Type *RetTy = FTy->getReturnType(); + const Type *RetTy = FTy->getReturnType(); const Type *NRetTy = NULL; unsigned RetCount = NumRetVals(F); // -1 means unused, other numbers are the new index SmallVector NewRetIdxs(RetCount, -1); - std::vector RetTypes; + std::vector RetTypes; if (RetTy->isVoidTy()) { NRetTy = RetTy; } else { Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 20:15:52 2011 @@ -1400,7 +1400,7 @@ /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. /// If so, insert the new bswap intrinsic and return it. Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { - IntegerType *ITy = dyn_cast(I.getType()); + const IntegerType *ITy = dyn_cast(I.getType()); if (!ITy || ITy->getBitWidth() % 16 || // ByteMask only allows up to 32-byte values. ITy->getBitWidth() > 32*8) @@ -1424,7 +1424,7 @@ for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) if (ByteValues[i] != V) return 0; - Type *Tys[] = { ITy }; + const Type *Tys[] = { ITy }; Module *M = I.getParent()->getParent()->getParent(); Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); return CallInst::Create(F, V); Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 20:15:52 2011 @@ -217,9 +217,9 @@ if (GVSrc->isConstant()) { Module *M = CI.getParent()->getParent()->getParent(); Intrinsic::ID MemCpyID = Intrinsic::memcpy; - Type *Tys[3] = { CI.getArgOperand(0)->getType(), - CI.getArgOperand(1)->getType(), - CI.getArgOperand(2)->getType() }; + const Type *Tys[3] = { CI.getArgOperand(0)->getType(), + CI.getArgOperand(1)->getType(), + CI.getArgOperand(2)->getType() }; CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); Changed = true; } @@ -1187,7 +1187,7 @@ const AttrListPtr &NestAttrs = NestF->getAttributes(); if (!NestAttrs.isEmpty()) { unsigned NestIdx = 1; - Type *NestTy = 0; + const Type *NestTy = 0; Attributes NestAttr = Attribute::None; // Look for a parameter marked with the 'nest' attribute. @@ -1249,7 +1249,7 @@ // Handle this by synthesizing a new function type, equal to FTy // with the chain parameter inserted. - std::vector NewTypes; + std::vector NewTypes; NewTypes.reserve(FTy->getNumParams()+1); // Insert the chain's type into the list of parameter types, which may Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 20:15:52 2011 @@ -1683,7 +1683,7 @@ // result and the overflow bit. Module *M = I.getParent()->getParent()->getParent(); - Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); + const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, &NewType, 1); @@ -1725,7 +1725,7 @@ Builder->SetInsertPoint(OrigAdd); Module *M = I.getParent()->getParent()->getParent(); - Type *Ty = LHS->getType(); + const Type *Ty = LHS->getType(); Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); Value *Add = Builder->CreateExtractValue(Call, 0); Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 20:15:52 2011 @@ -572,13 +572,14 @@ } Constant *GCOVProfiler::getStartFileFunc() { + const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), - Type::getInt8PtrTy(*Ctx), false); + Args, false); return M->getOrInsertFunction("llvm_gcda_start_file", FTy); } Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { - Type *Args[] = { + const Type *Args[] = { Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row }; @@ -588,7 +589,7 @@ } Constant *GCOVProfiler::getEmitFunctionFunc() { - Type *Args[2] = { + const Type *Args[2] = { Type::getInt32Ty(*Ctx), // uint32_t ident Type::getInt8PtrTy(*Ctx), // const char *function_name }; @@ -598,7 +599,7 @@ } Constant *GCOVProfiler::getEmitArcsFunc() { - Type *Args[] = { + const Type *Args[] = { Type::getInt32Ty(*Ctx), // uint32_t num_counters Type::getInt64PtrTy(*Ctx), // uint64_t *counters }; Modified: llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp (original) +++ llvm/trunk/lib/Transforms/Instrumentation/ProfilingUtils.cpp Mon Jul 11 20:15:52 2011 @@ -134,7 +134,7 @@ void llvm::InsertProfilingShutdownCall(Function *Callee, Module *Mod) { // llvm.global_dtors is an array of type { i32, void ()* }. Prepare those // types. - Type *GlobalDtorElems[2] = { + const Type *GlobalDtorElems[2] = { Type::getInt32Ty(Mod->getContext()), FunctionType::get(Type::getVoidTy(Mod->getContext()), false)->getPointerTo() }; Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 20:15:52 2011 @@ -840,9 +840,9 @@ // If not, then we know we can transform this. Module *Mod = M->getParent()->getParent()->getParent(); - Type *ArgTys[3] = { M->getRawDest()->getType(), - M->getRawSource()->getType(), - M->getLength()->getType() }; + const Type *ArgTys[3] = { M->getRawDest()->getType(), + M->getRawSource()->getType(), + M->getLength()->getType() }; M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, ArgTys, 3)); Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 20:15:52 2011 @@ -1498,8 +1498,8 @@ Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { if (!RetainRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1515,8 +1515,8 @@ Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { if (!AutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -1532,7 +1532,7 @@ Constant *ObjCARCOpt::getReleaseCallee(Module *M) { if (!ReleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1548,7 +1548,7 @@ Constant *ObjCARCOpt::getRetainCallee(Module *M) { if (!RetainCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -1564,7 +1564,7 @@ Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { if (!AutoreleaseCallee) { LLVMContext &C = M->getContext(); - std::vector Params; + std::vector Params; Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); AttrListPtr Attributes; Attributes.addAttr(~0u, Attribute::NoUnwind); @@ -3269,9 +3269,9 @@ Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { if (!StoreStrongCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - Type *I8XX = PointerType::getUnqual(I8X); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + const Type *I8XX = PointerType::getUnqual(I8X); + std::vector Params; Params.push_back(I8XX); Params.push_back(I8X); @@ -3291,8 +3291,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { if (!RetainAutoreleaseCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); @@ -3307,8 +3307,8 @@ Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { if (!RetainAutoreleaseRVCallee) { LLVMContext &C = M->getContext(); - Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); - std::vector Params; + const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); + std::vector Params; Params.push_back(I8X); const FunctionType *FTy = FunctionType::get(I8X, Params, /*isVarArg=*/false); Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 20:15:52 2011 @@ -992,7 +992,7 @@ } // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 - Type *ArgType = Op->getType(); + const Type *ArgType = Op->getType(); Value *F = Intrinsic::getDeclaration(Callee->getParent(), Intrinsic::cttz, &ArgType, 1); Value *V = B.CreateCall(F, Op, "cttz"); Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 20:15:52 2011 @@ -140,7 +140,7 @@ Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, bool ModuleLevelChanges, ClonedCodeInfo *CodeInfo) { - std::vector ArgTypes; + std::vector ArgTypes; // The user might be deleting arguments to the function by specifying them in // the VMap. If so, we need to not add the arguments to the arg ty vector Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 20:15:52 2011 @@ -258,7 +258,7 @@ default: RetTy = Type::getInt16Ty(header->getContext()); break; } - std::vector paramTy; + std::vector paramTy; // Add the types of the input values to the function's argument list for (Values::const_iterator i = inputs.begin(), @@ -279,7 +279,7 @@ } DEBUG(dbgs() << "Function type: " << *RetTy << " f("); - for (std::vector::iterator i = paramTy.begin(), + for (std::vector::iterator i = paramTy.begin(), e = paramTy.end(); i != e; ++i) DEBUG(dbgs() << **i << ", "); DEBUG(dbgs() << ")\n"); @@ -403,7 +403,7 @@ AllocaInst *Struct = 0; if (AggregateArgs && (inputs.size() + outputs.size() > 0)) { - std::vector ArgTypes; + std::vector ArgTypes; for (Values::iterator v = StructValues.begin(), ve = StructValues.end(); v != ve; ++v) ArgTypes.push_back((*v)->getType()); Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 20:15:52 2011 @@ -663,7 +663,7 @@ LLVMContext &Context = Arg->getContext(); - Type *VoidPtrTy = Type::getInt8PtrTy(Context); + const Type *VoidPtrTy = Type::getInt8PtrTy(Context); // Create the alloca. If we have TargetData, use nice alignment. unsigned Align = 1; @@ -680,7 +680,7 @@ Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), &*Caller->begin()->begin()); // Emit a memcpy. - Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; + const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), Intrinsic::memcpy, Tys, 3); Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jul 11 20:15:52 2011 @@ -619,7 +619,7 @@ StructType *ConstantStruct::getTypeForElements(LLVMContext &Context, ArrayRef V, bool Packed) { - SmallVector EltTypes; + SmallVector EltTypes; for (unsigned i = 0, e = V.size(); i != e; ++i) EltTypes.push_back(V[i]->getType()); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 20:15:52 2011 @@ -260,7 +260,7 @@ LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, LLVMTypeRef *ParamTypes, unsigned ParamCount, LLVMBool IsVarArg) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) Tys.push_back(unwrap(*I)); @@ -290,7 +290,7 @@ LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed) { - std::vector Tys; + std::vector Tys; for (LLVMTypeRef *I = ElementTypes, *E = ElementTypes + ElementCount; I != E; ++I) Tys.push_back(unwrap(*I)); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 20:15:52 2011 @@ -333,7 +333,7 @@ return 0; } -std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { +std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { assert(id < num_intrinsics && "Invalid intrinsic ID!"); static const char * const Table[] = { "not_intrinsic", @@ -356,10 +356,10 @@ } const FunctionType *Intrinsic::getType(LLVMContext &Context, - ID id, Type **Tys, + ID id, const Type **Tys, unsigned numTys) { const Type *ResultTy = NULL; - std::vector ArgTys; + std::vector ArgTys; bool IsVarArg = false; #define GET_INTRINSIC_GENERATOR @@ -384,7 +384,7 @@ #include "llvm/Intrinsics.gen" #undef GET_INTRINSIC_ATTRIBUTES -Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, +Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, unsigned numTys) { // There can never be multiple globals with the same name of different types, // because intrinsics must be a specific type. Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 20:15:52 2011 @@ -65,7 +65,7 @@ bool isVolatile, MDNode *TBAATag) { Ptr = getCastedInt8PtrValue(Ptr); Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Ptr->getType(), Size->getType() }; + const Type *Tys[] = { Ptr->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); @@ -85,7 +85,7 @@ Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); @@ -105,7 +105,7 @@ Src = getCastedInt8PtrValue(Src); Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; - Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; + const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; Module *M = BB->getParent()->getParent(); Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); Modified: llvm/trunk/lib/VMCore/Module.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Module.cpp (original) +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 20:15:52 2011 @@ -216,8 +216,8 @@ va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (Type *ArgTy = va_arg(Args, Type*)) + std::vector ArgTys; + while (const Type *ArgTy = va_arg(Args, const Type*)) ArgTys.push_back(ArgTy); va_end(Args); @@ -234,8 +234,8 @@ va_start(Args, RetTy); // Build the list of argument types... - std::vector ArgTys; - while (Type *ArgTy = va_arg(Args, Type*)) + std::vector ArgTys; + while (const Type *ArgTy = va_arg(Args, const Type*)) ArgTys.push_back(ArgTy); va_end(Args); Modified: llvm/trunk/lib/VMCore/Type.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Type.cpp (original) +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 20:15:52 2011 @@ -325,6 +325,13 @@ NumContainedTys = Params.size() + 1; // + 1 for result type } +// FIXME: Remove this version. +FunctionType *FunctionType::get(const Type *ReturnType, + ArrayRef Params, bool isVarArg) { + return get(ReturnType, ArrayRef(const_cast(Params.data()), + Params.size()), isVarArg); +} + // FunctionType::get - The factory function for the FunctionType class. FunctionType *FunctionType::get(const Type *ReturnType, ArrayRef Params, bool isVarArg) { @@ -350,7 +357,7 @@ FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { - return get(Result, ArrayRef(), isVarArg); + return get(Result, ArrayRef(), isVarArg); } @@ -458,15 +465,22 @@ //===----------------------------------------------------------------------===// // StructType Helper functions. +// FIXME: Remove this version. +StructType *StructType::get(LLVMContext &Context, ArrayRefElements, + bool isPacked) { + return get(Context, ArrayRef(const_cast(Elements.data()), + Elements.size()), isPacked); +} + StructType *StructType::get(LLVMContext &Context, bool isPacked) { - return get(Context, llvm::ArrayRef(), isPacked); + return get(Context, llvm::ArrayRef(), isPacked); } -StructType *StructType::get(Type *type, ...) { +StructType *StructType::get(const Type *type, ...) { assert(type != 0 && "Cannot create a struct type with no elements with this"); LLVMContext &Ctx = type->getContext(); va_list ap; - SmallVector StructFields; + SmallVector StructFields; va_start(ap, type); while (type) { StructFields.push_back(type); Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Mon Jul 11 20:15:52 2011 @@ -173,7 +173,7 @@ static Constant *GetTorInit(std::vector > &TorList) { assert(!TorList.empty() && "Don't create empty tor list!"); std::vector ArrayElts; - Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); + const Type *Int32Ty = Type::getInt32Ty(TorList[0].first->getContext()); const StructType *STy = StructType::get(Int32Ty, TorList[0].first->getType(), NULL); Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 20:15:52 2011 @@ -23,7 +23,7 @@ Module M("world", Context); const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), - std::vector(), false); + std::vector(), false); Function *F = cast(M.getOrInsertFunction("f", FTy)); BasicBlock *BB = BasicBlock::Create(Context, "entry", F); ReturnInst::Create(Context, 0, BB); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 20:15:52 2011 @@ -21,7 +21,7 @@ namespace { Function *makeFakeFunction() { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); return Function::Create(FTy, GlobalValue::ExternalLinkage); Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 20:15:52 2011 @@ -37,7 +37,7 @@ namespace { Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { - std::vector params; + std::vector params; const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), params, false); Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); @@ -322,7 +322,7 @@ const FunctionType *Func1Ty = cast(TypeBuilder::get(Context)); - std::vector arg_types; + std::vector arg_types; arg_types.push_back(Type::getInt1Ty(Context)); const FunctionType *FuncTy = FunctionType::get( Type::getVoidTy(Context), arg_types, false); Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 20:15:52 2011 @@ -120,7 +120,7 @@ } TEST(TypeBuilderTest, Functions) { - std::vector params; + std::vector params; EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), (TypeBuilder::get(getGlobalContext()))); EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), @@ -187,7 +187,7 @@ static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); st.push_back(TypeBuilder::get(Context)); @@ -210,7 +210,7 @@ static const StructType *get(LLVMContext &Context) { // Using the static result variable ensures that the type is // only looked up once. - std::vector st; + std::vector st; st.push_back(TypeBuilder, cross>::get(Context)); st.push_back(TypeBuilder*, cross>::get(Context)); st.push_back(TypeBuilder*[], cross>::get(Context)); Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134949&r1=134948&r2=134949&view=diff ============================================================================== --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 20:15:52 2011 @@ -405,13 +405,13 @@ mod->setTargetTriple("x86_64-unknown-linux-gnu"); // Type Definitions - std::vectorFuncTy_0_args; + std::vectorFuncTy_0_args; FunctionType* FuncTy_0 = FunctionType::get( /*Result=*/IntegerType::get(getGlobalContext(), 32), /*Params=*/FuncTy_0_args, /*isVarArg=*/false); - std::vectorFuncTy_2_args; + std::vectorFuncTy_2_args; FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); FunctionType* FuncTy_2 = FunctionType::get( /*Result=*/Type::getVoidTy(getGlobalContext()), From wendling at apple.com Mon Jul 11 20:18:30 2011 From: wendling at apple.com (Bill Wendling) Date: Mon, 11 Jul 2011 18:18:30 -0700 Subject: [llvm-commits] [llvm] r134888 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ unittests/Analysis/ unittests/ExecutionEngine/JIT/ unittests/Support/ unittests/VMCore/ In-Reply-To: <20110711075642.18E002A6C12C@llvm.org> References: <20110711075642.18E002A6C12C@llvm.org> Message-ID: <8339093A-C207-402B-BF4C-1F435E5368F5@apple.com> Hi Jay, I had to revert this and your related patches. It was causing llvm-gcc to fail to compile on Darwin (possibly other machines). It was an assert: Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file ... -bw On Jul 11, 2011, at 12:56 AM, Jay Foad wrote: > Author: foad > Date: Mon Jul 11 02:56:41 2011 > New Revision: 134888 > > URL: http://llvm.org/viewvc/llvm-project?rev=134888&view=rev > Log: > De-constify Types in FunctionType::get(). > > Modified: > llvm/trunk/include/llvm/DerivedTypes.h > llvm/trunk/include/llvm/Intrinsics.h > llvm/trunk/include/llvm/Support/TypeBuilder.h > llvm/trunk/lib/AsmParser/LLParser.cpp > llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp > llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp > llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp > llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp > llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp > llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp > llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp > llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp > llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp > llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp > llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp > llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp > llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > llvm/trunk/lib/VMCore/Core.cpp > llvm/trunk/lib/VMCore/Function.cpp > llvm/trunk/lib/VMCore/IRBuilder.cpp > llvm/trunk/lib/VMCore/Module.cpp > llvm/trunk/lib/VMCore/Type.cpp > llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp > llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp > llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > llvm/trunk/unittests/Support/TypeBuilderTest.cpp > llvm/trunk/unittests/VMCore/PassManagerTest.cpp > > Modified: llvm/trunk/include/llvm/DerivedTypes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/DerivedTypes.h (original) > +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 02:56:41 2011 > @@ -103,8 +103,6 @@ > /// a FunctionType. > /// > static FunctionType *get(const Type *Result, > - ArrayRef Params, bool isVarArg); > - static FunctionType *get(const Type *Result, > ArrayRef Params, bool isVarArg); > > /// FunctionType::get - Create a FunctionType taking no parameters. > > Modified: llvm/trunk/include/llvm/Intrinsics.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Intrinsics.h (original) > +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 02:56:41 2011 > @@ -44,12 +44,12 @@ > > /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as > /// "llvm.ppc.altivec.lvx". > - std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); > + std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); > > /// Intrinsic::getType(ID) - Return the function type for an intrinsic. > /// > const FunctionType *getType(LLVMContext &Context, ID id, > - const Type **Tys = 0, unsigned numTys = 0); > + Type **Tys = 0, unsigned numTys = 0); > > /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be > /// overloaded. > @@ -67,7 +67,7 @@ > /// overloaded intrinsic, Tys should point to an array of numTys pointers to > /// Type, and must provide exactly one type for each overloaded type in the > /// intrinsic. > - Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, > + Function *getDeclaration(Module *M, ID id, Type **Tys = 0, > unsigned numTys = 0); > > /// Map a GCC builtin name to an intrinsic ID. > > Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) > +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 02:56:41 2011 > @@ -51,7 +51,7 @@ > /// namespace llvm { > /// template class TypeBuilder { > /// public: > -/// static const StructType *get(LLVMContext &Context) { > +/// static StructType *get(LLVMContext &Context) { > /// // If you cache this result, be sure to cache it separately > /// // for each LLVMContext. > /// return StructType::get( > @@ -104,7 +104,7 @@ > // Pointers > template class TypeBuilder { > public: > - static const PointerType *get(LLVMContext &Context) { > + static PointerType *get(LLVMContext &Context) { > return PointerType::getUnqual(TypeBuilder::get(Context)); > } > }; > @@ -115,14 +115,14 @@ > // Arrays > template class TypeBuilder { > public: > - static const ArrayType *get(LLVMContext &Context) { > + static ArrayType *get(LLVMContext &Context) { > return ArrayType::get(TypeBuilder::get(Context), N); > } > }; > /// LLVM uses an array of length 0 to represent an unknown-length array. > template class TypeBuilder { > public: > - static const ArrayType *get(LLVMContext &Context) { > + static ArrayType *get(LLVMContext &Context) { > return ArrayType::get(TypeBuilder::get(Context), 0); > } > }; > @@ -152,7 +152,7 @@ > #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ > template<> class TypeBuilder { \ > public: \ > - static const IntegerType *get(LLVMContext &Context) { \ > + static IntegerType *get(LLVMContext &Context) { \ > return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ > } \ > }; \ > @@ -181,14 +181,14 @@ > template > class TypeBuilder, cross> { > public: > - static const IntegerType *get(LLVMContext &C) { > + static IntegerType *get(LLVMContext &C) { > return IntegerType::get(C, num_bits); > } > }; > > template<> class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { > + static Type *get(LLVMContext& C) { > return Type::getFloatTy(C); > } > }; > @@ -196,7 +196,7 @@ > > template<> class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { > + static Type *get(LLVMContext& C) { > return Type::getDoubleTy(C); > } > }; > @@ -204,32 +204,32 @@ > > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } > + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } > }; > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } > + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } > }; > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } > + static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } > }; > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } > + static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } > }; > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } > + static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } > }; > template class TypeBuilder { > public: > - static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } > + static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } > }; > > template class TypeBuilder { > public: > - static const Type *get(LLVMContext &C) { > + static Type *get(LLVMContext &C) { > return Type::getVoidTy(C); > } > }; > @@ -247,14 +247,14 @@ > > template class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > + static FunctionType *get(LLVMContext &Context) { > return FunctionType::get(TypeBuilder::get(Context), false); > } > }; > template class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(1); > params.push_back(TypeBuilder::get(Context)); > return FunctionType::get(TypeBuilder::get(Context), > @@ -264,8 +264,8 @@ > template > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(2); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -276,8 +276,8 @@ > template > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(3); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -291,8 +291,8 @@ > bool cross> > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(4); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -307,8 +307,8 @@ > typename A5, bool cross> > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(5); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -322,15 +322,15 @@ > > template class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > + static FunctionType *get(LLVMContext &Context) { > return FunctionType::get(TypeBuilder::get(Context), true); > } > }; > template > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(1); > params.push_back(TypeBuilder::get(Context)); > return FunctionType::get(TypeBuilder::get(Context), params, true); > @@ -339,8 +339,8 @@ > template > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(2); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -351,8 +351,8 @@ > template > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(3); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -366,8 +366,8 @@ > bool cross> > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(4); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > @@ -382,8 +382,8 @@ > typename A5, bool cross> > class TypeBuilder { > public: > - static const FunctionType *get(LLVMContext &Context) { > - std::vector params; > + static FunctionType *get(LLVMContext &Context) { > + std::vector params; > params.reserve(5); > params.push_back(TypeBuilder::get(Context)); > params.push_back(TypeBuilder::get(Context)); > > Modified: llvm/trunk/lib/AsmParser/LLParser.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) > +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 02:56:41 2011 > @@ -1442,7 +1442,7 @@ > "argument attributes invalid in function type"); > } > > - SmallVector ArgListTy; > + SmallVector ArgListTy; > for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ArgListTy.push_back(ArgList[i].Ty); > > @@ -2655,7 +2655,7 @@ > > // Okay, if we got here, the function is syntactically valid. Convert types > // and do semantic checks. > - std::vector ParamTypeList; > + std::vector ParamTypeList; > SmallVector Attrs; > > if (RetAttrs != Attribute::None) > @@ -3171,7 +3171,7 @@ > if (!(PFTy = dyn_cast(RetType)) || > !(Ty = dyn_cast(PFTy->getElementType()))) { > // Pull out the types of all of the arguments... > - std::vector ParamTypes; > + std::vector ParamTypes; > for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ParamTypes.push_back(ArgList[i].V->getType()); > > @@ -3508,7 +3508,7 @@ > if (!(PFTy = dyn_cast(RetType)) || > !(Ty = dyn_cast(PFTy->getElementType()))) { > // Pull out the types of all of the arguments... > - std::vector ParamTypes; > + std::vector ParamTypes; > for (unsigned i = 0, e = ArgList.size(); i != e; ++i) > ParamTypes.push_back(ArgList[i].V->getType()); > > > Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) > +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 02:56:41 2011 > @@ -582,7 +582,7 @@ > // FUNCTION: [vararg, attrid, retty, paramty x N] > if (Record.size() < 3) > return Error("Invalid FUNCTION type record"); > - std::vector ArgTys; > + std::vector ArgTys; > for (unsigned i = 3, e = Record.size(); i != e; ++i) { > if (Type *T = getTypeByID(Record[i])) > ArgTys.push_back(T); > @@ -838,7 +838,7 @@ > // FUNCTION: [vararg, attrid, retty, paramty x N] > if (Record.size() < 3) > return Error("Invalid FUNCTION type record"); > - std::vector ArgTys; > + std::vector ArgTys; > for (unsigned i = 3, e = Record.size(); i != e; ++i) { > if (Type *Elt = getTypeByIDOrNull(Record[i])) > ArgTys.push_back(Elt); > > Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) > +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 02:56:41 2011 > @@ -497,10 +497,8 @@ > // Find the rewind function if we didn't already. > if (!RewindFunction) { > LLVMContext &Ctx = ResumeInsts[0]->getContext(); > - std::vector > - Params(1, Type::getInt8PtrTy(Ctx)); > FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), > - Params, false); > + Type::getInt8PtrTy(Ctx), false); > const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); > RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); > } > > Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) > +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 02:56:41 2011 > @@ -29,7 +29,7 @@ > ArgIt ArgBegin, ArgIt ArgEnd, > const Type *RetTy) { > // Insert a correctly-typed definition now. > - std::vector ParamTys; > + std::vector ParamTys; > for (ArgIt I = ArgBegin; I != ArgEnd; ++I) > ParamTys.push_back(I->getType()); > M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); > @@ -69,7 +69,7 @@ > // program already contains a function with this name. > Module *M = CI->getParent()->getParent()->getParent(); > // Get or insert the definition now. > - std::vector ParamTys; > + std::vector ParamTys; > for (ArgIt I = ArgBegin; I != ArgEnd; ++I) > ParamTys.push_back((*I)->getType()); > Constant* FCache = M->getOrInsertFunction(NewFn, > @@ -553,12 +553,12 @@ > !CI->getType()->isIntegerTy()) > return false; > > - const IntegerType *Ty = dyn_cast(CI->getType()); > + IntegerType *Ty = dyn_cast(CI->getType()); > if (!Ty) > return false; > > // Okay, we can do this xform, do so now. > - const Type *Tys[] = { Ty }; > + Type *Tys[] = { Ty }; > Module *M = CI->getParent()->getParent()->getParent(); > Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); > > > Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) > +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 > @@ -83,7 +83,7 @@ > > static const FunctionType *getType(LLVMContext &Context, unsigned id) { > const Type *ResultTy = NULL; > - std::vector ArgTys; > + std::vector ArgTys; > bool IsVarArg = false; > > #define GET_INTRINSIC_GENERATOR > > Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) > +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 > @@ -92,7 +92,7 @@ > > static const FunctionType *getType(LLVMContext &Context, unsigned id) { > const Type *ResultTy = NULL; > - std::vector ArgTys; > + std::vector ArgTys; > bool IsVarArg = false; > > #define GET_INTRINSIC_GENERATOR > > Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 02:56:41 2011 > @@ -493,7 +493,7 @@ > // Start by computing a new prototype for the function, which is the same as > // the old function, but has modified arguments. > const FunctionType *FTy = F->getFunctionType(); > - std::vector Params; > + std::vector Params; > > typedef std::set ScalarizeTable; > > > Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) > +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 02:56:41 2011 > @@ -208,7 +208,7 @@ > // the old function, but doesn't have isVarArg set. > const FunctionType *FTy = Fn.getFunctionType(); > > - std::vector Params(FTy->param_begin(), FTy->param_end()); > + std::vector Params(FTy->param_begin(), FTy->param_end()); > FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), > Params, false); > unsigned NumArgs = Params.size(); > @@ -647,7 +647,7 @@ > // Start by computing a new prototype for the function, which is the same as > // the old function, but has fewer arguments and a different return type. > const FunctionType *FTy = F->getFunctionType(); > - std::vector Params; > + std::vector Params; > > // Set up to build a new list of parameter attributes. > SmallVector AttributesVec; > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 02:56:41 2011 > @@ -1400,7 +1400,7 @@ > /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. > /// If so, insert the new bswap intrinsic and return it. > Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { > - const IntegerType *ITy = dyn_cast(I.getType()); > + IntegerType *ITy = dyn_cast(I.getType()); > if (!ITy || ITy->getBitWidth() % 16 || > // ByteMask only allows up to 32-byte values. > ITy->getBitWidth() > 32*8) > @@ -1424,7 +1424,7 @@ > for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) > if (ByteValues[i] != V) > return 0; > - const Type *Tys[] = { ITy }; > + Type *Tys[] = { ITy }; > Module *M = I.getParent()->getParent()->getParent(); > Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); > return CallInst::Create(F, V); > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 02:56:41 2011 > @@ -217,9 +217,9 @@ > if (GVSrc->isConstant()) { > Module *M = CI.getParent()->getParent()->getParent(); > Intrinsic::ID MemCpyID = Intrinsic::memcpy; > - const Type *Tys[3] = { CI.getArgOperand(0)->getType(), > - CI.getArgOperand(1)->getType(), > - CI.getArgOperand(2)->getType() }; > + Type *Tys[3] = { CI.getArgOperand(0)->getType(), > + CI.getArgOperand(1)->getType(), > + CI.getArgOperand(2)->getType() }; > CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); > Changed = true; > } > @@ -1187,7 +1187,7 @@ > const AttrListPtr &NestAttrs = NestF->getAttributes(); > if (!NestAttrs.isEmpty()) { > unsigned NestIdx = 1; > - const Type *NestTy = 0; > + Type *NestTy = 0; > Attributes NestAttr = Attribute::None; > > // Look for a parameter marked with the 'nest' attribute. > @@ -1249,7 +1249,7 @@ > // Handle this by synthesizing a new function type, equal to FTy > // with the chain parameter inserted. > > - std::vector NewTypes; > + std::vector NewTypes; > NewTypes.reserve(FTy->getNumParams()+1); > > // Insert the chain's type into the list of parameter types, which may > > Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) > +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 02:56:41 2011 > @@ -1683,7 +1683,7 @@ > // result and the overflow bit. > Module *M = I.getParent()->getParent()->getParent(); > > - const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); > + Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); > Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, > &NewType, 1); > > @@ -1725,7 +1725,7 @@ > Builder->SetInsertPoint(OrigAdd); > > Module *M = I.getParent()->getParent()->getParent(); > - const Type *Ty = LHS->getType(); > + Type *Ty = LHS->getType(); > Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); > CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); > Value *Add = Builder->CreateExtractValue(Call, 0); > > Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) > +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 02:56:41 2011 > @@ -572,14 +572,13 @@ > } > > Constant *GCOVProfiler::getStartFileFunc() { > - const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; > const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), > - Args, false); > + Type::getInt8PtrTy(*Ctx), false); > return M->getOrInsertFunction("llvm_gcda_start_file", FTy); > } > > Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { > - const Type *Args[] = { > + Type *Args[] = { > Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor > Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row > }; > @@ -589,7 +588,7 @@ > } > > Constant *GCOVProfiler::getEmitFunctionFunc() { > - const Type *Args[2] = { > + Type *Args[2] = { > Type::getInt32Ty(*Ctx), // uint32_t ident > Type::getInt8PtrTy(*Ctx), // const char *function_name > }; > @@ -599,7 +598,7 @@ > } > > Constant *GCOVProfiler::getEmitArcsFunc() { > - const Type *Args[] = { > + Type *Args[] = { > Type::getInt32Ty(*Ctx), // uint32_t num_counters > Type::getInt64PtrTy(*Ctx), // uint64_t *counters > }; > > Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 02:56:41 2011 > @@ -840,9 +840,9 @@ > > // If not, then we know we can transform this. > Module *Mod = M->getParent()->getParent()->getParent(); > - const Type *ArgTys[3] = { M->getRawDest()->getType(), > - M->getRawSource()->getType(), > - M->getLength()->getType() }; > + Type *ArgTys[3] = { M->getRawDest()->getType(), > + M->getRawSource()->getType(), > + M->getLength()->getType() }; > M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, > ArgTys, 3)); > > > Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 02:56:41 2011 > @@ -1498,8 +1498,8 @@ > Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { > if (!RetainRVCallee) { > LLVMContext &C = M->getContext(); > - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - std::vector Params; > + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + std::vector Params; > Params.push_back(I8X); > const FunctionType *FTy = > FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -1515,8 +1515,8 @@ > Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { > if (!AutoreleaseRVCallee) { > LLVMContext &C = M->getContext(); > - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - std::vector Params; > + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + std::vector Params; > Params.push_back(I8X); > const FunctionType *FTy = > FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -1532,7 +1532,7 @@ > Constant *ObjCARCOpt::getReleaseCallee(Module *M) { > if (!ReleaseCallee) { > LLVMContext &C = M->getContext(); > - std::vector Params; > + std::vector Params; > Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > AttrListPtr Attributes; > Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -1548,7 +1548,7 @@ > Constant *ObjCARCOpt::getRetainCallee(Module *M) { > if (!RetainCallee) { > LLVMContext &C = M->getContext(); > - std::vector Params; > + std::vector Params; > Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > AttrListPtr Attributes; > Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -1564,7 +1564,7 @@ > Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { > if (!AutoreleaseCallee) { > LLVMContext &C = M->getContext(); > - std::vector Params; > + std::vector Params; > Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); > AttrListPtr Attributes; > Attributes.addAttr(~0u, Attribute::NoUnwind); > @@ -3269,9 +3269,9 @@ > Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { > if (!StoreStrongCallee) { > LLVMContext &C = M->getContext(); > - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - const Type *I8XX = PointerType::getUnqual(I8X); > - std::vector Params; > + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + Type *I8XX = PointerType::getUnqual(I8X); > + std::vector Params; > Params.push_back(I8XX); > Params.push_back(I8X); > > @@ -3291,8 +3291,8 @@ > Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { > if (!RetainAutoreleaseCallee) { > LLVMContext &C = M->getContext(); > - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - std::vector Params; > + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + std::vector Params; > Params.push_back(I8X); > const FunctionType *FTy = > FunctionType::get(I8X, Params, /*isVarArg=*/false); > @@ -3307,8 +3307,8 @@ > Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { > if (!RetainAutoreleaseRVCallee) { > LLVMContext &C = M->getContext(); > - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > - std::vector Params; > + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); > + std::vector Params; > Params.push_back(I8X); > const FunctionType *FTy = > FunctionType::get(I8X, Params, /*isVarArg=*/false); > > Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) > +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 02:56:41 2011 > @@ -992,7 +992,7 @@ > } > > // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 > - const Type *ArgType = Op->getType(); > + Type *ArgType = Op->getType(); > Value *F = Intrinsic::getDeclaration(Callee->getParent(), > Intrinsic::cttz, &ArgType, 1); > Value *V = B.CreateCall(F, Op, "cttz"); > > Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 02:56:41 2011 > @@ -140,7 +140,7 @@ > Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, > bool ModuleLevelChanges, > ClonedCodeInfo *CodeInfo) { > - std::vector ArgTypes; > + std::vector ArgTypes; > > // The user might be deleting arguments to the function by specifying them in > // the VMap. If so, we need to not add the arguments to the arg ty vector > > Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 02:56:41 2011 > @@ -258,7 +258,7 @@ > default: RetTy = Type::getInt16Ty(header->getContext()); break; > } > > - std::vector paramTy; > + std::vector paramTy; > > // Add the types of the input values to the function's argument list > for (Values::const_iterator i = inputs.begin(), > @@ -279,7 +279,7 @@ > } > > DEBUG(dbgs() << "Function type: " << *RetTy << " f("); > - for (std::vector::iterator i = paramTy.begin(), > + for (std::vector::iterator i = paramTy.begin(), > e = paramTy.end(); i != e; ++i) > DEBUG(dbgs() << **i << ", "); > DEBUG(dbgs() << ")\n"); > > Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) > +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 02:56:41 2011 > @@ -663,7 +663,7 @@ > > LLVMContext &Context = Arg->getContext(); > > - const Type *VoidPtrTy = Type::getInt8PtrTy(Context); > + Type *VoidPtrTy = Type::getInt8PtrTy(Context); > > // Create the alloca. If we have TargetData, use nice alignment. > unsigned Align = 1; > @@ -680,7 +680,7 @@ > Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), > &*Caller->begin()->begin()); > // Emit a memcpy. > - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > + Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; > Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), > Intrinsic::memcpy, > Tys, 3); > > Modified: llvm/trunk/lib/VMCore/Core.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Core.cpp (original) > +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 02:56:41 2011 > @@ -260,7 +260,7 @@ > LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, > LLVMTypeRef *ParamTypes, unsigned ParamCount, > LLVMBool IsVarArg) { > - std::vector Tys; > + std::vector Tys; > for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) > Tys.push_back(unwrap(*I)); > > > Modified: llvm/trunk/lib/VMCore/Function.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Function.cpp (original) > +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 02:56:41 2011 > @@ -333,7 +333,7 @@ > return 0; > } > > -std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { > +std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { > assert(id < num_intrinsics && "Invalid intrinsic ID!"); > static const char * const Table[] = { > "not_intrinsic", > @@ -356,10 +356,10 @@ > } > > const FunctionType *Intrinsic::getType(LLVMContext &Context, > - ID id, const Type **Tys, > + ID id, Type **Tys, > unsigned numTys) { > const Type *ResultTy = NULL; > - std::vector ArgTys; > + std::vector ArgTys; > bool IsVarArg = false; > > #define GET_INTRINSIC_GENERATOR > @@ -384,7 +384,7 @@ > #include "llvm/Intrinsics.gen" > #undef GET_INTRINSIC_ATTRIBUTES > > -Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, > +Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, > unsigned numTys) { > // There can never be multiple globals with the same name of different types, > // because intrinsics must be a specific type. > > Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) > +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 02:56:41 2011 > @@ -65,7 +65,7 @@ > bool isVolatile, MDNode *TBAATag) { > Ptr = getCastedInt8PtrValue(Ptr); > Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; > - const Type *Tys[] = { Ptr->getType(), Size->getType() }; > + Type *Tys[] = { Ptr->getType(), Size->getType() }; > Module *M = BB->getParent()->getParent(); > Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); > > @@ -85,7 +85,7 @@ > Src = getCastedInt8PtrValue(Src); > > Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; > - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > Module *M = BB->getParent()->getParent(); > Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); > > @@ -105,7 +105,7 @@ > Src = getCastedInt8PtrValue(Src); > > Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; > - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; > Module *M = BB->getParent()->getParent(); > Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); > > > Modified: llvm/trunk/lib/VMCore/Module.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Module.cpp (original) > +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 02:56:41 2011 > @@ -216,8 +216,8 @@ > va_start(Args, RetTy); > > // Build the list of argument types... > - std::vector ArgTys; > - while (const Type *ArgTy = va_arg(Args, const Type*)) > + std::vector ArgTys; > + while (Type *ArgTy = va_arg(Args, Type*)) > ArgTys.push_back(ArgTy); > > va_end(Args); > @@ -234,8 +234,8 @@ > va_start(Args, RetTy); > > // Build the list of argument types... > - std::vector ArgTys; > - while (const Type *ArgTy = va_arg(Args, const Type*)) > + std::vector ArgTys; > + while (Type *ArgTy = va_arg(Args, Type*)) > ArgTys.push_back(ArgTy); > > va_end(Args); > > Modified: llvm/trunk/lib/VMCore/Type.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/lib/VMCore/Type.cpp (original) > +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 02:56:41 2011 > @@ -325,13 +325,6 @@ > NumContainedTys = Params.size() + 1; // + 1 for result type > } > > -// FIXME: Remove this version. > -FunctionType *FunctionType::get(const Type *ReturnType, > - ArrayRef Params, bool isVarArg) { > - return get(ReturnType, ArrayRef(const_cast(Params.data()), > - Params.size()), isVarArg); > -} > - > // FunctionType::get - The factory function for the FunctionType class. > FunctionType *FunctionType::get(const Type *ReturnType, > ArrayRef Params, bool isVarArg) { > @@ -357,7 +350,7 @@ > > > FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { > - return get(Result, ArrayRef(), isVarArg); > + return get(Result, ArrayRef(), isVarArg); > } > > > > Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) > +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 02:56:41 2011 > @@ -23,7 +23,7 @@ > Module M("world", Context); > > const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), > - std::vector(), false); > + std::vector(), false); > Function *F = cast(M.getOrInsertFunction("f", FTy)); > BasicBlock *BB = BasicBlock::Create(Context, "entry", F); > ReturnInst::Create(Context, 0, BB); > > Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) > +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 02:56:41 2011 > @@ -21,7 +21,7 @@ > namespace { > > Function *makeFakeFunction() { > - std::vector params; > + std::vector params; > const FunctionType *FTy = > FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); > return Function::Create(FTy, GlobalValue::ExternalLinkage); > > Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) > +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 02:56:41 2011 > @@ -37,7 +37,7 @@ > namespace { > > Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { > - std::vector params; > + std::vector params; > const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), > params, false); > Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); > @@ -322,7 +322,7 @@ > > const FunctionType *Func1Ty = > cast(TypeBuilder::get(Context)); > - std::vector arg_types; > + std::vector arg_types; > arg_types.push_back(Type::getInt1Ty(Context)); > const FunctionType *FuncTy = FunctionType::get( > Type::getVoidTy(Context), arg_types, false); > > Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) > +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 02:56:41 2011 > @@ -120,7 +120,7 @@ > } > > TEST(TypeBuilderTest, Functions) { > - std::vector params; > + std::vector params; > EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), > (TypeBuilder::get(getGlobalContext()))); > EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), > > Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff > ============================================================================== > --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) > +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 02:56:41 2011 > @@ -405,13 +405,13 @@ > mod->setTargetTriple("x86_64-unknown-linux-gnu"); > > // Type Definitions > - std::vectorFuncTy_0_args; > + std::vectorFuncTy_0_args; > FunctionType* FuncTy_0 = FunctionType::get( > /*Result=*/IntegerType::get(getGlobalContext(), 32), > /*Params=*/FuncTy_0_args, > /*isVarArg=*/false); > > - std::vectorFuncTy_2_args; > + std::vectorFuncTy_2_args; > FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); > FunctionType* FuncTy_2 = FunctionType::get( > /*Result=*/Type::getVoidTy(getGlobalContext()), > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From echristo at apple.com Mon Jul 11 20:20:02 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 11 Jul 2011 18:20:02 -0700 Subject: [llvm-commits] [llvm] r134936 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711230653.7DA112A6C12C@llvm.org> Message-ID: <8A2651F5-7DEB-49C4-9251-7182EA1BBC31@apple.com> On Jul 11, 2011, at 5:01 PM, David A. Greene wrote: > Eric Christopher writes: > >>> Just to clarify, are you referring to the "pure virtual called" errors >>> or is there something additional going on? The messages I got from the >>> buildbot were not immediately helpful. One was for the "pure virtual" >>> problem which I think is exposed or caused by this patch. Another was >>> for some clang test failures that I somewhat doubt are connected to this >>> patch and the last was a buildbot slave hangup problem. >> >> Anecdotally reverting your patch has made everything go green again. > > How can you say? I'm seeing a lot of builds in progress and slaves > offline. > > Maybe I'm using this buildbot thing wrong. :) What page are you looking > at? I was going off of the buildbots that report to the llvm irc channel actually :) I saw them start failing this morning with your patches and go green when I reverted. One thought on tracking this down is to see if there are any virtual functions being called during object destruction. -eric From pichet2000 at gmail.com Mon Jul 11 20:34:24 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Mon, 11 Jul 2011 21:34:24 -0400 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> <4E1B4355.2030804@gmail.com> <8534C9F4-9F8C-46A6-B841-1780420789BD@apple.com> <41FB6CA0-C99A-4A12-92C3-1B8B63AF23D9@apple.com> Message-ID: On Mon, Jul 11, 2011 at 7:48 PM, David A. Greene wrote: > Francois Pichet writes: > >> I started the VC++ debugger on tblgen and the pure function call is on >> line 71 of file Support\Allocator.cpp: >>> ? ?Allocator.Deallocate(Slab); >> >> This is during doexit() after main has finished.. static variable >> destructor i suppose. >> >> I suspect a memory corruption. > > I ran valgrind on a gcc-compiled tblgen on Linux and didn't see any > obvious errors. ?Lots of leaks, but that's a separate issue. ?It doesn't > mean there's not a problem, just that I can't see it at all. > > Is there a similar memory analysis tool available for Windows that you > could run? > > Evan, could you go back to the old version of Clang you were using to > build and do a valgrind run on the resulting executable? ?That might > help us track this down. > I tried to find the problem for half a hour earlier today, I am using plain MSVC without any fancy tools. Splitting the patch in many parts would help to find the problem. Huge patch like that are very difficult to bisect for a problem. From aggarwa4 at illinois.edu Mon Jul 11 22:11:12 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 12 Jul 2011 03:11:12 -0000 Subject: [llvm-commits] [poolalloc] r134954 - /poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp Message-ID: <20110712031112.EF1C02A6C12C@llvm.org> Author: aggarwa4 Date: Mon Jul 11 22:11:12 2011 New Revision: 134954 URL: http://llvm.org/viewvc/llvm-project?rev=134954&view=rev Log: Do not delete the instructuion as we are using the same instruction with a changed function. Modified: poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp?rev=134954&r1=134953&r2=134954&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecksOpt.cpp Mon Jul 11 22:11:12 2011 @@ -175,7 +175,6 @@ // check if operand is an alloca inst. if(TS->isTypeSafe(CI->getOperand(1)->stripPointerCasts(), CI->getParent()->getParent())) { CI->setCalledFunction(trackInitInst); - toDelete.push_back(CI); if(AllocaInst *AI = dyn_cast(CI->getOperand(1)->stripPointerCasts())) { // Initialize the allocation to NULL From aggarwa4 at illinois.edu Mon Jul 11 22:12:59 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 12 Jul 2011 03:12:59 -0000 Subject: [llvm-commits] [poolalloc] r134956 - /poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Message-ID: <20110712031259.44AAE2A6C12C@llvm.org> Author: aggarwa4 Date: Mon Jul 11 22:12:59 2011 New Revision: 134956 URL: http://llvm.org/viewvc/llvm-project?rev=134956&view=rev Log: 1. more library functions. 2. Insert check if a load is used as condition in select Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Modified: poolalloc/trunk/lib/AssistDS/TypeChecks.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/TypeChecks.cpp?rev=134956&r1=134955&r2=134956&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/TypeChecks.cpp (original) +++ poolalloc/trunk/lib/AssistDS/TypeChecks.cpp Mon Jul 11 22:12:59 2011 @@ -1401,19 +1401,23 @@ CastInst *BCI = BitCastInst::CreatePointerCast(&AI, VoidPtrTy); BCI->insertAfter(&AI); - CastInst *ArraySize = CastInst::CreateSExtOrBitCast(AI.getArraySize(), Int64Ty); - ArraySize->insertAfter(BCI); - BinaryOperator *Size = BinaryOperator::Create(Instruction::Mul, AllocSize, ArraySize); - Size->insertAfter(ArraySize); + Value *TotalSize; + if(!AI.isArrayAllocation()) { + TotalSize = AllocSize; + } else { + CastInst *ArraySize = CastInst::CreateSExtOrBitCast(AI.getArraySize(), Int64Ty, "", &AI); + BinaryOperator *Size = BinaryOperator::Create(Instruction::Mul, AllocSize, ArraySize, "", &AI); + TotalSize = Size; + } // Setting metadata to be 0(BOTTOM/Uninitialized) std::vector Args; Args.push_back(BCI); - Args.push_back(Size); + Args.push_back(TotalSize); Args.push_back(getTagCounter()); CallInst *CI = CallInst::Create(trackUnInitInst, Args.begin(), Args.end()); - CI->insertAfter(Size); + CI->insertAfter(BCI); return true; } @@ -1591,6 +1595,15 @@ Args.push_back(getTagCounter()); CallInst *CI = CallInst::Create(trackInitInst, Args.begin(), Args.end()); CI->insertAfter(BCI); + } else if (F->getNameStr() == std::string("getservbyname")) { + CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy); + BCI->insertAfter(I); + std::vectorArgs; + Args.push_back(BCI); + Args.push_back(getTagCounter()); + Constant *F = M.getOrInsertFunction("trackgetservbyname", VoidTy, VoidPtrTy, Int32Ty, NULL); + CallInst *CI = CallInst::Create(F, Args.begin(), Args.end()); + CI->insertAfter(BCI); } else if (F->getNameStr() == std::string("gethostbyname") || F->getNameStr() == std::string("gethostbyaddr")) { CastInst *BCI = BitCastInst::CreatePointerCast(I, VoidPtrTy); @@ -1642,6 +1655,7 @@ } else if (F->getNameStr() == std::string("getrusage") || F->getNameStr() == std::string("getrlimit") || F->getNameStr() == std::string("stat") || + F->getNameStr() == std::string("vfsstat") || F->getNameStr() == std::string("fstat") || F->getNameStr() == std::string("lstat")) { CastInst *BCI = BitCastInst::CreatePointerCast(CS.getArgument(1), VoidPtrTy, "", I); @@ -1883,17 +1897,23 @@ Args.push_back(getTagCounter()); CallInst *CINew = CallInst::Create(trackInitInst, Args.begin(), Args.end()); CINew->insertAfter(NewValue); + } else if(F->getNameStr() == std::string("scanf")) { + unsigned i = 1; + while(i < CS.arg_size()) { + visitInputFunctionValue(M, CS.getArgument(i), I); + i++; + } } else if(F->getNameStr() == std::string("sscanf")) { // FIXME: Need to look at the format string and check - unsigned i = 3; - while(i < I->getNumOperands()) { - visitInputFunctionValue(M, CS.getArgument(i-1), I); + unsigned i = 2; + while(i < CS.arg_size()) { + visitInputFunctionValue(M, CS.getArgument(i), I); i++; } } else if(F->getNameStr() == std::string("fscanf")) { - unsigned i = 3; - while(i < I->getNumOperands()) { - visitInputFunctionValue(M, CS.getArgument(i-1), I); + unsigned i = 2; + while(i < CS.arg_size()) { + visitInputFunctionValue(M, CS.getArgument(i), I); i++; } } @@ -2060,40 +2080,45 @@ CallInst::Create(checkTypeInst, Args.begin(), Args.end(), "", cast(II.getUse().getUser())); } } else if(SelectInst *SelI = dyn_cast(II)) { - SelectInst *Prev = NULL; - SelectInst *PrevBasePtr = NULL; - if(SelectInst_MD_Map.find(SelI) != SelectInst_MD_Map.end()) { - Prev = SelectInst_MD_Map[SelI]; - PrevBasePtr = SelectInst_BasePtr_Map[SelI]; - } - SelectInst *AI_New; - SelectInst *BCI_New; - if(SelI->getTrueValue() == I) { - if(!Prev) { - AI_New = SelectInst::Create(SelI->getCondition(), AI, Constant::getNullValue(AI->getType()), "", SelI); - BCI_New = SelectInst::Create(SelI->getCondition(), BCI, Constant::getNullValue(BCI->getType()), "", SelI); - } else { - AI_New = SelectInst::Create(SelI->getCondition(), AI, Prev->getFalseValue(), "", SelI); - BCI_New = SelectInst::Create(SelI->getCondition(), BCI, Prev->getFalseValue(), "", SelI); - Prev->replaceAllUsesWith(AI_New); - PrevBasePtr->replaceAllUsesWith(BCI_New); + if(SelI->getOperand(0) == I) { + CallInst::Create(checkTypeInst, Args.begin(), Args.end(), "", cast(II.getUse().getUser())); + // if it is used as the condition, just insert a check + } else { + SelectInst *Prev = NULL; + SelectInst *PrevBasePtr = NULL; + if(SelectInst_MD_Map.find(SelI) != SelectInst_MD_Map.end()) { + Prev = SelectInst_MD_Map[SelI]; + PrevBasePtr = SelectInst_BasePtr_Map[SelI]; } - } - else { - if(!Prev) { - AI_New = SelectInst::Create(SelI->getCondition(), Constant::getNullValue(AI->getType()), AI, "", SelI); - BCI_New = SelectInst::Create(SelI->getCondition(), Constant::getNullValue(BCI->getType()), BCI, "", SelI); - } else { - AI_New = SelectInst::Create(SelI->getCondition(), Prev->getTrueValue(), AI, "", SelI); - BCI_New = SelectInst::Create(SelI->getCondition(), Prev->getTrueValue(), BCI, "", SelI); - Prev->replaceAllUsesWith(AI_New); - PrevBasePtr->replaceAllUsesWith(BCI_New); + SelectInst *AI_New; + SelectInst *BCI_New; + if(SelI->getTrueValue() == I) { + if(!Prev) { + AI_New = SelectInst::Create(SelI->getCondition(), AI, Constant::getNullValue(AI->getType()), "", SelI); + BCI_New = SelectInst::Create(SelI->getCondition(), BCI, Constant::getNullValue(BCI->getType()), "", SelI); + } else { + AI_New = SelectInst::Create(SelI->getCondition(), AI, Prev->getFalseValue(), "", SelI); + BCI_New = SelectInst::Create(SelI->getCondition(), BCI, Prev->getFalseValue(), "", SelI); + Prev->replaceAllUsesWith(AI_New); + PrevBasePtr->replaceAllUsesWith(BCI_New); + } + } + else { + if(!Prev) { + AI_New = SelectInst::Create(SelI->getCondition(), Constant::getNullValue(AI->getType()), AI, "", SelI); + BCI_New = SelectInst::Create(SelI->getCondition(), Constant::getNullValue(BCI->getType()), BCI, "", SelI); + } else { + AI_New = SelectInst::Create(SelI->getCondition(), Prev->getTrueValue(), AI, "", SelI); + BCI_New = SelectInst::Create(SelI->getCondition(), Prev->getTrueValue(), BCI, "", SelI); + Prev->replaceAllUsesWith(AI_New); + PrevBasePtr->replaceAllUsesWith(BCI_New); + } } + SelectInst_MD_Map[SelI] = AI_New; + SelectInst_BasePtr_Map[SelI] = BCI_New; + if(!Prev) + visitUses(SelI, AI_New, BCI_New); } - SelectInst_MD_Map[SelI] = AI_New; - SelectInst_BasePtr_Map[SelI] = BCI_New; - if(!Prev) - visitUses(SelI, AI_New, BCI_New); } else if(PHINode *PH = dyn_cast(II)) { PHINode *Prev = NULL; PHINode *PrevBasePtr = NULL; From aggarwa4 at illinois.edu Mon Jul 11 22:13:27 2011 From: aggarwa4 at illinois.edu (Arushi Aggarwal) Date: Tue, 12 Jul 2011 03:13:27 -0000 Subject: [llvm-commits] [poolalloc] r134957 - /poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp Message-ID: <20110712031327.8C44A2A6C12C@llvm.org> Author: aggarwa4 Date: Mon Jul 11 22:13:27 2011 New Revision: 134957 URL: http://llvm.org/viewvc/llvm-project?rev=134957&view=rev Log: More runtime functions Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp Modified: poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp?rev=134957&r1=134956&r2=134957&view=diff ============================================================================== --- poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp (original) +++ poolalloc/trunk/runtime/DynamicTypeChecks/TypeRuntime.cpp Mon Jul 11 22:13:27 2011 @@ -80,6 +80,7 @@ void trackgetcwd(void *ptr, uint32_t tag) ; void trackgetpwuid(void *ptr, uint32_t tag) ; void trackgethostname(void *ptr, uint32_t tag) ; + void trackgetservbyname(void *ptr, uint32_t tag) ; void trackgethostbyname(void *ptr, uint32_t tag) ; void trackgetaddrinfo(void *ptr, uint32_t tag) ; void trackaccept(void *ptr, void *size,uint32_t tag) ; @@ -395,6 +396,23 @@ void trackgethostname(void *ptr, uint32_t tag) { trackInitInst(ptr, strlen((const char *)ptr) + 1, tag); } + +void trackgetservbyname(void *ptr, uint32_t tag) { + struct servent *sn = (struct servent *)ptr; + trackInitInst(sn->s_name, strlen(sn->s_name) + 1, tag); + unsigned i; + for(i =0; sn->s_aliases[i] != NULL; i++) { + trackInitInst(&sn->s_aliases[i], sizeof(char*), tag); + trackInitInst(sn->s_aliases[i], strlen(sn->s_aliases[i]) + 1, tag); + } + trackInitInst(&sn->s_aliases[i], sizeof(char*), tag); + trackInitInst(sn->s_aliases[i], sizeof(char), tag); + + trackInitInst(sn->s_proto, strlen(sn->s_proto) + 1, tag); + + trackInitInst(ptr, sizeof(struct servent), tag); +} + void trackgethostbyname(void *ptr, uint32_t tag) { struct hostent *hn = (struct hostent *)ptr; trackInitInst(hn->h_name, strlen(hn->h_name) + 1, tag); From atrick at apple.com Mon Jul 11 22:39:23 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 12 Jul 2011 03:39:23 -0000 Subject: [llvm-commits] [llvm] r134958 - /llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll Message-ID: <20110712033923.1D5262A6C12C@llvm.org> Author: atrick Date: Mon Jul 11 22:39:22 2011 New Revision: 134958 URL: http://llvm.org/viewvc/llvm-project?rev=134958&view=rev Log: Comment correction. Modified: llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll Modified: llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll?rev=134958&r1=134957&r2=134958&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll (original) +++ llvm/trunk/test/CodeGen/Generic/2011-07-07-ScheduleDAGCrash.ll Mon Jul 11 22:39:22 2011 @@ -1,6 +1,7 @@ ; RUN: llc < %s -; This used to cause ScheduleDAG to crash during EmitPhysRegCopy when it mistook -; followed a non-control dependence, PR10220. +; This caused ScheduleDAG to crash in EmitPhysRegCopy when searching +; the uses of a copy to a physical register without ignoring non-data +; dependence, PR10220. define void @f(i256* nocapture %a, i256* nocapture %b, i256* nocapture %cc, i256* nocapture %dd) nounwind uwtable noinline ssp { entry: From johnw at boostpro.com Mon Jul 11 17:39:46 2011 From: johnw at boostpro.com (John Wiegley) Date: Mon, 11 Jul 2011 22:39:46 -0000 Subject: [llvm-commits] [llvm] r134933 - in /llvm/trunk/examples: BrainF/BrainF.cpp Kaleidoscope/Chapter3/toy.cpp Kaleidoscope/Chapter4/toy.cpp Kaleidoscope/Chapter5/toy.cpp Kaleidoscope/Chapter6/toy.cpp Kaleidoscope/Chapter7/toy.cpp Message-ID: <20110711223946.C67C52A6C12C@llvm.org> Author: johnw Date: Mon Jul 11 17:39:46 2011 New Revision: 134933 URL: http://llvm.org/viewvc/llvm-project?rev=134933&view=rev Log: fix some examples Modified: llvm/trunk/examples/BrainF/BrainF.cpp llvm/trunk/examples/Kaleidoscope/Chapter3/toy.cpp llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Mon Jul 11 17:39:46 2011 @@ -55,7 +55,7 @@ //Function prototypes //declare void @llvm.memset.p0i8.i32(i8 *, i8, i32, i32, i1) - const Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) }; + Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) }; Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset, Tys, 2); Modified: llvm/trunk/examples/Kaleidoscope/Chapter3/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter3/toy.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/Chapter3/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/Chapter3/toy.cpp Mon Jul 11 17:39:46 2011 @@ -400,8 +400,8 @@ Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. - std::vector Doubles(Args.size(), - Type::getDoubleTy(getGlobalContext())); + std::vector Doubles(Args.size(), + Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false); Modified: llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/Chapter4/toy.cpp Mon Jul 11 17:39:46 2011 @@ -408,8 +408,8 @@ Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. - std::vector Doubles(Args.size(), - Type::getDoubleTy(getGlobalContext())); + std::vector Doubles(Args.size(), + Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false); Modified: llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/Chapter5/toy.cpp Mon Jul 11 17:39:46 2011 @@ -653,8 +653,8 @@ Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. - std::vector Doubles(Args.size(), - Type::getDoubleTy(getGlobalContext())); + std::vector Doubles(Args.size(), + Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false); Modified: llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/Chapter6/toy.cpp Mon Jul 11 17:39:46 2011 @@ -757,8 +757,8 @@ Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. - std::vector Doubles(Args.size(), - Type::getDoubleTy(getGlobalContext())); + std::vector Doubles(Args.size(), + Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false); Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp?rev=134933&r1=134932&r2=134933&view=diff ============================================================================== --- llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp (original) +++ llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp Mon Jul 11 17:39:46 2011 @@ -905,8 +905,8 @@ Function *PrototypeAST::Codegen() { // Make the function type: double(double,double) etc. - std::vector Doubles(Args.size(), - Type::getDoubleTy(getGlobalContext())); + std::vector Doubles(Args.size(), + Type::getDoubleTy(getGlobalContext())); FunctionType *FT = FunctionType::get(Type::getDoubleTy(getGlobalContext()), Doubles, false); From clattner at apple.com Mon Jul 11 23:03:53 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 11 Jul 2011 21:03:53 -0700 Subject: [llvm-commits] [llvm] r134907 - /llvm/trunk/utils/TableGen/ In-Reply-To: References: <20110711182552.740612A6C12C@llvm.org> Message-ID: <41C7A1EE-5573-42E1-AD19-D810544C5EB4@apple.com> On Jul 11, 2011, at 1:44 PM, David A. Greene wrote: > Jakob Stoklund Olesen writes: > >> On Jul 11, 2011, at 11:25 AM, David Greene wrote: >> >>> Author: greened >>> Date: Mon Jul 11 13:25:51 2011 >>> New Revision: 134907 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=134907&view=rev >>> Log: >>> [AVX] Make Inits Foldable > >> David, please revert this. >> >> You are ignoring code review, > > How so? Your review came in after the commit. Specifically: http://llvm.org/docs/DeveloperPolicy.html#reviews This is a major change in an area that you don't own. This should be reviewed before you commit it. -Chris From sabre at nondot.org Mon Jul 11 23:14:22 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jul 2011 04:14:22 -0000 Subject: [llvm-commits] [llvm] r134959 - in /llvm/trunk: include/llvm/Support/IRBuilder.h lib/VMCore/IRBuilder.cpp Message-ID: <20110712041422.A3AB22A6C12C@llvm.org> Author: lattner Date: Mon Jul 11 23:14:22 2011 New Revision: 134959 URL: http://llvm.org/viewvc/llvm-project?rev=134959&view=rev Log: make the IRBuilder type methods return non-const types. Modified: llvm/trunk/include/llvm/Support/IRBuilder.h llvm/trunk/lib/VMCore/IRBuilder.cpp Modified: llvm/trunk/include/llvm/Support/IRBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=134959&r1=134958&r2=134959&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/IRBuilder.h (original) +++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Jul 11 23:14:22 2011 @@ -111,7 +111,7 @@ /// getCurrentDebugLocation - Get location information used by debugging /// information. - const DebugLoc &getCurrentDebugLocation() const { return CurDbgLocation; } + DebugLoc getCurrentDebugLocation() const { return CurDbgLocation; } /// SetInstDebugLocation - If this builder has a current debug location, set /// it on the specified instruction. @@ -122,7 +122,7 @@ /// getCurrentFunctionReturnType - Get the return type of the current function /// that we're emitting into. - const Type *getCurrentFunctionReturnType() const; + Type *getCurrentFunctionReturnType() const; /// InsertPoint - A saved insertion point. class InsertPoint { @@ -222,46 +222,46 @@ //===--------------------------------------------------------------------===// /// getInt1Ty - Fetch the type representing a single bit - const IntegerType *getInt1Ty() { + IntegerType *getInt1Ty() { return Type::getInt1Ty(Context); } /// getInt8Ty - Fetch the type representing an 8-bit integer. - const IntegerType *getInt8Ty() { + IntegerType *getInt8Ty() { return Type::getInt8Ty(Context); } /// getInt16Ty - Fetch the type representing a 16-bit integer. - const IntegerType *getInt16Ty() { + IntegerType *getInt16Ty() { return Type::getInt16Ty(Context); } /// getInt32Ty - Fetch the type resepresenting a 32-bit integer. - const IntegerType *getInt32Ty() { + IntegerType *getInt32Ty() { return Type::getInt32Ty(Context); } /// getInt64Ty - Fetch the type representing a 64-bit integer. - const IntegerType *getInt64Ty() { + IntegerType *getInt64Ty() { return Type::getInt64Ty(Context); } /// getFloatTy - Fetch the type representing a 32-bit floating point value. - const Type *getFloatTy() { + Type *getFloatTy() { return Type::getFloatTy(Context); } /// getDoubleTy - Fetch the type representing a 64-bit floating point value. - const Type *getDoubleTy() { + Type *getDoubleTy() { return Type::getDoubleTy(Context); } /// getVoidTy - Fetch the type representing void. - const Type *getVoidTy() { + Type *getVoidTy() { return Type::getVoidTy(Context); } - const PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { + PointerType *getInt8PtrTy(unsigned AddrSpace = 0) { return Type::getInt8PtrTy(Context, AddrSpace); } @@ -1257,7 +1257,7 @@ Value *CreatePtrDiff(Value *LHS, Value *RHS, const Twine &Name = "") { assert(LHS->getType() == RHS->getType() && "Pointer subtraction operand types must match!"); - const PointerType *ArgType = cast(LHS->getType()); + PointerType *ArgType = cast(LHS->getType()); Value *LHS_int = CreatePtrToInt(LHS, Type::getInt64Ty(Context)); Value *RHS_int = CreatePtrToInt(RHS, Type::getInt64Ty(Context)); Value *Difference = CreateSub(LHS_int, RHS_int); Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134959&r1=134958&r2=134959&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 23:14:22 2011 @@ -34,7 +34,7 @@ return GV; } -const Type *IRBuilderBase::getCurrentFunctionReturnType() const { +Type *IRBuilderBase::getCurrentFunctionReturnType() const { assert(BB && BB->getParent() && "No current function!"); return BB->getParent()->getReturnType(); } From sabre at nondot.org Tue Jul 12 00:26:21 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jul 2011 05:26:21 -0000 Subject: [llvm-commits] [llvm] r134968 - /llvm/trunk/lib/VMCore/Constants.cpp Message-ID: <20110712052621.7F8A52A6C12C@llvm.org> Author: lattner Date: Tue Jul 12 00:26:21 2011 New Revision: 134968 URL: http://llvm.org/viewvc/llvm-project?rev=134968&view=rev Log: simplify assertions to not be completely redundant. Modified: llvm/trunk/lib/VMCore/Constants.cpp Modified: llvm/trunk/lib/VMCore/Constants.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=134968&r1=134967&r2=134968&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Constants.cpp (original) +++ llvm/trunk/lib/VMCore/Constants.cpp Tue Jul 12 00:26:21 2011 @@ -1716,26 +1716,13 @@ Constant *ConstantExpr::getInsertValue(Constant *Agg, Constant *Val, const unsigned *Idxs, unsigned NumIdx) { - assert(Agg->getType()->isFirstClassType() && - "Tried to create insertelement operation on non-first-class type!"); - - const Type *ReqTy = Agg->getType(); - (void)ReqTy; -#ifndef NDEBUG - const Type *ValTy = - ExtractValueInst::getIndexedType(Agg->getType(), Idxs, Idxs+NumIdx); - assert(ValTy == Val->getType() && "insertvalue indices invalid!"); -#endif - assert(ExtractValueInst::getIndexedType(Agg->getType(), Idxs, Idxs+NumIdx) == Val->getType() && "insertvalue indices invalid!"); - assert(Agg->getType() == ReqTy && - "insertvalue type invalid!"); assert(Agg->getType()->isFirstClassType() && - "Non-first-class type for constant InsertValue expression"); + "Non-first-class type for constant insertvalue expression"); Constant *FC = ConstantFoldInsertValueInstruction(Agg, Val, Idxs, NumIdx); - assert(FC && "InsertValue constant expr couldn't be folded!"); + assert(FC && "insertvalue constant expr couldn't be folded!"); return FC; } From sabre at nondot.org Tue Jul 12 01:16:45 2011 From: sabre at nondot.org (Chris Lattner) Date: Tue, 12 Jul 2011 06:16:45 -0000 Subject: [llvm-commits] [test-suite] r134970 - /test-suite/trunk/MultiSource/Applications/Makefile Message-ID: <20110712061645.18D742A6C12C@llvm.org> Author: lattner Date: Tue Jul 12 01:16:44 2011 New Revision: 134970 URL: http://llvm.org/viewvc/llvm-project?rev=134970&view=rev Log: reenable oggenc, lets see if it works now, it works for me. Modified: test-suite/trunk/MultiSource/Applications/Makefile Modified: test-suite/trunk/MultiSource/Applications/Makefile URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/Makefile?rev=134970&r1=134969&r2=134970&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/Makefile (original) +++ test-suite/trunk/MultiSource/Applications/Makefile Tue Jul 12 01:16:44 2011 @@ -5,7 +5,7 @@ include $(LEVEL)/Makefile.config PARALLEL_DIRS = Burg aha sgefa siod d spiff treecc SPASS \ - JM viterbi SIBsim4 ClamAV sqlite3 lemon + oggenc JM viterbi SIBsim4 ClamAV sqlite3 lemon ifndef DISABLE_CXX PARALLEL_DIRS += lambda-0.1.3 hbd hexxagon minisat endif From jay.foad at gmail.com Tue Jul 12 01:29:55 2011 From: jay.foad at gmail.com (Jay Foad) Date: Tue, 12 Jul 2011 07:29:55 +0100 Subject: [llvm-commits] [llvm] r134888 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumenta Message-ID: Thanks. I'll look into it today. Sorry for the breakage. Jay. On 12 July 2011 02:18, Bill Wendling wrote: > Hi Jay, > > I had to revert this and your related patches. It was causing llvm-gcc to fail to compile on Darwin (possibly other machines). It was an assert: > > Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file ... > > -bw > > On Jul 11, 2011, at 12:56 AM, Jay Foad wrote: > >> Author: foad >> Date: Mon Jul 11 02:56:41 2011 >> New Revision: 134888 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=134888&view=rev >> Log: >> De-constify Types in FunctionType::get(). >> >> Modified: >> ? ?llvm/trunk/include/llvm/DerivedTypes.h >> ? ?llvm/trunk/include/llvm/Intrinsics.h >> ? ?llvm/trunk/include/llvm/Support/TypeBuilder.h >> ? ?llvm/trunk/lib/AsmParser/LLParser.cpp >> ? ?llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp >> ? ?llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp >> ? ?llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp >> ? ?llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp >> ? ?llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp >> ? ?llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp >> ? ?llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp >> ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp >> ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >> ? ?llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp >> ? ?llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp >> ? ?llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >> ? ?llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp >> ? ?llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >> ? ?llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp >> ? ?llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp >> ? ?llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >> ? ?llvm/trunk/lib/VMCore/Core.cpp >> ? ?llvm/trunk/lib/VMCore/Function.cpp >> ? ?llvm/trunk/lib/VMCore/IRBuilder.cpp >> ? ?llvm/trunk/lib/VMCore/Module.cpp >> ? ?llvm/trunk/lib/VMCore/Type.cpp >> ? ?llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp >> ? ?llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp >> ? ?llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >> ? ?llvm/trunk/unittests/Support/TypeBuilderTest.cpp >> ? ?llvm/trunk/unittests/VMCore/PassManagerTest.cpp >> >> Modified: llvm/trunk/include/llvm/DerivedTypes.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/DerivedTypes.h (original) >> +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 02:56:41 2011 >> @@ -103,8 +103,6 @@ >> ? /// a FunctionType. >> ? /// >> ? static FunctionType *get(const Type *Result, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ArrayRef Params, bool isVarArg); >> - ?static FunctionType *get(const Type *Result, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArrayRef Params, bool isVarArg); >> >> ? /// FunctionType::get - Create a FunctionType taking no parameters. >> >> Modified: llvm/trunk/include/llvm/Intrinsics.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Intrinsics.h (original) >> +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 02:56:41 2011 >> @@ -44,12 +44,12 @@ >> >> ? /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as >> ? /// "llvm.ppc.altivec.lvx". >> - ?std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); >> + ?std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); >> >> ? /// Intrinsic::getType(ID) - Return the function type for an intrinsic. >> ? /// >> ? const FunctionType *getType(LLVMContext &Context, ID id, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Type **Tys = 0, unsigned numTys = 0); >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type **Tys = 0, unsigned numTys = 0); >> >> ? /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be >> ? /// overloaded. >> @@ -67,7 +67,7 @@ >> ? /// overloaded intrinsic, Tys should point to an array of numTys pointers to >> ? /// Type, and must provide exactly one type for each overloaded type in the >> ? /// intrinsic. >> - ?Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, >> + ?Function *getDeclaration(Module *M, ID id, Type **Tys = 0, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned numTys = 0); >> >> ? /// Map a GCC builtin name to an intrinsic ID. >> >> Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) >> +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 02:56:41 2011 >> @@ -51,7 +51,7 @@ >> /// ? namespace llvm { >> /// ? template class TypeBuilder { >> /// ? public: >> -/// ? ? static const StructType *get(LLVMContext &Context) { >> +/// ? ? static StructType *get(LLVMContext &Context) { >> /// ? ? ? // If you cache this result, be sure to cache it separately >> /// ? ? ? // for each LLVMContext. >> /// ? ? ? return StructType::get( >> @@ -104,7 +104,7 @@ >> // Pointers >> template class TypeBuilder { >> public: >> - ?static const PointerType *get(LLVMContext &Context) { >> + ?static PointerType *get(LLVMContext &Context) { >> ? ? return PointerType::getUnqual(TypeBuilder::get(Context)); >> ? } >> }; >> @@ -115,14 +115,14 @@ >> // Arrays >> template class TypeBuilder { >> public: >> - ?static const ArrayType *get(LLVMContext &Context) { >> + ?static ArrayType *get(LLVMContext &Context) { >> ? ? return ArrayType::get(TypeBuilder::get(Context), N); >> ? } >> }; >> /// LLVM uses an array of length 0 to represent an unknown-length array. >> template class TypeBuilder { >> public: >> - ?static const ArrayType *get(LLVMContext &Context) { >> + ?static ArrayType *get(LLVMContext &Context) { >> ? ? return ArrayType::get(TypeBuilder::get(Context), 0); >> ? } >> }; >> @@ -152,7 +152,7 @@ >> #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ >> template<> class TypeBuilder { \ >> public: \ >> - ?static const IntegerType *get(LLVMContext &Context) { \ >> + ?static IntegerType *get(LLVMContext &Context) { \ >> ? ? return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ >> ? } \ >> }; \ >> @@ -181,14 +181,14 @@ >> template >> class TypeBuilder, cross> { >> public: >> - ?static const IntegerType *get(LLVMContext &C) { >> + ?static IntegerType *get(LLVMContext &C) { >> ? ? return IntegerType::get(C, num_bits); >> ? } >> }; >> >> template<> class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { >> + ?static Type *get(LLVMContext& C) { >> ? ? return Type::getFloatTy(C); >> ? } >> }; >> @@ -196,7 +196,7 @@ >> >> template<> class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { >> + ?static Type *get(LLVMContext& C) { >> ? ? return Type::getDoubleTy(C); >> ? } >> }; >> @@ -204,32 +204,32 @@ >> >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } >> }; >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } >> }; >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } >> }; >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } >> }; >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } >> }; >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } >> + ?static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } >> }; >> >> template class TypeBuilder { >> public: >> - ?static const Type *get(LLVMContext &C) { >> + ?static Type *get(LLVMContext &C) { >> ? ? return Type::getVoidTy(C); >> ? } >> }; >> @@ -247,14 +247,14 @@ >> >> template class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> + ?static FunctionType *get(LLVMContext &Context) { >> ? ? return FunctionType::get(TypeBuilder::get(Context), false); >> ? } >> }; >> template class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(1); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? return FunctionType::get(TypeBuilder::get(Context), >> @@ -264,8 +264,8 @@ >> template >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(2); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -276,8 +276,8 @@ >> template >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(3); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -291,8 +291,8 @@ >> ? ? ? ? ?bool cross> >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(4); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -307,8 +307,8 @@ >> ? ? ? ? ?typename A5, bool cross> >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(5); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -322,15 +322,15 @@ >> >> template class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> + ?static FunctionType *get(LLVMContext &Context) { >> ? ? return FunctionType::get(TypeBuilder::get(Context), true); >> ? } >> }; >> template >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(1); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? return FunctionType::get(TypeBuilder::get(Context), params, true); >> @@ -339,8 +339,8 @@ >> template >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(2); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -351,8 +351,8 @@ >> template >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(3); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -366,8 +366,8 @@ >> ? ? ? ? ?bool cross> >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(4); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> @@ -382,8 +382,8 @@ >> ? ? ? ? ?typename A5, bool cross> >> class TypeBuilder { >> public: >> - ?static const FunctionType *get(LLVMContext &Context) { >> - ? ?std::vector params; >> + ?static FunctionType *get(LLVMContext &Context) { >> + ? ?std::vector params; >> ? ? params.reserve(5); >> ? ? params.push_back(TypeBuilder::get(Context)); >> ? ? params.push_back(TypeBuilder::get(Context)); >> >> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) >> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 02:56:41 2011 >> @@ -1442,7 +1442,7 @@ >> ? ? ? ? ? ? ? ? ? ?"argument attributes invalid in function type"); >> ? } >> >> - ?SmallVector ArgListTy; >> + ?SmallVector ArgListTy; >> ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >> ? ? ArgListTy.push_back(ArgList[i].Ty); >> >> @@ -2655,7 +2655,7 @@ >> >> ? // Okay, if we got here, the function is syntactically valid. ?Convert types >> ? // and do semantic checks. >> - ?std::vector ParamTypeList; >> + ?std::vector ParamTypeList; >> ? SmallVector Attrs; >> >> ? if (RetAttrs != Attribute::None) >> @@ -3171,7 +3171,7 @@ >> ? if (!(PFTy = dyn_cast(RetType)) || >> ? ? ? !(Ty = dyn_cast(PFTy->getElementType()))) { >> ? ? // Pull out the types of all of the arguments... >> - ? ?std::vector ParamTypes; >> + ? ?std::vector ParamTypes; >> ? ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >> ? ? ? ParamTypes.push_back(ArgList[i].V->getType()); >> >> @@ -3508,7 +3508,7 @@ >> ? if (!(PFTy = dyn_cast(RetType)) || >> ? ? ? !(Ty = dyn_cast(PFTy->getElementType()))) { >> ? ? // Pull out the types of all of the arguments... >> - ? ?std::vector ParamTypes; >> + ? ?std::vector ParamTypes; >> ? ? for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >> ? ? ? ParamTypes.push_back(ArgList[i].V->getType()); >> >> >> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) >> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 02:56:41 2011 >> @@ -582,7 +582,7 @@ >> ? ? ? // FUNCTION: [vararg, attrid, retty, paramty x N] >> ? ? ? if (Record.size() < 3) >> ? ? ? ? return Error("Invalid FUNCTION type record"); >> - ? ? ?std::vector ArgTys; >> + ? ? ?std::vector ArgTys; >> ? ? ? for (unsigned i = 3, e = Record.size(); i != e; ++i) { >> ? ? ? ? if (Type *T = getTypeByID(Record[i])) >> ? ? ? ? ? ArgTys.push_back(T); >> @@ -838,7 +838,7 @@ >> ? ? ? // FUNCTION: [vararg, attrid, retty, paramty x N] >> ? ? ? if (Record.size() < 3) >> ? ? ? ? return Error("Invalid FUNCTION type record"); >> - ? ? ?std::vector ArgTys; >> + ? ? ?std::vector ArgTys; >> ? ? ? for (unsigned i = 3, e = Record.size(); i != e; ++i) { >> ? ? ? ? if (Type *Elt = getTypeByIDOrNull(Record[i])) >> ? ? ? ? ? ArgTys.push_back(Elt); >> >> Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) >> +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 02:56:41 2011 >> @@ -497,10 +497,8 @@ >> ? // Find the rewind function if we didn't already. >> ? if (!RewindFunction) { >> ? ? LLVMContext &Ctx = ResumeInsts[0]->getContext(); >> - ? ?std::vector >> - ? ? ?Params(1, Type::getInt8PtrTy(Ctx)); >> ? ? FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Params, false); >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt8PtrTy(Ctx), false); >> ? ? const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); >> ? ? RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); >> ? } >> >> Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) >> +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 02:56:41 2011 >> @@ -29,7 +29,7 @@ >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArgIt ArgBegin, ArgIt ArgEnd, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const Type *RetTy) { >> ? // Insert a correctly-typed definition now. >> - ?std::vector ParamTys; >> + ?std::vector ParamTys; >> ? for (ArgIt I = ArgBegin; I != ArgEnd; ++I) >> ? ? ParamTys.push_back(I->getType()); >> ? M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); >> @@ -69,7 +69,7 @@ >> ? // program already contains a function with this name. >> ? Module *M = CI->getParent()->getParent()->getParent(); >> ? // Get or insert the definition now. >> - ?std::vector ParamTys; >> + ?std::vector ParamTys; >> ? for (ArgIt I = ArgBegin; I != ArgEnd; ++I) >> ? ? ParamTys.push_back((*I)->getType()); >> ? Constant* FCache = M->getOrInsertFunction(NewFn, >> @@ -553,12 +553,12 @@ >> ? ? ? !CI->getType()->isIntegerTy()) >> ? ? return false; >> >> - ?const IntegerType *Ty = dyn_cast(CI->getType()); >> + ?IntegerType *Ty = dyn_cast(CI->getType()); >> ? if (!Ty) >> ? ? return false; >> >> ? // Okay, we can do this xform, do so now. >> - ?const Type *Tys[] = { Ty }; >> + ?Type *Tys[] = { Ty }; >> ? Module *M = CI->getParent()->getParent()->getParent(); >> ? Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); >> >> >> Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) >> +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 >> @@ -83,7 +83,7 @@ >> >> static const FunctionType *getType(LLVMContext &Context, unsigned id) { >> ? const Type *ResultTy = NULL; >> - ?std::vector ArgTys; >> + ?std::vector ArgTys; >> ? bool IsVarArg = false; >> >> #define GET_INTRINSIC_GENERATOR >> >> Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) >> +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 >> @@ -92,7 +92,7 @@ >> >> static const FunctionType *getType(LLVMContext &Context, unsigned id) { >> ? const Type *ResultTy = NULL; >> - ?std::vector ArgTys; >> + ?std::vector ArgTys; >> ? bool IsVarArg = false; >> >> #define GET_INTRINSIC_GENERATOR >> >> Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) >> +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 02:56:41 2011 >> @@ -493,7 +493,7 @@ >> ? // Start by computing a new prototype for the function, which is the same as >> ? // the old function, but has modified arguments. >> ? const FunctionType *FTy = F->getFunctionType(); >> - ?std::vector Params; >> + ?std::vector Params; >> >> ? typedef std::set ScalarizeTable; >> >> >> Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) >> +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 02:56:41 2011 >> @@ -208,7 +208,7 @@ >> ? // the old function, but doesn't have isVarArg set. >> ? const FunctionType *FTy = Fn.getFunctionType(); >> >> - ?std::vector Params(FTy->param_begin(), FTy->param_end()); >> + ?std::vector Params(FTy->param_begin(), FTy->param_end()); >> ? FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Params, false); >> ? unsigned NumArgs = Params.size(); >> @@ -647,7 +647,7 @@ >> ? // Start by computing a new prototype for the function, which is the same as >> ? // the old function, but has fewer arguments and a different return type. >> ? const FunctionType *FTy = F->getFunctionType(); >> - ?std::vector Params; >> + ?std::vector Params; >> >> ? // Set up to build a new list of parameter attributes. >> ? SmallVector AttributesVec; >> >> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 02:56:41 2011 >> @@ -1400,7 +1400,7 @@ >> /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. >> /// If so, insert the new bswap intrinsic and return it. >> Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { >> - ?const IntegerType *ITy = dyn_cast(I.getType()); >> + ?IntegerType *ITy = dyn_cast(I.getType()); >> ? if (!ITy || ITy->getBitWidth() % 16 || >> ? ? ? // ByteMask only allows up to 32-byte values. >> ? ? ? ITy->getBitWidth() > 32*8) >> @@ -1424,7 +1424,7 @@ >> ? for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) >> ? ? if (ByteValues[i] != V) >> ? ? ? return 0; >> - ?const Type *Tys[] = { ITy }; >> + ?Type *Tys[] = { ITy }; >> ? Module *M = I.getParent()->getParent()->getParent(); >> ? Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); >> ? return CallInst::Create(F, V); >> >> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 02:56:41 2011 >> @@ -217,9 +217,9 @@ >> ? ? ? ? if (GVSrc->isConstant()) { >> ? ? ? ? ? Module *M = CI.getParent()->getParent()->getParent(); >> ? ? ? ? ? Intrinsic::ID MemCpyID = Intrinsic::memcpy; >> - ? ? ? ? ?const Type *Tys[3] = { CI.getArgOperand(0)->getType(), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(1)->getType(), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(2)->getType() }; >> + ? ? ? ? ?Type *Tys[3] = { CI.getArgOperand(0)->getType(), >> + ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(1)->getType(), >> + ? ? ? ? ? ? ? ? ? ? ? ? ? CI.getArgOperand(2)->getType() }; >> ? ? ? ? ? CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); >> ? ? ? ? ? Changed = true; >> ? ? ? ? } >> @@ -1187,7 +1187,7 @@ >> ? const AttrListPtr &NestAttrs = NestF->getAttributes(); >> ? if (!NestAttrs.isEmpty()) { >> ? ? unsigned NestIdx = 1; >> - ? ?const Type *NestTy = 0; >> + ? ?Type *NestTy = 0; >> ? ? Attributes NestAttr = Attribute::None; >> >> ? ? // Look for a parameter marked with the 'nest' attribute. >> @@ -1249,7 +1249,7 @@ >> ? ? ? // Handle this by synthesizing a new function type, equal to FTy >> ? ? ? // with the chain parameter inserted. >> >> - ? ? ?std::vector NewTypes; >> + ? ? ?std::vector NewTypes; >> ? ? ? NewTypes.reserve(FTy->getNumParams()+1); >> >> ? ? ? // Insert the chain's type into the list of parameter types, which may >> >> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) >> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 02:56:41 2011 >> @@ -1683,7 +1683,7 @@ >> ? // result and the overflow bit. >> ? Module *M = I.getParent()->getParent()->getParent(); >> >> - ?const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); >> + ?Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); >> ? Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?&NewType, 1); >> >> @@ -1725,7 +1725,7 @@ >> ? Builder->SetInsertPoint(OrigAdd); >> >> ? Module *M = I.getParent()->getParent()->getParent(); >> - ?const Type *Ty = LHS->getType(); >> + ?Type *Ty = LHS->getType(); >> ? Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); >> ? CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); >> ? Value *Add = Builder->CreateExtractValue(Call, 0); >> >> Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) >> +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 02:56:41 2011 >> @@ -572,14 +572,13 @@ >> } >> >> Constant *GCOVProfiler::getStartFileFunc() { >> - ?const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; >> ? const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Args, false); >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Type::getInt8PtrTy(*Ctx), false); >> ? return M->getOrInsertFunction("llvm_gcda_start_file", FTy); >> } >> >> Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { >> - ?const Type *Args[] = { >> + ?Type *Args[] = { >> ? ? Type::getInt32PtrTy(*Ctx), ? ? ? ? ? ? ? ? ?// uint32_t *predecessor >> ? ? Type::getInt64PtrTy(*Ctx)->getPointerTo(), ?// uint64_t **state_table_row >> ? }; >> @@ -589,7 +588,7 @@ >> } >> >> Constant *GCOVProfiler::getEmitFunctionFunc() { >> - ?const Type *Args[2] = { >> + ?Type *Args[2] = { >> ? ? Type::getInt32Ty(*Ctx), ? ?// uint32_t ident >> ? ? Type::getInt8PtrTy(*Ctx), ?// const char *function_name >> ? }; >> @@ -599,7 +598,7 @@ >> } >> >> Constant *GCOVProfiler::getEmitArcsFunc() { >> - ?const Type *Args[] = { >> + ?Type *Args[] = { >> ? ? Type::getInt32Ty(*Ctx), ? ? // uint32_t num_counters >> ? ? Type::getInt64PtrTy(*Ctx), ?// uint64_t *counters >> ? }; >> >> Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 02:56:41 2011 >> @@ -840,9 +840,9 @@ >> >> ? // If not, then we know we can transform this. >> ? Module *Mod = M->getParent()->getParent()->getParent(); >> - ?const Type *ArgTys[3] = { M->getRawDest()->getType(), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getRawSource()->getType(), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; >> + ?Type *ArgTys[3] = { M->getRawDest()->getType(), >> + ? ? ? ? ? ? ? ? ? ? ?M->getRawSource()->getType(), >> + ? ? ? ? ? ? ? ? ? ? ?M->getLength()->getType() }; >> ? M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArgTys, 3)); >> >> >> Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 02:56:41 2011 >> @@ -1498,8 +1498,8 @@ >> Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { >> ? if (!RetainRVCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> - ? ?std::vector Params; >> + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> + ? ?std::vector Params; >> ? ? Params.push_back(I8X); >> ? ? const FunctionType *FTy = >> ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); >> @@ -1515,8 +1515,8 @@ >> Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { >> ? if (!AutoreleaseRVCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> - ? ?std::vector Params; >> + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> + ? ?std::vector Params; >> ? ? Params.push_back(I8X); >> ? ? const FunctionType *FTy = >> ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); >> @@ -1532,7 +1532,7 @@ >> Constant *ObjCARCOpt::getReleaseCallee(Module *M) { >> ? if (!ReleaseCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?std::vector Params; >> + ? ?std::vector Params; >> ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >> ? ? AttrListPtr Attributes; >> ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); >> @@ -1548,7 +1548,7 @@ >> Constant *ObjCARCOpt::getRetainCallee(Module *M) { >> ? if (!RetainCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?std::vector Params; >> + ? ?std::vector Params; >> ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >> ? ? AttrListPtr Attributes; >> ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); >> @@ -1564,7 +1564,7 @@ >> Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { >> ? if (!AutoreleaseCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?std::vector Params; >> + ? ?std::vector Params; >> ? ? Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >> ? ? AttrListPtr Attributes; >> ? ? Attributes.addAttr(~0u, Attribute::NoUnwind); >> @@ -3269,9 +3269,9 @@ >> Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { >> ? if (!StoreStrongCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> - ? ?const Type *I8XX = PointerType::getUnqual(I8X); >> - ? ?std::vector Params; >> + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> + ? ?Type *I8XX = PointerType::getUnqual(I8X); >> + ? ?std::vector Params; >> ? ? Params.push_back(I8XX); >> ? ? Params.push_back(I8X); >> >> @@ -3291,8 +3291,8 @@ >> Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { >> ? if (!RetainAutoreleaseCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> - ? ?std::vector Params; >> + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> + ? ?std::vector Params; >> ? ? Params.push_back(I8X); >> ? ? const FunctionType *FTy = >> ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); >> @@ -3307,8 +3307,8 @@ >> Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { >> ? if (!RetainAutoreleaseRVCallee) { >> ? ? LLVMContext &C = M->getContext(); >> - ? ?const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> - ? ?std::vector Params; >> + ? ?Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >> + ? ?std::vector Params; >> ? ? Params.push_back(I8X); >> ? ? const FunctionType *FTy = >> ? ? ? FunctionType::get(I8X, Params, /*isVarArg=*/false); >> >> Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) >> +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 02:56:41 2011 >> @@ -992,7 +992,7 @@ >> ? ? } >> >> ? ? // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 >> - ? ?const Type *ArgType = Op->getType(); >> + ? ?Type *ArgType = Op->getType(); >> ? ? Value *F = Intrinsic::getDeclaration(Callee->getParent(), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::cttz, &ArgType, 1); >> ? ? Value *V = B.CreateCall(F, Op, "cttz"); >> >> Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 02:56:41 2011 >> @@ -140,7 +140,7 @@ >> Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool ModuleLevelChanges, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ClonedCodeInfo *CodeInfo) { >> - ?std::vector ArgTypes; >> + ?std::vector ArgTypes; >> >> ? // The user might be deleting arguments to the function by specifying them in >> ? // the VMap. ?If so, we need to not add the arguments to the arg ty vector >> >> Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 02:56:41 2011 >> @@ -258,7 +258,7 @@ >> ? default: RetTy = Type::getInt16Ty(header->getContext()); break; >> ? } >> >> - ?std::vector paramTy; >> + ?std::vector paramTy; >> >> ? // Add the types of the input values to the function's argument list >> ? for (Values::const_iterator i = inputs.begin(), >> @@ -279,7 +279,7 @@ >> ? } >> >> ? DEBUG(dbgs() << "Function type: " << *RetTy << " f("); >> - ?for (std::vector::iterator i = paramTy.begin(), >> + ?for (std::vector::iterator i = paramTy.begin(), >> ? ? ? ? ?e = paramTy.end(); i != e; ++i) >> ? ? DEBUG(dbgs() << **i << ", "); >> ? DEBUG(dbgs() << ")\n"); >> >> Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) >> +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 02:56:41 2011 >> @@ -663,7 +663,7 @@ >> >> ? LLVMContext &Context = Arg->getContext(); >> >> - ?const Type *VoidPtrTy = Type::getInt8PtrTy(Context); >> + ?Type *VoidPtrTy = Type::getInt8PtrTy(Context); >> >> ? // Create the alloca. ?If we have TargetData, use nice alignment. >> ? unsigned Align = 1; >> @@ -680,7 +680,7 @@ >> ? Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? &*Caller->begin()->begin()); >> ? // Emit a memcpy. >> - ?const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; >> + ?Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; >> ? Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Intrinsic::memcpy, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Tys, 3); >> >> Modified: llvm/trunk/lib/VMCore/Core.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Core.cpp (original) >> +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 02:56:41 2011 >> @@ -260,7 +260,7 @@ >> LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?LLVMTypeRef *ParamTypes, unsigned ParamCount, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?LLVMBool IsVarArg) { >> - ?std::vector Tys; >> + ?std::vector Tys; >> ? for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) >> ? ? Tys.push_back(unwrap(*I)); >> >> >> Modified: llvm/trunk/lib/VMCore/Function.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Function.cpp (original) >> +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 02:56:41 2011 >> @@ -333,7 +333,7 @@ >> ? return 0; >> } >> >> -std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { >> +std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { >> ? assert(id < num_intrinsics && "Invalid intrinsic ID!"); >> ? static const char * const Table[] = { >> ? ? "not_intrinsic", >> @@ -356,10 +356,10 @@ >> } >> >> const FunctionType *Intrinsic::getType(LLVMContext &Context, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ID id, const Type **Tys, >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ID id, Type **Tys, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned numTys) { >> ? const Type *ResultTy = NULL; >> - ?std::vector ArgTys; >> + ?std::vector ArgTys; >> ? bool IsVarArg = false; >> >> #define GET_INTRINSIC_GENERATOR >> @@ -384,7 +384,7 @@ >> #include "llvm/Intrinsics.gen" >> #undef GET_INTRINSIC_ATTRIBUTES >> >> -Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, >> +Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned numTys) { >> ? // There can never be multiple globals with the same name of different types, >> ? // because intrinsics must be a specific type. >> >> Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) >> +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 02:56:41 2011 >> @@ -65,7 +65,7 @@ >> ? ? ? ? ? ? ?bool isVolatile, MDNode *TBAATag) { >> ? Ptr = getCastedInt8PtrValue(Ptr); >> ? Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; >> - ?const Type *Tys[] = { Ptr->getType(), Size->getType() }; >> + ?Type *Tys[] = { Ptr->getType(), Size->getType() }; >> ? Module *M = BB->getParent()->getParent(); >> ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); >> >> @@ -85,7 +85,7 @@ >> ? Src = getCastedInt8PtrValue(Src); >> >> ? Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; >> - ?const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >> + ?Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >> ? Module *M = BB->getParent()->getParent(); >> ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); >> >> @@ -105,7 +105,7 @@ >> ? Src = getCastedInt8PtrValue(Src); >> >> ? Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; >> - ?const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >> + ?Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >> ? Module *M = BB->getParent()->getParent(); >> ? Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); >> >> >> Modified: llvm/trunk/lib/VMCore/Module.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Module.cpp (original) >> +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 02:56:41 2011 >> @@ -216,8 +216,8 @@ >> ? va_start(Args, RetTy); >> >> ? // Build the list of argument types... >> - ?std::vector ArgTys; >> - ?while (const Type *ArgTy = va_arg(Args, const Type*)) >> + ?std::vector ArgTys; >> + ?while (Type *ArgTy = va_arg(Args, Type*)) >> ? ? ArgTys.push_back(ArgTy); >> >> ? va_end(Args); >> @@ -234,8 +234,8 @@ >> ? va_start(Args, RetTy); >> >> ? // Build the list of argument types... >> - ?std::vector ArgTys; >> - ?while (const Type *ArgTy = va_arg(Args, const Type*)) >> + ?std::vector ArgTys; >> + ?while (Type *ArgTy = va_arg(Args, Type*)) >> ? ? ArgTys.push_back(ArgTy); >> >> ? va_end(Args); >> >> Modified: llvm/trunk/lib/VMCore/Type.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/lib/VMCore/Type.cpp (original) >> +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 02:56:41 2011 >> @@ -325,13 +325,6 @@ >> ? NumContainedTys = Params.size() + 1; // + 1 for result type >> } >> >> -// FIXME: Remove this version. >> -FunctionType *FunctionType::get(const Type *ReturnType, >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?ArrayRef Params, bool isVarArg) { >> - ?return get(ReturnType, ArrayRef(const_cast(Params.data()), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Params.size()), isVarArg); >> -} >> - >> // FunctionType::get - The factory function for the FunctionType class. >> FunctionType *FunctionType::get(const Type *ReturnType, >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ArrayRef Params, bool isVarArg) { >> @@ -357,7 +350,7 @@ >> >> >> FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { >> - ?return get(Result, ArrayRef(), isVarArg); >> + ?return get(Result, ArrayRef(), isVarArg); >> } >> >> >> >> Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) >> +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 02:56:41 2011 >> @@ -23,7 +23,7 @@ >> ? Module M("world", Context); >> >> ? const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), >> - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::vector(), false); >> + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?std::vector(), false); >> ? Function *F = cast(M.getOrInsertFunction("f", FTy)); >> ? BasicBlock *BB = BasicBlock::Create(Context, "entry", F); >> ? ReturnInst::Create(Context, 0, BB); >> >> Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) >> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 02:56:41 2011 >> @@ -21,7 +21,7 @@ >> namespace { >> >> Function *makeFakeFunction() { >> - ?std::vector params; >> + ?std::vector params; >> ? const FunctionType *FTy = >> ? ? ? FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); >> ? return Function::Create(FTy, GlobalValue::ExternalLinkage); >> >> Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) >> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 02:56:41 2011 >> @@ -37,7 +37,7 @@ >> namespace { >> >> Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { >> - ?std::vector params; >> + ?std::vector params; >> ? const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), >> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? params, false); >> ? Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); >> @@ -322,7 +322,7 @@ >> >> ? const FunctionType *Func1Ty = >> ? ? ? cast(TypeBuilder::get(Context)); >> - ?std::vector arg_types; >> + ?std::vector arg_types; >> ? arg_types.push_back(Type::getInt1Ty(Context)); >> ? const FunctionType *FuncTy = FunctionType::get( >> ? ? ? Type::getVoidTy(Context), arg_types, false); >> >> Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) >> +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 02:56:41 2011 >> @@ -120,7 +120,7 @@ >> } >> >> TEST(TypeBuilderTest, Functions) { >> - ?std::vector params; >> + ?std::vector params; >> ? EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), >> ? ? ? ? ? ? (TypeBuilder::get(getGlobalContext()))); >> ? EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), >> >> Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >> ============================================================================== >> --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) >> +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 02:56:41 2011 >> @@ -405,13 +405,13 @@ >> ? ? ? mod->setTargetTriple("x86_64-unknown-linux-gnu"); >> >> ? ? ? // Type Definitions >> - ? ? ?std::vectorFuncTy_0_args; >> + ? ? ?std::vectorFuncTy_0_args; >> ? ? ? FunctionType* FuncTy_0 = FunctionType::get( >> ? ? ? ? /*Result=*/IntegerType::get(getGlobalContext(), 32), >> ? ? ? ? /*Params=*/FuncTy_0_args, >> ? ? ? ? /*isVarArg=*/false); >> >> - ? ? ?std::vectorFuncTy_2_args; >> + ? ? ?std::vectorFuncTy_2_args; >> ? ? ? FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); >> ? ? ? FunctionType* FuncTy_2 = FunctionType::get( >> ? ? ? ? /*Result=*/Type::getVoidTy(getGlobalContext()), >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From wendling at apple.com Tue Jul 12 02:17:26 2011 From: wendling at apple.com (Bill Wendling) Date: Tue, 12 Jul 2011 00:17:26 -0700 Subject: [llvm-commits] [llvm] r134888 - in /llvm/trunk: include/llvm/ include/llvm/Support/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Target/Blackfin/ lib/Target/MBlaze/ lib/Transforms/IPO/ lib/Transforms/InstCombine/ lib/Transforms/Instrumenta In-Reply-To: References: Message-ID: <26C97CFE-C4BA-4736-ACB9-2AEB30167EB2@apple.com> No worries. llvm-gcc doesn't get a lot of attention these days. :-) Thanks for looking into it! -bw On Jul 11, 2011, at 11:29 PM, Jay Foad wrote: > Thanks. I'll look into it today. Sorry for the breakage. > > Jay. > > On 12 July 2011 02:18, Bill Wendling wrote: >> Hi Jay, >> >> I had to revert this and your related patches. It was causing llvm-gcc to fail to compile on Darwin (possibly other machines). It was an assert: >> >> Assertion failed: (castIsValid(op, S, Ty) && "Invalid cast!"), function Create, file ... >> >> -bw >> >> On Jul 11, 2011, at 12:56 AM, Jay Foad wrote: >> >>> Author: foad >>> Date: Mon Jul 11 02:56:41 2011 >>> New Revision: 134888 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=134888&view=rev >>> Log: >>> De-constify Types in FunctionType::get(). >>> >>> Modified: >>> llvm/trunk/include/llvm/DerivedTypes.h >>> llvm/trunk/include/llvm/Intrinsics.h >>> llvm/trunk/include/llvm/Support/TypeBuilder.h >>> llvm/trunk/lib/AsmParser/LLParser.cpp >>> llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp >>> llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp >>> llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp >>> llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp >>> llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp >>> llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp >>> llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp >>> llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp >>> llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >>> llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp >>> llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp >>> llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >>> llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp >>> llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >>> llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp >>> llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp >>> llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >>> llvm/trunk/lib/VMCore/Core.cpp >>> llvm/trunk/lib/VMCore/Function.cpp >>> llvm/trunk/lib/VMCore/IRBuilder.cpp >>> llvm/trunk/lib/VMCore/Module.cpp >>> llvm/trunk/lib/VMCore/Type.cpp >>> llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp >>> llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp >>> llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >>> llvm/trunk/unittests/Support/TypeBuilderTest.cpp >>> llvm/trunk/unittests/VMCore/PassManagerTest.cpp >>> >>> Modified: llvm/trunk/include/llvm/DerivedTypes.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/DerivedTypes.h (original) >>> +++ llvm/trunk/include/llvm/DerivedTypes.h Mon Jul 11 02:56:41 2011 >>> @@ -103,8 +103,6 @@ >>> /// a FunctionType. >>> /// >>> static FunctionType *get(const Type *Result, >>> - ArrayRef Params, bool isVarArg); >>> - static FunctionType *get(const Type *Result, >>> ArrayRef Params, bool isVarArg); >>> >>> /// FunctionType::get - Create a FunctionType taking no parameters. >>> >>> Modified: llvm/trunk/include/llvm/Intrinsics.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Intrinsics.h?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Intrinsics.h (original) >>> +++ llvm/trunk/include/llvm/Intrinsics.h Mon Jul 11 02:56:41 2011 >>> @@ -44,12 +44,12 @@ >>> >>> /// Intrinsic::getName(ID) - Return the LLVM name for an intrinsic, such as >>> /// "llvm.ppc.altivec.lvx". >>> - std::string getName(ID id, const Type **Tys = 0, unsigned numTys = 0); >>> + std::string getName(ID id, Type **Tys = 0, unsigned numTys = 0); >>> >>> /// Intrinsic::getType(ID) - Return the function type for an intrinsic. >>> /// >>> const FunctionType *getType(LLVMContext &Context, ID id, >>> - const Type **Tys = 0, unsigned numTys = 0); >>> + Type **Tys = 0, unsigned numTys = 0); >>> >>> /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be >>> /// overloaded. >>> @@ -67,7 +67,7 @@ >>> /// overloaded intrinsic, Tys should point to an array of numTys pointers to >>> /// Type, and must provide exactly one type for each overloaded type in the >>> /// intrinsic. >>> - Function *getDeclaration(Module *M, ID id, const Type **Tys = 0, >>> + Function *getDeclaration(Module *M, ID id, Type **Tys = 0, >>> unsigned numTys = 0); >>> >>> /// Map a GCC builtin name to an intrinsic ID. >>> >>> Modified: llvm/trunk/include/llvm/Support/TypeBuilder.h >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/TypeBuilder.h?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/include/llvm/Support/TypeBuilder.h (original) >>> +++ llvm/trunk/include/llvm/Support/TypeBuilder.h Mon Jul 11 02:56:41 2011 >>> @@ -51,7 +51,7 @@ >>> /// namespace llvm { >>> /// template class TypeBuilder { >>> /// public: >>> -/// static const StructType *get(LLVMContext &Context) { >>> +/// static StructType *get(LLVMContext &Context) { >>> /// // If you cache this result, be sure to cache it separately >>> /// // for each LLVMContext. >>> /// return StructType::get( >>> @@ -104,7 +104,7 @@ >>> // Pointers >>> template class TypeBuilder { >>> public: >>> - static const PointerType *get(LLVMContext &Context) { >>> + static PointerType *get(LLVMContext &Context) { >>> return PointerType::getUnqual(TypeBuilder::get(Context)); >>> } >>> }; >>> @@ -115,14 +115,14 @@ >>> // Arrays >>> template class TypeBuilder { >>> public: >>> - static const ArrayType *get(LLVMContext &Context) { >>> + static ArrayType *get(LLVMContext &Context) { >>> return ArrayType::get(TypeBuilder::get(Context), N); >>> } >>> }; >>> /// LLVM uses an array of length 0 to represent an unknown-length array. >>> template class TypeBuilder { >>> public: >>> - static const ArrayType *get(LLVMContext &Context) { >>> + static ArrayType *get(LLVMContext &Context) { >>> return ArrayType::get(TypeBuilder::get(Context), 0); >>> } >>> }; >>> @@ -152,7 +152,7 @@ >>> #define DEFINE_INTEGRAL_TYPEBUILDER(T) \ >>> template<> class TypeBuilder { \ >>> public: \ >>> - static const IntegerType *get(LLVMContext &Context) { \ >>> + static IntegerType *get(LLVMContext &Context) { \ >>> return IntegerType::get(Context, sizeof(T) * CHAR_BIT); \ >>> } \ >>> }; \ >>> @@ -181,14 +181,14 @@ >>> template >>> class TypeBuilder, cross> { >>> public: >>> - static const IntegerType *get(LLVMContext &C) { >>> + static IntegerType *get(LLVMContext &C) { >>> return IntegerType::get(C, num_bits); >>> } >>> }; >>> >>> template<> class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { >>> + static Type *get(LLVMContext& C) { >>> return Type::getFloatTy(C); >>> } >>> }; >>> @@ -196,7 +196,7 @@ >>> >>> template<> class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { >>> + static Type *get(LLVMContext& C) { >>> return Type::getDoubleTy(C); >>> } >>> }; >>> @@ -204,32 +204,32 @@ >>> >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getFloatTy(C); } >>> + static Type *get(LLVMContext& C) { return Type::getFloatTy(C); } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } >>> + static Type *get(LLVMContext& C) { return Type::getDoubleTy(C); } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } >>> + static Type *get(LLVMContext& C) { return Type::getX86_FP80Ty(C); } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } >>> + static Type *get(LLVMContext& C) { return Type::getFP128Ty(C); } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } >>> + static Type *get(LLVMContext& C) { return Type::getPPC_FP128Ty(C); } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } >>> + static Type *get(LLVMContext& C) { return Type::getX86_MMXTy(C); } >>> }; >>> >>> template class TypeBuilder { >>> public: >>> - static const Type *get(LLVMContext &C) { >>> + static Type *get(LLVMContext &C) { >>> return Type::getVoidTy(C); >>> } >>> }; >>> @@ -247,14 +247,14 @@ >>> >>> template class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> + static FunctionType *get(LLVMContext &Context) { >>> return FunctionType::get(TypeBuilder::get(Context), false); >>> } >>> }; >>> template class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(1); >>> params.push_back(TypeBuilder::get(Context)); >>> return FunctionType::get(TypeBuilder::get(Context), >>> @@ -264,8 +264,8 @@ >>> template >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(2); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -276,8 +276,8 @@ >>> template >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(3); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -291,8 +291,8 @@ >>> bool cross> >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(4); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -307,8 +307,8 @@ >>> typename A5, bool cross> >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(5); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -322,15 +322,15 @@ >>> >>> template class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> + static FunctionType *get(LLVMContext &Context) { >>> return FunctionType::get(TypeBuilder::get(Context), true); >>> } >>> }; >>> template >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(1); >>> params.push_back(TypeBuilder::get(Context)); >>> return FunctionType::get(TypeBuilder::get(Context), params, true); >>> @@ -339,8 +339,8 @@ >>> template >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(2); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -351,8 +351,8 @@ >>> template >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(3); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -366,8 +366,8 @@ >>> bool cross> >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(4); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> @@ -382,8 +382,8 @@ >>> typename A5, bool cross> >>> class TypeBuilder { >>> public: >>> - static const FunctionType *get(LLVMContext &Context) { >>> - std::vector params; >>> + static FunctionType *get(LLVMContext &Context) { >>> + std::vector params; >>> params.reserve(5); >>> params.push_back(TypeBuilder::get(Context)); >>> params.push_back(TypeBuilder::get(Context)); >>> >>> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) >>> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Jul 11 02:56:41 2011 >>> @@ -1442,7 +1442,7 @@ >>> "argument attributes invalid in function type"); >>> } >>> >>> - SmallVector ArgListTy; >>> + SmallVector ArgListTy; >>> for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >>> ArgListTy.push_back(ArgList[i].Ty); >>> >>> @@ -2655,7 +2655,7 @@ >>> >>> // Okay, if we got here, the function is syntactically valid. Convert types >>> // and do semantic checks. >>> - std::vector ParamTypeList; >>> + std::vector ParamTypeList; >>> SmallVector Attrs; >>> >>> if (RetAttrs != Attribute::None) >>> @@ -3171,7 +3171,7 @@ >>> if (!(PFTy = dyn_cast(RetType)) || >>> !(Ty = dyn_cast(PFTy->getElementType()))) { >>> // Pull out the types of all of the arguments... >>> - std::vector ParamTypes; >>> + std::vector ParamTypes; >>> for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >>> ParamTypes.push_back(ArgList[i].V->getType()); >>> >>> @@ -3508,7 +3508,7 @@ >>> if (!(PFTy = dyn_cast(RetType)) || >>> !(Ty = dyn_cast(PFTy->getElementType()))) { >>> // Pull out the types of all of the arguments... >>> - std::vector ParamTypes; >>> + std::vector ParamTypes; >>> for (unsigned i = 0, e = ArgList.size(); i != e; ++i) >>> ParamTypes.push_back(ArgList[i].V->getType()); >>> >>> >>> Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) >>> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 11 02:56:41 2011 >>> @@ -582,7 +582,7 @@ >>> // FUNCTION: [vararg, attrid, retty, paramty x N] >>> if (Record.size() < 3) >>> return Error("Invalid FUNCTION type record"); >>> - std::vector ArgTys; >>> + std::vector ArgTys; >>> for (unsigned i = 3, e = Record.size(); i != e; ++i) { >>> if (Type *T = getTypeByID(Record[i])) >>> ArgTys.push_back(T); >>> @@ -838,7 +838,7 @@ >>> // FUNCTION: [vararg, attrid, retty, paramty x N] >>> if (Record.size() < 3) >>> return Error("Invalid FUNCTION type record"); >>> - std::vector ArgTys; >>> + std::vector ArgTys; >>> for (unsigned i = 3, e = Record.size(); i != e; ++i) { >>> if (Type *Elt = getTypeByIDOrNull(Record[i])) >>> ArgTys.push_back(Elt); >>> >>> Modified: llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/DwarfEHPrepare.cpp Mon Jul 11 02:56:41 2011 >>> @@ -497,10 +497,8 @@ >>> // Find the rewind function if we didn't already. >>> if (!RewindFunction) { >>> LLVMContext &Ctx = ResumeInsts[0]->getContext(); >>> - std::vector >>> - Params(1, Type::getInt8PtrTy(Ctx)); >>> FunctionType *FTy = FunctionType::get(Type::getVoidTy(Ctx), >>> - Params, false); >>> + Type::getInt8PtrTy(Ctx), false); >>> const char *RewindName = TLI->getLibcallName(RTLIB::UNWIND_RESUME); >>> RewindFunction = F->getParent()->getOrInsertFunction(RewindName, FTy); >>> } >>> >>> Modified: llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp (original) >>> +++ llvm/trunk/lib/CodeGen/IntrinsicLowering.cpp Mon Jul 11 02:56:41 2011 >>> @@ -29,7 +29,7 @@ >>> ArgIt ArgBegin, ArgIt ArgEnd, >>> const Type *RetTy) { >>> // Insert a correctly-typed definition now. >>> - std::vector ParamTys; >>> + std::vector ParamTys; >>> for (ArgIt I = ArgBegin; I != ArgEnd; ++I) >>> ParamTys.push_back(I->getType()); >>> M.getOrInsertFunction(Name, FunctionType::get(RetTy, ParamTys, false)); >>> @@ -69,7 +69,7 @@ >>> // program already contains a function with this name. >>> Module *M = CI->getParent()->getParent()->getParent(); >>> // Get or insert the definition now. >>> - std::vector ParamTys; >>> + std::vector ParamTys; >>> for (ArgIt I = ArgBegin; I != ArgEnd; ++I) >>> ParamTys.push_back((*I)->getType()); >>> Constant* FCache = M->getOrInsertFunction(NewFn, >>> @@ -553,12 +553,12 @@ >>> !CI->getType()->isIntegerTy()) >>> return false; >>> >>> - const IntegerType *Ty = dyn_cast(CI->getType()); >>> + IntegerType *Ty = dyn_cast(CI->getType()); >>> if (!Ty) >>> return false; >>> >>> // Okay, we can do this xform, do so now. >>> - const Type *Tys[] = { Ty }; >>> + Type *Tys[] = { Ty }; >>> Module *M = CI->getParent()->getParent()->getParent(); >>> Constant *Int = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); >>> >>> >>> Modified: llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original) >>> +++ llvm/trunk/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 >>> @@ -83,7 +83,7 @@ >>> >>> static const FunctionType *getType(LLVMContext &Context, unsigned id) { >>> const Type *ResultTy = NULL; >>> - std::vector ArgTys; >>> + std::vector ArgTys; >>> bool IsVarArg = false; >>> >>> #define GET_INTRINSIC_GENERATOR >>> >>> Modified: llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp (original) >>> +++ llvm/trunk/lib/Target/MBlaze/MBlazeIntrinsicInfo.cpp Mon Jul 11 02:56:41 2011 >>> @@ -92,7 +92,7 @@ >>> >>> static const FunctionType *getType(LLVMContext &Context, unsigned id) { >>> const Type *ResultTy = NULL; >>> - std::vector ArgTys; >>> + std::vector ArgTys; >>> bool IsVarArg = false; >>> >>> #define GET_INTRINSIC_GENERATOR >>> >>> Modified: llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp (original) >>> +++ llvm/trunk/lib/Transforms/IPO/ArgumentPromotion.cpp Mon Jul 11 02:56:41 2011 >>> @@ -493,7 +493,7 @@ >>> // Start by computing a new prototype for the function, which is the same as >>> // the old function, but has modified arguments. >>> const FunctionType *FTy = F->getFunctionType(); >>> - std::vector Params; >>> + std::vector Params; >>> >>> typedef std::set ScalarizeTable; >>> >>> >>> Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original) >>> +++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Mon Jul 11 02:56:41 2011 >>> @@ -208,7 +208,7 @@ >>> // the old function, but doesn't have isVarArg set. >>> const FunctionType *FTy = Fn.getFunctionType(); >>> >>> - std::vector Params(FTy->param_begin(), FTy->param_end()); >>> + std::vector Params(FTy->param_begin(), FTy->param_end()); >>> FunctionType *NFTy = FunctionType::get(FTy->getReturnType(), >>> Params, false); >>> unsigned NumArgs = Params.size(); >>> @@ -647,7 +647,7 @@ >>> // Start by computing a new prototype for the function, which is the same as >>> // the old function, but has fewer arguments and a different return type. >>> const FunctionType *FTy = F->getFunctionType(); >>> - std::vector Params; >>> + std::vector Params; >>> >>> // Set up to build a new list of parameter attributes. >>> SmallVector AttributesVec; >>> >>> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original) >>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Jul 11 02:56:41 2011 >>> @@ -1400,7 +1400,7 @@ >>> /// MatchBSwap - Given an OR instruction, check to see if this is a bswap idiom. >>> /// If so, insert the new bswap intrinsic and return it. >>> Instruction *InstCombiner::MatchBSwap(BinaryOperator &I) { >>> - const IntegerType *ITy = dyn_cast(I.getType()); >>> + IntegerType *ITy = dyn_cast(I.getType()); >>> if (!ITy || ITy->getBitWidth() % 16 || >>> // ByteMask only allows up to 32-byte values. >>> ITy->getBitWidth() > 32*8) >>> @@ -1424,7 +1424,7 @@ >>> for (unsigned i = 1, e = ByteValues.size(); i != e; ++i) >>> if (ByteValues[i] != V) >>> return 0; >>> - const Type *Tys[] = { ITy }; >>> + Type *Tys[] = { ITy }; >>> Module *M = I.getParent()->getParent()->getParent(); >>> Function *F = Intrinsic::getDeclaration(M, Intrinsic::bswap, Tys, 1); >>> return CallInst::Create(F, V); >>> >>> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) >>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jul 11 02:56:41 2011 >>> @@ -217,9 +217,9 @@ >>> if (GVSrc->isConstant()) { >>> Module *M = CI.getParent()->getParent()->getParent(); >>> Intrinsic::ID MemCpyID = Intrinsic::memcpy; >>> - const Type *Tys[3] = { CI.getArgOperand(0)->getType(), >>> - CI.getArgOperand(1)->getType(), >>> - CI.getArgOperand(2)->getType() }; >>> + Type *Tys[3] = { CI.getArgOperand(0)->getType(), >>> + CI.getArgOperand(1)->getType(), >>> + CI.getArgOperand(2)->getType() }; >>> CI.setCalledFunction(Intrinsic::getDeclaration(M, MemCpyID, Tys, 3)); >>> Changed = true; >>> } >>> @@ -1187,7 +1187,7 @@ >>> const AttrListPtr &NestAttrs = NestF->getAttributes(); >>> if (!NestAttrs.isEmpty()) { >>> unsigned NestIdx = 1; >>> - const Type *NestTy = 0; >>> + Type *NestTy = 0; >>> Attributes NestAttr = Attribute::None; >>> >>> // Look for a parameter marked with the 'nest' attribute. >>> @@ -1249,7 +1249,7 @@ >>> // Handle this by synthesizing a new function type, equal to FTy >>> // with the chain parameter inserted. >>> >>> - std::vector NewTypes; >>> + std::vector NewTypes; >>> NewTypes.reserve(FTy->getNumParams()+1); >>> >>> // Insert the chain's type into the list of parameter types, which may >>> >>> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp (original) >>> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp Mon Jul 11 02:56:41 2011 >>> @@ -1683,7 +1683,7 @@ >>> // result and the overflow bit. >>> Module *M = I.getParent()->getParent()->getParent(); >>> >>> - const Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); >>> + Type *NewType = IntegerType::get(OrigAdd->getContext(), NewWidth); >>> Value *F = Intrinsic::getDeclaration(M, Intrinsic::sadd_with_overflow, >>> &NewType, 1); >>> >>> @@ -1725,7 +1725,7 @@ >>> Builder->SetInsertPoint(OrigAdd); >>> >>> Module *M = I.getParent()->getParent()->getParent(); >>> - const Type *Ty = LHS->getType(); >>> + Type *Ty = LHS->getType(); >>> Value *F = Intrinsic::getDeclaration(M, Intrinsic::uadd_with_overflow, &Ty,1); >>> CallInst *Call = Builder->CreateCall2(F, LHS, RHS, "uadd"); >>> Value *Add = Builder->CreateExtractValue(Call, 0); >>> >>> Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Jul 11 02:56:41 2011 >>> @@ -572,14 +572,13 @@ >>> } >>> >>> Constant *GCOVProfiler::getStartFileFunc() { >>> - const Type *Args[] = { Type::getInt8PtrTy(*Ctx) }; >>> const FunctionType *FTy = FunctionType::get(Type::getVoidTy(*Ctx), >>> - Args, false); >>> + Type::getInt8PtrTy(*Ctx), false); >>> return M->getOrInsertFunction("llvm_gcda_start_file", FTy); >>> } >>> >>> Constant *GCOVProfiler::getIncrementIndirectCounterFunc() { >>> - const Type *Args[] = { >>> + Type *Args[] = { >>> Type::getInt32PtrTy(*Ctx), // uint32_t *predecessor >>> Type::getInt64PtrTy(*Ctx)->getPointerTo(), // uint64_t **state_table_row >>> }; >>> @@ -589,7 +588,7 @@ >>> } >>> >>> Constant *GCOVProfiler::getEmitFunctionFunc() { >>> - const Type *Args[2] = { >>> + Type *Args[2] = { >>> Type::getInt32Ty(*Ctx), // uint32_t ident >>> Type::getInt8PtrTy(*Ctx), // const char *function_name >>> }; >>> @@ -599,7 +598,7 @@ >>> } >>> >>> Constant *GCOVProfiler::getEmitArcsFunc() { >>> - const Type *Args[] = { >>> + Type *Args[] = { >>> Type::getInt32Ty(*Ctx), // uint32_t num_counters >>> Type::getInt64PtrTy(*Ctx), // uint64_t *counters >>> }; >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/MemCpyOptimizer.cpp Mon Jul 11 02:56:41 2011 >>> @@ -840,9 +840,9 @@ >>> >>> // If not, then we know we can transform this. >>> Module *Mod = M->getParent()->getParent()->getParent(); >>> - const Type *ArgTys[3] = { M->getRawDest()->getType(), >>> - M->getRawSource()->getType(), >>> - M->getLength()->getType() }; >>> + Type *ArgTys[3] = { M->getRawDest()->getType(), >>> + M->getRawSource()->getType(), >>> + M->getLength()->getType() }; >>> M->setCalledFunction(Intrinsic::getDeclaration(Mod, Intrinsic::memcpy, >>> ArgTys, 3)); >>> >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/ObjCARC.cpp Mon Jul 11 02:56:41 2011 >>> @@ -1498,8 +1498,8 @@ >>> Constant *ObjCARCOpt::getRetainRVCallee(Module *M) { >>> if (!RetainRVCallee) { >>> LLVMContext &C = M->getContext(); >>> - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> - std::vector Params; >>> + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> + std::vector Params; >>> Params.push_back(I8X); >>> const FunctionType *FTy = >>> FunctionType::get(I8X, Params, /*isVarArg=*/false); >>> @@ -1515,8 +1515,8 @@ >>> Constant *ObjCARCOpt::getAutoreleaseRVCallee(Module *M) { >>> if (!AutoreleaseRVCallee) { >>> LLVMContext &C = M->getContext(); >>> - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> - std::vector Params; >>> + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> + std::vector Params; >>> Params.push_back(I8X); >>> const FunctionType *FTy = >>> FunctionType::get(I8X, Params, /*isVarArg=*/false); >>> @@ -1532,7 +1532,7 @@ >>> Constant *ObjCARCOpt::getReleaseCallee(Module *M) { >>> if (!ReleaseCallee) { >>> LLVMContext &C = M->getContext(); >>> - std::vector Params; >>> + std::vector Params; >>> Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >>> AttrListPtr Attributes; >>> Attributes.addAttr(~0u, Attribute::NoUnwind); >>> @@ -1548,7 +1548,7 @@ >>> Constant *ObjCARCOpt::getRetainCallee(Module *M) { >>> if (!RetainCallee) { >>> LLVMContext &C = M->getContext(); >>> - std::vector Params; >>> + std::vector Params; >>> Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >>> AttrListPtr Attributes; >>> Attributes.addAttr(~0u, Attribute::NoUnwind); >>> @@ -1564,7 +1564,7 @@ >>> Constant *ObjCARCOpt::getAutoreleaseCallee(Module *M) { >>> if (!AutoreleaseCallee) { >>> LLVMContext &C = M->getContext(); >>> - std::vector Params; >>> + std::vector Params; >>> Params.push_back(PointerType::getUnqual(Type::getInt8Ty(C))); >>> AttrListPtr Attributes; >>> Attributes.addAttr(~0u, Attribute::NoUnwind); >>> @@ -3269,9 +3269,9 @@ >>> Constant *ObjCARCContract::getStoreStrongCallee(Module *M) { >>> if (!StoreStrongCallee) { >>> LLVMContext &C = M->getContext(); >>> - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> - const Type *I8XX = PointerType::getUnqual(I8X); >>> - std::vector Params; >>> + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> + Type *I8XX = PointerType::getUnqual(I8X); >>> + std::vector Params; >>> Params.push_back(I8XX); >>> Params.push_back(I8X); >>> >>> @@ -3291,8 +3291,8 @@ >>> Constant *ObjCARCContract::getRetainAutoreleaseCallee(Module *M) { >>> if (!RetainAutoreleaseCallee) { >>> LLVMContext &C = M->getContext(); >>> - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> - std::vector Params; >>> + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> + std::vector Params; >>> Params.push_back(I8X); >>> const FunctionType *FTy = >>> FunctionType::get(I8X, Params, /*isVarArg=*/false); >>> @@ -3307,8 +3307,8 @@ >>> Constant *ObjCARCContract::getRetainAutoreleaseRVCallee(Module *M) { >>> if (!RetainAutoreleaseRVCallee) { >>> LLVMContext &C = M->getContext(); >>> - const Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> - std::vector Params; >>> + Type *I8X = PointerType::getUnqual(Type::getInt8Ty(C)); >>> + std::vector Params; >>> Params.push_back(I8X); >>> const FunctionType *FTy = >>> FunctionType::get(I8X, Params, /*isVarArg=*/false); >>> >>> Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Mon Jul 11 02:56:41 2011 >>> @@ -992,7 +992,7 @@ >>> } >>> >>> // ffs(x) -> x != 0 ? (i32)llvm.cttz(x)+1 : 0 >>> - const Type *ArgType = Op->getType(); >>> + Type *ArgType = Op->getType(); >>> Value *F = Intrinsic::getDeclaration(Callee->getParent(), >>> Intrinsic::cttz, &ArgType, 1); >>> Value *V = B.CreateCall(F, Op, "cttz"); >>> >>> Modified: llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp Mon Jul 11 02:56:41 2011 >>> @@ -140,7 +140,7 @@ >>> Function *llvm::CloneFunction(const Function *F, ValueToValueMapTy &VMap, >>> bool ModuleLevelChanges, >>> ClonedCodeInfo *CodeInfo) { >>> - std::vector ArgTypes; >>> + std::vector ArgTypes; >>> >>> // The user might be deleting arguments to the function by specifying them in >>> // the VMap. If so, we need to not add the arguments to the arg ty vector >>> >>> Modified: llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Mon Jul 11 02:56:41 2011 >>> @@ -258,7 +258,7 @@ >>> default: RetTy = Type::getInt16Ty(header->getContext()); break; >>> } >>> >>> - std::vector paramTy; >>> + std::vector paramTy; >>> >>> // Add the types of the input values to the function's argument list >>> for (Values::const_iterator i = inputs.begin(), >>> @@ -279,7 +279,7 @@ >>> } >>> >>> DEBUG(dbgs() << "Function type: " << *RetTy << " f("); >>> - for (std::vector::iterator i = paramTy.begin(), >>> + for (std::vector::iterator i = paramTy.begin(), >>> e = paramTy.end(); i != e; ++i) >>> DEBUG(dbgs() << **i << ", "); >>> DEBUG(dbgs() << ")\n"); >>> >>> Modified: llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp (original) >>> +++ llvm/trunk/lib/Transforms/Utils/InlineFunction.cpp Mon Jul 11 02:56:41 2011 >>> @@ -663,7 +663,7 @@ >>> >>> LLVMContext &Context = Arg->getContext(); >>> >>> - const Type *VoidPtrTy = Type::getInt8PtrTy(Context); >>> + Type *VoidPtrTy = Type::getInt8PtrTy(Context); >>> >>> // Create the alloca. If we have TargetData, use nice alignment. >>> unsigned Align = 1; >>> @@ -680,7 +680,7 @@ >>> Value *NewAlloca = new AllocaInst(AggTy, 0, Align, Arg->getName(), >>> &*Caller->begin()->begin()); >>> // Emit a memcpy. >>> - const Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; >>> + Type *Tys[3] = {VoidPtrTy, VoidPtrTy, Type::getInt64Ty(Context)}; >>> Function *MemCpyFn = Intrinsic::getDeclaration(Caller->getParent(), >>> Intrinsic::memcpy, >>> Tys, 3); >>> >>> Modified: llvm/trunk/lib/VMCore/Core.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/Core.cpp (original) >>> +++ llvm/trunk/lib/VMCore/Core.cpp Mon Jul 11 02:56:41 2011 >>> @@ -260,7 +260,7 @@ >>> LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, >>> LLVMTypeRef *ParamTypes, unsigned ParamCount, >>> LLVMBool IsVarArg) { >>> - std::vector Tys; >>> + std::vector Tys; >>> for (LLVMTypeRef *I = ParamTypes, *E = ParamTypes + ParamCount; I != E; ++I) >>> Tys.push_back(unwrap(*I)); >>> >>> >>> Modified: llvm/trunk/lib/VMCore/Function.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/Function.cpp (original) >>> +++ llvm/trunk/lib/VMCore/Function.cpp Mon Jul 11 02:56:41 2011 >>> @@ -333,7 +333,7 @@ >>> return 0; >>> } >>> >>> -std::string Intrinsic::getName(ID id, const Type **Tys, unsigned numTys) { >>> +std::string Intrinsic::getName(ID id, Type **Tys, unsigned numTys) { >>> assert(id < num_intrinsics && "Invalid intrinsic ID!"); >>> static const char * const Table[] = { >>> "not_intrinsic", >>> @@ -356,10 +356,10 @@ >>> } >>> >>> const FunctionType *Intrinsic::getType(LLVMContext &Context, >>> - ID id, const Type **Tys, >>> + ID id, Type **Tys, >>> unsigned numTys) { >>> const Type *ResultTy = NULL; >>> - std::vector ArgTys; >>> + std::vector ArgTys; >>> bool IsVarArg = false; >>> >>> #define GET_INTRINSIC_GENERATOR >>> @@ -384,7 +384,7 @@ >>> #include "llvm/Intrinsics.gen" >>> #undef GET_INTRINSIC_ATTRIBUTES >>> >>> -Function *Intrinsic::getDeclaration(Module *M, ID id, const Type **Tys, >>> +Function *Intrinsic::getDeclaration(Module *M, ID id, Type **Tys, >>> unsigned numTys) { >>> // There can never be multiple globals with the same name of different types, >>> // because intrinsics must be a specific type. >>> >>> Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/IRBuilder.cpp (original) >>> +++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Jul 11 02:56:41 2011 >>> @@ -65,7 +65,7 @@ >>> bool isVolatile, MDNode *TBAATag) { >>> Ptr = getCastedInt8PtrValue(Ptr); >>> Value *Ops[] = { Ptr, Val, Size, getInt32(Align), getInt1(isVolatile) }; >>> - const Type *Tys[] = { Ptr->getType(), Size->getType() }; >>> + Type *Tys[] = { Ptr->getType(), Size->getType() }; >>> Module *M = BB->getParent()->getParent(); >>> Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memset, Tys, 2); >>> >>> @@ -85,7 +85,7 @@ >>> Src = getCastedInt8PtrValue(Src); >>> >>> Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; >>> - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >>> + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >>> Module *M = BB->getParent()->getParent(); >>> Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memcpy, Tys, 3); >>> >>> @@ -105,7 +105,7 @@ >>> Src = getCastedInt8PtrValue(Src); >>> >>> Value *Ops[] = { Dst, Src, Size, getInt32(Align), getInt1(isVolatile) }; >>> - const Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >>> + Type *Tys[] = { Dst->getType(), Src->getType(), Size->getType() }; >>> Module *M = BB->getParent()->getParent(); >>> Value *TheFn = Intrinsic::getDeclaration(M, Intrinsic::memmove, Tys, 3); >>> >>> >>> Modified: llvm/trunk/lib/VMCore/Module.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/Module.cpp (original) >>> +++ llvm/trunk/lib/VMCore/Module.cpp Mon Jul 11 02:56:41 2011 >>> @@ -216,8 +216,8 @@ >>> va_start(Args, RetTy); >>> >>> // Build the list of argument types... >>> - std::vector ArgTys; >>> - while (const Type *ArgTy = va_arg(Args, const Type*)) >>> + std::vector ArgTys; >>> + while (Type *ArgTy = va_arg(Args, Type*)) >>> ArgTys.push_back(ArgTy); >>> >>> va_end(Args); >>> @@ -234,8 +234,8 @@ >>> va_start(Args, RetTy); >>> >>> // Build the list of argument types... >>> - std::vector ArgTys; >>> - while (const Type *ArgTy = va_arg(Args, const Type*)) >>> + std::vector ArgTys; >>> + while (Type *ArgTy = va_arg(Args, Type*)) >>> ArgTys.push_back(ArgTy); >>> >>> va_end(Args); >>> >>> Modified: llvm/trunk/lib/VMCore/Type.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/VMCore/Type.cpp (original) >>> +++ llvm/trunk/lib/VMCore/Type.cpp Mon Jul 11 02:56:41 2011 >>> @@ -325,13 +325,6 @@ >>> NumContainedTys = Params.size() + 1; // + 1 for result type >>> } >>> >>> -// FIXME: Remove this version. >>> -FunctionType *FunctionType::get(const Type *ReturnType, >>> - ArrayRef Params, bool isVarArg) { >>> - return get(ReturnType, ArrayRef(const_cast(Params.data()), >>> - Params.size()), isVarArg); >>> -} >>> - >>> // FunctionType::get - The factory function for the FunctionType class. >>> FunctionType *FunctionType::get(const Type *ReturnType, >>> ArrayRef Params, bool isVarArg) { >>> @@ -357,7 +350,7 @@ >>> >>> >>> FunctionType *FunctionType::get(const Type *Result, bool isVarArg) { >>> - return get(Result, ArrayRef(), isVarArg); >>> + return get(Result, ArrayRef(), isVarArg); >>> } >>> >>> >>> >>> Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) >>> +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Mon Jul 11 02:56:41 2011 >>> @@ -23,7 +23,7 @@ >>> Module M("world", Context); >>> >>> const FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), >>> - std::vector(), false); >>> + std::vector(), false); >>> Function *F = cast(M.getOrInsertFunction("f", FTy)); >>> BasicBlock *BB = BasicBlock::Create(Context, "entry", F); >>> ReturnInst::Create(Context, 0, BB); >>> >>> Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp (original) >>> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITMemoryManagerTest.cpp Mon Jul 11 02:56:41 2011 >>> @@ -21,7 +21,7 @@ >>> namespace { >>> >>> Function *makeFakeFunction() { >>> - std::vector params; >>> + std::vector params; >>> const FunctionType *FTy = >>> FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false); >>> return Function::Create(FTy, GlobalValue::ExternalLinkage); >>> >>> Modified: llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp (original) >>> +++ llvm/trunk/unittests/ExecutionEngine/JIT/JITTest.cpp Mon Jul 11 02:56:41 2011 >>> @@ -37,7 +37,7 @@ >>> namespace { >>> >>> Function *makeReturnGlobal(std::string Name, GlobalVariable *G, Module *M) { >>> - std::vector params; >>> + std::vector params; >>> const FunctionType *FTy = FunctionType::get(G->getType()->getElementType(), >>> params, false); >>> Function *F = Function::Create(FTy, GlobalValue::ExternalLinkage, Name, M); >>> @@ -322,7 +322,7 @@ >>> >>> const FunctionType *Func1Ty = >>> cast(TypeBuilder::get(Context)); >>> - std::vector arg_types; >>> + std::vector arg_types; >>> arg_types.push_back(Type::getInt1Ty(Context)); >>> const FunctionType *FuncTy = FunctionType::get( >>> Type::getVoidTy(Context), arg_types, false); >>> >>> Modified: llvm/trunk/unittests/Support/TypeBuilderTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/TypeBuilderTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/unittests/Support/TypeBuilderTest.cpp (original) >>> +++ llvm/trunk/unittests/Support/TypeBuilderTest.cpp Mon Jul 11 02:56:41 2011 >>> @@ -120,7 +120,7 @@ >>> } >>> >>> TEST(TypeBuilderTest, Functions) { >>> - std::vector params; >>> + std::vector params; >>> EXPECT_EQ(FunctionType::get(Type::getVoidTy(getGlobalContext()), params, false), >>> (TypeBuilder::get(getGlobalContext()))); >>> EXPECT_EQ(FunctionType::get(Type::getInt8Ty(getGlobalContext()), params, true), >>> >>> Modified: llvm/trunk/unittests/VMCore/PassManagerTest.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/PassManagerTest.cpp?rev=134888&r1=134887&r2=134888&view=diff >>> ============================================================================== >>> --- llvm/trunk/unittests/VMCore/PassManagerTest.cpp (original) >>> +++ llvm/trunk/unittests/VMCore/PassManagerTest.cpp Mon Jul 11 02:56:41 2011 >>> @@ -405,13 +405,13 @@ >>> mod->setTargetTriple("x86_64-unknown-linux-gnu"); >>> >>> // Type Definitions >>> - std::vectorFuncTy_0_args; >>> + std::vectorFuncTy_0_args; >>> FunctionType* FuncTy_0 = FunctionType::get( >>> /*Result=*/IntegerType::get(getGlobalContext(), 32), >>> /*Params=*/FuncTy_0_args, >>> /*isVarArg=*/false); >>> >>> - std::vectorFuncTy_2_args; >>> + std::vectorFuncTy_2_args; >>> FuncTy_2_args.push_back(IntegerType::get(getGlobalContext(), 1)); >>> FunctionType* FuncTy_2 = FunctionType::get( >>> /*Result=*/Type::getVoidTy(getGlobalContext()), >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> >> From pichet2000 at gmail.com Tue Jul 12 03:43:36 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 12 Jul 2011 08:43:36 -0000 Subject: [llvm-commits] [llvm] r134975 - /llvm/trunk/examples/BrainF/BrainF.cpp Message-ID: <20110712084336.E207A2A6C12C@llvm.org> Author: fpichet Date: Tue Jul 12 03:43:36 2011 New Revision: 134975 URL: http://llvm.org/viewvc/llvm-project?rev=134975&view=rev Log: Fix the BrainF build. Modified: llvm/trunk/examples/BrainF/BrainF.cpp Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=134975&r1=134974&r2=134975&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Tue Jul 12 03:43:36 2011 @@ -55,7 +55,7 @@ //Function prototypes //declare void @llvm.memset.p0i8.i32(i8 *, i8, i32, i32, i1) - Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) }; + const Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) }; Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset, Tys, 2); From nicholas at mxc.ca Tue Jul 12 04:29:45 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 12 Jul 2011 02:29:45 -0700 Subject: [llvm-commits] patch: teach sroa to scalarize lifetime intrinsics Message-ID: <4E1C1409.1010207@mxc.ca> The attached patch extends sroa's ability to handle lifetime intrinsics. Despite the tests, I'm still not really confident that all the corner cases are handled properly and would appreciate a thorough review. I'm also unhappy with the innards of RewriteLifetimeIntrinsic() itself, but I don't see a way to straighten out the logic. Suggestions appreciated. Please review! This is another in the series of patches that should help PR10121, but there is still more to do in sroa. Nick -------------- next part -------------- A non-text attachment was scrubbed... Name: sroa-lifetime-pt2.patch Type: text/x-diff Size: 8900 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20110712/6820f946/attachment.bin From grosser at fim.uni-passau.de Tue Jul 12 06:36:58 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jul 2011 11:36:58 -0000 Subject: [llvm-commits] [llvm] r134978 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <20110712113658.DD47B2A6C12C@llvm.org> Author: grosser Date: Tue Jul 12 06:36:58 2011 New Revision: 134978 URL: http://llvm.org/viewvc/llvm-project?rev=134978&view=rev Log: Remove IntegerType constness from TargetData Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=134978&r1=134977&r2=134978&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Tue Jul 12 06:36:58 2011 @@ -259,7 +259,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. /// - const IntegerType *getIntPtrType(LLVMContext &C) const; + IntegerType *getIntPtrType(LLVMContext &C) const; /// getIndexedOffset - return the offset from the beginning of the type for /// the specified indices. This is used to implement getelementptr. Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=134978&r1=134977&r2=134978&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Tue Jul 12 06:36:58 2011 @@ -535,7 +535,7 @@ /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. -const IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { +IntegerType *TargetData::getIntPtrType(LLVMContext &C) const { return IntegerType::get(C, getPointerSizeInBits()); } From grosser at fim.uni-passau.de Tue Jul 12 06:37:02 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 12 Jul 2011 11:37:02 -0000 Subject: [llvm-commits] [llvm] r134979 - /llvm/trunk/docs/ProgrammersManual.html Message-ID: <20110712113702.B28AD2A6C12D@llvm.org> Author: grosser Date: Tue Jul 12 06:37:02 2011 New Revision: 134979 URL: http://llvm.org/viewvc/llvm-project?rev=134979&view=rev Log: VectorType is also a SequentialType Modified: llvm/trunk/docs/ProgrammersManual.html Modified: llvm/trunk/docs/ProgrammersManual.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/ProgrammersManual.html?rev=134979&r1=134978&r2=134979&view=diff ============================================================================== --- llvm/trunk/docs/ProgrammersManual.html (original) +++ llvm/trunk/docs/ProgrammersManual.html Tue Jul 12 06:37:02 2011 @@ -2979,7 +2979,7 @@
SequentialType
-
This is subclassed by ArrayType and PointerType +
This is subclassed by ArrayType, PointerType and VectorType.