comparison mc-code-powerpc.c @ 417:98888da30b35

code jump fixes (not finished)
author kono
date Mon, 25 Oct 2004 01:16:28 +0900
parents a6ed0575d731
children c73f013d07d7
comparison
equal deleted inserted replaced
416:a6ed0575d731 417:98888da30b35
309 if (max_func_arg_label) { 309 if (max_func_arg_label) {
310 printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24); 310 printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24);
311 max_func_arg_label = 0; 311 max_func_arg_label = 0;
312 } 312 }
313 313
314 #if 0
314 printf("# reg_save %d\n",reg_save); 315 printf("# reg_save %d\n",reg_save);
315 #if 0
316 printf("# function %s\n",fnptr->nm); 316 printf("# function %s\n",fnptr->nm);
317 l = ARG_LVAR_OFFSET; 317 l = ARG_LVAR_OFFSET;
318 printf("# offset call0\t%d\n",CALLER_ARG); 318 printf("# offset call0\t%d\n",CALLER_ARG);
319 l = ARG_LVAR_OFFSET+max_func_args*SIZE_OF_INT; 319 l = ARG_LVAR_OFFSET+max_func_args*SIZE_OF_INT;
320 printf("# offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT); 320 printf("# offset calln\t%d %d\n",CALLER_ARG,max_func_args*SIZE_OF_INT);
1534 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,lb,code_base); 1534 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",crn,lb,code_base);
1535 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,lb,code_base,crn); 1535 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",crn,lb,code_base,crn);
1536 } 1536 }
1537 1537
1538 #define MAX_COPY_LEN 20 1538 #define MAX_COPY_LEN 20
1539 // #define MAX_COPY_LEN 10
1539 1540
1540 void 1541 void
1541 1542
1542 emit_copy(int from,int to,int length,int offset,int value,int det) 1543 emit_copy(int from,int to,int length,int offset,int value,int det)
1543 { 1544 {
1592 clear_ptr_cache(); 1593 clear_ptr_cache();
1593 code_save_stacks(); 1594 code_save_stacks();
1594 printf("\tli r5,%d\n",length>0?length:-length); 1595 printf("\tli r5,%d\n",length>0?length:-length);
1595 printf("\tmr r4,%s\n",frn); 1596 printf("\tmr r4,%s\n",frn);
1596 printf("\tmr r3,%s\n",trn); 1597 printf("\tmr r3,%s\n",trn);
1597 if (length<0 && offset) { 1598 /* offset should be ignored */
1598 code_add(4,offset,4);
1599 code_add(3,offset,3);
1600 }
1601 /* overrap must be allowed */ 1599 /* overrap must be allowed */
1602 printf("\tbl L_%s$stub\n",memmove); 1600 printf("\tbl L_%s$stub\n",memmove);
1603 extern_define(memmove,0,FUNCTION,1); 1601 extern_define(memmove,0,FUNCTION,1);
1604 fix=0; 1602 fix=0;
1605 set_ireg(RET_REGISTER,0); 1603 set_ireg(RET_REGISTER,0);
2762 #ifdef DOT_SIZE 2760 #ifdef DOT_SIZE
2763 printf("\t.type\t%s,@function\n",name); 2761 printf("\t.type\t%s,@function\n",name);
2764 #endif 2762 #endif
2765 printf("_%s:\n",name); 2763 printf("_%s:\n",name);
2766 code_disp_label=fwdlabel(); 2764 code_disp_label=fwdlabel();
2765 #if 0
2767 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label); 2766 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
2767 #else
2768 printf("\tla r1,lo16(L_%d)(r30)\n",code_disp_label);
2769 printf("\taddis r1,r1,ha16(L_%d)\n",code_disp_label);
2770 #endif
2768 printf("\tbcl 20,31,L_%d\n",code_base = fwdlabel()); 2771 printf("\tbcl 20,31,L_%d\n",code_base = fwdlabel());
2769 fwddef(code_base); 2772 fwddef(code_base);
2770 printf("\tmflr r31\n"); 2773 printf("\tmflr r31\n");
2771 max_func_args = 0; 2774 max_func_args = 0;
2772 } 2775 }
2783 void 2786 void
2784 code_leave(char *name) 2787 code_leave(char *name)
2785 { 2788 {
2786 int r1_offsetv; 2789 int r1_offsetv;
2787 disp&= -SIZE_OF_INT; 2790 disp&= -SIZE_OF_INT;
2788 r1_offsetv = -disp+max_func_args*SIZE_OF_INT+code_disp_offset; 2791 r1_offsetv = -disp+max_func_args*SIZE_OF_INT+code_disp_offset+8;
2789 2792
2790 printf(".set L_%d,%d\n",code_disp_label,-r1_offsetv); 2793 printf(".set L_%d,%d\n",code_disp_label,-r1_offsetv);
2794 if (max_func_arg_label) {
2795 printf(".set L_%d,%d\n",max_func_arg_label,max_func_args*SIZE_OF_INT+24);
2796 max_func_arg_label = 0;
2797 }
2791 local_table(); 2798 local_table();
2792 // free_all_register(); 2799 // free_all_register();
2793 } 2800 }
2794 2801
2795 void 2802 void