[llvm] [X86] Support EGPR (R16-R31) for APX (PR #67702)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 30 20:35:45 PDT 2023


================
@@ -92,6 +92,37 @@ X86InstrInfo::X86InstrInfo(X86Subtarget &STI)
       Subtarget(STI), RI(STI.getTargetTriple()) {
 }
 
+const TargetRegisterClass *
+X86InstrInfo::getRegClass(const MCInstrDesc &MCID, unsigned OpNum,
+                          const TargetRegisterInfo *TRI,
+                          const MachineFunction &MF) const {
+  auto *RC = TargetInstrInfo::getRegClass(MCID, OpNum, TRI, MF);
+  // If the target does not have egpr, then r16-r31 will be resereved for all
+  // instructions.
+  if (!RC || !Subtarget.hasEGPR())
+    return RC;
+
+  if (X86II::canUseApxExtendedReg(MCID))
+    return RC;
+
+  switch (RC->getID()) {
+  default:
----------------
KanRobert wrote:

`GR*ABCD`s are not affected at all b/c they only includes `RAX, RCX, RDX, RBX`

https://github.com/llvm/llvm-project/pull/67702


More information about the llvm-commits mailing list