2019-01-07 04:08:55 -05:00
|
|
|
#ifndef TDL_INCLUDE_CODEGEN_SELECTION_H
|
|
|
|
#define TDL_INCLUDE_CODEGEN_SELECTION_H
|
2019-01-05 14:50:31 -05:00
|
|
|
|
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/IR/IRBuilder.h"
|
|
|
|
#include "ir/context.h"
|
|
|
|
#include "ir/module.h"
|
|
|
|
#include "ir/function.h"
|
|
|
|
#include "ir/type.h"
|
|
|
|
|
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
namespace llvm{
|
|
|
|
class Type;
|
|
|
|
class Value;
|
|
|
|
class Instruction;
|
|
|
|
class Constant;
|
|
|
|
class LLVMContext;
|
2019-01-05 14:50:31 -05:00
|
|
|
}
|
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
namespace tdl{
|
|
|
|
namespace codegen{
|
2019-01-05 19:23:00 -05:00
|
|
|
|
2019-01-12 23:24:25 -05:00
|
|
|
class allocation;
|
|
|
|
|
|
|
|
struct distributed_axis {
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
class selection{
|
|
|
|
typedef std::map<ir::value *, llvm::Value *> vmap_t;
|
|
|
|
typedef std::map<ir::basic_block *, llvm::BasicBlock *> bmap_t;
|
2019-01-05 19:23:00 -05:00
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
private:
|
|
|
|
llvm::Type* llvm_type(ir::type *ty, llvm::LLVMContext &ctx);
|
|
|
|
llvm::Value* llvm_value(ir::value *v,llvm:: LLVMContext &ctx);
|
|
|
|
llvm::Instruction* llvm_inst(ir::instruction *inst, llvm::LLVMContext &ctx);
|
|
|
|
llvm::Constant* llvm_constant(ir::constant *cst, llvm::LLVMContext &ctx);
|
2019-01-05 14:50:31 -05:00
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
public:
|
2019-01-12 23:24:25 -05:00
|
|
|
selection(allocation *alloc): alloc_(alloc){ }
|
2019-01-07 22:44:26 -05:00
|
|
|
void run(ir::module &src, llvm::Module &dst);
|
2019-01-05 19:23:00 -05:00
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
private:
|
|
|
|
vmap_t vmap_;
|
|
|
|
bmap_t bmap_;
|
2019-01-12 23:24:25 -05:00
|
|
|
allocation *alloc_;
|
2019-01-05 14:50:31 -05:00
|
|
|
|
2019-01-07 22:44:26 -05:00
|
|
|
};
|
2019-01-05 14:50:31 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|