Mercurial > hg > CbC > old > device
comparison mc-code-powerpc.c @ 216:941177f65d07
*** empty log message ***
author | kono |
---|---|
date | Sat, 24 Apr 2004 18:45:30 +0900 |
parents | abfad046e6de |
children | a4d3818f5353 |
comparison
equal
deleted
inserted
replaced
215:abfad046e6de | 216:941177f65d07 |
---|---|
1445 regs[regv_h(reg)]=USING_REG; | 1445 regs[regv_h(reg)]=USING_REG; |
1446 if (creg!=ireg) free_register(creg); | 1446 if (creg!=ireg) free_register(creg); |
1447 free_register(creg); | 1447 free_register(creg); |
1448 } | 1448 } |
1449 creg = freg = reg; | 1449 creg = freg = reg; |
1450 } | |
1451 | |
1452 void | |
1453 set_lreg_operand(int oreg,int mode) | |
1454 { | |
1455 wefwef wefwef | |
1450 } | 1456 } |
1451 | 1457 |
1452 void | 1458 void |
1453 use_reg(int arg) | 1459 use_reg(int arg) |
1454 { | 1460 { |
3300 static char *asld_lib[] = { | 3306 static char *asld_lib[] = { |
3301 ".data", | 3307 ".data", |
3302 /* ".literal8", */ | 3308 /* ".literal8", */ |
3303 " .align 3", | 3309 " .align 3", |
3304 "__u2dLC1:", | 3310 "__u2dLC1:", |
3305 " .long 1127219200", | |
3306 " .long 0", | |
3307 ".text", | |
3308 " .align 2", | |
3309 "u2d_:", | |
3310 " mflr r0", | |
3311 " bcl 20,31,__u2dL2$pb", | |
3312 "__u2dL2$pb:", | |
3313 " mflr r10", | |
3314 " mtlr r0", | |
3315 " stw r3,-28(r30)", | |
3316 " lis r0,0x4330", | |
3317 " stw r0,-32(r30)", | |
3318 " lfd f0,-32(r30)", | |
3319 " addis r9,r10,ha16(__u2dLC1-__u2dL2$pb)", | |
3320 " lfd f1,lo16(__u2dLC1-__u2dL2$pb)(r9)", | |
3321 " fsub f1,f0,f1", | |
3322 " blr", | 3311 " blr", |
3323 0 | 3312 0 |
3324 }; | 3313 }; |
3325 | 3314 |
3326 void | 3315 static int asld_lib_used=0; |
3327 code_asld_lib(int creg0) | 3316 static char *asld_lib_lib[] = { |
3317 }; | |
3318 | |
3319 static int lumod_lib_used=0; | |
3320 static char *lumod_lib_lib[] = { | |
3321 }; | |
3322 | |
3323 static int lmod_lib_used=0; | |
3324 static char *lmod_lib_lib[] = { | |
3325 }; | |
3326 | |
3327 static int ludiv_lib_used=0; | |
3328 static char *ludiv_lib_lib[] = { | |
3329 }; | |
3330 | |
3331 static int ldiv_lib_used=0; | |
3332 static char *ldiv_lib_lib[] = { | |
3333 }; | |
3334 | |
3335 static int lsrd_lib_used=0; | |
3336 static char *lsrd_lib_lib[] = { | |
3337 }; | |
3338 | |
3339 static int asrd_lib_used=0; | |
3340 static char *asrd_lib_lib[] = { | |
3341 }; | |
3342 | |
3343 #if FLOAT_CODE | |
3344 static int dl2ll_lib_used=0; | |
3345 static char *dl2ll_lib_lib[] = { | |
3346 }; | |
3347 | |
3348 static int d2ull_lib_used=0; | |
3349 static char *d2ull_lib_lib[] = { | |
3350 }; | |
3351 | |
3352 static int f2ll_lib_used=0; | |
3353 static char *f2ll_lib_lib[] = { | |
3354 }; | |
3355 | |
3356 static int f2ull_lib_used=0; | |
3357 static char *f2ull_lib_lib[] = { | |
3358 }; | |
3359 | |
3360 static int ll2d_lib_used=0; | |
3361 static char *ll2d_lib_lib[] = { | |
3362 }; | |
3363 | |
3364 static int ll2f_lib_used=0; | |
3365 static char *ll2f_lib_lib[] = { | |
3366 }; | |
3367 | |
3368 #endif | |
3369 | |
3370 static void | |
3371 code_asld_lib(int oreg) | |
3328 { | 3372 { |
3329 code_save_stacks(); | 3373 code_save_stacks(); |
3330 clear_ptr_cache(); | 3374 clear_ptr_cache(); |
3331 asld_lib_used = 1; | 3375 asld_lib_used = 1; |
3376 set_lreg(RET_LREGISTER,1); | |
3377 set_lreg_operand(oreg,1); | |
3332 printf("\tbl asld_\n"); | 3378 printf("\tbl asld_\n"); |
3379 } | |
3380 | |
3381 static void | |
3382 code_asrd_lib(int oreg) // ___ashrdi3$stub | |
3383 { | |
3384 code_save_stacks(); | |
3385 clear_ptr_cache(); | |
3386 asrd_lib_used = 1; | |
3387 set_lreg(RET_LREGISTER,1); | |
3388 set_lreg_operand(oreg,1); | |
3389 printf("\tbl asrd_\n"); | |
3390 } | |
3391 | |
3392 static void | |
3393 code_lsrd_lib(int oreg) // ___lshrdi3$stub | |
3394 { | |
3395 code_save_stacks(); | |
3396 clear_ptr_cache(); | |
3397 lsrd_lib_used = 1; | |
3398 set_lreg(RET_LREGISTER,1); | |
3399 set_lreg_operand(oreg,1); | |
3400 printf("\tbl lsrd_\n"); | |
3401 } | |
3402 | |
3403 static void | |
3404 code_ldiv_lib(int oreg) // ___divdi3$stub | |
3405 { | |
3406 code_save_stacks(); | |
3407 clear_ptr_cache(); | |
3408 ldiv_lib_used = 1; | |
3409 set_lreg_operand(oreg,1); | |
3410 set_lreg(RET_LREGISTER,1); | |
3411 printf("\tbl ldiv_\n"); | |
3412 } | |
3413 | |
3414 static void | |
3415 code_ludiv_lib(int oreg) // ___udivdi3$stub | |
3416 { | |
3417 code_save_stacks(); | |
3418 clear_ptr_cache(); | |
3419 ludiv_lib_used = 1; | |
3420 set_lreg_operand(oreg,1); | |
3421 set_lreg(RET_LREGISTER,1); | |
3422 printf("\tbl ludiv_\n"); | |
3423 } | |
3424 | |
3425 static void | |
3426 code_lmod_lib(int oreg) // ___moddi3$stub | |
3427 { | |
3428 code_save_stacks(); | |
3429 clear_ptr_cache(); | |
3430 lmod_lib_used = 1; | |
3431 set_lreg_operand(oreg,1); | |
3432 set_lreg(RET_LREGISTER,1); | |
3433 printf("\tbl lmod_\n"); | |
3434 } | |
3435 | |
3436 static void | |
3437 code_lumod_lib(int oreg) // ___umoddi3$stub | |
3438 { | |
3439 code_save_stacks(); | |
3440 clear_ptr_cache(); | |
3441 lumod_lib_used = 1; | |
3442 set_lreg_operand(oreg,1); | |
3443 set_lreg(RET_LREGISTER,1); | |
3444 printf("\tbl lumod_\n"); | |
3333 } | 3445 } |
3334 | 3446 |
3335 void | 3447 void |
3336 ltosop(int op,int oreg) | 3448 ltosop(int op,int oreg) |
3337 { | 3449 { |
3425 error(-1); | 3537 error(-1); |
3426 } | 3538 } |
3427 if(oreg!=creg) free_register(oreg); | 3539 if(oreg!=creg) free_register(oreg); |
3428 } | 3540 } |
3429 | 3541 |
3430 int code_lconst_op_p(int op,int e) | 3542 int |
3543 code_lconst_op_p(int op,int e) | |
3431 { | 3544 { |
3432 int v; | 3545 int v; |
3433 if (car(e)==LCONST) { | 3546 if (car(e)==LCONST) { |
3434 if (!(-32766<lcaddr(e)&&lcaddr(e)<32767)) return 0; | 3547 if (!(-32766<lcaddr(e)&&lcaddr(e)<32767)) return 0; |
3435 v = lcaddr(e); | 3548 v = lcaddr(e); |
3452 default: | 3565 default: |
3453 return 0; | 3566 return 0; |
3454 } | 3567 } |
3455 } | 3568 } |
3456 | 3569 |
3570 void | |
3457 loprtc(int op,int e) | 3571 loprtc(int op,int e) |
3458 { | 3572 { |
3459 char *crn_h = lregister_name_high(creg); | 3573 char *crn_h = lregister_name_high(creg); |
3460 char *crn_l = lregister_name_low(creg); | 3574 char *crn_l = lregister_name_low(creg); |
3461 char *grn; | 3575 char *grn; |
3596 { | 3710 { |
3597 code_ll2i(creg); | 3711 code_ll2i(creg); |
3598 } | 3712 } |
3599 | 3713 |
3600 #if FLOAT_CODE | 3714 #if FLOAT_CODE |
3715 | |
3601 void | 3716 void |
3602 code_d2ll(int creg) | 3717 code_d2ll(int creg) |
3603 { | 3718 { |
3604 creg = use_longlong(creg0=creg); | |
3605 // fixdfdi$stub | 3719 // fixdfdi$stub |
3720 code_save_stacks(); | |
3721 clear_ptr_cache(); | |
3722 dl2ll_lib_used = 1; | |
3723 set_freg(RET_DREGISTER,1); | |
3724 printf("\tbl d2ll_\n"); | |
3725 set_lreg(RET_LREGISTER,0); | |
3606 } | 3726 } |
3607 | 3727 |
3608 void | 3728 void |
3609 code_d2ull(int creg) | 3729 code_d2ull(int creg) |
3610 { | 3730 { |
3611 creg = use_longlong(creg0=creg); | |
3612 // fixunsdfdi$stub | 3731 // fixunsdfdi$stub |
3732 code_save_stacks(); | |
3733 clear_ptr_cache(); | |
3734 d2ull_lib_used = 1; | |
3735 set_freg(RET_DREGISTER,1); | |
3736 printf("\tbl d2ull\n"); | |
3737 set_lreg(RET_LREGISTER,0); | |
3613 } | 3738 } |
3614 | 3739 |
3615 void | 3740 void |
3616 code_f2ll(int creg) | 3741 code_f2ll(int creg) |
3617 { | 3742 { |
3618 creg = use_longlong(creg0=creg); | |
3619 // fixdfdi$stub | 3743 // fixdfdi$stub |
3620 | 3744 code_save_stacks(); |
3745 clear_ptr_cache(); | |
3746 f2ll_lib_used = 1; | |
3747 set_freg(RET_DREGISTER,1); | |
3748 printf("\tbl f2ll\n"); | |
3749 set_lreg(RET_LREGISTER,0); | |
3621 } | 3750 } |
3622 | 3751 |
3623 void | 3752 void |
3624 code_f2ull(int creg) | 3753 code_f2ull(int creg) |
3625 { | 3754 { |
3626 creg = use_longlong(creg0=creg); | |
3627 // fixsfdi$stub | 3755 // fixsfdi$stub |
3756 code_save_stacks(); | |
3757 clear_ptr_cache(); | |
3758 f2ull_lib_used = 1; | |
3759 set_freg(RET_DREGISTER,1); | |
3760 printf("\tbl f2ull\n"); | |
3761 set_lreg(RET_LREGISTER,0); | |
3628 } | 3762 } |
3629 | 3763 |
3630 void | 3764 void |
3631 code_ll2d(int creg) | 3765 code_ll2d(int creg) |
3632 { | 3766 { |
3633 creg = use_double(creg0=creg); | |
3634 // floatdidf$stub | 3767 // floatdidf$stub |
3768 code_save_stacks(); | |
3769 clear_ptr_cache(); | |
3770 ll2d_lib_used = 1; | |
3771 set_lreg(RET_LREGISTER,1); | |
3772 printf("\tbl ll2d\n"); | |
3773 set_freg(RET_DREGISTER,0); | |
3635 } | 3774 } |
3636 | 3775 |
3637 void | 3776 void |
3638 code_ll2f(int creg) | 3777 code_ll2f(int creg) |
3639 { | 3778 { |
3640 creg = use_float(creg0=creg); | |
3641 // floatdisf$stub | 3779 // floatdisf$stub |
3780 code_save_stacks(); | |
3781 clear_ptr_cache(); | |
3782 ll2f_lib_used = 1; | |
3783 set_lreg(RET_LREGISTER,1); | |
3784 printf("\tbl ll2f\n"); | |
3785 set_freg(RET_DREGISTER,0); | |
3642 } | 3786 } |
3643 | 3787 |
3644 void | 3788 void |
3645 code_ull2d(int creg) | 3789 code_ull2d(int creg) |
3646 { | 3790 { |
3804 if (float_one_lib_used) emit_lib(float_one_lib); | 3948 if (float_one_lib_used) emit_lib(float_one_lib); |
3805 if (float_zero_lib_used) emit_lib(float_zero_lib); | 3949 if (float_zero_lib_used) emit_lib(float_zero_lib); |
3806 if (i2d_lib_used) emit_lib(i2d_lib); | 3950 if (i2d_lib_used) emit_lib(i2d_lib); |
3807 #endif | 3951 #endif |
3808 #if LONGLONG_CODE | 3952 #if LONGLONG_CODE |
3953 if (asld_lib_used) emit_lib(d2u_lib); | |
3954 if (lumod_lib_used) emit_lib(lumod_lib); | |
3955 if (lmod_lib_used) emit_lib(lmod_lib); | |
3956 if (ludiv_lib_used) emit_lib(ludiv_lib); | |
3957 if (ldiv_lib_used) emit_lib(ldiv_lib); | |
3958 if (lsrd_lib_used) emit_lib(lsrd_lib); | |
3959 if (asrd_lib_used) emit_lib(asrd_lib); | |
3809 #if FLOAT_CODE | 3960 #if FLOAT_CODE |
3810 if (asld_lib_used) emit_lib(d2u_lib); | 3961 if (dl2ll_lib_used) emit_lib(dl2ll_lib); |
3962 if (d2ull_lib_used) emit_lib(d2ull_lib); | |
3963 if (f2ll_lib_used) emit_lib(f2ll_lib); | |
3964 if (f2ull_lib_used) emit_lib(f2ull_lib); | |
3965 if (ll2d_lib_used) emit_lib(ll2d_lib); | |
3966 if (ll2f_lib_used) emit_lib(ll2f_lib); | |
3811 #endif | 3967 #endif |
3812 #endif | 3968 #endif |
3813 global_table(); | 3969 global_table(); |
3814 /* printf("\t.ident \"Micro-C compiled\"\n"); */ | 3970 /* printf("\t.ident \"Micro-C compiled\"\n"); */ |
3815 } | 3971 } |