diff options
author | Gabor Greif <ggreif@gmail.com> | 2008-04-06 20:25:17 +0000 |
---|---|---|
committer | Gabor Greif <ggreif@gmail.com> | 2008-04-06 20:25:17 +0000 |
commit | 051a950000e21935165db56695e35bade668193b (patch) | |
tree | 76db4bc690c153a1cfbd2989849c3b1d95500390 /examples | |
parent | d963ab1f58adb6daa028533ff3285841d7e45f80 (diff) |
API changes for class Use size reduction, wave 1.
Specifically, introduction of XXX::Create methods
for Users that have a potentially variable number of
Uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49277 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'examples')
-rw-r--r-- | examples/BrainF/BrainF.cpp | 28 | ||||
-rw-r--r-- | examples/BrainF/BrainFDriver.cpp | 8 | ||||
-rw-r--r-- | examples/Fibonacci/fibonacci.cpp | 16 | ||||
-rw-r--r-- | examples/HowToUseJIT/HowToUseJIT.cpp | 10 | ||||
-rw-r--r-- | examples/ModuleMaker/ModuleMaker.cpp | 6 | ||||
-rw-r--r-- | examples/ParallelJIT/ParallelJIT.cpp | 20 |
6 files changed, 44 insertions, 44 deletions
diff --git a/examples/BrainF/BrainF.cpp b/examples/BrainF/BrainF.cpp index a920793648..b2959f2000 100644 --- a/examples/BrainF/BrainF.cpp +++ b/examples/BrainF/BrainF.cpp @@ -74,7 +74,7 @@ void BrainF::header() { brainf_func = cast<Function>(module-> getOrInsertFunction("brainf", Type::VoidTy, NULL)); - builder = new LLVMBuilder(new BasicBlock(label, brainf_func)); + builder = new LLVMBuilder(BasicBlock::Create(label, brainf_func)); //%arr = malloc i8, i32 %d ConstantInt *val_mem = ConstantInt::get(APInt(32, memtotal)); @@ -110,13 +110,13 @@ void BrainF::header() { //Function footer //brainf.end: - endbb = new BasicBlock(label, brainf_func); + endbb = BasicBlock::Create(label, brainf_func); //free i8 *%arr new FreeInst(ptr_arr, endbb); //ret void - new ReturnInst(endbb); + ReturnInst::Create(endbb); @@ -141,7 +141,7 @@ void BrainF::header() { PointerType::getUnqual(IntegerType::Int8Ty), NULL)); //brainf.aberror: - aberrorbb = new BasicBlock(label, brainf_func); + aberrorbb = BasicBlock::Create(label, brainf_func); //call i32 @puts(i8 *getelementptr([%d x i8] *@aberrormsg, i32 0, i32 0)) { @@ -161,14 +161,14 @@ void BrainF::header() { }; CallInst *puts_call = - new CallInst(puts_func, - puts_params, array_endof(puts_params), - "", aberrorbb); + CallInst::Create(puts_func, + puts_params, array_endof(puts_params), + "", aberrorbb); puts_call->setTailCall(false); } //br label %brainf.end - new BranchInst(endbb, aberrorbb); + BranchInst::Create(endbb, aberrorbb); } } @@ -247,7 +247,7 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) { CreateOr(test_0, test_1, testreg); //br i1 %test.%d, label %main.%d, label %main.%d - BasicBlock *nextbb = new BasicBlock(label, brainf_func); + BasicBlock *nextbb = BasicBlock::Create(label, brainf_func); builder->CreateCondBr(test_2, aberrorbb, nextbb); //main.%d: @@ -273,16 +273,16 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) { case SYM_LOOP: { //br label %main.%d - BasicBlock *testbb = new BasicBlock(label, brainf_func); + BasicBlock *testbb = BasicBlock::Create(label, brainf_func); builder->CreateBr(testbb); //main.%d: BasicBlock *bb_0 = builder->GetInsertBlock(); - BasicBlock *bb_1 = new BasicBlock(label, brainf_func); + BasicBlock *bb_1 = BasicBlock::Create(label, brainf_func); builder->SetInsertPoint(bb_1); //Make part of PHI instruction now, wait until end of loop to finish - PHINode *phi_0 = new PHINode(PointerType::getUnqual(IntegerType::Int8Ty), + PHINode *phi_0 = PHINode::Create(PointerType::getUnqual(IntegerType::Int8Ty), headreg, testbb); phi_0->reserveOperandSpace(2); phi_0->addIncoming(curhead, bb_0); @@ -431,8 +431,8 @@ void BrainF::readloop(PHINode *phi, BasicBlock *oldbb, BasicBlock *testbb) { testbb); //br i1 %test.%d, label %main.%d, label %main.%d - BasicBlock *bb_0 = new BasicBlock(label, brainf_func); - new BranchInst(bb_0, oldbb, test_0, testbb); + BasicBlock *bb_0 = BasicBlock::Create(label, brainf_func); + BranchInst::Create(bb_0, oldbb, test_0, testbb); //main.%d: builder->SetInsertPoint(bb_0); diff --git a/examples/BrainF/BrainFDriver.cpp b/examples/BrainF/BrainFDriver.cpp index 2a3d546bde..0a24d7b665 100644 --- a/examples/BrainF/BrainFDriver.cpp +++ b/examples/BrainF/BrainFDriver.cpp @@ -70,17 +70,17 @@ void addMainFunction(Module *mod) { } //main.0: - BasicBlock *bb = new BasicBlock("main.0", main_func); + BasicBlock *bb = BasicBlock::Create("main.0", main_func); //call void @brainf() { - CallInst *brainf_call = new CallInst(mod->getFunction("brainf"), - "", bb); + CallInst *brainf_call = CallInst::Create(mod->getFunction("brainf"), + "", bb); brainf_call->setTailCall(false); } //ret i32 0 - new ReturnInst(ConstantInt::get(APInt(32, 0)), bb); + ReturnInst::Create(ConstantInt::get(APInt(32, 0)), bb); } int main(int argc, char **argv) { diff --git a/examples/Fibonacci/fibonacci.cpp b/examples/Fibonacci/fibonacci.cpp index b028c4b794..f5ef0d02a8 100644 --- a/examples/Fibonacci/fibonacci.cpp +++ b/examples/Fibonacci/fibonacci.cpp @@ -43,7 +43,7 @@ static Function *CreateFibFunction(Module *M) { (Type *)0)); // Add a basic block to the function. - BasicBlock *BB = new BasicBlock("EntryBlock", FibF); + BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF); // Get pointers to the constants. Value *One = ConstantInt::get(Type::Int32Ty, 1); @@ -54,25 +54,25 @@ static Function *CreateFibFunction(Module *M) { ArgX->setName("AnArg"); // Give it a nice symbolic name for fun. // Create the true_block. - BasicBlock *RetBB = new BasicBlock("return", FibF); + BasicBlock *RetBB = BasicBlock::Create("return", FibF); // Create an exit block. - BasicBlock* RecurseBB = new BasicBlock("recurse", FibF); + BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF); // Create the "if (arg <= 2) goto exitbb" Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB); - new BranchInst(RetBB, RecurseBB, CondInst, BB); + BranchInst::Create(RetBB, RecurseBB, CondInst, BB); // Create: ret int 1 - new ReturnInst(One, RetBB); + ReturnInst::Create(One, RetBB); // create fib(x-1) Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB); - CallInst *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB); + CallInst *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB); CallFibX1->setTailCall(); // create fib(x-2) Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB); - CallInst *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB); + CallInst *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB); CallFibX2->setTailCall(); @@ -81,7 +81,7 @@ static Function *CreateFibFunction(Module *M) { "addresult", RecurseBB); // Create the return instruction and add it to the basic block - new ReturnInst(Sum, RecurseBB); + ReturnInst::Create(Sum, RecurseBB); return FibF; } diff --git a/examples/HowToUseJIT/HowToUseJIT.cpp b/examples/HowToUseJIT/HowToUseJIT.cpp index b79c6d42eb..2aba8e1128 100644 --- a/examples/HowToUseJIT/HowToUseJIT.cpp +++ b/examples/HowToUseJIT/HowToUseJIT.cpp @@ -58,7 +58,7 @@ int main() { // Add a basic block to the function. As before, it automatically inserts // because of the last argument. - BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); + BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F); // Get pointers to the constant `1'. Value *One = ConstantInt::get(Type::Int32Ty, 1); @@ -72,7 +72,7 @@ int main() { Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB); // Create the return instruction and add it to the basic block - new ReturnInst(Add, BB); + ReturnInst::Create(Add, BB); // Now, function add1 is ready. @@ -83,17 +83,17 @@ int main() { cast<Function>(M->getOrInsertFunction("foo", Type::Int32Ty, (Type *)0)); // Add a basic block to the FooF function. - BB = new BasicBlock("EntryBlock", FooF); + BB = BasicBlock::Create("EntryBlock", FooF); // Get pointers to the constant `10'. Value *Ten = ConstantInt::get(Type::Int32Ty, 10); // Pass Ten to the call call: - CallInst *Add1CallRes = new CallInst(Add1F, Ten, "add1", BB); + CallInst *Add1CallRes = CallInst::Create(Add1F, Ten, "add1", BB); Add1CallRes->setTailCall(true); // Create the return instruction and add it to the basic block. - new ReturnInst(Add1CallRes, BB); + ReturnInst::Create(Add1CallRes, BB); // Now we create the JIT. ExistingModuleProvider* MP = new ExistingModuleProvider(M); diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 1d630a4d77..40d2fa99f4 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -32,11 +32,11 @@ int main() { // By passing a module as the last parameter to the Function constructor, // it automatically gets appended to the Module. - Function *F = new Function(FT, Function::ExternalLinkage, "main", M); + Function *F = Function::Create(FT, Function::ExternalLinkage, "main", M); // Add a basic block to the function... again, it automatically inserts // because of the last argument. - BasicBlock *BB = new BasicBlock("EntryBlock", F); + BasicBlock *BB = BasicBlock::Create("EntryBlock", F); // Get pointers to the constant integers... Value *Two = ConstantInt::get(Type::Int32Ty, 2); @@ -50,7 +50,7 @@ int main() { BB->getInstList().push_back(Add); // Create the return instruction and add it to the basic block - BB->getInstList().push_back(new ReturnInst(Add)); + BB->getInstList().push_back(ReturnInst::Create(Add)); // Output the bitcode file to stdout WriteBitcodeToFile(M, std::cout); diff --git a/examples/ParallelJIT/ParallelJIT.cpp b/examples/ParallelJIT/ParallelJIT.cpp index 92d8f27f8b..300c432863 100644 --- a/examples/ParallelJIT/ParallelJIT.cpp +++ b/examples/ParallelJIT/ParallelJIT.cpp @@ -39,7 +39,7 @@ static Function* createAdd1(Module *M) { // Add a basic block to the function. As before, it automatically inserts // because of the last argument. - BasicBlock *BB = new BasicBlock("EntryBlock", Add1F); + BasicBlock *BB = BasicBlock::Create("EntryBlock", Add1F); // Get pointers to the constant `1'. Value *One = ConstantInt::get(Type::Int32Ty, 1); @@ -53,7 +53,7 @@ static Function* createAdd1(Module *M) { Instruction *Add = BinaryOperator::createAdd(One, ArgX, "addresult", BB); // Create the return instruction and add it to the basic block - new ReturnInst(Add, BB); + ReturnInst::Create(Add, BB); // Now, function add1 is ready. return Add1F; @@ -67,7 +67,7 @@ static Function *CreateFibFunction(Module *M) { (Type *)0)); // Add a basic block to the function. - BasicBlock *BB = new BasicBlock("EntryBlock", FibF); + BasicBlock *BB = BasicBlock::Create("EntryBlock", FibF); // Get pointers to the constants. Value *One = ConstantInt::get(Type::Int32Ty, 1); @@ -78,31 +78,31 @@ static Function *CreateFibFunction(Module *M) { ArgX->setName("AnArg"); // Give it a nice symbolic name for fun. // Create the true_block. - BasicBlock *RetBB = new BasicBlock("return", FibF); + BasicBlock *RetBB = BasicBlock::Create("return", FibF); // Create an exit block. - BasicBlock* RecurseBB = new BasicBlock("recurse", FibF); + BasicBlock* RecurseBB = BasicBlock::Create("recurse", FibF); // Create the "if (arg < 2) goto exitbb" Value *CondInst = new ICmpInst(ICmpInst::ICMP_SLE, ArgX, Two, "cond", BB); - new BranchInst(RetBB, RecurseBB, CondInst, BB); + BranchInst::Create(RetBB, RecurseBB, CondInst, BB); // Create: ret int 1 - new ReturnInst(One, RetBB); + ReturnInst::Create(One, RetBB); // create fib(x-1) Value *Sub = BinaryOperator::createSub(ArgX, One, "arg", RecurseBB); - Value *CallFibX1 = new CallInst(FibF, Sub, "fibx1", RecurseBB); + Value *CallFibX1 = CallInst::Create(FibF, Sub, "fibx1", RecurseBB); // create fib(x-2) Sub = BinaryOperator::createSub(ArgX, Two, "arg", RecurseBB); - Value *CallFibX2 = new CallInst(FibF, Sub, "fibx2", RecurseBB); + Value *CallFibX2 = CallInst::Create(FibF, Sub, "fibx2", RecurseBB); // fib(x-1)+fib(x-2) Value *Sum = BinaryOperator::createAdd(CallFibX1, CallFibX2, "addresult", RecurseBB); // Create the return instruction and add it to the basic block - new ReturnInst(Sum, RecurseBB); + ReturnInst::Create(Sum, RecurseBB); return FibF; } |