Skip to content

Conversation

@lancesix
Copy link
Contributor

Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32, s_setreg_imm32_b32 instructions.

@llvmbot
Copy link
Member

llvmbot commented Nov 27, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: None (lancesix)

Changes

Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32, s_setreg_imm32_b32 instructions.


Full diff: https://github.com/llvm/llvm-project/pull/169840.diff

3 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/SIDefines.h (+1)
  • (modified) llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp (+1)
  • (modified) llvm/test/MC/AMDGPU/gfx12_asm_sopk.s (+9)
diff --git a/llvm/lib/Target/AMDGPU/SIDefines.h b/llvm/lib/Target/AMDGPU/SIDefines.h
index b7a92a0a1d634..192e1a0d7a812 100644
--- a/llvm/lib/Target/AMDGPU/SIDefines.h
+++ b/llvm/lib/Target/AMDGPU/SIDefines.h
@@ -541,6 +541,7 @@ enum Id { // HwRegCode, (6) [5:0]
   ID_EXCP_FLAG_PRIV = 17,
   ID_EXCP_FLAG_USER = 18,
   ID_TRAP_CTRL = 19,
+  ID_SCHED_MODE = 26,
 
   // GFX94* specific registers
   ID_XCC_ID = 20,
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
index 6489e63d4f6b8..24d139b73d2b1 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUAsmUtils.cpp
@@ -208,6 +208,7 @@ static constexpr CustomOperand Operands[] = {
   {{"HW_REG_HW_ID"},                  ID_HW_ID1,                      isGFX10},
   {{"HW_REG_SQ_PERF_SNAPSHOT_PC_LO"}, ID_SQ_PERF_SNAPSHOT_PC_LO,      isGFX940},
   {{"HW_REG_WAVE_HW_ID2"},            ID_HW_ID2,                      isGFX12Plus},
+  {{"HW_REG_WAVE_SCHED_MODE"},        ID_SCHED_MODE,                  isGFX12Plus},
   {{"HW_REG_HW_ID2"},                 ID_HW_ID2,                      isGFX10Plus},
   {{"HW_REG_SQ_PERF_SNAPSHOT_PC_HI"}, ID_SQ_PERF_SNAPSHOT_PC_HI,      isGFX940},
   {{"HW_REG_POPS_PACKER"},            ID_POPS_PACKER,                 isGFX10},
diff --git a/llvm/test/MC/AMDGPU/gfx12_asm_sopk.s b/llvm/test/MC/AMDGPU/gfx12_asm_sopk.s
index 819ecb866c5ae..ba5159482df50 100644
--- a/llvm/test/MC/AMDGPU/gfx12_asm_sopk.s
+++ b/llvm/test/MC/AMDGPU/gfx12_asm_sopk.s
@@ -258,3 +258,12 @@ s_getreg_b32 s0, hwreg(HW_REG_SHADER_CYCLES_LO)
 
 s_getreg_b32 s0, hwreg(HW_REG_SHADER_CYCLES_HI)
 // GFX12: encoding: [0x1e,0xf8,0x80,0xb8]
+
+s_getreg_b32 s0, hwreg(HW_REG_WAVE_SCHED_MODE)
+// GFX12: encoding: [0x1a,0xf8,0x80,0xb8]
+
+s_setreg_b32 hwreg(HW_REG_WAVE_SCHED_MODE, 0, 2), s2
+// GFX12: encoding: [0x1a,0x08,0x02,0xb9]
+
+s_setreg_imm32_b32 hwreg(HW_REG_WAVE_SCHED_MODE), 0x2
+// GFX12: encoding: [0x1a,0xf8,0x80,0xb9,0x02,0x00,0x00,0x00]

@github-actions
Copy link

github-actions bot commented Nov 27, 2025

🐧 Linux x64 Test Results

  • 186669 tests passed
  • 4890 tests skipped

@lancesix lancesix force-pushed the users/lancesix/sched-mem branch 2 times, most recently from 7859ef2 to 35b3d7b Compare November 27, 2025 18:35
@lancesix lancesix requested a review from jayfoad November 27, 2025 18:36
Copy link
Contributor

@jayfoad jayfoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@scchan scchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ronlieb
Copy link
Contributor

ronlieb commented Nov 27, 2025

builders seem to be detecting errors in lit tests
Failed Tests (5):
LLVM :: MC/AMDGPU/gfx942_asm_features.s
LLVM :: MC/AMDGPU/sopk-err.s
LLVM :: MC/AMDGPU/sopk.s
LLVM :: MC/Disassembler/AMDGPU/gfx11_dasm_sopk.txt
LLVM :: MC/Disassembler/AMDGPU/gfx942_features.txt

Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.
@lancesix lancesix force-pushed the users/lancesix/sched-mem branch from 1013c5b to 7ab6454 Compare November 28, 2025 14:19
@ronlieb ronlieb merged commit 78defc8 into llvm:main Nov 28, 2025
10 checks passed
ronlieb pushed a commit to ROCm/llvm-project that referenced this pull request Nov 28, 2025
Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.
ronlieb pushed a commit to ROCm/llvm-project that referenced this pull request Nov 28, 2025
Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.
ronlieb added a commit to ROCm/llvm-project that referenced this pull request Nov 29, 2025
Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.

Co-authored-by: lancesix <lancelot.six@amd.com>
aahrun pushed a commit to aahrun/llvm-project that referenced this pull request Dec 1, 2025
Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.
augusto2112 pushed a commit to augusto2112/llvm-project that referenced this pull request Dec 3, 2025
Expose HW_REG_WAVE_SCHED_MODE to the s_getreg_b32, s_setreg_b32,
s_setreg_imm32_b32 instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants