OSDN Git Service

(check_float_value): New function.
authorkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 14 Apr 1996 00:16:55 +0000 (00:16 +0000)
committerkenner <kenner@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 14 Apr 1996 00:16:55 +0000 (00:16 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@11757 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/config/alpha/alpha.c

index 3eaf8e4..4d1af85 100644 (file)
@@ -2172,3 +2172,67 @@ final_prescan_insn (insn, opvec, noperands)
       trap_pending = 1;
     }
 }
+
+/* Check a floating-point value for validity for a particular machine mode.  */
+
+static char *float_strings[] =
+{
+   "1.70141173319264430e+38", /* 2^127 (2^24 - 1) / 2^24 */
+  "-1.70141173319264430e+38",
+   "2.93873587705571877e-39", /* 2^-128 */
+  "-2.93873587705571877e-39"
+};
+
+static REAL_VALUE_TYPE float_values[4];
+static int inited_float_values = 0;
+
+int
+check_float_value (mode, d, overflow)
+     enum machine_mode mode;
+     REAL_VALUE_TYPE *d;
+     int overflow;
+{
+
+  if (TARGET_IEEE || TARGET_IEEE_CONFORMANT || TARGET_IEEE_WITH_INEXACT)
+    return 0;
+
+  if (inited_float_values == 0)
+    {
+      int i;
+      for (i = 0; i < 4; i++)
+       float_values[i] = REAL_VALUE_ATOF (float_strings[i], DFmode);
+
+      inited_float_values = 1;
+    }
+
+  if (mode == SFmode)
+    {
+      REAL_VALUE_TYPE r;
+
+      bcopy (d, &r, sizeof (REAL_VALUE_TYPE));
+      if (REAL_VALUES_LESS (float_values[0], r))
+       {
+         bcopy (&float_values[0], d, sizeof (REAL_VALUE_TYPE));
+         return 1;
+       }
+      else if (REAL_VALUES_LESS (r, float_values[1]))
+       {
+         bcopy (&float_values[1], d, sizeof (REAL_VALUE_TYPE));
+         return 1;
+       }
+      else if (REAL_VALUES_LESS (dconst0, r)
+               && REAL_VALUES_LESS (r, float_values[2]))
+       {
+         bcopy (&dconst0, d, sizeof (REAL_VALUE_TYPE));
+         return 1;
+       }
+      else if (REAL_VALUES_LESS (r, dconst0)
+               && REAL_VALUES_LESS (float_values[3], r))
+       {
+         bcopy (&dconst0, d, sizeof (REAL_VALUE_TYPE));
+         return 1;
+       }
+    }
+
+  return 0;
+}