fpopcode.c 2.9 KB

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