From patchwork Tue Feb 7 14:00:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prathamesh Kulkarni X-Patchwork-Id: 93568 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2210942qgi; Tue, 7 Feb 2017 06:00:57 -0800 (PST) X-Received: by 10.99.95.87 with SMTP id t84mr20655022pgb.209.1486476057474; Tue, 07 Feb 2017 06:00:57 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id g5si4127689pgi.386.2017.02.07.06.00.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 06:00:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-448105-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-448105-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-448105-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=UoJgANsBwL+YtEHtgIe5B5HfbF/+EEQqJ2JSYpUPRV3EeU Si8xkp7L9sCNzuKJorDLpytv4kOD8wx89bzN0pCYCiMx6866gzcSgX5xvb9yxATb W9sdBTeFLDYx4XUwKJpIBtOGO1oDDLSQADHstJPp1O/dP3q3hYIFnRm72jpUI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=epu3idKtxvz8sUBx8o7X0NYDzdM=; b=oXJ/nLajP1l8FghQR9LT C1kJrMVnWnceH55Dy7OoNSKK5xPlPqsGa+9CToet3FkwPwVD5jtPE3omVrhsqWc5 eRVIBz5E6Br1FlGsALI8hss5QnqKB6j/dCb8wnnkIM0keuMt/roc+bVAIvyTEb01 u43ozuGLUqSVfoz+cdS81n4= Received: (qmail 122576 invoked by alias); 7 Feb 2017 14:00:39 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 122357 invoked by uid 89); 7 Feb 2017 14:00:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.3 required=5.0 tests=AWL, BAYES_40, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=no version=3.3.2 spammy=gimplefe, spc, *parser, c_expr X-HELO: mail-io0-f175.google.com Received: from mail-io0-f175.google.com (HELO mail-io0-f175.google.com) (209.85.223.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Feb 2017 14:00:28 +0000 Received: by mail-io0-f175.google.com with SMTP id l66so90464558ioi.1 for ; Tue, 07 Feb 2017 06:00:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=pwZe0lXZGF8Y+Fo8aGUIATRb4ey8hmNZ+KceI63s1ss=; b=f7Kmaako+9bluksyHada1DD7vOGr/410jc0gL3LsMpKDldQ9rv+pU3PgzvrusP0aqO r5GKtpCaXnGjRS0ysK1dxM2rhwOK8blun1OfjQf+ZnlmnRowgDrh0BvTmaxlxapQPsKq eauv17xWFnKun64txJLbRkwMdV8tbKUrIiMF0saq4OvAZq72CbJzfOA2/c2YPODeppT1 FmuG6eF0flg0rvEoM6BixKM3C/PiYK9n1amFAHP/TkCMCGPSjTNJ2xtEAXzQYxbRKIoI a9FmgNws1SVPmEMoqMN2/AioVG7KeKLnv+Lwzva2I5FZIzGRSwyRxKkuypETh7CjCNgf WHmg== X-Gm-Message-State: AMke39mgk1ob8fZdAZyPld8fIyJJPJX/z1r8GlDw5kvhzZz+HJtUbeaeui2nrIKM4EdDHhCiuqxYTqfruDFWiTxE X-Received: by 10.107.48.210 with SMTP id w201mr3824726iow.89.1486476026482; Tue, 07 Feb 2017 06:00:26 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.162.13 with HTTP; Tue, 7 Feb 2017 06:00:26 -0800 (PST) From: Prathamesh Kulkarni Date: Tue, 7 Feb 2017 19:30:26 +0530 Message-ID: Subject: [GIMPLE FE] Handle abs_expr To: gcc Patches , Richard Biener X-IsSubscribed: yes Hi Richard, The attached patch tries to handle ABS_EXPR in gimple-fe. I am not sure if __ABS_EXPR should be parsed as id (like __MEM) or parse it as keyword (like __GIMPLE). Currently in the patch, I parse it as id. Patch passes gimplefe tests, is it OK to commit after bootstrap+test ? Thanks, Prathamesh 2017-02-07 Prathamesh Kulkarni * gimple-pretty-print.c (dump_unary_rhs): Change dump format for ABS_EXPR for gimple dump. c/ * gimple-parser.c (c_parser_gimple_unary_expression): Handle ABS_EXPR. (c_parser_gimple_statement): Likewise. testsuite/ * gcc.dg/gimplefe-25.c: New test-case. diff --git a/gcc/c/gimple-parser.c b/gcc/c/gimple-parser.c index e167e42..51bbfdc 100644 --- a/gcc/c/gimple-parser.c +++ b/gcc/c/gimple-parser.c @@ -61,7 +61,7 @@ static bool c_parser_gimple_compound_statement (c_parser *, gimple_seq *); static void c_parser_gimple_label (c_parser *, gimple_seq *); static void c_parser_gimple_statement (c_parser *, gimple_seq *); static struct c_expr c_parser_gimple_binary_expression (c_parser *); -static struct c_expr c_parser_gimple_unary_expression (c_parser *); +static struct c_expr c_parser_gimple_unary_expression (c_parser *, enum tree_code oper_code = ERROR_MARK); static struct c_expr c_parser_gimple_postfix_expression (c_parser *); static struct c_expr c_parser_gimple_postfix_expression_after_primary (c_parser *, location_t, @@ -323,8 +323,19 @@ c_parser_gimple_statement (c_parser *parser, gimple_seq *seq) } /* Unary expression. */ + enum tree_code oper_code = ERROR_MARK; switch (c_parser_peek_token (parser)->type) { + case CPP_NAME: + { + tree id = c_parser_peek_token (parser)->value; + if (strcmp (IDENTIFIER_POINTER (id), "__ABS_EXPR") == 0) + { + oper_code = ABS_EXPR; + goto build_unary_expr; + } + break; + } case CPP_KEYWORD: if (c_parser_peek_token (parser)->keyword != RID_REALPART && c_parser_peek_token (parser)->keyword != RID_IMAGPART) @@ -336,7 +347,8 @@ c_parser_gimple_statement (c_parser *parser, gimple_seq *seq) case CPP_COMPL: case CPP_NOT: case CPP_MULT: /* pointer deref */ - rhs = c_parser_gimple_unary_expression (parser); + build_unary_expr: + rhs = c_parser_gimple_unary_expression (parser, oper_code); if (rhs.value != error_mark_node) { assign = gimple_build_assign (lhs.value, rhs.value); @@ -537,11 +549,11 @@ c_parser_gimple_binary_expression (c_parser *parser) unary-operator gimple-postfix-expression unary-operator: one of - & * + - ~ + & * + - ~ abs_expr */ static c_expr -c_parser_gimple_unary_expression (c_parser *parser) +c_parser_gimple_unary_expression (c_parser *parser, enum tree_code oper_code) { struct c_expr ret, op; location_t op_loc = c_parser_peek_token (parser)->location; @@ -599,6 +611,25 @@ c_parser_gimple_unary_expression (c_parser *parser) default: return c_parser_gimple_postfix_expression (parser); } + case CPP_NAME: + { + if (oper_code != ERROR_MARK) + { + c_parser_consume_token (parser); + op = c_parser_gimple_postfix_expression (parser); + return parser_build_unary_op (op_loc, oper_code, op); + } + + tree id = c_parser_peek_token (parser)->value; + if (strcmp (IDENTIFIER_POINTER (id), "__ABS_EXPR") == 0) + { + c_parser_consume_token (parser); + op = c_parser_gimple_postfix_expression (parser); + return parser_build_unary_op (op_loc, ABS_EXPR, op); + } + else + return c_parser_gimple_postfix_expression (parser); + } default: return c_parser_gimple_postfix_expression (parser); } diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c index 91c839d..6e9102e 100644 --- a/gcc/gimple-pretty-print.c +++ b/gcc/gimple-pretty-print.c @@ -323,9 +323,17 @@ dump_unary_rhs (pretty_printer *buffer, gassign *gs, int spc, int flags) break; case ABS_EXPR: - pp_string (buffer, "ABS_EXPR <"); - dump_generic_node (buffer, rhs, spc, flags, false); - pp_greater (buffer); + if (flags & TDF_GIMPLE) + { + pp_string (buffer, "__ABS_EXPR "); + dump_generic_node (buffer, rhs, spc, flags, false); + } + else + { + pp_string (buffer, "ABS_EXPR <"); + dump_generic_node (buffer, rhs, spc, flags, false); + pp_greater (buffer); + } break; default: