added more lifters...

merge-requests/12/head
_xeroxz 3 years ago
parent b82072e2ed
commit aaf0e9defe

@ -35,13 +35,13 @@ namespace vm
static lifter_callback_t sregq, sregdw, sregw, sregb;
static lifter_callback_t lregq, lregdw;
static lifter_callback_t imulq, imuldw;
static lifter_callback_t mulq;
static lifter_callback_t mulq, muldw;
static lifter_callback_t pushvsp;
static lifter_callback_t popvsp;
static lifter_callback_t writeq, writedw, writew, writeb;
static lifter_callback_t readq, readdw, readw, readb;
static lifter_callback_t nandq, nanddw, nandw, nandb;
static lifter_callback_t shrq, shrdw, shrw;
static lifter_callback_t shrq, shrdw, shrw, shrb;
static lifter_callback_t shlq, shldw;
static lifter_callback_t shlddw;
static lifter_callback_t shrdq, shrddw;
@ -73,6 +73,7 @@ namespace vm
{ vm::handler::SHRQ, &shrq },
{ vm::handler::SHRDW, &shrdw },
{ vm::handler::SHRW, &shrw },
{ vm::handler::SHRB, &shrb },
{ vm::handler::SHLQ, &shlq },
{ vm::handler::SHLDW, &shldw },
{ vm::handler::SHLDDW, &shlddw },
@ -81,6 +82,7 @@ namespace vm
{ vm::handler::IMULQ, &imulq },
{ vm::handler::IMULDW, &imuldw },
{ vm::handler::MULQ, &mulq },
{ vm::handler::MULDW, &muldw },
{ vm::handler::PUSHVSPQ, &pushvsp },
{ vm::handler::POPVSPQ, &popvsp },
{ vm::handler::SREGQ, &sregq },
@ -131,4 +133,4 @@ namespace vm
return true;
}
};
} // namespace vm
} // namespace vm

@ -15,6 +15,24 @@ namespace vm
rtn->push( 8, t4 );
rtn->push( 8, t5 );
// TODO: compute flags for IMULQ
auto &vmp_rtn = rtn->vmp_rtns.back();
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
};
lifters_t::lifter_callback_t lifters_t::muldw =
[ & ]( 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( 4 );
auto t2 = rtn->pop( 4 );
// TODO: this is wrong... still need to do some more research into this...
auto t3 = ir_builder->CreateMul( t1, t2 );
auto t4 = ir_builder->CreateAShr( t3, llvm::APInt( 32, 16 ) );
auto t5 = ir_builder->CreateAnd( t3, 0xFFFF0000 );
rtn->push( 4, t4 );
rtn->push( 4, t5 );
// TODO: compute flags for IMULQ
auto &vmp_rtn = rtn->vmp_rtns.back();
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );

@ -53,13 +53,28 @@ namespace vm
llvm::IRBuilder<> *ir_builder ) {
auto t1 = rtn->pop( 2 );
auto t2 = rtn->pop( 2 );
auto t3 = ir_builder->CreateIntCast( t2, llvm::IntegerType::get( *rtn->llvm_ctx, 16 ), false );
auto t4 = ir_builder->CreateLShr( t1, t3 );
auto t3 = ir_builder->CreateLShr( t1, t2 );
auto &vmp_rtn = rtn->vmp_rtns.back();
auto flags = lifters_t::shr_flags( rtn, 2, t1, t2, t3 );
ir_builder->CreateStore( flags, vmp_rtn->flags );
rtn->push( 2, t3 );
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
};
lifters_t::lifter_callback_t lifters_t::shrb =
[ & ]( 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( 2 );
auto t2 = rtn->pop( 2 );
auto t3 = ir_builder->CreateIntCast( t1, ir_builder->getInt8Ty(), false );
auto t4 = ir_builder->CreateIntCast( t2, ir_builder->getInt8Ty(), false );
auto t5 = ir_builder->CreateLShr( t3, t4 );
auto &vmp_rtn = rtn->vmp_rtns.back();
auto flags = lifters_t::shr_flags( rtn, 2, t1, t3, t4 );
auto flags = lifters_t::shr_flags( rtn, 1, t3, t4, t5 );
ir_builder->CreateStore( flags, vmp_rtn->flags );
rtn->push( 2, t4 );
rtn->push( 2, ir_builder->CreateIntCast( t5, ir_builder->getInt16Ty(), false ) );
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
};
} // namespace vm
Loading…
Cancel
Save