Skip to content

Commit 87eb7a4

Browse files
committed
[NFC][SYCL][SYCLLowerIR] Add cl::opt SpecConstantMode for LIT testing
This allows testing SpecConstantsPass with different modes.
1 parent 439ec9e commit 87eb7a4

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

llvm/lib/SYCLLowerIR/SpecConstants.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@
2929

3030
using namespace llvm;
3131

32+
static cl::opt<SpecConstantsPass::HandlingMode> SpecConstantMode(
33+
"spec-constant-mode", cl::Optional, cl::Hidden,
34+
cl::desc("Spec constant handling mode"),
35+
cl::values(
36+
clEnumValN(SpecConstantsPass::HandlingMode::default_values,
37+
"default_values",
38+
"spec constant uses are replaced by default values"),
39+
clEnumValN(SpecConstantsPass::HandlingMode::emulation, "emulation",
40+
"spec constant intrinsics are replaced by RT buffers"),
41+
clEnumValN(
42+
SpecConstantsPass::HandlingMode::native, "native",
43+
"spec constant intrinsics are lowered to spirv intrinsics")));
44+
3245
namespace {
3346

3447
// __sycl* intrinsic names are Itanium ABI-mangled; this is common prefix for
@@ -827,6 +840,9 @@ PreservedAnalyses SpecConstantsPass::run(Module &M,
827840
MapVector<StringRef, MDNode *> SCMetadata;
828841
SmallVector<MDNode *, 4> DefaultsMetadata;
829842

843+
if (SpecConstantMode.getNumOccurrences() > 0)
844+
Mode = SpecConstantMode;
845+
830846
// Iterate through all declarations of instances of function template
831847
// template <typename T> T __sycl_get*SpecConstantValue(const char *ID)
832848
// intrinsic to find its calls and lower them depending on the HandlingMode.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
; RUN: sycl-post-link -properties -split=auto -spec-const=native -S -o %t.table %s -generate-device-image-default-spec-consts
2-
; RUN: FileCheck %s -input-file %t_1.ll --implicit-check-not="SpecConst"
1+
; RUN: opt -passes=spec-constants -spec-constant-mode=default_values %s -S -o - | FileCheck %s
32

4-
; This test checks that the post link tool is able to correctly transform
3+
; This test checks that SpecConstantsPass is able to correctly transform
54
; SYCL alloca intrinsics in SPIR-V devices when using default values.
65

76
%"class.sycl::_V1::specialization_id" = type { i64 }
@@ -20,9 +19,9 @@
2019
define spir_kernel void @private_alloca() {
2120
; CHECK: alloca double, i32 120, align 8
2221
call ptr @llvm.sycl.alloca.p0.p4.p4.p4.f64(ptr addrspace(4) addrspacecast (ptr @size_i32_stable_name to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @size_i32 to ptr addrspace(4)), ptr addrspace(4) null, double 0.000000e+00, i64 8)
23-
; CHECK: alloca float, i64 10, align 8
22+
; CHECK-NEXT: alloca float, i64 10, align 8
2423
call ptr @llvm.sycl.alloca.p0.p4.p4.p4.f32(ptr addrspace(4) addrspacecast (ptr @size_i64_stable_name to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @size_i64 to ptr addrspace(4)), ptr addrspace(4) null, float 0.000000e+00, i64 8)
25-
; CHECK: alloca %my_range, i16 1, align 64
24+
; CHECK-NEXT: alloca %my_range, i16 1, align 64
2625
call ptr @llvm.sycl.alloca.p0.p4.p4.p4.s_my_range(ptr addrspace(4) addrspacecast (ptr @size_i16_stable_name to ptr addrspace(4)), ptr addrspace(4) addrspacecast (ptr addrspace(1) @size_i16 to ptr addrspace(4)), ptr addrspace(4) null, %my_range zeroinitializer, i64 64)
2726
ret void
2827
}

0 commit comments

Comments
 (0)