|
|
|
#pragma once
|
|
|
|
#include <vmprofiler.hpp>
|
|
|
|
|
|
|
|
#include "llvm/IR/BasicBlock.h"
|
|
|
|
#include "llvm/IR/Constants.h"
|
|
|
|
#include "llvm/IR/DerivedTypes.h"
|
|
|
|
#include "llvm/IR/Function.h"
|
|
|
|
#include "llvm/IR/IRBuilder.h"
|
|
|
|
#include "llvm/IR/IRPrintingPasses.h"
|
|
|
|
#include "llvm/IR/LLVMContext.h"
|
|
|
|
#include "llvm/IR/Module.h"
|
|
|
|
#include "llvm/IR/PassManager.h"
|
|
|
|
#include "llvm/IR/Type.h"
|
|
|
|
#include "llvm/IR/Verifier.h"
|
|
|
|
#include "llvm/Pass.h"
|
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
namespace vm
|
|
|
|
{
|
|
|
|
class vmp_rtn_t
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit vmp_rtn_t( llvm::LLVMContext *llvm_ctx, llvm::Module *llvm_module, std::uintptr_t rtn_begin,
|
|
|
|
std::vector< vm::instrs::code_block_t > vmp2_code_blocks );
|
|
|
|
|
|
|
|
llvm::Function *lift( void );
|
|
|
|
llvm::LLVMContext *llvm_ctx;
|
|
|
|
llvm::Module *llvm_module;
|
|
|
|
private:
|
|
|
|
std::uintptr_t rtn_begin;
|
|
|
|
llvm::Function *llvm_fptr;
|
|
|
|
std::shared_ptr< llvm::IRBuilder<> > ir_builder;
|
|
|
|
llvm::AllocaInst *virutal_registers, *virtual_stack;
|
|
|
|
std::vector< llvm::BasicBlock * > llvm_code_blocks;
|
|
|
|
std::vector< vm::instrs::code_block_t > vmp2_code_blocks;
|
|
|
|
};
|
|
|
|
} // namespace vm
|