Adding frsqrte and fixing fsqrt o_o

This commit is contained in:
Ben Vanik 2015-05-16 13:22:49 -07:00
parent 6239ff9616
commit 504b855c20
9 changed files with 81 additions and 4 deletions

View File

@ -130,8 +130,17 @@ XEEMITTER(fresx, 0xEC000030, A)(PPCHIRBuilder& f, InstrData& i) {
}
XEEMITTER(frsqrtex, 0xFC000034, A)(PPCHIRBuilder& f, InstrData& i) {
XEINSTRNOTIMPLEMENTED();
return 1;
// Double precision:
// frD <- 1/sqrt(frB)
Value* v = f.RSqrt(f.LoadFPR(i.A.FRB));
f.StoreFPR(i.A.FRT, v);
// f.UpdateFPRF(v);
if (i.A.Rc) {
// e.update_cr_with_cond(1, v);
XEINSTRNOTIMPLEMENTED();
return 1;
}
return 0;
}
XEEMITTER(fsubx, 0xFC000028, A)(PPCHIRBuilder& f, InstrData& i) {
@ -179,7 +188,7 @@ XEEMITTER(fselx, 0xFC00002E, A)(PPCHIRBuilder& f, InstrData& i) {
XEEMITTER(fsqrtx, 0xFC00002C, A)(PPCHIRBuilder& f, InstrData& i) {
// Double precision:
// frD <- sqrt(frB)
Value* v = f.Sqrt(f.LoadFPR(i.A.FRA));
Value* v = f.Sqrt(f.LoadFPR(i.A.FRB));
f.StoreFPR(i.A.FRT, v);
// f.UpdateFPRF(v);
if (i.A.Rc) {
@ -193,7 +202,7 @@ XEEMITTER(fsqrtx, 0xFC00002C, A)(PPCHIRBuilder& f, InstrData& i) {
XEEMITTER(fsqrtsx, 0xEC00002C, A)(PPCHIRBuilder& f, InstrData& i) {
// Single precision:
// frD <- sqrt(frB)
Value* v = f.Sqrt(f.LoadFPR(i.A.FRA));
Value* v = f.Sqrt(f.LoadFPR(i.A.FRB));
v = f.Convert(f.Convert(v, FLOAT32_TYPE), FLOAT64_TYPE);
f.StoreFPR(i.A.FRT, v);
// f.UpdateFPRF(v);

Binary file not shown.

View File

@ -0,0 +1,13 @@
Disassembly of section .text:
0000000000100000 <test_frsqrte_1>:
100000: fc 20 08 34 frsqrte f1,f1
100004: 4e 80 00 20 blr
0000000000100008 <test_frsqrte_2>:
100008: fc 20 08 34 frsqrte f1,f1
10000c: 4e 80 00 20 blr
0000000000100010 <test_frsqrte_3>:
100010: fc 20 08 34 frsqrte f1,f1
100014: 4e 80 00 20 blr

View File

@ -0,0 +1,3 @@
0000000000000000 t test_frsqrte_1
0000000000000008 t test_frsqrte_2
0000000000000010 t test_frsqrte_3

Binary file not shown.

View File

@ -0,0 +1,13 @@
Disassembly of section .text:
0000000000100000 <test_fsqrt_1>:
100000: fc 20 08 2c fsqrt f1,f1
100004: 4e 80 00 20 blr
0000000000100008 <test_fsqrt_2>:
100008: fc 20 08 2c fsqrt f1,f1
10000c: 4e 80 00 20 blr
0000000000100010 <test_fsqrt_3>:
100010: fc 20 08 2c fsqrt f1,f1
100014: 4e 80 00 20 blr

View File

@ -0,0 +1,3 @@
0000000000000000 t test_fsqrt_1
0000000000000008 t test_fsqrt_2
0000000000000010 t test_fsqrt_3

View File

@ -0,0 +1,19 @@
test_frsqrte_1:
#_ REGISTER_IN f1 1.0
frsqrte f1, f1
blr
#_ REGISTER_OUT f1 0.99975585937500000
# want: 0.97
test_frsqrte_2:
#_ REGISTER_IN f1 64.0
frsqrte f1, f1
blr
#_ REGISTER_OUT f1 0.12496948242187500
test_frsqrte_3:
#_ REGISTER_IN f1 0.5
frsqrte f1, f1
blr
#_ REGISTER_OUT f1 1.4138183593750000
# want: 1.375

View File

@ -0,0 +1,17 @@
test_fsqrt_1:
#_ REGISTER_IN f1 1.0
fsqrt f1, f1
blr
#_ REGISTER_OUT f1 1.0000000000000000
test_fsqrt_2:
#_ REGISTER_IN f1 64.0
fsqrt f1, f1
blr
#_ REGISTER_OUT f1 8.0000000000000000
test_fsqrt_3:
#_ REGISTER_IN f1 0.5
fsqrt f1, f1
blr
#_ REGISTER_OUT f1 0.70710678118654757