Mercurial > hg > CbC > old > device
diff mc-code-arm.c @ 593:c139d4d9307c
ltosop optimize
implement throw in ARM
author | kono |
---|---|
date | Fri, 20 Jan 2006 18:48:45 +0900 |
parents | 0497fa2e2414 |
children | f49c825920c4 |
line wrap: on
line diff
--- a/mc-code-arm.c Fri Jan 20 14:05:48 2006 +0900 +++ b/mc-code-arm.c Fri Jan 20 18:48:45 2006 +0900 @@ -393,8 +393,7 @@ int disp_offset=0; // fore mc-codegen.c #define disp_offset 0 -#define func_disp_offset 8 -#define code_disp_offset (-64) +#define code_disp_offset 0 #define CODE_LVAR(l) ((l)+code_disp_offset) #define CODE_CALLER_ARG(l) ((l)+arg_offset1) @@ -1779,19 +1778,22 @@ printf("\tldr\t%s, .L%d+%d\n",crn,label,disp); } -#define R1SAVE 0 - void code_environment(int creg) { /* save frame pointer */ - inc_inst(1); -#if R1SAVE - use_int(creg); - printf("\tldr\t%s, [fp, #0]\n",register_name(creg)); -#else - use_int(creg); - printf("\tmov\t%s, fp\n",register_name(creg)); -#endif + if (is_code(fnptr)) { + inc_inst(1); + use_int(creg); + printf("\tmov\t%s, fp\n",register_name(creg)); + } else { + int disp,label; + char *trn = register_name(REG_ip); + inc_inst(2); + use_int(creg); + disp = search_const(LVAR,glist2(lvar_offset_label,FUNC_LVAR(0)),&label); + printf("\tldr\t%s, .L%d+%d\n",trn,label,disp); + printf("\tadd\t%s, fp, %s\n",register_name(creg),trn); + } } static int rexpr_bool(int e1, int reg); @@ -2720,11 +2722,7 @@ code_frame_pointer(int e3) { use_int(e3); inc_inst(1); -#if R1SAVE printf("\tmov\tfp, %s\n",register_name(e3)); -#else - printf("\tmov\tfp, %s\n",register_name(e3)); -#endif } int @@ -2734,8 +2732,30 @@ } void -code_fix_frame_pointer(int offset) { -} +code_fix_frame_pointer(int env) { + char *trn; + int disp,label; + + if (is_function(fnptr) && ! env) { + trn = register_name(REG_ip); + disp = search_const(LVAR,glist2(lvar_offset_label,FUNC_LVAR(0)),&label); + printf("\tldr\t%s, .L%d+%d\n",trn,label,disp); + printf("\tadd\tfp, fp, %s\n",trn); + } +} + +static void +code_unfix_frame_pointer() +{ + char *trn; + int disp,label; + + trn = register_name(REG_ip); + disp = search_const(LVAR,glist2(lvar_offset_label,FUNC_LVAR(0)),&label); + printf("\tldr\t%s, .L%d+%d\n",trn,label,disp); + printf("\tsub\tfp, fp, %s\n",trn); +} + void code_jmp(char *s) { @@ -3457,7 +3477,7 @@ sz = size(cadr(fnptr->ty)); inc_inst(3); code_const(sz,REGISTER_OPERAND); - printf("\tsubl\tr1, r2, fp\n"); + printf("\tsub\tr1, r2, fp\n"); printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT); emit_copy(6,3,sz,0,1,1); } else if (cadr(fnptr->ty)!=VOID) { @@ -3465,9 +3485,7 @@ if (creg!=RET_REGISTER) set_ireg(RET_REGISTER,1); } -#if R1SAVE -#else -#endif + code_unfix_frame_pointer(); } fwddef(retlabel);