You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
983 B
20 lines
983 B
3 years ago
|
#include <vm_lifters.hpp>
|
||
|
|
||
|
namespace vmp2::lifters
|
||
|
{
|
||
|
lifter_callback_t pushvsp = [ & ]( vm::vmp_rtn_t *rtn, const vm::instrs::code_block_t &vm_code_block,
|
||
|
const vm::instrs::virt_instr_t &vinstr, llvm::IRBuilder<> *ir_builder ) {
|
||
|
// Load the current stack index into a temporary variable
|
||
|
auto current_stack_index =
|
||
|
ir_builder->CreateLoad( llvm::IntegerType::get( *rtn->llvm_ctx, 64 ), rtn->stack_ptr, false );
|
||
|
|
||
|
// Get a pointer to the top byte of the stack
|
||
|
llvm::Value *i64_zero = llvm::ConstantInt::get( *rtn->llvm_ctx, llvm::APInt( 64, 0 ) );
|
||
|
llvm::Value *indices[ 2 ] = { i64_zero, current_stack_index };
|
||
|
auto stack_ptr =
|
||
|
ir_builder->CreateInBoundsGEP( rtn->virtual_stack, llvm::ArrayRef< llvm::Value * >( indices, 2 ) );
|
||
|
|
||
|
auto stack_ptr_val = ir_builder->CreatePtrToInt( stack_ptr, ir_builder->getInt64Ty() );
|
||
|
rtn->push( 8, stack_ptr_val );
|
||
|
};
|
||
|
}
|