[llvm-branch-commits] [llvm] AMDGPU: Move default wavesize hack for disassembler (PR #117422)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Nov 22 21:55:14 PST 2024
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/117422
You cannot adjust the disassembler's subtarget. llvm-mc passes
the originally constructed MCSubtargetInfo around, rather than
querying the pointer in the disassembler instance.
>From bccd64648635ab9cdab25bfe3c910edc7f1adff0 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 22 Nov 2024 20:17:48 -0800
Subject: [PATCH] AMDGPU: Move default wavesize hack for disassembler
You cannot adjust the disassembler's subtarget. llvm-mc passes
the originally constructed MCSubtargetInfo around, rather than
querying the pointer in the disassembler instance.
---
.../Disassembler/AMDGPUDisassembler.cpp | 20 ++-----------------
.../MCTargetDesc/AMDGPUMCTargetDesc.cpp | 17 +++++++++++++++-
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
index f90121a86c846c..7817c5ff5acc0a 100644
--- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
+++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp
@@ -45,26 +45,10 @@ using namespace llvm;
using DecodeStatus = llvm::MCDisassembler::DecodeStatus;
-static const MCSubtargetInfo &addDefaultWaveSize(const MCSubtargetInfo &STI,
- MCContext &Ctx) {
- if (!STI.hasFeature(AMDGPU::FeatureWavefrontSize64) &&
- !STI.hasFeature(AMDGPU::FeatureWavefrontSize32)) {
- MCSubtargetInfo &STICopy = Ctx.getSubtargetCopy(STI);
- // If there is no default wave size it must be a generation before gfx10,
- // these have FeatureWavefrontSize64 in their definition already. For gfx10+
- // set wave32 as a default.
- STICopy.ToggleFeature(AMDGPU::FeatureWavefrontSize32);
- return STICopy;
- }
-
- return STI;
-}
-
AMDGPUDisassembler::AMDGPUDisassembler(const MCSubtargetInfo &STI,
MCContext &Ctx, MCInstrInfo const *MCII)
- : MCDisassembler(addDefaultWaveSize(STI, Ctx), Ctx), MCII(MCII),
- MRI(*Ctx.getRegisterInfo()), MAI(*Ctx.getAsmInfo()),
- TargetMaxInstBytes(MAI.getMaxInstLength(&STI)),
+ : MCDisassembler(STI, Ctx), MCII(MCII), MRI(*Ctx.getRegisterInfo()),
+ MAI(*Ctx.getAsmInfo()), TargetMaxInstBytes(MAI.getMaxInstLength(&STI)),
CodeObjectVersion(AMDGPU::getDefaultAMDHSACodeObjectVersion()) {
// ToDo: AMDGPUDisassembler supports only VI ISA.
if (!STI.hasFeature(AMDGPU::FeatureGCN3Encoding) && !isGFX10Plus())
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp
index 29be64625811f7..c692895d84c002 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp
@@ -77,7 +77,22 @@ static MCSubtargetInfo *
createAMDGPUMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS) {
if (TT.getArch() == Triple::r600)
return createR600MCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
- return createAMDGPUMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
+
+ MCSubtargetInfo *STI =
+ createAMDGPUMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
+
+ // FIXME: We should error for the default target.
+ if (!STI->hasFeature(AMDGPU::FeatureWavefrontSize64) &&
+ !STI->hasFeature(AMDGPU::FeatureWavefrontSize32)) {
+ // If there is no default wave size it must be a generation before gfx10,
+ // these have FeatureWavefrontSize64 in their definition already. For gfx10+
+ // set wave32 as a default.
+ STI->ToggleFeature(AMDGPU::isGFX10Plus(*STI)
+ ? AMDGPU::FeatureWavefrontSize32
+ : AMDGPU::FeatureWavefrontSize64);
+ }
+
+ return STI;
}
static MCInstPrinter *createAMDGPUMCInstPrinter(const Triple &T,
More information about the llvm-branch-commits
mailing list