This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

More floating point: kill do_float_handler


While I'm pondering the proper way to deal with the
REAL_VALUE_TO_TARGET_* macros, here's a quickie to get rid of
do_float_handler (which is no longer necessary, since the emulator
can't generate hardware floating-point exceptions).

I also tweaked an unhelpful warning message.

Bootstrapped i686-linux.

zw

	* toplev.c: Don't include setjmp.h.  Kill float_handler_set,
	float_handled, float_handler, float_signal, set_float_handler,
	and do_float_handler.  Set handler for SIGFPE to crash_signal.
	* toplev.h: Don't prototype do_float_handler.

	* c-lex.c: Fold parse_float into lex_number.  Make warning
	about portability of hex float constants more informative, and
	don't issue it on top of a syntax error.
	* fold-const.c: Fold const_binop_1 and fold_convert_1 into
	their callers.
	* real.h: Define REAL_VALUE_ABS here...
	* simplify-rtx.c: ... not here.  Fold check_fold_consts,
	simplify_unary_real, simplify_binary_real, and
	simplify_binary_is2orm1 into their callers.
	* tree.c: Fold build_real_from_int_cst_1 into caller.
	* java/lex.c: Change java_perform_atof to take normal
	parameters instead of a pointer to a parameter block.  Call it
	directly from java_lex.

	* testsuite/gcc.dg/c90-hexfloat-1.c: Adjust error regexps.
	* doc/tm.texi: Document REAL_VALUE_ABS and REAL_VALUE_NEGATIVE.

===================================================================
Index: c-lex.c
--- c-lex.c	2002/03/20 05:06:51	1.168
+++ c-lex.c	2002/03/23 09:27:42
@@ -84,7 +84,6 @@ int c_header_level;	 /* depth in C heade
 /* Nonzero tells yylex to ignore \ in string constants.  */
 static int ignore_escape_flag;
 
-static void parse_float		PARAMS ((PTR));
 static tree lex_number		PARAMS ((const char *, unsigned int));
 static tree lex_string		PARAMS ((const unsigned char *, unsigned int,
 					 int));
@@ -703,67 +702,6 @@ struct try_type type_sequence[] =
 };
 #endif /* 0 */
 
-struct pf_args
-{
-  /* Input */
-  const char *str;
-  int fflag;
-  int lflag;
-  int base;
-  /* Output */
-  int conversion_errno;
-  REAL_VALUE_TYPE value;
-  tree type;
-};
- 
-static void
-parse_float (data)
-  PTR data;
-{
-  struct pf_args * args = (struct pf_args *) data;
-  const char *typename;
-
-  args->conversion_errno = 0;
-  args->type = double_type_node;
-  typename = "double";
-
-  /* The second argument, machine_mode, of REAL_VALUE_ATOF
-     tells the desired precision of the binary result
-     of decimal-to-binary conversion.  */
-
-  if (args->fflag)
-    {
-      if (args->lflag)
-	error ("both 'f' and 'l' suffixes on floating constant");
-
-      args->type = float_type_node;
-      typename = "float";
-    }
-  else if (args->lflag)
-    {
-      args->type = long_double_type_node;
-      typename = "long double";
-    }
-  else if (flag_single_precision_constant)
-    {
-      args->type = float_type_node;
-      typename = "float";
-    }
-
-  errno = 0;
-  if (args->base == 16)
-    args->value = REAL_VALUE_HTOF (args->str, TYPE_MODE (args->type));
-  else
-    args->value = REAL_VALUE_ATOF (args->str, TYPE_MODE (args->type));
-
-  args->conversion_errno = errno;
-  /* A diagnostic is required here by some ISO C testsuites.
-     This is not pedwarn, because some people don't want
-     an error for this.  */
-  if (REAL_VALUE_ISINF (args->value) && pedantic)
-    warning ("floating point number exceeds range of '%s'", typename);
-}
- 
 int
 c_lex (value)
      tree *value;
@@ -974,14 +912,11 @@ lex_number (str, len)
   if (floatflag != NOT_FLOAT)
     {
       tree type;
-      int imag, fflag, lflag, conversion_errno;
+      const char *typename;
+      int imag, fflag, lflag;
       REAL_VALUE_TYPE real;
-      struct pf_args args;
       char *copy;
 
-      if (base == 16 && pedantic && !flag_isoc99)
-	pedwarn ("floating constant may not be in radix 16");
-
       if (base == 16 && floatflag != AFTER_EXPON)
 	ERROR ("hexadecimal floating constant has no exponent");
 
@@ -1046,34 +981,45 @@ lex_number (str, len)
 	    ERROR ("invalid suffix on floating constant");
 	  }
 
-      /* Setup input for parse_float() */
-      args.str = copy;
-      args.fflag = fflag;
-      args.lflag = lflag;
-      args.base = base;
+      type = double_type_node;
+      typename = "double";
+	
+      if (fflag)
+	{
+	  if (lflag)
+	    ERROR ("both 'f' and 'l' suffixes on floating constant");
 
-      /* Convert string to a double, checking for overflow.  */
-      if (do_float_handler (parse_float, (PTR) &args))
+	  type = float_type_node;
+	  typename = "float";
+	}
+      else if (lflag)
+	{
+	  type = long_double_type_node;
+	  typename = "long double";
+	}
+      else if (flag_single_precision_constant)
 	{
-	  /* Receive output from parse_float() */
-	  real = args.value;
+	  type = float_type_node;
+	  typename = "float";
 	}
+
+      /* Warn about this only after we know we're not issuing an error.  */
+      if (base == 16 && pedantic && !flag_isoc99)
+	pedwarn ("hexadecimal floating constants are only valid in C99");
+
+      /* The second argument, machine_mode, of REAL_VALUE_ATOF
+	 tells the desired precision of the binary result
+	 of decimal-to-binary conversion.  */
+      if (base == 16)
+	real = REAL_VALUE_HTOF (copy, TYPE_MODE (type));
       else
-	  /* We got an exception from parse_float() */
-	  ERROR ("floating constant out of range");
+	real = REAL_VALUE_ATOF (copy, TYPE_MODE (type));
 
-      /* Receive output from parse_float() */
-      conversion_errno = args.conversion_errno;
-      type = args.type;
-	    
-#ifdef ERANGE
-      /* ERANGE is also reported for underflow,
-	 so test the value to distinguish overflow from that.  */
-      if (conversion_errno == ERANGE && pedantic
-	  && (REAL_VALUES_LESS (dconst1, real)
-	      || REAL_VALUES_LESS (real, dconstm1)))
+      /* A diagnostic is required here by some ISO C testsuites.
+	 This is not pedwarn, because some people don't want
+	 an error for this.  */
+      if (REAL_VALUE_ISINF (real) && pedantic)
 	warning ("floating point number exceeds range of 'double'");
-#endif
 
       /* Create a node with determined type and value.  */
       if (imag)
===================================================================
Index: fold-const.c
--- fold-const.c	2002/03/23 01:10:30	1.190
+++ fold-const.c	2002/03/23 09:27:43
@@ -65,11 +65,9 @@ static tree split_tree		PARAMS ((tree, e
 					 int));
 static tree associate_trees	PARAMS ((tree, tree, enum tree_code, tree));
 static tree int_const_binop	PARAMS ((enum tree_code, tree, tree, int));
-static void const_binop_1	PARAMS ((PTR));
 static tree const_binop		PARAMS ((enum tree_code, tree, tree, int));
 static hashval_t size_htab_hash	PARAMS ((const void *));
 static int size_htab_eq		PARAMS ((const void *, const void *));
-static void fold_convert_1	PARAMS ((PTR));
 static tree fold_convert	PARAMS ((tree, tree));
 static enum tree_code invert_tree_comparison PARAMS ((enum tree_code));
 static enum tree_code swap_tree_comparison PARAMS ((enum tree_code));
@@ -1199,32 +1197,6 @@ int_const_binop (code, arg1, arg2, notru
   return t;
 }
 
-/* Define input and output argument for const_binop_1.  */
-struct cb_args
-{
-  enum tree_code code;		/* Input: tree code for operation.  */
-  tree type;			/* Input: tree type for operation.  */
-  REAL_VALUE_TYPE d1, d2;	/* Input: floating point operands.  */
-  tree t;			/* Output: constant for result.  */
-};
-
-/* Do the real arithmetic for const_binop while protected by a
-   float overflow handler.  */
-
-static void
-const_binop_1 (data)
-     PTR data;
-{
-  struct cb_args *args = (struct cb_args *) data;
-  REAL_VALUE_TYPE value;
-
-  REAL_ARITHMETIC (value, args->code, args->d1, args->d2);
-
-  args->t
-    = build_real (args->type,
-		  real_value_truncate (TYPE_MODE (args->type), value));
-}
-
 /* Combine two constants ARG1 and ARG2 under operation CODE to produce a new
    constant.  We assume ARG1 and ARG2 have the same data type, or at least
    are the same kind of constant and the same machine mode.
@@ -1247,9 +1219,8 @@ const_binop (code, arg1, arg2, notrunc)
     {
       REAL_VALUE_TYPE d1;
       REAL_VALUE_TYPE d2;
-      int overflow = 0;
+      REAL_VALUE_TYPE value;
       tree t;
-      struct cb_args args;
 
       d1 = TREE_REAL_CST (arg1);
       d2 = TREE_REAL_CST (arg2);
@@ -1261,24 +1232,14 @@ const_binop (code, arg1, arg2, notrunc)
       else if (REAL_VALUE_ISNAN (d2))
 	return arg2;
 
-      /* Setup input for const_binop_1() */
-      args.type = TREE_TYPE (arg1);
-      args.d1 = d1;
-      args.d2 = d2;
-      args.code = code;
-
-      if (do_float_handler (const_binop_1, (PTR) &args))
-	/* Receive output from const_binop_1.  */
-	t = args.t;
-      else
-	{
-	  /* We got an exception from const_binop_1.  */
-	  t = copy_node (arg1);
-	  overflow = 1;
-	}
+      REAL_ARITHMETIC (value, code, d1, d2);
+
+      t = build_real (TREE_TYPE (arg1),
+		      real_value_truncate (TYPE_MODE (TREE_TYPE (arg1)),
+					   value));
 
       TREE_OVERFLOW (t)
-	= (force_fit_type (t, overflow)
+	= (force_fit_type (t, 0)
 	   | TREE_OVERFLOW (arg1) | TREE_OVERFLOW (arg2));
       TREE_CONSTANT_OVERFLOW (t)
 	= TREE_OVERFLOW (t)
@@ -1530,28 +1491,7 @@ size_diffop (arg0, arg1)
 		       convert (ctype, size_binop (MINUS_EXPR, arg1, arg0)));
 }
 
-/* This structure is used to communicate arguments to fold_convert_1.  */
-struct fc_args
-{
-  tree arg1;			/* Input: value to convert.  */
-  tree type;			/* Input: type to convert value to.  */
-  tree t;			/* Output: result of conversion.  */
-};
 
-/* Function to convert floating-point constants, protected by floating
-   point exception handler.  */
-
-static void
-fold_convert_1 (data)
-     PTR data;
-{
-  struct fc_args *args = (struct fc_args *) data;
-
-  args->t = build_real (args->type,
-			real_value_truncate (TYPE_MODE (args->type),
-					     TREE_REAL_CST (args->arg1)));
-}
-
 /* Given T, a tree representing type conversion of ARG1, a constant,
    return a constant tree representing the result of conversion.  */
 
@@ -1650,8 +1590,6 @@ fold_convert (t, arg1)
 	return build_real_from_int_cst (type, arg1);
       if (TREE_CODE (arg1) == REAL_CST)
 	{
-	  struct fc_args args;
-
 	  if (REAL_VALUE_ISNAN (TREE_REAL_CST (arg1)))
 	    {
 	      t = arg1;
@@ -1659,24 +1597,12 @@ fold_convert (t, arg1)
 	      return t;
 	    }
 
-	  /* Setup input for fold_convert_1() */
-	  args.arg1 = arg1;
-	  args.type = type;
+	  t = build_real (type,
+			  real_value_truncate (TYPE_MODE (type),
+					       TREE_REAL_CST (arg1)));
 
-	  if (do_float_handler (fold_convert_1, (PTR) &args))
-	    {
-	      /* Receive output from fold_convert_1() */
-	      t = args.t;
-	    }
-	  else
-	    {
-	      /* We got an exception from fold_convert_1() */
-	      overflow = 1;
-	      t = copy_node (arg1);
-	    }
-
 	  TREE_OVERFLOW (t)
-	    = TREE_OVERFLOW (arg1) | force_fit_type (t, overflow);
+	    = TREE_OVERFLOW (arg1) | force_fit_type (t, 0);
 	  TREE_CONSTANT_OVERFLOW (t)
 	    = TREE_OVERFLOW (t) | TREE_CONSTANT_OVERFLOW (arg1);
 	  return t;
===================================================================
Index: real.h
--- real.h	2002/03/23 01:10:34	1.37
+++ real.h	2002/03/23 09:27:43
@@ -156,6 +156,10 @@ extern REAL_VALUE_TYPE real_value_trunca
 
 #define REAL_VALUE_NEGATE ereal_negate
 
+/* Compute the absolute value of a floating-point value X.  */
+#define REAL_VALUE_ABS(x) \
+   (REAL_VALUE_NEGATIVE (x) ? REAL_VALUE_NEGATE (x) : (x))
+
 /* Determine whether a floating-point value X is infinite.  */
 #define REAL_VALUE_ISINF(x) (target_isinf (x))
 
===================================================================
Index: simplify-rtx.c
--- simplify-rtx.c	2002/03/23 01:10:34	1.100
+++ simplify-rtx.c	2002/03/23 09:27:44
@@ -101,11 +101,6 @@ static int simplify_plus_minus_op_data_c
 static rtx simplify_plus_minus		PARAMS ((enum rtx_code,
 						 enum machine_mode, rtx,
 						 rtx, int));
-static void check_fold_consts		PARAMS ((PTR));
-static void simplify_unary_real		PARAMS ((PTR));
-static void simplify_binary_real	PARAMS ((PTR));
-static void simplify_binary_is2orm1	PARAMS ((PTR));
-
 
 /* Negate a CONST_INT rtx, truncating (because a conversion from a
    maximally negative number can overflow).  */
@@ -341,65 +336,6 @@ simplify_replace_rtx (x, old, new)
   return x;
 }
 
-/* Subroutine of simplify_unary_operation, called via do_float_handler.
-   Handles simplification of unary ops on floating point values.  */
-struct simplify_unary_real_args
-{
-  rtx operand;
-  rtx result;
-  enum machine_mode mode;
-  enum rtx_code code;
-  bool want_integer;
-};
-#define REAL_VALUE_ABS(d_) \
-   (REAL_VALUE_NEGATIVE (d_) ? REAL_VALUE_NEGATE (d_) : (d_))
-
-static void
-simplify_unary_real (p)
-     PTR p;
-{
-  REAL_VALUE_TYPE d;
-
-  struct simplify_unary_real_args *args =
-    (struct simplify_unary_real_args *) p;
-
-  REAL_VALUE_FROM_CONST_DOUBLE (d, args->operand);
-
-  if (args->want_integer)
-    {
-      HOST_WIDE_INT i;
-
-      switch (args->code)
-	{
-	case FIX:		i = REAL_VALUE_FIX (d);		  break;
-	case UNSIGNED_FIX:	i = REAL_VALUE_UNSIGNED_FIX (d);  break;
-	default:
-	  abort ();
-	}
-      args->result = gen_int_mode (i, args->mode);
-    }
-  else
-    {
-      switch (args->code)
-	{
-	case SQRT:
-	  /* We don't attempt to optimize this.  */
-	  args->result = 0;
-	  return;
-
-	case ABS:	      d = REAL_VALUE_ABS (d);			break;
-	case NEG:	      d = REAL_VALUE_NEGATE (d);		break;
-	case FLOAT_TRUNCATE:  d = real_value_truncate (args->mode, d);  break;
-	case FLOAT_EXTEND:    /* All this does is change the mode.  */  break;
-	case FIX:	      d = REAL_VALUE_RNDZINT (d);		break;
-	case UNSIGNED_FIX:    d = REAL_VALUE_UNSIGNED_RNDZINT (d);	break;
-	default:
-	  abort ();
-	}
-      args->result = CONST_DOUBLE_FROM_REAL_VALUE (d, args->mode);
-    }
-}
-
 /* Try to simplify a unary operation CODE whose output mode is to be
    MODE with input operand OP whose mode was originally OP_MODE.
    Return zero if no simplification can be made.  */
@@ -638,16 +574,25 @@ simplify_unary_operation (code, mode, op
   else if (GET_CODE (trueop) == CONST_DOUBLE
 	   && GET_MODE_CLASS (mode) == MODE_FLOAT)
     {
-      struct simplify_unary_real_args args;
-      args.operand = trueop;
-      args.mode = mode;
-      args.code = code;
-      args.want_integer = false;
+      REAL_VALUE_TYPE d;
+      REAL_VALUE_FROM_CONST_DOUBLE (d, trueop);
 
-      if (do_float_handler (simplify_unary_real, (PTR) &args))
-	return args.result;
+      switch (code)
+	{
+	case SQRT:
+	  /* We don't attempt to optimize this.  */
+	  return 0;
 
-      return 0;
+	case ABS:	      d = REAL_VALUE_ABS (d);			break;
+	case NEG:	      d = REAL_VALUE_NEGATE (d);		break;
+	case FLOAT_TRUNCATE:  d = real_value_truncate (mode, d);	break;
+	case FLOAT_EXTEND:    /* All this does is change the mode.  */  break;
+	case FIX:	      d = REAL_VALUE_RNDZINT (d);		break;
+	case UNSIGNED_FIX:    d = REAL_VALUE_UNSIGNED_RNDZINT (d);	break;
+	default:
+	  abort ();
+	}
+      return CONST_DOUBLE_FROM_REAL_VALUE (d, mode);
     }
 
   else if (GET_CODE (trueop) == CONST_DOUBLE
@@ -655,16 +600,17 @@ simplify_unary_operation (code, mode, op
 	   && GET_MODE_CLASS (mode) == MODE_INT
 	   && width <= HOST_BITS_PER_WIDE_INT && width > 0)
     {
-      struct simplify_unary_real_args args;
-      args.operand = trueop;
-      args.mode = mode;
-      args.code = code;
-      args.want_integer = true;
-
-      if (do_float_handler (simplify_unary_real, (PTR) &args))
-	return args.result;
-
-      return 0;
+      HOST_WIDE_INT i;
+      REAL_VALUE_TYPE d;
+      REAL_VALUE_FROM_CONST_DOUBLE (d, trueop);
+      switch (code)
+	{
+	case FIX:		i = REAL_VALUE_FIX (d);		  break;
+	case UNSIGNED_FIX:	i = REAL_VALUE_UNSIGNED_FIX (d);  break;
+	default:
+	  abort ();
+	}
+      return gen_int_mode (i, mode);
     }
 
   /* This was formerly used only for non-IEEE float.
@@ -740,64 +686,6 @@ simplify_unary_operation (code, mode, op
     }
 }
 
-/* Subroutine of simplify_binary_operation, called via do_float_handler.
-   Handles simplification of binary ops on floating point values.  */
-struct simplify_binary_real_args
-{
-  rtx trueop0, trueop1;
-  rtx result;
-  enum rtx_code code;
-  enum machine_mode mode;
-};
-
-static void
-simplify_binary_real (p)
-     PTR p;
-{
-  REAL_VALUE_TYPE f0, f1, value;
-  struct simplify_binary_real_args *args =
-    (struct simplify_binary_real_args *) p;
-
-  REAL_VALUE_FROM_CONST_DOUBLE (f0, args->trueop0);
-  REAL_VALUE_FROM_CONST_DOUBLE (f1, args->trueop1);
-  f0 = real_value_truncate (args->mode, f0);
-  f1 = real_value_truncate (args->mode, f1);
-
-  if (args->code == DIV
-      && !MODE_HAS_INFINITIES (args->mode)
-      && REAL_VALUES_EQUAL (f1, dconst0))
-    {
-      args->result = 0;
-      return;
-    }
-  REAL_ARITHMETIC (value, rtx_to_tree_code (args->code), f0, f1);
-
-  value = real_value_truncate (args->mode, value);
-  args->result = CONST_DOUBLE_FROM_REAL_VALUE (value, args->mode);
-}
-
-/* Another subroutine called via do_float_handler.  This one tests
-   the floating point value given against 2. and -1.  */
-struct simplify_binary_is2orm1_args
-{
-  rtx value;
-  bool is_2;
-  bool is_m1;
-};
-
-static void
-simplify_binary_is2orm1 (p)
-     PTR p;
-{
-  REAL_VALUE_TYPE d;
-  struct simplify_binary_is2orm1_args *args =
-    (struct simplify_binary_is2orm1_args *) p;
-
-  REAL_VALUE_FROM_CONST_DOUBLE (d, args->value);
-  args->is_2 = REAL_VALUES_EQUAL (d, dconst2);
-  args->is_m1 = REAL_VALUES_EQUAL (d, dconstm1);
-}
-
 /* Simplify a binary operation CODE with result mode MODE, operating on OP0
    and OP1.  Return 0 if no simplification is possible.
 
@@ -837,15 +725,22 @@ simplify_binary_operation (code, mode, o
       && GET_CODE (trueop1) == CONST_DOUBLE
       && mode == GET_MODE (op0) && mode == GET_MODE (op1))
     {
-      struct simplify_binary_real_args args;
-      args.trueop0 = trueop0;
-      args.trueop1 = trueop1;
-      args.mode = mode;
-      args.code = code;
+      REAL_VALUE_TYPE f0, f1, value;
 
-      if (do_float_handler (simplify_binary_real, (PTR) &args))
-	return args.result;
-      return 0;
+      REAL_VALUE_FROM_CONST_DOUBLE (f0, trueop0);
+      REAL_VALUE_FROM_CONST_DOUBLE (f1, trueop1);
+      f0 = real_value_truncate (mode, f0);
+      f1 = real_value_truncate (mode, f1);
+
+      if (code == DIV
+	  && !MODE_HAS_INFINITIES (mode)
+	  && REAL_VALUES_EQUAL (f1, dconst0))
+	return 0;
+
+      REAL_ARITHMETIC (value, rtx_to_tree_code (code), f0, f1);
+
+      value = real_value_truncate (mode, value);
+      return CONST_DOUBLE_FROM_REAL_VALUE (value, mode);
     }
 
   /* We can fold some multi-word operations.  */
@@ -1276,20 +1171,18 @@ simplify_binary_operation (code, mode, o
 	      && ! rtx_equal_function_value_matters)
 	    return gen_rtx_ASHIFT (mode, op0, GEN_INT (val));
 
+	  /* x*2 is x+x and x*(-1) is -x */
 	  if (GET_CODE (trueop1) == CONST_DOUBLE
-	      && GET_MODE_CLASS (GET_MODE (trueop1)) == MODE_FLOAT)
+	      && GET_MODE_CLASS (GET_MODE (trueop1)) == MODE_FLOAT
+	      && GET_MODE (op0) == mode)
 	    {
-	      struct simplify_binary_is2orm1_args args;
-
-	      args.value = trueop1;
-	      if (! do_float_handler (simplify_binary_is2orm1, (PTR) &args))
-		return 0;
+	      REAL_VALUE_TYPE d;
+	      REAL_VALUE_FROM_CONST_DOUBLE (d, trueop1);
 
-	      /* x*2 is x+x and x*(-1) is -x */
-	      if (args.is_2 && GET_MODE (op0) == mode)
+	      if (REAL_VALUES_EQUAL (d, dconst2))
 		return gen_rtx_PLUS (mode, op0, copy_rtx (op0));
 
-	      else if (args.is_m1 && GET_MODE (op0) == mode)
+	      if (REAL_VALUES_EQUAL (d, dconstm1))
 		return gen_rtx_NEG (mode, op0);
 	    }
 	  break;
@@ -1923,35 +1816,6 @@ simplify_plus_minus (code, mode, op0, op
   return negate ? gen_rtx_NEG (mode, result) : result;
 }
 
-struct cfc_args
-{
-  rtx op0, op1;			/* Input */
-  int equal, op0lt, op1lt;	/* Output */
-  int unordered;
-};
-
-static void
-check_fold_consts (data)
-  PTR data;
-{
-  struct cfc_args *args = (struct cfc_args *) data;
-  REAL_VALUE_TYPE d0, d1;
-
-  /* We may possibly raise an exception while reading the value.  */
-  args->unordered = 1;
-  REAL_VALUE_FROM_CONST_DOUBLE (d0, args->op0);
-  REAL_VALUE_FROM_CONST_DOUBLE (d1, args->op1);
-
-  /* Comparisons of Inf versus Inf are ordered.  */
-  if (REAL_VALUE_ISNAN (d0)
-      || REAL_VALUE_ISNAN (d1))
-    return;
-  args->equal = REAL_VALUES_EQUAL (d0, d1);
-  args->op0lt = REAL_VALUES_LESS (d0, d1);
-  args->op1lt = REAL_VALUES_LESS (d1, d0);
-  args->unordered = 0;
-}
-
 /* Like simplify_binary_operation except used for relational operators.
    MODE is the mode of the operands, not that of the result.  If MODE
    is VOIDmode, both operands must also be VOIDmode and we compare the
@@ -2035,17 +1899,13 @@ simplify_relational_operation (code, mod
 	   && GET_CODE (trueop1) == CONST_DOUBLE
 	   && GET_MODE_CLASS (GET_MODE (trueop0)) == MODE_FLOAT)
     {
-      struct cfc_args args;
+      REAL_VALUE_TYPE d0, d1;
 
-      /* Setup input for check_fold_consts() */
-      args.op0 = trueop0;
-      args.op1 = trueop1;
-      
-      
-      if (!do_float_handler (check_fold_consts, (PTR) &args))
-	args.unordered = 1;
+      REAL_VALUE_FROM_CONST_DOUBLE (d0, trueop0);
+      REAL_VALUE_FROM_CONST_DOUBLE (d1, trueop1);
 
-      if (args.unordered)
+      /* Comparisons are unordered iff at least one of the values is NaN. */
+      if (REAL_VALUE_ISNAN (d0) || REAL_VALUE_ISNAN (d1))
 	switch (code)
 	  {
 	  case UNEQ:
@@ -2068,10 +1928,9 @@ simplify_relational_operation (code, mod
 	    return 0;
 	  }
 
-      /* Receive output from check_fold_consts() */
-      equal = args.equal;
-      op0lt = op0ltu = args.op0lt;
-      op1lt = op1ltu = args.op1lt;
+      equal = REAL_VALUES_EQUAL (d0, d1);
+      op0lt = op0ltu = REAL_VALUES_LESS (d0, d1);
+      op1lt = op1ltu = REAL_VALUES_LESS (d1, d0);
     }
 
   /* Otherwise, see if the operands are both integers.  */
===================================================================
Index: toplev.c
--- toplev.c	2002/03/22 15:31:53	1.601
+++ toplev.c	2002/03/23 09:27:45
@@ -29,7 +29,6 @@ Software Foundation, 59 Temple Place - S
 #undef FFS  /* Some systems define this in param.h.  */
 #include "system.h"
 #include <signal.h>
-#include <setjmp.h>
 
 #ifdef HAVE_SYS_RESOURCE_H
 # include <sys/resource.h>
@@ -109,9 +108,7 @@ static void finalize PARAMS ((void));
 
 static void set_target_switch PARAMS ((const char *));
 
-static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
-static void set_float_handler PARAMS ((jmp_buf));
 static void compile_file PARAMS ((void));
 static void display_help PARAMS ((void));
 static void display_target_options PARAMS ((void));
@@ -1619,73 +1616,6 @@ floor_log2_wide (x)
   return log;
 }
 
-static int float_handler_set;
-int float_handled;
-jmp_buf float_handler;
-
-/* Signals actually come here.  */
-
-static void
-float_signal (signo)
-     /* If this is missing, some compilers complain.  */
-     int signo ATTRIBUTE_UNUSED;
-{
-  if (float_handled == 0)
-    crash_signal (signo);
-  float_handled = 0;
-
-  /* On System-V derived systems, we must reinstall the signal handler.
-     This is harmless on BSD-derived systems.  */
-  signal (SIGFPE, float_signal);
-  longjmp (float_handler, 1);
-}
-
-/* Specify where to longjmp to when a floating arithmetic error happens.
-   If HANDLER is 0, it means don't handle the errors any more.  */
-
-static void
-set_float_handler (handler)
-     jmp_buf handler;
-{
-  float_handled = (handler != 0);
-  if (handler)
-    memcpy (float_handler, handler, sizeof (float_handler));
-
-  if (float_handled && ! float_handler_set)
-    {
-      signal (SIGFPE, float_signal);
-      float_handler_set = 1;
-    }
-}
-
-/* This is a wrapper function for code which might elicit an
-   arithmetic exception.  That code should be passed in as a function
-   pointer FN, and one argument DATA.  DATA is usually a struct which
-   contains the real input and output for function FN.  This function
-   returns 0 (failure) if longjmp was called (i.e. an exception
-   occurred.)  It returns 1 (success) otherwise.  */
-
-int
-do_float_handler (fn, data)
-     void (*fn) PARAMS ((PTR));
-     PTR data;
-{
-  jmp_buf buf;
-
-  if (setjmp (buf))
-    {
-      /* We got here via longjmp () caused by an exception in function
-         fn ().  */
-      set_float_handler (NULL);
-      return 0;
-    }
-
-  set_float_handler (buf);
-  (*fn)(data);
-  set_float_handler (NULL);
-  return 1;
-}
-
 /* Handler for fatal signals, such as SIGSEGV.  These are transformed
    into ICE messages, which is much more user friendly.  */
 
@@ -4558,10 +4488,6 @@ general_init (argv0)
 
   gcc_init_libintl ();
 
-  /* Install handler for SIGFPE, which may be received while we do
-     compile-time floating point arithmetic.  */
-  signal (SIGFPE, float_signal);
-
   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
 #ifdef SIGSEGV
   signal (SIGSEGV, crash_signal);
@@ -4577,6 +4503,9 @@ general_init (argv0)
 #endif
 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
   signal (SIGIOT, crash_signal);
+#endif
+#ifdef SIGFPE
+  signal (SIGFPE, crash_signal);
 #endif
 
   /* Initialize the diagnostics reporting machinery, so option parsing
===================================================================
Index: toplev.h
--- toplev.h	2002/01/10 18:51:15	1.82
+++ toplev.h	2002/03/23 09:27:45
@@ -88,7 +88,6 @@ extern void error_for_asm		PARAMS ((stru
 extern void warning_for_asm		PARAMS ((struct rtx_def *,
 						 const char *, ...));
 extern void warn_deprecated_use		PARAMS ((union tree_node *));
-extern int do_float_handler PARAMS ((void (*) (PTR), PTR));
 
 #ifdef BUFSIZ
 extern void output_quoted_string	PARAMS ((FILE *, const char *));
===================================================================
Index: tree.c
--- tree.c	2002/03/13 01:42:31	1.245
+++ tree.c	2002/03/23 09:27:46
@@ -122,7 +122,6 @@ struct type_hash
 
 htab_t type_hash_table;
 
-static void build_real_from_int_cst_1 PARAMS ((PTR));
 static void set_type_quals PARAMS ((tree, int));
 static void append_random_chars PARAMS ((char *));
 static int type_hash_eq PARAMS ((const void*, const void*));
@@ -591,31 +590,8 @@ real_value_from_int_cst (type, i)
   return d;
 }
 
-/* Args to pass to and from build_real_from_int_cst_1.  */
-
-struct brfic_args
-{
-  tree type;			/* Input: type to conver to.  */
-  tree i;			/* Input: operand to convert.  */
-  REAL_VALUE_TYPE d;		/* Output: floating point value.  */
-};
-
-/* Convert an integer to a floating point value while protected by a floating
-   point exception handler.  */
-
-static void
-build_real_from_int_cst_1 (data)
-     PTR data;
-{
-  struct brfic_args *args = (struct brfic_args *) data;
-
-  args->d = real_value_from_int_cst (args->type, args->i);
-}
-
 /* Given a tree representing an integer constant I, return a tree
-   representing the same value as a floating-point constant of type TYPE.
-   We cannot perform this operation if there is no way of doing arithmetic
-   on floating-point values.  */
+   representing the same value as a floating-point constant of type TYPE.  */
 
 tree
 build_real_from_int_cst (type, i)
@@ -625,27 +601,13 @@ build_real_from_int_cst (type, i)
   tree v;
   int overflow = TREE_OVERFLOW (i);
   REAL_VALUE_TYPE d;
-  struct brfic_args args;
 
   v = make_node (REAL_CST);
   TREE_TYPE (v) = type;
 
-  /* Setup input for build_real_from_int_cst_1() */
-  args.type = type;
-  args.i = i;
-
-  if (do_float_handler (build_real_from_int_cst_1, (PTR) &args))
-    /* Receive output from build_real_from_int_cst_1() */
-    d = args.d;
-  else
-    {
-      /* We got an exception from build_real_from_int_cst_1() */
-      d = dconst0;
-      overflow = 1;
-    }
+  d = real_value_from_int_cst (type, i);
 
   /* Check for valid float value for this type on this target machine.  */
-
 #ifdef CHECK_FLOAT_VALUE
   CHECK_FLOAT_VALUE (TYPE_MODE (type), d, overflow);
 #endif
===================================================================
Index: java/lex.c
--- java/lex.c	2002/03/23 00:01:49	1.83
+++ java/lex.c	2002/03/23 09:27:49
@@ -828,38 +828,33 @@ java_parse_escape_sequence ()
     }
 }
 
-/* Isolate the code which may raise an arithmetic exception in its
-   own function.  */
-
 #ifndef JC1_LITE
-struct jpa_args
-{
-  YYSTYPE *java_lval;
-  char *literal_token;
-  int fflag;
-  int number_beginning;
-};
-
 #define IS_ZERO(X) (ereal_cmp (X, dconst0) == 0)
 
-static void java_perform_atof	PARAMS ((PTR));
+/* Subroutine of java_lex: converts floating-point literals to tree
+   nodes.  LITERAL_TOKEN is the input literal, JAVA_LVAL is where to
+   store the result.  FFLAG indicates whether the literal was tagged
+   with an 'f', indicating it is of type 'float'; NUMBER_BEGINNING
+   is the line number on which to report any error.  */
 
+static void java_perform_atof	PARAMS ((YYSTYPE *, char *, int, int));
+
 static void
-java_perform_atof (av)
-     PTR av;
+java_perform_atof (java_lval, literal_token, fflag, number_beginning)
+     YYSTYPE *java_lval;
+     char *literal_token;
+     int fflag;
+     int number_beginning;
 {
-  struct jpa_args *a = (struct jpa_args *)av;
-  YYSTYPE *java_lval = a->java_lval;
-  int number_beginning = a->number_beginning;
   REAL_VALUE_TYPE value;
-  tree type = (a->fflag ? FLOAT_TYPE_NODE : DOUBLE_TYPE_NODE);
+  tree type = (fflag ? FLOAT_TYPE_NODE : DOUBLE_TYPE_NODE);
 
   SET_REAL_VALUE_ATOF (value,
-		       REAL_VALUE_ATOF (a->literal_token, TYPE_MODE (type)));
+		       REAL_VALUE_ATOF (literal_token, TYPE_MODE (type)));
 
   if (REAL_VALUE_ISINF (value) || REAL_VALUE_ISNAN (value))
     {
-      JAVA_FLOAT_RANGE_ERROR ((a->fflag ? "float" : "double"));
+      JAVA_FLOAT_RANGE_ERROR (fflag ? "float" : "double");
       value = DCONST0;
     }
   else if (IS_ZERO (value))
@@ -867,7 +862,7 @@ java_perform_atof (av)
       /* We check to see if the value is really 0 or if we've found an
 	 underflow.  We do this in the most primitive imaginable way.  */
       int really_zero = 1;
-      char *p = a->literal_token;
+      char *p = literal_token;
       if (*p == '-')
 	++p;
       while (*p && *p != 'e' && *p != 'E')
@@ -1161,9 +1156,6 @@ java_lex (java_lval)
 		}
 	      else
 		{
-#ifndef JC1_LITE
-		  struct jpa_args a;
-#endif
 		  if (stage != 4) /* Don't push back fF/dD.  */
 		    java_unget_unicode ();
 		  
@@ -1176,17 +1168,10 @@ java_lex (java_lval)
 		  JAVA_LEX_LIT (literal_token, radix);
 
 #ifndef JC1_LITE
-		  a.literal_token = literal_token;
-		  a.fflag = fflag;
-		  a.java_lval = java_lval;
-		  a.number_beginning = number_beginning;
-		  if (do_float_handler (java_perform_atof, (PTR) &a))
-		    return FP_LIT_TK;
-
-		  JAVA_FLOAT_RANGE_ERROR ((fflag ? "float" : "double"));
-#else
-		  return FP_LIT_TK;
+		  java_perform_atof (java_lval, literal_token,
+				     fflag, number_beginning);
 #endif
+		  return FP_LIT_TK;
 		}
 	    }
 	} /* JAVA_ASCII_FPCHAR (c) */
===================================================================
Index: testsuite/gcc.dg/c90-hexfloat-1.c
--- testsuite/gcc.dg/c90-hexfloat-1.c	2001/05/22 11:02:17	1.2
+++ testsuite/gcc.dg/c90-hexfloat-1.c	2002/03/23 09:27:51
@@ -4,8 +4,8 @@
 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
 
 double d = 0x1.2p2; /* { dg-bogus "warning" "warning in place of error" } */
-/* { dg-error "radix 16" "hex float error" { target *-*-* } 6 } */
+/* { dg-error "hexadecimal floating" "hex float error" { target *-*-* } 6 } */
 double d1 = 0x1p2; /* { dg-bogus "warning" "warning in place of error" } */
-/* { dg-error "radix 16" "hex float error" { target *-*-* } 8 } */
+/* { dg-error "hexadecimal floating" "hex float error" { target *-*-* } 8 } */
 double d2 = 0x1...p2; /* { dg-bogus "warning" "warning in place of error" } */
 /* { dg-error "too many decimal points" "bad hex float" { target *-*-* } 10 } */
===================================================================
Index: doc/tm.texi
--- doc/tm.texi	2002/03/23 01:10:56	1.113
+++ doc/tm.texi	2002/03/23 09:40:46
@@ -7829,6 +7829,10 @@ decimal and hexadecimal floating point c
 defined by the C language for both.
 @end deftypefn
 
+@deftypefn Macro int REAL_VALUE_NEGATIVE (REAL_VALUE_TYPE @var{x})
+Returns 1 if @var{x} is negative (including negative zero), 0 otherwise.  
+@end deftypefn
+
 @deftypefn Macro int REAL_VALUE_ISINF (REAL_VALUE_TYPE @var{x})
 Determines whether @var{x} represents infinity (positive or negative).
 @end deftypefn
@@ -7854,6 +7858,10 @@ target's floating point format cannot re
 
 @deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_NEGATE (REAL_VALUE_TYPE @var{x})
 Returns the negative of the floating point value @var{x}.
+@end deftypefn
+
+@deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_ABS (REAL_VALUE_TYPE @var{x})
+Returns the absolute value of @var{x}.
 @end deftypefn
 
 @deftypefn Macro REAL_VALUE_TYPE REAL_VALUE_TRUNCATE (REAL_VALUE_TYPE @var{mode}, enum machine_mode @var{x})


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]