diff --git a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td --- a/llvm/include/llvm/IR/IntrinsicsAMDGPU.td +++ b/llvm/include/llvm/IR/IntrinsicsAMDGPU.td @@ -1329,6 +1329,11 @@ Intrinsic<[], [llvm_i32_ty], [ImmArg>, IntrNoMem, IntrHasSideEffects, IntrWillReturn]>; +def int_amdgcn_s_setprio : + GCCBuiltin<"__builtin_amdgcn_s_setprio">, + Intrinsic<[], [llvm_i32_ty], [ImmArg>, IntrNoMem, + IntrHasSideEffects, IntrWillReturn]>; + def int_amdgcn_s_getreg : GCCBuiltin<"__builtin_amdgcn_s_getreg">, Intrinsic<[llvm_i32_ty], [llvm_i32_ty], diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td --- a/llvm/lib/Target/AMDGPU/SOPInstructions.td +++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td @@ -1279,7 +1279,10 @@ let hasSideEffects = 1; } -def S_SETPRIO : SOPP_Pseudo <"s_setprio" , (ins i16imm:$simm16), "$simm16">; +def S_SETPRIO : SOPP_Pseudo <"s_setprio", (ins i32imm:$simm16), "$simm16", + [(int_amdgcn_s_setprio timm:$simm16)]> { + let hasSideEffects = 1; +} let Uses = [EXEC, M0] in { // FIXME: Should this be mayLoad+mayStore? diff --git a/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/llvm.amdgcn.s.setprio.ll @@ -0,0 +1,33 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s +; RUN: llc -march=amdgcn -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s +; RUN: llc -global-isel -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s +; RUN: llc -global-isel -march=amdgcn -mcpu=gfx90a -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s + +declare void @llvm.amdgcn.s.setprio(i32) #0 + +define void @test_llvm_amdgcn_s_setprio() #0 { +; GCN-LABEL: test_llvm_amdgcn_s_setprio: +; GCN: ; %bb.0: +; GCN-NEXT: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) +; GCN-NEXT: s_setprio 0 +; GCN-NEXT: s_setprio 1 +; GCN-NEXT: s_setprio 2 +; GCN-NEXT: s_setprio 3 +; GCN-NEXT: s_setprio 10 +; GCN-NEXT: s_setprio 0xffff +; GCN-NEXT: s_setprio 0x10000 +; GCN-NEXT: s_setprio -1 +; GCN-NEXT: s_setpc_b64 s[30:31] + call void @llvm.amdgcn.s.setprio(i32 0) + call void @llvm.amdgcn.s.setprio(i32 1) + call void @llvm.amdgcn.s.setprio(i32 2) + call void @llvm.amdgcn.s.setprio(i32 3) + call void @llvm.amdgcn.s.setprio(i32 10) + call void @llvm.amdgcn.s.setprio(i32 65535) + call void @llvm.amdgcn.s.setprio(i32 65536) + call void @llvm.amdgcn.s.setprio(i32 -1) + ret void +} + +attributes #0 = { nounwind }