Dear all,<div><br></div><div>I was wondering if it is possible in TableGen to either:</div><div><br></div><div>1. Selectively define an instruction depending on an SDNode's properties, e.g. if the SDNode is not commutative.</div>
<div>2. Override/ignore the TableGen error given when a commutative node has an immediate on the LHS.</div><div><br></div><div>My case comes from trying to define a generic ALU operation multiclass for my target, which includes a "dest_reg,immediate,src_reg" format. This is disallowed for commutative SDAG nodes (e.g. 'add') in LLVM, as the RHS cannot be an immediate (I assume for optimization purposes). I think I could achieve this with nested multiclasses, e.g.:</div>
<div><br></div><div>multiclass ALUOp<..> {<br>...<br>}</div><div><br></div><div>multiclass ALUOp_not_comm<..> {</div><div>  defm : ALUOp<...>;</div><div><br></div><div>  // Plus the 'dest_reg,immediate,src_reg' format.</div>
<div>}</div><div><br></div><div>defm ADD : ALUOp<..></div><div>defm SUB : ALUOp_not_comm<..></div><div><br></div><div><br></div><div>But this feels slightly dirty to me, not to mention more annoying to maintain (since in my target's eyes there is no difference between the formats for ADD and SUB), so I just wanted to check if there was any way to avoid this.</div>
<div><br></div><div>Thanks,</div><div>Stephen</div>