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]

[Committed] Tweak fold_builtin_unordered_cmp API


The following patch is a contribution to Kazu's reorganization of
fold.  This patch changes the API of fold_builtin_unordered_cmp to
take an fndecl/arglist pair instead of the CALL_EXPR.  This is now
the preferred form of the fold_builtin_foo functions (previously
there's been a mixture of styles with no strong bias, but the win
of fold_build3 now makes the "split" form preferable).

The following patch has been tested on i686-pc-linux-gnu with a full
"make bootstrap", all default languages, and regression tested with a
top-level "make -k check" with no new failures.

Committed to mainline CVS.


2005-03-09  Roger Sayle  <roger@eyesopen.com>

	* builtins.c (fold_builtin_unordered_cmp): Change prototype to take
	a fndecl and an arglist instead of a CALL_EXPR, exp.


Index: builtins.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/builtins.c,v
retrieving revision 1.426
diff -c -3 -p -r1.426 builtins.c
*** builtins.c	24 Feb 2005 20:00:04 -0000	1.426
--- builtins.c	6 Mar 2005 18:14:28 -0000
*************** static tree fold_builtin_toascii (tree);
*** 176,182 ****
  static tree fold_builtin_isdigit (tree);
  static tree fold_builtin_fabs (tree, tree);
  static tree fold_builtin_abs (tree, tree);
! static tree fold_builtin_unordered_cmp (tree, enum tree_code, enum tree_code);
  static tree fold_builtin_1 (tree, bool);

  static tree fold_builtin_strpbrk (tree, tree);
--- 176,183 ----
  static tree fold_builtin_isdigit (tree);
  static tree fold_builtin_fabs (tree, tree);
  static tree fold_builtin_abs (tree, tree);
! static tree fold_builtin_unordered_cmp (tree, tree, enum tree_code,
! 					enum tree_code);
  static tree fold_builtin_1 (tree, bool);

  static tree fold_builtin_strpbrk (tree, tree);
*************** fold_builtin_classify (tree exp, int bui
*** 7766,7784 ****
  }

  /* Fold a call to an unordered comparison function such as
!    __builtin_isgreater().  EXP is the CALL_EXPR for the call.
     UNORDERED_CODE and ORDERED_CODE are comparison codes that give
     the opposite of the desired result.  UNORDERED_CODE is used
     for modes that can hold NaNs and ORDERED_CODE is used for
     the rest.  */

  static tree
! fold_builtin_unordered_cmp (tree exp,
  			    enum tree_code unordered_code,
  			    enum tree_code ordered_code)
  {
-   tree fndecl = get_callee_fndecl (exp);
-   tree arglist = TREE_OPERAND (exp, 1);
    tree type = TREE_TYPE (TREE_TYPE (fndecl));
    enum tree_code code;
    tree arg0, arg1;
--- 7767,7784 ----
  }

  /* Fold a call to an unordered comparison function such as
!    __builtin_isgreater().  FNDECL is the FUNCTION_DECL for the function
!    being called and ARGLIST is the argument list for the call.
     UNORDERED_CODE and ORDERED_CODE are comparison codes that give
     the opposite of the desired result.  UNORDERED_CODE is used
     for modes that can hold NaNs and ORDERED_CODE is used for
     the rest.  */

  static tree
! fold_builtin_unordered_cmp (tree fndecl, tree arglist,
  			    enum tree_code unordered_code,
  			    enum tree_code ordered_code)
  {
    tree type = TREE_TYPE (TREE_TYPE (fndecl));
    enum tree_code code;
    tree arg0, arg1;
*************** fold_builtin_1 (tree exp, bool ignore)
*** 8211,8227 ****
        return fold_builtin_classify (exp, BUILT_IN_ISNAN);

      case BUILT_IN_ISGREATER:
!       return fold_builtin_unordered_cmp (exp, UNLE_EXPR, LE_EXPR);
      case BUILT_IN_ISGREATEREQUAL:
!       return fold_builtin_unordered_cmp (exp, UNLT_EXPR, LT_EXPR);
      case BUILT_IN_ISLESS:
!       return fold_builtin_unordered_cmp (exp, UNGE_EXPR, GE_EXPR);
      case BUILT_IN_ISLESSEQUAL:
!       return fold_builtin_unordered_cmp (exp, UNGT_EXPR, GT_EXPR);
      case BUILT_IN_ISLESSGREATER:
!       return fold_builtin_unordered_cmp (exp, UNEQ_EXPR, EQ_EXPR);
      case BUILT_IN_ISUNORDERED:
!       return fold_builtin_unordered_cmp (exp, UNORDERED_EXPR, NOP_EXPR);

        /* We do the folding for va_start in the expander.  */
      case BUILT_IN_VA_START:
--- 8211,8228 ----
        return fold_builtin_classify (exp, BUILT_IN_ISNAN);

      case BUILT_IN_ISGREATER:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNLE_EXPR, LE_EXPR);
      case BUILT_IN_ISGREATEREQUAL:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNLT_EXPR, LT_EXPR);
      case BUILT_IN_ISLESS:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNGE_EXPR, GE_EXPR);
      case BUILT_IN_ISLESSEQUAL:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNGT_EXPR, GT_EXPR);
      case BUILT_IN_ISLESSGREATER:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNEQ_EXPR, EQ_EXPR);
      case BUILT_IN_ISUNORDERED:
!       return fold_builtin_unordered_cmp (fndecl, arglist, UNORDERED_EXPR,
! 					 NOP_EXPR);

        /* We do the folding for va_start in the expander.  */
      case BUILT_IN_VA_START:

Roger
--


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