public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
@ 2019-05-16 10:18 John Darrington
  2019-05-20 15:40 ` Nick Clifton
  2019-05-21  1:07 ` Alan Modra
  0 siblings, 2 replies; 6+ messages in thread
From: John Darrington @ 2019-05-16 10:18 UTC (permalink / raw)
  To: binutils; +Cc: John Darrington

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 |  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               | 19 +++++++++++++------
 gas/expr.h               |  2 ++
 8 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/gas/config/tc-epiphany.c b/gas/config/tc-epiphany.c
index ca24520ffe..2e56452145 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 = 1;
 }
 
 valueT
diff --git a/gas/config/tc-epiphany.h b/gas/config/tc-epiphany.h
index ace8f3667b..695b970ca2 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 ab00b05235..fc0b0ce873 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 = 1;
 }
 
 
diff --git a/gas/config/tc-ip2k.h b/gas/config/tc-ip2k.h
index 0b38c9dcf2..ae9510d9e1 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 b93a53eb4b..f4f43cee22 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 = 1;
 }
 
 void
diff --git a/gas/config/tc-mt.h b/gas/config/tc-mt.h
index 111dadd1c6..8a96d2c84f 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 3efde88cc0..fa59ae3aa8 100644
--- a/gas/expr.c
+++ b/gas/expr.c
@@ -35,6 +35,8 @@
 #define CHAR_BIT 8
 #endif
 
+int literal_prefix_dollar_hex = 0;
+
 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 '%':
diff --git a/gas/expr.h b/gas/expr.h
index a6cb5cf364..6e75144bcb 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 int literal_prefix_dollar_hex;
-- 
2.17.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
  2019-05-16 10:18 [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value John Darrington
@ 2019-05-20 15:40 ` Nick Clifton
  2019-05-21  1:07 ` Alan Modra
  1 sibling, 0 replies; 6+ messages in thread
From: Nick Clifton @ 2019-05-20 15:40 UTC (permalink / raw)
  To: John Darrington, binutils

Hi John,

> +  literal_prefix_dollar_hex = 1;

I am tempted to suggest that this variable should be called "literal_hex_prefix"
and contain a string, or possibly just a character that should be interpreted
as being a prefix for hex strings.  But this is probably over complicating things,
so instead...

> +int literal_prefix_dollar_hex = 0;

... since this is a boolean variable, its type should be bfd_boolean and it should
be initialised to FALSE.

Patch approved with that change made (and the other places where it is set to 1 
replaced with TRUE, obviously).

Cheers
  Nick


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
  2019-05-16 10:18 [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value John Darrington
  2019-05-20 15:40 ` Nick Clifton
@ 2019-05-21  1:07 ` Alan Modra
  2019-05-21  1:35   ` Alan Modra
  2019-05-21  5:33   ` John Darrington
  1 sibling, 2 replies; 6+ messages in thread
From: Alan Modra @ 2019-05-21  1:07 UTC (permalink / raw)
  To: John Darrington; +Cc: binutils

This patch caused build failures on m68hc11, m68hc12 and m68k.
Please fix.  You also forgot to commit an entry in gas/ChangeLog.

/home/alan/src/binutils-gdb/gas/expr.c: In function ‘operand’:
/home/alan/src/binutils-gdb/gas/expr.c:1125:5: error: duplicate case value
 1125 |     case '$':
      |     ^~~~
/home/alan/src/binutils-gdb/gas/expr.c:783:5: note: previously used here
  783 |     case '$':
      |     ^~~~
Makefile:1224: recipe for target 'expr.o' failed

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
  2019-05-21  1:07 ` Alan Modra
@ 2019-05-21  1:35   ` Alan Modra
  2019-05-21  8:34     ` John Darrington
  2019-05-21  5:33   ` John Darrington
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Modra @ 2019-05-21  1:35 UTC (permalink / raw)
  To: John Darrington; +Cc: binutils

On Tue, May 21, 2019 at 10:37:10AM +0930, Alan Modra wrote:
> This patch caused build failures on m68hc11, m68hc12 and m68k.
and powerpc*, rs6000*, tic54x-coff, tic4x-coff, xgate-elf, z80-coff.

Note also that binutils sources use tabs to indent at beginning of
lines.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
  2019-05-21  1:07 ` Alan Modra
  2019-05-21  1:35   ` Alan Modra
@ 2019-05-21  5:33   ` John Darrington
  1 sibling, 0 replies; 6+ messages in thread
From: John Darrington @ 2019-05-21  5:33 UTC (permalink / raw)
  To: Alan Modra; +Cc: John Darrington, binutils

On Tue, May 21, 2019 at 10:37:11AM +0930, Alan Modra wrote:
     This patch caused build failures on m68hc11, m68hc12 and m68k.
     Please fix.

Sorry about that.  I've reverted the patch and I'll post a fixed one
after checking that it works on those targets.

J'

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value.
  2019-05-21  1:35   ` Alan Modra
@ 2019-05-21  8:34     ` John Darrington
  0 siblings, 0 replies; 6+ messages in thread
From: John Darrington @ 2019-05-21  8:34 UTC (permalink / raw)
  To: Alan Modra; +Cc: John Darrington, binutils

I have pushed an updated patch after checking that it passes "make check"
on a number of those targets.

If you (or anyone else) finds that this continues to cause problems, then
please feel free to revert.

On Tue, May 21, 2019 at 11:05:25AM +0930, Alan Modra wrote:
     On Tue, May 21, 2019 at 10:37:10AM +0930, Alan Modra wrote:
     > This patch caused build failures on m68hc11, m68hc12 and m68k.
     and powerpc*, rs6000*, tic54x-coff, tic4x-coff, xgate-elf, z80-coff.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-21  8:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-16 10:18 [PATCH] GAS: Replace macro LITERAL_PREFIXDOLLAR_HEX with a runtime value John Darrington
2019-05-20 15:40 ` Nick Clifton
2019-05-21  1:07 ` Alan Modra
2019-05-21  1:35   ` Alan Modra
2019-05-21  8:34     ` John Darrington
2019-05-21  5:33   ` John Darrington

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).