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
18 changes: 8 additions & 10 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,16 +400,6 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
if (T->isFloatingPointTy())
return mapType(T, BM->addFloatType(T->getPrimitiveSizeInBits()));

if (T->isTokenTy()) {
BM->getErrorLog().checkError(
BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_token_type),
SPIRVEC_RequiresExtension,
"SPV_INTEL_token_type\n"
"NOTE: LLVM module contains token type, which doesn't have analogs in "
"SPIR-V without extensions");
return mapType(T, BM->addTokenTypeINTEL());
}

// A pointer to image or pipe type in LLVM is translated to a SPIRV
// (non-pointer) image or pipe type.
if (T->isPointerTy()) {
Expand Down Expand Up @@ -620,6 +610,14 @@ SPIRVType *LLVMToSPIRVBase::transType(Type *T) {
}
}

if (T->isTokenTy()) {
BM->getErrorLog().checkError(
false, SPIRVEC_InvalidModule,
"LLVM module contains token type, which doesn't have a counterpart in "
"SPIR-V");
return nullptr;
}

llvm_unreachable("Not implemented!");
return 0;
}
Expand Down
44 changes: 0 additions & 44 deletions test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.ll

This file was deleted.

50 changes: 50 additions & 0 deletions test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.spt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; RUN: llvm-spirv %s -to-binary -o %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

; CHECK-LLVM: declare token @llvm.tokenfoo()

119734787 65536 393230 13 0
2 Capability Addresses
2 Capability Linkage
2 Capability Kernel
2 Capability TokenTypeINTEL
7 Extension "SPV_INTEL_token_type"
5 ExtInstImport 1 "OpenCL.std"
3 MemoryModel 1 2
4 EntryPoint 6 10 "foo"
3 Source 3 102000
6 Name 4 "llvm.tokenfoo"
3 Name 7 "foo"
4 Name 8 "entry"
3 Name 9 "tok"

8 Decorate 4 LinkageAttributes "llvm.tokenfoo" Import
5 Decorate 7 LinkageAttributes "foo" Export
2 TypeTokenINTEL 2
3 TypeFunction 3 2
2 TypeVoid 5
3 TypeFunction 6 5



5 Function 2 4 0 3

1 FunctionEnd

5 Function 5 7 0 6

2 Label 8
4 FunctionCall 2 9 4
1 Return

1 FunctionEnd

5 Function 5 10 0 6

2 Label 11
4 FunctionCall 5 12 7
1 Return

1 FunctionEnd

6 changes: 1 addition & 5 deletions test/negative/feature_requires_extension.ll
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
; Check whether the translator reports an error for a module with token type
; if SPV_INTEL_token_type extension is not used.

; RUN: llvm-as < %s -o %t.bc
; RUN: not llvm-spirv %t.bc 2>&1 --spirv-allow-unknown-intrinsics | FileCheck %s

; CHECK: RequiresExtension: Feature requires the following SPIR-V extension:
; CHECK-NEXT: SPV_INTEL_token_type
; CHECK-NEXT: NOTE: LLVM module contains token type, which doesn't have analogs
; CHECK-SAME: in SPIR-V without extensions
; CHECK: InvalidModule: Invalid SPIR-V module: LLVM module contains token type, which doesn't have a counterpart in SPIR-V

; ModuleID = 'token.bc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024"
Expand Down
Loading