comparison: fix how addresses are handled
[smatch.git] / target-x86.c
blobb7ff8f2ab4edc0cc4b353c4cf0dd91f31048f299
1 #include "symbol.h"
2 #include "target.h"
3 #include "machine.h"
6 static void predefine_i386(const struct target *self)
8 predefine("__i386__", 1, "1");
9 predefine("__i386", 1, "1");
10 predefine_nostd("i386");
13 static void predefine_x86_64(const struct target *self)
15 predefine("__x86_64__", 1, "1");
16 predefine("__x86_64", 1, "1");
17 predefine("__amd64__", 1, "1");
18 predefine("__amd64", 1, "1");
22 static void init_x86_common(const struct target *target)
24 switch (arch_os) {
25 case OS_CYGWIN:
26 wchar_ctype = &ushort_ctype;
27 break;
28 case OS_FREEBSD:
29 wint_ctype = &int_ctype;
30 break;
31 case OS_OPENBSD:
32 size_t_ctype = &ulong_ctype;
33 ssize_t_ctype = &long_ctype;
34 wchar_ctype = &int_ctype;
35 wint_ctype = &int_ctype;
36 fast16_ctype = &short_ctype;
37 ufast16_ctype = &ushort_ctype;
38 break;
43 static void init_i386(const struct target *target)
45 fast16_ctype = &int_ctype;
46 ufast16_ctype = &uint_ctype;
47 fast32_ctype = &int_ctype;
48 ufast32_ctype = &uint_ctype;
50 init_x86_common(target);
53 const struct target target_i386 = {
54 .mach = MACH_I386,
55 .bitness = ARCH_LP32,
56 .big_endian = 0,
57 .unsigned_char = 0,
59 .wchar = &long_ctype,
60 .bits_in_longdouble = 96,
61 .max_fp_alignment = 4,
63 .target_64bit = &target_x86_64,
65 .init = init_i386,
66 .predefine = predefine_i386,
70 static void init_x86_x32(const struct target *target)
72 init_x86_common(target);
74 max_int_alignment = 8;
76 fast16_ctype = &int_ctype;
77 ufast16_ctype = &uint_ctype;
78 fast32_ctype = &int_ctype;
79 ufast32_ctype = &uint_ctype;
80 wchar_ctype = &long_ctype;
83 static const struct target target_x86_x32 = {
84 .mach = MACH_X86_64,
85 .bitness = ARCH_X32,
86 .big_endian = 0,
87 .unsigned_char = 0,
88 .has_int128 = 1,
90 .bits_in_longdouble = 128,
91 .max_fp_alignment = 16,
93 .target_32bit = &target_i386,
94 .target_64bit = &target_x86_64,
96 .init = init_x86_x32,
97 .predefine = predefine_x86_64,
101 static void init_x86_64(const struct target *target)
103 init_x86_common(target);
105 switch (arch_os) {
106 case OS_CYGWIN:
107 break;
108 case OS_DARWIN:
109 int64_ctype = &llong_ctype;
110 uint64_ctype = &ullong_ctype;
111 wint_ctype = &int_ctype;
112 fast16_ctype = &short_ctype;
113 ufast16_ctype = &ushort_ctype;
114 fast32_ctype = &int_ctype;
115 ufast32_ctype = &uint_ctype;
116 fast64_ctype = &llong_ctype;
117 ufast64_ctype = &ullong_ctype;
118 break;
119 case OS_FREEBSD:
120 fast16_ctype = &short_ctype;
121 ufast16_ctype = &ushort_ctype;
122 fast32_ctype = &int_ctype;
123 ufast32_ctype = &uint_ctype;
124 break;
125 case OS_NETBSD:
126 fast8_ctype = &int_ctype;
127 ufast8_ctype = &uint_ctype;
128 fast16_ctype = &int_ctype;
129 ufast16_ctype = &uint_ctype;
130 fast32_ctype = &int_ctype;
131 ufast32_ctype = &uint_ctype;
132 wint_ctype = &int_ctype;
133 break;
134 case OS_OPENBSD:
135 fast32_ctype = &int_ctype;
136 ufast32_ctype = &uint_ctype;
137 int64_ctype = &llong_ctype;
138 uint64_ctype = &ullong_ctype;
139 intmax_ctype = &llong_ctype;
140 uintmax_ctype = &ullong_ctype;
141 least64_ctype = &long_ctype;
142 uleast64_ctype = &ulong_ctype;
143 break;
147 const struct target target_x86_64 = {
148 .mach = MACH_X86_64,
149 .bitness = ARCH_LP64,
150 .big_endian = 0,
151 .unsigned_char = 0,
152 .has_int128 = 1,
154 .bits_in_longdouble = 128,
155 .max_fp_alignment = 16,
157 .target_32bit = &target_i386,
158 .target_x32bit = &target_x86_x32,
160 .init = init_x86_64,
161 .predefine = predefine_x86_64,