param_key: fix container of when no struct member is referenced
[smatch.git] / target-x86.c
blob9d82869a27b8dcee48257ad75ebcdc75320ef71c
1 #include "symbol.h"
2 #include "target.h"
3 #include "machine.h"
4 #include "builtin.h"
7 static void predefine_i386(const struct target *self)
9 predefine("__i386__", 1, "1");
10 predefine("__i386", 1, "1");
11 predefine_nostd("i386");
14 static void predefine_x86_64(const struct target *self)
16 predefine("__x86_64__", 1, "1");
17 predefine("__x86_64", 1, "1");
18 predefine("__amd64__", 1, "1");
19 predefine("__amd64", 1, "1");
23 static void init_x86_common(const struct target *target)
25 switch (arch_os) {
26 case OS_CYGWIN:
27 wchar_ctype = &ushort_ctype;
28 break;
29 case OS_FREEBSD:
30 wint_ctype = &int_ctype;
31 break;
32 case OS_OPENBSD:
33 size_t_ctype = &ulong_ctype;
34 ssize_t_ctype = &long_ctype;
35 wchar_ctype = &int_ctype;
36 wint_ctype = &int_ctype;
37 fast16_ctype = &short_ctype;
38 ufast16_ctype = &ushort_ctype;
39 break;
43 static const struct builtin_fn builtins_x86_common[] = {
44 { "__builtin_ia32_pause", &void_ctype, 0, },
45 { }
49 static void init_i386(const struct target *target)
51 fast16_ctype = &int_ctype;
52 ufast16_ctype = &uint_ctype;
53 fast32_ctype = &int_ctype;
54 ufast32_ctype = &uint_ctype;
56 init_x86_common(target);
59 const struct target target_i386 = {
60 .mach = MACH_I386,
61 .bitness = ARCH_LP32,
62 .big_endian = 0,
63 .unsigned_char = 0,
65 .wchar = &long_ctype,
66 .bits_in_longdouble = 96,
67 .max_fp_alignment = 4,
69 .target_64bit = &target_x86_64,
71 .init = init_i386,
72 .predefine = predefine_i386,
73 .builtins = builtins_x86_common,
77 static void init_x86_x32(const struct target *target)
79 init_x86_common(target);
81 max_int_alignment = 8;
83 fast16_ctype = &int_ctype;
84 ufast16_ctype = &uint_ctype;
85 fast32_ctype = &int_ctype;
86 ufast32_ctype = &uint_ctype;
87 wchar_ctype = &long_ctype;
90 static const struct target target_x86_x32 = {
91 .mach = MACH_X86_64,
92 .bitness = ARCH_X32,
93 .big_endian = 0,
94 .unsigned_char = 0,
95 .has_int128 = 1,
97 .bits_in_longdouble = 128,
98 .max_fp_alignment = 16,
100 .target_32bit = &target_i386,
101 .target_64bit = &target_x86_64,
103 .init = init_x86_x32,
104 .predefine = predefine_x86_64,
108 static void init_x86_64(const struct target *target)
110 init_x86_common(target);
112 switch (arch_os) {
113 case OS_CYGWIN:
114 break;
115 case OS_DARWIN:
116 int64_ctype = &llong_ctype;
117 uint64_ctype = &ullong_ctype;
118 wint_ctype = &int_ctype;
119 fast16_ctype = &short_ctype;
120 ufast16_ctype = &ushort_ctype;
121 fast32_ctype = &int_ctype;
122 ufast32_ctype = &uint_ctype;
123 fast64_ctype = &llong_ctype;
124 ufast64_ctype = &ullong_ctype;
125 break;
126 case OS_FREEBSD:
127 fast16_ctype = &short_ctype;
128 ufast16_ctype = &ushort_ctype;
129 fast32_ctype = &int_ctype;
130 ufast32_ctype = &uint_ctype;
131 break;
132 case OS_NETBSD:
133 fast8_ctype = &int_ctype;
134 ufast8_ctype = &uint_ctype;
135 fast16_ctype = &int_ctype;
136 ufast16_ctype = &uint_ctype;
137 fast32_ctype = &int_ctype;
138 ufast32_ctype = &uint_ctype;
139 wint_ctype = &int_ctype;
140 break;
141 case OS_OPENBSD:
142 fast32_ctype = &int_ctype;
143 ufast32_ctype = &uint_ctype;
144 int64_ctype = &llong_ctype;
145 uint64_ctype = &ullong_ctype;
146 intmax_ctype = &llong_ctype;
147 uintmax_ctype = &ullong_ctype;
148 least64_ctype = &long_ctype;
149 uleast64_ctype = &ulong_ctype;
150 break;
154 const struct target target_x86_64 = {
155 .mach = MACH_X86_64,
156 .bitness = ARCH_LP64,
157 .big_endian = 0,
158 .unsigned_char = 0,
159 .has_int128 = 1,
161 .bits_in_longdouble = 128,
162 .max_fp_alignment = 16,
164 .target_32bit = &target_i386,
165 .target_x32bit = &target_x86_x32,
167 .init = init_x86_64,
168 .predefine = predefine_x86_64,
169 .builtins = builtins_x86_common,