diff options
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Constants.h | 37 | ||||
-rw-r--r-- | include/llvm/Instructions.h | 104 | ||||
-rw-r--r-- | include/llvm/LLVMContext.h | 28 | ||||
-rw-r--r-- | include/llvm/Support/IRBuilder.h | 4 | ||||
-rw-r--r-- | include/llvm/Transforms/Utils/Local.h | 7 |
5 files changed, 86 insertions, 94 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 448a87e..27e225b 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -102,39 +102,10 @@ public: return CreateTrueFalseVals(false); } - /// Return a ConstantInt with the specified integer value for the specified - /// type. If the type is wider than 64 bits, the value will be zero-extended - /// to fit the type, unless isSigned is true, in which case the value will - /// be interpreted as a 64-bit signed integer and sign-extended to fit - /// the type. - /// @brief Get a ConstantInt for a specific value. - static ConstantInt *get(const IntegerType *Ty, - uint64_t V, bool isSigned = false); - - /// If Ty is a vector type, return a Constant with a splat of the given - /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, uint64_t V, bool isSigned = false); - - /// Return a ConstantInt with the specified value for the specified type. The - /// value V will be canonicalized to a an unsigned APInt. Accessing it with - /// either getSExtValue() or getZExtValue() will yield a correctly sized and - /// signed value for the type Ty. - /// @brief Get a ConstantInt for a specific signed value. - static ConstantInt *getSigned(const IntegerType *Ty, int64_t V) { - return get(Ty, V, true); - } - static Constant *getSigned(const Type *Ty, int64_t V) { - return get(Ty, V, true); - } - /// Return a ConstantInt with the specified value and an implied Type. The /// type is the integer type that corresponds to the bit width of the value. static ConstantInt *get(const APInt &V); - /// If Ty is a vector type, return a Constant with a splat of the given - /// value. Otherwise return a ConstantInt for the given value. - static Constant *get(const Type *Ty, const APInt &V); - /// getType - Specialize the getType() method to always return an IntegerType, /// which reduces the amount of casting needed in parts of the compiler. /// @@ -348,14 +319,6 @@ public: return get(T, std::vector<Constant*>(Vals, Vals+NumVals)); } - /// This method constructs a ConstantArray and initializes it with a text - /// string. The default behavior (AddNull==true) causes a null terminator to - /// be placed at the end of the array. This effectively increases the length - /// of the array by one (you've been warned). However, in some situations - /// this is not desired so if AddNull==false then the string is copied without - /// null termination. - static Constant *get(const std::string &Initializer, bool AddNull = true); - /// Transparently provide more efficient getOperand methods. DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Constant); diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 5bd3066..b20ac18 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -29,6 +29,7 @@ namespace llvm { class ConstantInt; class ConstantRange; class APInt; +class LLVMContext; //===----------------------------------------------------------------------===// // AllocationInst Class @@ -39,10 +40,14 @@ class APInt; /// class AllocationInst : public UnaryInstruction { protected: - AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, - const std::string &Name = "", Instruction *InsertBefore = 0); - AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, unsigned Align, - const std::string &Name, BasicBlock *InsertAtEnd); + LLVMContext &Context; + + AllocationInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned iTy, unsigned Align, const std::string &Name = "", + Instruction *InsertBefore = 0); + AllocationInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned iTy, unsigned Align, const std::string &Name, + BasicBlock *InsertAtEnd); public: // Out of line virtual method, so the vtable, etc. has a home. virtual ~AllocationInst(); @@ -98,28 +103,33 @@ public: class MallocInst : public AllocationInst { MallocInst(const MallocInst &MI); public: - explicit MallocInst(const Type *Ty, Value *ArraySize = 0, + explicit MallocInst(LLVMContext &Context, + const Type *Ty, Value *ArraySize = 0, const std::string &NameStr = "", Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, Value *ArraySize, const std::string &NameStr, - BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {} + : AllocationInst(Context, Ty, ArraySize, Malloc, + 0, NameStr, InsertBefore) {} + MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + const std::string &NameStr, BasicBlock *InsertAtEnd) + : AllocationInst(Context, Ty, ArraySize, Malloc, 0, NameStr, InsertAtEnd) {} - MallocInst(const Type *Ty, const std::string &NameStr, + MallocInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr, Instruction *InsertBefore = 0) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertBefore) {} - MallocInst(const Type *Ty, const std::string &NameStr, + : AllocationInst(Context, Ty, 0, Malloc, 0, NameStr, InsertBefore) {} + MallocInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {} + : AllocationInst(Context, Ty, 0, Malloc, 0, NameStr, InsertAtEnd) {} - MallocInst(const Type *Ty, Value *ArraySize, unsigned Align, - const std::string &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertAtEnd) {} - MallocInst(const Type *Ty, Value *ArraySize, unsigned Align, - const std::string &NameStr = "", - Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Malloc, Align, NameStr, InsertBefore) {} + MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned Align, const std::string &NameStr, + BasicBlock *InsertAtEnd) + : AllocationInst(Context, Ty, ArraySize, Malloc, + Align, NameStr, InsertAtEnd) {} + MallocInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned Align, const std::string &NameStr = "", + Instruction *InsertBefore = 0) + : AllocationInst(Context, Ty, ArraySize, + Malloc, Align, NameStr, InsertBefore) {} virtual MallocInst *clone(LLVMContext &Context) const; @@ -143,27 +153,34 @@ public: class AllocaInst : public AllocationInst { AllocaInst(const AllocaInst &); public: - explicit AllocaInst(const Type *Ty, Value *ArraySize = 0, + explicit AllocaInst(LLVMContext &Context, const Type *Ty, + Value *ArraySize = 0, const std::string &NameStr = "", Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertBefore) {} - AllocaInst(const Type *Ty, Value *ArraySize, const std::string &NameStr, + : AllocationInst(Context, Ty, ArraySize, Alloca, + 0, NameStr, InsertBefore) {} + AllocaInst(LLVMContext &Context, const Type *Ty, + Value *ArraySize, const std::string &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {} + : AllocationInst(Context, Ty, ArraySize, Alloca, 0, NameStr, InsertAtEnd) {} - AllocaInst(const Type *Ty, const std::string &NameStr, + AllocaInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr, Instruction *InsertBefore = 0) - : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertBefore) {} - AllocaInst(const Type *Ty, const std::string &NameStr, + : AllocationInst(Context, Ty, 0, Alloca, 0, NameStr, InsertBefore) {} + AllocaInst(LLVMContext &Context, const Type *Ty, const std::string &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {} + : AllocationInst(Context, Ty, 0, Alloca, 0, NameStr, InsertAtEnd) {} - AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align, - const std::string &NameStr = "", Instruction *InsertBefore = 0) - : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertBefore) {} - AllocaInst(const Type *Ty, Value *ArraySize, unsigned Align, - const std::string &NameStr, BasicBlock *InsertAtEnd) - : AllocationInst(Ty, ArraySize, Alloca, Align, NameStr, InsertAtEnd) {} + AllocaInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned Align, const std::string &NameStr = "", + Instruction *InsertBefore = 0) + : AllocationInst(Context, Ty, ArraySize, Alloca, + Align, NameStr, InsertBefore) {} + AllocaInst(LLVMContext &Context, const Type *Ty, Value *ArraySize, + unsigned Align, const std::string &NameStr, + BasicBlock *InsertAtEnd) + : AllocationInst(Context, Ty, ArraySize, Alloca, + Align, NameStr, InsertAtEnd) {} virtual AllocaInst *clone(LLVMContext &Context) const; @@ -1266,12 +1283,8 @@ public: } ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr = "", Instruction *InsertBefore = 0); - ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr = "", - Instruction *InsertBefore = 0); ExtractElementInst(Value *Vec, Value *Idx, const std::string &NameStr, BasicBlock *InsertAtEnd); - ExtractElementInst(Value *Vec, unsigned Idx, const std::string &NameStr, - BasicBlock *InsertAtEnd); /// isValidOperands - Return true if an extractelement instruction can be /// formed with the specified operands. @@ -1310,13 +1323,8 @@ class InsertElementInst : public Instruction { InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const std::string &NameStr = "", Instruction *InsertBefore = 0); - InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &NameStr = "", - Instruction *InsertBefore = 0); InsertElementInst(Value *Vec, Value *NewElt, Value *Idx, const std::string &NameStr, BasicBlock *InsertAtEnd); - InsertElementInst(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &NameStr, BasicBlock *InsertAtEnd); public: static InsertElementInst *Create(const InsertElementInst &IE) { return new(IE.getNumOperands()) InsertElementInst(IE); @@ -1326,21 +1334,11 @@ public: Instruction *InsertBefore = 0) { return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore); } - static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &NameStr = "", - Instruction *InsertBefore = 0) { - return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertBefore); - } static InsertElementInst *Create(Value *Vec, Value *NewElt, Value *Idx, const std::string &NameStr, BasicBlock *InsertAtEnd) { return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd); } - static InsertElementInst *Create(Value *Vec, Value *NewElt, unsigned Idx, - const std::string &NameStr, - BasicBlock *InsertAtEnd) { - return new(3) InsertElementInst(Vec, NewElt, Idx, NameStr, InsertAtEnd); - } /// isValidOperands - Return true if an insertelement instruction can be /// formed with the specified operands. diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index e711838..552e799 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -70,12 +70,33 @@ public: // ConstantInt accessors ConstantInt* getConstantIntTrue(); ConstantInt* getConstantIntFalse(); + + /// If Ty is a vector type, return a Constant with a splat of the given + /// value. Otherwise return a ConstantInt for the given value. Constant* getConstantInt(const Type* Ty, uint64_t V, bool isSigned = false); + + /// Return a ConstantInt with the specified integer value for the specified + /// type. If the type is wider than 64 bits, the value will be zero-extended + /// to fit the type, unless isSigned is true, in which case the value will + /// be interpreted as a 64-bit signed integer and sign-extended to fit + /// the type. + /// @brief Get a ConstantInt for a specific value. ConstantInt* getConstantInt(const IntegerType* Ty, uint64_t V, bool isSigned = false); + + /// Return a ConstantInt with the specified value for the specified type. The + /// value V will be canonicalized to a an unsigned APInt. Accessing it with + /// either getSExtValue() or getZExtValue() will yield a correctly sized and + /// signed value for the type Ty. + /// @brief Get a ConstantInt for a specific signed value. ConstantInt* getConstantIntSigned(const IntegerType* Ty, int64_t V); + Constant *getConstantIntSigned(const Type *Ty, int64_t V); + ConstantInt* getConstantInt(const APInt& V); + + /// If Ty is a vector type, return a Constant with a splat of the given + /// value. Otherwise return a ConstantInt for the given value. Constant* getConstantInt(const Type* Ty, const APInt& V); // ConstantPointerNull accessors @@ -97,6 +118,13 @@ public: const std::vector<Constant*>& V); Constant* getConstantArray(const ArrayType* T, Constant* const* Vals, unsigned NumVals); + + /// This method constructs a ConstantArray and initializes it with a text + /// string. The default behavior (AddNull==true) causes a null terminator to + /// be placed at the end of the array. This effectively increases the length + /// of the array by one (you've been warned). However, in some situations + /// this is not desired so if AddNull==false then the string is copied without + /// null termination. Constant* getConstantArray(const std::string& Initializer, bool AddNull = true); diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 2ef13a7..cd0e182 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -330,11 +330,11 @@ public: MallocInst *CreateMalloc(const Type *Ty, Value *ArraySize = 0, const char *Name = "") { - return Insert(new MallocInst(Ty, ArraySize), Name); + return Insert(new MallocInst(Context, Ty, ArraySize), Name); } AllocaInst *CreateAlloca(const Type *Ty, Value *ArraySize = 0, const char *Name = "") { - return Insert(new AllocaInst(Ty, ArraySize), Name); + return Insert(new AllocaInst(Context, Ty, ArraySize), Name); } FreeInst *CreateFree(Value *Ptr) { return Insert(new FreeInst(Ptr)); diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index dd423fa..35f2a69 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -27,6 +27,7 @@ class PHINode; class AllocaInst; class ConstantExpr; class TargetData; +class LLVMContext; struct DbgInfoIntrinsic; template<typename T> class SmallVectorImpl; @@ -107,13 +108,15 @@ bool FoldBranchToCommonDest(BranchInst *BI); /// invalidating the SSA information for the value. It returns the pointer to /// the alloca inserted to create a stack slot for X. /// -AllocaInst *DemoteRegToStack(Instruction &X, bool VolatileLoads = false, +AllocaInst *DemoteRegToStack(LLVMContext &Context, Instruction &X, + bool VolatileLoads = false, Instruction *AllocaPoint = 0); /// DemotePHIToStack - This function takes a virtual register computed by a phi /// node and replaces it with a slot in the stack frame, allocated via alloca. /// The phi node is deleted and it returns the pointer to the alloca inserted. -AllocaInst *DemotePHIToStack(PHINode *P, Instruction *AllocaPoint = 0); +AllocaInst *DemotePHIToStack(LLVMContext &Context, PHINode *P, + Instruction *AllocaPoint = 0); /// OnlyUsedByDbgIntrinsics - Return true if the instruction I is only used /// by DbgIntrinsics. If DbgInUses is specified then the vector is filled |