aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/BrainF/BrainF.cpp33
-rw-r--r--examples/BrainF/BrainF.h3
-rw-r--r--examples/Fibonacci/fibonacci.cpp8
-rw-r--r--examples/HowToUseJIT/HowToUseJIT.cpp4
-rw-r--r--examples/ModuleMaker/ModuleMaker.cpp7
-rw-r--r--examples/ParallelJIT/ParallelJIT.cpp6
-rw-r--r--include/llvm/Constants.h37
-rw-r--r--include/llvm/Instructions.h104
-rw-r--r--include/llvm/LLVMContext.h28
-rw-r--r--include/llvm/Support/IRBuilder.h4
-rw-r--r--include/llvm/Transforms/Utils/Local.h7
-rw-r--r--lib/Analysis/ScalarEvolution.cpp9
-rw-r--r--lib/AsmParser/LLParser.cpp4
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp6
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp3
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp83
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp3
-rw-r--r--lib/CodeGen/ShadowStackGC.cpp56
-rw-r--r--lib/CodeGen/StackProtector.cpp2
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp18
-rw-r--r--lib/Target/ARM/ARMBaseRegisterInfo.cpp5
-rw-r--r--lib/Target/ARM/ARMISelDAGToDAG.cpp4
-rw-r--r--lib/Target/ARM/Thumb1RegisterInfo.cpp5
-rw-r--r--lib/Target/ARM/Thumb2RegisterInfo.cpp5
-rw-r--r--lib/Target/Alpha/AlphaISelDAGToDAG.cpp3
-rw-r--r--lib/Target/CBackend/CBackend.cpp2
-rw-r--r--lib/Target/XCore/XCoreISelDAGToDAG.cpp4
-rw-r--r--lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp9
-rw-r--r--lib/Transforms/IPO/IndMemRemoval.cpp8
-rw-r--r--lib/Transforms/IPO/LowerSetJmp.cpp4
-rw-r--r--lib/Transforms/IPO/RaiseAllocations.cpp3
-rw-r--r--lib/Transforms/IPO/StructRetPromotion.cpp2
-rw-r--r--lib/Transforms/Instrumentation/RSProfiling.cpp2
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp28
-rw-r--r--lib/Transforms/Scalar/JumpThreading.cpp2
-rw-r--r--lib/Transforms/Scalar/LICM.cpp5
-rw-r--r--lib/Transforms/Scalar/PredicateSimplifier.cpp2
-rw-r--r--lib/Transforms/Scalar/Reg2Mem.cpp4
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp11
-rw-r--r--lib/Transforms/Scalar/TailDuplication.cpp2
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp5
-rw-r--r--lib/Transforms/Utils/DemoteRegToStack.cpp16
-rw-r--r--lib/Transforms/Utils/InlineFunction.cpp5
-rw-r--r--lib/Transforms/Utils/LowerInvoke.cpp24
-rw-r--r--lib/VMCore/Constants.cpp53
-rw-r--r--lib/VMCore/Instructions.cpp94
-rw-r--r--lib/VMCore/LLVMContext.cpp49
-rw-r--r--tools/bugpoint/ExtractFunction.cpp9
-rw-r--r--tools/bugpoint/Miscompilation.cpp20
-rw-r--r--unittests/ExecutionEngine/JIT/JITTest.cpp6
-rw-r--r--unittests/Support/ValueHandleTest.cpp5
-rw-r--r--unittests/VMCore/MetadataTest.cpp34
53 files changed, 422 insertions, 435 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp
index 38914688ec..4969a55a66 100644
--- a/examples/BrainF/BrainF.cpp
+++ b/examples/BrainF/BrainF.cpp
@@ -43,7 +43,7 @@ Module *BrainF::parse(std::istream *in1, int mem, CompileFlags cf,
comflag = cf;
header(Context);
- readloop(0, 0, 0);
+ readloop(0, 0, 0, Context);
delete builder;
return module;
}
@@ -77,16 +77,16 @@ void BrainF::header(LLVMContext& C) {
builder = new IRBuilder<>(BasicBlock::Create(label, brainf_func));
//%arr = malloc i8, i32 %d
- ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal));
+ ConstantInt *val_mem = C.getConstantInt(APInt(32, memtotal));
ptr_arr = builder->CreateMalloc(IntegerType::Int8Ty, val_mem, "arr");
//call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1)
{
Value *memset_params[] = {
ptr_arr,
- ConstantInt::get(APInt(8, 0)),
+ C.getConstantInt(APInt(8, 0)),
val_mem,
- ConstantInt::get(APInt(32, 1))
+ C.getConstantInt(APInt(32, 1))
};
CallInst *memset_call = builder->
@@ -97,12 +97,12 @@ void BrainF::header(LLVMContext& C) {
//%arrmax = getelementptr i8 *%arr, i32 %d
if (comflag & flag_arraybounds) {
ptr_arrmax = builder->
- CreateGEP(ptr_arr, ConstantInt::get(APInt(32, memtotal)), "arrmax");
+ CreateGEP(ptr_arr, C.getConstantInt(APInt(32, memtotal)), "arrmax");
}
//%head.%d = getelementptr i8 *%arr, i32 %d
curhead = builder->CreateGEP(ptr_arr,
- ConstantInt::get(APInt(32, memtotal/2)),
+ C.getConstantInt(APInt(32, memtotal/2)),
headreg);
@@ -124,8 +124,8 @@ void BrainF::header(LLVMContext& C) {
if (comflag & flag_arraybounds)
{
//@aberrormsg = internal constant [%d x i8] c"\00"
- Constant *msg_0 = ConstantArray::
- get("Error: The head has left the tape.", true);
+ Constant *msg_0 =
+ C.getConstantArray("Error: The head has left the tape.", true);
GlobalVariable *aberrormsg = new GlobalVariable(
*module,
@@ -138,7 +138,7 @@ void BrainF::header(LLVMContext& C) {
//declare i32 @puts(i8 *)
Function *puts_func = cast<Function>(module->
getOrInsertFunction("puts", IntegerType::Int32Ty,
- PointerType::getUnqual(IntegerType::Int8Ty), NULL));
+ C.getPointerTypeUnqual(IntegerType::Int8Ty), NULL));
//brainf.aberror:
aberrorbb = BasicBlock::Create(label, brainf_func);
@@ -172,7 +172,8 @@ void BrainF::header(LLVMContext& C) {
}
}
-void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
+void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb,
+ LLVMContext &C) {
Symbol cursym = SYM_NONE;
int curvalue = 0;
Symbol nextsym = SYM_NONE;
@@ -228,7 +229,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
{
//%head.%d = getelementptr i8 *%head.%d, i32 %d
curhead = builder->
- CreateGEP(curhead, ConstantInt::get(APInt(32, curvalue)),
+ CreateGEP(curhead, C.getConstantInt(APInt(32, curvalue)),
headreg);
//Error block for array out of bounds
@@ -263,7 +264,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
//%tape.%d = add i8 %tape.%d, %d
Value *tape_1 = builder->
- CreateAdd(tape_0, ConstantInt::get(APInt(8, curvalue)), tapereg);
+ CreateAdd(tape_0, C.getConstantInt(APInt(8, curvalue)), tapereg);
//store i8 %tape.%d, i8 *%head.%d\n"
builder->CreateStore(tape_1, curhead);
@@ -283,13 +284,13 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
// Make part of PHI instruction now, wait until end of loop to finish
PHINode *phi_0 =
- PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty),
+ PHINode::Create(C.getPointerTypeUnqual(IntegerType::Int8Ty),
headreg, testbb);
phi_0->reserveOperandSpace(2);
phi_0->addIncoming(curhead, bb_0);
curhead = phi_0;
- readloop(phi_0, bb_1, testbb);
+ readloop(phi_0, bb_1, testbb, C);
}
break;
@@ -428,7 +429,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
//%test.%d = icmp eq i8 %tape.%d, 0
ICmpInst *test_0 = new ICmpInst(*testbb, ICmpInst::ICMP_EQ, tape_0,
- ConstantInt::get(APInt(8, 0)), testreg);
+ C.getConstantInt(APInt(8, 0)), testreg);
//br i1 %test.%d, label %main.%d, label %main.%d
BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func);
@@ -439,7 +440,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) {
//%head.%d = phi i8 *[%head.%d, %main.%d]
PHINode *phi_1 = builder->
- CreatePHI(PointerType::getUnqual(IntegerType::Int8Ty), headreg);
+ CreatePHI(C.getPointerTypeUnqual(IntegerType::Int8Ty), headreg);
phi_1->reserveOperandSpace(1);
phi_1->addIncoming(head_0, testbb);
curhead = phi_1;
diff --git a/examples/BrainF/BrainF.h b/examples/BrainF/BrainF.h
index 053ddaa587..add0687d54 100644
--- a/examples/BrainF/BrainF.h
+++ b/examples/BrainF/BrainF.h
@@ -70,7 +70,8 @@ class BrainF {
/// The main loop for parsing. It calls itself recursively
/// to handle the depth of nesting of "[]".
- void readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb);
+ void readloop(PHINode *phi, BasicBlock *oldbb,
+ BasicBlock *testbb, LLVMContext &Context);
/// Constants during parsing
int memtotal;
diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp
index 89f3ef2d75..d637d4dea1 100644
--- a/examples/Fibonacci/fibonacci.cpp
+++ b/examples/Fibonacci/fibonacci.cpp
@@ -36,7 +36,7 @@
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
-static Function *CreateFibFunction(Module *M) {
+static Function *CreateFibFunction(Module *M, LLVMContext &Context) {
// Create the fib function and insert it into module M. This function is said
// to return an int and take an int parameter.
Function *FibF =
@@ -47,8 +47,8 @@ static Function *CreateFibFunction(Module *M) {
BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
// Get pointers to the constants.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+ Value *One = Context.getConstantInt(Type::Int32Ty, 1);
+ Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
@@ -97,7 +97,7 @@ int main(int argc, char **argv) {
Module *M = new Module("test", Context);
// We are about to create the "fib" function:
- Function *FibF = CreateFibFunction(M);
+ Function *FibF = CreateFibFunction(M, Context);
// Now we going to create JIT
ExistingModuleProvider *MP = new ExistingModuleProvider(M);
diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp
index 6734547916..6d43cb47ce 100644
--- a/examples/HowToUseJIT/HowToUseJIT.cpp
+++ b/examples/HowToUseJIT/HowToUseJIT.cpp
@@ -69,7 +69,7 @@ int main() {
BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
// Get pointers to the constant `1'.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
+ Value *One = Context.getConstantInt(Type::Int32Ty, 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -94,7 +94,7 @@ int main() {
BB = BasicBlock::Create("EntryBlock", FooF);
// Get pointers to the constant `10'.
- Value *Ten = ConstantInt::get(Type::Int32Ty, 10);
+ Value *Ten = Context.getConstantInt(Type::Int32Ty, 10);
// Pass Ten to the call call:
CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB);
diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp
index 59a86d031d..537ee341dc 100644
--- a/examples/ModuleMaker/ModuleMaker.cpp
+++ b/examples/ModuleMaker/ModuleMaker.cpp
@@ -30,7 +30,8 @@ int main() {
Module *M = new Module("test", Context);
// Create the main function: first create the type 'int ()'
- FunctionType *FT = FunctionType::get(Type::Int32Ty, /*not vararg*/false);
+ FunctionType *FT =
+ Context.getFunctionType(Type::Int32Ty, /*not vararg*/false);
// By passing a module as the last parameter to the Function constructor,
// it automatically gets appended to the Module.
@@ -41,8 +42,8 @@ int main() {
BasicBlock *BB = BasicBlock::Create("EntryBlock", F);
// Get pointers to the constant integers...
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
- Value *Three = ConstantInt::get(Type::Int32Ty, 3);
+ Value *Two = Context.getConstantInt(Type::Int32Ty, 2);
+ Value *Three = Context.getConstantInt(Type::Int32Ty, 3);
// Create the add instruction... does not insert...
Instruction *Add = BinaryOperator::Create(Instruction::Add, Two, Three,
diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp
index e80dc4986a..d82a6be81d 100644
--- a/examples/ParallelJIT/ParallelJIT.cpp
+++ b/examples/ParallelJIT/ParallelJIT.cpp
@@ -44,7 +44,7 @@ static Function* createAdd1(Module *M) {
BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F);
// Get pointers to the constant `1'.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
+ Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
// Get pointers to the integer argument of the add1 function...
assert(Add1F->arg_begin() != Add1F->arg_end()); // Make sure there's an arg
@@ -72,8 +72,8 @@ static Function *CreateFibFunction(Module *M) {
BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF);
// Get pointers to the constants.
- Value *One = ConstantInt::get(Type::Int32Ty, 1);
- Value *Two = ConstantInt::get(Type::Int32Ty, 2);
+ Value *One = M->getContext().getConstantInt(Type::Int32Ty, 1);
+ Value *Two = M->getContext().getConstantInt(Type::Int32Ty, 2);
// Get pointer to the integer argument of the add1 function...
Argument *ArgX = FibF->arg_begin(); // Get the arg.
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 448a87e770..27e225bc37 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 5bd3066ef9..b20ac18f41 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 e71183855a..552e7992c6 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-extend