<div dir="ltr"><div>In an attempt to add vector registers to my target, I ran into a problem. LLVM started to complain about not being able to infer types from the provided DAG patterns for several classes of instructions. After a discussion on the llvm-dev mailing list and IRC channel the recommendation was to make DAG patterns for these classes of instructions more specific. Which is what was done. However after the changes were made, LLVM stopped recognizing a particular pattern, saying that it can not match it. Given that my understanding of DAG patterns is quite weak, I'd appreciate any help on this. For that matter, any opportunity to learn about LLVM is welcomed. Original code, modified code as well as the error are provided below. I can provide more if needed. There were two changes made. One in the definition of SDT_EsenciaSetFlag and another in SF_RI class (specifically in its DAG pattern). <br><br></div><div>Any help is appreciated.<br></div><div><br></div>========================= Orignal Code =====================================<br><br>def SDT_EsenciaSetFlag      : SDTypeProfile<0, 3, [SDTCisSameAs<0, 1>]>;<br><br>def Esenciasetflag     : SDNode<"EsenciaISD::SET_FLAG", SDT_EsenciaSetFlag,<br>                             [SDNPOutGlue]>;<br><br><br>def Esencia_CC_LT  : PatLeaf<(imm),<br>                  [{return (N->getZExtValue() == ISD::SETLT);}]>;<br><br><br>class SF_RI<bits<5> op2Val, string asmstr, PatLeaf Cond><br>  : InstRI<0xf, (outs), (ins GPR:$rA, s16imm:$imm),<br>           !strconcat(asmstr, "i\t$rA, $imm"),<br>           [(Esenciasetflag (i32 GPR:$rA), immSExt16:$imm, Cond)]> {<br>  bits<5> op2;<br>  bits<5> rA;<br>  bits<16> imm;<br><br>  let Inst{25-21} = op2;<br>  let Inst{20-16} = rA;<br>  let Inst{15-0} = imm;<br><br>  let format = AFrm;<br>  let op2 = op2Val;<br>}<br><br>defm SFLTS : SF<0xc, "l.sflts", Esencia_CC_LT>;<br><br>========================= Modified Code =====================================<br><br>def SDT_EsenciaSetFlag      : SDTypeProfile<1, 3, [SDTCisSameAs<1, 2>]>;<br><br>def Esenciasetflag     : SDNode<"EsenciaISD::SET_FLAG", SDT_EsenciaSetFlag,<br>                             [SDNPOutGlue]>;<br><br>def Esencia_CC_LT  : PatLeaf<(imm),<br>                  [{return (N->getZExtValue() == ISD::SETLT);}]>;<br><br>class SF_RI<bits<5> op2Val, string asmstr, PatLeaf Cond><br>  : InstRI<0xf, (outs), (ins GPR:$rA, s16imm:$imm),<br>           !strconcat(asmstr, "i\t$rA, $imm"),<br>           [(set SR:$rD, (Esenciasetflag (i32 GPR:$rA), (i32 immSExt16:$imm), (i32 Cond)))]> {<br>  bits<5> op2;<br>  bits<5> rA;<br>  bits<16> imm;<br><br>  let Inst{25-21} = op2;<br>  let Inst{20-16} = rA;<br>  let Inst{15-0} = imm;<br><br>  let format = AFrm;<br>  let op2 = op2Val;<br>}<br><br>multiclass SF<bits<5> op2Val, string asmstr, PatLeaf Cond> {<br>  def _rr : SF_RR<op2Val, asmstr, Cond>;<br>  def _ri : SF_RI<op2Val, asmstr, Cond>;<br>}<br><br>defm SFLTS : SF<0xc, "l.sflts", Esencia_CC_LT>;<br><br>========================= Orignal Match Result =====================================<br><br>Selecting: 0x2ebfa78: glue = EsenciaISD::SET_FLAG 0x2ebee18, 0x2ebef20, 0x2ebf658 [ORD=3] [ID=11]<br><br>ISEL: Starting pattern match on root node: 0x2ebfa78: glue = EsenciaISD::SET_FLAG 0x2ebee18, 0x2ebef20, 0x2ebf658 [ORD=3] [ID=11]<br><br>  Initial Opcode index to 258<br>  Skipped scope entry (due to false predicate) at index 278, continuing at 292<br>  Skipped scope entry (due to false predicate) at index 293, continuing at 307<br>  Skipped scope entry (due to false predicate) at index 308, continuing at 322<br>  Skipped scope entry (due to false predicate) at index 323, continuing at 337<br>  Skipped scope entry (due to false predicate) at index 338, continuing at 352<br>  Skipped scope entry (due to false predicate) at index 353, continuing at 367<br>  Skipped scope entry (due to false predicate) at index 368, continuing at 382<br>  Skipped scope entry (due to false predicate) at index 383, continuing at 397<br>  Morphed node: 0x2ebfa78: i32,glue = SFLTS_ri 0x2ebee18, 0x2ebf130 [ORD=3]<br><br>ISEL: Match complete!<br>=> 0x2ebfa78: i32,glue = SFLTS_ri 0x2ebee18, 0x2ebf130 [ORD=3]<br><br>========================= Failed Match Result =====================================<br><br>Selecting: 0x242d278: glue = EsenciaISD::SET_FLAG 0x242c618, 0x242c720, 0x242ce58 [ORD=3] [ID=11]<br><br>ISEL: Starting pattern match on root node: 0x242d278: glue = EsenciaISD::SET_FLAG 0x242c618, 0x242c720, 0x242ce58 [ORD=3] [ID=11]<br><br>  Initial Opcode index to 258<br>  Skipped scope entry (due to false predicate) at index 285, continuing at 301<br>  Skipped scope entry (due to false predicate) at index 302, continuing at 318<br>  Skipped scope entry (due to false predicate) at index 319, continuing at 335<br>  Skipped scope entry (due to false predicate) at index 336, continuing at 352<br>  Skipped scope entry (due to false predicate) at index 353, continuing at 369<br>  Skipped scope entry (due to false predicate) at index 370, continuing at 386<br>  Skipped scope entry (due to false predicate) at index 387, continuing at 403<br>  Skipped scope entry (due to false predicate) at index 404, continuing at 420<br>  Match failed at index 424<br>  Continuing at 437<br>  Match failed at index 438<br>  Continuing at 454<br>  Continuing at 455<br>  Skipped scope entry (due to false predicate) at index 466, continuing at 480<br>  Skipped scope entry (due to false predicate) at index 481, continuing at 495<br>  Skipped scope entry (due to false predicate) at index 496, continuing at 510<br>  Skipped scope entry (due to false predicate) at index 511, continuing at 525<br>  Skipped scope entry (due to false predicate) at index 526, continuing at 540<br>  Skipped scope entry (due to false predicate) at index 541, continuing at 555<br>  Skipped scope entry (due to false predicate) at index 556, continuing at 570<br>  Skipped scope entry (due to false predicate) at index 571, continuing at 585<br>  Match failed at index 589<br>  Continuing at 600<br>  Match failed at index 601<br>  Continuing at 615<br>  Continuing at 616<br>  Continuing at 617<br>  Match failed at index 619<br>  Continuing at 811<br>LLVM ERROR: Cannot select: 0x242d278: glue = EsenciaISD::SET_FLAG 0x242c618, 0x242c720, 0x242ce58 [ORD=3] [ID=11]<br>  0x242c618: i32,ch = CopyFromReg 0x24009a0, 0x242c510 [ORD=1] [ID=9]<br>    0x242c510: i32 = Register %vreg5 [ID=1]<br>  0x242c720: i32 = Constant<3> [ID=2]<br>  0x242ce58: i32 = Constant<20> [ID=8]<br>In function: fib<br><br><br clear="all"><div><div><div><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Rail Shafigulin<br></div>Software Engineer <br>Esencia Technologies<br></div></div></div></div>
</div></div></div></div>