comparison mc-code-powerpc.c @ 326:e5d40f8c4cce

bit-field continue.
author kono
date Sun, 20 Jun 2004 20:54:24 +0900
parents 575481408653
children da2e3f2d127d
comparison
equal deleted inserted replaced
325:b51b87ddf60c 326:e5d40f8c4cce
1 /* Micro-C Code Generatation Part for Power PC (Mac OS X) */ 1 /* Micro-C Code Generation Part for Power PC (Mac OS X) */
2 /* $Id$ */ 2 /* $Id$ */
3 3
4 #define EXTERN extern 4 #define EXTERN extern
5 #include "mc.h" 5 #include "mc.h"
6 #include "mc-code.h" 6 #include "mc-code.h"
257 257
258 /* 258 /*
259 259
260 r0 return value etc. 260 r0 return value etc.
261 r3-r10 input register 261 r3-r10 input register
262 r22-r29 saved register variable (input register for code segement) 262 r22-r29 saved register variable (input register for code segment)
263 r30 stack pointer 263 r30 stack pointer
264 r31 0 264 r31 0
265 r1 frame pointer 265 r1 frame pointer
266 266
267 f0 return value etc. 267 f0 return value etc.
352 } 352 }
353 353
354 /* if size of local variables / input variables is more then 64k, 354 /* if size of local variables / input variables is more then 64k,
355 lo16 does not work. We have to use ha16 also. But we can't know 355 lo16 does not work. We have to use ha16 also. But we can't know
356 the exact size in one path compile. We may safely use lvar16ha 356 the exact size in one path compile. We may safely use lvar16ha
357 if disp or max_func_args > 32k. Of course this is reduantant for 357 if disp or max_func_args > 32k. Of course this is redundant for
358 smaller offset. But who cares who use very large local variables? 358 smaller offset. But who cares who use very large local variables?
359 */ 359 */
360 360
361 #define LARGE_LVAR (disp<-32765||max_func_args>32765) 361 #define LARGE_LVAR (disp<-32765||max_func_args>32765)
362 362
1078 int ptcptr=ptr_cache; 1078 int ptcptr=ptr_cache;
1079 int g = (int)nptr; 1079 int g = (int)nptr;
1080 int p,p1; 1080 int p,p1;
1081 char *rrn; 1081 char *rrn;
1082 1082
1083 p1 = ptcptr; p = cadr(p1); /* unnecesary, if ptcptr is initialized */ 1083 p1 = ptcptr; p = cadr(p1); /* unnecessary, if ptcptr is initialized */
1084 while(ptcptr) { 1084 while(ptcptr) {
1085 if(car(ptcptr)==g) return caddr(ptcptr); 1085 if(car(ptcptr)==g) return caddr(ptcptr);
1086 p1=p; p=ptcptr; 1086 p1=p; p=ptcptr;
1087 ptcptr=cadr(ptcptr); 1087 ptcptr=cadr(ptcptr);
1088 } 1088 }
1692 } 1692 }
1693 1693
1694 void 1694 void
1695 set_lreg_operand(int reg,int mode) 1695 set_lreg_operand(int reg,int mode)
1696 { 1696 {
1697 // save_stack,clear_ptr_cache is assmued 1697 // save_stack,clear_ptr_cache is assumed
1698 if (!is_longlong_reg(reg)) { error(-1); return; } 1698 if (!is_longlong_reg(reg)) { error(-1); return; }
1699 if (mode) { 1699 if (mode) {
1700 if (regv_l(reg)!=3) 1700 if (regv_l(reg)!=3)
1701 printf("\tmr r3,%s\n", lregister_name_high(reg)); 1701 printf("\tmr r3,%s\n", lregister_name_high(reg));
1702 if (regv_l(reg)!=4) 1702 if (regv_l(reg)!=4)
1705 } 1705 }
1706 1706
1707 void 1707 void
1708 set_lreg_operand1(int reg,int mode) 1708 set_lreg_operand1(int reg,int mode)
1709 { 1709 {
1710 // save_stack,clear_ptr_cache is assmued 1710 // save_stack,clear_ptr_cache is assumed
1711 if (!is_longlong_reg(reg)) { error(-1); return; } 1711 if (!is_longlong_reg(reg)) { error(-1); return; }
1712 if (mode) { 1712 if (mode) {
1713 if (regv_l(reg)!=5) 1713 if (regv_l(reg)!=5)
1714 printf("\tmr r5,%s\n", lregister_name_high(reg)); 1714 printf("\tmr r5,%s\n", lregister_name_high(reg));
1715 if (regv_l(reg)!=6) 1715 if (regv_l(reg)!=6)
2036 // set_lreg(LREG_LREGISTER,0); 2036 // set_lreg(LREG_LREGISTER,0);
2037 set_freg(FREG_FREGISTER,0); 2037 set_freg(FREG_FREGISTER,0);
2038 set_ireg(CREG_REGISTER,0); 2038 set_ireg(CREG_REGISTER,0);
2039 2039
2040 // Struct arguments need emit_copy. it destructs 3 input registers. 2040 // Struct arguments need emit_copy. it destructs 3 input registers.
2041 // But it returns no value on a register. So calcurate it here. 2041 // But it returns no value on a register. So calculate it here.
2042 // We cannot do this in the previous loop, because the copied struct may be 2042 // We cannot do this in the previous loop, because the copied struct may be
2043 // override by other complex arguments. But bofore this we have to check 2043 // override by other complex arguments. But before this we have to check
2044 // complex_. 2044 // complex_.
2045 2045
2046 if (stargs) { 2046 if (stargs) {
2047 if (complex_) { 2047 if (complex_) {
2048 arg = get_input_arg(caddr(complex_),AS_SAVE, 2048 arg = get_input_arg(caddr(complex_),AS_SAVE,
2117 reg_arg_list = list2(arg,reg_arg_list); 2117 reg_arg_list = list2(arg,reg_arg_list);
2118 g_expr_u(assign_expr0(arg,e4,t,t)); 2118 g_expr_u(assign_expr0(arg,e4,t,t));
2119 } else if (t==DOUBLE||t==FLOAT) { 2119 } else if (t==DOUBLE||t==FLOAT) {
2120 if (reg_arg<MAX_INPUT_REGISTER_VAR) { 2120 if (reg_arg<MAX_INPUT_REGISTER_VAR) {
2121 /* sigh... 2121 /* sigh...
2122 printf requies floating value in integer registers 2122 printf requires floating value in integer registers
2123 */ 2123 */
2124 if (dots) { 2124 if (dots) {
2125 if (car(e4)==DRLVAR) { 2125 if (car(e4)==DRLVAR) {
2126 special_lvar = cadr(e4); 2126 special_lvar = cadr(e4);
2127 e5 = list2(LVAR,special_lvar); 2127 e5 = list2(LVAR,special_lvar);
2149 INT,INT), arg_assign); 2149 INT,INT), arg_assign);
2150 } 2150 }
2151 } 2151 }
2152 if (dots && freg_arg>=4 && freg_arg<MAX_INPUT_DREGISTER_VAR) { 2152 if (dots && freg_arg>=4 && freg_arg<MAX_INPUT_DREGISTER_VAR) {
2153 /* oh my god! 2153 /* oh my god!
2154 it requies integer register and floating register and 2154 it requires integer register and floating register and
2155 stack value. You are crazy. 2155 stack value. You are crazy.
2156 */ 2156 */
2157 arg_assign = list2( 2157 arg_assign = list2(
2158 assign_expr0(list2(LVAR,caller_arg_offset_v(nargs)), 2158 assign_expr0(list2(LVAR,caller_arg_offset_v(nargs)),
2159 get_input_dregister_var(freg_arg,0,0,1),t,t), 2159 get_input_dregister_var(freg_arg,0,0,1),t,t),
2951 if(mode!=GDECL && mode!=STADECL) { 2951 if(mode!=GDECL && mode!=STADECL) {
2952 error(-1); return; 2952 error(-1); return;
2953 } 2953 }
2954 if (chk) return; 2954 if (chk) return;
2955 if (n->dsp != -1) { 2955 if (n->dsp != -1) {
2956 n->dsp = -1; /* initiallized flag */ 2956 n->dsp = -1; /* initialized flag */
2957 printf(".globl\t_%s\n",name); 2957 printf(".globl\t_%s\n",name);
2958 data_mode(name); 2958 data_mode(name);
2959 align(t); 2959 align(t);
2960 printf("_%s:\n",name); 2960 printf("_%s:\n",name);
2961 } else { 2961 } else {
4965 4965
4966 /* 4966 /*
4967 prepare asm operands 4967 prepare asm operands
4968 4968
4969 char *constraints sgtring 4969 char *constraints sgtring
4970 int oeprand expre 4970 int oeprand expr
4971 int mode (ASM_INPUT,ASM_OUTPUT) 4971 int mode (ASM_INPUT,ASM_OUTPUT)
4972 int replacement list 4972 int replacement list
4973 int output operands count 4973 int output operands count
4974 int output operands replacement list 4974 int output operands replacement list
4975 4975