[binutils-gdb] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.

John Darrington jmd@sourceware.org
Tue May 21 08:29:00 GMT 2019


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e2d1595531b62487749e1af680d8f0c48c684feb

commit e2d1595531b62487749e1af680d8f0c48c684feb
Author: John Darrington <john@darrington.wattle.id.au>
Date:   Tue May 21 10:11:40 2019 +0200

    GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
    
    In an upcoming commit, I need to be able to set the prefix used
    to introduce hexadecimal literal constants using a command line
    flag.   This is not currently possible, because the switch which
    determines this (LITERAL_PREFIXDOLLAR_HEX) is a macro set at
    build time.
    
    This change substitutes it for a variable to be set at start up.
    
    gas/ChangeLog:
        * expr.c (literal_prefix_dollar_hex): New variable.
        (operand)[case '$']: Use the new variable instead of the old macro.
        Also, move this instance of "case '$'" next to the other one, and
        enable it only in the complementary proprocessor case.
        * expr.h (literal_prefix_dollar_hex): Declare it.
        * config/tc-epiphany.c (md_begin): Assign literal_prefix_dollar_hex.
        * config/tc-ip2k.c:      ditto
        * config/tc-mt.c:        ditto
        * config/tc-epiphany.h (LITERAL_PREFIXDOLLAR_HEX): Remove macro definition.
        * config/tc-ip2k.h:      ditto
        * config/tc-mt.h:        ditto

Diff:
---
 gas/ChangeLog            | 14 ++++++++++++++
 gas/config/tc-epiphany.c |  2 ++
 gas/config/tc-epiphany.h |  1 -
 gas/config/tc-ip2k.c     |  2 ++
 gas/config/tc-ip2k.h     |  1 -
 gas/config/tc-mt.c       |  2 ++
 gas/config/tc-mt.h       |  1 -
 gas/expr.c               | 27 +++++++++++++++++----------
 gas/expr.h               |  2 ++
 9 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 2230f44..fbfa00b 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,17 @@
+2019-05-21  John Darrington <john@darrington.wattle.id.au>
+
+	* expr.c (literal_prefix_dollar_hex): New variable.
+	(operand)[case '$']: Use the new variable instead of the old macro.
+	Also, move this instance of "case '$'" next to the other one, and
+	enable it only in the complementary proprocessor case.
+	* expr.h (literal_prefix_dollar_hex): Declare it.
+	* config/tc-epiphany.c (md_begin): Assign literal_prefix_dollar_hex.
+	* config/tc-ip2k.c:      ditto
+	* config/tc-mt.c:        ditto
+	* config/tc-epiphany.h (LITERAL_PREFIXDOLLAR_HEX): Remove macro definition.
+	* config/tc-ip2k.h:      ditto
+	* config/tc-mt.h:        ditto
+
 2019-05-20  Faraz Shahbazker  <fshahbazker@wavecomp.com>
 
 	PR 14798
diff --git a/gas/config/tc-epiphany.c b/gas/config/tc-epiphany.c
index ca24520..3117918 100644
--- a/gas/config/tc-epiphany.c
+++ b/gas/config/tc-epiphany.c
@@ -145,6 +145,8 @@ md_begin (void)
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_epiphany, bfd_mach_epiphany32);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 valueT
diff --git a/gas/config/tc-epiphany.h b/gas/config/tc-epiphany.h
index ace8f36..695b970 100644
--- a/gas/config/tc-epiphany.h
+++ b/gas/config/tc-epiphany.h
@@ -37,7 +37,6 @@
 /* We don't need to handle .word strangely.  */
 #define WORKING_DOT_WORD
 
-#define LITERAL_PREFIXDOLLAR_HEX
 #define LITERAL_PREFIXPERCENT_BIN
 #define DOUBLESLASH_LINE_COMMENTS
 
diff --git a/gas/config/tc-ip2k.c b/gas/config/tc-ip2k.c
index ab00b05..0fcc000 100644
--- a/gas/config/tc-ip2k.c
+++ b/gas/config/tc-ip2k.c
@@ -160,6 +160,8 @@ md_begin (void)
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_ip2k, ip2k_mach);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 
diff --git a/gas/config/tc-ip2k.h b/gas/config/tc-ip2k.h
index 0b38c9dc..ae9510d 100644
--- a/gas/config/tc-ip2k.h
+++ b/gas/config/tc-ip2k.h
@@ -38,7 +38,6 @@
 /* We don't need to handle .word strangely.  */
 #define WORKING_DOT_WORD
 
-#define LITERAL_PREFIXDOLLAR_HEX
 #define LITERAL_PREFIXPERCENT_BIN
 #define DOUBLESLASH_LINE_COMMENTS
 
diff --git a/gas/config/tc-mt.c b/gas/config/tc-mt.c
index b93a53e..bd51854 100644
--- a/gas/config/tc-mt.c
+++ b/gas/config/tc-mt.c
@@ -178,6 +178,8 @@ md_begin (void)
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_mt, mt_mach);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 void
diff --git a/gas/config/tc-mt.h b/gas/config/tc-mt.h
index 111dadd..8a96d2c 100644
--- a/gas/config/tc-mt.h
+++ b/gas/config/tc-mt.h
@@ -41,7 +41,6 @@
 /* All mt instructions are multiples of 32 bits.  */
 #define DWARF2_LINE_MIN_INSN_LENGTH 4
 
-#define LITERAL_PREFIXDOLLAR_HEX
 #define LITERAL_PREFIXPERCENT_BIN
 
 #define md_apply_fix mt_apply_fix
diff --git a/gas/expr.c b/gas/expr.c
index 3efde88..16c8934 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -35,6 +35,8 @@
 #define CHAR_BIT 8
 #endif
 
+bfd_boolean literal_prefix_dollar_hex = FALSE;
+
 static void floating_constant (expressionS * expressionP);
 static valueT generic_bignum_to_int32 (void);
 #ifdef BFD64
@@ -778,15 +780,6 @@ operand (expressionS *expressionP, enum expr_mode mode)
 			expressionP);
       break;
 
-#ifdef LITERAL_PREFIXDOLLAR_HEX
-    case '$':
-      /* $L is the start of a local label, not a hex constant.  */
-      if (* input_line_pointer == 'L')
-      goto isname;
-      integer_constant (16, expressionP);
-      break;
-#endif
-
 #ifdef LITERAL_PREFIXPERCENT_BIN
     case '%':
       integer_constant (2, expressionP);
@@ -1114,7 +1107,21 @@ operand (expressionS *expressionP, enum expr_mode mode)
       }
       break;
 
-#if defined (DOLLAR_DOT) || defined (TC_M68K)
+#if !defined (DOLLAR_DOT) && !defined (TC_M68K)
+    case '$':
+      if (literal_prefix_dollar_hex)
+	{
+	  /* $L is the start of a local label, not a hex constant.  */
+	  if (* input_line_pointer == 'L')
+		goto isname;
+	  integer_constant (16, expressionP);
+	}
+      else
+	{
+	  goto isname;
+	}
+      break;
+#else
     case '$':
       /* '$' is the program counter when in MRI mode, or when
 	 DOLLAR_DOT is defined.  */
diff --git a/gas/expr.h b/gas/expr.h
index a6cb5cf..c7d0681 100644
--- a/gas/expr.h
+++ b/gas/expr.h
@@ -187,3 +187,5 @@ extern symbolS *expr_build_uconstant (offsetT);
 extern symbolS *expr_build_dot (void);
 
 int resolve_expression (expressionS *);
+
+extern bfd_boolean literal_prefix_dollar_hex;



More information about the Binutils-cvs mailing list