Skip to content

Commit

Permalink
[AMDGPU] New intrinsic void llvm.amdgcn.s.nop(i16) (#65757)
Browse files Browse the repository at this point in the history
This allows front ends to insert s_nops - this is most often when a
delay less
than s_sleep 1 is required.
  • Loading branch information
dstutt authored Sep 8, 2023
1 parent ffb8434 commit 8c03239
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 5 additions & 0 deletions llvm/include/llvm/IR/IntrinsicsAMDGPU.td
Original file line number Diff line number Diff line change
Expand Up @@ -1677,6 +1677,11 @@ def int_amdgcn_s_sleep :
IntrHasSideEffects]> {
}

def int_amdgcn_s_nop :
DefaultAttrsIntrinsic<[], [llvm_i16_ty], [ImmArg<ArgIndex<0>>, IntrNoMem,
IntrHasSideEffects]> {
}

def int_amdgcn_s_incperflevel :
ClangBuiltin<"__builtin_amdgcn_s_incperflevel">,
DefaultAttrsIntrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>, IntrNoMem,
Expand Down
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/SOPInstructions.td
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,8 @@ multiclass SOPP_With_Relaxation <string opName, dag ins,
def _pad_s_nop : SOPP_Pseudo <opName # "_pad_s_nop", ins, asmOps, pattern, " ", opName>;
}

def S_NOP : SOPP_Pseudo<"s_nop" , (ins i16imm:$simm16), "$simm16"> {
def S_NOP : SOPP_Pseudo<"s_nop" , (ins i16imm:$simm16), "$simm16",
[(int_amdgcn_s_nop timm:$simm16)]> {
let hasSideEffects = 1;
}

Expand Down
30 changes: 30 additions & 0 deletions llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.nop.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
; RUN: llc -global-isel -march=amdgcn -mcpu=gfx900 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s

define amdgpu_kernel void @test_s_nop() {
; GCN-LABEL: test_s_nop:
; GCN: ; %bb.0:
; GCN-NEXT: s_nop 0
; GCN-NEXT: s_nop 1
; GCN-NEXT: s_nop 2
; GCN-NEXT: s_nop 3
; GCN-NEXT: s_nop 4
; GCN-NEXT: s_nop 5
; GCN-NEXT: s_nop 6
; GCN-NEXT: s_nop 7
; GCN-NEXT: s_nop 63
; GCN-NEXT: s_endpgm
call void @llvm.amdgcn.s.nop(i16 0)
call void @llvm.amdgcn.s.nop(i16 1)
call void @llvm.amdgcn.s.nop(i16 2)
call void @llvm.amdgcn.s.nop(i16 3)
call void @llvm.amdgcn.s.nop(i16 4)
call void @llvm.amdgcn.s.nop(i16 5)
call void @llvm.amdgcn.s.nop(i16 6)
call void @llvm.amdgcn.s.nop(i16 7)
call void @llvm.amdgcn.s.nop(i16 63)
ret void
}

declare void @llvm.amdgcn.s.nop(i16)

0 comments on commit 8c03239

Please sign in to comment.