Skip to content

Commit b2b58f1

Browse files
sarnexsys-ce-bb
authored andcommitted
Support the spirv.BufferSurfaceINTEL target extension type (#1995)
This target extension type is created here: https://github.com/intel/vc-intrinsics/blob/master/GenXIntrinsics/lib/GenXIntrinsics/GenXSPIRVWriterAdaptor.cpp#L245 As with other target extension types, reverse translation is not yet supported. Signed-off-by: Sarnie, Nick <[email protected]> Co-authored-by: Victor Mustya <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@60746d5
1 parent 0c2fe3e commit b2b58f1

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

llvm-spirv/lib/SPIRV/SPIRVInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ const static char PipeStorage[] = "PipeStorage";
311311
const static char ConstantPipeStorage[] = "ConstantPipeStorage";
312312
const static char VmeImageINTEL[] = "VmeImageINTEL";
313313
const static char JointMatrixINTEL[] = "JointMatrixINTEL";
314+
const static char BufferSurfaceINTEL[] = "BufferSurfaceINTEL";
314315
} // namespace kSPIRVTypeName
315316

316317
namespace kSPR2TypeName {
@@ -954,6 +955,7 @@ template <> inline void SPIRVMap<std::string, Op, SPIRVOpaqueType>::init() {
954955
_SPIRV_OP(AvcRefResultINTEL)
955956
_SPIRV_OP(AvcSicResultINTEL)
956957
_SPIRV_OP(VmeImageINTEL)
958+
_SPIRV_OP(BufferSurfaceINTEL)
957959
#undef _SPIRV_OP
958960
add("JointMatrixINTEL", internal::OpTypeJointMatrixINTEL);
959961
}

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,10 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
521521
return mapType(T, BM->addQueueType());
522522
case OpTypeDeviceEvent:
523523
return mapType(T, BM->addDeviceEventType());
524+
case OpTypeBufferSurfaceINTEL: {
525+
ArrayRef<unsigned> Ops = TargetTy->int_params();
526+
return mapType(T, BM->addBufferSurfaceINTELType(CastAccess(Ops[0])));
527+
}
524528
case internal::OpTypeJointMatrixINTEL: {
525529
// The expected representation is:
526530
// target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%,
@@ -789,8 +793,12 @@ SPIRVType *LLVMToSPIRVBase::transSPIRVOpaqueType(StringRef STName,
789793
return SaveType(BM->addQueueType());
790794
else if (TN == kSPIRVTypeName::PipeStorage)
791795
return SaveType(BM->addPipeStorageType());
792-
else if (TN == kSPIRVTypeName::JointMatrixINTEL) {
796+
else if (TN == kSPIRVTypeName::JointMatrixINTEL)
793797
return SaveType(transSPIRVJointMatrixINTELType(Postfixes));
798+
else if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute) &&
799+
TN == kSPIRVTypeName::BufferSurfaceINTEL) {
800+
auto Access = getAccessQualifier(STName);
801+
return SaveType(BM->addBufferSurfaceINTELType(Access));
794802
} else
795803
return SaveType(
796804
BM->addOpaqueGenericType(SPIRVOpaqueTypeOpCodeMap::map(TN)));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
; Check translation of the buffer surface target extension type
2+
;
3+
; RUN: llvm-as %s -o %t.bc
4+
; RUN: llvm-spirv -spirv-ext=+SPV_INTEL_vector_compute %t.bc -spirv-text -o %t.spv.txt
5+
; RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV
6+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
7+
target triple = "spir-unknown-unknown"
8+
9+
; CHECK-SPIRV: Capability VectorComputeINTEL
10+
; CHECK-SPIRV: Extension "SPV_INTEL_vector_compute"
11+
; CHECK-SPIRV: Name [[#FuncName:]] "foo"
12+
; CHECK-SPIRV: Name [[#ParamName:]] "a"
13+
; CHECK-SPIRV: TypeVoid [[#VoidT:]]
14+
; CHECK-SPIRV: TypeBufferSurfaceINTEL [[#BufferID:]]
15+
; CHECK-SPIRV: Function [[#VoidT]] [[#FuncID:]]
16+
; CHECK-SPIRV-NEXT: FunctionParameter [[#BufferID]] [[#ParamName]]
17+
18+
define spir_kernel void @foo(target("spirv.BufferSurfaceINTEL", 0) %a) #0 {
19+
entry:
20+
ret void
21+
}
22+
23+
attributes #0 = { noinline norecurse nounwind readnone "VCFunction"}

0 commit comments

Comments
 (0)