]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c/111468 - dump unordered compare operators in their GIMPLE form with -gimple
authorRichard Biener <rguenther@suse.de>
Tue, 19 Sep 2023 11:18:51 +0000 (13:18 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 19 Sep 2023 12:43:13 +0000 (14:43 +0200)
The following adjusts -gimple dumping to dump the unordered compare ops
and *h in their GIMPLE form.  It also adds parsing for __LTGT which I
missed before.

PR c/111468
gcc/c/
* gimple-parser.cc (c_parser_gimple_binary_expression): Handle __LTGT.

gcc/
* tree-pretty-print.h (op_symbol_code): Add defaulted flags
argument.
* tree-pretty-print.cc (op_symbol): Likewise.
(op_symbol_code): Print TDF_GIMPLE variant if requested.
* gimple-pretty-print.cc (dump_binary_rhs): Pass flags to
op_symbol_code.
(dump_gimple_cond): Likewise.

gcc/testsuite/
* gcc.dg/gimplefe-50.c: Amend.

gcc/c/gimple-parser.cc
gcc/gimple-pretty-print.cc
gcc/testsuite/gcc.dg/gimplefe-50.c
gcc/tree-pretty-print.cc
gcc/tree-pretty-print.h

index 9cf29701c06597f55273dc10b124b5a40474084a..f43c03986555101926fd4ee7b3b3c4b35a6e218b 100644 (file)
@@ -1044,6 +1044,11 @@ c_parser_gimple_binary_expression (gimple_parser &parser, tree ret_type)
            code = ORDERED_EXPR;
            break;
          }
+       else if (strcmp (IDENTIFIER_POINTER (id), "__LTGT") == 0)
+         {
+           code = LTGT_EXPR;
+           break;
+         }
       }
       /* Fallthru.  */
     default:
index 82017b92e89ef18b9e7517649d66a3979c0901e0..320df9197b4deadc949adb62ff81f33c952db42f 100644 (file)
@@ -480,7 +480,7 @@ dump_binary_rhs (pretty_printer *buffer, const gassign *gs, int spc,
       else
        dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags, false);
       pp_space (buffer);
-      pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs)));
+      pp_string (buffer, op_symbol_code (gimple_assign_rhs_code (gs), flags));
       pp_space (buffer);
       if (op_prio (gimple_assign_rhs2 (gs)) <= op_code_prio (code))
        {
@@ -1092,7 +1092,7 @@ dump_gimple_cond (pretty_printer *buffer, const gcond *gs, int spc,
                         flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
                         false);
       pp_space (buffer);
-      pp_string (buffer, op_symbol_code (gimple_cond_code (gs)));
+      pp_string (buffer, op_symbol_code (gimple_cond_code (gs), flags));
       pp_space (buffer);
       dump_generic_node (buffer, gimple_cond_rhs (gs), spc,
                         flags | ((flags & TDF_GIMPLE) ? TDF_GIMPLE_VAL : TDF_NONE),
index 03db786b6195328059b804bd8d03413e05970e98..63d228ce76d47025c9698e7007146791228585f0 100644 (file)
@@ -14,6 +14,7 @@ foo (float a, float b)
   x_7 = a_1(D) __UNEQ b_2(D);
   x_8 = a_1(D) __UNORDERED b_2(D);
   x_9 = a_1(D) __ORDERED b_2(D);
+  x_10 = a_1(D) __LTGT b_2(D);
   if (a_1(D) __UNEQ b_2(D))
     goto __BB4;
   else
index 45a1fd3e848e361525f881446095372c1fea7350..12c57c14dd4a36955aed621dbecdcc4bfccb790e 100644 (file)
@@ -49,7 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #endif
 
 /* Local functions, macros and variables.  */
-static const char *op_symbol (const_tree);
+static const char *op_symbol (const_tree, dump_flags_t = TDF_NONE);
 static void newline_and_indent (pretty_printer *, int);
 static void maybe_init_pretty_print (FILE *);
 static void print_struct_decl (pretty_printer *, const_tree, int, dump_flags_t);
@@ -4327,7 +4327,7 @@ op_prio (const_tree op)
 /* Return the symbol associated with operator CODE.  */
 
 const char *
-op_symbol_code (enum tree_code code)
+op_symbol_code (enum tree_code code, dump_flags_t flags)
 {
   switch (code)
     {
@@ -4354,14 +4354,14 @@ op_symbol_code (enum tree_code code)
       return "&";
 
     case ORDERED_EXPR:
-      return "ord";
+      return (flags & TDF_GIMPLE) ? "__ORDERED" : "ord";
     case UNORDERED_EXPR:
-      return "unord";
+      return (flags & TDF_GIMPLE) ? "__UNORDERED" : "unord";
 
     case EQ_EXPR:
       return "==";
     case UNEQ_EXPR:
-      return "u==";
+      return (flags & TDF_GIMPLE) ? "__UNEQ" : "u==";
 
     case NE_EXPR:
       return "!=";
@@ -4369,25 +4369,25 @@ op_symbol_code (enum tree_code code)
     case LT_EXPR:
       return "<";
     case UNLT_EXPR:
-      return "u<";
+      return (flags & TDF_GIMPLE) ? "__UNLT" : "u<";
 
     case LE_EXPR:
       return "<=";
     case UNLE_EXPR:
-      return "u<=";
+      return (flags & TDF_GIMPLE) ? "__UNLE" : "u<=";
 
     case GT_EXPR:
       return ">";
     case UNGT_EXPR:
-      return "u>";
+      return (flags & TDF_GIMPLE) ? "__UNGT" : "u>";
 
     case GE_EXPR:
       return ">=";
     case UNGE_EXPR:
-      return "u>=";
+      return (flags & TDF_GIMPLE) ? "__UNGE" : "u>=";
 
     case LTGT_EXPR:
-      return "<>";
+      return (flags & TDF_GIMPLE) ? "__LTGT" : "<>";
 
     case LSHIFT_EXPR:
       return "<<";
@@ -4417,7 +4417,7 @@ op_symbol_code (enum tree_code code)
       return "w*";
 
     case MULT_HIGHPART_EXPR:
-      return "h*";
+      return (flags & TDF_GIMPLE) ? "__MULT_HIGHPART" : "h*";
 
     case NEGATE_EXPR:
     case MINUS_EXPR:
@@ -4488,9 +4488,9 @@ op_symbol_code (enum tree_code code)
 /* Return the symbol associated with operator OP.  */
 
 static const char *
-op_symbol (const_tree op)
+op_symbol (const_tree op, dump_flags_t flags)
 {
-  return op_symbol_code (TREE_CODE (op));
+  return op_symbol_code (TREE_CODE (op), flags);
 }
 
 /* Prints the name of a call.  NODE is the CALL_EXPR_FN of a CALL_EXPR or
index 681384a8e58a75030267ee366c7f1b304dd64fba..2c8ee9aa377731522b10c4141f0857a8c9f33c72 100644 (file)
@@ -49,7 +49,7 @@ extern int dump_generic_node (pretty_printer *, tree, int, dump_flags_t, bool);
 extern void print_declaration (pretty_printer *, tree, int, dump_flags_t);
 extern int op_code_prio (enum tree_code);
 extern int op_prio (const_tree);
-extern const char *op_symbol_code (enum tree_code);
+extern const char *op_symbol_code (enum tree_code, dump_flags_t = TDF_NONE);
 extern void pretty_print_string (pretty_printer *, const char *, size_t);
 extern void print_call_name (pretty_printer *, tree, dump_flags_t);
 extern void pp_tree_identifier (pretty_printer *, tree);