Skip to content

Commit a1f6742

Browse files
authored
Improve matrices translation with SPV_KHR_untyped_pointers (#2857)
Ensure that we do correct translation of matrices (SPV_KHR_cooperative_matrix and SPV_INTEL_joint_matrix extensions) when untyped pointers are enabled. This mainly fixes mangling issues in reverse translation for the untyped pointer. Also added handling for typed and untyped SPIR-V friendly access chain instructions in forward translation (a point to review and discuss).
1 parent d20ca5d commit a1f6742

19 files changed

+280
-14
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,8 +2239,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22392239
auto *AC = static_cast<SPIRVAccessChainBase *>(BV);
22402240
auto *Base = transValue(AC->getBase(), F, BB);
22412241
SPIRVType *BaseSPVTy = AC->getBaseType();
2242-
if (BaseSPVTy->isTypePointer() &&
2243-
BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) {
2242+
if ((BaseSPVTy->isTypePointer() &&
2243+
BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) ||
2244+
(isUntypedAccessChainOpCode(OC) &&
2245+
BaseSPVTy->isTypeCooperativeMatrixKHR())) {
22442246
return mapValue(BV, transSPIRVBuiltinFromInst(AC, BB));
22452247
}
22462248
Type *BaseTy =
@@ -3488,23 +3490,64 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
34883490
BasicBlock *BB) {
34893491
std::string MangledName;
34903492
auto Ops = BI->getOperands();
3493+
Op OC = BI->getOpCode();
3494+
if (isUntypedAccessChainOpCode(OC)) {
3495+
auto *AC = static_cast<SPIRVAccessChainBase *>(BI);
3496+
if (AC->getBaseType()->isTypeCooperativeMatrixKHR())
3497+
Ops.erase(Ops.begin());
3498+
}
34913499
Type *RetTy =
34923500
BI->hasType() ? transType(BI->getType()) : Type::getVoidTy(*Context);
34933501
transOCLBuiltinFromInstPreproc(BI, RetTy, Ops);
34943502
std::vector<Type *> ArgTys =
34953503
transTypeVector(SPIRVInstruction::getOperandTypes(Ops), true);
34963504

3497-
// Special handling for "truly" untyped pointers to preserve correct
3498-
// builtin mangling of atomic operations.
34993505
auto Ptr = findFirstPtrType(ArgTys);
35003506
if (Ptr < ArgTys.size() &&
35013507
BI->getValueType(Ops[Ptr]->getId())->isTypeUntypedPointerKHR()) {
3502-
if (isAtomicOpCodeUntypedPtrSupported(BI->getOpCode())) {
3508+
// Special handling for "truly" untyped pointers to preserve correct
3509+
// builtin mangling of atomic and matrix operations.
3510+
if (isAtomicOpCodeUntypedPtrSupported(OC)) {
35033511
auto *AI = static_cast<SPIRVAtomicInstBase *>(BI);
35043512
ArgTys[Ptr] = TypedPointerType::get(
35053513
transType(AI->getSemanticType()),
35063514
SPIRSPIRVAddrSpaceMap::rmap(
35073515
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3516+
} else if (OC == spv::OpCooperativeMatrixStoreKHR ||
3517+
OC == spv::internal::OpJointMatrixStoreINTEL ||
3518+
OC == spv::internal::OpCooperativeMatrixStoreCheckedINTEL ||
3519+
OC == spv::internal::OpJointMatrixLoadINTEL ||
3520+
OC == spv::OpCompositeConstruct ||
3521+
OC == spv::internal::OpCooperativeMatrixApplyFunctionINTEL) {
3522+
auto *Val = transValue(Ops[Ptr], BB->getParent(), BB);
3523+
Val = Val->stripPointerCasts();
3524+
if (auto *GEP = dyn_cast<GetElementPtrInst>(Val))
3525+
ArgTys[Ptr] = TypedPointerType::get(
3526+
GEP->getSourceElementType(),
3527+
SPIRSPIRVAddrSpaceMap::rmap(
3528+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3529+
else if (auto *AI = dyn_cast<AllocaInst>(Val))
3530+
ArgTys[Ptr] = TypedPointerType::get(
3531+
AI->getAllocatedType(),
3532+
SPIRSPIRVAddrSpaceMap::rmap(
3533+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3534+
else if (isa<Argument>(Val) && !RetTy->isVoidTy()) {
3535+
// Pointer could be a function parameter. Assume that the type of the
3536+
// pointer is the same as the return type.
3537+
Type *Ty = nullptr;
3538+
// it return type is array type, assign its element type to Ty
3539+
if (RetTy->isArrayTy())
3540+
Ty = RetTy->getArrayElementType();
3541+
else if (RetTy->isVectorTy())
3542+
Ty = cast<VectorType>(RetTy)->getElementType();
3543+
else
3544+
Ty = RetTy;
3545+
3546+
ArgTys[Ptr] = TypedPointerType::get(
3547+
Ty,
3548+
SPIRSPIRVAddrSpaceMap::rmap(
3549+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3550+
}
35083551
}
35093552
}
35103553

@@ -3517,8 +3560,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35173560
if (BM->getDesiredBIsRepresentation() != BIsRepresentation::SPIRVFriendlyIR)
35183561
mangleOpenClBuiltin(FuncName, ArgTys, MangledName);
35193562
else
3520-
MangledName =
3521-
getSPIRVFriendlyIRFunctionName(FuncName, BI->getOpCode(), ArgTys, Ops);
3563+
MangledName = getSPIRVFriendlyIRFunctionName(FuncName, OC, ArgTys, Ops);
35223564

35233565
opaquifyTypedPointers(ArgTys);
35243566

@@ -3541,14 +3583,13 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35413583
Func->setCallingConv(CallingConv::SPIR_FUNC);
35423584
if (isFuncNoUnwind())
35433585
Func->addFnAttr(Attribute::NoUnwind);
3544-
auto OC = BI->getOpCode();
35453586
if (isGroupOpCode(OC) || isGroupNonUniformOpcode(OC) ||
35463587
isIntelSubgroupOpCode(OC) || isSplitBarrierINTELOpCode(OC) ||
35473588
OC == OpControlBarrier)
35483589
Func->addFnAttr(Attribute::Convergent);
35493590
}
35503591
CallInst *Call;
3551-
if (BI->getOpCode() == OpCooperativeMatrixLengthKHR &&
3592+
if (OC == OpCooperativeMatrixLengthKHR &&
35523593
Ops[0]->getOpCode() == OpTypeCooperativeMatrixKHR) {
35533594
// OpCooperativeMatrixLengthKHR needs special handling as its operand is
35543595
// a Type instead of a Value.

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6836,8 +6836,28 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
68366836
SPRetTy = transType(F->getParamStructRetType(0));
68376837
Args.erase(Args.begin());
68386838
}
6839+
if (RetTy->isPointerTy() &&
6840+
BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers)) {
6841+
if (OC == OpAccessChain)
6842+
OC = OpUntypedAccessChainKHR;
6843+
else if (OC == OpInBoundsAccessChain)
6844+
OC = OpUntypedInBoundsAccessChainKHR;
6845+
else if (OC == OpPtrAccessChain)
6846+
OC = OpUntypedPtrAccessChainKHR;
6847+
else if (OC == OpInBoundsPtrAccessChain)
6848+
OC = OpUntypedInBoundsPtrAccessChainKHR;
6849+
}
68396850
auto *SPI = SPIRVInstTemplateBase::create(OC);
68406851
std::vector<SPIRVWord> SPArgs;
6852+
if (isUntypedAccessChainOpCode(OC)) {
6853+
// Untyped access chain instructions have an additional argument BaseTy.
6854+
Type *Ty = Scavenger->getScavengedType(Args[0]);
6855+
SPIRVType *PtrTy = nullptr;
6856+
if (auto *TPT = dyn_cast<TypedPointerType>(Ty)) {
6857+
PtrTy = transType(TPT->getElementType());
6858+
SPArgs.push_back(PtrTy->getId());
6859+
}
6860+
}
68416861
for (size_t I = 0, E = Args.size(); I != E; ++I) {
68426862
if (Args[I]->getType()->isPointerTy()) {
68436863
Value *Pointee = Args[I]->stripPointerCasts();

lib/SPIRV/libSPIRV/SPIRVInstruction.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1747,6 +1747,16 @@ class SPIRVAccessChainBase : public SPIRVInstTemplateBase {
17471747
OpCode == OpUntypedPtrAccessChainKHR ||
17481748
OpCode == OpUntypedInBoundsPtrAccessChainKHR;
17491749
}
1750+
SPIRVCapVec getRequiredCapability() const override {
1751+
if (isUntyped())
1752+
return getVec(CapabilityUntypedPointersKHR);
1753+
return {};
1754+
}
1755+
std::optional<ExtensionID> getRequiredExtension() const override {
1756+
if (isUntyped())
1757+
return ExtensionID::SPV_KHR_untyped_pointers;
1758+
return {};
1759+
}
17501760
};
17511761

17521762
template <Op OC, unsigned FixedWC>

lib/SPIRV/libSPIRV/SPIRVOpCode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@ inline bool isAccessChainOpCode(Op OpCode) {
150150
return OpCode == OpAccessChain || OpCode == OpInBoundsAccessChain;
151151
}
152152

153+
inline bool isUntypedAccessChainOpCode(Op OpCode) {
154+
return OpCode == OpUntypedAccessChainKHR ||
155+
OpCode == OpUntypedInBoundsAccessChainKHR ||
156+
OpCode == OpUntypedPtrAccessChainKHR ||
157+
OpCode == OpUntypedInBoundsPtrAccessChainKHR;
158+
}
159+
153160
inline bool hasExecScope(Op OpCode) {
154161
unsigned OC = OpCode;
155162
return (OpGroupWaitEvents <= OC && OC <= OpGroupSMax) ||

test/extensions/INTEL/SPV_INTEL_joint_matrix/array_of_matrices.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
1010
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1111

12+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
13+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
14+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
15+
16+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
17+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
18+
1219
; CHECK-SPIRV-DAG: Capability JointMatrixINTEL
1320
; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix"
1421
; CHECK-SPIRV: TypeInt [[#Int16Ty:]] 16 0

test/extensions/INTEL/SPV_INTEL_joint_matrix/bf16_conversion_instructions.ll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,19 @@
1212
; RUN: not llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_bfloat16_conversion 2>&1 \
1313
; RUN: | FileCheck %s --check-prefix=CHECK-ERROR
1414

15+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_INTEL_bfloat16_conversion,+SPV_KHR_untyped_pointers -o %t.spv
16+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
17+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
18+
19+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
20+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-OCL-IR
21+
22+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc --spirv-target-env=SPV-IR
23+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-SPV-IR
24+
25+
; RUN: not llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_bfloat16_conversion,+SPV_KHR_untyped_pointers 2>&1 \
26+
; RUN: | FileCheck %s --check-prefix=CHECK-ERROR
27+
1528
; CHECK-ERROR: InvalidInstruction: Can't translate llvm instruction:
1629
; CHECK-ERROR-NEXT: ConvertFToBF16INTEL
1730
; CHECK-ERROR-NEXT: Can be used with cooperative matrices only when SPV_INTEL_joint_matrix is enabled

test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_apply.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
99
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1010

11+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
12+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
13+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
14+
15+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
16+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
17+
1118
; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR
1219
; CHECK-SPIRV-DAG: Capability CooperativeMatrixInvocationInstructionsINTEL
1320
; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix"

test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_checked.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
99
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1010

11+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
12+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
13+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
14+
15+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
16+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
17+
1118
; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR
1219
; CHECK-SPIRV-DAG: Capability CooperativeMatrixCheckedInstructionsINTEL
1320
; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix"

test/extensions/INTEL/SPV_INTEL_joint_matrix/cooperative_matrix_prefetch.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
99
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1010

11+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
12+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
13+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
14+
15+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
16+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
17+
1118
; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR
1219
; CHECK-SPIRV-DAG: Capability CooperativeMatrixPrefetchINTEL
1320
; CHECK-SPIRV-DAG: Extension "SPV_KHR_cooperative_matrix"

test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
77
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
88

9+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
10+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
11+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
12+
13+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
14+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
15+
916
; CHECK-SPIRV-DAG: Capability JointMatrixINTEL
1017
; CHECK-SPIRV-DAG: Extension "SPV_INTEL_joint_matrix"
1118
; CHECK-SPIRV-DAG: TypeInt [[#Int8Ty:]] 8 0

test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_bfloat16.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
1010
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1111

12+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_bfloat16_conversion,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
13+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
14+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
15+
16+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
17+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
18+
1219
; CHECK-SPIRV-DAG: TypeInt [[#SHORT:]] 16
1320
; CHECK-SPIRV-DAG: TypeInt [[#INT:]] 32
1421
; CHECK-SPIRV-DAG: TypeFloat [[#Float:]] 32

test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_checked.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
99
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1010

11+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers,+SPV_KHR_untyped_pointers -o %t.spv
12+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
13+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
14+
15+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
16+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
17+
1118
; CHECK-SPIRV-DAG: Capability JointMatrixINTEL
1219
; CHECK-SPIRV-DAG: Capability CooperativeMatrixKHR
1320
; CHECK-SPIRV-DAG: Capability CooperativeMatrixCheckedInstructionsINTEL

test/extensions/INTEL/SPV_INTEL_joint_matrix/joint_matrix_half.ll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
1010
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1111

12+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_bfloat16_conversion,+SPV_INTEL_joint_matrix,+SPV_KHR_untyped_pointers -o %t.spv
13+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
14+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
15+
16+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
17+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
18+
1219
; CHECK-SPIRV-DAG: TypeInt [[#INT:]] 32
1320
; CHECK-SPIRV-DAG: TypeFloat [[#Half:]] 16
1421
; CHECK-SPIRV-DAG: TypeFloat [[#Float:]] 32

test/extensions/KHR/SPV_KHR_cooperative_matrix/access_store.ll

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
; RUN: llvm-as < %s -o %t.bc
22
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix -o %t.spv
3+
; RUN: spirv-val %t.spv
34
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
4-
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-TYPED-PTR
56

67
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
7-
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
8+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-TYPED-PTR
9+
10+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_cooperative_matrix,+SPV_KHR_untyped_pointers -o %t.spv
11+
; RUN: spirv-val %t.spv
12+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
13+
; RUN: FileCheck < %t.spt %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-UNTYPED-PTR
14+
15+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
16+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefixes=CHECK-LLVM,CHECK-LLVM-UNTYPED-PTR
817

918
; CHECK-SPIRV: TypeInt [[#TypeInt:]] 32 0
1019
; CHECK-SPIRV-DAG: Constant [[#TypeInt]] [[#Const0:]] 0
@@ -15,18 +24,21 @@
1524

1625
; CHECK-SPIRV: TypeCooperativeMatrixKHR [[#TypeMatrix:]] [[#TypeInt]] [[#Const3]] [[#Const12]] [[#Const12]] [[#Const0]]
1726
; CHECK-SPIRV: TypePointer [[#TypeMatrixPtr:]] 7 [[#TypeMatrix]]
18-
; CHECK-SPIRV: TypePointer [[#TypeIntPtr:]] 7 [[#TypeInt]]
27+
; CHECK-SPIRV-TYPED-PTR: TypePointer [[#TypeIntPtr:]] 7 [[#TypeInt]]
28+
; CHECK-SPIRV-UNTYPED-PTR: TypeUntypedPointerKHR [[#TypePtr:]] 7
1929

2030
; CHECK-SPIRV: Variable [[#TypeMatrixPtr]] [[#VarMatrixPtr:]] 7
2131
; CHECK-SPIRV: CompositeConstruct [[#TypeMatrix]] [[#Composite:]] [[#Const0]]
2232
; CHECK-SPIRV: Store [[#VarMatrixPtr]] [[#Composite]]
23-
; CHECK-SPIRV: AccessChain [[#TypeIntPtr]] [[#Res:]] [[#VarMatrixPtr]] [[#Const1]]
33+
; CHECK-SPIRV-TYPED-PTR: AccessChain [[#TypeIntPtr]] [[#Res:]] [[#VarMatrixPtr]] [[#Const1]]
34+
; CHECK-SPIRV-UNTYPED-PTR: UntypedAccessChainKHR [[#TypePtr]] [[#Res:]] [[#TypeMatrix]] [[#VarMatrixPtr]] [[#Const1]]
2435
; CHECK-SPIRV: Store [[#Res]] [[#Const42]]
2536

2637
; CHECK-LLVM: %0 = alloca target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0)
2738
; CHECK-LLVM: %Obj = call spir_func target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) @_Z26__spirv_CompositeConstructi(i32 0)
2839
; CHECK-LLVM: store target("spirv.CooperativeMatrixKHR", i32, 3, 12, 12, 0) %Obj, ptr %0
29-
; CHECK-LLVM: %call = call spir_func ptr @_Z19__spirv_AccessChainPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1)
40+
; CHECK-LLVM-TYPED-PTR: %call = call spir_func ptr @_Z19__spirv_AccessChainPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1)
41+
; CHECK-LLVM-UNTYPED-PTR: %call = call spir_func ptr @_Z29__spirv_UntypedAccessChainKHRPPU3AS144__spirv_CooperativeMatrixKHR__uint_3_12_12_0i(ptr %0, i32 1)
3042
; CHECK-LLVM: store i32 42, ptr %call
3143

3244
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

0 commit comments

Comments
 (0)