Skip to content

Commit c9a3ce3

Browse files
searlmc1AlexVlxsvenvhsumesh-s-mcwbashbaug
authored
update amd-develop with amd-staging (#8)
* Absorb upstream carnage around `Triple`. (#6) * Re-sync with upstream, fix BitCast noise (#7) * Update after llvm::Triple changes (#3046) Update after llvm-project commit `979c275097a6 ("[IR] Store Triple in Module (NFC) (#129868)", 2025-03-06)`. * Corrected subnormal checking logic issubnormal(V) ==> unsigned(abs(V) -1) (#3036) Corrected sunormal checking logic in is_fpclass intrinsic issubnormal(V) ==> unsigned(abs(V) - 1) < (all mantissa bits set) corrected the testfile to check the corrected logic * properly handle LOD values when nontemporal image operand is present (#3050) Instead of checking that the image operands are equal to the LOD mask, check that the LOD bit is in the image operands. This way an LOD value of zero may be ignored even when image operands contains bits other than the LOD bit, such as for the SPIR-V 1.6 nontemporal image operand. fixes #3049 * [NFC] Add some missing includes (#3045) llvm-spirv.cpp was relying on transitive includes for these. Also remove an unneeded `<set>` include. * Emit error for LLVM bfloat type (#3047) Signed-off-by: Arvind Sudarsanam <[email protected]> * Update DebugInfo test after LLVM change (#3060) Update the pattern after llvm-project commit da0f9e75d858 ("Reland: [MC] output inlined-at debug info (#106230) (#130306)", 2025-03-11). --------- Signed-off-by: Arvind Sudarsanam <[email protected]> Co-authored-by: Sven van Haastregt <[email protected]> Co-authored-by: sumesh-s-mcw <[email protected]> Co-authored-by: Ben Ashbaugh <[email protected]> Co-authored-by: Arvind Sudarsanam <[email protected]> --------- Signed-off-by: Arvind Sudarsanam <[email protected]> Co-authored-by: Alex Voicu <[email protected]> Co-authored-by: Sven van Haastregt <[email protected]> Co-authored-by: sumesh-s-mcw <[email protected]> Co-authored-by: Ben Ashbaugh <[email protected]> Co-authored-by: Arvind Sudarsanam <[email protected]>
1 parent 2b0f765 commit c9a3ce3

11 files changed

+196
-93
lines changed

lib/SPIRV/OCLToSPIRV.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,8 @@ void OCLToSPIRVBase::visitCallInst(CallInst &CI) {
316316
DemangledName == kOCLBuiltinName::Barrier ||
317317
DemangledName == kOCLBuiltinName::SubGroupBarrier) {
318318
if (F->arg_size() != 1 && F->arg_size() != 2 &&
319-
F->getParent()->getTargetTriple() == "spirv64-amd-amdhsa")
319+
F->getParent()->getTargetTriple().getVendor()
320+
== Triple::VendorType::AMD)
320321
return; // Somebody used the name.
321322
visitCallBarrier(&CI);
322323
return;

lib/SPIRV/SPIRVReader.cpp

+59-49
Large diffs are not rendered by default.

lib/SPIRV/SPIRVToOCL.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void SPIRVToOCLBase::visitCastInst(CastInst &Cast) {
239239
!isa<UIToFPInst>(Cast) && !isa<SIToFPInst>(Cast))
240240
return;
241241

242-
if (M->getTargetTriple() == "amdgcn-amd-amdhsa")
242+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
243243
return;
244244

245245
Type const *SrcTy = Cast.getSrcTy();
@@ -755,8 +755,10 @@ SPIRVToOCLBase::mutateCallImageOperands(CallInst *CI, StringRef NewFuncName,
755755
ConstantFP *LodVal = dyn_cast<ConstantFP>(Mutator.getArg(ImOpArgIndex));
756756
// If the image operand is LOD and its value is zero, drop it too.
757757
if (LodVal && LodVal->isNullValue() &&
758-
ImOpValue == ImageOperandsMask::ImageOperandsLodMask)
758+
ImOpValue & ImageOperandsMask::ImageOperandsLodMask) {
759759
Mutator.removeArgs(ImOpArgIndex, Mutator.arg_size() - ImOpArgIndex);
760+
ImOpValue &= ~ImageOperandsMask::ImageOperandsLodMask;
761+
}
760762
}
761763
}
762764
return Mutator;

lib/SPIRV/SPIRVToOCL20.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ static void visitCallLLVMFence(CallInst *CI) { // TODO: AMDSPV JANK, this is inc
184184
}
185185

186186
void SPIRVToOCL20Base::visitCallSPIRVMemoryBarrier(CallInst *CI) {
187-
if (M->getTargetTriple() == "amdgcn-amd-amdhsa")
187+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
188188
return visitCallLLVMFence(CI);
189189

190190
Value *MemScope =
@@ -245,7 +245,7 @@ void SPIRVToOCL20Base::mutateAtomicName(CallInst *CI, Op OC) {
245245
void SPIRVToOCL20Base::visitCallSPIRVAtomicBuiltin(CallInst *CI, Op OC) {
246246
CallInst *CIG = mutateCommonAtomicArguments(CI, OC);
247247

248-
if (M->getTargetTriple() == "amdgcn-amd-amdhsa")
248+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
249249
return translateSPIRVAtomicBuiltinToLLVMAtomicOp(CIG, OC);
250250

251251
switch (OC) {
@@ -289,8 +289,9 @@ CallInst *SPIRVToOCL20Base::mutateCommonAtomicArguments(CallInst *CI, Op OC) {
289289

290290
Mutator.mapArgs([=](IRBuilder<> &Builder, Value *PtrArg, Type *PtrArgTy) {
291291
if (auto *TypedPtrTy = dyn_cast<TypedPointerType>(PtrArgTy)) {
292-
unsigned AS = M->getTargetTriple() == "amdgcn-amd-amdhsa" ?
293-
mapSPIRVAddrSpaceToAMDGPU(StorageClassGeneric) : SPIRAS_Generic;
292+
unsigned AS = M->getTargetTriple().getVendor() == Triple::VendorType::AMD
293+
? mapSPIRVAddrSpaceToAMDGPU(StorageClassGeneric)
294+
: SPIRAS_Generic;
294295
if (TypedPtrTy->getAddressSpace() != AS) {
295296
Type *ElementTy = TypedPtrTy->getElementType();
296297
Type *FixedPtr = PointerType::get(ElementTy, AS);
@@ -338,9 +339,10 @@ void SPIRVToOCL20Base::visitCallSPIRVAtomicCmpExchg(CallInst *CI) {
338339
.mapArg(1,
339340
[=](IRBuilder<> &Builder, Value *Expected) {
340341
Builder.CreateStore(Expected, PExpected);
341-
unsigned AddrSpc = M->getTargetTriple() == "amdgcn-amd-amdhsa" ?
342-
mapSPIRVAddrSpaceToAMDGPU(StorageClassGeneric) :
343-
SPIRAS_Generic;
342+
unsigned AddrSpc =
343+
M->getTargetTriple().getVendor() == Triple::VendorType::AMD
344+
? mapSPIRVAddrSpaceToAMDGPU(StorageClassGeneric)
345+
: SPIRAS_Generic;
344346
Type *PtrTyAS = PointerType::get(PExpected->getType(), AddrSpc);
345347
Value *V = Builder.CreateAddrSpaceCast(
346348
PExpected, PtrTyAS, PExpected->getName() + ".as");
@@ -382,7 +384,7 @@ void SPIRVToOCL20Base::visitCallSPIRVEnqueueKernel(CallInst *CI, Op OC) {
382384

383385
auto Mutator = mutateCallInst(CI, FName.str());
384386
Mutator.mapArg(6, [=](IRBuilder<> &Builder, Value *Invoke) {
385-
unsigned AS = M->getTargetTriple() == "amdgcn-amd-amdhsa" ?
387+
unsigned AS = M->getTargetTriple().getVendor() == Triple::VendorType::AMD ?
386388
mapSPIRVAddrSpaceToAMDGPU(StorageClassGeneric) : SPIRAS_Generic;
387389
Value *Replace = CastInst::CreatePointerBitCastOrAddrSpaceCast(
388390
Invoke, Builder.getPtrTy(AS), "", CI->getIterator());

lib/SPIRV/SPIRVUtil.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Function *getOrCreateFunction(Module *M, Type *RetTy, ArrayRef<Type *> ArgTypes,
303303
if (F)
304304
NewF->setDSOLocal(F->isDSOLocal());
305305
F = NewF;
306-
if (M->getTargetTriple() == "amdgcn-amd-amdhsa")
306+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
307307
F->setCallingConv(CallingConv::C);
308308
else
309309
F->setCallingConv(CallingConv::SPIR_FUNC);

lib/SPIRV/SPIRVWriter.cpp

+31-21
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,9 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
397397
}
398398
}
399399

400+
// Emit error if type is bfloat. LLVM native bfloat type is not supported.
401+
BM->getErrorLog().checkError(!T->isBFloatTy(),
402+
SPIRVEC_UnsupportedLLVMBFloatType);
400403
if (T->isFloatingPointTy())
401404
return mapType(T, BM->addFloatType(T->getPrimitiveSizeInBits()));
402405

@@ -441,7 +444,8 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
441444
// It must be at least 1.
442445
const auto ArraySize =
443446
T->getArrayNumElements() ? T->getArrayNumElements() :
444-
(M->getTargetTriple() == "spirv64-amd-amdhsa" ? UINT32_MAX : 1);
447+
(M->getTargetTriple().getVendor() == Triple::VendorType::AMD
448+
? UINT32_MAX : 1);
445449

446450
Type *ElTy = T->getArrayElementType();
447451
SPIRVType *TransType = BM->addArrayType(
@@ -753,7 +757,7 @@ SPIRVType *LLVMToSPIRVBase::transPointerType(SPIRVType *ET, unsigned AddrSpc) {
753757
return transPointerType(ET, SPIRAS_Private);
754758
if (BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers) &&
755759
!(ET->isTypeArray() || ET->isTypeVector() || ET->isSPIRVOpaqueType() ||
756-
(M->getTargetTriple() == "spirv64-amd-amdhsa" &&
760+
(M->getTargetTriple().getVendor() == Triple::VendorType::AMD &&
757761
ET->getOpCode() == OpTypeFunction))) {
758762
TranslatedTy = BM->addUntypedPointerKHRType(
759763
SPIRSPIRVAddrSpaceMap::map(static_cast<SPIRAddressSpace>(AddrSpc)));
@@ -842,12 +846,12 @@ SPIRVType *LLVMToSPIRVBase::transScavengedType(Value *V) {
842846
// error. To be on the safe side, an assertion is added to check printf
843847
// never reaches this point.
844848
assert(F->getName() != "printf");
845-
if (M->getTargetTriple() != "spirv64-amd-amdhsa")
849+
if (M->getTargetTriple().getVendor() != Triple::VendorType::AMD)
846850
BM->getErrorLog().checkError(!FnTy->isVarArg(),
847851
SPIRVEC_UnsupportedVarArgFunction);
848852

849853
SPIRVType *RT = transType(FnTy->getReturnType());
850-
if (M->getTargetTriple() == "spirv64-amd-amdhsa" &&
854+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD &&
851855
F->hasName() && F->getName().contains("dispatch.ptr"))
852856
RT = transType(PointerType::get(F->getContext(), SPIRAS_Constant));
853857

@@ -1596,7 +1600,8 @@ SPIRVValue *LLVMToSPIRVBase::transUnaryInst(UnaryInstruction *U,
15961600
return BM->addUndef(ExpectedTy);
15971601
}
15981602
}
1599-
if (isa<VAArgInst>(U) && M->getTargetTriple() == "spirv64-amd-amdhsa") {
1603+
if (isa<VAArgInst>(U) &&
1604+
M->getTargetTriple().getVendor() == Triple::VendorType::AMD) {
16001605
SPIRVType *ExpectedTy = transScavengedType(U);
16011606
return BM->addUndef(ExpectedTy);
16021607
}
@@ -1606,7 +1611,7 @@ SPIRVValue *LLVMToSPIRVBase::transUnaryInst(UnaryInstruction *U,
16061611
const auto SrcAddrSpace = Cast->getSrcTy()->getPointerAddressSpace();
16071612
const auto DestAddrSpace = Cast->getDestTy()->getPointerAddressSpace();
16081613
if (DestAddrSpace == SPIRAS_Generic) {
1609-
if (M->getTargetTriple() != "spirv64-amd-amdhsa")
1614+
if (M->getTargetTriple().getVendor() != Triple::VendorType::AMD)
16101615
getErrorLog().checkError(
16111616
SrcAddrSpace != SPIRAS_Constant, SPIRVEC_InvalidModule, U,
16121617
"Casts from constant address space to generic are illegal\n");
@@ -1649,7 +1654,7 @@ SPIRVValue *LLVMToSPIRVBase::transUnaryInst(UnaryInstruction *U,
16491654
SrcAddrSpace == SPIRAS_Generic, SPIRVEC_InvalidModule, U,
16501655
"Casts from private/local/global address space are allowed only to "
16511656
"generic\n");
1652-
if (M->getTargetTriple() != "spirv64-amd-amdhsa")
1657+
if (M->getTargetTriple().getVendor() != Triple::VendorType::AMD)
16531658
getErrorLog().checkError(
16541659
DestAddrSpace != SPIRAS_Constant, SPIRVEC_InvalidModule, U,
16551660
"Casts from generic address space to constant are illegal\n");
@@ -2131,7 +2136,7 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
21312136
GV->isConstant(), transLinkageType(GV), BVarInit, GV->getName().str(),
21322137
StorageClass, nullptr));
21332138
if (GV->isExternallyInitialized() &&
2134-
M->getTargetTriple() == "spirv64-amd-amdhsa")
2139+
M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
21352140
BVar->addDecorate(DecorationUserTypeGOOGLE,
21362141
BM->getString("externally_initialized")->getId());
21372142

@@ -2320,10 +2325,11 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
23202325
BB));
23212326

23222327
if (AllocaInst *Alc = dyn_cast<AllocaInst>(V)) {
2323-
SPIRVType *TranslatedTy = M->getTargetTriple() != "spirv64-amd-amdhsa" ?
2324-
transScavengedType(V) :
2325-
BM->addPointerType(StorageClassFunction,
2326-
transType(Alc->getAllocatedType()));
2328+
SPIRVType *TranslatedTy =
2329+
M->getTargetTriple().getVendor() != Triple::VendorType::AMD
2330+
? transScavengedType(V)
2331+
: BM->addPointerType(StorageClassFunction,
2332+
transType(Alc->getAllocatedType()));
23272333
if (Alc->isArrayAllocation()) {
23282334
SPIRVValue *Length = transValue(Alc->getArraySize(), BB);
23292335
assert(Length && "Couldn't translate array size!");
@@ -3140,7 +3146,7 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
31403146
((Opcode == Instruction::FNeg || Opcode == Instruction::FCmp ||
31413147
BV->isExtInst()) &&
31423148
BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_6)) ||
3143-
(M->getTargetTriple() == "spirv64-amd-amdhsa" &&
3149+
(M->getTargetTriple().getVendor() == Triple::VendorType::AMD &&
31443150
Opcode == Instruction::Call)) {
31453151
FastMathFlags FMF = BVF->getFastMathFlags();
31463152
SPIRVWord M{0};
@@ -3260,7 +3266,8 @@ void LLVMToSPIRVBase::transMemAliasingINTELDecorations(Instruction *Inst,
32603266
if (!BM->isAllowedToUseExtension(
32613267
ExtensionID::SPV_INTEL_memory_access_aliasing))
32623268
return;
3263-
if (!BV->hasId() && M->getTargetTriple() == "spirv64-amd-amdhsa") // Fences
3269+
if (!BV->hasId() &&
3270+
M->getTargetTriple().getVendor() == Triple::VendorType::AMD) // Fences
32643271
return;
32653272
if (MDNode *AliasingListMD = Inst->getMetadata(LLVMContext::MD_alias_scope)) {
32663273
auto *MemAliasList = addMemAliasingINTELInstructions(BM, AliasingListMD);
@@ -5074,7 +5081,7 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
50745081
const APInt Inf = APFloat::getInf(Semantics).bitcastToAPInt();
50755082
const APInt AllOneMantissa =
50765083
APFloat::getLargest(Semantics).bitcastToAPInt() & ~Inf;
5077-
5084+
const APInt OneValue = APInt(BitSize, 1);
50785085
// Some checks can be inverted tests for simple cases, for example
50795086
// simultaneous check for inf, normal, subnormal and zero is a check for
50805087
// non nan.
@@ -5183,8 +5190,10 @@ SPIRVValue *LLVMToSPIRVBase::transIntrinsicInst(IntrinsicInst *II,
51835190
BM->addUnaryInst(OpBitcast, OpSPIRVTy, InputFloat, BB);
51845191
auto *MantissaConst = transValue(
51855192
Constant::getIntegerValue(IntOpLLVMTy, AllOneMantissa), BB);
5193+
auto *ConstOne =
5194+
transValue(Constant::getIntegerValue(IntOpLLVMTy, OneValue), BB);
51865195
auto *MinusOne =
5187-
BM->addBinaryInst(OpISub, OpSPIRVTy, BitCastToInt, MantissaConst, BB);
5196+
BM->addBinaryInst(OpISub, OpSPIRVTy, BitCastToInt, ConstOne, BB);
51885197
auto *TestIsSubnormal =
51895198
BM->addCmpInst(OpULessThan, ResTy, MinusOne, MantissaConst, BB);
51905199
if (FPClass & fcPosSubnormal && FPClass & fcNegSubnormal)
@@ -5529,7 +5538,7 @@ SPIRVValue *LLVMToSPIRVBase::transAsmINTEL(InlineAsm *IA) {
55295538
// TODO: intention here is to provide information about actual target
55305539
// but in fact spir-64 is substituted as triple when translator works
55315540
// eventually we need to fix it (not urgent)
5532-
StringRef TripleStr(M->getTargetTriple());
5541+
StringRef TripleStr(M->getTargetTriple().str());
55335542
auto *AsmTarget = static_cast<SPIRVAsmTargetINTEL *>(
55345543
BM->getOrAddAsmTargetINTEL(TripleStr.str()));
55355544
auto *SIA = BM->addAsmINTEL(
@@ -5980,7 +5989,7 @@ bool isEmptyLLVMModule(Module *M) {
59805989
}
59815990

59825991
bool LLVMToSPIRVBase::translate() {
5983-
if (M->getTargetTriple() == "spirv64-amd-amdhsa")
5992+
if (M->getTargetTriple().getVendor() == Triple::VendorType::AMD)
59845993
BM->setGeneratorVer(UINT16_MAX);
59855994
else
59865995
BM->setGeneratorVer(KTranslatorVer);
@@ -7043,7 +7052,8 @@ bool isValidLLVMModule(Module *M, SPIRVErrorLog &ErrorLog) {
70437052

70447053
Triple TT(M->getTargetTriple());
70457054
if (!ErrorLog.checkError(isSupportedTriple(TT), SPIRVEC_InvalidTargetTriple,
7046-
"Actual target triple is " + M->getTargetTriple()))
7055+
"Actual target triple is " +
7056+
M->getTargetTriple().str()))
70477057
return false;
70487058

70497059
return true;
@@ -7144,7 +7154,7 @@ bool runSpirvBackend(Module *M, std::string &Result, std::string &ErrMsg,
71447154
? Triple::spirv64
71457155
: Triple::spirv32,
71467156
TargetTriple.getSubArch());
7147-
M->setTargetTriple(TargetTriple.str());
7157+
M->setTargetTriple(TargetTriple);
71487158
// We need to reset Data Layout to conform with the TargetMachine
71497159
M->setDataLayout("");
71507160
}
@@ -7153,7 +7163,7 @@ bool runSpirvBackend(Module *M, std::string &Result, std::string &ErrMsg,
71537163
TargetTriple.setTriple(DefaultTriple);
71547164
TargetTriple.setArch(TargetTriple.getArch(),
71557165
spirvVersionToSubArch(TranslatorOpts.getMaxVersion()));
7156-
M->setTargetTriple(TargetTriple.str());
7166+
M->setTargetTriple(TargetTriple);
71577167
}
71587168

71597169
// Translate the Module into SPIR-V

lib/SPIRV/libSPIRV/SPIRVErrorEnum.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ _SPIRV_OP(UnspecifiedMemoryModel, "Unspecified Memory Model.")
2828
_SPIRV_OP(RepeatedMemoryModel, "Expects a single OpMemoryModel instruction.")
2929
_SPIRV_OP(UnsupportedVarArgFunction,
3030
"Variadic functions other than 'printf' are not supported in SPIR-V.")
31+
_SPIRV_OP(UnsupportedLLVMBFloatType,
32+
"LLVM bfloat type is not supported in SPIR-V.")
3133

3234
/* This is the last error code to have a maximum valid value to compare to */
3335
_SPIRV_OP(InternalMaxErrorCode, "Unknown error code")

test/bfloat.ll

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; Check that translator emits error for LLVM bfloat type
2+
; RUN: llvm-as %s -o %t.bc
3+
; RUN: not amd-llvm-spirv --spirv-ext=+all %t.bc -o %t.spv 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR
4+
5+
; CHECK-ERROR: UnsupportedLLVMBFloatType: LLVM bfloat type is not supported in SPIR-V
6+
7+
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"
8+
target triple = "spir-unknown-unknown"
9+
10+
; Function Attrs: nounwind
11+
define spir_kernel void @testBFloat(bfloat %a, bfloat %b) {
12+
entry:
13+
%r1 = fmul bfloat %a, %b
14+
ret void
15+
}
16+
17+
!llvm.module.flags = !{!0}
18+
!opencl.ocl.version = !{!1}
19+
!opencl.spir.version = !{!1}
20+
21+
!0 = !{i32 1, !"wchar_size", i32 4}
22+
!1 = !{i32 2, i32 0}

test/image_operand_nontemporal.spvasm

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; Tests the Nontemporal image operand that was added for SPIR-V 1.6.
2+
3+
; REQUIRES: spirv-as
4+
; RUN: spirv-as --target-env spv1.6 -o %t.spv %s
5+
; RUN: spirv-val %t.spv
6+
; RUN: amd-llvm-spirv -r %t.spv -o %t.rev.bc
7+
; RUN: llvm-dis %t.rev.bc
8+
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM
9+
10+
OpCapability Addresses
11+
OpCapability Kernel
12+
OpCapability ImageBasic
13+
OpCapability LiteralSampler
14+
OpMemoryModel Physical64 OpenCL
15+
OpEntryPoint Kernel %kernel "read_write_image_nontemporal"
16+
%uint = OpTypeInt 32 0
17+
%void = OpTypeVoid
18+
%read_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown ReadOnly
19+
%write_image2d_t = OpTypeImage %void 2D 0 0 0 0 Unknown WriteOnly
20+
%sampler_t = OpTypeSampler
21+
%kernel_sig = OpTypeFunction %void %read_image2d_t %write_image2d_t
22+
%sampledimage_t = OpTypeSampledImage %read_image2d_t
23+
%v2uint = OpTypeVector %uint 2
24+
%float = OpTypeFloat 32
25+
%v4float = OpTypeVector %float 4
26+
%sampler = OpConstantSampler %sampler_t None 0 Nearest
27+
%coord_0_0 = OpConstantNull %v2uint
28+
%float_0 = OpConstant %float 0
29+
%kernel = OpFunction %void None %kernel_sig
30+
%src = OpFunctionParameter %read_image2d_t
31+
%dst = OpFunctionParameter %write_image2d_t
32+
%entry = OpLabel
33+
%si = OpSampledImage %sampledimage_t %src %sampler
34+
%data0 = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod %float_0
35+
OpImageWrite %dst %coord_0_0 %data0
36+
%data1 = OpImageSampleExplicitLod %v4float %si %coord_0_0 Lod|Nontemporal %float_0
37+
OpImageWrite %dst %coord_0_0 %data1 Nontemporal
38+
OpReturn
39+
OpFunctionEnd
40+
41+
; CHECK-LLVM: define spir_kernel void @read_write_image_nontemporal
42+
; CHECK-LLVM: call spir_func <4 x float> [[READ_IMAGEF:@[a-zA-Z0-9_]+]](
43+
; CHECK-LLVM: call spir_func void [[WRITE_IMAGEF:@[a-zA-Z0-9_]+]](
44+
; CHECK-LLVM: call spir_func <4 x float> [[READ_IMAGEF]](
45+
; CHECK-LLVM: call spir_func void [[WRITE_IMAGEF]](

0 commit comments

Comments
 (0)