xref: /llvm-project/llvm/test/CodeGen/SPIRV/constant/local-float-point-constants.ll (revision 67d3ef74b31e1517d4f679e754cc2b3041c95901)
1*67d3ef74SVyacheslav Levytskyy; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
2df871307SIlia Diachkov
3df871307SIlia Diachkovdefine half @getConstantFP16() {
4df871307SIlia Diachkov  ret half 0x3ff1340000000000 ; 0x3c4d represented as double.
5df871307SIlia Diachkov}
6df871307SIlia Diachkov
7df871307SIlia Diachkovdefine float @getConstantFP32() {
8df871307SIlia Diachkov  ret float 0x3fd27c8be0000000 ; 0x3e93e45f represented as double
9df871307SIlia Diachkov}
10df871307SIlia Diachkov
11df871307SIlia Diachkovdefine double @getConstantFP64() {
12df871307SIlia Diachkov  ret double 0x4f2de42b8c68f3f1
13df871307SIlia Diachkov}
14df871307SIlia Diachkov
15bb6a4373SAndrey Tretyakov;; Capabilities
16df871307SIlia Diachkov; CHECK-DAG: OpCapability Float16
17df871307SIlia Diachkov; CHECK-DAG: OpCapability Float64
18df871307SIlia Diachkov
19df871307SIlia Diachkov; CHECK-NOT: DAG-FENCE
20df871307SIlia Diachkov
21bb6a4373SAndrey Tretyakov;; Names:
22df871307SIlia Diachkov; CHECK-DAG: OpName %[[#GET_FP16:]] "getConstantFP16"
23df871307SIlia Diachkov; CHECK-DAG: OpName %[[#GET_FP32:]] "getConstantFP32"
24df871307SIlia Diachkov; CHECK-DAG: OpName %[[#GET_FP64:]] "getConstantFP64"
25df871307SIlia Diachkov
26df871307SIlia Diachkov; CHECK-NOT: DAG-FENCE
27df871307SIlia Diachkov
28bb6a4373SAndrey Tretyakov;; Types and Constants:
29bb6a4373SAndrey Tretyakov;; NOTE: These tests don't actually check the values of the constants because
30bb6a4373SAndrey Tretyakov;;       their representation isn't defined for textual output.
31bb6a4373SAndrey Tretyakov;; TODO: Test constant representation using binary output.
32df871307SIlia Diachkov; CHECK-DAG: %[[#FP16:]] = OpTypeFloat 16
33df871307SIlia Diachkov; CHECK-DAG: %[[#FP32:]] = OpTypeFloat 32
34df871307SIlia Diachkov; CHECK-DAG: %[[#FP64:]] = OpTypeFloat 64
35df871307SIlia Diachkov; CHECK-DAG: %[[#CST_FP16:]] = OpConstant %[[#FP16]]
36df871307SIlia Diachkov; CHECK-DAG: %[[#CST_FP32:]] = OpConstant %[[#FP32]]
37df871307SIlia Diachkov; CHECK-DAG: %[[#CST_FP64:]] = OpConstant %[[#FP64]]
38df871307SIlia Diachkov
39df871307SIlia Diachkov; CHECK: %[[#GET_FP16]] = OpFunction %[[#FP16]]
40df871307SIlia Diachkov; CHECK: OpReturnValue %[[#CST_FP16]]
41df871307SIlia Diachkov; CHECK: OpFunctionEnd
42df871307SIlia Diachkov
43df871307SIlia Diachkov; CHECK: %[[#GET_FP32]] = OpFunction %[[#FP32]]
44df871307SIlia Diachkov; CHECK: OpReturnValue %[[#CST_FP32]]
45df871307SIlia Diachkov; CHECK: OpFunctionEnd
46df871307SIlia Diachkov
47df871307SIlia Diachkov; CHECK: %[[#GET_FP64]] = OpFunction %[[#FP64]]
48df871307SIlia Diachkov; CHECK: OpReturnValue %[[#CST_FP64]]
49df871307SIlia Diachkov; CHECK: OpFunctionEnd
50