[LLVMdev] How to use property 'isCommutable' in target description file?

Heyu Zhu zhu.heyu at gmail.com
Mon Dec 7 02:45:26 PST 2009


Hi everyone,

I  practice writing target description file with MSP430 reference.

I add a multiply-and-add instruction as below:

let isTwoAddress=1 in {

  def MULADD:Pseudo<(out GR16:$dst), (ins GR16:$src1, GR16:$src2,
GR16:$src3),

                                "muladd\t{$dst, $src2, $src3}",

                                [(set GR16:$dst, (add GR16:$src1, (mul
GR16:$src2, GR16:$src3)))]>

}

How can i tell the system X=A*B + C == X = B*A + C == X=C+A*B == X=C+B*A by
property 'isCommutable'? Is it necessary to do that?

***  Another question: Why set isCommutable = 1 in ADD16rr but NOT set in
ADD16ri?

let isCommutable = 1 in { // X = ADD Y, Z  == X = ADD Z, Y
def ADD16rr : Pseudo<(outs GR16:$dst), (ins GR16:$src1, GR16:$src2),
                     "add.w\t{$src2, $dst}",
                     [(set GR16:$dst, (add GR16:$src1, GR16:$src2)),
                      (implicit SRW)]>;
}
def ADD16ri : Pseudo<(outs GR16:$dst), (ins GR16:$src1, i16imm:$src2),
                     "add.w\t{$src2, $dst}",
                     [(set GR16:$dst, (add GR16:$src1, imm:$src2)),
                      (implicit SRW)]>;

Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091207/13deea8b/attachment.html>


More information about the llvm-dev mailing list