1*1da177e4SLinus Torvalds /* 2*1da177e4SLinus Torvalds NetWinder Floating Point Emulator 3*1da177e4SLinus Torvalds (c) Rebel.COM, 1998,1999 4*1da177e4SLinus Torvalds 5*1da177e4SLinus Torvalds Direct questions, comments to Scott Bambrough <scottb@netwinder.org> 6*1da177e4SLinus Torvalds 7*1da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify 8*1da177e4SLinus Torvalds it under the terms of the GNU General Public License as published by 9*1da177e4SLinus Torvalds the Free Software Foundation; either version 2 of the License, or 10*1da177e4SLinus Torvalds (at your option) any later version. 11*1da177e4SLinus Torvalds 12*1da177e4SLinus Torvalds This program is distributed in the hope that it will be useful, 13*1da177e4SLinus Torvalds but WITHOUT ANY WARRANTY; without even the implied warranty of 14*1da177e4SLinus Torvalds MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*1da177e4SLinus Torvalds GNU General Public License for more details. 16*1da177e4SLinus Torvalds 17*1da177e4SLinus Torvalds You should have received a copy of the GNU General Public License 18*1da177e4SLinus Torvalds along with this program; if not, write to the Free Software 19*1da177e4SLinus Torvalds Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20*1da177e4SLinus Torvalds */ 21*1da177e4SLinus Torvalds 22*1da177e4SLinus Torvalds #include <linux/config.h> 23*1da177e4SLinus Torvalds #include "fpa11.h" 24*1da177e4SLinus Torvalds #include "softfloat.h" 25*1da177e4SLinus Torvalds #include "fpopcode.h" 26*1da177e4SLinus Torvalds #include "fpsr.h" 27*1da177e4SLinus Torvalds #include "fpmodule.h" 28*1da177e4SLinus Torvalds #include "fpmodule.inl" 29*1da177e4SLinus Torvalds 30*1da177e4SLinus Torvalds #ifdef CONFIG_FPE_NWFPE_XP 31*1da177e4SLinus Torvalds const floatx80 floatx80Constant[] = { 32*1da177e4SLinus Torvalds {0x0000, 0x0000000000000000ULL}, /* extended 0.0 */ 33*1da177e4SLinus Torvalds {0x3fff, 0x8000000000000000ULL}, /* extended 1.0 */ 34*1da177e4SLinus Torvalds {0x4000, 0x8000000000000000ULL}, /* extended 2.0 */ 35*1da177e4SLinus Torvalds {0x4000, 0xc000000000000000ULL}, /* extended 3.0 */ 36*1da177e4SLinus Torvalds {0x4001, 0x8000000000000000ULL}, /* extended 4.0 */ 37*1da177e4SLinus Torvalds {0x4001, 0xa000000000000000ULL}, /* extended 5.0 */ 38*1da177e4SLinus Torvalds {0x3ffe, 0x8000000000000000ULL}, /* extended 0.5 */ 39*1da177e4SLinus Torvalds {0x4002, 0xa000000000000000ULL} /* extended 10.0 */ 40*1da177e4SLinus Torvalds }; 41*1da177e4SLinus Torvalds #endif 42*1da177e4SLinus Torvalds 43*1da177e4SLinus Torvalds const float64 float64Constant[] = { 44*1da177e4SLinus Torvalds 0x0000000000000000ULL, /* double 0.0 */ 45*1da177e4SLinus Torvalds 0x3ff0000000000000ULL, /* double 1.0 */ 46*1da177e4SLinus Torvalds 0x4000000000000000ULL, /* double 2.0 */ 47*1da177e4SLinus Torvalds 0x4008000000000000ULL, /* double 3.0 */ 48*1da177e4SLinus Torvalds 0x4010000000000000ULL, /* double 4.0 */ 49*1da177e4SLinus Torvalds 0x4014000000000000ULL, /* double 5.0 */ 50*1da177e4SLinus Torvalds 0x3fe0000000000000ULL, /* double 0.5 */ 51*1da177e4SLinus Torvalds 0x4024000000000000ULL /* double 10.0 */ 52*1da177e4SLinus Torvalds }; 53*1da177e4SLinus Torvalds 54*1da177e4SLinus Torvalds const float32 float32Constant[] = { 55*1da177e4SLinus Torvalds 0x00000000, /* single 0.0 */ 56*1da177e4SLinus Torvalds 0x3f800000, /* single 1.0 */ 57*1da177e4SLinus Torvalds 0x40000000, /* single 2.0 */ 58*1da177e4SLinus Torvalds 0x40400000, /* single 3.0 */ 59*1da177e4SLinus Torvalds 0x40800000, /* single 4.0 */ 60*1da177e4SLinus Torvalds 0x40a00000, /* single 5.0 */ 61*1da177e4SLinus Torvalds 0x3f000000, /* single 0.5 */ 62*1da177e4SLinus Torvalds 0x41200000 /* single 10.0 */ 63*1da177e4SLinus Torvalds }; 64*1da177e4SLinus Torvalds 65*1da177e4SLinus Torvalds /* condition code lookup table 66*1da177e4SLinus Torvalds index into the table is test code: EQ, NE, ... LT, GT, AL, NV 67*1da177e4SLinus Torvalds bit position in short is condition code: NZCV */ 68*1da177e4SLinus Torvalds static const unsigned short aCC[16] = { 69*1da177e4SLinus Torvalds 0xF0F0, // EQ == Z set 70*1da177e4SLinus Torvalds 0x0F0F, // NE 71*1da177e4SLinus Torvalds 0xCCCC, // CS == C set 72*1da177e4SLinus Torvalds 0x3333, // CC 73*1da177e4SLinus Torvalds 0xFF00, // MI == N set 74*1da177e4SLinus Torvalds 0x00FF, // PL 75*1da177e4SLinus Torvalds 0xAAAA, // VS == V set 76*1da177e4SLinus Torvalds 0x5555, // VC 77*1da177e4SLinus Torvalds 0x0C0C, // HI == C set && Z clear 78*1da177e4SLinus Torvalds 0xF3F3, // LS == C clear || Z set 79*1da177e4SLinus Torvalds 0xAA55, // GE == (N==V) 80*1da177e4SLinus Torvalds 0x55AA, // LT == (N!=V) 81*1da177e4SLinus Torvalds 0x0A05, // GT == (!Z && (N==V)) 82*1da177e4SLinus Torvalds 0xF5FA, // LE == (Z || (N!=V)) 83*1da177e4SLinus Torvalds 0xFFFF, // AL always 84*1da177e4SLinus Torvalds 0 // NV 85*1da177e4SLinus Torvalds }; 86*1da177e4SLinus Torvalds 87*1da177e4SLinus Torvalds unsigned int checkCondition(const unsigned int opcode, const unsigned int ccodes) 88*1da177e4SLinus Torvalds { 89*1da177e4SLinus Torvalds return (aCC[opcode >> 28] >> (ccodes >> 28)) & 1; 90*1da177e4SLinus Torvalds } 91