Heyu Zhu
2009-Dec-07 10:45 UTC
[LLVMdev] How to use property 'isCommutable' in target description file?
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>
Anton Korobeynikov
2009-Dec-07 12:42 UTC
[LLVMdev] How to use property 'isCommutable' in target description file?
Hello> 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?Most probably you will need to write a special hook to commute this instruction. However, everything depends on your target (e.g. if there is an output register tied to one of the input).> *** Another question: Why set isCommutable = 1 in ADD16rr but NOT set in > ADD16ri?Because all msp430 instructions are two-address, this means that output register is tied to first input. That's why you cannot swap operands for reg-imm operations. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Heyu Zhu
2009-Dec-08 06:18 UTC
[LLVMdev] How to use property 'isCommutable' in target description file?
Thanks to Anton. Frankly said i don't know the exact meaning and purpose of 'isCommutable'. By my opinion "add.w r6, r7" != "add.w r7, r6", so we shouldn't set isCommutable = 1. Who would like give an example to demonstrate what benifit it has if 'isCommuatble=1' in instruction selection, register allocation or other process? Regards 2009/12/7, Anton Korobeynikov <anton at korobeynikov.info>:> > Hello > > > *** Another question: Why set isCommutable = 1 in ADD16rr but NOT set in > > ADD16ri? > Because all msp430 instructions are two-address, this means that > output register is tied to first input. That's why you cannot swap > operands for reg-imm operations. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20091208/3b7fbde6/attachment.html>
Seemingly Similar Threads
- [LLVMdev] How to use property 'isCommutable' in target description file?
- [LLVMdev] How to use property 'isCommutable' in target description file?
- [LLVMdev] Questions of instruction target description of MSP430
- [LLVMdev] Questions of instruction target description of MSP430
- [LLVMdev] Help me improve two-address code