Mercurial > hg > CbC > old > device
comparison mc-code-powerpc.c @ 217:a4d3818f5353
*** empty log message ***
author | kono |
---|---|
date | Sat, 24 Apr 2004 21:44:50 +0900 |
parents | 941177f65d07 |
children | 2d64e82437d2 |
comparison
equal
deleted
inserted
replaced
216:941177f65d07 | 217:a4d3818f5353 |
---|---|
1448 } | 1448 } |
1449 creg = freg = reg; | 1449 creg = freg = reg; |
1450 } | 1450 } |
1451 | 1451 |
1452 void | 1452 void |
1453 set_lreg_operand(int oreg,int mode) | 1453 set_lreg_operand(int reg,int mode) |
1454 { | 1454 { |
1455 wefwef wefwef | 1455 // save_stack,clear_ptr_cache is assmued |
1456 if (!is_longlong_reg(reg)) { error(-1); return; } | |
1457 if (mode) { | |
1458 if (regv_l(reg)!=5) | |
1459 printf("\tmr r5,%s\n", lregister_name_low(reg)); | |
1460 if (regv_l(reg)!=6) | |
1461 printf("\tmr r6,%s\n", lregister_name_high(reg)); | |
1462 } | |
1456 } | 1463 } |
1457 | 1464 |
1458 void | 1465 void |
1459 use_reg(int arg) | 1466 use_reg(int arg) |
1460 { | 1467 { |
3300 lvar_intro(e1); | 3307 lvar_intro(e1); |
3301 printf("\tlwz %s,",crn_h); lvar(e1); | 3308 printf("\tlwz %s,",crn_h); lvar(e1); |
3302 printf("\tlwz %s,",crn_l); lvar(e1+size_of_int); | 3309 printf("\tlwz %s,",crn_l); lvar(e1+size_of_int); |
3303 } | 3310 } |
3304 | 3311 |
3312 static int lumod_lib_used=0; | |
3313 static char *lumod_lib[] = { | |
3314 }; | |
3315 | |
3316 static int lmod_lib_used=0; | |
3317 static char *lmod_lib[] = { | |
3318 }; | |
3319 | |
3320 static int ludiv_lib_used=0; | |
3321 static char *ludiv_lib[] = { | |
3322 }; | |
3323 | |
3324 static int ldiv_lib_used=0; | |
3325 static char *ldiv_lib[] = { | |
3326 }; | |
3327 | |
3328 static int lsrd_lib_used=0; | |
3329 static char *lsrd_lib[] = { | |
3330 ".text", | |
3331 " .align 2", | |
3332 "lsrd__:", | |
3333 " mr. r5,r5", | |
3334 " beqlr", | |
3335 " subfic r2,r5,32", | |
3336 " stw r3,-32(r1)", | |
3337 " stw r4,-28(r1)", | |
3338 " cmpwi cr7,r2,0", | |
3339 " bgt+ cr7,L__lsrd1", | |
3340 " neg r0,r2", | |
3341 " lwz r2,-32(r1)", | |
3342 " li r9,0", | |
3343 " srw r2,r2,r0", | |
3344 " stw r9,-48(r1)", | |
3345 " b L__lsrd2", | |
3346 "L__lsrd1: lwz r0,-32(r1)", | |
3347 " slw r9,r0,r2", | |
3348 " lwz r2,-28(r1)", | |
3349 " srw r0,r0,r5", | |
3350 " srw r2,r2,r5", | |
3351 " stw r0,-48(r1)", | |
3352 " or r2,r2,r9", | |
3353 "L__lsrd2: stw r2,-44(r1)", | |
3354 " lwz r3,-48(r1)", | |
3355 " lwz r4,-44(r1)", | |
3356 " blr", | |
3357 }; | |
3358 | |
3305 static int asld_lib_used=0; | 3359 static int asld_lib_used=0; |
3306 static char *asld_lib[] = { | 3360 static char *asld_lib[] = { |
3307 ".data", | 3361 ".text", |
3308 /* ".literal8", */ | 3362 " .align 2", |
3309 " .align 3", | 3363 "asld__:", |
3310 "__u2dLC1:", | 3364 " mr. r5,r5", |
3311 " blr", | 3365 " beqlr", |
3312 0 | 3366 " subfic r2,r5,32", |
3367 " stw r3,-32(r1)", | |
3368 " stw r4,-28(r1)", | |
3369 " cmpwi cr7,r2,0", | |
3370 " bgt+ cr7,L__asld1", | |
3371 " neg r0,r2", | |
3372 " lwz r2,-28(r1)", | |
3373 " li r9,0", | |
3374 " slw r2,r2,r0", | |
3375 " stw r9,-44(r1)", | |
3376 " b L__asld2", | |
3377 "L__asld1: lwz r0,-28(r1)", | |
3378 " srw r9,r0,r2", | |
3379 " lwz r2,-32(r1)", | |
3380 " slw r0,r0,r5", | |
3381 " slw r2,r2,r5", | |
3382 " stw r0,-44(r1)", | |
3383 " or r2,r2,r9", | |
3384 "L__asld2: stw r2,-48(r1)", | |
3385 " lwz r3,-48(r1)", | |
3386 " lwz r4,-44(r1)", | |
3387 " blr", | |
3313 }; | 3388 }; |
3314 | 3389 |
3315 static int asld_lib_used=0; | 3390 static int asrd_lib_used=0; |
3316 static char *asld_lib_lib[] = { | 3391 static char *asrd_lib[] = { |
3392 ".text", | |
3393 " .align 2", | |
3394 "asrd__:", | |
3395 " mr. r5,r5", | |
3396 " beqlr", | |
3397 " subfic r2,r5,32", | |
3398 " stw r3,-32(r1)", | |
3399 " stw r4,-28(r1)", | |
3400 " cmpwi cr7,r2,0", | |
3401 " bgt+ cr7,L__asrd1", | |
3402 " lwz r0,-32(r1)", | |
3403 " neg r2,r2", | |
3404 " sraw r2,r0,r2", | |
3405 " srawi r0,r0,31", | |
3406 " b L__asrd2", | |
3407 "L__asrd1: lwz r0,-32(r1)", | |
3408 " slw r9,r0,r2", | |
3409 " lwz r2,-28(r1)", | |
3410 " sraw r0,r0,r5", | |
3411 " srw r2,r2,r5", | |
3412 " or r2,r2,r9", | |
3413 "L__asrd2: stw r0,-48(r1)", | |
3414 " stw r2,-44(r1)", | |
3415 " lwz r3,-48(r1)", | |
3416 " lwz r4,-44(r1)", | |
3417 " blr", | |
3317 }; | 3418 }; |
3318 | 3419 |
3319 static int lumod_lib_used=0; | 3420 static void |
3320 static char *lumod_lib_lib[] = { | 3421 extern_conv(char *conv) |
3422 { | |
3423 code_save_stacks(); | |
3424 clear_ptr_cache(); | |
3425 extern_define(conv,0,FUNCTION,1); | |
3426 printf("\tbl L_%s$stub\n",conv); | |
3427 } | |
3428 | |
3429 #if FLOAT_CODE | |
3430 static int d2ll_lib_used=0; | |
3431 static char *d2ll_lib[] = { | |
3321 }; | 3432 }; |
3322 | 3433 |
3323 static int lmod_lib_used=0; | 3434 static int d2ull_lib_used=0; |
3324 static char *lmod_lib_lib[] = { | 3435 static char *d2ull_lib[] = { |
3325 }; | 3436 }; |
3326 | 3437 |
3327 static int ludiv_lib_used=0; | 3438 static int f2ll_lib_used=0; |
3328 static char *ludiv_lib_lib[] = { | 3439 static char *f2ll_lib[] = { |
3329 }; | 3440 }; |
3330 | 3441 |
3331 static int ldiv_lib_used=0; | 3442 static int f2ull_lib_used=0; |
3332 static char *ldiv_lib_lib[] = { | 3443 static char *f2ull_lib[] = { |
3333 }; | 3444 }; |
3334 | 3445 |
3335 static int lsrd_lib_used=0; | 3446 static int ll2d_lib_used=0; |
3336 static char *lsrd_lib_lib[] = { | 3447 static char *ll2d_lib[] = { |
3337 }; | 3448 }; |
3338 | 3449 |
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; | 3450 static int ll2f_lib_used=0; |
3365 static char *ll2f_lib_lib[] = { | 3451 static char *ll2f_lib[] = { |
3366 }; | 3452 }; |
3367 | 3453 |
3368 #endif | 3454 #endif |
3369 | 3455 |
3370 static void | 3456 static void |
3401 } | 3487 } |
3402 | 3488 |
3403 static void | 3489 static void |
3404 code_ldiv_lib(int oreg) // ___divdi3$stub | 3490 code_ldiv_lib(int oreg) // ___divdi3$stub |
3405 { | 3491 { |
3406 code_save_stacks(); | |
3407 clear_ptr_cache(); | |
3408 ldiv_lib_used = 1; | |
3409 set_lreg_operand(oreg,1); | 3492 set_lreg_operand(oreg,1); |
3410 set_lreg(RET_LREGISTER,1); | 3493 set_lreg(RET_LREGISTER,1); |
3411 printf("\tbl ldiv_\n"); | 3494 extern_conv("__divdi3"); |
3412 } | 3495 } |
3413 | 3496 |
3414 static void | 3497 static void |
3415 code_ludiv_lib(int oreg) // ___udivdi3$stub | 3498 code_ludiv_lib(int oreg) // ___udivdi3$stub |
3416 { | 3499 { |
3417 code_save_stacks(); | |
3418 clear_ptr_cache(); | |
3419 ludiv_lib_used = 1; | |
3420 set_lreg_operand(oreg,1); | 3500 set_lreg_operand(oreg,1); |
3421 set_lreg(RET_LREGISTER,1); | 3501 set_lreg(RET_LREGISTER,1); |
3422 printf("\tbl ludiv_\n"); | 3502 extern_conv("__udivdi3"); |
3423 } | 3503 } |
3424 | 3504 |
3425 static void | 3505 static void |
3426 code_lmod_lib(int oreg) // ___moddi3$stub | 3506 code_lmod_lib(int oreg) // ___moddi3$stub |
3427 { | 3507 { |
3428 code_save_stacks(); | |
3429 clear_ptr_cache(); | |
3430 lmod_lib_used = 1; | |
3431 set_lreg_operand(oreg,1); | 3508 set_lreg_operand(oreg,1); |
3432 set_lreg(RET_LREGISTER,1); | 3509 set_lreg(RET_LREGISTER,1); |
3433 printf("\tbl lmod_\n"); | 3510 extern_conv("__moddi3"); |
3434 } | 3511 } |
3435 | 3512 |
3436 static void | 3513 static void |
3437 code_lumod_lib(int oreg) // ___umoddi3$stub | 3514 code_lumod_lib(int oreg) // ___umoddi3$stub |
3438 { | 3515 { |
3439 code_save_stacks(); | |
3440 clear_ptr_cache(); | |
3441 lumod_lib_used = 1; | |
3442 set_lreg_operand(oreg,1); | 3516 set_lreg_operand(oreg,1); |
3443 set_lreg(RET_LREGISTER,1); | 3517 set_lreg(RET_LREGISTER,1); |
3444 printf("\tbl lumod_\n"); | 3518 extern_conv("__umoddi3"); |
3445 } | 3519 } |
3446 | 3520 |
3447 void | 3521 void |
3448 ltosop(int op,int oreg) | 3522 ltosop(int op,int oreg) |
3449 { | 3523 { |
3715 | 3789 |
3716 void | 3790 void |
3717 code_d2ll(int creg) | 3791 code_d2ll(int creg) |
3718 { | 3792 { |
3719 // fixdfdi$stub | 3793 // fixdfdi$stub |
3720 code_save_stacks(); | |
3721 clear_ptr_cache(); | |
3722 dl2ll_lib_used = 1; | |
3723 set_freg(RET_DREGISTER,1); | 3794 set_freg(RET_DREGISTER,1); |
3724 printf("\tbl d2ll_\n"); | 3795 extern_conv("_fixdfdi"); |
3725 set_lreg(RET_LREGISTER,0); | 3796 set_lreg(RET_LREGISTER,0); |
3726 } | 3797 } |
3727 | 3798 |
3728 void | 3799 void |
3729 code_d2ull(int creg) | 3800 code_d2ull(int creg) |
3730 { | 3801 { |
3731 // fixunsdfdi$stub | |
3732 code_save_stacks(); | |
3733 clear_ptr_cache(); | |
3734 d2ull_lib_used = 1; | |
3735 set_freg(RET_DREGISTER,1); | 3802 set_freg(RET_DREGISTER,1); |
3736 printf("\tbl d2ull\n"); | 3803 extern_conv("_fixunsdfdi"); |
3737 set_lreg(RET_LREGISTER,0); | 3804 set_lreg(RET_LREGISTER,0); |
3738 } | 3805 } |
3739 | 3806 |
3740 void | 3807 void |
3741 code_f2ll(int creg) | 3808 code_f2ll(int creg) |
3742 { | 3809 { |
3743 // fixdfdi$stub | |
3744 code_save_stacks(); | |
3745 clear_ptr_cache(); | |
3746 f2ll_lib_used = 1; | |
3747 set_freg(RET_DREGISTER,1); | 3810 set_freg(RET_DREGISTER,1); |
3748 printf("\tbl f2ll\n"); | 3811 extern_conv("_fixdfdi"); |
3749 set_lreg(RET_LREGISTER,0); | 3812 set_lreg(RET_LREGISTER,0); |
3750 } | 3813 } |
3751 | 3814 |
3752 void | 3815 void |
3753 code_f2ull(int creg) | 3816 code_f2ull(int creg) |
3754 { | 3817 { |
3755 // fixsfdi$stub | |
3756 code_save_stacks(); | |
3757 clear_ptr_cache(); | |
3758 f2ull_lib_used = 1; | |
3759 set_freg(RET_DREGISTER,1); | 3818 set_freg(RET_DREGISTER,1); |
3760 printf("\tbl f2ull\n"); | 3819 extern_conv("_fixsfdi"); |
3761 set_lreg(RET_LREGISTER,0); | 3820 set_lreg(RET_LREGISTER,0); |
3762 } | 3821 } |
3763 | 3822 |
3764 void | 3823 void |
3765 code_ll2d(int creg) | 3824 code_ll2d(int creg) |
3766 { | 3825 { |
3767 // floatdidf$stub | |
3768 code_save_stacks(); | |
3769 clear_ptr_cache(); | |
3770 ll2d_lib_used = 1; | |
3771 set_lreg(RET_LREGISTER,1); | 3826 set_lreg(RET_LREGISTER,1); |
3772 printf("\tbl ll2d\n"); | 3827 extern_conv("_floatdidf"); |
3773 set_freg(RET_DREGISTER,0); | 3828 set_freg(RET_DREGISTER,0); |
3774 } | 3829 } |
3775 | 3830 |
3831 | |
3776 void | 3832 void |
3777 code_ll2f(int creg) | 3833 code_ll2f(int creg) |
3778 { | 3834 { |
3779 // floatdisf$stub | |
3780 code_save_stacks(); | |
3781 clear_ptr_cache(); | |
3782 ll2f_lib_used = 1; | |
3783 set_lreg(RET_LREGISTER,1); | 3835 set_lreg(RET_LREGISTER,1); |
3784 printf("\tbl ll2f\n"); | 3836 extern_conv("_floatdisf"); |
3785 set_freg(RET_DREGISTER,0); | 3837 set_freg(RET_DREGISTER,0); |
3786 } | 3838 } |
3787 | 3839 |
3788 void | 3840 void |
3789 code_ull2d(int creg) | 3841 code_ull2d(int creg) |