public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* [gimplefe] Ran into a internal compiler error
@ 2011-09-20  3:32 Sandeep Soni
  2011-09-20 16:15 ` Iyer, Balaji V
  2011-09-20 17:18 ` Diego Novillo
  0 siblings, 2 replies; 4+ messages in thread
From: Sandeep Soni @ 2011-09-20  3:32 UTC (permalink / raw)
  To: GCC LIST; +Cc: Diego Novillo

Hi,
I was trying to make a symbol table for all the variable declarations
for the gimple front end. Following is a patch:

Index: parser.c
===================================================================
--- parser.c	(revision 174754)
+++ parser.c	(working copy)
@@ -28,6 +28,7 @@
 #include "tree.h"
 #include "gimple.h"
 #include "parser.h"
+#include "hashtab.h"
 #include "ggc.h"

 /* The GIMPLE parser.  Note: do not use this variable directly.  It is
@@ -807,6 +808,31 @@
     }
 }

+
+struct gimple_symtab_entry_def
+{
+  tree decl;
+};
+
+static hashval_t
+gimple_symtab_entry_hash (const void *entry)
+{
+  const struct gimple_symtab_entry_def *base =
+    (const struct gimple_symtab_entry_def *)entry;
+  return IDENTIFIER_HASH_VALUE (base->decl);
+}
+
+static int
+gimple_symtab_eq_hash (const void *entry1, const void *entry2)
+{
+  const struct gimple_symtab_entry_def *p1 =
+    (const struct gimple_symtab_entry_def *)entry1;
+  const struct gimple_symtab_entry_def *p2 =
+    (const struct gimple_symtab_entry_def *)entry2;
+
+  return (p1->decl == p2->decl);
+}
+
 /* The Declaration section within a .gimple file can consist of
    a) Declaration of variables.
    b) Declaration of functions.
@@ -871,10 +897,29 @@
 gp_parse_var_decl (gimple_parser *parser)
 {
   const gimple_token *next_token;
+  const gimple_token *name_token;
+  const char* name;
   enum tree_code code ;

+  htab_t gimple_symtab;
+  void **slot1, **slot2;
+  struct gimple_symtab_entry_def e;
+
+  gimple_symtab = htab_create_ggc (10, gimple_symtab_entry_hash,
gimple_symtab_eq_hash, NULL);
   gl_consume_expected_token (parser->lexer, CPP_LESS);
-  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  name_token = gl_consume_expected_token (parser->lexer, CPP_NAME);
+  name = gl_token_as_text(name_token);
+  e.decl = build_decl (UNKNOWN_LOCATION, VAR_DECL,
get_identifier(name), void_type_node);
+  slot1 = htab_find_slot (gimple_symtab ,&e, INSERT);
+  slot2 = htab_find_slot (gimple_symtab, &e, NO_INSERT);
+  if (slot1 == slot2)
+    {
+      printf ("I think this is right\n");
+    }
+  else
+    {
+      printf ("Or this is wrong\n");
+    }
   gl_consume_expected_token (parser->lexer, CPP_COMMA);

   next_token = gl_consume_token (parser->lexer);
@@ -1391,7 +1436,6 @@
   parser_gc_root__ = NULL;
 }

-
 /* Main entry point for the GIMPLE front end.  */

 void
@@ -1402,7 +1446,6 @@
   parser_gc_root__ = parser = gp_init (main_input_filename);
   if (parser->lexer->filename == NULL)
     return;
-
   gl_lex (parser->lexer);
   gp_parse (parser);
   gp_finish (parser);


It gives me a internal compiler error saying:
gimple1: internal compiler error: tree check: expected
identifier_node, have var_decl in gimple_symtab_entry_hash

Is there something that I have gotten wrong or something that I had to
do before that I missed?

-- 
Cheers
Sandy

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

* RE: [gimplefe] Ran into a internal compiler error
  2011-09-20  3:32 [gimplefe] Ran into a internal compiler error Sandeep Soni
@ 2011-09-20 16:15 ` Iyer, Balaji V
  2011-09-20 17:18 ` Diego Novillo
  1 sibling, 0 replies; 4+ messages in thread
From: Iyer, Balaji V @ 2011-09-20 16:15 UTC (permalink / raw)
  To: Sandeep Soni, GCC LIST; +Cc: Diego Novillo

HI Sandeep,
	I think what it is saying is that it is requiring an identifier, but you are passing in a variable declaration. Please try to do the following and see if it works.

+  return IDENTIFIER_HASH_VALUE (base->decl); }

With

 return IDENTIFIER_HASH_VALUE (DECL_NAME (base->decl));


Thanks,

Balaji V. Iyer.

-----Original Message-----
From: Sandeep Soni [mailto:soni.sandeepb@gmail.com] 
Sent: Monday, September 19, 2011 11:32 PM
To: GCC LIST
Cc: Diego Novillo
Subject: [gimplefe] Ran into a internal compiler error

Hi,
I was trying to make a symbol table for all the variable declarations for the gimple front end. Following is a patch:

Index: parser.c
===================================================================
--- parser.c	(revision 174754)
+++ parser.c	(working copy)
@@ -28,6 +28,7 @@
 #include "tree.h"
 #include "gimple.h"
 #include "parser.h"
+#include "hashtab.h"
 #include "ggc.h"

 /* The GIMPLE parser.  Note: do not use this variable directly.  It is @@ -807,6 +808,31 @@
     }
 }

+
+struct gimple_symtab_entry_def
+{
+  tree decl;
+};
+
+static hashval_t
+gimple_symtab_entry_hash (const void *entry) {
+  const struct gimple_symtab_entry_def *base =
+    (const struct gimple_symtab_entry_def *)entry;
+  return IDENTIFIER_HASH_VALUE (base->decl); }
+
+static int
+gimple_symtab_eq_hash (const void *entry1, const void *entry2) {
+  const struct gimple_symtab_entry_def *p1 =
+    (const struct gimple_symtab_entry_def *)entry1;
+  const struct gimple_symtab_entry_def *p2 =
+    (const struct gimple_symtab_entry_def *)entry2;
+
+  return (p1->decl == p2->decl);
+}
+
 /* The Declaration section within a .gimple file can consist of
    a) Declaration of variables.
    b) Declaration of functions.
@@ -871,10 +897,29 @@
 gp_parse_var_decl (gimple_parser *parser)  {
   const gimple_token *next_token;
+  const gimple_token *name_token;
+  const char* name;
   enum tree_code code ;

+  htab_t gimple_symtab;
+  void **slot1, **slot2;
+  struct gimple_symtab_entry_def e;
+
+  gimple_symtab = htab_create_ggc (10, gimple_symtab_entry_hash,
gimple_symtab_eq_hash, NULL);
   gl_consume_expected_token (parser->lexer, CPP_LESS);
-  gl_consume_expected_token (parser->lexer, CPP_NAME);
+  name_token = gl_consume_expected_token (parser->lexer, CPP_NAME);  
+ name = gl_token_as_text(name_token);  e.decl = build_decl 
+ (UNKNOWN_LOCATION, VAR_DECL,
get_identifier(name), void_type_node);
+  slot1 = htab_find_slot (gimple_symtab ,&e, INSERT);
+  slot2 = htab_find_slot (gimple_symtab, &e, NO_INSERT);  if (slot1 == 
+ slot2)
+    {
+      printf ("I think this is right\n");
+    }
+  else
+    {
+      printf ("Or this is wrong\n");
+    }
   gl_consume_expected_token (parser->lexer, CPP_COMMA);

   next_token = gl_consume_token (parser->lexer); @@ -1391,7 +1436,6 @@
   parser_gc_root__ = NULL;
 }

-
 /* Main entry point for the GIMPLE front end.  */

 void
@@ -1402,7 +1446,6 @@
   parser_gc_root__ = parser = gp_init (main_input_filename);
   if (parser->lexer->filename == NULL)
     return;
-
   gl_lex (parser->lexer);
   gp_parse (parser);
   gp_finish (parser);


It gives me a internal compiler error saying:
gimple1: internal compiler error: tree check: expected identifier_node, have var_decl in gimple_symtab_entry_hash

Is there something that I have gotten wrong or something that I had to do before that I missed?

--
Cheers
Sandy

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

* Re: [gimplefe] Ran into a internal compiler error
  2011-09-20  3:32 [gimplefe] Ran into a internal compiler error Sandeep Soni
  2011-09-20 16:15 ` Iyer, Balaji V
@ 2011-09-20 17:18 ` Diego Novillo
  2011-09-21  3:14   ` Sandeep Soni
  1 sibling, 1 reply; 4+ messages in thread
From: Diego Novillo @ 2011-09-20 17:18 UTC (permalink / raw)
  To: Sandeep Soni; +Cc: GCC LIST

On 11-09-19 23:32 , Sandeep Soni wrote:

> It gives me a internal compiler error saying:
> gimple1: internal compiler error: tree check: expected
> identifier_node, have var_decl in gimple_symtab_entry_hash

As Balaji said, the problem is that you need to pass 
DECL_NAME(base->decl) to IDENTIFIER_HASH_VALUE().

When you build a decl node, its DECL_NAME is the IDENTIFIER_NODE that 
you created with get_identifier().


Diego.

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

* Re: [gimplefe] Ran into a internal compiler error
  2011-09-20 17:18 ` Diego Novillo
@ 2011-09-21  3:14   ` Sandeep Soni
  0 siblings, 0 replies; 4+ messages in thread
From: Sandeep Soni @ 2011-09-21  3:14 UTC (permalink / raw)
  To: GCC LIST; +Cc: Diego Novillo, balaji.v.iyer

On Tue, Sep 20, 2011 at 10:48 PM, Diego Novillo <dnovillo@google.com> wrote:
> On 11-09-19 23:32 , Sandeep Soni wrote:
>
>> It gives me a internal compiler error saying:
>> gimple1: internal compiler error: tree check: expected
>> identifier_node, have var_decl in gimple_symtab_entry_hash
>
> As Balaji said, the problem is that you need to pass DECL_NAME(base->decl)
> to IDENTIFIER_HASH_VALUE().
>
> When you build a decl node, its DECL_NAME is the IDENTIFIER_NODE that you
> created with get_identifier().
>

It worked. Thanks Balaji and Diego.



-- 
Cheers
Sandy

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

end of thread, other threads:[~2011-09-21  3:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-20  3:32 [gimplefe] Ran into a internal compiler error Sandeep Soni
2011-09-20 16:15 ` Iyer, Balaji V
2011-09-20 17:18 ` Diego Novillo
2011-09-21  3:14   ` Sandeep Soni

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