aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-04-13 20:16:55 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1996-04-13 20:16:55 -0400
commita874dd182c0ccbe5ca9109b014c2787598a292a6 (patch)
tree1efffdd0f6955f349733cac177a6474cb3878bf4
parent89a2944c3b346b6c32a38af04bf75bf48146ee77 (diff)
downloadgcc-a874dd182c0ccbe5ca9109b014c2787598a292a6.zip
gcc-a874dd182c0ccbe5ca9109b014c2787598a292a6.tar.gz
gcc-a874dd182c0ccbe5ca9109b014c2787598a292a6.tar.bz2
(check_float_value): New function.
From-SVN: r11757
-rw-r--r--gcc/config/alpha/alpha.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c
index 3eaf8e4..4d1af85 100644
--- a/gcc/config/alpha/alpha.c
+++ b/gcc/config/alpha/alpha.c
@@ -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;
+}