Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ SPIRVType *LLVMToSPIRVBase::transPointerType(SPIRVType *ET, unsigned AddrSpc) {
return transPointerType(ET, SPIRAS_Private);
if (BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers) &&
!(ET->isTypeArray() || ET->isTypeVector() || ET->isTypeStruct() ||
ET->isTypeImage() || ET->isTypeSampler() || ET->isTypePipe())) {
ET->isSPIRVOpaqueType())) {
TranslatedTy = BM->addUntypedPointerKHRType(
SPIRSPIRVAddrSpaceMap::map(static_cast<SPIRAddressSpace>(AddrSpc)));
} else {
Expand Down Expand Up @@ -2220,11 +2220,11 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
MemoryAccess.clear();
if (BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_untyped_pointers)) {
SPIRVValue *Source = transValue(LD->getPointerOperand(), BB);
SPIRVType *PtrElTy = Source->getType()->getPointerElementType();
SPIRVType *LoadTy = transType(LD->getType());
// For images do not use explicit load type, but rather use the source
// type (calculated in SPIRVLoad constructor)
if (LoadTy->isTypeUntypedPointerKHR() &&
(Source->getType()->getPointerElementType()->isTypeImage())) {
// For special types (images, pipes, etc.) do not use explicit load type,
// but rather use the source type (calculated in SPIRVLoad constructor)
if (LoadTy->isTypeUntypedPointerKHR() && PtrElTy->isSPIRVOpaqueType()) {
LoadTy = nullptr;
}
return mapValue(V, BM->addLoadInst(Source, MemoryAccess, BB, LoadTy));
Expand Down
8 changes: 8 additions & 0 deletions lib/SPIRV/libSPIRV/SPIRVType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ bool SPIRVType::isTypeVectorOrScalarFloat() const {
return isTypeFloat() || isTypeVectorFloat();
}

bool SPIRVType::isSPIRVOpaqueType() const {
return isTypeDeviceEvent() || isTypeEvent() || isTypeImage() ||
isTypePipe() || isTypeReserveId() || isTypeSampler() ||
isTypeSampledImage() || isTypePipeStorage() ||
isTypeCooperativeMatrixKHR() || isTypeJointMatrixINTEL() ||
isTypeTaskSequenceINTEL();
}

bool SPIRVTypeStruct::isPacked() const {
return hasDecorate(DecorationCPacked);
}
Expand Down
1 change: 1 addition & 0 deletions lib/SPIRV/libSPIRV/SPIRVType.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class SPIRVType : public SPIRVEntry {
bool isTypeSubgroupAvcINTEL() const;
bool isTypeSubgroupAvcMceINTEL() const;
bool isTypeTaskSequenceINTEL() const;
bool isSPIRVOpaqueType() const;
};

class SPIRVTypeVoid : public SPIRVType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
; RUN: llvm-dis %t.rev.bc
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM

; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence,+SPV_KHR_untyped_pointers -o %t.spv
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV

; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis %t.rev.bc
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM

; Source SYCL code example
; int mult(int a, int b) {
; return a * b;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
; RUN: llvm-dis %t.rev.bc
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM

; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_task_sequence,+SPV_KHR_untyped_pointers -o %t.spv
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV

; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis %t.rev.bc
; RUN: FileCheck < %t.rev.ll %s --check-prefix=CHECK-LLVM

; CHECK-SPIRV: TypeInt [[#IntTy:]] 32 0
; CHECK-SPIRV: TypeTaskSequenceINTEL [[#TypeTS:]]
; CHECK-SPIRV: TypeFunction [[#FuncTy:]] [[#IntTy]] [[#IntTy]] [[#IntTy]]
Expand Down
13 changes: 13 additions & 0 deletions test/transcoding/enqueue_marker.cl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@
// RUN: llvm-spirv %t.rev.bc -spirv-text -o %t.spv.txt
// RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV

// RUN: llvm-spirv --spirv-ext=+SPV_KHR_untyped_pointers %t.bc -spirv-text -o %t.spv.txt
// RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV
// RUN: llvm-spirv --spirv-ext=+SPV_KHR_untyped_pointers %t.bc -o %t.spv
// RUN: spirv-val %t.spv
// RUN: llvm-spirv -r %t.spv -o %t.rev.bc
// RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
// RUN: llvm-spirv -r -spirv-target-env="SPV-IR" %t.spv -o %t.rev.bc
// RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-SPV-IR

// Check that SPIR-V friendly IR is correctly recognized
// RUN: llvm-spirv --spirv-ext=+SPV_KHR_untyped_pointers %t.rev.bc -spirv-text -o %t.spv.txt
// RUN: FileCheck < %t.spv.txt %s --check-prefix=CHECK-SPIRV

kernel void test_enqueue_marker(global int *out) {
queue_t queue = get_default_queue();

Expand Down
Loading