This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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: [SH]: prepending $ to register names


Hi Nick

As you suggested. This patch adds a command line option -enable-reg-prefix to SH target options and is disabled by default.

Is this patch acceptable?

Thanks

Khem

gas/ChangeLog

2005-10-04  Khem Raj  <kraj@mvista.com>
                           NIIBE Yutaka  <gniibe@m17n.org>

* config/tc-sh.c (use_dollar_register_prefix): New variable.
(parse_reg_without_prefix):New function.
(parse_reg): Check for '$' register prefix if -enable-reg-prefix is set.
(option md_longopts): Add enable-reg-prefix option.
* doc/c-sh.texi: Document -enable-reg-prefix option.
* testsuite/gas/sh/basic.exp: Run reg-prefix test.
* testsuite/gas/sh/reg-prefix.s: New
* testsuite/gas/sh/reg-prefix.d: New


Nick Clifton wrote:
Hi Khem,

I have a question regrading SH assembly. Is it required to have '$' prepended to register names?.

At the moment: "No".


There was some discussion about it in the following URL.
http://sourceforge.net/mailarchive/forum.php?forum_id=5348&max_rows=25&style=nested&viewmonth=200011 but the patch posted there is not applied in binutils

I would be prepared to accept a variant of that patch whereby requiring a "$" register prefix was controlled by a GAS command line switch, (which defaults to off). That way the current behaviour can be preserved, but the more useful behaviour (of requiring the prefix) can be enabled if the user so desires.


Cheers
  Nick



-- Khem Raj <kraj@mvista.com> MontaVista Software, Inc. www.mvista.com

Index: gas/config/tc-sh.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-sh.c,v
retrieving revision 1.112
diff -u -u -r1.112 tc-sh.c
--- gas/config/tc-sh.c	20 Sep 2005 18:24:48 -0000	1.112
+++ gas/config/tc-sh.c	4 Oct 2005 09:11:41 -0000
@@ -134,6 +134,10 @@
 
 static int dont_adjust_reloc_32;
 
+/* Flag to indicate that '$' is used as register prefix.  */
+
+static int use_dollar_register_prefix;
+
 /* preset architecture set, if given; zero otherwise.  */
 
 static unsigned int preset_target_arch;
@@ -870,7 +874,7 @@
 /* Try to parse a reg name.  Return the number of chars consumed.  */
 
 static int
-parse_reg (char *src, int *mode, int *reg)
+parse_reg_without_prefix (char *src, int *mode, int *reg)
 {
   char l0 = TOLOWER (src[0]);
   char l1 = l0 ? TOLOWER (src[1]) : 0;
@@ -1225,6 +1229,19 @@
   return 0;
 }
 
+static int
+parse_reg (char *src, int *mode, int *reg)
+{
+  int prefix = 0;
+  if (use_dollar_register_prefix && src[0] == '$')
+    {
+      src++;
+      prefix = 1;
+    }
+
+  return prefix + parse_reg_without_prefix (src, mode, reg);
+}
+
 static char *
 parse_exp (char *s, sh_operand_info *op)
 {
@@ -3015,6 +3032,7 @@
 #define OPTION_DSP (OPTION_SMALL + 1)
 #define OPTION_ISA                    (OPTION_DSP + 1)
 #define OPTION_RENESAS (OPTION_ISA + 1)
+#define OPTION_REG_PREFIX (OPTION_RENESAS + 1)
 
   {"relax", no_argument, NULL, OPTION_RELAX},
   {"big", no_argument, NULL, OPTION_BIG},
@@ -3023,9 +3041,10 @@
   {"dsp", no_argument, NULL, OPTION_DSP},
   {"isa",                    required_argument, NULL, OPTION_ISA},
   {"renesas", no_argument, NULL, OPTION_RENESAS},
+  {"enable-reg-prefix", no_argument, NULL, OPTION_REG_PREFIX},
 
 #ifdef HAVE_SH64
-#define OPTION_ABI                    (OPTION_RENESAS + 1)
+#define OPTION_ABI                    (OPTION_REG_PREFIX + 1)
 #define OPTION_NO_MIX                 (OPTION_ABI + 1)
 #define OPTION_SHCOMPACT_CONST_CRANGE (OPTION_NO_MIX + 1)
 #define OPTION_NO_EXPAND              (OPTION_SHCOMPACT_CONST_CRANGE + 1)
@@ -3069,7 +3088,9 @@
     case OPTION_RENESAS:
       dont_adjust_reloc_32 = 1;
       break;
-
+    case OPTION_REG_PREFIX:
+      use_dollar_register_prefix = 1;
+      break;
     case OPTION_ISA:
       if (strcasecmp (arg, "dsp") == 0)
 	preset_target_arch = arch_sh_up & ~(arch_sh_sp_fpu|arch_sh_dp_fpu);
@@ -3180,6 +3201,7 @@
 			compatibility with Renesas assembler.\n\
 -small			align sections to 4 byte boundaries, not 16\n\
 -dsp			enable sh-dsp insns, and disable floating-point ISAs.\n\
+-enable-reg-prefix      use '$' as register prefix.\n\
 -isa=[any		use most appropriate isa\n\
     | dsp               same as '-dsp'\n\
     | fp"));
Index: gas/doc/c-sh.texi
===================================================================
RCS file: /cvs/src/src/gas/doc/c-sh.texi,v
retrieving revision 1.9
diff -u -u -r1.9 c-sh.texi
--- gas/doc/c-sh.texi	3 Mar 2005 01:29:54 -0000	1.9
+++ gas/doc/c-sh.texi	4 Oct 2005 09:11:41 -0000
@@ -30,6 +30,7 @@
 @kindex -small
 @kindex -dsp
 @kindex -renesas
+@kindex -enable-reg-prefix
 
 @item -little
 Generate little endian code.
@@ -50,6 +51,9 @@
 Disable optimization with section symbol for compatibility with
 Renesas assembler.
 
+@item -enable-reg-prefix
+Use '$' as register prefix.
+
 @item -isa=sh4 | sh4a
 Specify the sh4 or sh4a instruction set.
 @item -isa=dsp
Index: gas/testsuite/gas/sh/basic.exp
===================================================================
RCS file: /cvs/src/src/gas/testsuite/gas/sh/basic.exp,v
retrieving revision 1.21
diff -u -u -r1.21 basic.exp
--- gas/testsuite/gas/sh/basic.exp	5 May 2005 10:29:16 -0000	1.21
+++ gas/testsuite/gas/sh/basic.exp	4 Oct 2005 09:11:41 -0000
@@ -164,6 +164,9 @@
 
 	# Test -renesas.
 	run_dump_test "renesas-1"
+
+	# Test -enable-reg-prefix.
+	run_dump_test "reg-prefix"
     }
 }
 
--- dev/null	1969-12-31 16:00:00.000000000 -0800
+++ gas/testsuite/gas/sh/reg-prefix.s	2005-10-03 23:00:00.000000000 -0700
@@ -0,0 +1,2 @@
+         .text
+          movli.l @r1,$r0
--- dev/null	1969-12-31 16:00:00.000000000 -0800
+++ gas/testsuite/gas/sh/reg-prefix.d	2005-10-04 01:49:12.000000000 -0700
@@ -0,0 +1,9 @@
+#objdump: -dr --prefix-addresses --show-raw-insn
+#as: -enable-reg-prefix
+#name: SH -enable-reg-prefix option
+# Test SH register names prefixed with $:
+
+.*:     file format elf.*sh.*
+
+Disassembly of section .text:
+0x00000000 01 63       	movli.l	@r1,r0


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