From patchwork Sat Aug 7 20:05:02 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Diego Novillo X-Patchwork-Id: 61191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5B78EB6EFF for ; Sun, 8 Aug 2010 06:05:51 +1000 (EST) Received: (qmail 24110 invoked by alias); 7 Aug 2010 20:05:47 -0000 Received: (qmail 24093 invoked by uid 22791); 7 Aug 2010 20:05:45 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_SN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 07 Aug 2010 20:05:07 +0000 Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by smtp-out.google.com with ESMTP id o77K549w007237 for ; Sat, 7 Aug 2010 13:05:04 -0700 Received: from gxk7 (gxk7.prod.google.com [10.202.11.7]) by wpaz9.hot.corp.google.com with ESMTP id o77K52KO021435 for ; Sat, 7 Aug 2010 13:05:02 -0700 Received: by gxk7 with SMTP id 7so3651624gxk.21 for ; Sat, 07 Aug 2010 13:05:02 -0700 (PDT) MIME-Version: 1.0 Received: by 10.101.212.16 with SMTP id o16mr15680995anq.113.1281211502344; Sat, 07 Aug 2010 13:05:02 -0700 (PDT) Received: by 10.100.143.4 with HTTP; Sat, 7 Aug 2010 13:05:02 -0700 (PDT) In-Reply-To: References: Date: Sat, 7 Aug 2010 16:05:02 -0400 Message-ID: Subject: Re: [patch 1/2] [gimplefe] Changes internal interface of recognition of tuples. From: Diego Novillo To: Sandeep Soni Cc: gcc patches X-System-Of-Record: true X-IsSubscribed: yes 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 On 10-08-06 13:58 , Sandeep Soni wrote: > The patch fixes the documentation of the last patch. Changes the > interface of the recognition of the tuple contents and adds support > for the recognition of gimple_return tuple. I will be esnding one > more patch that handles gimple_switch and gimple_call shortly. Thanks. I made some minor formatting changes and started preparing the functions to move into the new gimple/ directory. I also fixed the calls to strcasecmp. They need to break when the return value is 0. Otherwise, we will not match anything. Diego. 2010-08-07 Diego Novillo * lto/lto.c (gimple_parse_expect_token, gimple_parse_expect_subcode, gimple_parse_expect_lhs, gimple_parse_expect_rhs1, gimple_parse_expect_rhs2, gimple_parse_assign_stmt, gimple parse_expect_op1, gimple_parse_expect_op2, gimple_parse_expect_true_label, gimple_parse_expect_false_label, gimple_parse_cond_stmt, gimple_parse_goto_stmt, gimple_parse_label_stmt, gimple_parse_return_stmt, gimple_parse_stmt): Make static. (gimple_parse_stmt): Fix call to strcasecmp. (gimple_parse_expect_subcode): Likewise. diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c index 6f12c5f..f5fba73 100644 --- a/gcc/lto/lto.c +++ b/gcc/lto/lto.c @@ -1995,10 +1995,11 @@ lto_eh_personality (void) /* Consumes a token if the EXPECTED_TOKEN_TYPE is exactly the one we are looking for. The token is obtained by reading it from the reader P. */ -void +static const cpp_token * gimple_parse_expect_token (cpp_reader *p, int expected_token_type) { const cpp_token *next_token; + next_token = cpp_peek_token (p, 0); /* If the token type does not match then we must report an error, @@ -2008,17 +2009,21 @@ gimple_parse_expect_token (cpp_reader *p, int expected_token_type) diagnostics similar to that reported by other front ends in the same case. */ - if(next_token->type != expected_token_type) - error ("Mismatch in expected token type"); + if (next_token->type != expected_token_type) + error ("expected token type %s instead of %s", + cpp_type2name (expected_token_type, 0), + cpp_type2name (next_token->type, 0)); else - next_token = cpp_get_token (p); + next_token = cpp_get_token_with_location (p, &input_location); + + return next_token; } /* Helper for gimple_parse_assign_stmt and gimple_parse_cond_stmt. Peeks a token by reading from reader P and looks it up to match against the tree codes. */ -void +static void gimple_parse_expect_subcode (cpp_reader *p) { const cpp_token *next_token; @@ -2032,7 +2037,7 @@ gimple_parse_expect_subcode (cpp_reader *p) next_token = cpp_peek_token (p, 0); text = (const char *) cpp_token_as_text (p, next_token); for (i = ERROR_MARK; i < LAST_AND_UNUSED_TREE_CODE; i++) - if (strcasecmp (text, tree_code_name[i]) != NULL) + if (strcasecmp (text, tree_code_name[i]) == 0) break; /* If none of the tree codes match, then report an error. Otherwise @@ -2051,7 +2056,7 @@ gimple_parse_expect_subcode (cpp_reader *p) /* Helper for gimple_parse_assign_stmt. The token read from reader P should be the lhs of the tuple. */ -void +static void gimple_parse_expect_lhs (cpp_reader *p) { const cpp_token *next_token; @@ -2070,7 +2075,7 @@ gimple_parse_expect_lhs (cpp_reader *p) /* Helper for gimple_parse_assign_stmt. The token read from reader P should be the first operand in rhs of the tuple. */ -void +static void gimple_parse_expect_rhs1 (cpp_reader *p) { const cpp_token *next_token; @@ -2103,7 +2108,7 @@ gimple_parse_expect_rhs1 (cpp_reader *p) /* Helper for gimple_parse_assign_stmt. The token read from reader P should be the second operand in rhs of the tuple. */ -void +static void gimple_parse_expect_rhs2 (cpp_reader *p) { const cpp_token *next_token; @@ -2131,7 +2136,7 @@ gimple_parse_expect_rhs2 (cpp_reader *p) /* Parse a gimple_assign tuple that is read from the reader P. For now we only recognize the tuple. Refer gimple.def for the format of this tuple. */ -void +static void gimple_parse_assign_stmt (cpp_reader *p) { gimple_parse_expect_subcode (p); @@ -2142,7 +2147,7 @@ gimple_parse_assign_stmt (cpp_reader *p) /* Helper for gimple_parse_cond_stmt. The token read from reader P should be the first operand in the tuple. */ -void +static void gimple_parse_expect_op1 (cpp_reader *p) { const cpp_token *next_token; @@ -2159,7 +2164,7 @@ gimple_parse_expect_op1 (cpp_reader *p) /* Helper for gimple_parse_cond_stmt. The token read from reader P should be the second operand in the tuple. */ -void +static void gimple_parse_expect_op2 (cpp_reader *p) { const cpp_token *next_token; @@ -2184,7 +2189,7 @@ gimple_parse_expect_op2 (cpp_reader *p) be the true label in the tuple that means the label where the control jumps if the condition evaluates to true. */ -void +static void gimple_parse_expect_true_label (cpp_reader *p) { gimple_parse_expect_token (p, CPP_LESS); @@ -2197,7 +2202,7 @@ gimple_parse_expect_true_label (cpp_reader *p) be the false label in the tuple that means the label where the control jumps if the condition evaluates to false. */ -void +static void gimple_parse_expect_false_label (cpp_reader *p) { gimple_parse_expect_token (p, CPP_LESS); @@ -2208,7 +2213,7 @@ gimple_parse_expect_false_label (cpp_reader *p) /* Parse a gimple_cond tuple that is read from the reader P. For now we only recognize the tuple. Refer gimple.def for the format of this tuple. */ -void +static void gimple_parse_cond_stmt (cpp_reader *p) { gimple_parse_expect_subcode (p); @@ -2221,7 +2226,7 @@ gimple_parse_cond_stmt (cpp_reader *p) /* Parse a gimple_goto tuple that is read from the reader P. For now we only recognize the tuple. Refer gimple.def for the format of this tuple. */ -void +static void gimple_parse_goto_stmt (cpp_reader *p) { gimple_parse_expect_token (p, CPP_LSHIFT); @@ -2232,7 +2237,7 @@ gimple_parse_goto_stmt (cpp_reader *p) /* Parse a gimple_label tuple that is read from the reader P. For now we only recognize the tuple. Refer gimple.def for the format of this tuple. */ -void +static void gimple_parse_label_stmt (cpp_reader *p) { gimple_parse_expect_token (p, CPP_LSHIFT); @@ -2243,7 +2248,7 @@ gimple_parse_label_stmt (cpp_reader *p) /* Parse a gimple_return tuple that is read from the reader P. For now we only recognize the tuple. Refer gimple.def for the format of this tuple. */ -void +static void gimple_parse_return_stmt (cpp_reader *p) { gimple_parse_expect_token (p, CPP_LESS); @@ -2254,17 +2259,17 @@ gimple_parse_return_stmt (cpp_reader *p) /* The TOK read from the reader P is looked up for a match. Calls the corresponding function to do the parsing for the match. */ -void +static void gimple_parse_stmt (cpp_reader *p, const cpp_token *tok) { const char *text; int i; text = (const char *) cpp_token_as_text (p, tok); for (i = GIMPLE_ERROR_MARK; i < LAST_AND_UNUSED_GIMPLE_CODE; i++) - if (strcasecmp (text, gimple_code_name[i]) != NULL) + if (strcasecmp (text, gimple_code_name[i]) == 0) break; - if(i == LAST_AND_UNUSED_GIMPLE_CODE) + if (i == LAST_AND_UNUSED_GIMPLE_CODE) error ("Invalid gimple code used"); else { @@ -2340,7 +2345,7 @@ lto_main (int debug_p ATTRIBUTE_UNUSED) tok = cpp_get_token (p); while (tok->type != CPP_EOF) { - gimple_parse_stmt (p,tok); + gimple_parse_stmt (p, tok); tok = cpp_get_token (p); } } diff --git a/gcc/lto/lto.h b/gcc/lto/lto.h index 36ab64b..d340d05 100644 --- a/gcc/lto/lto.h +++ b/gcc/lto/lto.h @@ -40,21 +40,6 @@ extern const char *resolution_file_name; extern tree lto_eh_personality (void); extern void lto_main (int); extern void lto_read_all_file_options (void); -extern void gimple_parse_stmt (cpp_reader *p, const cpp_token *tok); -extern void gimple_parse_expect_subcode (cpp_reader *p); -extern void gimple_parse_expect_lhs (cpp_reader *p); -extern void gimple_parse_expect_rhs1 (cpp_reader *p); -extern void gimple_parse_expect_rhs2 (cpp_reader *p); -extern void gimple_parse_assign_stmt (cpp_reader *p); -extern void gimple_parse_expect_op1 (cpp_reader *p); -extern void gimple_parse_expect_op2 (cpp_reader *p); -extern void gimple_parse_expect_true_label (cpp_reader *p); -extern void gimple_parse_expect_false_label (cpp_reader *p); -extern void gimple_parse_cond_stmt (cpp_reader *p); -extern void gimple_parse_label_stmt (cpp_reader *p); -extern void gimple_parse_goto_stmt (cpp_reader *p); -extern void gimple_parse_return_stmt (cpp_reader *p); -extern void gimple_parse_expect_token (cpp_reader *p, int expected_token_type); /* In lto-elf.c or lto-coff.c */ extern lto_file *lto_obj_file_open (const char *filename, bool writable); diff --git a/gcc/tags b/gcc/tags index 63b1d3d..e7a6af9 100644 --- a/gcc/tags +++ b/gcc/tags @@ -38424,10 +38424,19 @@ gimple_p vecir.h /^DEF_VEC_P(gimple_p);$/;" v gimple_p vecir.h /^typedef gimple *gimple_p;$/;" t gimple_parse_assign_stmt lto/lto.c /^gimple_parse_assign_stmt (cpp_reader *p)$/;" f gimple_parse_cond_stmt lto/lto.c /^gimple_parse_cond_stmt (cpp_reader *p)$/;" f -gimple_parse_expect_token lto/lto.c /^gimple_parse_expect_token (cpp_reader *p,int expected_token_type)$/;" f +gimple_parse_expect_false_label lto/lto.c /^gimple_parse_expect_false_label (cpp_reader *p)$/;" f +gimple_parse_expect_lhs lto/lto.c /^gimple_parse_expect_lhs (cpp_reader *p)$/;" f +gimple_parse_expect_op1 lto/lto.c /^gimple_parse_expect_op1 (cpp_reader *p)$/;" f +gimple_parse_expect_op2 lto/lto.c /^gimple_parse_expect_op2 (cpp_reader *p)$/;" f +gimple_parse_expect_rhs1 lto/lto.c /^gimple_parse_expect_rhs1 (cpp_reader *p)$/;" f +gimple_parse_expect_rhs2 lto/lto.c /^gimple_parse_expect_rhs2 (cpp_reader *p)$/;" f +gimple_parse_expect_subcode lto/lto.c /^gimple_parse_expect_subcode (cpp_reader *p)$/;" f +gimple_parse_expect_token lto/lto.c /^gimple_parse_expect_token (cpp_reader *p, int expected_token_type)$/;" f +gimple_parse_expect_true_label lto/lto.c /^gimple_parse_expect_true_label (cpp_reader *p)$/;" f gimple_parse_goto_stmt lto/lto.c /^gimple_parse_goto_stmt (cpp_reader *p)$/;" f -gimple_parse_label_stmt lto/lto.c /^void gimple_parse_label_stmt (cpp_reader *p)$/;" f -gimple_parse_stmt lto/lto.c /^gimple_parse_stmt (cpp_reader *p,const cpp_token *tok)$/;" f +gimple_parse_label_stmt lto/lto.c /^gimple_parse_label_stmt (cpp_reader *p)$/;" f +gimple_parse_return_stmt lto/lto.c /^gimple_parse_return_stmt (cpp_reader *p)$/;" f +gimple_parse_stmt lto/lto.c /^gimple_parse_stmt (cpp_reader *p, const cpp_token *tok)$/;" f gimple_phi_arg gimple.h /^gimple_phi_arg (gimple gs, unsigned index)$/;" f gimple_phi_arg_def tree-flow-inline.h /^gimple_phi_arg_def (gimple gs, size_t index)$/;" f gimple_phi_arg_def_ptr tree-flow-inline.h /^gimple_phi_arg_def_ptr (gimple gs, size_t index)$/;" f