diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp index 66bdda917f..20f128b4cc 100644 --- a/lib/SPIRV/SPIRVWriter.cpp +++ b/lib/SPIRV/SPIRVWriter.cpp @@ -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()) { @@ -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; } diff --git a/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.ll b/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.ll deleted file mode 100644 index 615f69d23a..0000000000 --- a/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.ll +++ /dev/null @@ -1,44 +0,0 @@ -; RUN: llvm-as < %s -o %t.bc -; RUN: llvm-spirv %t.bc -o %t.spv --spirv-allow-unknown-intrinsics --spirv-ext=+SPV_INTEL_token_type -; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV -; RUN: llvm-spirv -r %t.spv -o %t.rev.bc -; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM - -; CHECK-SPIRV: Capability TokenTypeINTEL -; CHECK-SPIRV: Extension "SPV_INTEL_token_type" -; CHECK-SPIRV: Name [[#FUN:]] "llvm.tokenfoo" -; CHECK-SPIRV: TypeTokenINTEL [[#TYPE:]] -; CHECK-SPIRV: TypeFunction [[#FUN_TYPE:]] [[#TYPE]] -; CHECK-SPIRV: Function {{.*}} [[#FUN]] {{.*}} [[#FUN_TYPE]] - - -; 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" -target triple = "spir-unknown-unknown" - -; CHECK-LLVM: declare token @llvm.tokenfoo() -declare token @llvm.tokenfoo() - -; Function Attrs: nounwind -define spir_kernel void @foo() #0 !kernel_arg_addr_space !2 !kernel_arg_access_qual !2 !kernel_arg_type !2 !kernel_arg_type_qual !2 !kernel_arg_base_type !2 { -entry: -; CHECK-LLVM: call token @llvm.tokenfoo() - %tok = call token @llvm.tokenfoo() - ret void -} - -attributes #0 = { nounwind } - -!spirv.MemoryModel = !{!0} -!opencl.enable.FP_CONTRACT = !{} -!spirv.Source = !{!1} -!opencl.spir.version = !{!0} -!opencl.ocl.version = !{!0} -!opencl.used.extensions = !{!2} -!opencl.used.optional.core.features = !{!2} -!spirv.Generator = !{!3} - -!0 = !{i32 1, i32 2} -!1 = !{i32 3, i32 102000} -!2 = !{} -!3 = !{i16 6, i16 14} diff --git a/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.spt b/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.spt new file mode 100644 index 0000000000..76d5f351f2 --- /dev/null +++ b/test/extensions/INTEL/SPV_INTEL_token_type/token_type_intel.spt @@ -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 + diff --git a/test/negative/feature_requires_extension.ll b/test/negative/feature_requires_extension.ll index 7ecc34d97a..b48985cef5 100644 --- a/test/negative/feature_requires_extension.ll +++ b/test/negative/feature_requires_extension.ll @@ -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"