11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds NetWinder Floating Point Emulator 31da177e4SLinus Torvalds (c) Rebel.COM, 1998,1999 41da177e4SLinus Torvalds 51da177e4SLinus Torvalds Direct questions, comments to Scott Bambrough <scottb@netwinder.org> 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds This program is free software; you can redistribute it and/or modify 81da177e4SLinus Torvalds it under the terms of the GNU General Public License as published by 91da177e4SLinus Torvalds the Free Software Foundation; either version 2 of the License, or 101da177e4SLinus Torvalds (at your option) any later version. 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds This program is distributed in the hope that it will be useful, 131da177e4SLinus Torvalds but WITHOUT ANY WARRANTY; without even the implied warranty of 141da177e4SLinus Torvalds MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 151da177e4SLinus Torvalds GNU General Public License for more details. 161da177e4SLinus Torvalds 171da177e4SLinus Torvalds You should have received a copy of the GNU General Public License 181da177e4SLinus Torvalds along with this program; if not, write to the Free Software 191da177e4SLinus Torvalds Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 201da177e4SLinus Torvalds */ 211da177e4SLinus Torvalds 221da177e4SLinus Torvalds #include <linux/config.h> 231da177e4SLinus Torvalds #include "fpa11.h" 241da177e4SLinus Torvalds #include "softfloat.h" 251da177e4SLinus Torvalds #include "fpopcode.h" 261da177e4SLinus Torvalds #include "fpsr.h" 271da177e4SLinus Torvalds #include "fpmodule.h" 281da177e4SLinus Torvalds #include "fpmodule.inl" 291da177e4SLinus Torvalds 301da177e4SLinus Torvalds #ifdef CONFIG_FPE_NWFPE_XP 311da177e4SLinus Torvalds const floatx80 floatx80Constant[] = { 32*06c03cacSLennert Buytenhek { .high = 0x0000, .low = 0x0000000000000000ULL},/* extended 0.0 */ 33*06c03cacSLennert Buytenhek { .high = 0x3fff, .low = 0x8000000000000000ULL},/* extended 1.0 */ 34*06c03cacSLennert Buytenhek { .high = 0x4000, .low = 0x8000000000000000ULL},/* extended 2.0 */ 35*06c03cacSLennert Buytenhek { .high = 0x4000, .low = 0xc000000000000000ULL},/* extended 3.0 */ 36*06c03cacSLennert Buytenhek { .high = 0x4001, .low = 0x8000000000000000ULL},/* extended 4.0 */ 37*06c03cacSLennert Buytenhek { .high = 0x4001, .low = 0xa000000000000000ULL},/* extended 5.0 */ 38*06c03cacSLennert Buytenhek { .high = 0x3ffe, .low = 0x8000000000000000ULL},/* extended 0.5 */ 39*06c03cacSLennert Buytenhek { .high = 0x4002, .low = 0xa000000000000000ULL},/* extended 10.0 */ 401da177e4SLinus Torvalds }; 411da177e4SLinus Torvalds #endif 421da177e4SLinus Torvalds 431da177e4SLinus Torvalds const float64 float64Constant[] = { 441da177e4SLinus Torvalds 0x0000000000000000ULL, /* double 0.0 */ 451da177e4SLinus Torvalds 0x3ff0000000000000ULL, /* double 1.0 */ 461da177e4SLinus Torvalds 0x4000000000000000ULL, /* double 2.0 */ 471da177e4SLinus Torvalds 0x4008000000000000ULL, /* double 3.0 */ 481da177e4SLinus Torvalds 0x4010000000000000ULL, /* double 4.0 */ 491da177e4SLinus Torvalds 0x4014000000000000ULL, /* double 5.0 */ 501da177e4SLinus Torvalds 0x3fe0000000000000ULL, /* double 0.5 */ 511da177e4SLinus Torvalds 0x4024000000000000ULL /* double 10.0 */ 521da177e4SLinus Torvalds }; 531da177e4SLinus Torvalds 541da177e4SLinus Torvalds const float32 float32Constant[] = { 551da177e4SLinus Torvalds 0x00000000, /* single 0.0 */ 561da177e4SLinus Torvalds 0x3f800000, /* single 1.0 */ 571da177e4SLinus Torvalds 0x40000000, /* single 2.0 */ 581da177e4SLinus Torvalds 0x40400000, /* single 3.0 */ 591da177e4SLinus Torvalds 0x40800000, /* single 4.0 */ 601da177e4SLinus Torvalds 0x40a00000, /* single 5.0 */ 611da177e4SLinus Torvalds 0x3f000000, /* single 0.5 */ 621da177e4SLinus Torvalds 0x41200000 /* single 10.0 */ 631da177e4SLinus Torvalds }; 641da177e4SLinus Torvalds 651da177e4SLinus Torvalds /* condition code lookup table 661da177e4SLinus Torvalds index into the table is test code: EQ, NE, ... LT, GT, AL, NV 671da177e4SLinus Torvalds bit position in short is condition code: NZCV */ 681da177e4SLinus Torvalds static const unsigned short aCC[16] = { 691da177e4SLinus Torvalds 0xF0F0, // EQ == Z set 701da177e4SLinus Torvalds 0x0F0F, // NE 711da177e4SLinus Torvalds 0xCCCC, // CS == C set 721da177e4SLinus Torvalds 0x3333, // CC 731da177e4SLinus Torvalds 0xFF00, // MI == N set 741da177e4SLinus Torvalds 0x00FF, // PL 751da177e4SLinus Torvalds 0xAAAA, // VS == V set 761da177e4SLinus Torvalds 0x5555, // VC 771da177e4SLinus Torvalds 0x0C0C, // HI == C set && Z clear 781da177e4SLinus Torvalds 0xF3F3, // LS == C clear || Z set 791da177e4SLinus Torvalds 0xAA55, // GE == (N==V) 801da177e4SLinus Torvalds 0x55AA, // LT == (N!=V) 811da177e4SLinus Torvalds 0x0A05, // GT == (!Z && (N==V)) 821da177e4SLinus Torvalds 0xF5FA, // LE == (Z || (N!=V)) 831da177e4SLinus Torvalds 0xFFFF, // AL always 841da177e4SLinus Torvalds 0 // NV 851da177e4SLinus Torvalds }; 861da177e4SLinus Torvalds 871da177e4SLinus Torvalds unsigned int checkCondition(const unsigned int opcode, const unsigned int ccodes) 881da177e4SLinus Torvalds { 891da177e4SLinus Torvalds return (aCC[opcode >> 28] >> (ccodes >> 28)) & 1; 901da177e4SLinus Torvalds } 91