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).
21 lines
887 B
LLVM
21 lines
887 B
LLVM
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK
|
|
|
|
; CHECK-DAG: %[[#Int32Ty:]] = OpTypeInt 32 0
|
|
; CHECK-DAG: %[[#PtrInt32Ty:]] = OpTypePointer Function %[[#Int32Ty]]
|
|
; CHECK-DAG: %[[#Int64Ty:]] = OpTypeInt 64 0
|
|
; CHECK-DAG: %[[#PtrInt64Ty:]] = OpTypePointer Function %[[#Int64Ty]]
|
|
; CHECK-DAG: %[[#FTy:]] = OpTypeFunction %[[#Int64Ty]] %[[#PtrInt32Ty]]
|
|
; CHECK-DAG: %[[#Const:]] = OpConstant %[[#Int32Ty]] 0
|
|
; CHECK: OpFunction %[[#Int64Ty]] None %[[#FTy]]
|
|
; CHECK: %[[#Param:]] = OpFunctionParameter %[[#PtrInt32Ty]]
|
|
; CHECK: OpStore %[[#Param]] %[[#Const]] Aligned 4
|
|
; CHECK-DAG: %[[#Bitcast:]] = OpBitcast %[[#PtrInt64Ty]] %[[#Param]]
|
|
; CHECK: %[[#Res:]] = OpLoad %[[#Int64Ty]] %[[#Bitcast]] Aligned 4
|
|
; CHECK: OpReturnValue %[[#Res]]
|
|
|
|
define i64 @test(ptr %p) {
|
|
store i32 0, ptr %p, align 4
|
|
%v = load i64, ptr %p, align 4
|
|
ret i64 %v
|
|
}
|