This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH][m68k] Fix 'value out of range' error for jump table references


Hello, Andreas,

The below patch forbids use of addressing mode 7 (PC-relative indexed with offset) for jump table references on certain targets.

On ColdFire the offset in mode 7 must fit within 1 byte. If the jump table is big enough (i.e., case's in switch statement contain big chunks of code) the offset might overflow 127 bytes limit which will result in 'value out of range' error at assembly-time.

The fix is to use mode 7 for jump table references only for TARGET_68020 targets.

OK for trunk/4.2 ?

--
Maxim
2008-01-17  Maxim Kuvyrkov  <maxim@codesourcery.com>

	* config/m68k/m68k.c (m68k_decompose_address): Use mode 7 addressing
	for tablejump labels only for TARGET_68020.
Index: m68k.c
===================================================================
--- m68k.c	(revision 131450)
+++ m68k.c	(working copy)
@@ -1849,26 +1849,30 @@ m68k_decompose_address (enum machine_mod
       return true;
     }
 
-  /* Check for (d8,PC,Xn), a mode 7 form.  This case is needed for
-     tablejumps.
-
-     ??? do_tablejump creates these addresses before placing the target
-     label, so we have to assume that unplaced labels are jump table
-     references.  It seems unlikely that we would ever generate indexed
-     accesses to unplaced labels in other cases.  */
-  if (GET_CODE (x) == PLUS
-      && m68k_jump_table_ref_p (XEXP (x, 1))
-      && m68k_decompose_index (XEXP (x, 0), strict_p, address))
-    {
-      address->offset = XEXP (x, 1);
-      return true;
-    }
-
   /* Everything hereafter deals with (d8,An,Xn.SIZE*SCALE) or
      (bd,An,Xn.SIZE*SCALE) addresses.  */
 
   if (TARGET_68020)
     {
+      /* Check for (d8,PC,Xn), a mode 7 form.  This case is needed for
+	 tablejumps.
+
+	 ColdFire provides only 1 byte for address->offset in mode 7.
+	 As we can't be sure the jump table is small enough to fit within
+	 such offset, we allow such addresses only for TARGET_68020.
+
+	 ??? do_tablejump creates these addresses before placing the target
+	 label, so we have to assume that unplaced labels are jump table
+	 references.  It seems unlikely that we would ever generate indexed
+	 accesses to unplaced labels in other cases.  */
+      if (GET_CODE (x) == PLUS
+	  && m68k_jump_table_ref_p (XEXP (x, 1))
+	  && m68k_decompose_index (XEXP (x, 0), strict_p, address))
+	{
+	  address->offset = XEXP (x, 1);
+	  return true;
+	}
+
       /* Check for a nonzero base displacement.  */
       if (GET_CODE (x) == PLUS
 	  && m68k_legitimate_constant_address_p (XEXP (x, 1), reach, strict_p))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]