Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 13 additions & 14 deletions codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@

#include <map>

#include <llvm/Analysis/Verifier.h>
#include <llvm/Constants.h>
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
#include <llvm/IntrinsicInst.h>
#include <llvm/Module.h>

// In LLVM 3.2, this becomes <llvm/DataLayout.h>
#include <llvm/Target/TargetData.h>
#include <llvm/IR/Verifier.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/DataLayout.h>

#include "expand_constantexpr.h"
#include "expand_getelementptr.h"
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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<uint32_t*,llvm::BasicBlock*> JumpReloc;
Expand Down Expand Up @@ -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 <llvm/IR/Instruction.def>
#undef HANDLE_INST
default: return "<unknown-instruction>";
}
Expand Down Expand Up @@ -1298,7 +1297,7 @@ void translate_function(llvm::Function *func, CodeBuf &codebuf) {

void translate(llvm::Module *module, std::map<std::string,uintptr_t> *globals,
CodeGenOptions *options) {
llvm::TargetData data_layout(module);
llvm::DataLayout data_layout(module);
CodeBuf codebuf(&data_layout, options);

llvm::ModulePass *expand_varargs = createExpandVarArgsPass();
Expand Down
2 changes: 1 addition & 1 deletion codegen.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include <map>

#include <llvm/Module.h>
#include <llvm/IR/Module.h>

class CodeGenOptions {
public:
Expand Down
5 changes: 3 additions & 2 deletions codegen_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include <stdio.h>
#include <sys/mman.h>

#include <llvm/LLVMContext.h>
#include <llvm/Support/IRReader.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IRReader/IRReader.h>
#include <llvm/Support/SourceMgr.h>

#include "arithmetic_test.h"
#include "codegen.h"
Expand Down
14 changes: 7 additions & 7 deletions expand_constantexpr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

#include "expand_constantexpr.h"

#include <llvm/BasicBlock.h>
#include <llvm/Constants.h>
#include <llvm/Function.h>
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
#include <llvm/Module.h>
#include <llvm/Operator.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Module.h>
#include <llvm/IR/Operator.h>
#include <llvm/Pass.h>

using namespace llvm;
Expand Down
18 changes: 8 additions & 10 deletions expand_getelementptr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@

#include "expand_getelementptr.h"

#include <llvm/BasicBlock.h>
#include <llvm/Constants.h>
#include <llvm/Function.h>
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
#include <llvm/Module.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/Module.h>
#include <llvm/Pass.h>

// In LLVM 3.2, this becomes <llvm/DataLayout.h>
#include <llvm/Target/TargetData.h>
#include <llvm/IR/DataLayout.h>

using namespace llvm;

Expand All @@ -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(); ) {
Expand Down
22 changes: 10 additions & 12 deletions expand_varargs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@

#include "expand_varargs.h"

#include <llvm/BasicBlock.h>
#include <llvm/Constants.h>
#include <llvm/Function.h>
#include <llvm/InstrTypes.h>
#include <llvm/Instructions.h>
#include <llvm/IntrinsicInst.h>
#include <llvm/Module.h>
#include <llvm/IR/BasicBlock.h>
#include <llvm/IR/Constants.h>
#include <llvm/IR/Function.h>
#include <llvm/IR/InstrTypes.h>
#include <llvm/IR/Instructions.h>
#include <llvm/IR/IntrinsicInst.h>
#include <llvm/IR/Module.h>
#include <llvm/Pass.h>

// In LLVM 3.2, this becomes <llvm/DataLayout.h>
#include <llvm/Target/TargetData.h>
#include <llvm/IR/DataLayout.h>

using namespace llvm;

Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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++;
Expand Down
6 changes: 3 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="$(
Expand Down Expand Up @@ -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 \
Expand Down
5 changes: 3 additions & 2 deletions run_program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#include <stdio.h>
#include <sys/mman.h>

#include <llvm/LLVMContext.h>
#include <llvm/Support/IRReader.h>
#include <llvm/IR/LLVMContext.h>
#include <llvm/IRReader/IRReader.h>
#include <llvm/Support/SourceMgr.h>

#include "codegen.h"
#include "nacl_irt_interfaces.h"
Expand Down