[clang] [AMDGPU] Add GFX11.5 s_singleuse_vdst instruction (PR #67536)
Jay Foad via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 29 06:30:45 PDT 2023
https://github.com/jayfoad updated https://github.com/llvm/llvm-project/pull/67536
>From e0571e8b4712e39678218f02d7f5d68755bc85f9 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 27 Sep 2023 11:01:17 +0100
Subject: [PATCH] [AMDGPU] Add GFX11.5 s_singleuse_vdst instruction
---
llvm/lib/Target/AMDGPU/AMDGPU.td | 13 ++++++++++++-
llvm/lib/Target/AMDGPU/GCNSubtarget.h | 3 +++
llvm/lib/Target/AMDGPU/SOPInstructions.td | 11 +++++++++++
llvm/test/MC/AMDGPU/gfx1150_asm_sopp.s | 10 ++++++++++
llvm/test/MC/AMDGPU/gfx11_unsupported.s | 3 +++
llvm/test/MC/Disassembler/AMDGPU/decode-err.txt | 4 ++++
.../MC/Disassembler/AMDGPU/gfx1150_dasm_sopp.txt | 10 ++++++++++
7 files changed, 53 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/MC/AMDGPU/gfx1150_asm_sopp.s
create mode 100644 llvm/test/MC/Disassembler/AMDGPU/gfx1150_dasm_sopp.txt
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.td b/llvm/lib/Target/AMDGPU/AMDGPU.td
index d5356d1be3d758a..cdf7ca15b4c5fbc 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -791,6 +791,12 @@ def FeatureSALUFloatInsts : SubtargetFeature<"salu-float",
"Has SALU floating point instructions"
>;
+def FeatureVGPRSingleUseHintInsts : SubtargetFeature<"vgpr-singleuse-hint",
+ "HasVGPRSingleUseHintInsts",
+ "true",
+ "Has single-use VGPR hint instructions"
+>;
+
//===------------------------------------------------------------===//
// Subtarget Features (options and debugging)
//===------------------------------------------------------------===//
@@ -1383,11 +1389,13 @@ def FeatureISAVersion11_0_3 : FeatureSet<
def FeatureISAVersion11_5_0 : FeatureSet<
!listconcat(FeatureISAVersion11_Common.Features,
- [FeatureSALUFloatInsts])>;
+ [FeatureSALUFloatInsts,
+ FeatureVGPRSingleUseHintInsts])>;
def FeatureISAVersion11_5_1 : FeatureSet<
!listconcat(FeatureISAVersion11_Common.Features,
[FeatureSALUFloatInsts,
+ FeatureVGPRSingleUseHintInsts,
FeatureGFX11FullVGPRs])>;
//===----------------------------------------------------------------------===//
@@ -1901,6 +1909,9 @@ def HasNotMADIntraFwdBug : Predicate<"!Subtarget->hasMADIntraFwdBug()">;
def HasSALUFloatInsts : Predicate<"Subtarget->hasSALUFloatInsts()">,
AssemblerPredicate<(all_of FeatureSALUFloatInsts)>;
+def HasVGPRSingleUseHintInsts : Predicate<"Subtarget->hasVGPRSingleUseHintInsts()">,
+ AssemblerPredicate<(all_of FeatureVGPRSingleUseHintInsts)>;
+
def HasGDS : Predicate<"Subtarget->hasGDS()">;
def HasGWS : Predicate<"Subtarget->hasGWS()">;
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.h b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
index f60938d830fcc43..1a6479cc8baa587 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.h
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.h
@@ -193,6 +193,7 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
bool HasPackedTID = false;
bool ScalarizeGlobal = false;
bool HasSALUFloatInsts = false;
+ bool HasVGPRSingleUseHintInsts = false;
bool HasVcmpxPermlaneHazard = false;
bool HasVMEMtoScalarWriteHazard = false;
@@ -1142,6 +1143,8 @@ class GCNSubtarget final : public AMDGPUGenSubtargetInfo,
bool hasSALUFloatInsts() const { return HasSALUFloatInsts; }
+ bool hasVGPRSingleUseHintInsts() const { return HasVGPRSingleUseHintInsts; }
+
/// Return the maximum number of waves per SIMD for kernels using \p SGPRs
/// SGPRs
unsigned getOccupancyWithNumSGPRs(unsigned SGPRs) const;
diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td
index 90b89e9ed4055ae..f3309049e7a7fd9 100644
--- a/llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -1558,6 +1558,11 @@ let SubtargetPredicate = isGFX11Plus in {
"$simm16">;
} // End SubtargetPredicate = isGFX11Plus
+let SubtargetPredicate = HasVGPRSingleUseHintInsts in {
+ def S_SINGLEUSE_VDST :
+ SOPP_Pseudo<"s_singleuse_vdst", (ins s16imm:$simm16), "$simm16">;
+} // End SubtargetPredicate = HasVGPRSingeUseHintInsts
+
//===----------------------------------------------------------------------===//
// SOP1 Patterns
//===----------------------------------------------------------------------===//
@@ -2267,6 +2272,12 @@ defm S_TTRACEDATA_IMM : SOPP_Real_32_gfx11<0x03b>;
defm S_ICACHE_INV : SOPP_Real_32_gfx11<0x03c>;
defm S_BARRIER : SOPP_Real_32_gfx11<0x03d>;
+//===----------------------------------------------------------------------===//
+// SOPP - GFX1150
+//===----------------------------------------------------------------------===//
+
+defm S_SINGLEUSE_VDST : SOPP_Real_32_gfx11<0x013>;
+
//===----------------------------------------------------------------------===//
// SOPP - GFX6, GFX7, GFX8, GFX9, GFX10
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/MC/AMDGPU/gfx1150_asm_sopp.s b/llvm/test/MC/AMDGPU/gfx1150_asm_sopp.s
new file mode 100644
index 000000000000000..463e9cade7f9c0c
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/gfx1150_asm_sopp.s
@@ -0,0 +1,10 @@
+// RUN: llvm-mc -arch=amdgcn -mcpu=gfx1150 -show-encoding %s | FileCheck --check-prefixes=GFX1150 %s
+
+s_singleuse_vdst 0x0000
+// GFX1150: encoding: [0x00,0x00,0x93,0xbf]
+
+s_singleuse_vdst 0xffff
+// GFX1150: encoding: [0xff,0xff,0x93,0xbf]
+
+s_singleuse_vdst 0x1234
+// GFX1150: encoding: [0x34,0x12,0x93,0xbf]
diff --git a/llvm/test/MC/AMDGPU/gfx11_unsupported.s b/llvm/test/MC/AMDGPU/gfx11_unsupported.s
index 5e9714be224edcf..3b1b7e47b2143cb 100644
--- a/llvm/test/MC/AMDGPU/gfx11_unsupported.s
+++ b/llvm/test/MC/AMDGPU/gfx11_unsupported.s
@@ -1980,3 +1980,6 @@ s_cmp_neq_f16 s1, s2
s_cmp_nlt_f16 s1, s2
// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
+
+s_singleuse_vdst 0x1234
+// CHECK: :[[@LINE-1]]:{{[0-9]+}}: error: instruction not supported on this GPU
diff --git a/llvm/test/MC/Disassembler/AMDGPU/decode-err.txt b/llvm/test/MC/Disassembler/AMDGPU/decode-err.txt
index 8da7e5ac2d88b38..bf2c55ef2e77b2b 100644
--- a/llvm/test/MC/Disassembler/AMDGPU/decode-err.txt
+++ b/llvm/test/MC/Disassembler/AMDGPU/decode-err.txt
@@ -5,6 +5,10 @@
# GCN: warning: invalid instruction encoding
0xdf,0x00,0x00,0x02
+# this is s_singleuse_vdst 0x1234, which is only valid on gfx1150
+# GFX11: warning: invalid instruction encoding
+0x34,0x12,0x93,0xbf
+
# this is buffer_atomic_csub_u32 v5, off, s[8:11], s3 offset:4095. Invalid without glc
# GFX11: warning: invalid instruction encoding
0xff,0x0f,0xdc,0xe0,0x00,0x05,0x02,0x03
diff --git a/llvm/test/MC/Disassembler/AMDGPU/gfx1150_dasm_sopp.txt b/llvm/test/MC/Disassembler/AMDGPU/gfx1150_dasm_sopp.txt
new file mode 100644
index 000000000000000..ddeb70a55969796
--- /dev/null
+++ b/llvm/test/MC/Disassembler/AMDGPU/gfx1150_dasm_sopp.txt
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -arch=amdgcn -mcpu=gfx1150 -disassemble -show-encoding < %s | FileCheck -check-prefixes=GFX1150 %s
+
+# GFX1150: s_singleuse_vdst 0x0 ; encoding: [0x00,0x00,0x93,0xbf]
+0x00,0x00,0x93,0xbf
+
+# GFX1150: s_singleuse_vdst 0xffff ; encoding: [0xff,0xff,0x93,0xbf]
+0xff,0xff,0x93,0xbf
+
+# GFX1150: s_singleuse_vdst 0x1234 ; encoding: [0x34,0x12,0x93,0xbf]
+0x34,0x12,0x93,0xbf
More information about the cfe-commits
mailing list