Skip to content

Commit 60746d5

Browse files
sarnexvmustya
andauthored
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]>
1 parent 730eaf0 commit 60746d5

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

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 {
@@ -955,6 +956,7 @@ template <> inline void SPIRVMap<std::string, Op, SPIRVOpaqueType>::init() {
955956
_SPIRV_OP(AvcRefResultINTEL)
956957
_SPIRV_OP(AvcSicResultINTEL)
957958
_SPIRV_OP(VmeImageINTEL)
959+
_SPIRV_OP(BufferSurfaceINTEL)
958960
#undef _SPIRV_OP
959961
add("JointMatrixINTEL", internal::OpTypeJointMatrixINTEL);
960962
}

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
517517
return mapType(T, BM->addQueueType());
518518
case OpTypeDeviceEvent:
519519
return mapType(T, BM->addDeviceEventType());
520+
case OpTypeBufferSurfaceINTEL: {
521+
ArrayRef<unsigned> Ops = TargetTy->int_params();
522+
return mapType(T, BM->addBufferSurfaceINTELType(CastAccess(Ops[0])));
523+
}
520524
case internal::OpTypeJointMatrixINTEL: {
521525
// The expected representation is:
522526
// target("spirv.JointMatrixINTEL", %element_type, %rows%, %cols%,
@@ -785,8 +789,12 @@ SPIRVType *LLVMToSPIRVBase::transSPIRVOpaqueType(StringRef STName,
785789
return SaveType(BM->addQueueType());
786790
else if (TN == kSPIRVTypeName::PipeStorage)
787791
return SaveType(BM->addPipeStorageType());
788-
else if (TN == kSPIRVTypeName::JointMatrixINTEL) {
792+
else if (TN == kSPIRVTypeName::JointMatrixINTEL)
789793
return SaveType(transSPIRVJointMatrixINTELType(Postfixes));
794+
else if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute) &&
795+
TN == kSPIRVTypeName::BufferSurfaceINTEL) {
796+
auto Access = getAccessQualifier(STName);
797+
return SaveType(BM->addBufferSurfaceINTELType(Access));
790798
} else
791799
return SaveType(
792800
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)