Browse Source

Add a special OP for retrieving the frame pointer

previousely this was handeled by incoming_reg however the register allocator
doesn't allow to move registers from different reg classes.
Nesting is tested on x86-86, x86 and the interpreter.
pull/15/head
Jakob Löw 6 years ago
parent
commit
00f8f12fb8
  1. 5
      attic/jit-rules-alpha.ins
  2. 3
      jit/jit-dump.c
  3. 30
      jit/jit-insn.c
  4. 8
      jit/jit-interp.c
  5. 1
      jit/jit-opcodes.ops
  6. 5
      jit/jit-rules-arm.ins
  7. 5
      jit/jit-rules-x86-64.ins
  8. 5
      jit/jit-rules-x86.ins
  9. 3
      jit/jit-rules.c

5
attic/jit-rules-alpha.ins

@ -450,6 +450,11 @@ JIT_OP_RETURN_REG: manual
/* Nothing to do here */;
}
JIT_OP_RETRIEVE_FRAME_POINTER: note
[=reg] -> {
alpha_mov(inst,$1,ALPHA_FP);
}
JIT_OP_PUSH_INT: note
[imm] -> {
alpha_li(inst,ALPHA_AT,$1);

3
jit/jit-dump.c

@ -794,7 +794,8 @@ void jit_dump_function(FILE *stream, jit_function_t func, const char *name)
putc('[', stream);
if(func->nested_parent)
{
fputs("parent_frame", stream);
jit_dump_value(stream, func, func->parent_frame, 0);
fputs(" : parent_frame", stream);
if(value)
{
fputs(", ", stream);

30
jit/jit-insn.c

@ -6292,34 +6292,8 @@ jit_insn_flush_struct(jit_function_t func, jit_value_t value)
jit_value_t
jit_insn_get_frame_pointer(jit_function_t func)
{
int reg;
jit_value_t value;
value = jit_value_create(func, jit_type_void_ptr);
if(!value)
{
return 0;
}
for(reg = 0; reg < JIT_NUM_REGS; reg++)
{
if(jit_reg_flags(reg) & JIT_REG_FRAME)
{
break;
}
}
if(reg < JIT_NUM_REGS)
{
jit_insn_incoming_reg(func, value, reg);
}
else
{
jit_insn_incoming_frame_posn(func, value, 0);
value = jit_insn_address_of(func, value);
}
return value;
return create_dest_note(func, JIT_OP_RETRIEVE_FRAME_POINTER,
jit_type_void_ptr);
}
static jit_value_t

8
jit/jit-interp.c

@ -4892,6 +4892,14 @@ restart_tail:
* Stack management.
******************************************************************/
VMCASE(JIT_OP_RETRIEVE_FRAME_POINTER):
{
/* Move the frame pointer into the register 0 */
VM_R0_PTR = frame;
VM_MODIFY_PC(1);
}
VMBREAK;
VMCASE(JIT_OP_POP_STACK):
{
/* Pop a specific number of items from the stack */

1
jit/jit-opcodes.ops

@ -797,6 +797,7 @@ opcodes(JIT_OP_, "jit_opcode_info_t const jit_opcodes[JIT_OP_NUM_OPCODES]")
op_def("outgoing_reg") { op_type(reg) }
op_def("outgoing_frame_posn") { op_values(empty, any, int) }
op_def("return_reg") { op_type(reg) }
op_def("retrieve_frame_pointer") { op_values(any, empty, empty) }
op_def("push_int") { op_values(empty, int) }
op_def("push_long") { op_values(empty, long) }
op_def("push_float32") { op_values(empty, float32) }

5
jit/jit-rules-arm.ins

@ -1322,6 +1322,11 @@ JIT_OP_INCOMING_REG, JIT_OP_RETURN_REG: note
*/
}
JIT_OP_RETRIEVE_FRAME_POINTER: note
[=reg] -> {
arm_mov_reg_reg(inst, $1, ARM_FP);
}
JIT_OP_PUSH_INT: note
[reg] -> {
arm_push_reg(inst, $1);

5
jit/jit-rules-x86-64.ins

@ -388,6 +388,11 @@ JIT_OP_INCOMING_REG, JIT_OP_RETURN_REG: note
*/
}
JIT_OP_RETRIEVE_FRAME_POINTER: note
[=reg] -> {
x86_64_mov_reg_reg_size(inst, $1, X86_64_RBP, 8);
}
JIT_OP_PUSH_INT: note
[imm] -> {
x86_64_push_imm(inst, $1);

5
jit/jit-rules-x86.ins

@ -1993,6 +1993,11 @@ JIT_OP_INCOMING_REG, JIT_OP_RETURN_REG: note
*/
}
JIT_OP_RETRIEVE_FRAME_POINTER: note
[=reg] -> {
x86_mov_reg_reg(inst, $1, X86_EBP, 4);
}
JIT_OP_PUSH_INT: note
[imm] -> {
x86_push_imm(inst, $1);

3
jit/jit-rules.c

@ -172,7 +172,8 @@ int _jit_create_entry_insns(jit_function_t func)
{
return 0;
}
func->builder->parent_frame = value;
jit_function_set_parent_frame(func, value);
if(!alloc_incoming_word(func, &passing, value, 0))
{
return 0;

Loading…
Cancel
Save