[llvm-dev] Modelling registers per subtarget

Quentin Colombet via llvm-dev llvm-dev at lists.llvm.org
Thu May 27 13:46:31 PDT 2021


Hi,

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).

Now assuming target2 is a strict super set of target1, there is actually a simpler approach:
- Have one register class for all 2048 gprs
- Mark the 1024 top gprs as not “reachable” for target1

You could do that by simply modifying TargetRegisterInfo::getReservedRegs.

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.

Take a look at X86RegisterInfo::getReservedRegs for instance.

Cheers,
-Quentin

> On May 27, 2021, at 11:41 AM, jeniffer lesley via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi
> 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?
> 
> If this is not the right way then can someone please educate?
> 
> 
> Thanks
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210527/7599b4d8/attachment.html>


More information about the llvm-dev mailing list