From 34de70a553c0863626f254ed89d689611b7f9c0a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 18 Aug 2010 18:53:44 +0000 Subject: Update for LLVM 2.7. Factor out mostly duplicated code in Env::topLevel and Env::innerMost. git-svn-id: http://svn.drobilla.net/resp/resp@259 ad02d1e2-f140-0410-9f75-f8b11f17cedd --- src/llvm.cpp | 14 ++++++-------- src/resp.hpp | 14 +++++--------- 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/llvm.cpp b/src/llvm.cpp index e606062..e4d7c07 100644 --- a/src/llvm.cpp +++ b/src/llvm.cpp @@ -25,6 +25,7 @@ #include #include #include +#include "llvm/Value.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Assembly/AsmAnnotationWriter.h" #include "llvm/DerivedTypes.h" @@ -33,8 +34,8 @@ #include "llvm/Instructions.h" #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/PassManager.h" +#include "llvm/Support/raw_os_ostream.h" #include "llvm/Support/IRBuilder.h" #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetSelect.h" @@ -55,9 +56,8 @@ struct LLVMEngine : public Engine { { InitializeNativeTarget(); module = new Module("resp", context); - emp = new ExistingModuleProvider(module); engine = EngineBuilder(module).create(); - opt = new FunctionPassManager(emp); + opt = new FunctionPassManager(module); // Set up optimiser pipeline const TargetData* target = engine->getTargetData(); @@ -76,10 +76,8 @@ struct LLVMEngine : public Engine { ~LLVMEngine() { - emp->releaseModule(); delete engine; delete opt; - delete emp; } inline Value* llVal(CVal v) { return static_cast(v); } @@ -123,7 +121,7 @@ struct LLVMEngine : public Engine { return PointerType::get(StructType::get(context, ctypes, false), 0); } - return PointerType::get(Type::getVoidTy(context), NULL); + return PointerType::get(Type::getInt8Ty(context), NULL); } CFunc startFunction(CEnv& cenv, @@ -197,7 +195,8 @@ struct LLVMEngine : public Engine { void writeModule(CEnv& cenv, std::ostream& os) { AssemblyAnnotationWriter writer; - module->print(os, &writer); + llvm::raw_os_ostream raw_stream(os); + module->print(raw_stream, &writer); } const string call(CEnv& cenv, CFunc f, const AType* retT) { @@ -225,7 +224,6 @@ struct LLVMEngine : public Engine { ExecutionEngine* engine; IRBuilder<> builder; Function* alloc; - ExistingModuleProvider* emp; FunctionPassManager* opt; }; diff --git a/src/resp.hpp b/src/resp.hpp index 34106f4..752796b 100644 --- a/src/resp.hpp +++ b/src/resp.hpp @@ -87,18 +87,14 @@ struct Env : public list< vector< pair > > { return &b->second; return NULL; } - bool topLevel(const K& key) const { - for (typename Frame::const_iterator b = this->back().begin(); b != this->back().end(); ++b) - if (b->first == key) - return true; - return false; - } - bool innermost(const K& key) const { - for (typename Frame::const_iterator b = this->front().begin(); b != this->front().end(); ++b) + bool contains(const Frame& frame, const K& key) const { + for (typename Frame::const_iterator b = frame.begin(); b != frame.end(); ++b) if (b->first == key) return true; return false; } + bool topLevel(const K& key) const { return contains(this->back(), key); } + bool innermost(const K& key) const { return contains(this->front(), key); } }; template @@ -119,7 +115,7 @@ ostream& operator<<(ostream& out, const Env& env) { * Lexer: Text (istream) -> S-Expressions (SExp) * ***************************************************************************/ -class AST; +struct AST; AST* readExpression(Cursor& cur, std::istream& in); -- cgit v1.2.1