[llvm] 4e312ab - [AMDGPU][NFC] Add a getRegBitWidth() helper for TargetRegisterClass operands.
Ivan Kosarev via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 7 03:41:19 PDT 2023
Author: Ivan Kosarev
Date: 2023-06-07T11:41:11+01:00
New Revision: 4e312abdfd4fb9d60afe6590588092ba0bfb23c9
URL: https://github.com/llvm/llvm-project/commit/4e312abdfd4fb9d60afe6590588092ba0bfb23c9
DIFF: https://github.com/llvm/llvm-project/commit/4e312abdfd4fb9d60afe6590588092ba0bfb23c9.diff
LOG: [AMDGPU][NFC] Add a getRegBitWidth() helper for TargetRegisterClass operands.
Reviewed By: foad
Differential Revision: https://reviews.llvm.org/D152257
Added:
Modified:
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
index d33778dcdce48..713e6e38857fc 100644
--- a/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
+++ b/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp
@@ -908,11 +908,10 @@ void SIFoldOperands::foldOperand(
TRI->getRegClass(FoldDesc.operands()[0].RegClass);
// Split 64-bit constants into 32-bits for folding.
- if (UseOp.getSubReg() && AMDGPU::getRegBitWidth(FoldRC->getID()) == 64) {
+ if (UseOp.getSubReg() && AMDGPU::getRegBitWidth(*FoldRC) == 64) {
Register UseReg = UseOp.getReg();
const TargetRegisterClass *UseRC = MRI->getRegClass(UseReg);
-
- if (AMDGPU::getRegBitWidth(UseRC->getID()) != 64)
+ if (AMDGPU::getRegBitWidth(*UseRC) != 64)
return;
APInt Imm(64, OpToFold.getImm());
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 399b18ec35ca0..1e3e518cb0a6f 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -2882,7 +2882,7 @@ bool SIInstrInfo::canInsertSelect(const MachineBasicBlock &MBB,
if (MRI.getRegClass(FalseReg) != RC)
return false;
- int NumInsts = AMDGPU::getRegBitWidth(RC->getID()) / 32;
+ int NumInsts = AMDGPU::getRegBitWidth(*RC) / 32;
CondCycles = TrueCycles = FalseCycles = NumInsts; // ???
// Limit to equal cost for branch vs. N v_cndmask_b32s.
@@ -2897,7 +2897,7 @@ bool SIInstrInfo::canInsertSelect(const MachineBasicBlock &MBB,
if (MRI.getRegClass(FalseReg) != RC)
return false;
- int NumInsts = AMDGPU::getRegBitWidth(RC->getID()) / 32;
+ int NumInsts = AMDGPU::getRegBitWidth(*RC) / 32;
// Multiples of 8 can do s_cselect_b64
if (NumInsts % 2 == 0)
diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
index 04bab9a3985d0..d750088e12f15 100644
--- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.cpp
@@ -1310,7 +1310,7 @@ void SIRegisterInfo::buildSpillLoadStore(
const TargetRegisterClass *RC = getRegClassForReg(MF->getRegInfo(), ValueReg);
// On gfx90a+ AGPR is a regular VGPR acceptable for loads and stores.
const bool IsAGPR = !ST.hasGFX90AInsts() && isAGPRClass(RC);
- const unsigned RegWidth = AMDGPU::getRegBitWidth(RC->getID()) / 8;
+ const unsigned RegWidth = AMDGPU::getRegBitWidth(*RC) / 8;
// Always use 4 byte operations for AGPRs because we need to scavenge
// a temporary VGPR.
@@ -2904,7 +2904,7 @@ bool SIRegisterInfo::isUniformReg(const MachineRegisterInfo &MRI,
ArrayRef<int16_t> SIRegisterInfo::getRegSplitParts(const TargetRegisterClass *RC,
unsigned EltSize) const {
- const unsigned RegBitWidth = AMDGPU::getRegBitWidth(*RC->MC);
+ const unsigned RegBitWidth = AMDGPU::getRegBitWidth(*RC);
assert(RegBitWidth >= 32 && RegBitWidth <= 1024);
const unsigned RegDWORDs = RegBitWidth / 32;
@@ -3209,4 +3209,4 @@ SIRegisterInfo::getSubRegAlignmentNumBits(const TargetRegisterClass *RC,
break;
}
return 0;
-}
\ No newline at end of file
+}
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
index e7d970fbe87ee..ef927c55128a6 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.cpp
@@ -12,6 +12,7 @@
#include "AMDKernelCodeT.h"
#include "MCTargetDesc/AMDGPUMCTargetDesc.h"
#include "llvm/BinaryFormat/ELF.h"
+#include "llvm/CodeGen/TargetRegisterInfo.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/Function.h"
@@ -2367,11 +2368,15 @@ unsigned getRegBitWidth(const MCRegisterClass &RC) {
return getRegBitWidth(RC.getID());
}
+unsigned getRegBitWidth(const TargetRegisterClass &RC) {
+ return getRegBitWidth(RC.getID());
+}
+
unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc,
unsigned OpNo) {
assert(OpNo < Desc.NumOperands);
unsigned RCID = Desc.operands()[OpNo].RegClass;
- return getRegBitWidth(MRI->getRegClass(RCID)) / 8;
+ return getRegBitWidth(RCID) / 8;
}
bool isInlinableLiteral64(int64_t Literal, bool HasInv2Pi) {
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
index b68e47a961d64..b0ac6cea16263 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUBaseInfo.h
@@ -31,6 +31,7 @@ class MCRegisterClass;
class MCRegisterInfo;
class MCSubtargetInfo;
class StringRef;
+class TargetRegisterClass;
class Triple;
class raw_ostream;
@@ -1178,6 +1179,9 @@ unsigned getRegBitWidth(unsigned RCID);
/// Get the size in bits of a register from the register class \p RC.
unsigned getRegBitWidth(const MCRegisterClass &RC);
+/// Get the size in bits of a register from the register class \p RC.
+unsigned getRegBitWidth(const TargetRegisterClass &RC);
+
/// Get size of register operand
unsigned getRegOperandSize(const MCRegisterInfo *MRI, const MCInstrDesc &Desc,
unsigned OpNo);
More information about the llvm-commits
mailing list