aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile8
-rw-r--r--src/llvm.cpp14
-rw-r--r--src/resp.hpp14
3 files changed, 15 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 69c58b7..6b3107b 100644
--- a/Makefile
+++ b/Makefile
@@ -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);