Skip to content

Commit b8e0e3c

Browse files
DmitryBushevvmaksimo
authored andcommitted
Implementing VectorComputeCallableFunctionINTEL decoration
Added following decoration and bidirectional translation it to "VCCallable" attribute
1 parent d8d8bb5 commit b8e0e3c

8 files changed

+32
-0
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -4018,6 +4018,8 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
40184018
SPIRVWord SIMTMode = 0;
40194019
if (BF->hasDecorate(DecorationSIMTCallINTEL, 0, &SIMTMode))
40204020
F->addFnAttr(kVCMetadata::VCSIMTCall, std::to_string(SIMTMode));
4021+
if (BF->hasDecorate(DecorationVectorComputeCallableFunctionINTEL))
4022+
F->addFnAttr(kVCMetadata::VCCallable);
40214023

40224024
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
40234025
++I) {

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,10 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
621621
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
622622
}
623623

624+
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable)) {
625+
BF->addDecorate(DecorationVectorComputeCallableFunctionINTEL);
626+
}
627+
624628
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
625629
++I) {
626630
auto ArgNo = I->getArgNo();

llvm-spirv/lib/SPIRV/VectorComputeUtil.h

+1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const static char VCByteOffset[] = "VCByteOffset";
110110
const static char VCSIMTCall[] = "VCSIMTCall";
111111
const static char VCArgumentKind[] = "VCArgumentKind";
112112
const static char VCArgumentDesc[] = "VCArgumentDesc";
113+
const static char VCCallable[] = "VCCallable";
113114
} // namespace kVCMetadata
114115

115116
namespace kVCType {

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

+2
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,8 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
412412
{CapabilityFunctionFloatControlINTEL});
413413
ADD_VEC_INIT(DecorationFunctionFloatingPointModeINTEL,
414414
{CapabilityFunctionFloatControlINTEL});
415+
ADD_VEC_INIT(DecorationVectorComputeCallableFunctionINTEL,
416+
{CapabilityVectorComputeINTEL});
415417
}
416418

417419
template <> inline void SPIRVMap<BuiltIn, SPIRVCapVec>::init() {

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

+1
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ inline bool isValid(spv::Decoration V) {
439439
case DecorationFunctionRoundingModeINTEL:
440440
case DecorationFunctionDenormModeINTEL:
441441
case DecorationFunctionFloatingPointModeINTEL:
442+
case DecorationVectorComputeCallableFunctionINTEL:
442443
return true;
443444
default:
444445
return false;

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

+2
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
163163
add(DecorationFunctionDenormModeINTEL, "FunctionDenormModeINTEL");
164164
add(DecorationFunctionFloatingPointModeINTEL,
165165
"FunctionFloatingPointModeINTEL");
166+
add(DecorationVectorComputeCallableFunctionINTEL,
167+
"VectorComputeCallableFunctionINTEL");
166168
add(DecorationMax, "Max");
167169
}
168170
SPIRV_DEF_NAMEMAP(Decoration, SPIRVDecorationNameMap)

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

+1
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ enum Decoration {
523523
DecorationBufferLocationINTEL = 5921,
524524
DecorationIOPipeStorageINTEL = 5944,
525525
DecorationFunctionFloatingPointModeINTEL = 6080,
526+
DecorationVectorComputeCallableFunctionINTEL = 6087,
526527
DecorationMax = 0x7fffffff,
527528
};
528529

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
3+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
4+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5+
; RUN: llvm-spirv %t.spv -o %t.bc -r
6+
; RUN: llvm-dis %t.bc -o %t.ll
7+
; RUN: FileCheck < %t.ll %s --check-prefix=CHECK-LLVM
8+
target triple = "spir64"
9+
10+
11+
define dso_local <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) #0 {
12+
entry:
13+
ret <4 x i32> %a
14+
}
15+
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} VectorComputeCallableFunctionINTEL
16+
; CHECK-LLVM: attributes
17+
; CHECK-LLVM-SAME: "VCCallable"
18+
19+
attributes #0 = { "VCCallable" "VCFunction" }

0 commit comments

Comments
 (0)