+2019-05-09 Martin Liska <mliska@suse.cz>
+
+ * gimple-parser.c (c_parser_gimple_statement): Support __MIN and
+ __MAX.
+ (c_parser_gimple_unary_expression): Parse also binary expression
+ __MIN and __MAX.
+ (c_parser_gimple_parentized_binary_expression): New function.
+
2019-05-09 Martin Liska <mliska@suse.cz>
* gimple-parser.c (struct gimple_parser): Add probability.
{
tree id = c_parser_peek_token (parser)->value;
if (strcmp (IDENTIFIER_POINTER (id), "__ABS") == 0
- || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0)
+ || strcmp (IDENTIFIER_POINTER (id), "__ABSU") == 0
+ || strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0
+ || strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0)
goto build_unary_expr;
break;
}
return ret;
}
+/* Parse a gimple parentized binary expression. */
+
+static c_expr
+c_parser_gimple_parentized_binary_expression (gimple_parser &parser,
+ location_t op_loc,
+ tree_code code)
+{
+ struct c_expr ret;
+ ret.set_error ();
+
+ c_parser_consume_token (parser);
+ if (!c_parser_require (parser, CPP_OPEN_PAREN, "expected %<(%>"))
+ return ret;
+ c_expr op1 = c_parser_gimple_postfix_expression (parser);
+ if (!c_parser_require (parser, CPP_COMMA, "expected %<,%>"))
+ return ret;
+ c_expr op2 = c_parser_gimple_postfix_expression (parser);
+ if (!c_parser_require (parser, CPP_CLOSE_PAREN, "expected %<)%>"))
+ return ret;
+
+ if (op1.value != error_mark_node && op2.value != error_mark_node)
+ ret.value = build2_loc (op_loc,
+ code, TREE_TYPE (op1.value), op1.value, op2.value);
+ return ret;
+}
+
/* Parse gimple unary expression.
gimple-unary-expression:
op = c_parser_gimple_postfix_expression (parser);
return parser_build_unary_op (op_loc, ABSU_EXPR, op);
}
+ else if (strcmp (IDENTIFIER_POINTER (id), "__MIN") == 0)
+ return c_parser_gimple_parentized_binary_expression (parser,
+ op_loc,
+ MIN_EXPR);
+ else if (strcmp (IDENTIFIER_POINTER (id), "__MAX") == 0)
+ return c_parser_gimple_parentized_binary_expression (parser,
+ op_loc,
+ MAX_EXPR);
else
return c_parser_gimple_postfix_expression (parser);
}
enum tree_code code = gimple_assign_rhs_code (gs);
switch (code)
{
- case COMPLEX_EXPR:
case MIN_EXPR:
case MAX_EXPR:
+ if (flags & TDF_GIMPLE)
+ {
+ pp_string (buffer, code == MIN_EXPR ? "__MIN (" : "__MAX (");
+ dump_generic_node (buffer, gimple_assign_rhs1 (gs), spc, flags,
+ false);
+ pp_string (buffer, ", ");
+ dump_generic_node (buffer, gimple_assign_rhs2 (gs), spc, flags,
+ false);
+ pp_string (buffer, ")");
+ break;
+ }
+ else
+ gcc_fallthrough ();
+ case COMPLEX_EXPR:
case VEC_WIDEN_MULT_HI_EXPR:
case VEC_WIDEN_MULT_LO_EXPR:
case VEC_WIDEN_MULT_EVEN_EXPR: