<div dir="ltr"><span style="font-size:13px">I'm working on generating code for a machine that has a register set kind of like the 68000.</span><div style="font-size:13px"><br><div>For those who don't recall, the 68K has 8 Data registers that can be used for ordinary integer</div><div>instructions like add, subtract, multiply, shift, etc., and 8 Address registers that can be use for</div><div>integer addition and a few other things, especially base registers for addressing modes.</div></div><div style="font-size:13px">The Data register, on the other hand, cannot be used as base registers.</div><div style="font-size:13px"><br></div><div style="font-size:13px">So, neither is more general than the other. We can use either for integer addition,</div><div style="font-size:13px">but only Address registers as base registers and only Data registers for integer</div><div style="font-size:13px">multiplication, etc. (I may have a few details wrong, but since this is only an example,</div><div style="font-size:13px">I don't think they're too important.)</div><div style="font-size:13px"><br></div><div style="font-size:13px">Back when, I defined 3 register classes: Address, Data, and General,</div><div style="font-size:13px">where Address = 1, Data = 2, and General = 3.</div><div style="font-size:13px">My approach was to begin by defining every symbolic register (aka live range)</div><div style="font-size:13px">as General. Then I'd walk through all the instructions, intersecting the requirements</div><div style="font-size:13px">for the particular instruction to yield a perhaps less general register class.</div><div style="font-size:13px"><br></div><div style="font-size:13px">For example, an Add instruction would require and produce General registers (since we</div><div style="font-size:13px">have add instructions for both Address and Data registers). But an addressing mode</div><div style="font-size:13px">would require an Address register, so when we notice a General register being used in</div><div style="font-size:13px">an addressing mode, intersection the Addressing requirement (= 1) with the General</div><div style="font-size:13px">register (= 3) yields 1, implying the register needs to be an Address register.</div><div style="font-size:13px"><br></div><div style="font-size:13px">When building the interference graph and noting that 2 live ranges were simultaneously live,</div><div style="font-size:13px">if the intersection of their classes was non-zero, I'd add an interference to the IG.</div><div style="font-size:13px">Similarly, I'd make symbolic registers of Address class interfere with all the machine's</div><div style="font-size:13px">Data registers and vice versa. In this fashion, since live ranges that are more restricted</div><div style="font-size:13px">(have higher degree) tend to be colored first, live ranges that must be Address or</div><div style="font-size:13px">must be Data will end up in the right place, with the coloring algorithm naturally</div><div style="font-size:13px">balancing everyone's requirements.</div><div style="font-size:13px"><br></div><div style="font-size:13px">Care is required when a live range ends up with class = 0; implies copies are required.</div><div style="font-size:13px"><br></div><div style="font-size:13px">So, finally, my question: Is there any similar scheme in LLVM's code generator?</div><div style="font-size:13px">What I'm looking for is a way to select the one of the two available integer addition</div><div style="font-size:13px">instructions (add using Address registers or add using Data registers) so as to</div><div style="font-size:13px">minimize the number of Address-Data copies.</div><div style="font-size:13px"><br></div><div style="font-size:13px">Thanks,</div><div style="font-size:13px">Preston</div><div style="font-size:13px"><br></div></div>