Peter Jansen wrote:
Hi Grant,

Ok try this patch.

Here is another try, the last patch had a problem compiling with -O0 I think this fixes it. There must be a way of detecting if we have a fixed even address and using mov instead of two mov.b instructions.

Anyone able to test this?



--
Peter Jansen


___________________________________________________________________________

   Australian Antarctic Division - Commonwealth of Australia
IMPORTANT: This transmission is intended for the addressee only. If you are not 
the
intended recipient, you are notified that use or dissemination of this 
communication is
strictly prohibited by Commonwealth law. If you have received this transmission 
in error,
please notify the sender immediately by e-mail or by telephoning +61 3 6232 
3209 and
DELETE the message.
       Visit our web site at http://www.aad.gov.au/
___________________________________________________________________________
diff -rU 3 gcc-3.2.3-orig/gcc/config/msp430/msp430.c 
gcc-3.2.3/gcc/config/msp430/msp430.c
--- gcc-3.2.3-orig/gcc/config/msp430/msp430.c   2006-04-24 02:18:20.000000000 
+1000
+++ gcc-3.2.3/gcc/config/msp430/msp430.c        2006-09-15 20:12:30.000000000 
+1000
@@ -3548,6 +3548,71 @@
   return (REGNO (x));
 }
 
+const char *
+msp430_movehi_code (insn, operands, len)
+     rtx insn;
+     rtx operands[];
+     int *len;
+{
+  rtx op0 = operands[0];
+  rtx op1 = operands[1];
+
+
+  if (memory_operand (op0, VOIDmode)
+      && memory_operand (op1, VOIDmode) && zero_shifted (op1))
+    {
+      if (!len)
+       msp430_emit_indexed_mov2 (insn, operands, NULL);
+      else
+       *len = 3;
+      return "";
+    }
+  else if (register_operand (op0, VOIDmode)
+          && memory_operand (op1, VOIDmode) && zero_shifted (op1))
+    {
+      if (!len)
+       movsisf_regmode (insn, operands, NULL);
+      else
+       *len = 1;
+      return "";
+    }
+
+  if (!len)
+    {
+        if (immediate_operand (op1, VOIDmode))
+        {
+            output_asm_insn ("mov.b\t#(%F1&0xff), %I0; movehiC", operands);
+            output_asm_insn ("mov.b\t#(%F1>>8), %J0; movehiC", operands);
+        }
+        else if (register_operand (op1, VOIDmode))
+        {
+            output_asm_insn ("mov\t%1, %0; movehiR", operands);
+        }
+        else
+        {
+            output_asm_insn ("mov.b\t%I1, %I0; movehi", operands);
+            output_asm_insn ("mov.b\t%J1, %J0; movehi", operands);
+        }
+    }
+  else
+    {
+      *len = 1;                        /* base length */
+
+      if (register_operand (op0, VOIDmode))
+       *len += 0;
+      else if (memory_operand (op0, VOIDmode))
+       *len += 1;
+
+      if (register_operand (op1, VOIDmode))
+       *len += 0;
+      else if (memory_operand (op1, VOIDmode))
+       *len += 1;
+      else if (immediate_operand (op1, VOIDmode))
+       *len += 1;
+    }
+
+  return "";
+}
 
 const char *
 msp430_movesi_code (insn, operands, len)
diff -rU 3 gcc-3.2.3-orig/gcc/config/msp430/msp430.md 
gcc-3.2.3/gcc/config/msp430/msp430.md
--- gcc-3.2.3-orig/gcc/config/msp430/msp430.md  2006-01-30 20:47:05.000000000 
+1100
+++ gcc-3.2.3/gcc/config/msp430/msp430.md       2006-09-15 21:26:16.000000000 
+1000
@@ -1157,14 +1157,23 @@
   ""
   "")
 
-(define_insn "*movhi3"
-  [(set (match_operand:HI 0 "nonimmediate_operand_msp430"      
"=m,m,m,m,r,r,r,r")
-       (match_operand:HI 1 "general_operand_msp430"            " 
r,m,P,i,r,m,P,i"))]
+(define_insn "*movhi2"
+  [(set (match_operand:HI 0 "register_operand"                 "=r,r,r,r")
+       (match_operand:HI 1 "general_operand_msp430"            " r,m,P,i")) ]
   ""
-  "mov\\t%1, %0 "
-  [(set_attr "length" "2,3,3,3,1,2,2,2")
+  "mov\\t%1, %0"
+  [(set_attr "length" "1,2,2,2")
    (set_attr "cc" "none")])
 
+(define_insn "*movhi2m"
+  [(set (match_operand:HI 0 "memory_operand_msp430"            "=mmmm")
+       (match_operand:HI 1 "general_operand_msp430"            " rmPi")) ]
+  ""
+  "* return msp430_movehi_code(insn,operands,NULL);"
+  [(set_attr "length" "3")
+   (set_attr "cc" "none")])
+
+
 (define_insn "movhipi"
   [(set (match_operand:HI 0 "nonimmediate_operand_msp430" "=r,m")
        (mem:HI (post_inc:HI (match_operand:HI 1 "register_operand" "r,r"))))]

Reply via email to