Files
TheRock/compiler/spirv-llvm-translator/test/transcoding/OpenCL/convert_functions.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

85 lines
3.3 KiB
LLVM

; This test checks that functions with `convert_` prefix are translated as
; OpenCL builtins only in case they match the specification. Otherwise, we
; expect such functions to be translated to SPIR-V FunctionCall.
; RUN: llvm-spirv %s -o %t.spv
; TODO: re-enable validation
; RUNx: spirv-val %t.spv
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
; RUN: FileCheck < %t.spt %s -check-prefix=CHECK-SPIRV
; RUN: llvm-spirv %t.spv -r -o - | llvm-dis -o %t.rev.ll
; RUN: FileCheck < %t.rev.ll %s -check-prefix=CHECK-LLVM
; CHECK-SPIRV: Name [[#Func:]] "_Z18convert_float_func"
; CHECK-SPIRV: Name [[#Func1:]] "_Z20convert_uint_satfunc"
; CHECK-SPIRV: Name [[#Func2:]] "_Z21convert_float_rtzfunc"
; CHECK-SPIRV-DAG: TypeVoid [[#VoidTy:]]
; CHECK-SPIRV-DAG: TypeInt [[#CharTy:]] 8
; CHECK-SPIRV-DAG: TypeFloat [[#FloatTy:]] 32
; CHECK-SPIRV: Function [[#VoidTy]] [[#Func]]
; CHECK-SPIRV: SConvert [[#CharTy]] [[#ConvertId:]] [[#]]
; CHECK-SPIRV: ConvertSToF [[#FloatTy]] [[#ConvertId:]] [[#]]
; CHECK-SPIRV: FunctionCall [[#VoidTy]] [[#]] [[#Func]] [[#ConvertId]]
; CHECK-SPIRV: FunctionCall [[#VoidTy]] [[#]] [[#Func1]] [[#]]
; CHECK-SPIRV: FunctionCall [[#VoidTy]] [[#]] [[#Func2]] [[#ConvertId]]
; CHECK-SPIRV-NOT: FConvert
; CHECK-SPIRV-NOT: ConvertUToF
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
target triple = "spir"
; Function Attrs: convergent noinline norecurse nounwind optnone
define dso_local spir_func void @_Z18convert_float_func(float noundef %x) #0 {
entry:
%x.addr = alloca float, align 4
store float %x, ptr %x.addr, align 4
ret void
}
define dso_local spir_func void @_Z20convert_uint_satfunc(i32 noundef %x) #0 {
entry:
ret void
}
define dso_local spir_func void @_Z21convert_float_rtzfunc(float noundef %x) #0 {
entry:
ret void
}
; Function Attrs: convergent noinline norecurse nounwind optnone
define dso_local spir_func void @convert_int_bf16(i32 noundef %x) #0 {
entry:
%x.addr = alloca i32, align 4
store i32 %x, ptr %x.addr, align 4
%0 = load i32, ptr %x.addr, align 4
; We don't get the convert_char_rtei back, but that's fine because they are
; functionally equivalent anyway. The rounding information is lost when
; translating to SPIR-V.
; CHECK-LLVM: call spir_func i8 @_Z12convert_chari(i32 %[[#]])
call spir_func signext i8 @_Z16convert_char_rtei(i32 noundef %0) #1
; CHECK-LLVM: %[[Call:[a-z]+]] = sitofp i32 %[[#]] to float
; CHECK-LLVM: call spir_func void @_Z18convert_float_func(float %[[Call]])
; CHECK-LLVM: call spir_func void @_Z20convert_uint_satfunc(i32 %[[#]])
; CHECK-LLVM: call spir_func void @_Z21convert_float_rtzfunc(float %[[Call]])
%call = call spir_func float @_Z13convert_floati(i32 noundef %0) #1
call spir_func void @_Z18convert_float_func(float noundef %call) #0
call spir_func void @_Z20convert_uint_satfunc(i32 noundef %0) #0
call spir_func void @_Z21convert_float_rtzfunc(float noundef %call) #0
ret void
}
; Function Attrs: convergent nounwind willreturn memory(none)
declare spir_func signext i8 @_Z16convert_char_rtei(i32 noundef) #1
; Function Attrs: convergent nounwind willreturn memory(none)
declare spir_func float @_Z13convert_floati(i32 noundef) #1
attributes #0 = { convergent nounwind }
attributes #1 = { convergent nounwind willreturn memory(none) }
!opencl.ocl.version = !{!0}
!opencl.spir.version = !{!0}
!0 = !{i32 3, i32 0}