Skip to content

Commit

Permalink
Implementing VectorComputeCallableFunctionINTEL decoration
Browse files Browse the repository at this point in the history
Added following decoration and bidirectional translation it to
"VCCallable" attribute
  • Loading branch information
DmitryBushev authored and AlexeySotkin committed Oct 14, 2020
1 parent 61a10b2 commit e1cee96
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3749,6 +3749,8 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
SPIRVWord SIMTMode = 0;
if (BF->hasDecorate(DecorationSIMTCallINTEL, 0, &SIMTMode))
F->addFnAttr(kVCMetadata::VCSIMTCall, std::to_string(SIMTMode));
if (BF->hasDecorate(DecorationVectorComputeCallableFunctionINTEL))
F->addFnAttr(kVCMetadata::VCCallable);

for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
++I) {
Expand Down
4 changes: 4 additions & 0 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,10 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
}

if (Attrs.hasFnAttribute(kVCMetadata::VCCallable)) {
BF->addDecorate(DecorationVectorComputeCallableFunctionINTEL);
}

for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
++I) {
auto ArgNo = I->getArgNo();
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/VectorComputeUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const static char VCGlobalVariable[] = "VCGlobalVariable";
const static char VCVolatile[] = "VCVolatile";
const static char VCByteOffset[] = "VCByteOffset";
const static char VCSIMTCall[] = "VCSIMTCall";
const static char VCCallable[] = "VCCallable";
} // namespace kVCMetadata

namespace kVCType {
Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
{CapabilityFunctionFloatControlINTEL});
ADD_VEC_INIT(DecorationFunctionFloatingPointModeINTEL,
{CapabilityFunctionFloatControlINTEL});
ADD_VEC_INIT(DecorationVectorComputeCallableFunctionINTEL,
{CapabilityVectorComputeINTEL});
}

template <> inline void SPIRVMap<BuiltIn, SPIRVCapVec>::init() {
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ inline bool isValid(spv::Decoration V) {
case DecorationFunctionRoundingModeINTEL:
case DecorationFunctionDenormModeINTEL:
case DecorationFunctionFloatingPointModeINTEL:
case DecorationVectorComputeCallableFunctionINTEL:
return true;
default:
return false;
Expand Down
2 changes: 2 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,8 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
add(DecorationFunctionDenormModeINTEL, "FunctionDenormModeINTEL");
add(DecorationFunctionFloatingPointModeINTEL,
"FunctionFloatingPointModeINTEL");
add(DecorationVectorComputeCallableFunctionINTEL,
"VectorComputeCallableFunctionINTEL");
add(DecorationMax, "Max");
}
SPIRV_DEF_NAMEMAP(Decoration, SPIRVDecorationNameMap)
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/libSPIRV/spirv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ enum Decoration {
DecorationBufferLocationINTEL = 5921,
DecorationIOPipeStorageINTEL = 5944,
DecorationFunctionFloatingPointModeINTEL = 6080,
DecorationVectorComputeCallableFunctionINTEL = 6087,
DecorationMax = 0x7fffffff,
};

Expand Down
19 changes: 19 additions & 0 deletions test/callable-attribute-decoration.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
; RUN: llvm-spirv %t.spv -o %t.bc -r
; RUN: llvm-dis %t.bc -o %t.ll
; RUN: FileCheck < %t.ll %s --check-prefix=CHECK-LLVM
target triple = "spir64"


define dso_local <4 x i32> @foo(<4 x i32> %a, <4 x i32> %b) #0 {
entry:
ret <4 x i32> %a
}
; CHECK-SPIRV: 3 Decorate {{[0-9]+}} VectorComputeCallableFunctionINTEL
; CHECK-LLVM: attributes
; CHECK-LLVM-SAME: "VCCallable"

attributes #0 = { "VCCallable" "VCFunction" }

0 comments on commit e1cee96

Please sign in to comment.