avr.c (print_operand): Support code = 'i' for CONST_INT.
authorGeorg-Johann Lay <avr@gjlay.de>
Fri, 25 Nov 2011 15:00:39 +0000 (15:00 +0000)
committerGeorg-Johann Lay <gjl@gcc.gnu.org>
Fri, 25 Nov 2011 15:00:39 +0000 (15:00 +0000)
* config/avr/avr.c (print_operand): Support code = 'i' for CONST_INT.

From-SVN: r181722

gcc/ChangeLog
gcc/config/avr/avr.c
gcc/config/avr/avr.md

index a77cf2e3c06e37c7851f94df5f1d6281d59d4488..fc0394d4a36c0f6b0cb410b8c7f117edcb3a4bd5 100644 (file)
@@ -1,3 +1,7 @@
+2011-11-25  Georg-Johann Lay  <avr@gjlay.de>
+
+       * config/avr/avr.c (print_operand): Support code = 'i' for CONST_INT.
+
 2011-11-24  Andrew MacLeod  <amacleod@redhat.com>
 
        PR other/51011
index 543bb9c56c154d1b9b0c3da22e20a575cb54ffa1..9fd8b8ef935031a8c433d60ab0176125ba488ca6 100644 (file)
@@ -1822,9 +1822,32 @@ print_operand (FILE *file, rtx x, int code)
       else
        fprintf (file, reg_names[true_regnum (x) + abcd]);
     }
-  else if (GET_CODE (x) == CONST_INT)
-    fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (x) + abcd);
-  else if (GET_CODE (x) == MEM)
+  else if (CONST_INT_P (x))
+    {
+      HOST_WIDE_INT ival = INTVAL (x);
+        
+      if ('i' != code)
+        fprintf (file, HOST_WIDE_INT_PRINT_DEC, ival + abcd);
+      else if (low_io_address_operand (x, VOIDmode)
+               || high_io_address_operand (x, VOIDmode))
+        {
+          switch (ival)
+            {
+            case RAMPZ_ADDR: fprintf (file, "__RAMPZ__"); break;
+            case SREG_ADDR: fprintf (file, "__SREG__"); break;
+            case SP_ADDR:   fprintf (file, "__SP_L__"); break;
+            case SP_ADDR+1: fprintf (file, "__SP_H__"); break;
+              
+            default:
+              fprintf (file, HOST_WIDE_INT_PRINT_HEX,
+                       ival - avr_current_arch->sfr_offset);
+              break;
+            }
+        }
+      else
+        fatal_insn ("bad address, not an I/O address:", x);
+    }
+  else if (MEM_P (x))
     {
       rtx addr = XEXP (x, 0);
       
@@ -1844,21 +1867,7 @@ print_operand (FILE *file, rtx x, int code)
        }
       else if (code == 'i')
         {
-          if (!io_address_operand (addr, GET_MODE (x)))
-            fatal_insn ("bad address, not an I/O address:", addr);
-          
-          switch (INTVAL (addr))
-            {
-            case RAMPZ_ADDR: fprintf (file, "__RAMPZ__"); break;
-            case SREG_ADDR: fprintf (file, "__SREG__"); break;
-            case SP_ADDR:   fprintf (file, "__SP_L__"); break;
-            case SP_ADDR+1: fprintf (file, "__SP_H__"); break;
-              
-            default:
-              fprintf (file, HOST_WIDE_INT_PRINT_HEX,
-                       UINTVAL (addr) - avr_current_arch->sfr_offset);
-              break;
-            }
+          print_operand (file, addr, 'i');
         }
       else if (code == 'o')
        {
@@ -1889,6 +1898,10 @@ print_operand (FILE *file, rtx x, int code)
       else
        print_operand_address (file, addr);
     }
+  else if (code == 'i')
+    {
+      fatal_insn ("bad address, not an I/O address:", x);
+    }
   else if (code == 'x')
     {
       /* Constant progmem address - like used in jmp or call */
index f19e6f9b0487655ed818aae0901a335212e6ee57..d59488ea1b51d256f786a0f2b495042d3003c844 100644 (file)
@@ -28,8 +28,8 @@
 ;;  j  Branch condition.
 ;;  k  Reverse branch condition.
 ;;..m..Constant Direct Data memory address.
-;;  i  Print the SFR address quivalent of a CONST_INT RAM address.
-;;     The resulting addres is suitable to be used in IN/OUT.
+;;  i  Print the SFR address quivalent of a CONST_INT or a CONST_INT
+;;     RAM address.  The resulting addres is suitable to be used in IN/OUT.
 ;;  o  Displacement for (mem (plus (reg) (const_int))) operands.
 ;;  p  POST_INC or PRE_DEC address as a pointer (X, Y, Z)
 ;;  r  POST_INC or PRE_DEC address as a register (r26, r28, r30)