Vyacheslav Levytskyy 8655378878
[SPIR-V] Built-in variables: mapping from an OpenCL to SPIR-V BuiltIn and SPIR-V friendly builtins for Image Read/Write instructions (#127242)
This PR improves built-in variables and functions support:
* extends mapping from an OpenCL C built-in function to the SPIR-V
BuiltIn variables as in
https://registry.khronos.org/OpenCL/specs/3.0-unified/html/OpenCL_Env.html#_built_in_variables,
and
* adds SPIR-V friendly builtins for Image Read/Write instructions.

Test cases are extended accordingly.
2025-02-18 12:03:37 +01:00

20 lines
922 B
LLVM

; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
; RUN: llc -verify-machineinstrs -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 %}
; CHECK: OpDecorate %[[#Id:]] BuiltIn GlobalLinearId
; CHECK: %[[#Id:]] = OpVariable %[[#]]
@__spirv_BuiltInGlobalLinearId = external addrspace(1) global i32
define spir_kernel void @f(i32 addrspace(1)* nocapture %order) {
entry:
%0 = load i32, i32 addrspace(4)* addrspacecast (i32 addrspace(1)* @__spirv_BuiltInGlobalLinearId to i32 addrspace(4)*), align 4
;; Need to store the result somewhere, otherwise the access to GlobalLinearId
;; may be removed.
store i32 %0, i32 addrspace(1)* %order, align 4
ret void
}