Skip to content

Commit 6f47dbd

Browse files
NikitaRudenkoIntelvladimirlaz
authored andcommitted
Add SIMTCallINTEL decoration of SPV_INTEL_vector_compute extension
Extension is published at #1612
1 parent 326f12d commit 6f47dbd

File tree

8 files changed

+52
-0
lines changed

8 files changed

+52
-0
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3460,6 +3460,10 @@ bool SPIRVToLLVM::transVectorComputeMetadata(SPIRVFunction *BF) {
34603460
return true;
34613461
F->addFnAttr(kVCMetadata::VCFunction);
34623462

3463+
SPIRVWord SIMTMode = 0;
3464+
if (BF->hasDecorate(DecorationSIMTCallINTEL, 0, &SIMTMode))
3465+
F->addFnAttr(kVCMetadata::VCSIMTCall, std::to_string(SIMTMode));
3466+
34633467
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
34643468
++I) {
34653469
auto ArgNo = I->getArgNo();

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,14 @@ void LLVMToSPIRV::transVectorComputeMetadata(Function *F) {
585585
else
586586
return;
587587

588+
if (Attrs.hasFnAttribute(kVCMetadata::VCSIMTCall)) {
589+
SPIRVWord SIMTMode = 0;
590+
Attrs.getAttribute(AttributeList::FunctionIndex, kVCMetadata::VCSIMTCall)
591+
.getValueAsString()
592+
.getAsInteger(0, SIMTMode);
593+
BF->addDecorate(DecorationSIMTCallINTEL, SIMTMode);
594+
}
595+
588596
for (Function::arg_iterator I = F->arg_begin(), E = F->arg_end(); I != E;
589597
++I) {
590598
auto ArgNo = I->getArgNo();

llvm-spirv/lib/SPIRV/VectorComputeUtil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ const static char VCSLMSize[] = "VCSLMSize";
116116
const static char VCGlobalVariable[] = "VCGlobalVariable";
117117
const static char VCVolatile[] = "VCVolatile";
118118
const static char VCByteOffset[] = "VCByteOffset";
119+
const static char VCSIMTCall[] = "VCSIMTCall";
119120
const static char VCArgumentKind[] = "VCArgumentKind";
120121
const static char VCArgumentDesc[] = "VCArgumentDesc";
121122
} // namespace kVCMetadata

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ template <> inline void SPIRVMap<Decoration, SPIRVCapVec>::init() {
393393
{CapabilityVectorComputeINTEL});
394394
ADD_VEC_INIT(DecorationFuncParamIOKind, {CapabilityVectorComputeINTEL});
395395
ADD_VEC_INIT(DecorationStackCallINTEL, {CapabilityVectorComputeINTEL});
396+
ADD_VEC_INIT(DecorationSIMTCallINTEL, {CapabilityVectorComputeINTEL});
396397
ADD_VEC_INIT(DecorationFuncParamKindINTEL, {CapabilityVectorComputeINTEL});
397398
ADD_VEC_INIT(DecorationFuncParamDescINTEL, {CapabilityVectorComputeINTEL});
398399
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ inline bool isValid(spv::Decoration V) {
431431
case DecorationVectorComputeVariableINTEL:
432432
case DecorationGlobalVariableOffsetINTEL:
433433
case DecorationFuncParamIOKind:
434+
case DecorationSIMTCallINTEL:
434435
return true;
435436
default:
436437
return false;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ template <> inline void SPIRVMap<Decoration, std::string>::init() {
371371
add(DecorationVectorComputeVariableINTEL, "VectorComputeVariableINTEL");
372372
add(DecorationGlobalVariableOffsetINTEL, "GlobalVariableOffsetINTEL");
373373
add(DecorationFuncParamIOKind, "FuncParamIOKind");
374+
add(DecorationSIMTCallINTEL, "SIMTCallINTEL");
374375
}
375376
SPIRV_DEF_NAMEMAP(Decoration, SPIRVDecorationNameMap)
376377

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ enum Decoration {
477477
DecorationRestrictPointerEXT = 5355,
478478
DecorationAliasedPointer = 5356,
479479
DecorationAliasedPointerEXT = 5356,
480+
DecorationSIMTCallINTEL = 5599,
480481
DecorationFuncParamKindINTEL = 9624,
481482
DecorationFuncParamDescINTEL = 9625,
482483
DecorationReferencedIndirectlyINTEL = 5602,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
; RUN: llvm-as %s -o %t.bc
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute --spirv-allow-unknown-intrinsics
3+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
4+
; RUN: llvm-spirv -r %t.spv -o %t.bc
5+
; RUN: llvm-dis %t.bc -o %t.ll
6+
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
7+
; RUN: FileCheck %s --input-file %t.ll -check-prefix=LLVM
8+
9+
; ModuleID = 'slm.bc'
10+
source_filename = "slm.cpp"
11+
target datalayout = "e-p:64:64-i64:64-n8:16:32"
12+
target triple = "spir"
13+
14+
; LLVM-DAG: @k_rte{{[^#]*}}#[[K_RTE:[0-9]+]]
15+
; LLVM-DAG: attributes #[[K_RTE]]{{.*"VCSIMTCall"="5" }}
16+
; SPV-DAG: EntryPoint 6 [[K_RTE:[0-9]+]] "k_rte"
17+
; SPV-DAG: Decorate [[K_RTE]] SIMTCallINTEL 5
18+
19+
@in = internal global <256 x i8> undef, align 256 #0
20+
declare <256 x i8> @llvm.genx.vload(<256 x i8>* nonnull %aaa)
21+
22+
; Function Attrs: noinline norecurse nounwind readnone
23+
define dso_local dllexport spir_kernel void @k_rte(i32 %ibuf, i32 %obuf) local_unnamed_addr #1 {
24+
entry:
25+
%gload53 = tail call <256 x i8> @llvm.genx.vload(<256 x i8>* nonnull @in)
26+
ret void
27+
}
28+
29+
attributes #1 = { noinline norecurse nounwind readnone "VCFunction" "VCSIMTCall"="5" "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
30+
31+
!llvm.module.flags = !{!0}
32+
!llvm.ident = !{!1}
33+
34+
!0 = !{i32 1, !"wchar_size", i32 4}
35+
!1 = !{!"clang version 8.0.1"}

0 commit comments

Comments
 (0)