[PATCH] D156100: [AMDGPU] Have a command-line flag to enable true True16 codegen.
Ivan Kosarev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 03:57:23 PDT 2023
kosarev created this revision.
kosarev added reviewers: arsenm, rampitec, Joe_Nash, foad.
Herald added subscribers: StephenFan, kerbowa, hiraditya, tpr, dstuttard, yaxunl, jvesely, kzhuravl.
Herald added a project: All.
kosarev requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156100
Files:
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Index: llvm/lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIISelLowering.cpp
+++ llvm/lib/Target/AMDGPU/SIISelLowering.cpp
@@ -146,8 +146,13 @@
addRegisterClass(MVT::v16f64, TRI->getVGPRClassForBitWidth(1024));
if (Subtarget->has16BitInsts()) {
- addRegisterClass(MVT::i16, &AMDGPU::SReg_32RegClass);
- addRegisterClass(MVT::f16, &AMDGPU::SReg_32RegClass);
+ if (Subtarget->useTrue16BitInsts()) {
+ addRegisterClass(MVT::i16, &AMDGPU::VGPR_16RegClass);
+ addRegisterClass(MVT::f16, &AMDGPU::VGPR_16RegClass);
+ } else {
+ addRegisterClass(MVT::i16, &AMDGPU::SReg_32RegClass);
+ addRegisterClass(MVT::f16, &AMDGPU::SReg_32RegClass);
+ }
// Unless there are also VOP3P operations, not operations are really legal.
addRegisterClass(MVT::v2i16, &AMDGPU::SReg_32RegClass);
Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
+++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.h
@@ -155,6 +155,10 @@
bool hasTrue16BitInsts() const { return HasTrue16BitInsts; }
+ // TODO: Remove and use hasTrue16BitInsts() instead once True16 is
+ // fully supported.
+ bool useTrue16BitInsts() const;
+
bool hasMadMixInsts() const {
return HasMadMixInsts;
}
Index: llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
@@ -58,6 +58,10 @@
cl::desc("Number of addresses from which to enable MIMG NSA."),
cl::init(3), cl::Hidden);
+static cl::opt<bool> EnableTrue16Codegen("amdgpu-true16",
+ cl::desc("Use true 16-bit registers"),
+ cl::init(false), cl::ReallyHidden);
+
GCNSubtarget::~GCNSubtarget() = default;
GCNSubtarget &
@@ -166,6 +170,10 @@
AMDGPUSubtarget::AMDGPUSubtarget(const Triple &TT) : TargetTriple(TT) {}
+bool AMDGPUSubtarget::useTrue16BitInsts() const {
+ return hasTrue16BitInsts() && EnableTrue16Codegen;
+}
+
GCNSubtarget::GCNSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
const GCNTargetMachine &TM)
: // clang-format off
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156100.543462.patch
Type: text/x-patch
Size: 2448 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230724/315d2afc/attachment.bin>
More information about the llvm-commits
mailing list