This PR reworks implementation of OpSpecConstantOp with ptr-cast operation (PtrCastToGeneric, GenericCastToPtr). Previous implementation didn't take into account a lot of use cases, including multiple inclusion of pointers, reference to a pointer from OpName, etc. A reproducer is attached as a new test case. This PR also fixes wrong type inference for IR patterns which generate new virtual registers without SPIRV type. Previous implementation assumed always that result has the same address space as a source that is not the fact, and, for example, led to impossibility to emit a ptr-cast operation in the reproducer, because wrong type inference rendered source and destination with the same address space, eliminating translation of G_ADDRSPACE_CAST.
20 lines
1010 B
LLVM
20 lines
1010 B
LLVM
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
|
|
; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
|
|
; CHECK-DAG: %[[Array:.*]] = OpTypeArray %[[#]] %[[#]]
|
|
; CHECK-DAG: %[[Struct:.*]] = OpTypeStruct %[[Array]]
|
|
; CHECK-DAG: %[[Zero:.*]] = OpTypeInt 64 0
|
|
; CHECK-DAG: %[[Null:.*]] = OpConstantNull %[[Zero]]
|
|
; CHECK-DAG: %[[R1:.*]] = OpConstantComposite %[[Array]] %[[Null]]
|
|
; CHECK-DAG: %[[#]] = OpConstantComposite %[[Struct]] %[[R1]]
|
|
; CHECK-DAG: %[[R2:.*]] = OpConstantComposite %[[Array]] %[[Null]]
|
|
; CHECK-DAG: %[[#]] = OpConstantComposite %[[Struct]] %[[R2]]
|
|
|
|
@G1 = addrspace(1) constant { [1 x ptr addrspace(4)] } { [1 x ptr addrspace(4)] [ptr addrspace(4) addrspacecast (ptr null to ptr addrspace(4))] }
|
|
@G2 = addrspace(1) constant { [1 x ptr addrspace(4)] } { [1 x ptr addrspace(4)] [ptr addrspace(4) addrspacecast (ptr addrspace(1) null to ptr addrspace(4))] }
|
|
|
|
define void @foo() {
|
|
entry:
|
|
ret void
|
|
}
|