This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: [gimplefe] Ran into a internal compiler error


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]