]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
Remove unnecessary code from the prolog, epilog, redirector, and
authorThomas Cort <linuxgeek@gmail.com>
Sun, 20 Aug 2006 15:47:54 +0000 (15:47 +0000)
committerThomas Cort <linuxgeek@gmail.com>
Sun, 20 Aug 2006 15:47:54 +0000 (15:47 +0000)
closure. Implement > and >= opcodes for signed and unsigned values.

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

index d12e494a82478361fdcbb282e67d0d100c1c44cf..e8149aebf841b87acaba25e81fd501cfc5628d37 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2006-08-20  Thomas Cort  <linuxgeek@gmail.com>
+
+       * jit/jit-apply-alpha.c jit/jit-apply-alpha.h jit/jit-rules-alpha.h
+       jit/jit-rules-alpha.ins jit/jit-rules-alpha.c jit/jit-gen-alpha.h:
+       Remove unnecessary code from the prolog, epilog, redirector, and
+       closure. Implement > and >= opcodes for signed and unsigned values.
+
 2006-08-19  Aleksey Demakov  <ademakov@gmail.com>
 
        * jit/jit-reg-alloc.c (set_regdesc_flags): fix a problem with the
index 66c79bbaf79b39766441bfe3ab23c4dd6849e044..9c07a20359d0689bcffe3af334e9edb4e9f4cfc5 100644 (file)
 void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_type) {
        alpha_inst inst = (alpha_inst) buf;
 
-       /* Compute and load the global pointer */
+       /* Compute and load the global pointer (2 instructions) */
        alpha_ldah(inst,ALPHA_GP,ALPHA_PV,0);
        alpha_lda( inst,ALPHA_GP,ALPHA_GP,0);
 
-       /* Allocate space for a new stack frame. */
+       /* Allocate space for a new stack frame. (1 instruction) */
        alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(13*8));
 
-       /* Save the return address. */
+       /* Save the return address. (1 instruction) */
        alpha_stq(inst,ALPHA_RA,ALPHA_SP,0*8);
 
-       /* Save integer register arguments as local variables */
+       /* Save integer register arguments as local variables (6 instructions) */
        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);
@@ -45,7 +45,7 @@ void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_t
        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 */
+       /* Save floating-point register arguments as local variables (8 instructions) */
        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);
@@ -53,13 +53,13 @@ void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_t
        alpha_stt(inst,ALPHA_FA4,ALPHA_SP,11*8);
        alpha_stt(inst,ALPHA_FA5,ALPHA_SP,12*8);
 
-       /* Call the closure handling function */
+       /* Call the closure handling function (1 instruction) */
        alpha_call(inst,func);
 
-       /* Restore the return address */
+       /* Restore the return address (1 instruction) */
        alpha_ldq(inst,ALPHA_RA,ALPHA_SP,0*8);
 
-       /* Restore integer register arguments */
+       /* Restore integer register arguments (6 instructions) */
        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);
@@ -67,7 +67,7 @@ void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_t
        alpha_ldq(inst,ALPHA_A4,ALPHA_SP,5*8);
        alpha_ldq(inst,ALPHA_A5,ALPHA_SP,6*8);
 
-       /* Restore floating-point register arguments */
+       /* Restore floating-point register arguments (8 instructions) */
        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);
@@ -75,7 +75,7 @@ void _jit_create_closure(unsigned char *buf, void *func, void *closure, void *_t
        alpha_ldt(inst,ALPHA_FA4,ALPHA_SP,11*8);
        alpha_ldt(inst,ALPHA_FA5,ALPHA_SP,12*8);
 
-       /* restore the stack pointer */
+       /* restore the stack pointer (1 instruction) */
        alpha_lda(inst,ALPHA_SP,ALPHA_SP,(13*8));
 }
 
@@ -112,63 +112,16 @@ void *_jit_create_redirector(unsigned char *buf, void *func, void *user_data, in
        /* 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 */
+       /* Compute and load the global pointer (2 instructions) */
        alpha_ldah(inst,ALPHA_GP,ALPHA_PV,0);
        alpha_lda( inst,ALPHA_GP,ALPHA_GP,0);
 
-       /* 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);
+       /* Force any pending hardware exceptions to be raised. (1 instruction) */
+       alpha_trapb(inst);
 
-       /* Call the redirector handling function */
+       /* Call the redirector handling function (1 instruction) */
        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);
 
@@ -199,7 +152,7 @@ void *_jit_create_redirector(unsigned char *buf, void *func, void *user_data, in
        /* Force any pending hardware exceptions to be raised. (1 instruction) */
        alpha_trapb(inst);
 
-       /* Jump to the function that the redirector indicated */
+       /* Jump to the function that the redirector indicated (1 instruction) */
        alpha_jsr(inst,ALPHA_RA,ALPHA_V0,1);
 
        /* Return the start of the buffer as the redirector entry point */
index 01fc109fa307bac7527903c6af1b3ba1a5d147f6..63d5e4c68e7ef4b63535e334d8fd5de8eb580b29 100644 (file)
  * 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_size                (35 /* 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 */)
+#define jit_redirector_size             (41 /* instructions */ * 4 /* bytes per instruction */)
 
 /*
  * We should pad unused code space with NOP's.
index f32511ecaba6c174462c8e8a0b77547ea80f4ff7..3662b1619660dbbe735e2cd9dacf0cf7268b23be 100644 (file)
@@ -500,6 +500,19 @@ void jump_to_epilog(jit_gencode_t, alpha_inst, jit_block_t);
 #define alpha_subqv(inst,sreg0,sreg1,dreg)     alpha_encode_regops(inst,ALPHA_OP_SUBQV,ALPHA_FUNC_SUBQV,sreg0,sreg1,dreg)
 #define alpha_cmple(inst,sreg0,sreg1,dreg)     alpha_encode_regops(inst,ALPHA_OP_CMPLE,ALPHA_FUNC_CMPLE,sreg0,sreg1,dreg)
 
+/*
+ * pseudo comparison operations
+ *
+ * Alpha doesn't have all possible comparison opcodes. For example, we
+ * have cmple for A <= B, but no cmpge for A >= B. So we make cmpge by 
+ * using cmple with the operands switched. Example, A >= B becomes B <= A
+ */
+#define alpha_cmpble(inst,sreg0,sreg1,dreg)    alpha_encode_regops(inst,ALPHA_OP_CMPBGE,ALPHA_FUNC_CMPBGE,sreg1,sreg0,dreg)
+#define alpha_cmpugt(inst,sreg0,sreg1,dreg)    alpha_encode_regops(inst,ALPHA_OP_CMPULT,ALPHA_FUNC_CMPULT,sreg1,sreg0,dreg)
+#define alpha_cmpuge(inst,sreg0,sreg1,dreg)    alpha_encode_regops(inst,ALPHA_OP_CMPULE,ALPHA_FUNC_CMPULE,sreg1,sreg0,dreg)
+#define alpha_cmpgt(inst,sreg0,sreg1,dreg)     alpha_encode_regops(inst,ALPHA_OP_CMPLT,ALPHA_FUNC_CMPLT,sreg1,sreg0,dreg)
+#define alpha_cmpge(inst,sreg0,sreg1,dreg)     alpha_encode_regops(inst,ALPHA_OP_CMPLE,ALPHA_FUNC_CMPLE,sreg1,sreg0,dreg)
+
 /* bitwise / move operations */
 #define alpha_and(inst,sreg0,sreg1,dreg)       alpha_encode_regops(inst,ALPHA_OP_AND,ALPHA_FUNC_AND,sreg0,sreg1,dreg)
 #define alpha_bic(inst,sreg0,sreg1,dreg)       alpha_encode_regops(inst,ALPHA_OP_BIC,ALPHA_FUNC_BIC,sreg0,sreg1,dreg)
index c4b621fed0431c6e37eeeff7d73737854f66c4a1..1d77464c0848a2467df783469da4ebbb6adaa993 100644 (file)
@@ -147,7 +147,7 @@ void *_jit_gen_prolog(jit_gencode_t gen, jit_function_t func, void *buf) {
         alpha_lda( inst,ALPHA_GP,ALPHA_GP,0);
 
        /* Allocate space for a new stack frame. (1 instruction) */
-       alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(16*8));
+       alpha_lda(inst,ALPHA_SP,ALPHA_SP,-(2*8));
 
        /* Save the return address. (1 instruction) */
        alpha_stq(inst,ALPHA_RA,ALPHA_SP,0*8);
@@ -155,24 +155,6 @@ void *_jit_gen_prolog(jit_gencode_t gen, jit_function_t func, void *buf) {
        /* 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);
 
@@ -219,24 +201,6 @@ void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) {
        /* 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);
 
index adb8e035aa55ec9d092c83055bcb0f3c63758624..9f6c9783d02af7df7dcc8d04af799fd513e71362 100644 (file)
@@ -153,7 +153,7 @@ extern      "C" {
  * The maximum number of bytes to allocate for the prolog.
  * This may be shortened once we know the true prolog size.
  */
-#define JIT_PROLOG_SIZE                        (21 /* instructions */ * 4 /* bytes per instruction */)
+#define JIT_PROLOG_SIZE                        (7 /* instructions */ * 4 /* bytes per instruction */)
 
 /*
  * Preferred alignment for the start of functions.
index 62b40e0f4555474fbdd728b9acf37c8dbf5455b9..fc7e911409e7511e29cdff7ce2369869ea4fbf91 100644 (file)
@@ -307,9 +307,41 @@ JIT_OP_BR_ILE_UN: binary_branch
                alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
        }
 
+JIT_OP_BR_IGT:
+       [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:
+       [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 */
+JIT_OP_BR_IGE:
+       [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:
+       [reg, reg] -> {
+               /* $1 >= $2 -> $at */
+               alpha_cmpuge(inst, $1, $2, ALPHA_AT);
+
+               /* branch if $at == 1 */
+               alpha_output_branch(func, inst, ALPHA_OP_BEQ, insn, ALPHA_AT);
+       }
 
 
 /*