[M3devel] "the tree problems"

Jay K jay.krell at cornell.edu
Mon Jun 28 14:08:47 CEST 2010


The "tree problems" exist with gcc 4.3 also.
I'd like to clear these up ahead of most other work.
  Enable configure -enable-checking=something unconditionally.

There a few. Some are more trivial than others.

Here is a start that I'm testing:
It can be broken into two parts, "bit operations (and/or/xor/not)" and index_address.

Index: parse.c
===================================================================
RCS file: /usr/cvs/cm3/m3-sys/m3cc/gcc/gcc/m3cg/parse.c,v
retrieving revision 1.201
diff -u -5 -r1.201 parse.c
--- parse.c    27 Jun 2010 14:09:32 -0000    1.201
+++ parse.c    28 Jun 2010 12:04:49 -0000
@@ -4404,41 +4404,43 @@
 static void
 m3cg_not (void)
 {
   MTYPE (t);
 
-  EXPR_REF (-1) = m3_build1 (BIT_NOT_EXPR, m3_unsigned_type (t),
-                             EXPR_REF (-1));
+  EXPR_REF (-1) = m3_build1 (BIT_NOT_EXPR, t, m3_cast (t, EXPR_REF (-1)));
 }
 
 static void
 m3cg_and (void)
 {
   MTYPE (t);
 
-  EXPR_REF (-2) = m3_build2 (BIT_AND_EXPR, m3_unsigned_type (t),
-                             EXPR_REF (-2), EXPR_REF (-1));
+  EXPR_REF (-2) = m3_build2 (BIT_AND_EXPR, t,
+                             m3_cast (t, EXPR_REF (-2)),
+                             m3_cast (t, EXPR_REF (-1)));
   EXPR_POP ();
 }
 
 static void
 m3cg_or (void)
 {
   MTYPE (t);
 
-  EXPR_REF (-2) = m3_build2 (BIT_IOR_EXPR, m3_unsigned_type (t),
-                             EXPR_REF (-2), EXPR_REF (-1));
+  EXPR_REF (-2) = m3_build2 (BIT_IOR_EXPR, t,
+                             m3_cast (t, EXPR_REF (-2)),
+                             m3_cast (t, EXPR_REF (-1)));
   EXPR_POP ();
 }
 
 static void
 m3cg_xor (void)
 {
   MTYPE (t);
 
-  EXPR_REF (-2) = m3_build2 (BIT_XOR_EXPR, m3_unsigned_type (t),
-                             EXPR_REF (-2), EXPR_REF (-1));
+  EXPR_REF (-2) = m3_build2 (BIT_XOR_EXPR, t,
+                             m3_cast (t, EXPR_REF (-2)),
+                             m3_cast (t, EXPR_REF (-1)));
   EXPR_POP ();
 }
 
 static void
 m3cg_shift (void)
@@ -4972,28 +4974,29 @@
 }
 
 static void
 m3cg_index_address (void)
 {
-  enum tree_code plus = (GCC45 ? POINTER_PLUS_EXPR : PLUS_EXPR);
-  tree a = { 0 };
   MTYPE2   (t, T);
-  BYTESIZE (n);
+  BYTESIZE (bits);
+  long bytes = bits / BITS_PER_UNIT;
+  bool signd = IS_INTEGER_TYPE_TREE(t);  
+  tree a = (signd ? ssize_int (bytes) : ssize_int (bytes));
 
   if (option_vars_trace)
-    fprintf(stderr, "  index address n:0x%lx n_bytes:0x%lx type:%s\n",
-            n, n / BITS_PER_UNIT, m3cg_typename(T));
+    fprintf(stderr, "  index address n_bytes:0x%lx type:%s\n",
+            bytes, m3cg_typename(T));
 
-  a = m3_build2 (MULT_EXPR, t, EXPR_REF (-1), size_int (n / BITS_PER_UNIT));
-  if (GCC45)
-  {
-    gcc_assert(IS_INTEGER_TYPE_TREE(t) || IS_WORD_TYPE_TREE(t));
-    if (IS_INTEGER_TYPE_TREE(t))
-      a = m3_cast(ssizetype, a);
-    a = m3_cast(sizetype, a);
-  }
-  EXPR_REF (-2) = m3_build2 (plus, t_addr, m3_cast (t_addr, EXPR_REF (-2)), a);
+  gcc_assert(signd || IS_WORD_TYPE_TREE(t));
+  gcc_assert(bits>= 0);
+  gcc_assert(bytes>= 0);
+  
+  a = m3_build2 (MULT_EXPR, t, m3_cast(t, EXPR_REF (-1)), a);
+  if (signd)
+    a = m3_cast(ssizetype, a);
+  a = m3_cast(sizetype, a);
+  EXPR_REF (-2) = m3_build2 (POINTER_PLUS_EXPR, t_addr, m3_cast (t_addr, EXPR_REF (-2)), a);
   EXPR_POP ();
 }
 

alternatively we could try like:


+  EXPR_REF (-2) = m3_build2 (BIT_AND_EXPR, t,

+                             EXPR_REF (-2),

+                             EXPR_REF (-1));



which is nicer, if it works.


Though I believe the more "forceful" (cast-ful) interpretation is what Tony described a while ago, in describing what the NT/x86 backend does wrong.
These "bit" are fairly uniquely uninteresting, since they don't vary for signed vs. unsigned.


There are more problems in shifting, where I'm treading more carefully, since right shift's and "extract" are affected by signed vs. unsigned.


  - Jay
 		 	   		  


More information about the M3devel mailing list