+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
 
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_epiphany, bfd_mach_epiphany32);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 valueT
 
 /* We don't need to handle .word strangely.  */
 #define WORKING_DOT_WORD
 
-#define LITERAL_PREFIXDOLLAR_HEX
 #define LITERAL_PREFIXPERCENT_BIN
 #define DOUBLESLASH_LINE_COMMENTS
 
 
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_ip2k, ip2k_mach);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 
 
 /* We don't need to handle .word strangely.  */
 #define WORKING_DOT_WORD
 
-#define LITERAL_PREFIXDOLLAR_HEX
 #define LITERAL_PREFIXPERCENT_BIN
 #define DOUBLESLASH_LINE_COMMENTS
 
 
 
   /* Set the machine type.  */
   bfd_default_set_arch_mach (stdoutput, bfd_arch_mt, mt_mach);
+
+  literal_prefix_dollar_hex = TRUE;
 }
 
 void
 
 /* 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
 
 #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
                        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);
       }
       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.  */
 
 extern symbolS *expr_build_dot (void);
 
 int resolve_expression (expressionS *);
+
+extern bfd_boolean literal_prefix_dollar_hex;