]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Implement the redirector for alpha. Continue to implement more functions
authorThomas Cort <linuxgeek@gmail.com>
Sun, 23 Jul 2006 04:45:36 +0000 (04:45 +0000)
committerThomas Cort <linuxgeek@gmail.com>
Sun, 23 Jul 2006 04:45:36 +0000 (04:45 +0000)
in jit/jit-rules-alpha.c.

There is enough done on the alpha port to compile the following function
"void func(void) { return; }" and call it 1,000,000 times without anything
crashing. jit_dump_function shows a properly generated prolog and epilog.

ChangeLog
jit/jit-apply-alpha.c
jit/jit-apply-alpha.h
jit/jit-apply-func.h
jit/jit-gen-alpha.h
jit/jit-rules-alpha.c
jit/jit-rules-alpha.h
jit/jit-rules-alpha.ins

index bda8e4fac39c47e730173ec74c066b805e35842e..4d14d2c49886148ce7684ba848f5b28d29387fb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-07-23  Thomas Cort  <linuxgeek@gmail.com>
+
+       * jit/jit-apply-alpha.c jit/jit-apply-alpha.h jit/jit-apply-func.h
+       jit/jit-gen-alpha.h jit/jit-rules-alpha.c jit/jit-rules-alpha.h
+       jit/jit-rules-alpha.ins Implement the redirector for alpha. 
+       Continue to implement more functions in jit/jit-rules-alpha.c.
+
 2006-07-15  Thomas Cort  <linuxgeek@gmail.com>
 
        * jit/jit-apply-alpha.c jit/jit-gen-alpha.h jit/jit-rules-alpha.h
index 9a7646b42a242a6f72edbf239ee8792d5b4b2a3b..66c79bbaf79b39766441bfe3ab23c4dd6849e044 100644 (file)
@@ -82,18 +82,138 @@ void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_t
 void *_jit_create_redirector(unsigned char *buf, void *func, void *user_data, int abi) {
        alpha_inst inst = (alpha_inst) buf;
 
-       /* NOT IMPLEMENTED YET! */
+       /* Allocate space for a new stack frame. (1 instruction) */
+       alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(16*8));
 
-       /* Set up a new stack frame */
+       /* Save the return address. (1 instruction) */
+       alpha_stq(inst,ALPHA_RA,ALPHA_SP,0*8);
+
+       /* Save the frame pointer. (1 instruction) */
+       alpha_stq(inst,ALPHA_FP,ALPHA_SP,1*8);
+
+       /* Save the integer save registers (6 instructions) */
+       alpha_stq(inst,ALPHA_S0,ALPHA_SP,2*8);
+       alpha_stq(inst,ALPHA_S1,ALPHA_SP,3*8);
+       alpha_stq(inst,ALPHA_S2,ALPHA_SP,4*8);
+       alpha_stq(inst,ALPHA_S3,ALPHA_SP,5*8);
+       alpha_stq(inst,ALPHA_S4,ALPHA_SP,6*8);
+       alpha_stq(inst,ALPHA_S5,ALPHA_SP,7*8);
+
+       /* Save the floating point save registers (8 instructions) */
+       alpha_stt(inst,ALPHA_FS0,ALPHA_SP, 8*8);
+       alpha_stt(inst,ALPHA_FS1,ALPHA_SP, 9*8);
+       alpha_stt(inst,ALPHA_FS2,ALPHA_SP,10*8);
+       alpha_stt(inst,ALPHA_FS3,ALPHA_SP,11*8);
+       alpha_stt(inst,ALPHA_FS4,ALPHA_SP,12*8);
+       alpha_stt(inst,ALPHA_FS5,ALPHA_SP,13*8);
+       alpha_stt(inst,ALPHA_FS6,ALPHA_SP,14*8);
+       alpha_stt(inst,ALPHA_FS7,ALPHA_SP,15*8);
+
+       /* Set the frame pointer (1 instruction) */
+       alpha_mov(inst,ALPHA_SP,ALPHA_FP);
+
+       /* Force any pending hardware exceptions to be raised. (1 instruction) */
+       alpha_trapb(inst);
+
+       /* Compute and load the global pointer */
+       alpha_ldah(inst,ALPHA_GP,ALPHA_PV,0);
+       alpha_lda( inst,ALPHA_GP,ALPHA_GP,0);
 
-       /* Push the user data onto the stack "(int)(jit_nint)user_data" */      
+       /* Allocate space for a new stack frame. */
+       alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(13*8));
+
+       /* Save the return address. */
+       alpha_stq(inst,ALPHA_RA,ALPHA_SP,0*8);
+
+       /* Save integer register arguments as local variables */
+       alpha_stq(inst,ALPHA_A0,ALPHA_SP,1*8);
+       alpha_stq(inst,ALPHA_A1,ALPHA_SP,2*8);
+       alpha_stq(inst,ALPHA_A2,ALPHA_SP,3*8);
+       alpha_stq(inst,ALPHA_A3,ALPHA_SP,4*8);
+       alpha_stq(inst,ALPHA_A4,ALPHA_SP,5*8);
+       alpha_stq(inst,ALPHA_A5,ALPHA_SP,6*8);
+
+       /* Save floating-point register arguments as local variables */
+       alpha_stt(inst,ALPHA_FA0,ALPHA_SP, 7*8);
+       alpha_stt(inst,ALPHA_FA1,ALPHA_SP, 8*8);
+       alpha_stt(inst,ALPHA_FA2,ALPHA_SP, 9*8);
+       alpha_stt(inst,ALPHA_FA3,ALPHA_SP,10*8);
+       alpha_stt(inst,ALPHA_FA4,ALPHA_SP,11*8);
+       alpha_stt(inst,ALPHA_FA5,ALPHA_SP,12*8);
 
        /* Call the redirector handling function */
+       alpha_call(inst, func);
+
+       /* Restore the return address */
+       alpha_ldq(inst,ALPHA_RA,ALPHA_SP,0*8);
+
+       /* Restore integer register arguments */
+       alpha_ldq(inst,ALPHA_A0,ALPHA_SP,1*8);
+       alpha_ldq(inst,ALPHA_A1,ALPHA_SP,2*8);
+       alpha_ldq(inst,ALPHA_A2,ALPHA_SP,3*8);
+       alpha_ldq(inst,ALPHA_A3,ALPHA_SP,4*8);
+       alpha_ldq(inst,ALPHA_A4,ALPHA_SP,5*8);
+       alpha_ldq(inst,ALPHA_A5,ALPHA_SP,6*8);
+
+       /* Restore floating-point register arguments */
+       alpha_ldt(inst,ALPHA_FA0,ALPHA_SP, 7*8);
+       alpha_ldt(inst,ALPHA_FA1,ALPHA_SP, 8*8);
+       alpha_ldt(inst,ALPHA_FA2,ALPHA_SP, 9*8);
+       alpha_ldt(inst,ALPHA_FA3,ALPHA_SP,10*8);
+       alpha_ldt(inst,ALPHA_FA4,ALPHA_SP,11*8);
+       alpha_ldt(inst,ALPHA_FA5,ALPHA_SP,12*8);
+
+       /* restore the stack pointer */
+       alpha_lda(inst,ALPHA_SP,ALPHA_SP,(13*8));
+
+       /* Set the stack pointer */
+       alpha_mov(inst,ALPHA_FP,ALPHA_SP);
+
+       /* Restore the return address. (1 instruction) */
+       alpha_ldq(inst,ALPHA_RA,ALPHA_SP,0*8);
+
+       /* Restore the frame pointer. (1 instruction) */
+       alpha_ldq(inst,ALPHA_FP,ALPHA_SP,1*8);
+
+       /* Restore the integer save registers (6 instructions) */
+       alpha_ldq(inst,ALPHA_S0,ALPHA_SP,2*8);
+       alpha_ldq(inst,ALPHA_S1,ALPHA_SP,3*8);
+       alpha_ldq(inst,ALPHA_S2,ALPHA_SP,4*8);
+       alpha_ldq(inst,ALPHA_S3,ALPHA_SP,5*8);
+       alpha_ldq(inst,ALPHA_S4,ALPHA_SP,6*8);
+       alpha_ldq(inst,ALPHA_S5,ALPHA_SP,7*8);
+
+       /* Restore the floating point save registers (8 instructions) */
+       alpha_ldt(inst,ALPHA_FS0,ALPHA_SP, 8*8);
+       alpha_ldt(inst,ALPHA_FS1,ALPHA_SP, 9*8);
+       alpha_ldt(inst,ALPHA_FS2,ALPHA_SP,10*8);
+       alpha_ldt(inst,ALPHA_FS3,ALPHA_SP,11*8);
+       alpha_ldt(inst,ALPHA_FS4,ALPHA_SP,12*8);
+       alpha_ldt(inst,ALPHA_FS5,ALPHA_SP,13*8);
+       alpha_ldt(inst,ALPHA_FS6,ALPHA_SP,14*8);
+       alpha_ldt(inst,ALPHA_FS7,ALPHA_SP,15*8);
+
+       /* Restore the stack pointer (1 instruction) */
+       alpha_lda(inst,ALPHA_SP,ALPHA_SP,16*8);
+
+       /* Force any pending hardware exceptions to be raised. (1 instruction) */
+       alpha_trapb(inst);
 
        /* Jump to the function that the redirector indicated */
-       alpha_jsr(inst,ALPHA_RA,ALPHA_R0,1);
+       alpha_jsr(inst,ALPHA_RA,ALPHA_V0,1);
+
+       /* Return the start of the buffer as the redirector entry point */
+       return (void *)buf;
+}
+
+void _jit_pad_buffer(unsigned char *buf, int len) {
+       alpha_inst inst = (alpha_inst) buf;
 
-       return (void *)inst;
+       if (len > 0) {
+               do {
+                       alpha_nop(inst);
+               } while (--len);
+       }
 }
 
 #endif /* alpha */
index f541ff0454681e98338fed1364de119cce80efd4..01fc109fa307bac7527903c6af1b3ba1a5d147f6 100644 (file)
 #ifndef        _JIT_APPLY_ALPHA_H
 #define        _JIT_APPLY_ALPHA_H
 
-/* NOT IMPLEMENTED YET! */
+/*
+ * The maximum number of bytes that are needed to represent a closure,
+ * and the alignment to use for the closure.
+ */
+#define jit_closure_size                (32 /* instructions */ * 4 /* bytes per instruction */)
+#define jit_closure_align              32
+
+/*
+ * The number of bytes that are needed for a redirector stub.
+ * This includes any extra bytes that are needed for alignment.
+ */
+#define jit_redirector_size             (100 /* instructions */ * 4 /* bytes per instruction */)
+
+/*
+ * We should pad unused code space with NOP's.
+ */
+#define jit_should_pad                  1
 
 #endif /* _JIT_APPLY_ALPHA_H */
index 100c3fabc0de0f83f9b7b0acc01bb721f4def3f4..ebfb73ad2dce49bdbbca0adf037f38dbda8e439b 100644 (file)
 
 #include "jit-apply-arm.h"
 
+#elif defined(__alpha) || defined(__alpha__)
+
+#include "jit-apply-alpha.h"
+
 #elif defined(__x86_64) || defined(__x86_64__)
 
 #include "jit-apply-x86-64.h"
index fffab31bdaf2b6888619b728ada29e88d4dd1d3a..f32511ecaba6c174462c8e8a0b77547ea80f4ff7 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef        _JIT_GEN_ALPHA_H
 #define        _JIT_GEN_ALPHA_H
 
+#include "jit-rules.h"
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -139,6 +141,10 @@ typedef enum {
 
 typedef unsigned int * alpha_inst;
 
+/* misc function prototypes */
+void alpha_output_branch(jit_function_t, alpha_inst, int, jit_insn_t, int);
+void jump_to_epilog(jit_gencode_t, alpha_inst, jit_block_t);
+
 #define ALPHA_REG_MASK         0x1f
 #define ALPHA_REGA_SHIFT       0x15
 #define ALPHA_REGB_SHIFT       0x10
@@ -179,6 +185,7 @@ typedef unsigned int * alpha_inst;
 #define ALPHA_OP_CMPBGE                0x10
 #define ALPHA_OP_S8ADDL                0x10
 #define ALPHA_OP_S8SUBL                0x10
+#define ALPHA_OP_CMPLT         0x10
 #define ALPHA_OP_CMPULT                0x10
 #define ALPHA_OP_ADDQ          0x10
 #define ALPHA_OP_S4ADDQ                0x10
index 24e48a14673a5566fe0878f31994bf6203ecddf6..581a1e01d7cab5ab0509c1bb9aa681888d32c85b 100644 (file)
@@ -66,6 +66,13 @@ int _alpha_has_ieeefp() {
        return (__implver >= 2);
 }
 
+/*
+ * Round a size up to a multiple of the stack word size.
+ */
+#define ROUND_STACK(size)       \
+       (((size) + (sizeof(alpha_inst) - 1)) & ~(sizeof(alpha_inst) - 1))
+
+
 /*
  * Setup or teardown the alpha code output process.
  */
@@ -79,6 +86,19 @@ int _alpha_has_ieeefp() {
 #define jit_cache_end_output()  \
        gen->posn.ptr = (char*) inst
 
+/*
+ * Load the instruction pointer from the generation context.
+ */
+#define jit_gen_load_inst_ptr(gen,inst) \
+       inst = (alpha_inst) (gen)->posn.ptr;
+
+/*
+ * Save the instruction pointer back to the generation context.
+ */
+#define jit_gen_save_inst_ptr(gen,inst) \
+       (gen)->posn.ptr = (unsigned char *) inst;
+
+
 /*
  * Initialize the backend. This is normally used to configure registers 
  * that may not appear on all CPU's in a given family. For example, only 
@@ -168,10 +188,9 @@ void *_jit_gen_prolog(jit_gencode_t gen, jit_function_t func, void *buf) {
  * epilog until the full function has been processed. 
  */
 void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
-       alpha_inst inst;
        void **fixup, **next;
 
-       inst = (alpha_inst) gen->posn.ptr;
+       jit_cache_setup_output(20);
 
        /* Perform fixups on any blocks that jump to the epilog */
        fixup = (void **)(gen->epilog_fixup);
@@ -181,7 +200,7 @@ void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
                fixup    = next;
        }
 
-       /* Set the stack pointer */
+       /* Set the stack pointer (1 instruction) */
        alpha_mov(inst,ALPHA_FP,ALPHA_SP);
 
        /* Restore the return address. (1 instruction) */
@@ -216,6 +235,8 @@ void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
 
        /* Return from the current function (1 instruction) */
        alpha_ret(inst,ALPHA_RA,1);
+
+       jit_cache_end_output();
 }
 
 /*
@@ -230,8 +251,37 @@ void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
  * signature alone; especially if the called function is vararg. 
  */
 int _jit_create_call_return_insns(jit_function_t func, jit_type_t signature, jit_value_t *args, unsigned int num_args, jit_value_t return_value, int is_nested) {
-       /* NOT IMPLEMENTED YET */
-       return 0;
+       jit_type_t return_type;
+       int ptr_return;
+
+       return_type = jit_type_normalize(jit_type_get_return(signature));
+       ptr_return  = jit_type_return_via_pointer(return_type);
+
+       /* Bail out now if we don't need to worry about return values */
+       if (!return_value || ptr_return) {
+               return 0;
+       }
+
+       /*
+        * Structure values must be flushed into the frame, and
+        * everything else ends up in a register
+        */
+       if (jit_type_is_struct(return_type) || jit_type_is_union(return_type)) {
+               if (!jit_insn_flush_struct(func, return_value)) {
+                       return 0;
+               }
+       } else if (return_type->kind == JIT_TYPE_FLOAT32 || return_type->kind == JIT_TYPE_FLOAT64 || return_type->kind == JIT_TYPE_NFLOAT) {
+               if (!jit_insn_return_reg(func, return_value, 32 /* fv0 */)) {
+                       return 0;
+               }
+       } else if (return_type->kind != JIT_TYPE_VOID) {
+               if (!jit_insn_return_reg(func, return_value, 0 /* v0 */)) {
+                       return 0;
+               }
+       }
+
+       /* Everything is back where it needs to be */
+       return 1;
 }
 
 /*
@@ -265,7 +315,36 @@ void _jit_gen_spill_global(jit_gencode_t gen, int reg, jit_value_t value) {
  * position, and will then generate the appropriate spill instructions. 
  */
 void _jit_gen_spill_reg(jit_gencode_t gen, int reg, int other_reg, jit_value_t value) {
-       /* NOT IMPLEMENTED YET */;
+       int offset;
+
+       /* Make sure that we have sufficient space */
+       jit_cache_setup_output(32);
+
+       /* If the value is associated with a global register, then copy to that */
+       if (value->has_global_register) {
+               alpha_mov(inst,_jit_reg_info[reg].cpu_reg,_jit_reg_info[value->global_reg].cpu_reg);
+               jit_cache_end_output();
+               return;
+       }
+
+       /* Fix the value in place within the local variable frame */
+       _jit_gen_fix_value(value);
+
+       /* Output an appropriate instruction to spill the value */
+       offset = (int)(value->frame_offset);
+
+       if (reg < 32) {         /* if integer register */
+               alpha_stq(inst,reg,ALPHA_FP,offset);
+               if (other_reg != -1) {
+                       offset += sizeof(void *);
+                       alpha_stq(inst,other_reg,ALPHA_FP,offset);
+               }
+       } else /* floating point register */ {
+               /* TODO requires floating point support */
+       }
+
+       jit_cache_end_output();
+       return;
 }
 
 /*
@@ -362,6 +441,7 @@ void _jit_gen_end_block(jit_gencode_t gen, jit_block_t block) {
  * _jit_gen_fix_value.
  */
 void _jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t value) {
+       short int offset;
 
        /* Make sure that we have sufficient space */
        jit_cache_setup_output(32);
@@ -399,7 +479,47 @@ void _jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t
                /* mov from value->reg to _jit_reg_info[reg].cpu_reg */
                alpha_mov(inst,value->reg,_jit_reg_info[reg].cpu_reg);
 
-       } /* TODO else load from mem */
+       } else {
+
+               /* Fix the position of the value in the stack frame */
+               _jit_gen_fix_value(value);
+               offset = (int)(value->frame_offset);
+
+               /* Load the value into the specified register */
+               switch (jit_type_normalize(value->type)->kind) {
+
+                       case JIT_TYPE_SBYTE:
+/* TODO add alpha_ldb          alpha_ldb(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+ */                            break;
+                       case JIT_TYPE_UBYTE:
+                               alpha_ldbu(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+                               break;
+                       case JIT_TYPE_SHORT:
+/* TODO add alpha_ldw          alpha_ldw(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+ */                            break;
+                       case JIT_TYPE_USHORT:
+                               alpha_ldwu(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+                               break;
+                       case JIT_TYPE_INT:
+                               alpha_ldl(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+                               break;
+                       case JIT_TYPE_UINT:
+/* TODO add alpha_ldlu         alpha_ldlu(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+*/                             break;
+                       case JIT_TYPE_LONG:
+                               alpha_ldq(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+                               break;
+                       case JIT_TYPE_ULONG:
+/* TODO add alpha_ldqu         alpha_ldqu(inst,_jit_reg_info[reg].cpu_reg,ALPHA_SP,offset);
+*/                             break;
+
+                       /* TODO requires floating-point support */
+                       case JIT_TYPE_FLOAT32:
+                       case JIT_TYPE_FLOAT64:
+                       case JIT_TYPE_NFLOAT:
+                               break;
+               }
+       }
 
        jit_cache_end_output();
 }
@@ -430,7 +550,16 @@ void *_jit_gen_redirector(jit_gencode_t gen, jit_function_t func) {
  * for the result to be placed in an appropriate register or memory destination.
  */
 void _jit_gen_insn(jit_gencode_t gen, jit_function_t func, jit_block_t block, jit_insn_t insn) {
-       /* NOT IMPLEMENTED YET */;
+
+       switch (insn->opcode) {
+               #define JIT_INCLUDE_RULES
+                       #include "jit-rules-alpha.inc"
+               #undef JIT_INCLUDE_RULES
+
+               default:
+                       fprintf(stderr, "TODO(%x) at %s, %d\n", (int)(insn->opcode), __FILE__, (int)__LINE__);
+                       break;
+       }
 }
 
 /*
@@ -440,6 +569,16 @@ void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) {
        /* NOT IMPLEMENTED YET */;
 }
 
+void _jit_gen_fix_value(jit_value_t value) {
+
+       if (!(value->has_frame_offset) && !(value->is_constant)) {
+               jit_nint size = (jit_nint)(ROUND_STACK(jit_type_get_size(value->type)));
+               value->block->func->builder->frame_size += size;
+               value->frame_offset = -(value->block->func->builder->frame_size);
+               value->has_frame_offset = 1;
+       }
+}
+
 /*
  * Output a branch instruction.
  */
@@ -473,7 +612,7 @@ void alpha_output_branch(jit_function_t func, alpha_inst inst, int opcode, jit_i
 /*
  * Jump to the current function's epilog.
  */
-void alpha_jump_to_epilog(jit_gencode_t gen, alpha_inst inst, jit_block_t block) {
+void jump_to_epilog(jit_gencode_t gen, alpha_inst inst, jit_block_t block) {
        short int offset;
 
        /*
index c196654e2e1627f0f0f5cd79b623589e69317a8a..74dc560b0f8b65b1728d9d9c2b00da9bd724f89b 100644 (file)
@@ -96,16 +96,16 @@ extern      "C" {
        {   "gp", 29, -1, JIT_REG_FIXED}, \
        {   "sp", 30, -1, JIT_REG_FIXED | JIT_REG_STACK_PTR}, \
        { "zero", 31, -1, JIT_REG_FIXED}, \
-       {  "fv0",  0, -1, JIT_REG_FIXED}, \
-       {  "fv1",  1, -1, JIT_REG_FIXED}, \
-       {  "fs0",  2, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs1",  3, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs2",  4, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs3",  5, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs4",  6, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs5",  7, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs6",  8, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
-       {  "fs7",  9, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fv0", 0, -1, JIT_REG_FIXED}, \
+       {  "fv1", 1, -1, JIT_REG_FIXED}, \
+       {  "fs0", 2, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs1", 3, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs2", 4, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs3", 5, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs4", 6, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs5", 7, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs6", 8, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
+       {  "fs7", 9, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_GLOBAL}, \
        {  "ft0", 10, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_CALL_USED}, \
        {  "ft1", 11, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_CALL_USED}, \
        {  "ft2", 12, -1, JIT_REG_ALPHA_FLOAT | JIT_REG_CALL_USED}, \
@@ -200,10 +200,8 @@ extern     "C" {
  */
 #define JIT_CDECL_WORD_REG_PARAMS      {9,10,11,12,13,14,-1}
 #define JIT_MAX_WORD_REG_PARAMS                6
-
-/* TODO: find the proper values for these */
 #define JIT_INITIAL_STACK_OFFSET       0
-#define JIT_INITIAL_FRAME_SIZE                 0
+#define JIT_INITIAL_FRAME_SIZE                 (14*8)
 
 #ifdef __cplusplus
 };
index b3b6d2fb1ec90ee39a69c46ad80af2cad6e33cb6..10c0cbfc1db7548220af617c4f09327783d6415e 100644 (file)
 
 JIT_OP_TRUNC_SBYTE: unary
        [reg] -> {
-               alpha_slli(code,$1,56,$1);
-               alpha_srai(code,$1,56,$1);
+               alpha_slli(inst,$1,56,$1);
+               alpha_srai(inst,$1,56,$1);
        }
 
 JIT_OP_TRUNC_UBYTE: unary
        [reg] -> {
-               alpha_li8(code,ALPHA_AT,0xff);
-               alpha_and(code,$1,ALPHA_AT,$1);
+               _alpha_li8(inst,ALPHA_AT,0xff);
+               alpha_and(inst,$1,ALPHA_AT,$1);
        }
 
 JIT_OP_TRUNC_SHORT: unary
        [reg] -> {
-               alpha_slli(code,$1,56,$1);
-               alpha_srai(code,$1,56,$1);
+               alpha_slli(inst,$1,56,$1);
+               alpha_srai(inst,$1,56,$1);
        }
 
 JIT_OP_TRUNC_USHORT: unary
        [reg] -> {
-               alpha_slli(code,$1,56,$1);
-               alpha_srli(code,$1,56,$1);
+               alpha_slli(inst,$1,56,$1);
+               alpha_srli(inst,$1,56,$1);
        }
 
 /*
@@ -184,7 +184,7 @@ JIT_OP_IXOR: binary
 
 JIT_OP_INOT: unary
        [reg] -> {
-               alpha_li32(inst,ALPHA_AT,0xffffffff);
+               _alpha_li32(inst,ALPHA_AT,0xffffffff);
                alpha_xor(inst,ALPHA_AT,$1,$1);
        }
 
@@ -213,7 +213,7 @@ JIT_OP_LXOR: binary
 
 JIT_OP_LNOT: unary
        [reg] -> {
-               alpha_li64(inst,ALPHA_AT,0xffffffff);
+               _alpha_li64(inst,ALPHA_AT,0xffffffff);
                alpha_xor(inst,ALPHA_AT,$1,$1);
        }
 
@@ -308,41 +308,8 @@ JIT_OP_BR_ILE_UN: binary_branch
        }
 
 
-JIT_OP_BR_IGT: binary_branch
-       [reg, reg] -> {
-               /* $1 > $2 -> $at */
-               alpha_cmpgt(inst, $1, $2, ALPHA_AT);
-
-               /* branch if $at == 1 */
-               alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
-       }
-
-JIT_OP_BR_IGT_UN: binary_branch
-       [reg, reg] -> {
-               /* $1 > $2 -> $at */
-               alpha_cmpugt(inst, $1, $2, ALPHA_AT);
-
-               /* branch if $at == 1 */
-               alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
-       }
-
-JIT_OP_BR_IGE: binary_branch
-       [reg, reg] -> {
-               /* $1 >= $2 -> $at */
-               alpha_cmpge(inst, $1, $2, ALPHA_AT);
-
-               /* branch if $at == 1 */
-               alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
-       }
-
-JIT_OP_BR_IGE_UN: binary_branch
-       [reg, reg] -> {
-               /* $1 => $2 -> $at */
-               alpha_cmpugt(inst, $1, $2, ALPHA_AT);
-
-               /* branch if $at == 1 */
-               alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
-       }
+/* TODO: JIT_OP_BR_IGT JIT_OP_BR_IGT_UN */
+/* TODO: JIT_OP_BR_IGE JIT_OP_BR_IGE_UN */
 
 
 /*
@@ -381,25 +348,7 @@ JIT_OP_ILE_UN: binary
                alpha_cmpule(inst,$3,$2,$1);
        }
 
-JIT_OP_IGT: binary
-       [=reg, reg, reg] -> {
-               alpha_cmpgt(inst,$3,$2,$1);
-       }
-
-JIT_OP_IGT_UN: binary
-       [=reg, reg, reg] -> {
-               alpha_cmpugt(inst,$3,$2,$1);
-       }
-
-JIT_OP_IGE: binary
-       [=reg, reg, reg] -> {
-               alpha_cmpge(inst,$3,$2,$1);
-       }
-
-JIT_OP_IGE_UN: binary
-       [=reg, reg, reg] -> {
-               alpha_cmpuge(inst,$3,$2,$1);
-       }
+/* TODO: JIT_OP_IGT JIT_OP_IGT_UN JIT_OP_IGE JIT_OP_IGE_UN */
 
 /*
  * Mathematical opcodes.