• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ===-- int_lib.h - configuration header for compiler-rt  -----------------===
2  *
3  *                     The LLVM Compiler Infrastructure
4  *
5  * This file is dual licensed under the MIT and the University of Illinois Open
6  * Source Licenses. See LICENSE.TXT for details.
7  *
8  * ===----------------------------------------------------------------------===
9  *
10  * This file is not part of the interface of this library.
11  *
12  * This file defines various standard types, most importantly a number of unions
13  * used to access parts of larger types.
14  *
15  * ===----------------------------------------------------------------------===
16  */
17 
18 #ifndef INT_TYPES_H
19 #define INT_TYPES_H
20 
21 #include "int_endianness.h"
22 
23 typedef      int si_int;
24 typedef unsigned su_int;
25 
26 typedef          long long di_int;
27 typedef unsigned long long du_int;
28 
29 typedef union
30 {
31     di_int all;
32     struct
33     {
34 #if _YUGA_LITTLE_ENDIAN
35         su_int low;
36         si_int high;
37 #else
38         si_int high;
39         su_int low;
40 #endif /* _YUGA_LITTLE_ENDIAN */
41     }s;
42 } dwords;
43 
44 typedef union
45 {
46     du_int all;
47     struct
48     {
49 #if _YUGA_LITTLE_ENDIAN
50         su_int low;
51         su_int high;
52 #else
53         su_int high;
54         su_int low;
55 #endif /* _YUGA_LITTLE_ENDIAN */
56     }s;
57 } udwords;
58 
59 #if __x86_64
60 
61 typedef int      ti_int __attribute__ ((mode (TI)));
62 typedef unsigned tu_int __attribute__ ((mode (TI)));
63 
64 typedef union
65 {
66     ti_int all;
67     struct
68     {
69 #if _YUGA_LITTLE_ENDIAN
70         du_int low;
71         di_int high;
72 #else
73         di_int high;
74         du_int low;
75 #endif /* _YUGA_LITTLE_ENDIAN */
76     }s;
77 } twords;
78 
79 typedef union
80 {
81     tu_int all;
82     struct
83     {
84 #if _YUGA_LITTLE_ENDIAN
85         du_int low;
86         du_int high;
87 #else
88         du_int high;
89         du_int low;
90 #endif /* _YUGA_LITTLE_ENDIAN */
91     }s;
92 } utwords;
93 
make_ti(di_int h,di_int l)94 static inline ti_int make_ti(di_int h, di_int l) {
95     twords r;
96     r.s.high = h;
97     r.s.low = l;
98     return r.all;
99 }
100 
make_tu(du_int h,du_int l)101 static inline tu_int make_tu(du_int h, du_int l) {
102     utwords r;
103     r.s.high = h;
104     r.s.low = l;
105     return r.all;
106 }
107 
108 #endif /* __x86_64 */
109 
110 typedef union
111 {
112     su_int u;
113     float f;
114 } float_bits;
115 
116 typedef union
117 {
118     udwords u;
119     double  f;
120 } double_bits;
121 
122 typedef struct
123 {
124 #if _YUGA_LITTLE_ENDIAN
125     udwords low;
126     udwords high;
127 #else
128     udwords high;
129     udwords low;
130 #endif /* _YUGA_LITTLE_ENDIAN */
131 } uqwords;
132 
133 typedef union
134 {
135     uqwords     u;
136     long double f;
137 } long_double_bits;
138 
139 #endif /* INT_TYPES_H */
140 
141