aboutsummaryrefslogtreecommitdiffstats
path: root/target-ppc.c
blob: 6c0c0737482c1ec8a9ade29d3cb7f61b8073f682 (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
#include "symbol.h"
#include "target.h"
#include "machine.h"
#include "expression.h"


static void predefine_ppc(const struct target *self)
{
	predefine("__powerpc__", 1, "1");
	predefine("__powerpc", 1, "1");
	predefine("__ppc__", 1, "1");
	predefine("__PPC__", 1, "1");
	predefine("__PPC", 1, "1");
	predefine("_ARCH_PPC", 1, "1");
	if (arch_big_endian)
		predefine("_BIG_ENDIAN", 1, "1");
	if (ldouble_ctype.bit_size == 128) {
		predefine("__LONGDOUBLE128", 1, "1");
		predefine("__LONG_DOUBLE_128__", 1, "1");
	}
}

static const char *asm_constraint_ppc(struct asm_operand *op, int c, const char *str)
{
	switch (c) {
	case 'Z':
		op->is_memory = true;
		break;
	}
	return str;
}


static void init_ppc32(const struct target *self)
{
	fast16_ctype = &int_ctype;
	ufast16_ctype = &uint_ctype;
	fast32_ctype = &int_ctype;
	ufast32_ctype = &uint_ctype;
}

static void predefine_ppc32(const struct target *self)
{
	predefine_ppc(self);
}

const struct target target_ppc32 = {
	.mach = MACH_PPC32,
	.bitness = ARCH_LP32,
	.big_endian = 1,
	.unsigned_char = 1,

	.wchar = &long_ctype,

	.target_64bit = &target_ppc64,

	.init = init_ppc32,
	.predefine = predefine_ppc32,
	.asm_constraint = asm_constraint_ppc,
};


static void predefine_ppc64(const struct target *self)
{
	predefine("__powerpc64__", 1, "1");
	predefine("__ppc64__", 1, "1");
	predefine("__PPC64__", 1, "1");
	predefine("_ARCH_PPC64", 1, "1");

	predefine_ppc(self);
}

const struct target target_ppc64 = {
	.mach = MACH_PPC64,
	.bitness = ARCH_LP64,
	.big_endian = 1,
	.unsigned_char = 1,
	.has_int128 = 1,

	.target_32bit = &target_ppc32,

	.predefine = predefine_ppc64,
	.asm_constraint = asm_constraint_ppc,
};