Skip to content

Commit c9090b6

Browse files
DmitryBushevvmaksimo
authored andcommitted
Update translator for new Fast Composite extension
SPV_INTEL_fast_composite extension specification separated some decorations and execution modes from SPV_INTEL_vector_compute Original commit: KhronosGroup/SPIRV-LLVM-Translator@fabf003
1 parent 832b1c4 commit c9090b6

File tree

11 files changed

+30
-26
lines changed

11 files changed

+30
-26
lines changed

llvm-spirv/include/LLVMSPIRVExtensions.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ EXT(SPV_INTEL_arbitrary_precision_integers)
2222
EXT(SPV_INTEL_optimization_hints)
2323
EXT(SPV_INTEL_float_controls2)
2424
EXT(SPV_INTEL_vector_compute)
25+
EXT(SPV_INTEL_fast_composite)
2526
EXT(SPV_INTEL_usm_storage_classes)
2627
EXT(SPV_INTEL_fpga_buffer_location)
2728
EXT(SPV_INTEL_arbitrary_precision_fixed_point)

llvm-spirv/lib/SPIRV/PreprocessMetadata.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,7 @@ void PreprocessMetadata::preprocessVectorComputeMetadata(Module *M,
328328
.done();
329329
}
330330
if (Attrs.hasFnAttribute(kVCMetadata::VCFCEntry)) {
331-
EM.addOp()
332-
.add(&F)
333-
.add(spv::ExecutionModeVectorComputeFastCompositeKernelINTEL)
334-
.done();
331+
EM.addOp().add(&F).add(spv::ExecutionModeFastCompositeKernelINTEL).done();
335332
}
336333
}
337334
}

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,6 +3906,12 @@ bool SPIRVToLLVM::transMetadata() {
39063906
transVectorComputeMetadata(BF);
39073907
transFPGAFunctionMetadata(BF, F);
39083908

3909+
if (BF->hasDecorate(DecorationCallableFunctionINTEL))
3910+
F->addFnAttr(kVCMetadata::VCCallable);
3911+
if (isKernel(BF) &&
3912+
BF->getExecutionMode(ExecutionModeFastCompositeKernelINTEL))
3913+
F->addFnAttr(kVCMetadata::VCFCEntry);
3914+
39093915
if (F->getCallingConv() != CallingConv::SPIR_KERNEL)
39103916
continue;
39113917

@@ -4084,11 +4090,6 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
40844090
SPIRVWord SIMTMode = 0;
40854091
if (BF->hasDecorate(DecorationSIMTCallINTEL, 0, &SIMTMode))
40864092
F->addFnAttr(kVCMetadata::VCSIMTCall, std::to_string(SIMTMode));
4087-
if (BF->hasDecorate(DecorationVectorComputeCallableFunctionINTEL))
4088-
F->addFnAttr(kVCMetadata::VCCallable);
4089-
if (isKernel(BF) &&
4090-
BF->getExecutionMode(ExecutionModeVectorComputeFastCompositeKernelINTEL))
4091-
F->addFnAttr(kVCMetadata::VCFCEntry);
40924093

40934094
auto SEVAttr = Attribute::get(*Context, kVCMetadata::VCSingleElementVector);
40944095
if (BF->hasDecorate(DecorationSingleElementVectorINTEL))

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -619,6 +619,11 @@ SPIRVFunction *LLVMToSPIRV::transFunctionDecl(Function *F) {
619619
BF->addDecorate(DecorationReferencedIndirectlyINTEL);
620620
}
621621

622+
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable) &&
623+
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite)) {
624+
BF->addDecorate(DecorationCallableFunctionINTEL);
625+
}
626+
622627
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
623628
transVectorComputeMetadata(F);
624629

@@ -652,10 +657,6 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
652657
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
653658
}
654659

655-
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable)) {
656-
BF->addDecorate(DecorationVectorComputeCallableFunctionINTEL);
657-
}
658-
659660
if (Attrs.hasAttribute(AttributeList::ReturnIndex,
660661
kVCMetadata::VCSingleElementVector)) {
661662
auto *RT = BF->getType();
@@ -3403,8 +3404,8 @@ bool LLVMToSPIRV::transExecutionMode() {
34033404
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
34043405
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
34053406
} break;
3406-
case spv::ExecutionModeVectorComputeFastCompositeKernelINTEL: {
3407-
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
3407+
case spv::ExecutionModeFastCompositeKernelINTEL: {
3408+
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite))
34083409
BF->addExecutionMode(BM->add(
34093410
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
34103411
} break;

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVDecorate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ class SPIRVDecorate : public SPIRVDecorateGeneric {
190190
return ExtensionID::SPV_INTEL_fpga_cluster_attributes;
191191
case DecorationFuseLoopsInFunctionINTEL:
192192
return ExtensionID::SPV_INTEL_loop_fuse;
193+
case DecorationCallableFunctionINTEL:
194+
return ExtensionID::SPV_INTEL_fast_composite;
193195
default:
194196
return {};
195197
}

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEntry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,8 @@ class SPIRVCapability : public SPIRVEntryNoId<OpCapability> {
842842
case CapabilityVectorComputeINTEL:
843843
case CapabilityVectorAnyINTEL:
844844
return ExtensionID::SPV_INTEL_vector_compute;
845+
case CapabilityFastCompositeINTEL:
846+
return ExtensionID::SPV_INTEL_fast_composite;
845847
default:
846848
return {};
847849
}

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEnum.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,8 @@ template <> inline void SPIRVMap<SPIRVExecutionModeKind, SPIRVCapVec>::init() {
252252
{CapabilityFloatingPointModeINTEL});
253253
ADD_VEC_INIT(ExecutionModeSharedLocalMemorySizeINTEL,
254254
{CapabilityVectorComputeINTEL});
255-
ADD_VEC_INIT(ExecutionModeVectorComputeFastCompositeKernelINTEL,
256-
{CapabilityVectorComputeINTEL});
255+
ADD_VEC_INIT(ExecutionModeFastCompositeKernelINTEL,
256+
{CapabilityFastCompositeINTEL});
257257
}
258258

259259
template <> inline void SPIRVMap<SPIRVMemoryModelKind, SPIRVCapVec>::init() {
@@ -416,8 +416,7 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
416416
{CapabilityFunctionFloatControlINTEL});
417417
ADD_VEC_INIT(DecorationSingleElementVectorINTEL,
418418
{CapabilityVectorComputeINTEL});
419-
ADD_VEC_INIT(DecorationVectorComputeCallableFunctionINTEL,
420-
{CapabilityVectorComputeINTEL});
419+
ADD_VEC_INIT(DecorationCallableFunctionINTEL, {CapabilityFastCompositeINTEL});
421420
ADD_VEC_INIT(DecorationStallEnableINTEL,
422421
{CapabilityFPGAClusterAttributesINTEL});
423422
ADD_VEC_INIT(DecorationFuseLoopsInFunctionINTEL, {CapabilityLoopFuseINTEL});

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
165165
add(DecorationFunctionFloatingPointModeINTEL,
166166
"FunctionFloatingPointModeINTEL");
167167
add(DecorationSingleElementVectorINTEL, "SingleElementVectorINTEL");
168-
add(DecorationVectorComputeCallableFunctionINTEL,
169-
"VectorComputeCallableFunctionINTEL");
168+
add(DecorationCallableFunctionINTEL, "CallableFunctionINTEL");
170169
add(DecorationStallEnableINTEL, "StallEnableINTEL");
171170
add(DecorationFuseLoopsInFunctionINTEL, "FuseLoopsInFunctionINTEL");
172171
add(DecorationMax, "Max");
@@ -513,6 +512,7 @@ template <> inline void SPIRVMap<Capability, std::string>::init() {
513512
add(CapabilityLoopFuseINTEL, "LoopFuseINTEL");
514513
add(CapabilityMax, "Max");
515514
add(CapabilityLongConstantCompositeINTEL, "LongConstantCompositeINTEL");
515+
add(CapabilityFastCompositeINTEL, "FastCompositeINTEL");
516516
}
517517
SPIRV_DEF_NAMEMAP(Capability, SPIRVCapabilityNameMap)
518518

llvm-spirv/lib/SPIRV/libSPIRV/spirv.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ enum ExecutionMode {
178178
ExecutionModeNoGlobalOffsetINTEL = 5895,
179179
ExecutionModeNumSIMDWorkitemsINTEL = 5896,
180180
ExecutionModeSchedulerTargetFmaxMhzINTEL = 5903,
181-
ExecutionModeVectorComputeFastCompositeKernelINTEL = 6088,
181+
ExecutionModeFastCompositeKernelINTEL = 6088,
182182
ExecutionModeMax = 0x7fffffff,
183183
};
184184

@@ -549,7 +549,7 @@ enum Decoration {
549549
DecorationIOPipeStorageINTEL = 5944,
550550
DecorationFunctionFloatingPointModeINTEL = 6080,
551551
DecorationSingleElementVectorINTEL = 6085,
552-
DecorationVectorComputeCallableFunctionINTEL = 6087,
552+
DecorationCallableFunctionINTEL = 6087,
553553
DecorationMax = 0x7fffffff,
554554
};
555555

@@ -1049,6 +1049,7 @@ enum Capability {
10491049
CapabilityAtomicFloat32AddEXT = 6033,
10501050
CapabilityAtomicFloat64AddEXT = 6034,
10511051
CapabilityLongConstantCompositeINTEL = 6089,
1052+
CapabilityFastCompositeINTEL = 6093,
10521053
CapabilityMax = 0x7fffffff,
10531054
};
10541055

llvm-spirv/test/callable-attribute-decoration.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_fast_composite
33
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
44
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
55
; RUN: llvm-spirv %t.spv -o %t.bc -r
@@ -12,7 +12,7 @@ define dso_local <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) #0 {
1212
entry:
1313
ret <4 x i32> %a
1414
}
15-
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} VectorComputeCallableFunctionINTEL
15+
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} CallableFunctionINTEL
1616
; CHECK-LLVM: attributes
1717
; CHECK-LLVM-SAME: "VCCallable"
1818

0 commit comments

Comments
 (0)