<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 8 Jun 2020, at 08:13, Gabriel Hjort Åkerlund <<a href="mailto:gabriel.hjort.akerlund@ericsson.com" class="">gabriel.hjort.akerlund@ericsson.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">Hi Daniel,<o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">Thanks for replying; I was hoping to get in touch with you on this issue.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">I had a look at how SelectionIDAG does it when generating the matcher table, and it does consider the implicit defs as additional output. Here is the match table generated for the pattern:<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 0*/ OPC_CheckOpcode, TARGET_VAL(ISD::SIGN_EXTEND),<o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 3*/ OPC_MoveChild0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 4*/ OPC_CheckOpcode, TARGET_VAL(ISD::SHL),<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 7*/ OPC_MoveChild0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 8*/ OPC_CheckOpcode, TARGET_VAL(ISD::ANY_EXTEND),<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 11*/ OPC_RecordChild0, // #0 = $src<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 12*/ OPC_CheckChild0Type, MVT::i16,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 14*/ OPC_MoveParent,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 15*/ OPC_RecordChild1, // #1 = $imm<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 16*/ OPC_MoveChild1,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 17*/ OPC_CheckOpcode, TARGET_VAL(ISD::Constant),<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 20*/ OPC_CheckPredicate, 0, // Predicate_Imm_17_31_i16<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 22*/ OPC_CheckType, MVT::i16,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 24*/ OPC_MoveParent,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 25*/ OPC_CheckType, MVT::i32,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 27*/ OPC_MoveParent,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 28*/ OPC_CheckType, MVT::i40,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 30*/ OPC_EmitNode1, TARGET_VAL(TargetOpcode::IMPLICIT_DEF), 0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i40, 0/*#Ops*/, // Results = #2<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 36*/ OPC_EmitNode1, TARGET_VAL(TargetOpcode::IMPLICIT_DEF), 0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i32, 0/*#Ops*/, // Results = #3<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 42*/ OPC_EmitInteger, MVT::i32, OurTarget::hi16, // Results = #4<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 45*/ OPC_EmitNode1, TARGET_VAL(TargetOpcode::INSERT_SUBREG), 0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i32, 3/*#Ops*/, 3, 0, 4, // Results = #5<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 54*/ OPC_EmitNode1, TARGET_VAL(OurTarget::clearLo32_pseudo), 0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i32, 1/*#Ops*/, 5, // Results = #6<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 61*/ OPC_EmitInteger, MVT::i16, 0,<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 64*/ OPC_EmitRegister, MVT::i16, 0 /*zero_reg*/,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 67*/ OPC_EmitInteger, MVT::i16, 0,<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 70*/ OPC_EmitNode2, TARGET_VAL(OurTarget::shfts_a32_imm7), 0,<o:p class=""></o:p></span></b></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i32, MVT::i16, 5/*#Ops*/, 6, 1, 7, 8, 9, // Results = #10 #11<o:p class=""></o:p></span></b></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 82*/ OPC_EmitInteger, MVT::i32, OurTarget::acc,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 85*/ OPC_EmitNode1, TARGET_VAL(TargetOpcode::INSERT_SUBREG), 0,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i40, 3/*#Ops*/, 2, 10, 12, // Results = #13<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 94*/ OPC_EmitInteger, MVT::i16, 0,<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 97*/ OPC_EmitRegister, MVT::i16, 0 /*zero_reg*/,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 100*/ OPC_EmitInteger, MVT::i16, 0,<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 103*/ OPC_MorphNodeTo1, TARGET_VAL(OurTarget::sext_a32), 0,<o:p class=""></o:p></span></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> MVT::i40, 4/*#Ops*/, 13, 14, 15, 16, ...<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">The line of interest here is the one below<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/* 70 */</span><span lang="EN-US" style="font-size: 12pt;" class="">. There, we can see that the instruction produces two results of type<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">MVT::i32</span><span lang="EN-US" style="font-size: 12pt;" class=""><span class="Apple-converted-space"> </span>(the value produced by the instruction) respectively<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">MVT::i16</span><span lang="EN-US" style="font-size: 12pt;" class=""><span class="Apple-converted-space"> </span>(the CCReg updated by the instruction). These are labeled as results<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">#10</span><span lang="EN-US" style="font-size: 12pt;" class=""><span class="Apple-converted-space"> </span>respectively<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">#11</span><span lang="EN-US" style="font-size: 12pt;" class="">. Looking at operand identifiers after<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">/*#Ops*/</span><span lang="EN-US" style="font-size: 12pt;" class="">, we can see that only<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">#10</span><span lang="EN-US" style="font-size: 12pt;" class=""><span class="Apple-converted-space"> </span>is used by the rest of the resulting pattern (by<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">INSERT_SUBREG</span><span lang="EN-US" style="font-size: 12pt;" class="">), which is as intended.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">However, in the destination pattern declared in the *.td file, there is no information pertaining to which of the results should be used by the parent node. Since only tree-shaped patterns are allowed, SelectionIDAG must somehow decide which of the results are to be used by the parent node. And this decision is taken at lines 869-870 in<span class="Apple-converted-space"> </span></span><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class="">DAGISelMatcherGen.cpp</span><span lang="EN-US" style="font-size: 12pt;" class="">:<span class="Apple-converted-space"> </span><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> ...<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> unsigned FinalNumOps = InstOps.size() + NumSubOps;<o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> while (InstOps.size() < FinalNumOps) {<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> const TreePatternNode *Child = N->getChild(ChildNo);<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> unsigned BeforeAddingNumOps = InstOps.size();<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> EmitResultOperand(Child, InstOps);<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> assert(InstOps.size() > BeforeAddingNumOps && "Didn't add any operands");<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> // If the operand is an instruction and it produced multiple results, just<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> // take the first one.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> if (!Child->isLeaf() && Child->getOperator()->isSubClassOf("Instruction"))<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> InstOps.resize(BeforeAddingNumOps+1);<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> ++ChildNo;<o:p class=""></o:p></span></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> }<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt; font-family: "Courier New", serif;" class=""> ...<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">In other words, if a child produces more than one result SelectionIDAG always takes the first result. Those two lines originate from a patch by Chris Lattner (r99725), so presumably this is the correct way of doing it. If GlobalISel were to do the same, it would solve the issue I'm having with our patterns.</span></div></div></div></div></blockquote><div><br class=""></div>Thanks for looking into that.</div><div><br class=""></div><div>There's three questions I feel I have with the SelectionDAG behaviour:</div><div>* If Defs=[A] causes SelectionDAG to add a result to the intermediate SDNode, why doesn't Defs=[A,B] add two?</div><div>* Given that SDNode's support MVT::Other results, why doesn't MVT::Other behave the same way?</div><div>* If nothing can use that result, why model it? I suppose custom C++ instruction selection can still see it so maybe that's it but if so, what code is relying on it?</div><div>The inconsistency makes me rather suspicious about it. It feels like it was a hack for a specific purpose but I don't know what that purpose is. Overall, I'm not keen to carry it forwards unless there's a clear reason it's there.</div><div><br class=""></div><div>Leaving that aside for the moment. I see a difference in modelling that makes directly importing the SelectionDAG behaviour tricky. SelectionDAG uses SDNode's which keep the result list (+ the first implicit def with known type) and the operand list separate. GlobalISel uses the MachineInstr's which uses a single list in a fixed order. That order is outputs, inputs, implicits so we would need to split the results list into two pieces and defer adding the implicit def to the place it's currently added to handle it the SelectionDAG way. That being the case (and assuming we don't find a good reason for SelectionDAG's behaviour), I think the best approach for this might be to adjust the numbers that originate from GetNumNodeResults() for the `InstInfo.HasOneImplicitDefWithKnownVT(CDP.getTargetInfo()) !=MVT::Other` case to undo the adjustment CodeGenDAGPatterns does. That's an ugly solution but I think the other ones I can think of are worse.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">Best regards,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class="">Gabriel<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 12pt;" class=""><o:p class=""> </o:p></span></div></div><div class="MsoNormal" align="center" style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; text-align: center;"><hr size="2" width="98%" align="center" class=""></div><div id="divRplyFwdMsg" class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="" class="">From:</span></b><span lang="EN-US" style="" class=""><span class="Apple-converted-space"> </span>Daniel Sanders <<a href="mailto:daniel_l_sanders@apple.com" class="">daniel_l_sanders@apple.com</a>><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Friday, June 5, 2020 9:02 PM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Quentin Colombet <<a href="mailto:qcolombet@apple.com" class="">qcolombet@apple.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span>Dominik Montada <<a href="mailto:dominik.montada@hightec-rt.com" class="">dominik.montada@hightec-rt.com</a>>; Gabriel Hjort Åkerlund <<a href="mailto:gabriel.hjort.akerlund@ericsson.com" class="">gabriel.hjort.akerlund@ericsson.com</a>>; <a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a> <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [llvm-dev] Nested instruction patterns rejected by GlobalISel when having registers in Defs</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">The implicit defs don't participate much in the patterns. For the most part it's just read into CodeGenInstruction::ImplicitDefs and then GlobalISel gathers and adds them all at the end. I think I do see the code Gabriel is referring to though.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">GetNumNodeResults() has:<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> if (InstInfo.HasOneImplicitDefWithKnownVT(CDP.getTargetInfo()) !=MVT::Other)<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> ++NumDefsToAdd;<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">and ultimately this VT gets into Types via UpdateNodeType(). I have no idea why this code does this as I don't really see why the VT matters to how you treat an implicit def. This code dates back to 2010 (r99726) and that commit called it 'funky logic' so it's unlikely that we'll find someone that remembers it.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Does your CCReg need to have a specific type? If not, then you could make it MVT::Other and the problem should go away.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Have you looked into how DAGISel supports these patterns? This code is common between DAGISel and GlobalISel so given that DAGISel works it must be doing something to handle this that's missing from GlobalISel.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><br class=""><br class=""><o:p class=""></o:p></span></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">On 5 Jun 2020, at 11:02, Quentin Colombet <</span><a href="mailto:qcolombet@apple.com" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" class="">qcolombet@apple.com</span></a><span lang="EN-US" class="">> wrote:<o:p class=""></o:p></span></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">+ Daniel who knows the most about the table gen importer<o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><br class=""><br class=""><o:p class=""></o:p></span></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">On Jun 5, 2020, at 12:48 AM, Dominik Montada via llvm-dev <</span><a href="mailto:llvm-dev@lists.llvm.org" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" class="">llvm-dev@lists.llvm.org</span></a><span lang="EN-US" class="">> wrote:<o:p class=""></o:p></span></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Hi Gabriel,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Your comment made me take a look at our instruction definitions and patterns in a little bit more detail. And while we do use nested patterns with INSERT_SUBREG, apparently none of those patterns use instructions with implicit-defs. Sorry for misleading you there by a wrong assumption on my part.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">However, I still find it strange that TableGen should reject such a pattern. I'm really not sure if this is simply an overlooked use-case or if there is some real reasoning behind this logic. If it were an actual output register I could understand it, but since this is an implicit one it should not impact the pattern in my opinion.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Sorry for not being able to help out with the actual problem after all!<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Cheers,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Dominik<o:p class=""></o:p></span></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Am 04.06.20 um 15:06 schrieb Gabriel Hjort Åkerlund:<o:p class=""></o:p></span></div></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class=""><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Hi Dominik,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Thanks for your reply.<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">In my case, the<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-family: "Courier New", serif;" class="">Defs</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">is the cause of the problem. Or rather, it is part of the problem, because when I remove it from the instruction TableGen gives me a different error message which concerns a part which is deeper into the pattern tree, so at least it is able to proceed beyond that part of the pattern. I have also stepped TableGen inside<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-family: "Courier New", serif;" class="">gdb</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">and verified that having Defs causes GlobalISel to include<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-family: "Courier New", serif;" class="">CCReg</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">in the<span class="xapple-converted-space"> </span></span><span lang="EN-US" class="">Types</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">field of the<span class="xapple-converted-space"> </span></span><span lang="EN-US" class="">TreePatternNode</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">corresponding to the instruction, which is what GlobalISel looks at to subsequently reject the pattern on basis that the instruction produces multiple results.</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">But from your comment, I take it that the<span class="xapple-converted-space"> </span>Defs</span><span class="xapple-converted-space"><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class=""> </span></span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">field should never be considered actual output, is that correct? If so, I find it strange that<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-family: "Courier New", serif;" class="">CodeGenDAGPatterns</span><span lang="EN-US" style="font-family: "Ericsson Hilda", serif;" class="">, which parses the patterns, takes the CCReg into consideration as additional results. I am tempted to modify that part of the code, but maybe I’m missing some invariant that’s not immediately evident…</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Cheers,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Gabriel<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" class="">From:</span></b><span class="xapple-converted-space"><span lang="EN-US" class=""> </span></span><span lang="EN-US" class="">Dominik Montada<span class="xapple-converted-space"> </span><a href="mailto:dominik.montada@hightec-rt.com" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class=""><dominik.montada@hightec-rt.com></span></a><span class="xapple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="xapple-converted-space"> </span>den 4 juni 2020 14:51<br class=""><b class="">To:</b><span class="xapple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class="">llvm-dev@lists.llvm.org</span></a><br class=""><b class="">Cc:</b><span class="xapple-converted-space"> </span>Gabriel Hjort Åkerlund<span class="xapple-converted-space"> </span><a href="mailto:gabriel.hjort.akerlund@ericsson.com" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class=""><gabriel.hjort.akerlund@ericsson.com></span></a><br class=""><b class="">Subject:</b><span class="xapple-converted-space"> </span>Re: [llvm-dev] Nested instruction patterns rejected by GlobalISel when having registers in Defs<o:p class=""></o:p></span></div></div></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Hi Gabriel,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">I'm working on a downstream target which uses GlobalISel and we have many patterns with instructions that also define a system register as a side-effect and use them without any problem. Since CCReg is not an actual output of the instruction, but an implicit definition, GlobalISel should have no trouble with it, so I'm guessing your problem lies somewhere. Have you tried running the tablegen command manually and looked at the output there?<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">The command is<span class="xapple-converted-space"> </span></span><tt style="font-family: "Courier New", serif;" class=""><span lang="EN-US" style="font-size: 10pt;" class="">llvm-tblgen -gen-global-isel <couple of -I flags> <your_target>.td --write-if-changed --warn-on-skipped-patterns</span></tt><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class=""><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">I can't tell you exactly what -I flags you'll need but if you run ninja in verbose mode or look at the ninja build log, you should be able to see what is being used.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Word of caution however: sometimes TableGen gives you a very clear error message indicating what is wrong, sometimes it gives you a very cryptic error message. And sometimes it doesn't even give you that and behave as if everything is a-ok while it still hasn't included your pattern. I have lost countless hours trying to debug TableGen patterns with GlobalISel and there's still a lot of stuff that GlobalISel unfortunately does not support yet in TableGen. So be prepared to write some C++ code for the unsupported cases for the moment.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Cheers,<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">Dominik<o:p class=""></o:p></span></div><div class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class="">Am 04.06.20 um 14:34 schrieb Gabriel Hjort Åkerlund via llvm-dev:<o:p class=""></o:p></div></div></div><blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class=""><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Hi,<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">I am in the process of porting our target to GlobalISel, and have encountered a problem. Nearly all instructions in our instruction set make modifications to a CC register, and hence are defined as follows:<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">let ..., Defs = [CCReg] in<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">def shfts_a32_imm7: Instruction<(outs OurRC:$dst), ...>;<o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">What’s more, many of these instructions have patterns where the instruction itself appears inside a nested tree, e.g.:</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt;" class="">def Pat<(source pattern ...),</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt;" class=""> <span class="xapple-converted-space"> </span>(sext_a32 (INSERT_SUBREG (...), (shfts_a32_imm7 OurRC:$src, Imm7:$imm), ...>;</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">Now to the problem: When TableGen processes the instruction above, it includes the<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">CCReg</span><span class="xapple-converted-space"><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span></span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">in the<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">Defs</span><span class="xapple-converted-space"><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span></span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">field along with the registers appearing in<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">outs</span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">, thereby indicating that shfts_a32_imm7 produces two results. Currently, the GlobalISel-backend in TableGen requires that nested instructions appearing in the output pattern produce exactly one result. Consequently, TableGen rejects many of our patterns. But in reality, the instruction really only produces a single result and therefore this pattern should be allowed.</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">So I wonder, how should registers appear in<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">Defs</span><span class="xapple-converted-space"><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span></span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">be treated? Are they equal to those appearing in<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">outs</span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">, and therefore interchangeable, or is it valid to disambiguate between them and therefore modify TableGen to only consider<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt;" class="">outs<span class="xapple-converted-space"> </span></span><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">as the result of interest when processing the patterns?</span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><b class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class="">Gabriel Hjort Åkerlund</span></b><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 10pt; font-family: Arial, sans-serif; color: rgb(24, 24, 24);" class=""> </span><span lang="EN-US" class=""><o:p class=""></o:p></span></div></div><div class=""><p class="MsoNormal" style="margin: 0cm 0cm 12pt; font-size: 11pt; font-family: Calibri, sans-serif;"><span lang="EN-US" class=""><o:p class=""> </o:p></span></p></div><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">_______________________________________________<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">LLVM Developers mailing list<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" style="color: rgb(149, 79, 114);" class="">llvm-dev@lists.llvm.org</span></a><span lang="EN-US" class=""><o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><a href="https://protect2.fireeye.com/v1/url?k=52e18446-0c413e28-52e1c4dd-86b1886cfa64-f424e731a80348bd&q=1&e=238953c8-f0ec-4510-8c97-620bfb03d5be&u=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" style="color: rgb(149, 79, 114);" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</span></a><span lang="EN-US" class=""><o:p class=""></o:p></span></pre></blockquote><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">-- <o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">----------------------------------------------------------------------<o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">Dominik Montada Email: <a href="mailto:dominik.montada@hightec-rt.com" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class="">dominik.montada@hightec-rt.com</span></a><o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">HighTec EDV-Systeme GmbH Phone: +49 681 92613 19<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">Europaallee 19 Fax: +49-681-92613-26<o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">D-66113 Saarbrücken WWW: <a href="https://protect2.fireeye.com/v1/url?k=a0228059-fe823a37-a022c0c2-86b1886cfa64-48b7aa6978940111&q=1&e=238953c8-f0ec-4510-8c97-620bfb03d5be&u=http%3A%2F%2Fwww.hightec-rt.com%2F" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class="">http://www.hightec-rt.com</span></a><o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""> <o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">Managing Director: Vera Strothmann<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class=""> <o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">This e-mail may contain confidential and/or privileged information. If<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">you are not the intended recipient please notify the sender immediately<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">and destroy this e-mail. Any unauthorised copying, disclosure or<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">distribution of the material in this e-mail is strictly forbidden.<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">--- <o:p class=""></o:p></pre></div></blockquote><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif; font-variant-caps: normal; text-align: start; word-spacing: 0px;" class="">-- <o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">----------------------------------------------------------------------<o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">Dominik Montada Email: <a href="mailto:dominik.montada@hightec-rt.com" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class="">dominik.montada@hightec-rt.com</span></a><o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">HighTec EDV-Systeme GmbH Phone: +49 681 92613 19<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">Europaallee 19 Fax: +49-681-92613-26<o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class="">D-66113 Saarbrücken WWW: <a href="https://protect2.fireeye.com/v1/url?k=b7cd53d5-e96de9bb-b7cd134e-861d41abace8-5636b949d44c6f9b&q=1&e=9aff5cfa-72fd-4986-af7c-78b27f9ea1e8&u=http%3A%2F%2Fwww.hightec-rt.com%2F" style="color: purple; text-decoration: underline;" class=""><span style="color: rgb(149, 79, 114);" class="">http://www.hightec-rt.com</span></a><o:p class=""></o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><o:p class=""> </o:p></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">Managing Director: Vera Strothmann<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">Register Court: Saarbrücken, HRB 10445, VAT ID: DE 138344222<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class=""><o:p class=""> </o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">This e-mail may contain confidential and/or privileged information. If<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">you are not the intended recipient please notify the sender immediately<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">and destroy this e-mail. Any unauthorised copying, disclosure or<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">distribution of the material in this e-mail is strictly forbidden.<o:p class=""></o:p></span></pre><pre style="margin: 0cm 0cm 0.0001pt; font-size: 10pt; font-family: "Courier New", serif;" class=""><span lang="EN-US" class="">--- <o:p class=""></o:p></span></pre><div style="margin: 0cm 0cm 0.0001pt; font-size: 11pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class="">_______________________________________________<br class="">LLVM Developers mailing list<br class=""></span><a href="mailto:llvm-dev@lists.llvm.org" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif; color: rgb(149, 79, 114);" class="">llvm-dev@lists.llvm.org</span></a><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif;" class=""><br class=""></span><a href="https://protect2.fireeye.com/v1/url?k=b3d033f0-ed70899e-b3d0736b-861d41abace8-91f0c9908116c6fb&q=1&e=9aff5cfa-72fd-4986-af7c-78b27f9ea1e8&u=https%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev" style="color: purple; text-decoration: underline;" class=""><span lang="EN-US" style="font-size: 9pt; font-family: Helvetica, sans-serif; color: rgb(149, 79, 114);" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</span></a></div></div></blockquote></div></div></div></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>