aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Stallman <rms@gnu.org>1993-03-31 20:41:33 +0000
committerRichard Stallman <rms@gnu.org>1993-03-31 20:41:33 +0000
commit990a1e466c9390b4d94fbfb129f7fd121e006df9 (patch)
tree08ebb8df336130432053ca1aa5beb8ab85e9d2d5
parent969e811dc6ed792f1c6386e5b7141e444294f4d6 (diff)
downloadgcc-990a1e466c9390b4d94fbfb129f7fd121e006df9.zip
gcc-990a1e466c9390b4d94fbfb129f7fd121e006df9.tar.gz
gcc-990a1e466c9390b4d94fbfb129f7fd121e006df9.tar.bz2
(check_float_value): New function.
From-SVN: r3959
-rw-r--r--gcc/config/vax/vax.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c
index bd63746..d5d9c34 100644
--- a/gcc/config/vax/vax.c
+++ b/gcc/config/vax/vax.c
@@ -577,6 +577,66 @@ vax_rtx_cost (x)
}
return c;
}
+
+/* Check a `double' 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;
+
+
+void
+check_float_value (mode, d)
+ enum machine_mode mode;
+ REAL_VALUE_TYPE *d;
+{
+
+ 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))
+ {
+ error ("magnitude of constant too large for `float'");
+ bcopy (&float_values[0], d, sizeof (REAL_VALUE_TYPE));
+ }
+ else if (REAL_VALUES_LESS (r, float_values[1]))
+ {
+ error ("magnitude of constant too large for `float'");
+ bcopy (&float_values[1], d, sizeof (REAL_VALUE_TYPE));
+ }
+ else if (REAL_VALUES_LESS (dconst0, r)
+ && REAL_VALUES_LESS (r, float_values[2]))
+ {
+ warning ("`float' constant truncated to zero");
+ bcopy (&dconst0, d, sizeof (REAL_VALUE_TYPE));
+ }
+ else if (REAL_VALUES_LESS (r, dconst0)
+ && REAL_VALUES_LESS (float_values[3], r))
+ {
+ warning ("`float' constant truncated to zero");
+ bcopy (&dconst0, d, sizeof (REAL_VALUE_TYPE));
+ }
+ }
+}
/* Linked list of all externals that are to be emitted when optimizing
for the global pointer if they haven't been declared by the end of