This pull request aims to remove any dependency on OpenCL/SPIR-V type information in LLVM IR metadata. While, using metadata might simplify and prettify the resulting SPIR-V output (and restore some of the information missed in the transformation to opaque pointers), the overall methodology for resolving kernel parameter types is highly inefficient. The high-level strategy is to assign kernel parameter types in this order: 1. Resolving the types using builtin function calls as mangled names must contain type information or by looking up builtin definition in SPIRVBuiltins.td. Then: - Assigning the type temporarily using an intrinsic and later setting the right SPIR-V type in SPIRVGlobalRegistry after IRTranslation - Inserting a bitcast 2. Defaulting to LLVM IR types (in case of pointers the generic i8* type or types from byval/byref attributes) In case of type incompatibility (e.g. parameter defined initially as sampler_t and later used as image_t) the error will be found early on before IRTranslation (in the SPIRVEmitIntrinsics pass).
25 lines
950 B
LLVM
25 lines
950 B
LLVM
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
|
|
target triple = "spirv64-unknown-unknown"
|
|
|
|
; CHECK-DAG: %[[#VOID:]] = OpTypeVoid
|
|
; CHECK-DAG: %[[#INT32:]] = OpTypeInt 32 0
|
|
; CHECK-DAG: %[[#STRUCT1:]] = OpTypeStruct %[[#INT32]]
|
|
; CHECK-DAG: %[[#CONST:]] = OpConstant %[[#INT32]] 7
|
|
; CHECK-DAG: %[[#ARRAY:]] = OpTypeArray %[[#STRUCT1]] %[[#CONST]]
|
|
; CHECK-DAG: %[[#STRUCT2:]] = OpTypeStruct %[[#ARRAY]]
|
|
; CHECK-DAG: %[[#PTR:]] = OpTypePointer Function %[[#STRUCT2]]
|
|
|
|
; CHECK: %[[#FUNC:]] = OpTypeFunction %[[#VOID]] %[[#PTR]]
|
|
; CHECK: %[[#]] = OpFunction %[[#VOID]] None %[[#FUNC]]
|
|
; CHECK: %[[#]] = OpFunctionParameter %[[#PTR]]
|
|
|
|
%struct.S = type { i32 }
|
|
%struct.__wrapper_class = type { [7 x %struct.S] }
|
|
|
|
define spir_kernel void @foo(ptr noundef byref(%struct.__wrapper_class) align 4 %_arg_Arr) {
|
|
entry:
|
|
ret void
|
|
}
|