Commit eea57455 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed a bug when passing 128-bit integers on the stack. Also added a...

Fixed a bug when passing 128-bit integers on the stack. Also added a diagnostic message of the entry function returns.
parent 81a87444
......@@ -2783,7 +2783,8 @@ impl <'a> InstructionSelection {
// Everything else is simple
_ => {
if is_int_ex_reg(&arg_val) {
// Need to pass in two registers
if is_int_ex_reg(&arg_val) && arg_loc.is_reg() {
let (val_l, val_h) = split_int128(&arg_val, f_context, vm);
let arg_loc_h = get_register_from_id(arg_loc.id() + 2);
......
......@@ -1701,6 +1701,7 @@ fn emit_reg_value(backend: &mut CodeGenerator, pv: &P<Value>, f_context: &mut Fu
tmp
//}
},
&Constant::IntEx(ref val) => { unimplemented!() },
&Constant::FuncRef(func_id) => {
let tmp = make_temporary(f_context, pv.ty.clone(), vm);
......@@ -1750,8 +1751,13 @@ pub fn emit_ireg_value(backend: &mut CodeGenerator, pv: &P<Value>, f_context: &m
tmp
//}
},
&Constant::FuncRef(_) => {
unimplemented!();
&Constant::IntEx(ref val) => { unimplemented!() },
&Constant::FuncRef(func_id) => {
let tmp = make_temporary(f_context, pv.ty.clone(), vm);
let mem = make_value_symbolic(vm.get_func_name(func_id), true, &ADDRESS_TYPE, vm);
emit_calculate_address(backend, &tmp, &mem, f_context, vm);
tmp
},
&Constant::NullRef => {
let tmp = make_temporary(f_context, pv.ty.clone(), vm);
......@@ -1813,7 +1819,6 @@ pub fn emit_ireg_ex_value(backend: &mut CodeGenerator, pv: &P<Value>, f_context:
emit_mov_u64(backend, &tmp_h, val[1]);
(tmp_l, tmp_h)
},
_ => panic!("expected ireg_ex")
}
......
......@@ -1910,8 +1910,11 @@ impl <'a> InstructionSelection {
}
}
128 => {
let reg_op1 = self.emit_ireg(&op1, f_content, f_context, vm);
let reg_op2 = self.emit_ireg(&op2, f_content, f_context, vm);
self.emit_runtime_entry(&entrypoints::UDIV_U128,
vec![op1.clone(), op2.clone()],
vec![reg_op1, reg_op2],
Some(vec![res_tmp.clone()]),
Some(node), f_content, f_context, vm);
}
......@@ -1941,8 +1944,11 @@ impl <'a> InstructionSelection {
}
}
128 => {
let reg_op1 = self.emit_ireg(&op1, f_content, f_context, vm);
let reg_op2 = self.emit_ireg(&op2, f_content, f_context, vm);
self.emit_runtime_entry(&entrypoints::SDIV_I128,
vec![op1.clone(), op2.clone()],
vec![reg_op1, reg_op2],
Some(vec![res_tmp.clone()]),
Some(node), f_content, f_context, vm);
}
......@@ -1972,10 +1978,14 @@ impl <'a> InstructionSelection {
}
}
128 => {
let reg_op1 = self.emit_ireg(&op1, f_content, f_context, vm);
let reg_op2 = self.emit_ireg(&op2, f_content, f_context, vm);
self.emit_runtime_entry(&entrypoints::UREM_U128,
vec![op1.clone(), op2.clone()],
vec![reg_op1, reg_op2],
Some(vec![res_tmp.clone()]),
Some(node), f_content, f_context, vm);
}
_ => unimplemented!()
}
......@@ -2003,8 +2013,11 @@ impl <'a> InstructionSelection {
}
}
128 => {
let reg_op1 = self.emit_ireg(&op1, f_content, f_context, vm);
let reg_op2 = self.emit_ireg(&op2, f_content, f_context, vm);
self.emit_runtime_entry(&entrypoints::SREM_I128,
vec![op1.clone(), op2.clone()],
vec![reg_op1, reg_op2],
Some(vec![res_tmp.clone()]),
Some(node), f_content, f_context, vm);
}
......@@ -3840,6 +3853,7 @@ impl <'a> InstructionSelection {
self.backend.emit_mov_r64_imm64(&tmp, val as i64);
}
},
&Constant::IntEx(ref vals) => { unimplemented!() },
&Constant::FuncRef(func_id) => {
if cfg!(target_os = "macos") {
let mem = self.get_mem_for_funcref(func_id, vm);
......
......@@ -24,23 +24,41 @@ begin_func swap_to_mu_stack
# -- on new stack --
# arguments (reverse order of thread.rs - runtime_load_args)
pop_arguments
//enter_frame // Unncesary Note saves the return address of the function that called this function
# If entry tries to return (IT SHOULDN'T) it will return to entry_returned
# If entry tries to return (IT SHOULDN'T) it will call entry_returned (which will panic!)
ADR LR, entry_returned
# branch to entry
RET X9
end_func swap_to_mu_stack
# For debuging only, executes
# The error message to print when entry returns
.type .Lentry_returned_message, @object
.section .rodata.str1.1,"aMS",@progbits,1
.Lentry_returned_message:
.asciz "ERROR: The entry function returned\n"
.size .Lentry_returned_message, 36
# Prints an error mesage and calls exit(1)
begin_func entry_returned
HLT #0
end_func entry_returned
ADRP x0, .Lentry_returned_message
ADD x0, x0, :lo12:.Lentry_returned_message // Loads x0 with the adress of .Lentry_returned_message
MOV X1, #35 // Length of string
MOV X2, #1 // Number of elements
ADRP X3, :got:stderr
LDR X3, [X3, :got_lo12:stderr]
LDR X3, [X3] // Load X3 with the address of stderr
BL fwrite // calls fwrite(x0, x1, x2, x3)
MOV W0, 1
BL exit // call exit(1)
end_func entry_returned
# _swap_back_to_native_stack(sp_loc: Address)
# X0
// _swap_back_to_native_stack(sp_loc: Address)
// X0
begin_func muentry_swap_back_to_native_stack
# SP = *sp_loc
LDR X9, [X0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment