<div dir="ltr"><div>With a "toy" target with non-homogeneous register banks and specific instructions for copying or summing values between them (remotely similar to a 6502 but with multiple acculmulators and indexes), I'm trying to restrict instruction selection by the register class. However given these (simplified extracts) from the .td definitions:</div><div><br></div><div><div>def aRegs : RegisterClass<"ToyCPU", [i8], 8,</div><div>  (add a0, a1, a2, a3 )>;</div></div><div><br></div><div><div><div>def xRegs : RegisterClass<"ToyCPU", [i8], 8,</div><div>  (add x0, x1, x2, x3, x4, x5, x6, x7 )>;</div></div></div><div><br></div><div><div>// Add an index to an accumulator </div><div>// (aN = aN + xO => "ADX aN, xO")</div><div>let Constraints = "$src = $dst" in {</div><div>  def ADX  : ToyInst<0x0600, //opcode</div><div>                     (outs aRegs:$dst), (ins aRegs:$src, xRegs:$src2),</div><div>                     "adx {$dst, $src2}",</div><div>                     [(set aRegs:$dst, (add aRegs:$src xRegs:$src2))]>;</div><div>}</div><div><br></div></div><div>it seemingly ignores the register class, emitting assembler such as "adx a1, a0". </div><div><br></div><div>The only direct commentary that I've found is this thread:</div><div><br></div><div><a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-September/010815.html" target="_blank">http://lists.cs.uiuc.edu/pipermail/llvmdev/2007-September/010815.html</a><br></div><div><br></div><div>which (as I understand) says that register class constraints can only be handled through custom pattern code. Before heading in that direction I'd welcome confirmation that - eight years after that thread - this remains the best approach for restricting register selections?</div><div><br></div><div>/Tyro</div></div>