xref: /llvm-project/llvm/test/CodeGen/SPIRV/extensions/SPV_INTEL_function_pointers/fp_const.ll (revision 83c1d003118a2cb8136fe49e2ec43958c93d9d6b)
1; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_function_pointers %s -o - | FileCheck %s
2; TODO: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4; CHECK-DAG: OpCapability FunctionPointersINTEL
5; CHECK-DAG: OpCapability Int64
6; CHECK: OpExtension "SPV_INTEL_function_pointers"
7
8; CHECK-DAG: %[[TyVoid:.*]] = OpTypeVoid
9; CHECK-DAG: %[[TyInt64:.*]] = OpTypeInt 64 0
10; CHECK-DAG: %[[TyFun:.*]] = OpTypeFunction %[[TyInt64]] %[[TyInt64]]
11; CHECK-DAG: %[[TyPtrFunCodeSection:.*]] = OpTypePointer CodeSectionINTEL %[[TyFun]]
12; CHECK-DAG: %[[ConstFunFp:.*]] = OpConstantFunctionPointerINTEL %[[TyPtrFunCodeSection]] %[[DefFunFp:.*]]
13; CHECK-DAG: %[[TyPtrFun:.*]] = OpTypePointer Function %[[TyFun]]
14; CHECK-DAG: %[[TyPtrPtrFun:.*]] = OpTypePointer Function %[[TyPtrFun]]
15; CHECK: OpFunction
16; CHECK: %[[Var:.*]] = OpVariable %[[TyPtrPtrFun]] Function
17; CHECK: OpStore %[[Var]] %[[ConstFunFp]]
18; CHECK: %[[FP:.*]] = OpLoad %[[TyPtrFun]] %[[Var]]
19; CHECK: OpFunctionPointerCallINTEL %[[TyInt64]] %[[FP]] %[[#]]
20; CHECK: OpFunctionEnd
21
22; CHECK: %[[DefFunFp]] = OpFunction %[[TyInt64]] None %[[TyFun]]
23
24target triple = "spir64-unknown-unknown"
25
26define spir_kernel void @test() {
27entry:
28  %fp = alloca ptr
29  store ptr @foo, ptr %fp
30  %tocall = load ptr, ptr %fp
31  %res = call i64 %tocall(i64 42)
32  ret void
33}
34
35define i64 @foo(i64 %a) {
36entry:
37  ret i64 %a
38}
39