Mercurial > hg > CbC > old > device
comparison mc-code-arm.c @ 935:7672a37e7545 default tip
Raspbery PI ARM support begin
author | kono |
---|---|
date | Sat, 24 Dec 2016 03:02:57 +0000 |
parents | 35b339b36c88 |
children |
comparison
equal
deleted
inserted
replaced
934:b7f4ff38a3bf | 935:7672a37e7545 |
---|---|
225 | 225 |
226 static char *reg_name[] = { "xx", | 226 static char *reg_name[] = { "xx", |
227 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", | 227 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", |
228 "r8", "r9", "sl", "lr", "ip", "fp", "sp", "pc", | 228 "r8", "r9", "sl", "lr", "ip", "fp", "sp", "pc", |
229 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7" | 229 "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7" |
230 // "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7", | |
231 // "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", | |
232 "s0", "s2", "s4", "s6", "s8", "s10","s12", "s14", | |
233 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7", | |
230 }; | 234 }; |
231 | 235 |
232 #define register_name(i) reg_name[i] | 236 #define register_name(i) reg_name[i] |
233 #define fregister_name(i) reg_name[i] | 237 #define fregister_name(i) reg_name[i] |
238 #define dregister_name(i) reg_name[i+8] | |
234 #define lregister_name_low(i) reg_name[regv_l(i)] | 239 #define lregister_name_low(i) reg_name[regv_l(i)] |
235 #define lregister_name_high(i) reg_name[regv_h(i)] | 240 #define lregister_name_high(i) reg_name[regv_h(i)] |
236 | 241 |
237 char *rn(int i) { return register_name(i); } | 242 char *rn(int i) { return register_name(i); } |
238 char *fn(int i) { return fregister_name(i); } | 243 char *fn(int i) { return fregister_name(i); } |
244 char *dn(int i) { return dregister_name(i+8); } | |
239 char *lln(int i) { return lregister_name_low(i); } | 245 char *lln(int i) { return lregister_name_low(i); } |
240 char *lhn(int i) { return lregister_name_high(i); } | 246 char *lhn(int i) { return lregister_name_high(i); } |
241 int ll(int i) { return regv_l(i); } | 247 int ll(int i) { return regv_l(i); } |
242 int lh(int i) { return regv_h(i); } | 248 int lh(int i) { return regv_h(i); } |
243 | 249 |
3483 #if FLOAT_CODE | 3489 #if FLOAT_CODE |
3484 creg = freg = cadr(get_input_dregister_var(0,0,1,0)); | 3490 creg = freg = cadr(get_input_dregister_var(0,0,1,0)); |
3485 set_freg(RET_FREGISTER,1); | 3491 set_freg(RET_FREGISTER,1); |
3486 #endif | 3492 #endif |
3487 printf("\tmov\t%s, %s\n",register_name( | 3493 printf("\tmov\t%s, %s\n",register_name( |
3488 cadr(get_input_register_var(1,0,1,0)); | 3494 cadr(get_input_register_var(1,0,0)) |
3489 ),register_name(REG_fp)); | 3495 ),register_name(REG_fp)); |
3490 } else if (cadr(fnptr->ty)==DOUBLE) { | 3496 } else if (cadr(fnptr->ty)==DOUBLE) { |
3491 #if FLOAT_CODE | 3497 #if FLOAT_CODE |
3492 creg = lreg = cadr(get_input_dregister_var(0,0,1,1)); | 3498 creg = lreg = cadr(get_input_dregister_var(0,0,1,1)); |
3493 set_dreg(RET_DREGISTER,1); | 3499 set_dreg(RET_DREGISTER,1); |
3494 printf("\tmov\t%s, %s\n",register_name( | 3500 printf("\tmov\t%s, %s\n",register_name( |
3495 cadr(get_input_register_var(2,0,1,0)); | 3501 cadr(get_input_register_var(2,0,0)) |
3496 ),register_name(REG_fp)); | 3502 ),register_name(REG_fp)); |
3497 #endif | 3503 #endif |
3498 } else if (cadr(fnptr->ty)>0&&( | 3504 } else if (cadr(fnptr->ty)>0&&( |
3499 car(cadr(fnptr->ty))==STRUCT || | 3505 car(cadr(fnptr->ty))==STRUCT || |
3500 car(cadr(fnptr->ty))==UNION)) { | 3506 car(cadr(fnptr->ty))==UNION)) { |
3502 inc_inst(3); | 3508 inc_inst(3); |
3503 code_const(sz,REGISTER_OPERAND); | 3509 code_const(sz,REGISTER_OPERAND); |
3504 printf("\tsub\tr1, r2, fp\n"); | 3510 printf("\tsub\tr1, r2, fp\n"); |
3505 printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT); | 3511 printf("\tldr\tr0, [fp, #%d]\n",(my_func_args-1)*SIZE_OF_INT); |
3506 printf("\tmov\t%s, %s\n",register_name( | 3512 printf("\tmov\t%s, %s\n",register_name( |
3507 cadr(get_input_register_var(1,0,1,0)); | 3513 cadr(get_input_register_var(1,0,0)) |
3508 ),register_name(REG_fp)); | 3514 ),register_name(REG_fp)); |
3509 // emit_copy(6,3,sz,0,1,1); | 3515 // emit_copy(6,3,sz,0,1,1); |
3510 } else if (cadr(fnptr->ty)!=VOID) { | 3516 } else if (cadr(fnptr->ty)!=VOID) { |
3511 creg = ireg = cadr(get_input_register_var(0,0,1)); | 3517 creg = ireg = cadr(get_input_register_var(0,0,1)); |
3512 if (creg!=RET_REGISTER) | 3518 if (creg!=RET_REGISTER) |
3513 set_ireg(RET_REGISTER,1); | 3519 set_ireg(RET_REGISTER,1); |
3514 printf("\tmov\t%s, %s\n",register_name( | 3520 printf("\tmov\t%s, %s\n",register_name( |
3515 cadr(get_input_register_var(1,0,1,0)); | 3521 cadr(get_input_register_var(1,0,1)) |
3516 ),register_name(REG_fp)); | 3522 ),register_name(REG_fp)); |
3517 } | 3523 } |
3518 code_unfix_frame_pointer(); | 3524 code_unfix_frame_pointer(); |
3519 } | 3525 } |
3520 | 3526 |
3679 cstring_mode(); | 3685 cstring_mode(); |
3680 printf(".L%d:\n",lb); | 3686 printf(".L%d:\n",lb); |
3681 return lb; | 3687 return lb; |
3682 } | 3688 } |
3683 | 3689 |
3684 extern void | 3690 extern void |
3685 emit_string(char *s,int t,long len) | 3691 emit_string(char *s,int t,int len) |
3686 { | 3692 { |
3687 t = type_value(t); | 3693 t = type_value(t); |
3688 if (car(t)==ARRAY && | 3694 if (car(t)==ARRAY && |
3689 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { | 3695 (type_value(cadr(t))==CHAR||type_value(cadr(t))==UCHAR)) { |
3690 ascii(s,len); | 3696 ascii(s,len); |