gas/
authorJan Beulich <jbeulich@novell.com>
Wed, 26 Sep 2007 08:34:24 +0000 (08:34 +0000)
committerJan Beulich <jbeulich@novell.com>
Wed, 26 Sep 2007 08:34:24 +0000 (08:34 +0000)
2007-09-26  Jan Beulich  <jbeulich@novell.com>

* config/tc-i386.h (md_register_arithmetic): Define.
* config/tc-ia64.h (md_register_arithmetic): Likewise.
* doc/internals.texi: Document md_register_arithmetic.
* expr.c (make_expr_symbol): Force O_register expressions into
reg_section.
(expr): Provide default for md_register_arithmetic. Don't resolve
adding/subtracting constants to/from registers if
md_register_arithmetic is zero.

gas/ChangeLog
gas/config/tc-i386.h
gas/config/tc-ia64.h
gas/doc/internals.texi
gas/expr.c

index 6a9bb5402329d5e03ba430eab2c53ab4593e93fc..9cf0f71d323e5addc8156d368efbb7f23e76626e 100644 (file)
@@ -1,3 +1,14 @@
+2007-09-26  Jan Beulich  <jbeulich@novell.com>
+
+       * config/tc-i386.h (md_register_arithmetic): Define.
+       * config/tc-ia64.h (md_register_arithmetic): Likewise.
+       * doc/internals.texi: Document md_register_arithmetic.
+       * expr.c (make_expr_symbol): Force O_register expressions into
+       reg_section.
+       (expr): Provide default for md_register_arithmetic. Don't resolve
+       adding/subtracting constants to/from registers if
+       md_register_arithmetic is zero.
+
 2007-09-26  Jan Beulich  <jbeulich@novell.com>
 
        * dw2gencfi.c: Conditionalize whole body upon TARGET_USE_CFIPOP.
index e55d5cad5ec58069c756c5320f155402c8e2e209..65e300a4f771a6e1f81f60ca132f9264e2dd5bfd 100644 (file)
@@ -272,6 +272,8 @@ extern int tc_i386_fix_adjustable (struct fix *);
 extern int i386_parse_name (char *, expressionS *, char *);
 #define md_parse_name(s, e, m, c) i386_parse_name (s, e, c)
 
+#define md_register_arithmetic 0
+
 extern const struct relax_type md_relax_table[];
 #define TC_GENERIC_RELAX_TABLE md_relax_table
 
index 725e6eaa44c36c3a629991841ad7c43d8d4298c1..d0b0b1b09ff787bf2061a3a07ca8492e2f767699 100644 (file)
@@ -130,6 +130,7 @@ extern void ia64_convert_frag (fragS *);
 #endif /* TE_HPUX */
 #define md_flush_pending_output()      ia64_flush_pending_output ()
 #define md_parse_name(s,e,m,c)         ia64_parse_name (s, e, c)
+#define md_register_arithmetic         0
 #define tc_canonicalize_symbol_name(s) ia64_canonicalize_symbol_name (s)
 #define tc_canonicalize_section_name(s)        ia64_canonicalize_symbol_name (s)
 #define md_optimize_expr(l,o,r)                ia64_optimize_expr (l, o, r)
index c63a2dbd7705ccbef6581a729c293eb1e2e1e673..a97ead386c58cc01a9a6e47f34d0425df341171e 100644 (file)
@@ -1045,6 +1045,16 @@ pointer, for any expression that can not be recognized.  When the function
 is called, @code{input_line_pointer} will point to the start of the
 expression.
 
+@item md_register_arithmetic
+@cindex md_register_arithmetic
+If this macro is defined and evaluates to zero then GAS will not fold
+expressions that add or subtract a constant to/from a register to give
+another register.  For example GAS's default behaviour is to fold the
+expression "r8 + 1" into "r9", which is probably not the result
+intended by the programmer.  The default is to allow such folding,
+since this maintains backwards compatibility with earlier releases of
+GAS.
+
 @item tc_unrecognized_line
 @cindex tc_unrecognized_line
 If you define this macro, GAS will call it when it finds a line that it can not
index b88328502eebdddbd2250ebdb38c628dcbebb024..4f4d380ff915b0a3f52fa266366dfbcbad0c5bef 100644 (file)
@@ -95,7 +95,9 @@ make_expr_symbol (expressionS *expressionP)
   symbolP = symbol_create (FAKE_LABEL_NAME,
                           (expressionP->X_op == O_constant
                            ? absolute_section
-                           : expr_section),
+                           : expressionP->X_op == O_register
+                             ? reg_section
+                             : expr_section),
                           0, &zero_address_frag);
   symbol_set_value_expression (symbolP, expressionP);
 
@@ -1722,7 +1724,11 @@ expr (int rankarg,               /* Larger # is higher rank.  */
        }
       else
 #endif
-      if (op_left == O_add && right.X_op == O_constant)
+#ifndef md_register_arithmetic
+# define md_register_arithmetic 1
+#endif
+      if (op_left == O_add && right.X_op == O_constant
+         && (md_register_arithmetic || resultP->X_op != O_register))
        {
          /* X + constant.  */
          resultP->X_add_number += right.X_add_number;
@@ -1745,12 +1751,14 @@ expr (int rankarg,              /* Larger # is higher rank.  */
          resultP->X_op = O_constant;
          resultP->X_add_symbol = 0;
        }
-      else if (op_left == O_subtract && right.X_op == O_constant)
+      else if (op_left == O_subtract && right.X_op == O_constant
+              && (md_register_arithmetic || resultP->X_op != O_register))
        {
          /* X - constant.  */
          resultP->X_add_number -= right.X_add_number;
        }
-      else if (op_left == O_add && resultP->X_op == O_constant)
+      else if (op_left == O_add && resultP->X_op == O_constant
+              && (md_register_arithmetic || right.X_op != O_register))
        {
          /* Constant + X.  */
          resultP->X_op = right.X_op;