public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch 1/2] [gimplefe] Changes internal interface of recognition of  tuples.
@ 2010-08-06 17:58 Sandeep Soni
  2010-08-07 20:05 ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Sandeep Soni @ 2010-08-06 17:58 UTC (permalink / raw)
  To: gcc patches; +Cc: Diego Novillo

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

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.

-- 
Cheers
Sandy

[-- Attachment #2: gimplefe.patch --]
[-- Type: application/octet-stream, Size: 13321 bytes --]

diff -Napru /home/Sandy/Development/gimple-front-end/gcc/ChangeLog.gimplefe /home/Sandy/Development/my-gimple-front-end/gcc/ChangeLog.gimplefe
--- /home/Sandy/Development/gimple-front-end/gcc/ChangeLog.gimplefe	2010-08-05 01:40:47.000000000 +0530
+++ /home/Sandy/Development/my-gimple-front-end/gcc/ChangeLog.gimplefe	2010-08-06 04:05:51.000000000 +0530
@@ -1,3 +1,19 @@
+2010-08-06  Sandeep Soni  <soni.sandeepb@gmail.com>
+
+	* lto/lto.c (gimple_parse_expect_subcode,
+	gimple_parse_expect_lhs, gimple_parse_expect_rhs1,
+	gimple_parse_expect_op1, gimple_parse_expect_op2,
+	gimple_parse_expect_true_label,
+        gimple_parse_expect_false_label,
+        gimple_parse_return_stmt): New.
+        * lto/lto.c (gimple_parse_assign_stmt,
+        gimple_parse_cond_stmt): Changed body to suit the new
+        interface.
+        * lto/lto.c (gimple_parse_stmt) : Added case to handle
+        gimple_return tuple.
+	* lto/lto.h: Added function declarations.
+	
+
 2010-08-02  Diego Novillo  <dnovillo@google.com>
 
 	* lto/lto.c (lto_main): Call ggc_alloc_cleared_line_maps
diff -Napru /home/Sandy/Development/gimple-front-end/gcc/lto/lto.c /home/Sandy/Development/my-gimple-front-end/gcc/lto/lto.c
--- /home/Sandy/Development/gimple-front-end/gcc/lto/lto.c	2010-08-05 01:35:44.000000000 +0530
+++ /home/Sandy/Development/my-gimple-front-end/gcc/lto/lto.c	2010-08-06 03:20:51.000000000 +0530
@@ -1992,83 +1992,283 @@ lto_eh_personality (void)
   return lto_eh_personality_decl;
 }
 
+/* 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 
-gimple_parse_expect_token (cpp_reader *p,int expected_token_type)
+gimple_parse_expect_token (cpp_reader *p, int expected_token_type)
 {
   const cpp_token *next_token;
-  FILE *fp;
-  next_token = cpp_get_token (p);
+  next_token = cpp_peek_token (p, 0);
+
+  /* If the token type does not match then we must report an error,
+     otherwise consume the token.  */
+
+  /* FIXME The error reported should be more precise to help 
+     diagnostics similar to that reported by other front ends in
+     the same case.  */
+
   if(next_token->type != expected_token_type)
-    {
-      /* Report Error.  */
-      fp = fopen ("/tmp/error.txt","a");
-      fprintf (fp,"Reporting Error\n");
-      fclose (fp);
-    }
+    error ("Mismatch in expected token type");
+  else
+    next_token = cpp_get_token (p);     
 }
 
-void 
-gimple_parse_assign_stmt (cpp_reader *p)
+/* 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
+gimple_parse_expect_subcode (cpp_reader *p)
 {
+  const cpp_token *next_token;
+  const char *text;
+  int i;
+
   gimple_parse_expect_token (p, CPP_LESS);
-  gimple_parse_expect_token (p, CPP_NAME);
-  gimple_parse_expect_token (p, CPP_COMMA);
-  gimple_parse_expect_token (p, CPP_NAME);
+
+  /* Peeks a token and looks it up for a match.  */
+ 
+  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]))
+        break;
+
+  /* If none of the tree codes match, then report an error. Otherwise
+     consume this token.  */
+
+  if (i == LAST_AND_UNUSED_TREE_CODE)
+    error ("Expected token should be one of the tree codes");
+  else
+    next_token = cpp_get_token (p);
+
   gimple_parse_expect_token (p, CPP_COMMA);
+
+  /* FIXME From this function we should return the tree code since it
+     can be used by the other helper functions to recognize precisely.  */
+}
+
+/* Helper for gimple_parse_assign_stmt. The token read from reader P should 
+   be the lhs of the tuple.  */
+
+void 
+gimple_parse_expect_lhs (cpp_reader *p)
+{  
+  const cpp_token *next_token;
+
+  /* Just before the name of the identifier we might get the symbol 
+     of dereference too. If we do get it then consume that token, else
+     continue recognizing the name.  */
+
+  next_token = cpp_peek_token (p, 0);
+  if (next_token->type == CPP_MULT)
+    next_token = cpp_get_token (p);
+
   gimple_parse_expect_token (p, CPP_NAME);
   gimple_parse_expect_token (p, CPP_COMMA);
-  gimple_parse_expect_token (p, CPP_NAME);
-  gimple_parse_expect_token (p, CPP_GREATER);
 }
 
+/* Helper for gimple_parse_assign_stmt. The token read from reader P should 
+   be the first operand in rhs of the tuple.  */
+
+void 
+gimple_parse_expect_rhs1 (cpp_reader *p)
+{
+  const cpp_token *next_token;
+  next_token = cpp_peek_token (p, 0);
+
+/* Currently there is duplication in the following blocks but there would be 
+   more stuff added here as we go on.  */
+
+/* ??? Can there be more possibilities than these ?  */
+ 
+  if (next_token->type == CPP_MULT)
+    {
+      next_token = cpp_get_token (p);
+      gimple_parse_expect_token (p, CPP_NAME);
+    }
+  else if (next_token->type == CPP_AND)
+    {
+      next_token = cpp_get_token (p);
+      gimple_parse_expect_token (p, CPP_NAME);    
+    }
+  else if (next_token->type == CPP_NAME)
+      next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_NUMBER)
+      next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_STRING)
+      next_token = cpp_get_token (p);      
+
+  gimple_parse_expect_token (p, CPP_COMMA); 
+}
+
+/* Helper for gimple_parse_assign_stmt. The token read from reader P should 
+   be the second operand in rhs of the tuple.  */
+
+void 
+gimple_parse_expect_rhs2 (cpp_reader *p)
+{
+  const cpp_token *next_token;
+  next_token = cpp_peek_token (p, 0);
+
+/* ??? Can there be more possibilities than these ?  */
+
+  if (next_token->type == CPP_NAME)
+    {
+      /* Handle a special case, this can be NULL too. 
+
+      if (!strcasecmp ((const char *) cpp_token_as_text (p, next_token), "Null"));
+        {
+          
+        }  */
+
+      next_token = cpp_get_token (p);
+    }
+  else if (next_token->type == CPP_NUMBER)
+      next_token = cpp_get_token (p);      
+
+  gimple_parse_expect_token (p, CPP_GREATER);  
+}
+
+/* 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 
+gimple_parse_assign_stmt (cpp_reader *p)
+{
+  gimple_parse_expect_subcode (p);
+  gimple_parse_expect_lhs (p);
+  gimple_parse_expect_rhs1 (p);
+  gimple_parse_expect_rhs2 (p);
+}
+
+/* Helper for gimple_parse_cond_stmt. The token read from reader P should
+   be the first operand in the tuple.  */
 void
-gimple_parse_cond_stmt (cpp_reader *p)
+gimple_parse_expect_op1 (cpp_reader *p)
+{
+  const cpp_token *next_token;
+  next_token = cpp_peek_token (p, 0);
+
+  if(next_token->type == CPP_NAME)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_NUMBER)
+    next_token = cpp_get_token (p);
+
+  gimple_parse_expect_token (p, CPP_COMMA);  
+}
+
+/* Helper for gimple_parse_cond_stmt. The token read from reader P should
+   be the second operand in the tuple.  */
+
+void
+gimple_parse_expect_op2 (cpp_reader *p)
+{
+  const cpp_token *next_token;
+  next_token = cpp_peek_token (p, 0);
+
+  if(next_token->type == CPP_NAME)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_NUMBER)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_STRING)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_AND)
+    {
+      next_token = cpp_get_token (p);
+      gimple_parse_expect_token (p, CPP_NAME);
+    }
+
+  gimple_parse_expect_token (p, CPP_COMMA);  
+}
+
+/* Helper for gimple_parse_cond_stmt. The token read from reader P should
+   be the true label in the tuple that means the label where the control
+   jumps if the condition evaluates to true.  */
+
+void
+gimple_parse_expect_true_label (cpp_reader *p)
 {
-  gimple_parse_expect_token (p, CPP_LESS);
-  gimple_parse_expect_token (p, CPP_NAME);
-  gimple_parse_expect_token (p, CPP_COMMA);
-  gimple_parse_expect_token (p, CPP_NAME);
-  gimple_parse_expect_token (p, CPP_COMMA);
-  gimple_parse_expect_token (p, CPP_NAME);
-  gimple_parse_expect_token (p, CPP_COMMA);
   gimple_parse_expect_token (p, CPP_LESS);
   gimple_parse_expect_token (p, CPP_NAME);
   gimple_parse_expect_token (p, CPP_GREATER);
-  gimple_parse_expect_token (p, CPP_COMMA);
+  gimple_parse_expect_token (p, CPP_COMMA);  
+}
+
+/* Helper for gimple_parse_cond_stmt. The token read from reader P should
+   be the false label in the tuple that means the label where the control
+   jumps if the condition evaluates to false.  */
+
+void
+gimple_parse_expect_false_label (cpp_reader *p)
+{
   gimple_parse_expect_token (p, CPP_LESS);
   gimple_parse_expect_token (p, CPP_NAME);
   gimple_parse_expect_token (p, CPP_RSHIFT);
 }
 
+/* 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
+gimple_parse_cond_stmt (cpp_reader *p)
+{
+  gimple_parse_expect_subcode (p);
+  gimple_parse_expect_op1 (p);
+  gimple_parse_expect_op2 (p);
+  gimple_parse_expect_true_label (p);
+  gimple_parse_expect_false_label (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
 gimple_parse_goto_stmt (cpp_reader *p)
 {
-  gimple_parse_expect_token (p,CPP_LSHIFT);
-  gimple_parse_expect_token (p,CPP_NAME);
-  gimple_parse_expect_token (p,CPP_RSHIFT);
+  gimple_parse_expect_token (p, CPP_LSHIFT);
+  gimple_parse_expect_token (p, CPP_NAME);
+  gimple_parse_expect_token (p, CPP_RSHIFT);
+}
+
+/* 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
+gimple_parse_label_stmt (cpp_reader *p)
+{
+  gimple_parse_expect_token (p, CPP_LSHIFT);
+  gimple_parse_expect_token (p, CPP_NAME);
+  gimple_parse_expect_token (p, CPP_RSHIFT);  
 }
 
-void 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
+gimple_parse_return_stmt (cpp_reader *p)
 {
-  gimple_parse_expect_token (p,CPP_LSHIFT);
-  gimple_parse_expect_token (p,CPP_NAME);
-  gimple_parse_expect_token (p,CPP_RSHIFT);  
+  gimple_parse_expect_token (p, CPP_LESS);
+  gimple_parse_expect_token (p, CPP_NAME);
+  gimple_parse_expect_token (p, CPP_GREATER);  
 }
 
+/* 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 
-gimple_parse_stmt (cpp_reader *p,const cpp_token *tok)
+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=0;i<LAST_AND_UNUSED_GIMPLE_CODE;i++)
-    if(!strcasecmp(text,gimple_code_name[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]))
       break;
 
   if(i==LAST_AND_UNUSED_GIMPLE_CODE)
-    {
-      /* Report Error.  */
-    }
+    error ("Invalid gimple code used"); 
   else
     {
     switch (i)
@@ -2085,6 +2285,9 @@ gimple_parse_stmt (cpp_reader *p,const c
         case GIMPLE_GOTO:
           gimple_parse_goto_stmt (p);
           break;
+        case GIMPLE_RETURN:
+          gimple_parse_return_stmt (p);
+          break;
         default:
           break;
       }
diff -Napru /home/Sandy/Development/gimple-front-end/gcc/lto/lto.h /home/Sandy/Development/my-gimple-front-end/gcc/lto/lto.h
--- /home/Sandy/Development/gimple-front-end/gcc/lto/lto.h	2010-08-05 01:35:44.000000000 +0530
+++ /home/Sandy/Development/my-gimple-front-end/gcc/lto/lto.h	2010-08-06 03:27:32.000000000 +0530
@@ -40,12 +40,21 @@ 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_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_expect_token (cpp_reader *p,int expected_token_type);
+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);


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] [gimplefe] Changes internal interface of recognition  of tuples.
  2010-08-06 17:58 [patch 1/2] [gimplefe] Changes internal interface of recognition of tuples Sandeep Soni
@ 2010-08-07 20:05 ` Diego Novillo
  2010-08-10 14:08   ` Sandeep Soni
  0 siblings, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2010-08-07 20:05 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: gcc patches

[-- Attachment #1: Type: text/plain, Size: 569 bytes --]

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.

[-- Attachment #2: 00.diff --]
[-- Type: text/x-patch, Size: 10516 bytes --]

2010-08-07  Diego Novillo  <dnovillo@google.com>

	* 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] [gimplefe] Changes internal interface of recognition  of tuples.
  2010-08-07 20:05 ` Diego Novillo
@ 2010-08-10 14:08   ` Sandeep Soni
  2010-08-12 22:47     ` Diego Novillo
  0 siblings, 1 reply; 4+ messages in thread
From: Sandeep Soni @ 2010-08-10 14:08 UTC (permalink / raw)
  To: Diego Novillo; +Cc: gcc patches

[-- Attachment #1: Type: text/plain, Size: 634 bytes --]

> 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.
>

The additional call to cpp_type2name in gcc/lto/lto.c :
gimple_parse_expect_token in the last patch caused a build error
(default build options).
I am attaching a patch that changes the argument type for the above
function from int expected_token_type to enum cpp_ttype
expected_token_type (This we anyways wanted to fix).


-- 
Cheers
Sandy

[-- Attachment #2: gimplefe.patch --]
[-- Type: application/octet-stream, Size: 622 bytes --]

2010-08-08  Sandeep Soni   <soni.sandeepb@gmail.com>

        * lto/lto.c (gimple_parse_expect_token): Changed 
        argument type from int to enum cpp_ttype.

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)
    are looking for. The token is obtained by reading it from the reader P.  */
   
static const cpp_token * 
- gimple_parse_expect_token (cpp_reader *p, int expected_token_type)
+ gimple_parse_expect_token (cpp_reader *p, enum cpp_ttype expected_token_type)
 {
   const cpp_token *next_token;



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch 1/2] [gimplefe] Changes internal interface of recognition of tuples.
  2010-08-10 14:08   ` Sandeep Soni
@ 2010-08-12 22:47     ` Diego Novillo
  0 siblings, 0 replies; 4+ messages in thread
From: Diego Novillo @ 2010-08-12 22:47 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: gcc patches

On Tue, Aug 10, 2010 at 10:05, Sandeep Soni <soni.sandeepb@gmail.com> wrote:

> The additional call to cpp_type2name in gcc/lto/lto.c :
> gimple_parse_expect_token in the last patch caused a build error
> (default build options).
> I am attaching a patch that changes the argument type for the above
> function from int expected_token_type to enum cpp_ttype
> expected_token_type (This we anyways wanted to fix).

Thanks.  Committed.


Diego.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-08-12 22:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-06 17:58 [patch 1/2] [gimplefe] Changes internal interface of recognition of tuples Sandeep Soni
2010-08-07 20:05 ` Diego Novillo
2010-08-10 14:08   ` Sandeep Soni
2010-08-12 22:47     ` Diego Novillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).