[M3devel] parse.c builtins hashtable needed?

Jay K jay.krell at cornell.edu
Thu Jan 13 16:14:21 CET 2011


Um. I don't see the point of the hashtable actually.
All the calls except "m3_alloca" are translated "directly".

I understand that if there were many things like this new m3_alloca, a hashtable would make sense.

I understand as well that __builtin_alloca ought to just work w/o special handling, but I didn't debug why.

I'm testing the below and expect it will work. Even if atomics are used much.

?

Index: m3-sys/m3cc/gcc/gcc/m3cg/parse.c
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3cc/gcc/gcc/m3cg/parse.c,v
retrieving revision 1.478
diff -u -r1.478 parse.c
--- m3-sys/m3cc/gcc/gcc/m3cg/parse.c    13 Jan 2011 14:58:29 -0000    1.478
+++ m3-sys/m3cc/gcc/gcc/m3cg/parse.c    13 Jan 2011 15:10:35 -0000
@@ -1535,37 +1535,6 @@
   return decl;
 }
 
-/* Return a definition for a builtin function named NAME and whose data type
-   is TYPE.  TYPE should be a function type with argument types.
-   FUNCTION_CODE tells later passes how to compile calls to this function.
-   See tree.h for its possible values.
-
-   If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
-   the name to be called if we can't opencode the function.  If
-   ATTRS is nonzero, use that for the function's attribute list.
-
-   copied from gcc/c-decl.c
-*/
-
-static GTY ((param_is (union tree_node))) htab_t builtins;
-
-static hashval_t
-htab_hash_builtin (const PTR p)
-{
-  const_tree t = (const_tree)p;
-
-  return htab_hash_pointer (DECL_NAME (t));
-}
-
-static int
-htab_eq_builtin (const PTR p1, const PTR p2)
-{
-  const_tree t1 = (const_tree)p1;
-  const_tree t2 = (const_tree)p2;
-
-  return DECL_NAME (t1) == DECL_NAME (t2);
-}
-
 static tree
 builtin_function (PCSTR name, tree type,
 #if GCC42
@@ -1595,13 +1564,6 @@
     gcc_assert (!library_name);
   }
 
-  if (!builtins)
-    builtins = htab_create_ggc (1021, htab_hash_builtin,
-                                htab_eq_builtin, NULL);
-  tree* slot = (tree *)htab_find_slot (builtins, decl, INSERT);
-  gcc_assert (*slot == NULL);
-  *slot = decl;
-
   TREE_CHAIN (decl) = global_decls;
   global_decls = decl;
 
@@ -2979,11 +2941,7 @@
 static tree
 m3_convert_function_to_builtin (tree p)
 {
-  tree *slot = (tree *)htab_find_slot (builtins, p, NO_INSERT);
-
-  if (slot)
-    p = *slot;
-  else if (DECL_NAME (p) == m3_alloca)
+  if (DECL_NAME (p) == m3_alloca)
     p = built_in_decls[BUILT_IN_ALLOCA];
   return p;
 }

?

 - Jay


From: jay.krell at cornell.edu
To: jkrell at elego.de; m3commit at elegosoft.com
Subject: RE: [M3commit] CVS Update: cm3
Date: Thu, 13 Jan 2011 15:06:37 +0000








Hm. I'll try the hashtable instead.

 - Jay

From: jay.krell at cornell.edu
To: jkrell at elego.de; m3commit at elegosoft.com
Subject: RE: [M3commit] CVS Update: cm3
Date: Thu, 13 Jan 2011 15:00:24 +0000








Index: m3-sys/m3front/src/misc/Marker.m3
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3front/src/misc/Marker.m3,v
retrieving revision 1.8
diff -u -r1.8 Marker.m3
--- m3-sys/m3front/src/misc/Marker.m3    6 Jan 2011 20:40:16 -0000    1.8
+++ m3-sys/m3front/src/misc/Marker.m3    13 Jan 2011 14:56:53 -0000
@@ -248,7 +248,7 @@
     END;
     (* void* _alloca(size_t); *)
     IF (alloca = NIL) THEN
-      alloca := CG.Import_procedure (M3ID.Add ("_alloca"), 1, CG.Type.Addr,
+      alloca := CG.Import_procedure (M3ID.Add ("m3_alloca"), 1, CG.Type.Addr,
                                      Target.DefaultCall, new);
       IF (new) THEN
         EVAL CG.Declare_param (M3ID.NoID, Target.Word.size, Target.Word.align,
Index: m3-sys/m3cc/gcc/gcc/m3cg/parse.c
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3cc/gcc/gcc/m3cg/parse.c,v
retrieving revision 1.477
diff -u -r1.477 parse.c
--- m3-sys/m3cc/gcc/gcc/m3cg/parse.c    5 Jan 2011 14:34:53 -0000    1.477
+++ m3-sys/m3cc/gcc/gcc/m3cg/parse.c    13 Jan 2011 14:56:53 -0000
@@ -473,6 +473,8 @@
 #define t_void void_type_node
 static GTY (()) tree t_set;
 
+static tree m3_alloca;
+
 static const struct { UINT32 type_id; tree* t; } builtin_uids[] = {
   { UID_INTEGER, &t_int },
   { UID_LONGINT, &t_longint },
@@ -1750,6 +1752,7 @@
   bits_per_integer_tree = build_int_cst (t_word, BITS_PER_INTEGER);
   bytes_per_integer_tree = build_int_cst (t_word, BITS_PER_INTEGER / BITS_PER_UNIT);
   tree stdcall = get_identifier_with_length (CONSTANT_STRING_AND_LENGTH ("stdcall"));
+  m3_alloca = get_identifier_with_length (CONSTANT_STRING_AND_LENGTH ("m3_alloca"));
   stdcall_list = build_tree_list (stdcall, NULL);
   t_set = m3_build_pointer_type (t_word);
 
@@ -2979,22 +2982,9 @@
   tree *slot = (tree *)htab_find_slot (builtins, p, NO_INSERT);
 
   if (slot)
-  {
     p = *slot;
-  }
-  else
-  {
-    const char *name = IDENTIFIER_POINTER (DECL_NAME (p));
-    if (name[0] == 'a' || name[0] == '_')
-    {
-      if (strcmp(name, "alloca") == 0
-        || strcmp(name, "_alloca") == 0
-        || strcmp(name, "__builtin_alloca") == 0)
-      {
-        p = built_in_decls[BUILT_IN_ALLOCA];
-      }
-    }
-  }
+  else if (DECL_NAME (p) == m3_alloca)
+    p = built_in_decls[BUILT_IN_ALLOCA];
   return p;
 }
 
 - Jay


> Date: Thu, 13 Jan 2011 15:58:29 +0000
> To: m3commit at elegosoft.com
> From: jkrell at elego.de
> Subject: [M3commit] CVS Update: cm3
> 
> CVSROOT:	/usr/cvs
> Changes by:	jkrell at birch.	11/01/13 15:58:29
> 
> Modified files:
> 	cm3/m3-sys/m3front/src/misc/: Marker.m3 
> 	cm3/m3-sys/m3cc/gcc/gcc/m3cg/: parse.c 
> 
> Log message:
> 	__builtin_alloca didn't work w/o translation
> 	among alloca, _alloca, __builtin_alloca, make up our own name, m3_alloca
> 	and do the comparison by pointer equality (since gcc uses
> 	string interning)
> 	I'd also go for _m3_alloca, __m3_alloca, or alloca, or darn near
> 	anything else.
> 
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20110113/8700fb47/attachment-0001.html>


More information about the M3devel mailing list