Hello 

Is this best List to get help for  GCC coding problems ?

in gcc/c-decl.c

I see in fnction finish_decl 

"""
finish_decl (tree decl, tree init, tree asmspec_tree)
{
""""

there is access possible to asmspec_tree.

but the func

push_parm_decl 

have no parameter asmspec_tree.

is there a way to get access to it, without many code changes, or below func
can use in a better place  ?

the amigaos target need that functions.
does somebody can tell me a more
easy way to add this feature, so not so many gcc source must change when
make a amiga OS Port ?.  

here is a short testprog to see what need.it is the feature to tell what
variable must put in which register or what register must put in which
variable

long GfxBase;

void (*Old_Text)(long rp asm("a1"),
                  long string asm("a0"),
                 long count asm("d0"),
                 long GfxBase asm("a6"));

 void New_Text(long rp __asm("a1"),
              long string __asm("a0"),
              long count __asm("d0"))

{
(*Old_Text)(rp, string, count,GfxBase);

}

But it is much more easy, when there is a way to get access to asmspec and
need not 1 additional parameter.

The current way is change many lines in c-parse.in (see below)

here is change that is need in c-decl.c
the changes are from 3.4.0 i find out, 

diff -rupN gcc-3.4.0/gcc/c-decl.c gcc-3.4.0-gg/gcc/c-decl.c
--- gcc-3.4.0/gcc/c-decl.c  Mon Mar 22 18:58:18 2004
+++ gcc-3.4.0-gg/gcc/c-decl.c   Tue Apr 27 11:12:30 2004
@@ -2943,7 +2943,7 @@ finish_decl (tree decl, tree init, tree 
    and push that on the current scope.  */
 
 void
-push_parm_decl (tree parm)
+push_parm_decl (tree parm, tree asmspec)
 {
   tree decl;
 
@@ -2956,6 +2956,75 @@ push_parm_decl (tree parm)
             TREE_PURPOSE (TREE_PURPOSE (parm)),
             PARM, 0, NULL);
   decl_attributes (&decl, TREE_VALUE (parm), 0);
+
+  /* begin-GG-local: explicit register specification for parameters */
+  if (asmspec)
+#ifdef TARGET_AMIGAOS
+    {
+      const char *regname=TREE_STRING_POINTER(asmspec);
+      int regnum;
+      if ((regnum=decode_reg_name(regname))>=0)
+   {
+     tree type=TREE_TYPE(decl);
+     if (HARD_REGNO_MODE_OK(regnum, TYPE_MODE(type)))
+       {
+         tree t, attrs;
+         /* Build tree for __attribute__ ((asm(regnum))). */
+#if 0
+         /* This doesn't work well because of a bug in
+        attribute_list_contained(), which passes list of arguments to
+        simple_cst_equal() instead of passing every argument
+        separately. */
+         attrs=tree_cons(get_identifier("asm"), tree_cons(NULL_TREE,
+           build_int_2_wide(regnum, 0), NULL_TREE), NULL_TREE);
+#else
+         attrs=tree_cons(get_identifier("asm"),
+                 build_int_2_wide(regnum, 0), NULL_TREE);
+#endif
+#if 0
+         /* build_type_attribute_variant() would seem to be more
+        appropriate here. However, that function does not support
+        attributes for parameters properly. It modifies
+        TYPE_MAIN_VARIANT of a new type. As a result, comptypes()
+        thinks that types of parameters in prototype and definition
+        are different and issues error messages. See also comment
+        below. */
+         type=build_type_attribute_variant(type, attrs);
+#else
+         /* First check whether such a type already exists - if yes, use
+        that one. This is very important, since otherwise
+        common_type() would think that it sees two different
+        types and would try to merge them - this could result in
+        warning messages. */
+         for (t=TYPE_MAIN_VARIANT(type); t; t=TYPE_NEXT_VARIANT(t))
+       if (comptypes(t, type, COMPARE_STRICT)==1
+           && attribute_list_equal(TYPE_ATTRIBUTES(t), attrs))
+             break;
+         if (t)
+       type=t;
+         else
+       {
+         /* Create a new variant, with differing attributes.
+            (Hack! Type with differing attributes should no longer be
+            a variant of its main type. See comment above for
+            explanation why this was necessary). */
+         type=build_type_copy(type);
+         TYPE_ATTRIBUTES(type)=attrs;
+       }
+#endif
+         TREE_TYPE(decl)=type;
+       }
+     else
+       error ("%Jregister specified for '%D' isn't suitable for data type",
+          decl, decl);
+   }
+      else
+   error ("invalid register name `%s'", regname);
+    }
+#else /* !TARGET_AMIGAOS */
+    error("explicit register specification for parameters is not supported
for this target");
+#endif /* !TARGET_AMIGAOS */
+  /* end-GG-local */
 
   decl = pushdecl (decl); 





......

diff -rupN gcc-3.4.0/gcc/c-parse.in gcc-3.4.0-gg/gcc/c-parse.in
--- gcc-3.4.0/gcc/c-parse.in    Sun Feb  8 21:56:44 2004
+++ gcc-3.4.0-gg/gcc/c-parse.in Tue Apr 27 11:12:30 2004
@@ -29,7 +29,7 @@ Software Foundation, 59 Temple Place - S
    written by AT&T, but I have never seen it.  */
 
 @@ifc
-%expect 10 /* shift/reduce conflicts, and no reduce/reduce conflicts.  */
+%expect 11 /* shift/reduce conflicts, and no reduce/reduce conflicts.  */
 @@end_ifc
 
 %{
@@ -1927,20 +1927,25 @@ absdcl:   /* an absolute declarator */
    | absdcl1
    ;
 
+/* begin-GG-local: explicit register specification for parameters */
 absdcl_maybe_attribute:   /* absdcl maybe_attribute, but not just
attributes */
-   /* empty */
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            NULL_TREE),
-                   all_prefix_attributes); }
-   | absdcl1
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $1),
-                   all_prefix_attributes); }
-   | absdcl1_noea attributes
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $1),
-                   chainon ($2, all_prefix_attributes)); }
+   maybeasm
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs,
NULL_TREE),
+                   all_prefix_attributes),
+            $1); }
+   | absdcl1 maybeasm
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $1),
+                     all_prefix_attributes),
+            $2); }
+   | absdcl1_noea maybeasm attributes
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $1),
+                     chainon ($3, all_prefix_attributes)),
+            $2); }
    ;
+/* end-GG-local */
 
 absdcl1:  /* a nonempty absolute declarator */
      absdcl1_ea
@@ -2595,33 +2600,37 @@ parmlist_2:  /* empty */
        }
    ;
 
+/* begin-GG-local: explicit register specification for parameters */
 parms:
    firstparm
-       { push_parm_decl ($1); }
+       { push_parm_decl (TREE_PURPOSE($1), TREE_VALUE($1)); }
    | parms ',' parm
-       { push_parm_decl ($3); }
+       { push_parm_decl (TREE_PURPOSE($3), TREE_VALUE($3)); }
    ;
 
 /* A single parameter declaration or parameter type name,
    as found in a parmlist.  */
 parm:
-     declspecs_ts setspecs parm_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+     declspecs_ts setspecs parm_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
-   | declspecs_ts setspecs notype_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+   | declspecs_ts setspecs notype_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
    | declspecs_ts setspecs absdcl_maybe_attribute
        { $$ = $3;
          POP_DECLSPEC_STACK; }
-   | declspecs_nots setspecs notype_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+   | declspecs_nots setspecs notype_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
 
    | declspecs_nots setspecs absdcl_maybe_attribute
@@ -2632,29 +2641,33 @@ parm:
 /* The first parm, which must suck attributes from off the top of the
parser
    stack.  */
 firstparm:
-     declspecs_ts_nosa setspecs_fp parm_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+     declspecs_ts_nosa setspecs_fp parm_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
-   | declspecs_ts_nosa setspecs_fp notype_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+   | declspecs_ts_nosa setspecs_fp notype_declarator maybeasm
maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
    | declspecs_ts_nosa setspecs_fp absdcl_maybe_attribute
        { $$ = $3;
          POP_DECLSPEC_STACK; }
-   | declspecs_nots_nosa setspecs_fp notype_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $3),
-                   chainon ($4, all_prefix_attributes));
+   | declspecs_nots_nosa setspecs_fp notype_declarator maybeasm
maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $3),
+                     chainon ($5, all_prefix_attributes)),
+            $4);
          POP_DECLSPEC_STACK; }
 
    | declspecs_nots_nosa setspecs_fp absdcl_maybe_attribute
        { $$ = $3;
          POP_DECLSPEC_STACK; }
    ;
+/* end-GG-local */
 
 setspecs_fp:
      setspecs
@@ -3054,28 +3067,32 @@ mydecl:
        { pedwarn ("empty declaration"); }
    ;
 
+/* begin-GG-local: explicit register specification for parameters */
 myparms:
    myparm
-       { push_parm_decl ($1); }
+       { push_parm_decl (TREE_PURPOSE($1), TREE_VALUE($1)); }
    | myparms ',' myparm
-       { push_parm_decl ($3); }
+       { push_parm_decl (TREE_PURPOSE($3), TREE_VALUE($3)); }
    ;
 
 /* A single parameter declaration or parameter type name,
    as found in a parmlist. DOES NOT ALLOW AN INITIALIZER OR ASMSPEC */
 
 myparm:
-     parm_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $1),
-                   chainon ($2, all_prefix_attributes)); }
-   | notype_declarator maybe_attribute
-       { $$ = build_tree_list (build_tree_list (current_declspecs,
-                            $1),
-                   chainon ($2, all_prefix_attributes)); }
+     parm_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $1),
+                     chainon ($3, all_prefix_attributes)),
+            $2); }
+   | notype_declarator maybeasm maybe_attribute
+       { $$ = build_tree_list (
+            build_tree_list (build_tree_list (current_declspecs, $1),
+                     chainon ($2, all_prefix_attributes)),
+            $2); }
    | absdcl_maybe_attribute
        { $$ = $1; }
    ;
+/* end-GG-local */ 



Regards

Reply via email to