diff options
author | David Robillard <d@drobilla.net> | 2010-08-18 18:53:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-08-18 18:53:44 +0000 |
commit | 34de70a553c0863626f254ed89d689611b7f9c0a (patch) | |
tree | 59e3e7f05acee64b62b2ef72caf2c263f8c65029 | |
parent | 7bec36818542d53a52fb285757b1c5947b77b443 (diff) | |
download | resp-34de70a553c0863626f254ed89d689611b7f9c0a.tar.gz resp-34de70a553c0863626f254ed89d689611b7f9c0a.tar.bz2 resp-34de70a553c0863626f254ed89d689611b7f9c0a.zip |
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
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | src/llvm.cpp | 14 | ||||
-rw-r--r-- | src/resp.hpp | 14 |
3 files changed, 15 insertions, 21 deletions
@@ -1,7 +1,7 @@ -LLVM_CXXFLAGS=`llvm-config --cppflags core jit native` -LLVM_LDFLAGS=`llvm-config --ldflags --libs core jit native` -#LLVM_CXXFLAGS=`llvm-config --cppflags all` -#LLVM_LDFLAGS=`llvm-config --ldflags --libs all` +LLVM_CXXFLAGS=`llvm-config-2.7 --cppflags core jit native` +LLVM_LDFLAGS=`llvm-config-2.7 --ldflags --libs core jit native` +#LLVM_CXXFLAGS=`llvm-config-2.7 --cppflags all` +#LLVM_LDFLAGS=`llvm-config-2.7 --ldflags --libs all` COMMON_FLAGS=-fPIC COMMON_FLAGS+=-Wall -Wextra -Wno-unused-parameter 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 <map> #include <sstream> #include <boost/format.hpp> +#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<Value*>(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<K,V> > > { 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<typename K, typename V> @@ -119,7 +115,7 @@ ostream& operator<<(ostream& out, const Env<K,V>& env) { * Lexer: Text (istream) -> S-Expressions (SExp) * ***************************************************************************/ -class AST; +struct AST; AST* readExpression(Cursor& cur, std::istream& in); |