1 // RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -ffixed-point %s -emit-llvm -o - | FileCheck %s -check-prefixes=CHECK
2 //
3 // Check that we generate correct TBAA metadata for fixed-point types.
4
sfract(unsigned short _Fract * p,short _Fract * q,unsigned _Sat short _Fract * r,_Sat short _Fract * s)5 void sfract(unsigned short _Fract *p, short _Fract *q,
6 unsigned _Sat short _Fract *r, _Sat short _Fract *s) {
7 // CHECK-LABEL: define void @sfract
8 // CHECK: store i8 -128, i8* %p, align 1, !tbaa [[TAG_sf:!.*]]
9 // CHECK: store i8 -64, i8* %q, align 1, !tbaa [[TAG_sf]]
10 // CHECK: store i8 -128, i8* %r, align 1, !tbaa [[TAG_sat_sf:!.*]]
11 // CHECK: store i8 -64, i8* %s, align 1, !tbaa [[TAG_sat_sf]]
12 *p = 0.5hur;
13 *q = -0.5hr;
14 *r = 0.5hur;
15 *s = -0.5hr;
16 }
17
fract(unsigned _Fract * p,_Fract * q,unsigned _Sat _Fract * r,_Sat _Fract * s)18 void fract(unsigned _Fract *p, _Fract *q,
19 unsigned _Sat _Fract *r, _Sat _Fract *s) {
20 // CHECK-LABEL: define void @fract
21 // CHECK: store i16 -32768, i16* %p, align 2, !tbaa [[TAG_f:!.*]]
22 // CHECK: store i16 -16384, i16* %q, align 2, !tbaa [[TAG_f]]
23 // CHECK: store i16 -32768, i16* %r, align 2, !tbaa [[TAG_sat_f:!.*]]
24 // CHECK: store i16 -16384, i16* %s, align 2, !tbaa [[TAG_sat_f]]
25 *p = 0.5ur;
26 *q = -0.5r;
27 *r = 0.5ur;
28 *s = -0.5r;
29 }
30
lfract(unsigned long _Fract * p,long _Fract * q,unsigned _Sat long _Fract * r,_Sat long _Fract * s)31 void lfract(unsigned long _Fract *p, long _Fract *q,
32 unsigned _Sat long _Fract *r, _Sat long _Fract *s) {
33 // CHECK-LABEL: define void @lfract
34 // CHECK: store i32 -2147483648, i32* %p, align 4, !tbaa [[TAG_lf:!.*]]
35 // CHECK: store i32 -1073741824, i32* %q, align 4, !tbaa [[TAG_lf]]
36 // CHECK: store i32 -2147483648, i32* %r, align 4, !tbaa [[TAG_sat_lf:!.*]]
37 // CHECK: store i32 -1073741824, i32* %s, align 4, !tbaa [[TAG_sat_lf]]
38 *p = 0.5ulr;
39 *q = -0.5lr;
40 *r = 0.5ulr;
41 *s = -0.5lr;
42 }
43
saccum(unsigned short _Accum * p,short _Accum * q,unsigned _Sat short _Accum * r,_Sat short _Accum * s)44 void saccum(unsigned short _Accum *p, short _Accum *q,
45 unsigned _Sat short _Accum *r, _Sat short _Accum *s) {
46 // CHECK-LABEL: define void @saccum
47 // CHECK: store i16 128, i16* %p, align 2, !tbaa [[TAG_sk:!.*]]
48 // CHECK: store i16 -64, i16* %q, align 2, !tbaa [[TAG_sk]]
49 // CHECK: store i16 128, i16* %r, align 2, !tbaa [[TAG_sat_sk:!.*]]
50 // CHECK: store i16 -64, i16* %s, align 2, !tbaa [[TAG_sat_sk]]
51 *p = 0.5huk;
52 *q = -0.5hk;
53 *r = 0.5huk;
54 *s = -0.5hk;
55 }
56
accum(unsigned _Accum * p,_Accum * q,unsigned _Sat _Accum * r,_Sat _Accum * s)57 void accum(unsigned _Accum *p, _Accum *q,
58 unsigned _Sat _Accum *r, _Sat _Accum *s) {
59 // CHECK-LABEL: define void @accum
60 // CHECK: store i32 32768, i32* %p, align 4, !tbaa [[TAG_k:!.*]]
61 // CHECK: store i32 -16384, i32* %q, align 4, !tbaa [[TAG_k]]
62 // CHECK: store i32 32768, i32* %r, align 4, !tbaa [[TAG_sat_k:!.*]]
63 // CHECK: store i32 -16384, i32* %s, align 4, !tbaa [[TAG_sat_k]]
64 *p = 0.5uk;
65 *q = -0.5k;
66 *r = 0.5uk;
67 *s = -0.5k;
68 }
69
laccum(unsigned long _Accum * p,long _Accum * q,unsigned _Sat long _Accum * r,_Sat long _Accum * s)70 void laccum(unsigned long _Accum *p, long _Accum *q,
71 unsigned _Sat long _Accum *r, _Sat long _Accum *s) {
72 // CHECK-LABEL: define void @laccum
73 // CHECK: store i64 2147483648, i64* %p, align 8, !tbaa [[TAG_lk:!.*]]
74 // CHECK: store i64 -1073741824, i64* %q, align 8, !tbaa [[TAG_lk]]
75 // CHECK: store i64 2147483648, i64* %r, align 8, !tbaa [[TAG_sat_lk:!.*]]
76 // CHECK: store i64 -1073741824, i64* %s, align 8, !tbaa [[TAG_sat_lk]]
77 *p = 0.5ulk;
78 *q = -0.5lk;
79 *r = 0.5ulk;
80 *s = -0.5lk;
81 }
82
83 // CHECK-DAG: [[TAG_sf]] = !{[[TYPE_sf:!.*]], [[TYPE_sf]], i64 0}
84 // CHECK-DAG: [[TYPE_sf]] = !{!"short _Fract"
85 // CHECK-DAG: [[TAG_f]] = !{[[TYPE_f:!.*]], [[TYPE_f]], i64 0}
86 // CHECK-DAG: [[TYPE_f]] = !{!"_Fract"
87 // CHECK-DAG: [[TAG_lf]] = !{[[TYPE_lf:!.*]], [[TYPE_lf]], i64 0}
88 // CHECK-DAG: [[TYPE_lf]] = !{!"long _Fract"
89
90 // CHECK-DAG: [[TAG_sat_sf]] = !{[[TYPE_sat_sf:!.*]], [[TYPE_sat_sf]], i64 0}
91 // CHECK-DAG: [[TYPE_sat_sf]] = !{!"_Sat short _Fract"
92 // CHECK-DAG: [[TAG_sat_f]] = !{[[TYPE_sat_f:!.*]], [[TYPE_sat_f]], i64 0}
93 // CHECK-DAG: [[TYPE_sat_f]] = !{!"_Sat _Fract"
94 // CHECK-DAG: [[TAG_sat_lf]] = !{[[TYPE_sat_lf:!.*]], [[TYPE_sat_lf]], i64 0}
95 // CHECK-DAG: [[TYPE_sat_lf]] = !{!"_Sat long _Fract"
96
97 // CHECK-DAG: [[TAG_sk]] = !{[[TYPE_sk:!.*]], [[TYPE_sk]], i64 0}
98 // CHECK-DAG: [[TYPE_sk]] = !{!"short _Accum"
99 // CHECK-DAG: [[TAG_k]] = !{[[TYPE_k:!.*]], [[TYPE_k]], i64 0}
100 // CHECK-DAG: [[TYPE_k]] = !{!"_Accum"
101 // CHECK-DAG: [[TAG_lk]] = !{[[TYPE_lk:!.*]], [[TYPE_lk]], i64 0}
102 // CHECK-DAG: [[TYPE_lk]] = !{!"long _Accum"
103
104 // CHECK-DAG: [[TAG_sat_sk]] = !{[[TYPE_sat_sk:!.*]], [[TYPE_sat_sk]], i64 0}
105 // CHECK-DAG: [[TYPE_sat_sk]] = !{!"_Sat short _Accum"
106 // CHECK-DAG: [[TAG_sat_k]] = !{[[TYPE_sat_k:!.*]], [[TYPE_sat_k]], i64 0}
107 // CHECK-DAG: [[TYPE_sat_k]] = !{!"_Sat _Accum"
108 // CHECK-DAG: [[TAG_sat_lk]] = !{[[TYPE_sat_lk:!.*]], [[TYPE_sat_lk]], i64 0}
109 // CHECK-DAG: [[TYPE_sat_lk]] = !{!"_Sat long _Accum"
110