From: Thomas Cort Date: Tue, 15 Aug 2006 01:08:59 +0000 (+0000) Subject: Add a TODO() macro to print unimplemented warnings. Fix some X-Git-Tag: before.move.to.git~214 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=9feaff053975d9bf535770df259a2d1472aa8501;p=francis%2Flibjit.git Add a TODO() macro to print unimplemented warnings. Fix some casting warnings. Implement _jit_gen_redirector(...). Fix JIT_CDECL_WORD_REG_PARAMS to use the correct parameter registers. Add some stack push and pop instructions. --- diff --git a/ChangeLog b/ChangeLog index 4cee899..ccee029 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-08-15 Thomas Cort + * jit/jit-rules-alpha.c jit/jit-rules-alpha.h jit/jit-rules-alpha.ins + Add a TODO() macro to print unimplemented warnings. Fix some + casting warnings. Implement _jit_gen_redirector(...). Fix + JIT_CDECL_WORD_REG_PARAMS to use the correct parameter + registers. Add some stack push and pop instructions. + 2006-08-15 Kirill Kononenko * configure.in: add --enable-signals option; diff --git a/jit/jit-rules-alpha.c b/jit/jit-rules-alpha.c index af41e56..c4b621f 100644 --- a/jit/jit-rules-alpha.c +++ b/jit/jit-rules-alpha.c @@ -108,6 +108,12 @@ void _jit_init_backend(void) { /* Nothing to do here */; } +#define TODO() \ + do { \ + fprintf(stderr, "TODO at %s, %d\n", __FILE__, (int)__LINE__); \ + } while (0) + + /* * Get the ELF machine and ABI type information for this platform. The * machine field should be set to one of the EM_* values in @@ -198,7 +204,7 @@ void _jit_gen_epilog(jit_gencode_t gen, jit_function_t func) { alpha_inst code = (alpha_inst) fixup; next = (void **)(fixup[0]); - _alpha_li64(code,ALPHA_AT,inst); + _alpha_li64(code,ALPHA_AT,(long int)inst); alpha_jmp(code,ALPHA_ZERO,ALPHA_AT,1); fixup = next; @@ -293,7 +299,7 @@ int _jit_create_call_return_insns(jit_function_t func, jit_type_t signature, jit * stack location for a subsequent indirect call. */ int _jit_setup_indirect_pointer(jit_function_t func, jit_value_t value) { - /* NOT IMPLEMENTED YET */ + TODO(); return 0; } @@ -301,14 +307,14 @@ int _jit_setup_indirect_pointer(jit_function_t func, jit_value_t value) { * TODO: write what this function is supposed to do */ void _jit_gen_spill_top(jit_gencode_t gen, int reg, jit_value_t value, int pop) { - /* NOT IMPLEMENTED YET */; + TODO(); } /* * TODO: write what this function is supposed to do */ void _jit_gen_spill_global(jit_gencode_t gen, int reg, jit_value_t value) { - /* NOT IMPLEMENTED YET */; + TODO(); } /* @@ -427,7 +433,7 @@ void _jit_gen_start_block(jit_gencode_t gen, jit_block_t block) { alpha_inst code = (alpha_inst) fixup; next = (void **)(fixup[0]); - _alpha_li64(code,ALPHA_AT,(gen->posn.ptr)); + _alpha_li64(code,ALPHA_AT,(long int)(gen->posn.ptr)); alpha_jmp(code,ALPHA_ZERO,ALPHA_AT,1); fixup = next; @@ -533,11 +539,7 @@ void _jit_gen_load_value(jit_gencode_t gen, int reg, int other_reg, jit_value_t } void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value) { -/* - NOT IMPLEMENTED YET! - jit_cache_setup_output(); - jit_cache_end_output(); -*/ + TODO(); } @@ -548,8 +550,20 @@ void _jit_gen_load_global(jit_gencode_t gen, int reg, jit_value_t value) { * version after recompilation. */ void *_jit_gen_redirector(jit_gencode_t gen, jit_function_t func) { - /* NOT IMPLEMENTED YET */ - return NULL; + void *ptr, *entry; + alpha_inst inst = (alpha_inst) gen->posn.ptr; + + if (!jit_cache_check_for_n(&(gen->posn), 8*6)) { + jit_cache_mark_full(&(gen->posn)); + return NULL; + } + + ptr = (void *)&(func->entry_point); + entry = gen->posn.ptr; + + alpha_call(inst, ptr); + + return entry; } /* @@ -574,7 +588,7 @@ void _jit_gen_insn(jit_gencode_t gen, jit_function_t func, jit_block_t block, ji * TODO: write what this function is supposed to do */ void _jit_gen_exch_top(jit_gencode_t gen, int reg, int pop) { - /* NOT IMPLEMENTED YET */; + TODO(); } void _jit_gen_fix_value(jit_value_t value) { diff --git a/jit/jit-rules-alpha.h b/jit/jit-rules-alpha.h index 74dc560..adb8e03 100644 --- a/jit/jit-rules-alpha.h +++ b/jit/jit-rules-alpha.h @@ -198,10 +198,10 @@ extern "C" { /* * Parameter passing rules. */ -#define JIT_CDECL_WORD_REG_PARAMS {9,10,11,12,13,14,-1} +#define JIT_CDECL_WORD_REG_PARAMS {16,17,18,19,20,21,-1} #define JIT_MAX_WORD_REG_PARAMS 6 -#define JIT_INITIAL_STACK_OFFSET 0 -#define JIT_INITIAL_FRAME_SIZE (14*8) +#define JIT_INITIAL_STACK_OFFSET (14*8) +#define JIT_INITIAL_FRAME_SIZE (sizeof(void*)) #ifdef __cplusplus }; diff --git a/jit/jit-rules-alpha.ins b/jit/jit-rules-alpha.ins index 4d6ba61..62b40e0 100644 --- a/jit/jit-rules-alpha.ins +++ b/jit/jit-rules-alpha.ins @@ -402,3 +402,38 @@ JIT_OP_CALL_EXTERNAL: alpha_call(inst, (insn->dest)); } +/* + * Stack pushes and pops. + */ + +JIT_OP_RETURN_REG: manual + [] -> { + /* Nothing to do here */; + } + +JIT_OP_PUSH_INT: unary_note + [imm] -> { + alpha_li(inst,ALPHA_AT,$1); + alpha_stq(inst,ALPHA_AT,ALPHA_SP,0); + alpha_lda(inst,ALPHA_SP,ALPHA_SP,-8); + } + [reg] -> { + alpha_stq(inst,$1,ALPHA_SP,0); + alpha_lda(inst,ALPHA_SP,ALPHA_SP,-8); + } + +JIT_OP_PUSH_LONG: unary_note + [imm] -> { + alpha_li(inst,ALPHA_AT,$1); + alpha_stq(inst,ALPHA_AT,ALPHA_SP,0); + alpha_lda(inst,ALPHA_SP,ALPHA_SP,-8); + } + [reg] -> { + alpha_stq(inst,$1,ALPHA_SP,0); + alpha_lda(inst,ALPHA_SP,ALPHA_SP,-8); + } + +JIT_OP_POP_STACK: + [] -> { + alpha_lda(inst,ALPHA_SP,ALPHA_SP,insn->value1->address); + }