Skip to content

Commit c3c7e24

Browse files
DmitryBushevAlexeySotkin
authored andcommitted
Implementing VectorComputeCallableFunctionINTEL decoration
Added following decoration and bidirectional translation it to "VCCallable" attribute
1 parent 0e375bc commit c3c7e24

8 files changed

+32
-0
lines changed

lib/SPIRV/SPIRVReader.cpp

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

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

lib/SPIRV/SPIRVWriter.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,10 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
617617
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
618618
}
619619

620+
if (Attrs.hasFnAttribute(kVCMetadata::VCCallable)) {
621+
BF->addDecorate(DecorationVectorComputeCallableFunctionINTEL);
622+
}
623+
620624
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
621625
++I) {
622626
auto ArgNo = I->getArgNo();

lib/SPIRV/VectorComputeUtil.h

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ const static char VCGlobalVariable[] = "VCGlobalVariable";
108108
const static char VCVolatile[] = "VCVolatile";
109109
const static char VCByteOffset[] = "VCByteOffset";
110110
const static char VCSIMTCall[] = "VCSIMTCall";
111+
const static char VCCallable[] = "VCCallable";
111112
} // namespace kVCMetadata
112113

113114
namespace kVCType {

lib/SPIRV/libSPIRV/SPIRVEnum.h

+2
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
410410
{CapabilityFunctionFloatControlINTEL});
411411
ADD_VEC_INIT(DecorationFunctionFloatingPointModeINTEL,
412412
{CapabilityFunctionFloatControlINTEL});
413+
ADD_VEC_INIT(DecorationVectorComputeCallableFunctionINTEL,
414+
{CapabilityVectorComputeINTEL});
413415
}
414416

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

lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ inline bool isValid(spv::Decoration V) {
437437
case DecorationFunctionRoundingModeINTEL:
438438
case DecorationFunctionDenormModeINTEL:
439439
case DecorationFunctionFloatingPointModeINTEL:
440+
case DecorationVectorComputeCallableFunctionINTEL:
440441
return true;
441442
default:
442443
return false;

lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h

+2
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
161161
add(DecorationFunctionDenormModeINTEL, "FunctionDenormModeINTEL");
162162
add(DecorationFunctionFloatingPointModeINTEL,
163163
"FunctionFloatingPointModeINTEL");
164+
add(DecorationVectorComputeCallableFunctionINTEL,
165+
"VectorComputeCallableFunctionINTEL");
164166
add(DecorationMax, "Max");
165167
}
166168
SPIRV_DEF_NAMEMAP(Decoration, SPIRVDecorationNameMap)

lib/SPIRV/libSPIRV/spirv.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,7 @@ enum Decoration {
521521
DecorationBufferLocationINTEL = 5921,
522522
DecorationIOPipeStorageINTEL = 5944,
523523
DecorationFunctionFloatingPointModeINTEL = 6080,
524+
DecorationVectorComputeCallableFunctionINTEL = 6087,
524525
DecorationMax = 0x7fffffff,
525526
};
526527

test/callable-attribute-decoration.ll

+19
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)