File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -4552,6 +4552,14 @@ bool SPIRVToLLVM::transMetadata() {
4552
4552
if (auto *EM = BF->getExecutionMode (ExecutionModeLocalSize)) {
4553
4553
F->setMetadata (kSPIR2MD ::WGSize,
4554
4554
getMDNodeStringIntVec (Context, EM->getLiterals ()));
4555
+ } else if (auto *EM = BF->getExecutionModeId (ExecutionModeLocalSizeId)) {
4556
+ std::vector<SPIRVWord> Values;
4557
+ for (const auto Id : EM->getLiterals ()) {
4558
+ if (auto Val = transIdAsConstant (Id)) {
4559
+ Values.emplace_back (static_cast <SPIRVWord>(*Val));
4560
+ }
4561
+ }
4562
+ F->setMetadata (kSPIR2MD ::WGSize, getMDNodeStringIntVec (Context, Values));
4555
4563
}
4556
4564
// Generate metadata for work_group_size_hint
4557
4565
if (auto *EM = BF->getExecutionMode (ExecutionModeLocalSizeHint)) {
Original file line number Diff line number Diff line change @@ -656,6 +656,7 @@ void SPIRVExecutionMode::decode(std::istream &I) {
656
656
getDecoder (I) >> Target >> ExecMode;
657
657
switch (static_cast <uint32_t >(ExecMode)) {
658
658
case ExecutionModeLocalSize:
659
+ case ExecutionModeLocalSizeId:
659
660
case ExecutionModeLocalSizeHint:
660
661
case ExecutionModeMaxWorkgroupSizeINTEL:
661
662
WordLiterals.resize (3 );
Original file line number Diff line number Diff line change @@ -807,6 +807,12 @@ class SPIRVComponentExecutionModes {
807
807
return nullptr ;
808
808
return Loc->second ;
809
809
}
810
+ SPIRVExecutionModeId *getExecutionModeId (SPIRVExecutionModeKind EMK) const {
811
+ auto Loc = ExecModes.find (EMK);
812
+ if (Loc == ExecModes.end ())
813
+ return nullptr ;
814
+ return static_cast <SPIRVExecutionModeId *>(Loc->second );
815
+ }
810
816
SPIRVExecutionModeRange
811
817
getExecutionModeRange (SPIRVExecutionModeKind EMK) const {
812
818
return ExecModes.equal_range (EMK);
Original file line number Diff line number Diff line change
1
+ ; REQUIRES: spirv-as
2
+
3
+ ; RUN: spirv-as %s --target-env spv1.2 -o %t.spv
4
+ ; RUN: spirv-val %t.spv
5
+ ; RUN: llvm-spirv -r -o %t.rev.bc %t.spv
6
+ ; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s
7
+
8
+ OpCapability Addresses
9
+ OpCapability Linkage
10
+ OpCapability Kernel
11
+ OpMemoryModel Physical64 OpenCL
12
+ OpEntryPoint Kernel %fn "testLocalSizeId"
13
+ OpExecutionModeId %fn LocalSizeId %uint_64 %uint_1 %uint_1sco
14
+ %void = OpTypeVoid
15
+ %uint = OpTypeInt 32 0
16
+ %uint_1 = OpConstant %uint 1
17
+ %uint_64 = OpConstant %uint 64
18
+ %uint_1sco = OpSpecConstantOp %uint UDiv %uint_64 %uint_64
19
+ %fnTy = OpTypeFunction %void
20
+
21
+ ; CHECK: define spir_kernel void @testLocalSizeId() {{.*}} !reqd_work_group_size ![[MD:[0-9]+]]
22
+ ; CHECK: ![[MD]] = !{i32 64, i32 1, i32 1}
23
+
24
+ %fn = OpFunction %void None %fnTy
25
+ %entry = OpLabel
26
+ OpReturn
27
+ OpFunctionEnd
You can’t perform that action at this time.
0 commit comments