Skip to content

Commit d618c7b

Browse files
fda0sarnexvmustya
authored
[Backport to LLVM 16] Support the spirv.BufferSurfaceINTEL target extension type (KhronosGroup#1995) (KhronosGroup#3241)
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 <nick.sarnie@intel.com> Co-authored-by: Victor Mustya <victor.mustya@intel.com> (cherry picked from commit 60746d5) Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com> Co-authored-by: Nick Sarnie <sarnex@users.noreply.github.com> Co-authored-by: Victor Mustya <victor.mustya@intel.com>
1 parent 586acf5 commit d618c7b

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

lib/SPIRV/SPIRVInternal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ const static char ConstantPipeStorage[] = "ConstantPipeStorage";
319319
const static char VmeImageINTEL[] = "VmeImageINTEL";
320320
const static char JointMatrixINTEL[] = "JointMatrixINTEL";
321321
const static char CooperativeMatrixKHR[] = "CooperativeMatrixKHR";
322+
const static char BufferSurfaceINTEL[] = "BufferSurfaceINTEL";
322323
} // namespace kSPIRVTypeName
323324

324325
namespace kSPR2TypeName {
@@ -976,6 +977,7 @@ template <> inline void SPIRVMap<std::string, Op, SPIRVOpaqueType>::init() {
976977
_SPIRV_OP(AvcRefResultINTEL)
977978
_SPIRV_OP(AvcSicResultINTEL)
978979
_SPIRV_OP(VmeImageINTEL)
980+
_SPIRV_OP(BufferSurfaceINTEL)
979981
_SPIRV_OP(CooperativeMatrixKHR)
980982
#undef _SPIRV_OP
981983
add("JointMatrixINTEL", internal::OpTypeJointMatrixINTEL);

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,12 @@ SPIRVType *LLVMToSPIRVBase::transSPIRVOpaqueType(StringRef STName,
824824
return SaveType(BM->addQueueType());
825825
else if (TN == kSPIRVTypeName::PipeStorage)
826826
return SaveType(BM->addPipeStorageType());
827-
else if (TN == kSPIRVTypeName::JointMatrixINTEL) {
827+
else if (TN == kSPIRVTypeName::JointMatrixINTEL)
828828
return SaveType(transSPIRVJointMatrixINTELType(Postfixes));
829+
else if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute) &&
830+
TN == kSPIRVTypeName::BufferSurfaceINTEL) {
831+
auto Access = getAccessQualifier(STName);
832+
return SaveType(BM->addBufferSurfaceINTELType(Access));
829833
} else
830834
return SaveType(
831835
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)