comparison mc-code-powerpc.c @ 616:2ba903c8e749

builtin_fabs builtin_inf()
author kono
date Wed, 06 Sep 2006 20:58:03 +0900
parents 2dee957ef988
children 72c4a8137fff
comparison
equal deleted inserted replaced
615:2dee957ef988 616:2ba903c8e749
41 #define __inline__ inline\n\ 41 #define __inline__ inline\n\
42 #define __builtin_va_list int\n\ 42 #define __builtin_va_list int\n\
43 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\ 43 #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
44 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\ 44 #define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
45 #define alloca __builtin_alloca\n\ 45 #define alloca __builtin_alloca\n\
46 #define __FLT_MIN__ 1.17549435e-38F\n\
47 #define __DBL_MIN__ 2.2250738585072014e-308\n\
48 #define __LDBL_MIN__ 2.00416836000897277799610805135016e-292L\n\
46 "; 49 ";
47 50
48 #define TEXT_EMIT_MODE 0 51 #define TEXT_EMIT_MODE 0
49 #define DATA_EMIT_MODE 1 52 #define DATA_EMIT_MODE 1
50 #define RODATA_EMIT_MODE 2 53 #define RODATA_EMIT_MODE 2
1324 else { 1327 else {
1325 printf("\tlis %s,ha16(%d)\n",crn,e2); 1328 printf("\tlis %s,ha16(%d)\n",crn,e2);
1326 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,e2); 1329 printf("\taddi %s,%s,lo16(%d)\n",crn,crn,e2);
1327 } 1330 }
1328 } 1331 }
1329
1330 1332
1331 void 1333 void
1332 code_neg(int creg) { 1334 code_neg(int creg) {
1333 use_int(creg); 1335 use_int(creg);
1334 printf("\tneg %s,%s\n", register_name(creg), register_name(creg)); 1336 printf("\tneg %s,%s\n", register_name(creg), register_name(creg));
3453 int *j = (int *)&f; 3455 int *j = (int *)&f;
3454 return *j; 3456 return *j;
3455 } 3457 }
3456 3458
3457 void 3459 void
3458
3459 code_dconst(int e2,int freg,int d) 3460 code_dconst(int e2,int freg,int d)
3460 { 3461 {
3461 int lb; 3462 int lb;
3462 double value = dcadr(e2); 3463 double value = dcadr(e2);
3463 int r; 3464 int r;
3505 } else { 3506 } else {
3506 printf("\tlfs %s,0(%s)\n",frn,rrn); 3507 printf("\tlfs %s,0(%s)\n",frn,rrn);
3507 } 3508 }
3508 free_register(r); 3509 free_register(r);
3509 } 3510 }
3511
3512 void
3513 code_builtin_fabsf(int e)
3514 {
3515 char *frn;
3516 g_expr0(e);
3517 use_float(0,freg);
3518 frn = fregister_name(freg);
3519 printf("\tfabs %s,%s\n",frn,frn);
3520 }
3521
3522 void
3523 code_builtin_fabs(int e)
3524 {
3525 char *frn;
3526 g_expr0(e);
3527 use_float(1,freg);
3528 frn = fregister_name(freg);
3529 printf("\tfabs %s,%s\n",frn,frn);
3530 }
3531
3532 static void
3533 code_inf(int d)
3534 {
3535 int lb;
3536 int r;
3537 char *rrn,*frn;
3538 int freg = USE_CREG;
3539
3540 use_float(d,freg);
3541 frn = fregister_name(freg);
3542 rrn = register_name((r=get_register()));
3543 use_reg(r); // to clear ptr cache
3544 printf(" \t.data\n\t.align 3\n");
3545 lb=fwdlabel();
3546 printf("L_%d:\n",lb);
3547 if (d) {
3548 #if ENDIAN_D==0
3549 printf("\t.long\t0x%x,0x%x\n",0,0x7ff00000);
3550 #else
3551 printf("\t.long\t0x%x,0x%x\n",0x7ff00000,0);
3552 #endif
3553 } else {
3554 printf("\t.long\t0x%x\n",0x7f800000);
3555 }
3556 if (output_mode==TEXT_EMIT_MODE) {
3557 printf(".text\n");
3558 } else {
3559 text_mode(0);
3560 }
3561 printf("\taddis %s,r31,ha16(L_%d-L_%d)\n",rrn,lb,code_base);
3562 printf("\tla %s,lo16(L_%d-L_%d)(%s)\n",rrn,lb,code_base,rrn);
3563 if (d) {
3564 printf("\tlfd %s,0(%s)\n",frn,rrn);
3565 } else {
3566 printf("\tlfs %s,0(%s)\n",frn,rrn);
3567 }
3568 free_register(r);
3569 }
3570
3571 void
3572 code_builtin_inff()
3573 {
3574 code_inf(0);
3575 }
3576
3577 void
3578 code_builtin_inf()
3579 {
3580 code_inf(1);
3581 }
3582
3510 3583
3511 3584
3512 void 3585 void
3513 code_dneg(int freg,int d) 3586 code_dneg(int freg,int d)
3514 { 3587 {