patch: ".unreq" pseudo op for ARM

Pete Gonzalez gonz@ratloop.com
Wed Jul 30 21:35:00 GMT 2003


At 11:31 AM 7/30/2003, Nick Clifton wrote:
>Thanks very much for submitting this patch.  There are a couple of
>problems with it however:
>
>   * We need an FSF copyright assignment to be completed before it can
>     be accepted.  (Since the patch is adding a new feature, it cannot
>     be consider to be trivial).

Sure, how do I proceed with this?  Is there a form I should fill out
and sign?  Do I fax it somewhere or just e-mail it?

>   * A patch should always be accompanied by a ChangeLog entry.  Also
>     in the case of a patch that adds a new feature the documentation
>     should be updated as well.  In this the documentation is the file
>     gas/doc/c-arm.texi and the news file gas/NEWS.
>
>   * The code in the patch should follow the GNU Coding Standard.

Attached is an updated patch with the requested changes.  BTW if
there is a document somewhere detailing the coding conventions,
"diff" parameters, and other basic tips for submitting patches to
a GNU project, please send me the link.

Thanks,
-Pete


________________


--- gas/config/tc-arm.c.orig    2003-07-23 14:30:39.000000000 -0500
+++ gas/config/tc-arm.c 2003-07-30 17:30:26.000000000 -0500
@@ -591,7 +591,8 @@
  #define wc_register(reg)  ((reg ^ WC_PREFIX) >= 0 && (reg ^ WC_PREFIX) <= 15)
  #define wcg_register(reg) ((reg ^ WC_PREFIX) >= 8 && (reg ^ WC_PREFIX) <= 11)

-/* These are the standard names.  Users can add aliases with .req.  */
+/* These are the standard names.  */
+/* Users can add aliases with .req and delete them with .unreq.  */
  /* Integer Register Numbers.  */
  static const struct reg_entry rn_table[] =
  {
@@ -2324,6 +2325,7 @@
       Integer arg to pass to the function.  */

  static void s_req PARAMS ((int));
+static void s_unreq PARAMS ((int));
  static void s_align PARAMS ((int));
  static void s_bss PARAMS ((int));
  static void s_even PARAMS ((int));
@@ -2342,8 +2344,9 @@

  const pseudo_typeS md_pseudo_table[] =
  {
-  /* Never called becasue '.req' does not start line.  */
+  /* Never called because '.req' does not start line.  */
    { "req",         s_req,         0 },
+  { "unreq",       s_unreq,       0 },
    { "bss",         s_bss,         0 },
    { "align",       s_align,       0 },
    { "arm",         s_arm,         0 },
@@ -2647,6 +2650,63 @@
    as_bad (_("invalid syntax for .req directive"));
  }

+/* The .unreq directive deletes an alias which was previously defined
+   by .req.  For example:
+
+       my_alias .req r11
+       .unreq my_alias
+*/
+static void
+s_unreq (a)
+     int a ATTRIBUTE_UNUSED;
+{
+  char *name;
+  char saved_char;
+
+  skip_whitespace(input_line_pointer);
+  name = input_line_pointer;
+
+  while (*input_line_pointer != 0
+    && *input_line_pointer != ' '
+    && *input_line_pointer != '\n')
+    ++input_line_pointer;
+
+  saved_char = *input_line_pointer;
+  *input_line_pointer = 0;
+
+  if (*name)
+    {
+      enum arm_reg_type req_type = arm_reg_parse_any(name);
+
+      if (req_type != REG_TYPE_MAX)
+       {
+         char *temp_name = name;
+         int req_no = arm_reg_parse(&temp_name, all_reg_maps[req_type].htab);
+         if (req_no != FAIL)
+           {
+             struct reg_entry *req_entry;
+             req_entry = hash_delete (all_reg_maps[req_type].htab, name);
+             if (!req_entry)
+               as_bad (_("unreq: missing hash entry for \"%s\""), name);
+             else
+               {
+                 free((PTR)req_entry->name);
+                 free(req_entry);
+               }
+           }
+          else
+            as_bad (_(".unreq: unrecognized symbol \"%s\""), name);
+       }
+      else
+        as_bad (_(".unreq: unrecognized symbol \"%s\""), name);
+    }
+  else
+    as_bad (_("invalid syntax for .unreq directive"));
+
+  *input_line_pointer = saved_char;
+  demand_empty_rest_of_line ();
+}
+
  static void
  s_bss (ignore)
       int ignore ATTRIBUTE_UNUSED;
--- gas/doc/c-arm.texi.orig     2003-07-30 17:12:30.000000000 -0500
+++ gas/doc/c-arm.texi  2003-07-30 17:16:45.000000000 -0500
@@ -303,6 +303,18 @@
          foo .req r0
  @end smallexample

+@cindex @code{unreq} directive, ARM
+@item .unreq @var{name}
+This undefines an alias which was previously defined using the
+@code{req} directive.  For example:
+
+@smallexample
+        foo .req r0
+        .unreq r0
+@end smallexample
+
+An error occurs if the name is undefined.
+
  @cindex @code{code} directive, ARM
  @item .code @code{[16|32]}
  This directive selects the instruction set being generated. The value 16
--- gas/NEWS.orig       2003-07-30 17:31:55.000000000 -0500
+++ gas/NEWS    2003-07-30 17:22:53.000000000 -0500
@@ -1,5 +1,8 @@
  -*- text -*-

+* On ARM architectures, added a new gas directive ".unreq" that undoes
+  definitions created by ".req"
+
  * Added -n switch for x86 assembler.  By default, x86 GAS replaces
    multiple nop instructions used for alignment within code sections
    with multi-byte nop instructions such as leal 0(%esi,1),%esi.  This




More information about the Binutils mailing list