public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch 2/2][gimplefe] Extends coverage to gimple_switch and  gimple_call recognition
@ 2010-08-10 14:12 Sandeep Soni
  2010-08-12 23:31 ` Diego Novillo
  0 siblings, 1 reply; 2+ messages in thread
From: Sandeep Soni @ 2010-08-10 14:12 UTC (permalink / raw)
  To: gcc patches; +Cc: Diego Novillo

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

Hi,

I am attaching the patch that is able to recognize gimple_switch and
gimple_call statements. Work now begins on getting to recognize types
and variable declarations.

-- 
Cheers
Sandy

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

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

        * lto/lto.c (gimple_parse_switch_stmt,
        gimple_parse_expect_function_name,
        gimple_parse_expect_return_var,
        gimple_parse_expect_argument,
        gimple_parse_call_stmt): New.
        (gimple_parse_stmt): Added case to handle
        gimple_call and gimple_switch.

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-10 11:36:37.000000000 +0530
+++ /home/Sandy/Development/my-gimple-front-end/gcc/lto/lto.c	2010-08-10 12:41:30.000000000 +0530
@@ -2248,6 +2248,125 @@ gimple_parse_label_stmt (cpp_reader *p)
   gimple_parse_expect_token (p, CPP_RSHIFT);  
 }
 
+/* Parse a gimple_switch tuple that is read from the reader P. For now we only 
+   recognize the tuple. Refer gimple.def for the format of this tuple.  */
+
+static void
+gimple_parse_switch_stmt (cpp_reader *p)
+{
+  const cpp_token *next_token;
+
+  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_COLON);
+  gimple_parse_expect_token (p, CPP_LESS);
+  gimple_parse_expect_token (p, CPP_NAME);
+
+  for (;;)
+    {
+      next_token = cpp_peek_token (p, 0);
+      
+      if (next_token->type == CPP_GREATER)
+        {
+          next_token = cpp_get_token (p);
+          gimple_parse_expect_token (p, CPP_COMMA);
+          gimple_parse_expect_token (p, CPP_NAME);
+          gimple_parse_expect_token (p, CPP_NUMBER);
+          gimple_parse_expect_token (p, CPP_COLON);
+          gimple_parse_expect_token (p, CPP_LESS);
+          gimple_parse_expect_token (p, CPP_NAME);  
+        }
+      else if (next_token->type == CPP_RSHIFT)
+        {
+          next_token = cpp_get_token (p);
+          break;
+        }
+      else
+        error ("Incorrect use of the gimple_switch statement");
+    }
+}
+
+/* Helper for gimple_parse_call_stmt. The token read from reader P should
+   be the name of the function called.  */
+
+static void
+gimple_parse_expect_function_name (cpp_reader *p)
+{
+  gimple_parse_expect_token (p, CPP_LESS);
+  gimple_parse_expect_token (p, CPP_NAME);
+  gimple_parse_expect_token (p, CPP_COMMA);
+}
+
+/* Helper for gimple_parse_call_stmt. The token read from reader P should
+   be the identifier in which the value is returned.  */
+
+static void
+gimple_parse_expect_return_var (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);
+  
+  /* There may be no variable in which the return value is collected.
+     In that case this field in the tuple will contain NULL. We need 
+     to handle it too.  */
+}
+
+/* Helper for gimple_parse_call_stmt. The token read from reader P should
+   be the argument in the function call.  */
+
+static void
+gimple_parse_expect_argument (cpp_reader *p)
+{
+  const cpp_token *next_token;
+
+  next_token = cpp_peek_token (p, 0);
+
+  if (next_token->type == CPP_NUMBER)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_NAME)
+    next_token = cpp_get_token (p);
+  else if (next_token->type == CPP_MULT)
+    {
+      next_token = cpp_get_token (p);
+      gimple_parse_expect_token (p, CPP_NAME);
+    }
+  else
+    error ("Incorrect way to specify an argument");
+}
+
+/* Parse a gimple_call tuple that is read from the reader P. For now we only 
+   recognize the tuple. Refer gimple.def for the format of this tuple.  */
+
+static void
+gimple_parse_call_stmt (cpp_reader *p)
+{
+  const cpp_token *next_token;
+
+  gimple_parse_expect_function_name (p);
+  gimple_parse_expect_return_var (p);
+  
+  for (;;)
+    {
+      next_token = cpp_peek_token (p, 0);
+      if (next_token->type == CPP_GREATER)
+        {
+          next_token = cpp_get_token (p);
+          break;
+        }
+      else if (next_token->type == CPP_COMMA)
+        {
+          next_token = cpp_get_token (p);
+          gimple_parse_expect_argument (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.  */
 
@@ -2291,6 +2410,12 @@ gimple_parse_stmt (cpp_reader *p, const 
         case GIMPLE_GOTO:
           gimple_parse_goto_stmt (p);
           break;
+        case GIMPLE_SWITCH:
+          gimple_parse_switch_stmt (p);
+          break;
+        case GIMPLE_CALL:
+          gimple_parse_call_stmt (p);
+          break;
         case GIMPLE_RETURN:
           gimple_parse_return_stmt (p);
           break;


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

* Re: [patch 2/2][gimplefe] Extends coverage to gimple_switch and gimple_call recognition
  2010-08-10 14:12 [patch 2/2][gimplefe] Extends coverage to gimple_switch and gimple_call recognition Sandeep Soni
@ 2010-08-12 23:31 ` Diego Novillo
  0 siblings, 0 replies; 2+ messages in thread
From: Diego Novillo @ 2010-08-12 23:31 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: gcc patches

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

> I am attaching the patch that is able to recognize gimple_switch and
> gimple_call statements. Work now begins on getting to recognize types
> and variable declarations.

Thanks.  Committed.

A couple of minor nits.  There should be two spaces between your name
and the email address in the ChangeLog entry and each line in the
ChangeLog entry should be prefixed by a tab character, not spaces.


Diego.

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-10 14:12 [patch 2/2][gimplefe] Extends coverage to gimple_switch and gimple_call recognition Sandeep Soni
2010-08-12 23:31 ` 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).