File: fixed_point_conversions_const.c

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (120 lines) | stat: -rw-r--r-- 5,188 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -S -emit-llvm %s -o - -fpadding-on-unsigned-fixed-point | FileCheck %s --check-prefixes=CHECK,UNSIGNED

// Between different fixed point types
short _Accum sa_const = 2.5hk;
// CHECK-DAG: @sa_const  = {{.*}}global i16 320, align 2
_Accum a_const = 2.5hk;
// CHECK-DAG: @a_const   = {{.*}}global i32 81920, align 4
short _Accum sa_const2 = 2.5k;
// CHECK-DAG: @sa_const2 = {{.*}}global i16 320, align 2

short _Accum sa_from_f_const = 0.5r;
// CHECK-DAG: sa_from_f_const = {{.*}}global i16 64, align 2
_Fract f_from_sa_const = 0.5hk;
// CHECK-DAG: f_from_sa_const = {{.*}}global i16 16384, align 2

unsigned short _Accum usa_const = 2.5uk;
unsigned _Accum ua_const = 2.5uhk;
// SIGNED-DAG: @usa_const  = {{.*}}global i16 640, align 2
// SIGNED-DAG: @ua_const   = {{.*}}global i32 163840, align 4
// UNSIGNED-DAG:    @usa_const  = {{.*}}global i16 320, align 2
// UNSIGNED-DAG:    @ua_const   = {{.*}}global i32 81920, align 4

// FixedPoint to integer
int i_const = -128.0hk;
// CHECK-DAG: @i_const  = {{.*}}global i32 -128, align 4
int i_const2 = 128.0hk;
// CHECK-DAG: @i_const2 = {{.*}}global i32 128, align 4
int i_const3 = -128.0k;
// CHECK-DAG: @i_const3 = {{.*}}global i32 -128, align 4
int i_const4 = 128.0k;
// CHECK-DAG: @i_const4 = {{.*}}global i32 128, align 4
short s_const = -128.0k;
// CHECK-DAG: @s_const  = {{.*}}global i16 -128, align 2
short s_const2 = 128.0k;
// CHECK-DAG: @s_const2 = {{.*}}global i16 128, align 2

// Integer to fixed point
short _Accum sa_const5 = 2;
// CHECK-DAG: @sa_const5 = {{.*}}global i16 256, align 2
short _Accum sa_const6 = -2;
// CHECK-DAG: @sa_const6 = {{.*}}global i16 -256, align 2
short _Accum sa_const7 = -256;
// CHECK-DAG: @sa_const7 = {{.*}}global i16 -32768, align 2

// Fixed point to floating point
float fl_const = 1.0hk;
// CHECK-DAG: @fl_const = {{.*}}global float 1.000000e+00, align 4
float fl_const2 = -128.0k;
// CHECK-DAG: @fl_const2 = {{.*}}global float -1.280000e+02, align 4
float fl_const3 = 0.0872802734375k;
// CHECK-DAG: @fl_const3 = {{.*}}global float 0x3FB6580000000000, align 4
float fl_const4 = 192.5k;
// CHECK-DAG: @fl_const4 = {{.*}}global float 1.925000e+02, align 4
float fl_const5 = -192.5k;
// CHECK-DAG: @fl_const5 = {{.*}}global float -1.925000e+02, align 4

// Floating point to fixed point
_Accum a_fl_const = 1.0f;
// CHECK-DAG: @a_fl_const = {{.*}}global i32 32768, align 4
_Accum a_fl_const2 = -128.0f;
// CHECK-DAG: @a_fl_const2 = {{.*}}global i32 -4194304, align 4
_Accum a_fl_const3 = 0.0872802734375f;
// CHECK-DAG: @a_fl_const3 = {{.*}}global i32 2860, align 4
_Accum a_fl_const4 = 0.0872802734375;
// CHECK-DAG: @a_fl_const4 = {{.*}}global i32 2860, align 4
_Accum a_fl_const5 = -0.0872802734375f;
// CHECK-DAG: @a_fl_const5 = {{.*}}global i32 -2860, align 4
_Fract f_fl_const = 0.5f;
// CHECK-DAG: @f_fl_const = {{.*}}global i16 16384, align 2
_Fract f_fl_const2 = -0.75;
// CHECK-DAG: @f_fl_const2 = {{.*}}global i16 -24576, align 2
unsigned short _Accum usa_fl_const = 48.75f;
// SIGNED-DAG: @usa_fl_const = {{.*}}global i16 12480, align 2
// UNSIGNED-DAG: @usa_fl_const = {{.*}}global i16 6240, align 2

// Signedness
unsigned short _Accum usa_const2 = 2.5hk;
// SIGNED-DAG: @usa_const2  = {{.*}}global i16 640, align 2
// UNSIGNED-DAG:    @usa_const2  = {{.*}}global i16 320, align 2
short _Accum sa_const3 = 2.5hk;
// CHECK-DAG: @sa_const3 = {{.*}}global i16 320, align 2

int i_const5 = 128.0uhk;
unsigned int ui_const = 128.0hk;
// CHECK-DAG: @i_const5  = {{.*}}global i32 128, align 4
// CHECK-DAG: @ui_const  = {{.*}}global i32 128, align 4

short _Accum sa_const9 = 2u;
// CHECK-DAG: @sa_const9 = {{.*}}global i16 256, align 2
unsigned short _Accum usa_const3 = 2;
// SIGNED-DAG: @usa_const3 = {{.*}}global i16 512, align 2
// UNSIGNED-DAG:    @usa_const3 = {{.*}}global i16 256, align 2

// Overflow (this is undefined but allowed)
short _Accum sa_const4 = 256.0k;
unsigned int ui_const2 = -2.5hk;
short _Accum sa_const8 = 256;
unsigned short _Accum usa_const4 = -2;

// Saturation
_Sat short _Accum sat_sa_const = 2.5hk;
// CHECK-DAG: @sat_sa_const  = {{.*}}global i16 320, align 2
_Sat short _Accum sat_sa_const2 = 256.0k;
// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
_Sat unsigned short _Accum sat_usa_const = -1.0hk;
// CHECK-DAG: @sat_usa_const = {{.*}}global i16 0, align 2
_Sat unsigned short _Accum sat_usa_const2 = 256.0k;
// SIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 -1, align 2
// UNSIGNED-DAG:    @sat_usa_const2 = {{.*}}global i16 32767, align 2

_Sat short _Accum sat_sa_const3 = 256;
// CHECK-DAG: @sat_sa_const3 = {{.*}}global i16 32767, align 2
_Sat short _Accum sat_sa_const4 = -257;
// CHECK-DAG: @sat_sa_const4 = {{.*}}global i16 -32768, align 2
_Sat unsigned short _Accum sat_usa_const3 = -1;
// CHECK-DAG: @sat_usa_const3 = {{.*}}global i16 0, align 2
_Sat unsigned short _Accum sat_usa_const4 = 256;
// SIGNED-DAG: @sat_usa_const4 = {{.*}}global i16 -1, align 2
// UNSIGNED-DAG:    @sat_usa_const4 = {{.*}}global i16 32767, align 2