[pure-lang-svn] SF.net SVN: pure-lang: [434] pure/trunk
Status: Beta
Brought to you by:
agraef
From: <ag...@us...> - 2008-07-11 02:59:03
|
Revision: 434 http://pure-lang.svn.sourceforge.net/pure-lang/?rev=434&view=rev Author: agraef Date: 2008-07-10 19:59:08 -0700 (Thu, 10 Jul 2008) Log Message: ----------- Apply Rooslan S. Khayrov's patches to make the interpreter compile with LLVM 2.3. Modified Paths: -------------- pure/trunk/ChangeLog pure/trunk/INSTALL pure/trunk/README pure/trunk/interpreter.cc pure/trunk/interpreter.hh Modified: pure/trunk/ChangeLog =================================================================== --- pure/trunk/ChangeLog 2008-07-10 12:23:48 UTC (rev 433) +++ pure/trunk/ChangeLog 2008-07-11 02:59:08 UTC (rev 434) @@ -1,3 +1,13 @@ +2008-07-11 Albert Graef <Dr....@t-...> + + * interpreter.cc/h: Apply Rooslan S. Khayrov's patches to make the + interpreter compile with LLVM 2.3. + + Note that this means that Pure really needs LLVM 2.3 now. By + reverting these changes you can still make it work with LLVM 2.2, + but we really recommend using LLVM 2.3 now since it has many + improvements and bugfixes. + 2008-07-08 Albert Graef <Dr....@t-...> * runtime.cc/h, lib/math.pure: Add random number generator Modified: pure/trunk/INSTALL =================================================================== --- pure/trunk/INSTALL 2008-07-10 12:23:48 UTC (rev 433) +++ pure/trunk/INSTALL 2008-07-11 02:59:08 UTC (rev 434) @@ -48,12 +48,12 @@ bison, libgmp3c2, libgmp3-dev, readline5-dev, libltdl3, libldtl3-dev, subversion. -STEP 2. Get and unpack the LLVM 2.2 sources at: -http://llvm.org/releases/download.html#2.2 +STEP 2. Get and unpack the LLVM 2.3 sources at: +http://llvm.org/releases/download.html#2.3 STEP 3. Configure, build and install LLVM as follows: -$ cd llvm-2.2 +$ cd llvm-2.3 $ ./configure --enable-optimized --disable-assertions --disable-expensive-checks --enable-targets=host-only $ make $ sudo make install @@ -76,7 +76,7 @@ section. STEP 5. Configure, build and install Pure as follows (x.y denotes the current -Pure version number, 0.4 at the time of this writing): +Pure version number, 0.5 at the time of this writing): $ cd pure-x.y $ ./configure @@ -111,10 +111,10 @@ Run Pure interactively as: $ pure -Pure 0.4 (i686-pc-linux-gnu) Copyright (c) 2008 by Albert Graef +Pure 0.5 (i686-pc-linux-gnu) Copyright (c) 2008 by Albert Graef This program is free software distributed under the GNU Public License (GPL V3 or later). Please see the COPYING file for details. -Loaded prelude from /usr/local/lib/pure-0.4/prelude.pure. +Loaded prelude from /usr/local/lib/pure-0.5/prelude.pure. Check that it works: @@ -371,10 +371,10 @@ -- --- ------- 64 bit systems are fully supported by Pure. However, you'll need to patch up -LLVM 2.2 so that it can be linked into the Pure runtime library on x86-64 +LLVM 2.3 so that it can be linked into the Pure runtime library on x86-64 systems. You also have to configure LLVM with --enable-pic. The patch by -Cyrille Berger, which is to be applied in the llvm-2.2 source directory, is -available at http://pure-lang.sf.net/X86JITInfo.cpp.pic.patch. +Cyrille Berger, which is to be applied in the llvm-2.3 source directory, is +available at http://pure-lang.sf.net/X86JITInfo.cpp.pic.2.3.patch. Also, the debug build currently does *not* work on x86-64 Linux versions. This seems to be a bug in LLVM, so there's hope that it will go away in a future Modified: pure/trunk/README =================================================================== --- pure/trunk/README 2008-07-10 12:23:48 UTC (rev 433) +++ pure/trunk/README 2008-07-11 02:59:08 UTC (rev 434) @@ -31,8 +31,9 @@ systems, the usual './configure && make && sudo make install' should do the trick. This requires GNU make and g++. For other setups, you'll probably have to fiddle with the Makefile and the sources. You'll also need LLVM for the -compiler backend (version 2.2 has been tested). For your convenience, -instructions for installing LLVM are also included in the INSTALL file. +compiler backend (version 2.3 or later is required as of Pure 0.5). For your +convenience, instructions for installing LLVM are also included in the INSTALL +file. USING PURE ----- ---- @@ -44,10 +45,10 @@ can also just type EOF a.k.a. Ctrl-D at the beginning of the interpreter's command line). For instance: -Pure 0.4 (i686-pc-linux-gnu) Copyright (c) 2008 by Albert Graef +Pure 0.5 (i686-pc-linux-gnu) Copyright (c) 2008 by Albert Graef This program is free software distributed under the GNU Public License (GPL V3 or later). Please see the COPYING file for details. -Loaded prelude from /usr/local/lib/pure-0.4/prelude.pure. +Loaded prelude from /usr/local/lib/pure-0.5/prelude.pure. > fact n = if n>0 then n*fact (n-1) else 1; > map fact (1..10); Modified: pure/trunk/interpreter.cc =================================================================== --- pure/trunk/interpreter.cc 2008-07-10 12:23:48 UTC (rev 433) +++ pure/trunk/interpreter.cc 2008-07-11 02:59:08 UTC (rev 434) @@ -8,6 +8,7 @@ #include <glob.h> #include <llvm/CallingConv.h> +#include <llvm/PassManager.h> #include <llvm/System/DynamicLibrary.h> #include <llvm/Transforms/Utils/BasicBlockUtils.h> @@ -1805,7 +1806,7 @@ // Code generation. -#define Dbl(d) ConstantFP::get(Type::DoubleTy, APFloat(d)) +#define Dbl(d) ConstantFP::get(Type::DoubleTy, d) #define Bool(i) ConstantInt::get(Type::Int1Ty, i) #define UInt(i) ConstantInt::get(Type::Int32Ty, i) #define SInt(i) ConstantInt::get(Type::Int32Ty, (uint64_t)i, true) @@ -2045,7 +2046,7 @@ // We must garbage-collect args and environment here, immediately before the // call (if any), or the return instruction otherwise. if (pi != ret && n == 1 && m == 0) - new CallInst(free1_fun, "", pi); + CallInst::Create(free1_fun, "", pi); else if (n+m != 0) { vector<Value*> myargs; if (pi == ret) @@ -2054,10 +2055,10 @@ myargs.push_back(ConstantPointerNull::get(interp.ExprPtrTy)); myargs.push_back(UInt(n)); myargs.push_back(UInt(m)); - new CallInst(free_fun, myargs.begin(), myargs.end(), "", pi); + CallInst::Create(free_fun, myargs.begin(), myargs.end(), "", pi); if (pi == ret) { Value *x[1] = { v }; - new CallInst(interp.module->getFunction("pure_unref"), x, x+1, "", ret); + CallInst::Create(interp.module->getFunction("pure_unref"), x, x+1, "", ret); } } return ret; @@ -2549,7 +2550,7 @@ } // The function declaration hasn't been assembled yet. Do it now. FunctionType *ft = FunctionType::get(type, argt, varargs); - f = new Function(ft, Function::ExternalLinkage, name, module); + f = Function::Create(ft, Function::ExternalLinkage, name, module); // Enter a fixed association into the dynamic linker table. This ensures // that even if the runtime functions can't be resolved via dlopening // the interpreter executable (e.g., if the interpreter was linked @@ -2643,7 +2644,7 @@ // entered into the externals table. if (!g) { gt = ft; - g = new Function(gt, Function::ExternalLinkage, name, module); + g = Function::Create(gt, Function::ExternalLinkage, name, module); Function::arg_iterator a = g->arg_begin(); for (size_t i = 0; a != g->arg_end(); ++a, ++i) a->setName(mklabel("arg", i)); @@ -2659,7 +2660,7 @@ // programs). vector<const Type*> argt2(n, ExprPtrTy); FunctionType *ft2 = FunctionType::get(ExprPtrTy, argt2, false); - Function *f = new Function(ft2, Function::InternalLinkage, + Function *f = Function::Create(ft2, Function::InternalLinkage, "$$wrap."+asname, module); vector<Value*> args(n), unboxed(n); Function::arg_iterator a = f->arg_begin(); @@ -2667,15 +2668,15 @@ a->setName(mklabel("arg", i)); args[i] = a; } Builder b; - BasicBlock *bb = new BasicBlock("entry", f), - *failedbb = new BasicBlock("failed"); + BasicBlock *bb = BasicBlock::Create("entry", f), + *failedbb = BasicBlock::Create("failed"); b.SetInsertPoint(bb); // unbox arguments bool temps = false; for (size_t i = 0; i < n; i++) { Value *x = args[i]; if (argt[i] == Type::Int1Ty) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2687,7 +2688,7 @@ Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateICmpNE(iv, Zero); } else if (argt[i] == Type::Int8Ty) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2699,7 +2700,7 @@ Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateTrunc(iv, Type::Int8Ty); } else if (argt[i] == Type::Int16Ty) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2711,7 +2712,7 @@ Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = b.CreateTrunc(iv, Type::Int16Ty); } else if (argt[i] == Type::Int32Ty) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2723,9 +2724,9 @@ Value *iv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "intval"); unboxed[i] = iv; } else if (argt[i] == Type::Int64Ty) { - BasicBlock *intbb = new BasicBlock("int"); - BasicBlock *mpzbb = new BasicBlock("mpz"); - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *intbb = BasicBlock::Create("int"); + BasicBlock *mpzbb = BasicBlock::Create("mpz"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); SwitchInst *sw = b.CreateSwitch(tagv, failedbb, 2); @@ -2751,7 +2752,7 @@ phi->addIncoming(mpzv, mpzbb); unboxed[i] = phi; } else if (argt[i] == Type::DoubleTy) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2763,7 +2764,7 @@ Value *dv = b.CreateLoad(b.CreateGEP(pv, idx, idx+2), "dblval"); unboxed[i] = dv; } else if (argt[i] == CharPtrTy) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2776,7 +2777,7 @@ argt[i] == PointerType::get(Type::Int32Ty, 0) || argt[i] == PointerType::get(Type::Int64Ty, 0) || argt[i] == PointerType::get(Type::DoubleTy, 0)) { - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); b.CreateCondBr @@ -2791,9 +2792,9 @@ // passed through unboxed[i] = x; } else if (argt[i] == VoidPtrTy) { - BasicBlock *ptrbb = new BasicBlock("ptr"); - BasicBlock *mpzbb = new BasicBlock("mpz"); - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *ptrbb = BasicBlock::Create("ptr"); + BasicBlock *mpzbb = BasicBlock::Create("mpz"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *idx[2] = { Zero, Zero }; Value *tagv = b.CreateLoad(b.CreateGEP(x, idx, idx+2), "tag"); SwitchInst *sw = b.CreateSwitch(tagv, failedbb, 3); @@ -2867,7 +2868,7 @@ b.CreateBitCast(u, VoidPtrTy)); else if (type == ExprPtrTy) { // check that we actually got a valid pointer; otherwise the call failed - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); b.CreateCondBr (b.CreateICmpNE(u, NullExprPtr, "cmp"), okbb, failedbb); f->getBasicBlockList().push_back(okbb); @@ -3009,8 +3010,8 @@ // compute the matchee Value *arg = codegen(rhs); // emit the matching code - BasicBlock *matchedbb = new BasicBlock("matched"); - BasicBlock *failedbb = new BasicBlock("failed"); + BasicBlock *matchedbb = BasicBlock::Create("matched"); + BasicBlock *failedbb = BasicBlock::Create("failed"); matcher m(rule(lhs, rhs)); if (verbose&verbosity::code) std::cout << m << endl; state *start = m.start; @@ -3104,9 +3105,9 @@ Env& e = act.act_fmap()[-y.hash()]; push("when", &e); fun_prolog("anonymous"); - BasicBlock *bodybb = new BasicBlock("body"); - BasicBlock *matchedbb = new BasicBlock("matched"); - BasicBlock *failedbb = new BasicBlock("failed"); + BasicBlock *bodybb = BasicBlock::Create("body"); + BasicBlock *matchedbb = BasicBlock::Create("matched"); + BasicBlock *failedbb = BasicBlock::Create("failed"); e.builder.CreateBr(bodybb); e.f->getBasicBlockList().push_back(bodybb); e.builder.SetInsertPoint(bodybb); @@ -3282,8 +3283,8 @@ Env& e = act_env(); Value *condv = b.CreateICmpNE(u, Zero, "cond"); BasicBlock *iftruebb = b.GetInsertBlock(); - BasicBlock *iffalsebb = new BasicBlock("iffalse"); - BasicBlock *endbb = new BasicBlock("end"); + BasicBlock *iffalsebb = BasicBlock::Create("iffalse"); + BasicBlock *endbb = BasicBlock::Create("end"); b.CreateCondBr(condv, endbb, iffalsebb); e.f->getBasicBlockList().push_back(iffalsebb); b.SetInsertPoint(iffalsebb); @@ -3310,8 +3311,8 @@ Env& e = act_env(); Value *condv = b.CreateICmpNE(u, Zero, "cond"); BasicBlock *iffalsebb = b.GetInsertBlock(); - BasicBlock *iftruebb = new BasicBlock("iftrue"); - BasicBlock *endbb = new BasicBlock("end"); + BasicBlock *iftruebb = BasicBlock::Create("iftrue"); + BasicBlock *endbb = BasicBlock::Create("end"); b.CreateCondBr(condv, iftruebb, endbb); e.f->getBasicBlockList().push_back(iftruebb); b.SetInsertPoint(iftruebb); @@ -3351,9 +3352,9 @@ return b.CreateAnd(u, v); else if (f.ftag() == symtab.shl_sym().f) { // result of shl is undefined if u>=#bits, return 0 in that case - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); BasicBlock *zerobb = b.GetInsertBlock(); - BasicBlock *endbb = new BasicBlock("end"); + BasicBlock *endbb = BasicBlock::Create("end"); Value *cmp = b.CreateICmpULT(v, UInt(32)); b.CreateCondBr(cmp, okbb, endbb); act_env().f->getBasicBlockList().push_back(okbb); @@ -3584,8 +3585,8 @@ if (f.ftag() == symtab.or_sym().f) { Value *u = get_int(x.xval1().xval2()); Value *condv = b.CreateICmpNE(u, Zero, "cond"); - BasicBlock *iftruebb = new BasicBlock("iftrue"); - BasicBlock *iffalsebb = new BasicBlock("iffalse"); + BasicBlock *iftruebb = BasicBlock::Create("iftrue"); + BasicBlock *iffalsebb = BasicBlock::Create("iffalse"); b.CreateCondBr(condv, iftruebb, iffalsebb); e.f->getBasicBlockList().push_back(iftruebb); b.SetInsertPoint(iftruebb); @@ -3596,8 +3597,8 @@ } else if (f.ftag() == symtab.and_sym().f) { Value *u = get_int(x.xval1().xval2()); Value *condv = b.CreateICmpNE(u, Zero, "cond"); - BasicBlock *iftruebb = new BasicBlock("iftrue"); - BasicBlock *iffalsebb = new BasicBlock("iffalse"); + BasicBlock *iftruebb = BasicBlock::Create("iftrue"); + BasicBlock *iffalsebb = BasicBlock::Create("iffalse"); b.CreateCondBr(condv, iftruebb, iffalsebb); e.f->getBasicBlockList().push_back(iffalsebb); b.SetInsertPoint(iffalsebb); @@ -3880,9 +3881,9 @@ // emit the condition (turn the previous result into a flag) Value *condv = f.builder.CreateICmpNE(iv, Zero, "cond"); // create the basic blocks for the branches - BasicBlock *thenbb = new BasicBlock("then"); - BasicBlock *elsebb = new BasicBlock("else"); - BasicBlock *endbb = new BasicBlock("end"); + BasicBlock *thenbb = BasicBlock::Create("then"); + BasicBlock *elsebb = BasicBlock::Create("else"); + BasicBlock *endbb = BasicBlock::Create("end"); // create the branch instruction and emit the 'then' block f.builder.CreateCondBr(condv, thenbb, elsebb); f.f->getBasicBlockList().push_back(thenbb); @@ -3928,8 +3929,8 @@ // emit the condition (turn the previous result into a flag) Value *condv = f.builder.CreateICmpNE(iv, Zero, "cond"); // create the basic blocks for the branches - BasicBlock *thenbb = new BasicBlock("then"); - BasicBlock *elsebb = new BasicBlock("else"); + BasicBlock *thenbb = BasicBlock::Create("then"); + BasicBlock *elsebb = BasicBlock::Create("else"); // create the branch instruction and emit the 'then' block f.builder.CreateCondBr(condv, thenbb, elsebb); f.f->getBasicBlockList().push_back(thenbb); @@ -4425,14 +4426,14 @@ if (have_c_func) pure_name = "$$pure."+name; if (cc == CallingConv::Fast) { // create the function - f.f = new Function(ft, Function::InternalLinkage, + f.f = Function::Create(ft, Function::InternalLinkage, "$$fastcc."+name, module); assert(f.f); f.f->setCallingConv(cc); // create the C-callable stub - f.h = new Function(ft, scope, pure_name, module); assert(f.h); + f.h = Function::Create(ft, scope, pure_name, module); assert(f.h); } else { // no need for a separate stub - f.f = new Function(ft, scope, pure_name, module); assert(f.f); + f.f = Function::Create(ft, scope, pure_name, module); assert(f.f); f.h = f.f; } /* Give names to the arguments, and provide direct access to these by @@ -4455,7 +4456,7 @@ } /* Create the body of the stub. This is just a call to the internal function, passing through all arguments including the environment. */ - BasicBlock *bb = new BasicBlock("entry", f.h); + BasicBlock *bb = BasicBlock::Create("entry", f.h); f.builder.SetInsertPoint(bb); CallInst* v = f.builder.CreateCall(f.f, myargs.begin(), myargs.end()); v->setCallingConv(cc); @@ -4473,7 +4474,7 @@ llvm::cerr << "PROLOG FUNCTION " << f.name << endl; #endif // create a new basic block to start insertion into - BasicBlock *bb = new BasicBlock("entry", f.f); + BasicBlock *bb = BasicBlock::Create("entry", f.f); f.builder.SetInsertPoint(bb); #if DEBUG>1 if (!f.name.empty()) { ostringstream msg; @@ -4491,7 +4492,7 @@ #if DEBUG>1 llvm::cerr << "BODY FUNCTION " << f.name << endl; #endif - BasicBlock *bodybb = new BasicBlock("body"); + BasicBlock *bodybb = BasicBlock::Create("body"); f.builder.CreateBr(bodybb); f.f->getBasicBlockList().push_back(bodybb); f.builder.SetInsertPoint(bodybb); @@ -4500,7 +4501,7 @@ msg << "body " << f.name; debug(msg.str().c_str()); } #endif - BasicBlock *failedbb = new BasicBlock("failed"); + BasicBlock *failedbb = BasicBlock::Create("failed"); // emit the matching code complex_match(pm, failedbb); // emit code for a failed match @@ -4570,8 +4571,8 @@ // throw an exception if v == false Env& f = act_env(); assert(f.f!=0); - BasicBlock *errbb = new BasicBlock("err"); - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *errbb = BasicBlock::Create("err"); + BasicBlock *okbb = BasicBlock::Create("ok"); f.builder.CreateCondBr(v, okbb, errbb); f.f->getBasicBlockList().push_back(errbb); f.builder.SetInsertPoint(errbb); @@ -4585,8 +4586,8 @@ // throw an exception if v == true Env& f = act_env(); assert(f.f!=0); - BasicBlock *errbb = new BasicBlock("err"); - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *errbb = BasicBlock::Create("err"); + BasicBlock *okbb = BasicBlock::Create("ok"); f.builder.CreateCondBr(v, errbb, okbb); f.f->getBasicBlockList().push_back(errbb); f.builder.SetInsertPoint(errbb); @@ -4650,7 +4651,7 @@ case EXPR::INT: case EXPR::DBL: { // first check the tag - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *tagv = f.CreateLoadGEP(x, Zero, Zero, "tag"); f.builder.CreateCondBr (f.builder.CreateICmpEQ(tagv, SInt(t.tag), "cmp"), okbb, failedbb); @@ -4675,7 +4676,7 @@ case EXPR::STR: { // first do a quick check on the tag so that we may avoid an expensive // call if the tags don't match - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); Value *tagv = f.CreateLoadGEP(x, Zero, Zero, "tag"); f.builder.CreateCondBr (f.builder.CreateICmpEQ(tagv, SInt(t.tag), "cmp"), okbb, failedbb); @@ -4698,8 +4699,8 @@ break; case EXPR::APP: { // first match the tag... - BasicBlock *ok1bb = new BasicBlock("arg1"); - BasicBlock *ok2bb = new BasicBlock("arg2"); + BasicBlock *ok1bb = BasicBlock::Create("arg1"); + BasicBlock *ok2bb = BasicBlock::Create("arg2"); Value *tagv = f.CreateLoadGEP(x, Zero, Zero, "tag"); f.builder.CreateCondBr (f.builder.CreateICmpEQ(tagv, SInt(t.tag)), ok1bb, failedbb); @@ -4748,7 +4749,7 @@ if (f.n == 1 && f.b && pm->r.size() == 1 && pm->r[0].qual.is_null()) { Value *arg = f.args[0]; // emit the matching code - BasicBlock *matchedbb = new BasicBlock("matched"); + BasicBlock *matchedbb = BasicBlock::Create("matched"); state *start = pm->start; simple_match(arg, start, matchedbb, failedbb); // matched => emit code for the reduct, and return the result @@ -4840,7 +4841,7 @@ assert(x->getType() == ExprPtrTy); // start a new block for this state (this is just for purposes of // readability, we don't actually need this as a label to branch to) - BasicBlock *statebb = new BasicBlock(mklabel("state", s->s)); + BasicBlock *statebb = BasicBlock::Create(mklabel("state", s->s)); f.builder.CreateBr(statebb); f.f->getBasicBlockList().push_back(statebb); f.builder.SetInsertPoint(statebb); @@ -4850,8 +4851,8 @@ debug(msg.str().c_str()); } #endif // blocks for retrying with default transitions after a failed match - BasicBlock *retrybb = new BasicBlock(mklabel("retry.state", s->s)); - BasicBlock *defaultbb = new BasicBlock(mklabel("default.state", s->s)); + BasicBlock *retrybb = BasicBlock::Create(mklabel("retry.state", s->s)); + BasicBlock *defaultbb = BasicBlock::Create(mklabel("default.state", s->s)); // first check for a literal match size_t i, n = s->tr.size(), m = 0; transl::iterator t0 = s->tr.begin(); @@ -4872,7 +4873,7 @@ transl::iterator t; for (t = t0, i = 0; t != s->tr.end(); t++, i++) { // first create the block for this specific transition - BasicBlock *bb = new BasicBlock(mklabel("trans.state", s->s, t->st->s)); + BasicBlock *bb = BasicBlock::Create(mklabel("trans.state", s->s, t->st->s)); if (t->tag == EXPR::APP || t->tag > 0) { // transition on a function symbol; in this case there's only a single // transition, to which we simply assign the label just generated @@ -4887,7 +4888,7 @@ // no outer label has been generated yet, do it now and add the // target to the outer switch tmap[t->tag].bb = - new BasicBlock(mklabel("begin.state", s->s, -t->tag)); + BasicBlock::Create(mklabel("begin.state", s->s, -t->tag)); sw->addCase(SInt(t->tag), tmap[t->tag].bb); } } @@ -4916,7 +4917,7 @@ list<trans_info>::iterator k = l; k++; BasicBlock *okbb = l->bb; BasicBlock *trynextbb = - new BasicBlock(mklabel("next.state", s->s, -tag)); + BasicBlock::Create(mklabel("next.state", s->s, -tag)); switch (tag) { case EXPR::INT: case EXPR::DBL: { @@ -4984,7 +4985,7 @@ transl::iterator t; for (t = t1, i = 0; t != s->tr.end() && t->tag == EXPR::VAR; t++, i++) { vtransbb.push_back - (new BasicBlock(mklabel("trans.state", s->s, t->st->s))); + (BasicBlock::Create(mklabel("trans.state", s->s, t->st->s))); sw->addCase(SInt(t->ttag), vtransbb[i]); } // now handle the transitions on the different type tags @@ -5021,7 +5022,7 @@ ruleml::const_iterator r = rl.begin(); assert(r != rl.end()); assert(f.fmap_idx == 0); - BasicBlock* rulebb = new BasicBlock(mklabel("rule.state", s->s, rl.front())); + BasicBlock* rulebb = BasicBlock::Create(mklabel("rule.state", s->s, rl.front())); f.builder.CreateBr(rulebb); while (r != rl.end()) { const rule& rr = rules[*r]; @@ -5064,11 +5065,11 @@ iv = get_int(rr.qual); // emit the condition (turn the previous result into a flag) Value *condv = f.builder.CreateICmpNE(iv, Zero, "cond"); - BasicBlock *okbb = new BasicBlock("ok"); + BasicBlock *okbb = BasicBlock::Create("ok"); // determine the next rule block ('failed' if none) BasicBlock *nextbb; if (++r != rl.end()) - nextbb = new BasicBlock(mklabel("rule.state", s->s, *r)); + nextbb = BasicBlock::Create(mklabel("rule.state", s->s, *r)); else nextbb = failedbb; f.builder.CreateCondBr(condv, okbb, nextbb); Modified: pure/trunk/interpreter.hh =================================================================== --- pure/trunk/interpreter.hh 2008-07-10 12:23:48 UTC (rev 433) +++ pure/trunk/interpreter.hh 2008-07-11 02:59:08 UTC (rev 434) @@ -9,7 +9,7 @@ #include <llvm/Analysis/Verifier.h> #include <llvm/Target/TargetData.h> #include <llvm/Transforms/Scalar.h> -#include <llvm/Support/LLVMBuilder.h> +#include <llvm/Support/IRBuilder.h> #include <time.h> #include <set> @@ -83,7 +83,7 @@ }; //#define Builder llvm::LLVMBuilder -#define Builder llvm::LLVMFoldingBuilder +#define Builder llvm::IRBuilder typedef list<Env*> EnvStack; typedef pair<int32_t,uint8_t> xmap_key; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |