At the moment AMDGCN flavoured SPIRV uses the SPIRV ABI with some tweaks revolving around passing aggregates as direct. This is problematic in multiple ways: - it leads to divergence from code compiled for a concrete target, which makes it difficult to debug; - it incurs a run time cost, when dealing with larger aggregates; - it incurs a compile time cost, when dealing with larger aggregates. This patch switches over AMDGCN flavoured SPIRV to implement the AMDGPU ABI (except for dealing with variadic functions, which will be added in the future). One additional complication (and the primary motivation behind the current less than ideal state of affairs) stems from `byref`, which AMDGPU uses, not being expressible in SPIR-V. We deal with this by CodeGen-ing for `byref`, lowering it to the `FuncParamAttr ByVal` in SPIR-V, and restoring it when doing reverse translation from AMDGCN flavoured SPIR-V.
24 lines
983 B
LLVM
24 lines
983 B
LLVM
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck --check-prefixes=CHECK,SPIRV %s
|
|
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-amd-amdhsa %s -o - | FileCheck --check-prefixes=CHECK,AMDGCNSPIRV %s
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
|
|
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-amd-amdhsa %s -o - -filetype=obj | spirv-val %}
|
|
|
|
; CHECK: OpName %[[#XKER:]] "x"
|
|
; CHECK-DAG: OpName %[[#XFN:]] "x"
|
|
; SPIRV-NOT: OpDecorate %[[#XKER]] FuncParamAttr ByVal
|
|
; AMDGCNSPIRV: OpDecorate %[[#XKER]] FuncParamAttr ByVal
|
|
; SPIRV-NOT: OpDecorate %[[#XFN]] FuncParamAttr ByVal
|
|
; AMDGCNSPIRV: OpDecorate %[[#XFN]] FuncParamAttr ByVal
|
|
|
|
%struct.S = type { i32 }
|
|
%struct.SS = type { [7 x %struct.S] }
|
|
|
|
define spir_kernel void @ker(ptr addrspace(2) noundef byref(%struct.SS) %x) {
|
|
entry:
|
|
ret void
|
|
}
|
|
|
|
define spir_func void @fn(ptr noundef byref(%struct.SS) %x) {
|
|
entry:
|
|
ret void
|
|
} |