parent
4fe8c63f49
commit
93402767a9
@ -0,0 +1,26 @@
|
|||||||
|
#include <vm_lifters.hpp>
|
||||||
|
|
||||||
|
namespace vm
|
||||||
|
{
|
||||||
|
lifters_t::lifter_callback_t lifters_t::readcr8 =
|
||||||
|
[ & ]( vm::devirt_t *rtn, const vm::instrs::code_block_t &vm_code_block, const vm::instrs::virt_instr_t &vinstr,
|
||||||
|
llvm::IRBuilder<> *ir_builder ) {
|
||||||
|
llvm::Function *readcr8_intrin = nullptr;
|
||||||
|
if ( !( readcr8_intrin = rtn->llvm_module->getFunction( "readcr8" ) ) )
|
||||||
|
{
|
||||||
|
readcr8_intrin = llvm::Function::Create( llvm::FunctionType::get( ir_builder->getInt64Ty(), false ),
|
||||||
|
llvm::GlobalValue::LinkageTypes::ExternalLinkage );
|
||||||
|
|
||||||
|
auto entry_block = llvm::BasicBlock::Create( ir_builder->getContext(), "", readcr8_intrin );
|
||||||
|
auto ib = ir_builder->GetInsertBlock();
|
||||||
|
ir_builder->SetInsertPoint( entry_block );
|
||||||
|
auto intrin = llvm::InlineAsm::get( llvm::FunctionType::get( ir_builder->getVoidTy(), false ),
|
||||||
|
"mov rax, cr8; ret", "", false, false, llvm::InlineAsm::AD_Intel );
|
||||||
|
ir_builder->CreateCall( intrin );
|
||||||
|
ir_builder->CreateRetVoid(); // TODO: dont return VOID here...
|
||||||
|
ir_builder->SetInsertPoint( ib );
|
||||||
|
}
|
||||||
|
auto t1 = ir_builder->CreateCall( readcr8_intrin );
|
||||||
|
rtn->push( 8, t1 );
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#include <vm_lifters.hpp>
|
||||||
|
|
||||||
|
namespace vm
|
||||||
|
{
|
||||||
|
lifters_t::lifter_callback_t lifters_t::shlq =
|
||||||
|
[ & ]( vm::devirt_t *rtn, const vm::instrs::code_block_t &vm_code_block, const vm::instrs::virt_instr_t &vinstr,
|
||||||
|
llvm::IRBuilder<> *ir_builder ) {
|
||||||
|
auto t1 = rtn->pop( 8 );
|
||||||
|
auto t2 = rtn->pop( 2 );
|
||||||
|
auto t3 = ir_builder->CreateIntCast( t2, llvm::IntegerType::get( *rtn->llvm_ctx, 64 ), false );
|
||||||
|
auto t4 = ir_builder->CreateShl( t1, t3 );
|
||||||
|
|
||||||
|
auto &vmp_rtn = rtn->vmp_rtns.back();
|
||||||
|
// TODO: update rflags...
|
||||||
|
|
||||||
|
rtn->push( 8, t4 );
|
||||||
|
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in new issue