added more lifters :yawn:

merge-requests/12/head
_xeroxz 3 years ago
parent ea078d9847
commit 65ae6ebe02

@ -32,16 +32,16 @@ namespace vm
lconstbsxdw; lconstbsxdw;
static lifter_callback_t addq, adddw, addw, addb; static lifter_callback_t addq, adddw, addw, addb;
static lifter_callback_t sregq, sregdw, sregb; static lifter_callback_t sregq, sregdw, sregw, sregb;
static lifter_callback_t lregq, lregdw; static lifter_callback_t lregq, lregdw;
static lifter_callback_t imulq, imuldw; static lifter_callback_t imulq, imuldw;
static lifter_callback_t pushvsp; static lifter_callback_t pushvsp;
static lifter_callback_t popvsp; static lifter_callback_t popvsp;
static lifter_callback_t writeq, writedw, writeb; static lifter_callback_t writeq, writedw, writew, writeb;
static lifter_callback_t readq, readdw, readw, readb; static lifter_callback_t readq, readdw, readw, readb;
static lifter_callback_t nandq, nanddw, nandw, nandb; static lifter_callback_t nandq, nanddw, nandw, nandb;
static lifter_callback_t shrq, shrdw; static lifter_callback_t shrq, shrdw;
static lifter_callback_t shlq; static lifter_callback_t shlq, shldw;
static lifter_callback_t jmp; static lifter_callback_t jmp;
static lifter_callback_t lflagsq; static lifter_callback_t lflagsq;
static lifter_callback_t vmexit; static lifter_callback_t vmexit;
@ -63,12 +63,14 @@ namespace vm
{ vm::handler::SHRQ, &shrq }, { vm::handler::SHRQ, &shrq },
{ vm::handler::SHRDW, &shrdw }, { vm::handler::SHRDW, &shrdw },
{ vm::handler::SHLQ, &shlq }, { vm::handler::SHLQ, &shlq },
{ vm::handler::SHLDW, &shldw },
{ vm::handler::IMULQ, &imulq }, { vm::handler::IMULQ, &imulq },
{ vm::handler::IMULDW, &imuldw }, { vm::handler::IMULDW, &imuldw },
{ vm::handler::PUSHVSPQ, &pushvsp }, { vm::handler::PUSHVSPQ, &pushvsp },
{ vm::handler::POPVSPQ, &popvsp }, { vm::handler::POPVSPQ, &popvsp },
{ vm::handler::SREGQ, &sregq }, { vm::handler::SREGQ, &sregq },
{ vm::handler::SREGDW, &sregdw }, { vm::handler::SREGDW, &sregdw },
{ vm::handler::SREGW, &sregw },
{ vm::handler::SREGB, &sregb }, { vm::handler::SREGB, &sregb },
{ vm::handler::LREGQ, &lregq }, { vm::handler::LREGQ, &lregq },
{ vm::handler::LREGDW, &lregdw }, { vm::handler::LREGDW, &lregdw },
@ -78,6 +80,7 @@ namespace vm
{ vm::handler::READB, &readb }, { vm::handler::READB, &readb },
{ vm::handler::WRITEQ, &writeq }, { vm::handler::WRITEQ, &writeq },
{ vm::handler::WRITEDW, &writedw }, { vm::handler::WRITEDW, &writedw },
{ vm::handler::WRITEW, &writew },
{ vm::handler::WRITEB, &writeb }, { vm::handler::WRITEB, &writeb },
{ vm::handler::NANDQ, &nandq }, { vm::handler::NANDQ, &nandq },
{ vm::handler::NANDDW, &nanddw }, { vm::handler::NANDDW, &nanddw },

@ -16,4 +16,19 @@ namespace vm
rtn->push( 8, t4 ); rtn->push( 8, t4 );
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) ); rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
}; };
}
lifters_t::lifter_callback_t lifters_t::shldw =
[ & ]( 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( 2 );
auto t3 = ir_builder->CreateIntCast( t2, llvm::IntegerType::get( *rtn->llvm_ctx, 32 ), false );
auto t4 = ir_builder->CreateShl( t1, t3 );
auto &vmp_rtn = rtn->vmp_rtns.back();
// TODO: update rflags...
rtn->push( 4, t4 );
rtn->push( 8, rtn->load_value( 8, vmp_rtn->flags ) );
};
} // namespace vm

@ -20,6 +20,17 @@ namespace vm
ir_builder->CreateStore( ir_builder->CreateIntCast( t1, ir_builder->getInt64Ty(), false ), vreg ); ir_builder->CreateStore( ir_builder->CreateIntCast( t1, ir_builder->getInt64Ty(), false ), vreg );
}; };
lifters_t::lifter_callback_t lifters_t::sregw =
[ & ]( 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 &vmp_rtn = rtn->vmp_rtns.back();
auto vreg = vmp_rtn->virtual_registers[ vinstr.operand.imm.u ? vinstr.operand.imm.u / 8 : 0 ];
ir_builder->CreateStore(
ir_builder->CreateIntCast( t1, ir_builder->getInt16Ty(), false ),
ir_builder->CreatePointerCast( vreg, llvm::PointerType::get( ir_builder->getInt16Ty(), 0ull ) ) );
};
lifters_t::lifter_callback_t lifters_t::sregb = lifters_t::lifter_callback_t lifters_t::sregb =
[ & ]( vm::devirt_t *rtn, const vm::instrs::code_block_t &vm_code_block, const vm::instrs::virt_instr_t &vinstr, [ & ]( 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::IRBuilder<> *ir_builder ) {

@ -20,6 +20,15 @@ namespace vm
ir_builder->CreateStore( t2, t3 ); ir_builder->CreateStore( t2, t3 );
}; };
lifters_t::lifter_callback_t lifters_t::writew =
[ & ]( 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->CreateIntToPtr( t1, llvm::PointerType::get( ir_builder->getInt16Ty(), 0ull ) );
ir_builder->CreateStore( t2, t3 );
};
lifters_t::lifter_callback_t lifters_t::writeb = lifters_t::lifter_callback_t lifters_t::writeb =
[ & ]( vm::devirt_t *rtn, const vm::instrs::code_block_t &vm_code_block, const vm::instrs::virt_instr_t &vinstr, [ & ]( 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::IRBuilder<> *ir_builder ) {

Loading…
Cancel
Save