Skip to content

Commit 6387666

Browse files
vmaksimojsji
authored andcommitted
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). Original commit: KhronosGroup/SPIRV-LLVM-Translator@a1f6742cd6a2ce2
1 parent 412025f commit 6387666

19 files changed

+280
-14
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2242,8 +2242,10 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
22422242
auto *AC = static_cast<SPIRVAccessChainBase *>(BV);
22432243
auto *Base = transValue(AC->getBase(), F, BB);
22442244
SPIRVType *BaseSPVTy = AC->getBaseType();
2245-
if (BaseSPVTy->isTypePointer() &&
2246-
BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) {
2245+
if ((BaseSPVTy->isTypePointer() &&
2246+
BaseSPVTy->getPointerElementType()->isTypeCooperativeMatrixKHR()) ||
2247+
(isUntypedAccessChainOpCode(OC) &&
2248+
BaseSPVTy->isTypeCooperativeMatrixKHR())) {
22472249
return mapValue(BV, transSPIRVBuiltinFromInst(AC, BB));
22482250
}
22492251
Type *BaseTy =
@@ -3521,23 +3523,64 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35213523
BasicBlock *BB) {
35223524
std::string MangledName;
35233525
auto Ops = BI->getOperands();
3526+
Op OC = BI->getOpCode();
3527+
if (isUntypedAccessChainOpCode(OC)) {
3528+
auto *AC = static_cast<SPIRVAccessChainBase *>(BI);
3529+
if (AC->getBaseType()->isTypeCooperativeMatrixKHR())
3530+
Ops.erase(Ops.begin());
3531+
}
35243532
Type *RetTy =
35253533
BI->hasType() ? transType(BI->getType()) : Type::getVoidTy(*Context);
35263534
transOCLBuiltinFromInstPreproc(BI, RetTy, Ops);
35273535
std::vector<Type *> ArgTys =
35283536
transTypeVector(SPIRVInstruction::getOperandTypes(Ops), true);
35293537

3530-
// Special handling for "truly" untyped pointers to preserve correct
3531-
// builtin mangling of atomic operations.
35323538
auto Ptr = findFirstPtrType(ArgTys);
35333539
if (Ptr < ArgTys.size() &&
35343540
BI->getValueType(Ops[Ptr]->getId())->isTypeUntypedPointerKHR()) {
3535-
if (isAtomicOpCodeUntypedPtrSupported(BI->getOpCode())) {
3541+
// Special handling for "truly" untyped pointers to preserve correct
3542+
// builtin mangling of atomic and matrix operations.
3543+
if (isAtomicOpCodeUntypedPtrSupported(OC)) {
35363544
auto *AI = static_cast<SPIRVAtomicInstBase *>(BI);
35373545
ArgTys[Ptr] = TypedPointerType::get(
35383546
transType(AI->getSemanticType()),
35393547
SPIRSPIRVAddrSpaceMap::rmap(
35403548
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3549+
} else if (OC == spv::OpCooperativeMatrixStoreKHR ||
3550+
OC == spv::internal::OpJointMatrixStoreINTEL ||
3551+
OC == spv::internal::OpCooperativeMatrixStoreCheckedINTEL ||
3552+
OC == spv::internal::OpJointMatrixLoadINTEL ||
3553+
OC == spv::OpCompositeConstruct ||
3554+
OC == spv::internal::OpCooperativeMatrixApplyFunctionINTEL) {
3555+
auto *Val = transValue(Ops[Ptr], BB->getParent(), BB);
3556+
Val = Val->stripPointerCasts();
3557+
if (auto *GEP = dyn_cast<GetElementPtrInst>(Val))
3558+
ArgTys[Ptr] = TypedPointerType::get(
3559+
GEP->getSourceElementType(),
3560+
SPIRSPIRVAddrSpaceMap::rmap(
3561+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3562+
else if (auto *AI = dyn_cast<AllocaInst>(Val))
3563+
ArgTys[Ptr] = TypedPointerType::get(
3564+
AI->getAllocatedType(),
3565+
SPIRSPIRVAddrSpaceMap::rmap(
3566+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3567+
else if (isa<Argument>(Val) && !RetTy->isVoidTy()) {
3568+
// Pointer could be a function parameter. Assume that the type of the
3569+
// pointer is the same as the return type.
3570+
Type *Ty = nullptr;
3571+
// it return type is array type, assign its element type to Ty
3572+
if (RetTy->isArrayTy())
3573+
Ty = RetTy->getArrayElementType();
3574+
else if (RetTy->isVectorTy())
3575+
Ty = cast<VectorType>(RetTy)->getElementType();
3576+
else
3577+
Ty = RetTy;
3578+
3579+
ArgTys[Ptr] = TypedPointerType::get(
3580+
Ty,
3581+
SPIRSPIRVAddrSpaceMap::rmap(
3582+
BI->getValueType(Ops[Ptr]->getId())->getPointerStorageClass()));
3583+
}
35413584
}
35423585
}
35433586

@@ -3550,8 +3593,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35503593
if (BM->getDesiredBIsRepresentation() != BIsRepresentation::SPIRVFriendlyIR)
35513594
mangleOpenClBuiltin(FuncName, ArgTys, MangledName);
35523595
else
3553-
MangledName =
3554-
getSPIRVFriendlyIRFunctionName(FuncName, BI->getOpCode(), ArgTys, Ops);
3596+
MangledName = getSPIRVFriendlyIRFunctionName(FuncName, OC, ArgTys, Ops);
35553597

35563598
opaquifyTypedPointers(ArgTys);
35573599

@@ -3574,14 +3616,13 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
35743616
Func->setCallingConv(CallingConv::SPIR_FUNC);
35753617
if (isFuncNoUnwind())
35763618
Func->addFnAttr(Attribute::NoUnwind);
3577-
auto OC = BI->getOpCode();
35783619
if (isGroupOpCode(OC) || isGroupNonUniformOpcode(OC) ||
35793620
isIntelSubgroupOpCode(OC) || isSplitBarrierINTELOpCode(OC) ||
35803621
OC == OpControlBarrier)
35813622
Func->addFnAttr(Attribute::Convergent);
35823623
}
35833624
CallInst *Call;
3584-
if (BI->getOpCode() == OpCooperativeMatrixLengthKHR &&
3625+
if (OC == OpCooperativeMatrixLengthKHR &&
35853626
Ops[0]->getOpCode() == OpTypeCooperativeMatrixKHR) {
35863627
// OpCooperativeMatrixLengthKHR needs special handling as its operand is
35873628
// a Type instead of a Value.

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6829,8 +6829,28 @@ LLVMToSPIRVBase::transBuiltinToInstWithoutDecoration(Op OC, CallInst *CI,
68296829
SPRetTy = transType(F->getParamStructRetType(0));
68306830
Args.erase(Args.begin());
68316831
}
6832+
if (RetTy->isPointerTy() &&
6833+
BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers)) {
6834+
if (OC == OpAccessChain)
6835+
OC = OpUntypedAccessChainKHR;
6836+
else if (OC == OpInBoundsAccessChain)
6837+
OC = OpUntypedInBoundsAccessChainKHR;
6838+
else if (OC == OpPtrAccessChain)
6839+
OC = OpUntypedPtrAccessChainKHR;
6840+
else if (OC == OpInBoundsPtrAccessChain)
6841+
OC = OpUntypedInBoundsPtrAccessChainKHR;
6842+
}
68326843
auto *SPI = SPIRVInstTemplateBase::create(OC);
68336844
std::vector<SPIRVWord> SPArgs;
6845+
if (isUntypedAccessChainOpCode(OC)) {
6846+
// Untyped access chain instructions have an additional argument BaseTy.
6847+
Type *Ty = Scavenger->getScavengedType(Args[0]);
6848+
SPIRVType *PtrTy = nullptr;
6849+
if (auto *TPT = dyn_cast<TypedPointerType>(Ty)) {
6850+
PtrTy = transType(TPT->getElementType());
6851+
SPArgs.push_back(PtrTy->getId());
6852+
}
6853+
}
68346854
for (size_t I = 0, E = Args.size(); I != E; ++I) {
68356855
if (Args[I]->getType()->isPointerTy()) {
68366856
Value *Pointee = Args[I]->stripPointerCasts();

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1738,6 +1738,16 @@ class SPIRVAccessChainBase : public SPIRVInstTemplateBase {
17381738
OpCode == OpUntypedPtrAccessChainKHR ||
17391739
OpCode == OpUntypedInBoundsPtrAccessChainKHR;
17401740
}
1741+
SPIRVCapVec getRequiredCapability() const override {
1742+
if (isUntyped())
1743+
return getVec(CapabilityUntypedPointersKHR);
1744+
return {};
1745+
}
1746+
std::optional<ExtensionID> getRequiredExtension() const override {
1747+
if (isUntyped())
1748+
return ExtensionID::SPV_KHR_untyped_pointers;
1749+
return {};
1750+
}
17411751
};
17421752

17431753
template <Op OC, unsigned FixedWC>

llvm-spirv/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) ||

llvm-spirv/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

llvm-spirv/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

llvm-spirv/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"

llvm-spirv/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"

llvm-spirv/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"

llvm-spirv/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

llvm-spirv/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

llvm-spirv/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

llvm-spirv/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

llvm-spirv/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)