#! /bin/sh -e
# DP: Add two m68k specfic patches backported from 4.0 concerning wrong code
# DP: generation (Richard Zidlicky).
dir=
if [ $# -eq 3 -a "$2" = '-d' ]; then
pdir="-d $3"
dir="$3/"
elif [ $# -ne 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
case "$1" in
-patch)
patch $pdir -f --no-backup-if-mismatch -p0 < $0
;;
-unpatch)
patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
esac
exit 0
--- gcc/config/m68k/m68k.md.rz 2005-03-05 12:14:41.038411000 +0100
+++ gcc/config/m68k/m68k.md 2005-03-05 12:15:19.580856855 +0100
@@ -1454,11 +1454,20 @@
""
{
CC_STATUS_INIT;
- operands[2] = gen_rtx_REG (SImode, REGNO (operands[0]) + 1);
- if (TARGET_68020 || TARGET_COLDFIRE)
- return "move%.b %1,%2\;extb%.l %2\;smi %0\;extb%.l %0";
+ if (ADDRESS_REG_P(operands[1]))
+ {
+ if (TARGET_68020 || TARGET_COLDFIRE)
+ return "move%.w %1,%R0\;extb%.l %R0\;smi %0\;extb%.l %0";
+ else
+ return "move%.w %1,%R0\;ext%.w %R0\;ext%.l %R0\;move%.l %R0,%0\;smi %0";
+ }
else
- return "move%.b %1,%2\;ext%.w %0\;ext%.l %2\;move%.l %2,%0\;smi %0";
+ {
+ if (TARGET_68020 || TARGET_COLDFIRE)
+ return "move%.b %1,%R0\;extb%.l %R0\;smi %0\;extb%.l %0";
+ else
+ return "move%.b %1,%R0\;ext%.w %R0\;ext%.l %R0\;move%.l %R0,%0\;smi %0";
+ }
})
(define_insn "extendhidi2"
@@ -4834,8 +4843,8 @@
(define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extract:SI (match_operand:QI 1 "memory_operand" "o")
- (match_operand:SI 2 "general_operand" "di")
- (match_operand:SI 3 "general_operand" "di")))]
+ (match_operand:SI 2 "general_operand" "dn")
+ (match_operand:SI 3 "general_operand" "dn")))]
"TARGET_68020 && TARGET_BITFIELD"
"bfexts %1{%b3:%b2},%0")
@@ -4850,8 +4859,8 @@
(define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=d,d")
(zero_extract:SI (match_operand:QI 1 "memory_operand" "o,d")
- (match_operand:SI 2 "general_operand" "di,di")
- (match_operand:SI 3 "general_operand" "di,di")))]
+ (match_operand:SI 2 "general_operand" "dn,dn")
+ (match_operand:SI 3 "general_operand" "dn,dn")))]
"TARGET_68020 && TARGET_BITFIELD"
{
if (GET_CODE (operands[2]) == CONST_INT)
@@ -4868,8 +4877,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(xor:SI (zero_extract:SI (match_dup 0) (match_dup 1) (match_dup 2))
(match_operand 3 "const_int_operand" "n")))]
"TARGET_68020 && TARGET_BITFIELD
@@ -4883,8 +4892,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(const_int 0))]
"TARGET_68020 && TARGET_BITFIELD"
{
@@ -4894,8 +4903,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(const_int -1))]
"TARGET_68020 && TARGET_BITFIELD"
{
@@ -4913,8 +4922,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:QI 0 "memory_operand" "+o")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(match_operand:SI 3 "register_operand" "d"))]
"TARGET_68020 && TARGET_BITFIELD"
"bfins %3,%0{%b2:%b1}")
@@ -4925,16 +4934,16 @@
(define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(sign_extract:SI (match_operand:SI 1 "register_operand" "d")
- (match_operand:SI 2 "general_operand" "di")
- (match_operand:SI 3 "general_operand" "di")))]
+ (match_operand:SI 2 "general_operand" "dn")
+ (match_operand:SI 3 "general_operand" "dn")))]
"TARGET_68020 && TARGET_BITFIELD"
"bfexts %1{%b3:%b2},%0")
(define_insn ""
[(set (match_operand:SI 0 "nonimmediate_operand" "=d")
(zero_extract:SI (match_operand:SI 1 "register_operand" "d")
- (match_operand:SI 2 "general_operand" "di")
- (match_operand:SI 3 "general_operand" "di")))]
+ (match_operand:SI 2 "general_operand" "dn")
+ (match_operand:SI 3 "general_operand" "dn")))]
"TARGET_68020 && TARGET_BITFIELD"
{
if (GET_CODE (operands[2]) == CONST_INT)
@@ -4951,8 +4960,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(const_int 0))]
"TARGET_68020 && TARGET_BITFIELD"
{
@@ -4962,8 +4971,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(const_int -1))]
"TARGET_68020 && TARGET_BITFIELD"
{
@@ -4973,8 +4982,8 @@
(define_insn ""
[(set (zero_extract:SI (match_operand:SI 0 "register_operand" "+d")
- (match_operand:SI 1 "general_operand" "di")
- (match_operand:SI 2 "general_operand" "di"))
+ (match_operand:SI 1 "general_operand" "dn")
+ (match_operand:SI 2 "general_operand" "dn"))
(match_operand:SI 3 "register_operand" "d"))]
"TARGET_68020 && TARGET_BITFIELD"
{
@@ -4996,7 +5005,7 @@
[(set (cc0)
(zero_extract:SI (match_operand:QI 0 "memory_operand" "o")
(match_operand:SI 1 "const_int_operand" "n")
- (match_operand:SI 2 "general_operand" "di")))]
+ (match_operand:SI 2 "general_operand" "dn")))]
"TARGET_68020 && TARGET_BITFIELD"
{
if (operands[1] == const1_rtx
@@ -5021,7 +5030,7 @@
[(set (cc0)
(zero_extract:SI (match_operand:SI 0 "register_operand" "d")
(match_operand:SI 1 "const_int_operand" "n")
- (match_operand:SI 2 "general_operand" "di")))]
+ (match_operand:SI 2 "general_operand" "dn")))]
"TARGET_68020 && TARGET_BITFIELD"
{
if (operands[1] == const1_rtx