This is the mail archive of the gcc-bugs@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]

gcc-3.0.2 bug in jump from dispatch table in ColdFire.



The 'extl' instruction can not extend an address register in the
ColdFire architecture.  This instruction is used in the pattern to
jump to a variable address from a dispatch table of relative
addreses. 

To fix this, I created another pattern using "d" as a constraint, and
"TARGET_5200" as a condition, as well as put "!TARGET_5200" in the
condition of the oritinal instruction pattern. I also removed the
TARGET_5200 conditionals from the output template of each instruction
pattern since the RTL condition selects if its TARGET_5200 or not. 

Here's a diff -Nru:

- --- /home/gcc/org/gcc-3.0.2/gcc/config/m68k/m68k.md	Tue Jul 31 02:18:33 2001
+++ /home/gcc/new/gcc-3.0.2/gcc/config/m68k/m68k.md	Wed Nov  7 09:39:48 2001
@@ -6501,58 +6501,68 @@
 ")
 
 ;; Jump to variable address from dispatch table of relative addresses.
+
+;; On ColdFire, the 'extl' instruction can only extend data registers.
+;; To get around this, create a new pattern for the 5200 that has "d"
+;; for the register constraint instead of "r", and prevent the
+;; original pattern from being used on ColdFire.
 (define_insn ""
   [(set (pc)
 	(plus:SI (pc)
 		 (sign_extend:SI (match_operand:HI 0 "register_operand" "r"))))
    (use (label_ref (match_operand 1 "" "")))]
- -  ""
+  "!TARGET_5200"
   "*
 #ifdef ASM_RETURN_CASE_JUMP
  ASM_RETURN_CASE_JUMP;
 #else
- -#ifdef SGS
- -#ifdef ASM_OUTPUT_CASE_LABEL
- -  if (TARGET_5200) 
- -    return \"ext%.l %0\;jmp 6(%%pc,%0.l)\";
- -  else
+# ifdef SGS
+#  ifdef ASM_OUTPUT_CASE_LABEL
     return \"jmp 6(%%pc,%0.w)\";
- -#else
- -  if (TARGET_5200)
- -    {
- -#ifdef CRDS
- -      return \"ext%.l %0\;jmp 2(pc,%0.l)\";
- -#else
- -      return \"extl %0\;jmp 2(%%pc,%0.l)\";
- -#endif  /* end !CRDS */
- -    }
- -  else
- -    {
- -#ifdef CRDS
+#  else
+#   ifdef CRDS
       return \"jmp 2(pc,%0.w)\";
- -#else
+#   else
       return \"jmp 2(%%pc,%0.w)\";
- -#endif  /* end !CRDS */
- -    }
- -#endif
- -#else /* not SGS */
- -  if (TARGET_5200)
- -    {
- -#ifdef MOTOROLA
- -      return \"ext%.l %0\;jmp (2,pc,%0.l)\";
- -#else
- -      return \"extl %0\;jmp pc@(2,%0:l)\";
- -#endif
- -    }
- -  else
- -    {
- -#ifdef MOTOROLA
+#   endif  /* end !CRDS */
+#  endif
+# else /* not SGS */
+#  ifdef MOTOROLA
       return \"jmp (2,pc,%0.w)\";
- -#else
+#  else
       return \"jmp pc@(2,%0:w)\";
+#  endif
+# endif
 #endif
- -    }
- -#endif
+")
+
+(define_insn ""
+  [(set (pc)
+	(plus:SI (pc)
+		 (sign_extend:SI (match_operand:HI 0 "register_operand" "d"))))
+   (use (label_ref (match_operand 1 "" "")))]
+  "TARGET_5200"
+  "*
+#ifdef ASM_RETURN_CASE_JUMP
+ ASM_RETURN_CASE_JUMP;
+#else
+# ifdef SGS
+#  ifdef ASM_OUTPUT_CASE_LABEL
+    return \"ext%.l %0\;jmp 6(%%pc,%0.l)\";
+#  else
+#   ifdef CRDS
+      return \"ext%.l %0\;jmp 2(pc,%0.l)\";
+#   else
+      return \"extl %0\;jmp 2(%%pc,%0.l)\";
+#   endif  /* end !CRDS */
+#  endif
+# else /* not SGS */
+#  ifdef MOTOROLA
+      return \"ext%.l %0\;jmp (2,pc,%0.l)\";
+#  else
+      return \"extl %0\;jmp pc@(2,%0:l)\";
+#  endif
+# endif
 #endif
 ")

- -- 
Peter Barada                                   Peter.Barada@motorola.com
Wizard                                         781-852-2768 (direct)
WaveMark Solutions(wholly owned by Motorola)   781-270-0193 (fax)


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