GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 20 May 2019 17:53:30 +0000 (19:53 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 20 May 2019 17:54:31 +0000 (19:54 +0200)
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.
* 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

gas/config/tc-epiphany.c
gas/config/tc-epiphany.h
gas/config/tc-ip2k.c
gas/config/tc-ip2k.h
gas/config/tc-mt.c
gas/config/tc-mt.h
gas/expr.c
gas/expr.h

index ca24520..3117918 100644 (file)
@@ -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
index ace8f36..695b970 100644 (file)
@@ -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
 
index ab00b05..0fcc000 100644 (file)
@@ -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;
 }
 
 
index 0b38c9d..ae9510d 100644 (file)
@@ -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
 
index b93a53e..bd51854 100644 (file)
@@ -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
index 111dadd..8a96d2c 100644 (file)
@@ -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
index 3efde88..0fab955 100644 (file)
@@ -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,14 +780,19 @@ 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);
+      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;
-#endif
 
 #ifdef LITERAL_PREFIXPERCENT_BIN
     case '%':
index a6cb5cf..c7d0681 100644 (file)
@@ -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;