Correct way to modify a .md file?

Robert Baruch autophile@starband.net
Tue Mar 19 14:01:00 GMT 2002


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

I'm trying to add some optimizations to the m68k.md file. I'm just starting 
out, and I've read the gcc docs backwards and forwards, and it's beginning to 
make just a little sense.

Hopefully this question belongs on this mailing list?

Anyway, one thing I'm trying, just to see if it works, is to find anything 
which multiples an HI register by 40 and replace it with two shifts and an 
add. For example:

muls.w #40,%d0

becomes

move.w %d0,%d1
asl.w #2,%d0    /* 4x */
add.w %d1,%d0   /* 5x */
asl.w #3,%d0    /* 40x */

Would the correct way to do this in the .md file be the included patch? It 
*seems* to work, but I'd like to know if I'm using clobber/match_scratch 
properly, and if my define_insn really belongs here.

Thanks!

- --Rob


- --- gcc-2.95.3.orig/gcc/config/m68k/m68k.md     Tue Mar 19 16:50:26 2002
+++ gcc-2.95.3/gcc/config/m68k/m68k.md  Tue Mar 19 16:57:43 2002
@@ -2997,6 +2997,21 @@
 ^L
 ;; multiply instructions

+(define_insn ""
+  [(set (match_operand:HI 0 "general_operand" "=d")
+       (mult:HI (match_operand:HI 1 "general_operand" "%0")
+                (match_operand:HI 2 "const_int_operand" "n")))
+    (clobber (match_scratch:SI 3 "=d"))]
+  "!TARGET_68020 && !TARGET_5200 &&
+   INTVAL (operands[2]) == 40"
+  "*
+{
+  return \"move%.w %0,%3 /* RCB0 */\;
+          asl%.w #2,%0 /* RCB0 */\;
+          add%.w %3,%0 /* RCB0 */\;
+          asl%.w #3,%0 /* RCB0 */\"
+}")
+
 (define_insn "mulhi3"
   [(set (match_operand:HI 0 "general_operand" "=d")
        (mult:HI (match_operand:HI 1 "general_operand" "%0")

-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.8

iQA/AwUBPJe07NhpAoRIZLToEQIakACeIZKYayiTjaVUHoa0VE1kX0ODzPMAoL3S
+G6/grM5Ez6OeJS7NRLZMgWB
=1LHT
-----END PGP SIGNATURE-----



More information about the Gcc-help mailing list