[PATCH] D157231: [SPARC][IAS] Add definitions for v9 State Registers

Koakuma via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 13 06:08:39 PDT 2023


koakuma added inline comments.


================
Comment at: llvm/lib/Target/Sparc/SparcRegisterInfo.td:135
+def GL         : SparcCtrlReg<16, "GL">;
+def VER        : SparcCtrlReg<31, "VER">;
 
----------------
barannikov88 wrote:
> It looks like these registers are actually aliases to %asrXX (or vice versa). They should use the corresponding functionality instead of being redefined.
> See RegAltNameIndex in Target.td and how other targets use it.
> 
The privileged ones are on a separate register file from the ASRs, so those need to be defined separately.

The unprivileged ones can be merged with the ASRs, however, I have a question about the handling of %tick/%asr4.
The same register can be viewed through nonprivileged (rd %tick/rd %asr4) or privileged (rdpr %tick) instructions, however, since the two are modeled using different objects, it is quite difficult to make it usable by both instructions.
Currently I am special casing it so that privileged TICK can also be read by `rd`. Is there any better way to do this or will this do for now?


================
Comment at: llvm/test/MC/Sparc/sparcv9-instructions.s:425
         ! V9: rd %pc, %o7               ! encoding: [0x9f,0x41,0x40,0x00]
         rd %pc, %o7
+        ! V9: rd %asi, %g1              ! encoding: [0x83,0x40,0xc0,0x00]
----------------
barannikov88 wrote:
> IIUC all of these should complain about missing feature on V8. This can probably be done by adding some checks to validateTargetOperandClass or checkTargetMatchPredicate.
> 
How do I do this? Seems like in both functions I can only get the raw register number, I don't know how to recover the textual name (e.g whether it was originally referred to as %asi or %asr3)...


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157231/new/

https://reviews.llvm.org/D157231



More information about the llvm-commits mailing list