diff --git a/codegen.cc b/codegen.cc index b36c762..c12f9b4 100644 --- a/codegen.cc +++ b/codegen.cc @@ -15,15 +15,13 @@ #include -#include -#include -#include -#include -#include -#include - -// In LLVM 3.2, this becomes -#include +#include +#include +#include +#include +#include +#include +#include #include "expand_constantexpr.h" #include "expand_getelementptr.h" @@ -70,7 +68,7 @@ bool is_i64(llvm::Type *ty) { return false; } -void expand_constant(llvm::Constant *val, llvm::TargetData *data_layout, +void expand_constant(llvm::Constant *val, llvm::DataLayout *data_layout, llvm::GlobalValue **result_global, uint64_t *result_offset, const char **result_unhandled) { @@ -181,11 +179,12 @@ class DataBuffer { void put_uint32(uint32_t val) { *(uint32_t *) put_alloc_space(sizeof(val)) = val; } + }; class CodeBuf : public DataBuffer { public: - CodeBuf(llvm::TargetData *data_layout_arg, CodeGenOptions *options_arg): + CodeBuf(llvm::DataLayout *data_layout_arg, CodeGenOptions *options_arg): DataBuffer(PROT_READ | PROT_WRITE | PROT_EXEC), data_segment(PROT_READ | PROT_WRITE), data_layout(data_layout_arg), @@ -487,7 +486,7 @@ class CodeBuf : public DataBuffer { int frame_vars_size; int frame_callees_args_size; - llvm::TargetData *data_layout; + llvm::DataLayout *data_layout; CodeGenOptions *options; typedef std::pair JumpReloc; @@ -556,7 +555,7 @@ const char *get_instruction_type(llvm::Instruction *inst) { switch (inst->getOpcode()) { #define HANDLE_INST(NUM, OPCODE, CLASS) \ case llvm::Instruction::OPCODE: return #OPCODE; -#include "llvm/Instruction.def" +#include #undef HANDLE_INST default: return ""; } @@ -1298,7 +1297,7 @@ void translate_function(llvm::Function *func, CodeBuf &codebuf) { void translate(llvm::Module *module, std::map *globals, CodeGenOptions *options) { - llvm::TargetData data_layout(module); + llvm::DataLayout data_layout(module); CodeBuf codebuf(&data_layout, options); llvm::ModulePass *expand_varargs = createExpandVarArgsPass(); diff --git a/codegen.h b/codegen.h index 373817f..3a9c39d 100644 --- a/codegen.h +++ b/codegen.h @@ -12,7 +12,7 @@ #include -#include +#include class CodeGenOptions { public: diff --git a/codegen_test.cc b/codegen_test.cc index 6dac74a..94d7b84 100644 --- a/codegen_test.cc +++ b/codegen_test.cc @@ -11,8 +11,9 @@ #include #include -#include -#include +#include +#include +#include #include "arithmetic_test.h" #include "codegen.h" diff --git a/expand_constantexpr.cc b/expand_constantexpr.cc index a29e71d..40ca032 100644 --- a/expand_constantexpr.cc +++ b/expand_constantexpr.cc @@ -9,13 +9,13 @@ #include "expand_constantexpr.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include using namespace llvm; diff --git a/expand_getelementptr.cc b/expand_getelementptr.cc index 0f92779..3d901c0 100644 --- a/expand_getelementptr.cc +++ b/expand_getelementptr.cc @@ -9,16 +9,14 @@ #include "expand_getelementptr.h" -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include - -// In LLVM 3.2, this becomes -#include +#include using namespace llvm; @@ -39,7 +37,7 @@ bool ExpandGetElementPtr::runOnBasicBlock(BasicBlock &bb) { bool modified = false; Module *module = bb.getParent()->getParent(); Type *ptrtype = Type::getInt32Ty(module->getContext()); - TargetData data_layout(module); + DataLayout data_layout(module); for (BasicBlock::InstListType::iterator iter = bb.begin(); iter != bb.end(); ) { diff --git a/expand_varargs.cc b/expand_varargs.cc index 66bb550..8ca4770 100644 --- a/expand_varargs.cc +++ b/expand_varargs.cc @@ -9,17 +9,15 @@ #include "expand_varargs.h" -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include #include - -// In LLVM 3.2, this becomes -#include +#include using namespace llvm; @@ -91,7 +89,7 @@ static void ExpandVarArgFunc(Function *Func) { // TODO: Update debug information too. } -static void ExpandVAArgInst(VAArgInst *Inst, TargetData *DataLayout) { +static void ExpandVAArgInst(VAArgInst *Inst, DataLayout *DataLayout) { Module *Module = Inst->getParent()->getParent()->getParent(); Type *I8 = Type::getInt8Ty(Module->getContext()); Type *I32 = Type::getInt32Ty(Module->getContext()); @@ -195,7 +193,7 @@ static bool ExpandVarArgCall(CallInst *Call) { bool ExpandVarArgs::runOnModule(Module &M) { bool Changed = false; - TargetData DataLayout(&M); + DataLayout DataLayout(&M); for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E; ) { Function *Func = Iter++; diff --git a/run.sh b/run.sh index 9a53657..80bc439 100755 --- a/run.sh +++ b/run.sh @@ -8,7 +8,7 @@ if which ccache >/dev/null 2>&1; then ccache=ccache fi -llvm_config=llvm-config-3.1 +llvm_config=llvm-config-3.5 # Filter out -O2 to reduce compile time cflags="$( @@ -52,12 +52,12 @@ g++ -m32 $lib \ codegen_test.o \ gen_arithmetic_test_c.o \ gen_arithmetic_test_ll.o \ - $($llvm_config --ldflags --libs) -ldl \ + $($llvm_config --ldflags --libs --system-libs) -ldl \ -o codegen_test g++ -m32 $lib \ run_program.o \ - $($llvm_config --ldflags --libs) -ldl \ + $($llvm_config --ldflags --libs --system-libs) -ldl \ -o run_program $ccache clang -m32 -O2 -c -emit-llvm hellow_minimal_irt.c \ diff --git a/run_program.cc b/run_program.cc index 6059ca9..aa5d140 100644 --- a/run_program.cc +++ b/run_program.cc @@ -11,8 +11,9 @@ #include #include -#include -#include +#include +#include +#include #include "codegen.h" #include "nacl_irt_interfaces.h"