File: fixed_point_add_const.c

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (54 lines) | stat: -rw-r--r-- 2,731 bytes parent folder | download | duplicates (7)
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
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
// RUN: %clang_cc1 -ffixed-point -triple x86_64-unknown-linux-gnu -fpadding-on-unsigned-fixed-point -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED

// Addition between different fixed point types
short _Accum sa_const = 1.0hk + 2.0hk;
// CHECK-DAG: @sa_const  = {{.*}}global i16 384, align 2
_Accum a_const = 1.0hk + 2.0k;
// CHECK-DAG: @a_const   = {{.*}}global i32 98304, align 4
long _Accum la_const = 1.0hk + 2.0lk;
// CHECK-DAG: @la_const  = {{.*}}global i64 6442450944, align 8
short _Accum sa_const2 = 0.5hr + 2.0hk;
// CHECK-DAG: @sa_const2  = {{.*}}global i16 320, align 2
short _Accum sa_const3 = 0.5r + 2.0hk;
// CHECK-DAG: @sa_const3  = {{.*}}global i16 320, align 2
short _Accum sa_const4 = 0.5lr + 2.0hk;
// CHECK-DAG: @sa_const4  = {{.*}}global i16 320, align 2

// Unsigned addition
unsigned short _Accum usa_const = 1.0uhk + 2.0uhk;
// SIGNED-DAG:   @usa_const = {{.*}}global i16 768, align 2
// UNSIGNED-DAG: @usa_const = {{.*}}global i16 384, align 2

// Unsigned + signed
short _Accum sa_const5 = 1.0uhk + 2.0hk;
// CHECK-DAG: @sa_const5 = {{.*}}global i16 384, align 2

// Addition with negative number
short _Accum sa_const6 = 0.5hr + (-2.0hk);
// CHECK-DAG: @sa_const6 = {{.*}}global i16 -192, align 2

// Int addition
unsigned short _Accum usa_const2 = 2 + 0.5uhk;
// SIGNED-DAG:   @usa_const2 = {{.*}}global i16 640, align 2
// UNSIGNED-DAG: @usa_const2 = {{.*}}global i16 320, align 2
short _Accum sa_const7 = 2 + (-0.5hk);
// CHECK-DAG: @sa_const7 = {{.*}}global i16 192, align 2
short _Accum sa_const8 = 257 + (-2.0hk);
// CHECK-DAG: @sa_const8 = {{.*}}global i16 32640, align 2
long _Fract lf_const = -0.5lr + 1;
// CHECK-DAG: @lf_const  = {{.*}}global i32 1073741824, align 4

// Saturated addition
_Sat short _Accum sat_sa_const = (_Sat short _Accum)128.0hk + 128.0hk;
// CHECK-DAG: @sat_sa_const = {{.*}}global i16 32767, align 2
_Sat unsigned short _Accum sat_usa_const = (_Sat unsigned short _Accum)128.0uhk + 128.0uhk;
// SIGNED-DAG:   @sat_usa_const = {{.*}}global i16 -1, align 2
// UNSIGNED-DAG: @sat_usa_const = {{.*}}global i16 32767, align 2
_Sat short _Accum sat_sa_const2 = (_Sat short _Accum)128.0hk + 128;
// CHECK-DAG: @sat_sa_const2 = {{.*}}global i16 32767, align 2
_Sat unsigned short _Accum sat_usa_const2 = (_Sat unsigned short _Accum)128.0uhk + 128;
// SIGNED-DAG:   @sat_usa_const2 = {{.*}}global i16 -1, align 2
// UNSIGNED-DAG: @sat_usa_const2 = {{.*}}global i16 32767, align 2
_Sat unsigned short _Accum sat_usa_const3 = (_Sat unsigned short _Accum)0.5uhk + (-2);
// CHECK-DAG:   @sat_usa_const3 = {{.*}}global i16 0, align 2