[LLVMdev] Operand order in dag pattern matching in td files

Anitha B Gollamudi anitha.boyapati at gmail.com
Fri Nov 16 00:19:22 PST 2012


On 16 November 2012 13:41, Anitha B Gollamudi <anitha.boyapati at gmail.com> wrote:
> Hi,
>
> I have a simple question w.r.t the order of operands used in dag
> pattern matching in target files. Some of them seem intuitive. But I
> want to get it clarified anyway. I am using a pattern from
> X86InstrFMA.td in the below example. Consider FMA3 pattern
> (simplified).
>
> let Constraints = "$src1 = $dst" in {
> multiclass fma3s_rm<bits<8> opc, string OpcodeStr, X86MemOperand x86memop,
>                     RegisterClass RC, ValueType OpVT, PatFrag mem_frag,
>                     SDPatternOperator OpNode = null_frag> {
>
>   def r     : FMA3<opc, MRMSrcReg, (outs RC:$dst),
>                    (ins RC:$src1, RC:$src2, RC:$src3),
>                    !strconcat(OpcodeStr,
>                               "\t{$src3, $src2, $dst|$dst, $src2, $src3}"),
>                    [(set RC:$dst,
>                      (OpVT (OpNode RC:$src2, RC:$src1, RC:$src3)))]>;
>
>
> Given that it is an FMA pattern, the OpNode can be one of X86Fmadd,
> X86Fmsub (among other opnodes). The respective operations are :
> (a*b+c) and (a*b-c). My questions are:
>
> 1. Why does $src2 and not $src1 come first in (OpNode RC:$src2,
> RC:$src1, RC:$src3) ?  In other words what is the difference between
> (a) and (b):
>    (a)    [(set RC:$dst, (OpVT (OpNode RC:$src2, RC:$src1, RC:$src3)))]
>    (b)    [(set RC:$dst,(OpVT (OpNode RC:$src1, RC:$src2, RC:$src3)))]
>

Typo.

> 2. Why happens when OpNode is null_frag?

2. What happens when OpNode is null_frag?





-- 
 Anitha



More information about the llvm-dev mailing list