#include "jit-reg-alloc.h"
#include "jit-setjmp.h"
#include <stdio.h>
+#include <stdlib.h>
/*
* Pseudo register numbers for the ARM registers. These are not the
* Get a temporary register that isn't one of the specified registers.
* When this function is used EVERY REGISTER COULD BE DESTROYED!!!
* TODO: this function is only used by JIT_OP_STORE_RELATIVE_STRUCT, through memory_copy: remove
- * the need of using it by sustituting it with register allocation with [scratch reg]
+ * the need of using it by substituting it with register allocation with [scratch reg]
*/
static int get_temp_reg(int reg1, int reg2, int reg3)
{
/* We don't have to do anything to free ARM registers */
}
+/*
+ * Loads the content of the value @var{value} into register @var{reg} and (if needed) @var{other_reg}
+ */
void _jit_gen_load_value
(jit_gencode_t gen, int reg, int other_reg, jit_value_t value)
{
break;
}
}
- else if(value->has_global_register)
+ else if(value->in_global_register)
{
- /*
- * This value has been assinged a global register. This means
- * that it can use that register, but not necessarily that it's
- * already in it!!
- */
-
- /* Ensure that the value is already in the global_register */
- if (!value->in_global_register)
- {
- /* Find the other register in a long pair */
- int reg = value->reg;
- int other_reg = jit_reg_current_other_reg(gen,reg);
-
- //Spill to the global register
- _jit_gen_spill_reg(gen, reg, other_reg, value);
- value->in_global_register=1;
-
- /* A new instruction has probably been generated by _jit_gen_spill_reg: reload the inst pointer */
- jit_gen_load_inst_ptr(gen, inst);
- }
/* Load the value out of a global register */
if(IS_FLOAT_REG(reg))
{
/* Load into a floating point register */
#ifdef JIT_ARM_HAS_VFP
- /* Vector floating point instructions */
+ /* Vector Floating Point instructions */
if(jit_type_normalize(value->type)->kind == JIT_TYPE_FLOAT32)
{
arm_mov_float_reg(inst,
}
#endif
#ifdef JIT_ARM_HAS_FPA
+ /* Floating Point Architecture instructions */
TODO();
abort();
#endif
_jit_reg_info[value->global_reg].cpu_reg);
}
}
+ else if(value->in_register)
+ {
+ /* The value is already in another register. Move it */
+ switch(jit_type_normalize(value->type)->kind)
+ {
+ case JIT_TYPE_SBYTE:
+ case JIT_TYPE_UBYTE:
+ case JIT_TYPE_SHORT:
+ case JIT_TYPE_USHORT:
+ case JIT_TYPE_INT:
+ case JIT_TYPE_UINT:
+ {
+ arm_mov_reg_reg(inst, jit_reg_code(reg), jit_reg_code(value->reg));
+ }
+ break;
+
+ case JIT_TYPE_LONG:
+ case JIT_TYPE_ULONG:
+ {
+ assert(jit_reg_code(other_reg) !=-1);
+ assert(jit_reg_other_reg(value->reg) != -1);
+
+ arm_mov_reg_reg(inst, jit_reg_code(reg), jit_reg_code(value->reg));
+ arm_mov_reg_reg(inst, jit_reg_code(other_reg), jit_reg_other_reg(value->reg));
+ }
+ break;
+
+ case JIT_TYPE_FLOAT32:
+ {
+#ifdef JIT_ARM_HAS_VFP
+ /* Vector Floating Point instructions */
+ if(IS_FLOAT_REG(reg))
+ {
+ if(IS_WORD_REG(value->reg))
+ {
+ arm_mov_float_reg(inst,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ else
+ {
+ arm_alu_freg_32(inst, ARM_MVF,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ }
+ else
+ {
+ if(IS_WORD_REG(value->reg))
+ {
+ arm_mov_reg_reg(inst,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ else
+ {
+ arm_mov_reg_float(inst,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ }
+#endif
+#ifdef JIT_ARM_HAS_FPA
+ /* Floating Point Architecture instructions */
+ TODO();
+ abort();
+#endif
+ }
+ break;
+
+ case JIT_TYPE_FLOAT64:
+ case JIT_TYPE_NFLOAT:
+ {
+#ifdef JIT_ARM_HAS_VFP
+ /* Vector Floating Point instruction */
+ if(IS_FLOAT_REG(reg))
+ {
+ if(IS_WORD_REG(value->reg))
+ {
+ assert(jit_reg_other_reg(value->reg) != -1);
+
+ arm_mov_double_reg_reg(inst,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg),
+ jit_reg_other_reg(value->reg));
+ }
+ else
+ {
+ arm_alu_freg(inst, ARM_MVF,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ }
+ else
+ {
+ if(IS_WORD_REG(value->reg))
+ {
+ arm_mov_reg_reg(inst,
+ jit_reg_code(reg),
+ jit_reg_code(value->reg));
+ }
+ else
+ {
+ assert(jit_reg_other_reg(reg));
+ arm_mov_reg_reg_double(inst,
+ jit_reg_code(reg),
+ jit_reg_other_reg(reg),
+ jit_reg_code(value->reg));
+ }
+ }
+#endif
+#ifdef JIT_ARM_HAS_FPA
+ /* Floating Point Architecture instructions */
+ TODO();
+ abort();
+#endif
+ }
+ break;
+ }
+ }
else
{
+ /* Load from the stack */
+ assert(!value->in_global_register && !value->is_constant && !value->in_register);
+
/* Fix the position of the value in the stack frame */
_jit_gen_fix_value(value);
offset = (int)(value->frame_offset);
- /* Ensure that the value is already in the stack frame */
- if(value->in_register)
- {
- /* Find the other register in a long pair */
- int reg = value->reg;
- int other_reg = jit_reg_current_other_reg(gen,reg);
-
- _jit_gen_spill_reg(gen, reg, other_reg, value);
- value->in_frame=1;
-
- /* A new instruction has probably been generated by _jit_gen_spill_reg: reload the inst pointer */
- jit_gen_load_inst_ptr(gen, inst);
- }
-
switch(jit_type_normalize(value->type)->kind)
{
case JIT_TYPE_SBYTE: