<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="">Hi,<div class=""><br class=""></div><div class="">I could be wrong but the register hierarchy doesn’t really take into account subtargets, instead you can, like you said, create different register classes for them, then have different sets of instructions for each of the subtarget (e.g., take a look at how GR16 vs. GR16_NOREX are modeled in X86).</div><div class=""><br class=""></div><div class="">Now assuming target2 is a strict super set of target1, there is actually a simpler approach:</div><div class="">- Have one register class for all 2048 gprs</div><div class="">- Mark the 1024 top gprs as not “reachable” for target1</div><div class=""><br class=""></div><div class="">You could do that by simply modifying TargetRegisterInfo::getReservedRegs.</div><div class=""><br class=""></div><div class="">Note: even if you use the register class approach with different instructions, you’ll need to modify that function to “disable” the top registers for target1 anyway. Otherwise you may end up with “out-of-bound’ registers (w.r.t. target1) in things like copies.</div><div class=""><br class=""></div><div class="">Take a look at <span style="font-family: Menlo; font-size: 11px;" class="">X86RegisterInfo::getReservedRegs </span>for instance.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">-Quentin</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On May 27, 2021, at 11:41 AM, jeniffer lesley via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">Hi</div><div class="">For my toy architecture, I have two subtarget, target 1 and target 2. Target 1 has 1024 and Target2 has 2048 GPRs. How do I model them in .td files? Should I just create a RegisterClass for them? If so, how do I associate them with SubtargetFeature or ProcessorModel?</div><div class=""><br class=""></div><div class="">If this is not the right way then can someone please educate?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Thanks<br class=""></div></div>
_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev<br class=""></div></blockquote></div><br class=""></div></body></html>