aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/target-x86.c
blob: 956af92efe4e99b0fa656d1dd615cb22520f4fe1 (plain)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include "symbol.h"
#include "target.h"
#include "machine.h"


static void predefine_i386(const struct target *self)
{
	predefine("__i386__", 1, "1");
	predefine("__i386", 1, "1");
	predefine_nostd("i386");
}

static void predefine_x86_64(const struct target *self)
{
	predefine("__x86_64__", 1, "1");
	predefine("__x86_64", 1, "1");
	predefine("__amd64__", 1, "1");
	predefine("__amd64", 1, "1");
}


static void init_x86_common(const struct target *target)
{
	switch (arch_os) {
	case OS_CYGWIN:
		wchar_ctype = &ushort_ctype;
		break;
	case OS_FREEBSD:
		wint_ctype = &int_ctype;
		break;
	case OS_OPENBSD:
		size_t_ctype = &ulong_ctype;
		ssize_t_ctype = &long_ctype;
		wchar_ctype = &int_ctype;
		wint_ctype = &int_ctype;
		break;
	}
}


static void init_i386(const struct target *target)
{
	init_x86_common(target);
}

const struct target target_i386 = {
	.mach = MACH_I386,
	.bitness = ARCH_LP32,
	.big_endian = 0,
	.unsigned_char = 0,

	.wchar = &long_ctype,
	.bits_in_longdouble = 96,
	.max_fp_alignment = 4,

	.target_64bit = &target_x86_64,

	.init = init_i386,
	.predefine = predefine_i386,
};


static void init_x86_64(const struct target *target)
{
	init_x86_common(target);

	switch (arch_os) {
	case OS_CYGWIN:
		break;
	case OS_DARWIN:
		int64_ctype = &llong_ctype;
		uint64_ctype = &ullong_ctype;
		wint_ctype = &int_ctype;
		break;
	case OS_FREEBSD:
		break;
	case OS_NETBSD:
		wint_ctype = &int_ctype;
		break;
	case OS_OPENBSD:
		int64_ctype = &llong_ctype;
		uint64_ctype = &ullong_ctype;
		intmax_ctype = &llong_ctype;
		uintmax_ctype = &ullong_ctype;
		least64_ctype = &long_ctype;
		uleast64_ctype = &ulong_ctype;
		break;
	}
}

const struct target target_x86_64 = {
	.mach = MACH_X86_64,
	.bitness = ARCH_LP64,
	.big_endian = 0,
	.unsigned_char = 0,
	.has_int128 = 1,

	.bits_in_longdouble = 128,
	.max_fp_alignment = 16,

	.target_32bit = &target_i386,

	.init = init_x86_64,
	.predefine = predefine_x86_64,
};