aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--target-x86.c32
-rw-r--r--target.c11
-rw-r--r--target.h1
3 files changed, 41 insertions, 3 deletions
diff --git a/target-x86.c b/target-x86.c
index e69594ed..b7ff8f2a 100644
--- a/target-x86.c
+++ b/target-x86.c
@@ -67,6 +67,37 @@ const struct target target_i386 = {
};
+static void init_x86_x32(const struct target *target)
+{
+ init_x86_common(target);
+
+ max_int_alignment = 8;
+
+ fast16_ctype = &int_ctype;
+ ufast16_ctype = &uint_ctype;
+ fast32_ctype = &int_ctype;
+ ufast32_ctype = &uint_ctype;
+ wchar_ctype = &long_ctype;
+}
+
+static const struct target target_x86_x32 = {
+ .mach = MACH_X86_64,
+ .bitness = ARCH_X32,
+ .big_endian = 0,
+ .unsigned_char = 0,
+ .has_int128 = 1,
+
+ .bits_in_longdouble = 128,
+ .max_fp_alignment = 16,
+
+ .target_32bit = &target_i386,
+ .target_64bit = &target_x86_64,
+
+ .init = init_x86_x32,
+ .predefine = predefine_x86_64,
+};
+
+
static void init_x86_64(const struct target *target)
{
init_x86_common(target);
@@ -124,6 +155,7 @@ const struct target target_x86_64 = {
.max_fp_alignment = 16,
.target_32bit = &target_i386,
+ .target_x32bit = &target_x86_x32,
.init = init_x86_64,
.predefine = predefine_x86_64,
diff --git a/target.c b/target.c
index 308386b8..8ae22d74 100644
--- a/target.c
+++ b/target.c
@@ -213,10 +213,17 @@ void target_init(void)
const struct target *target = arch_target;
switch (arch_m64) {
+ case ARCH_X32:
+ if (target->target_x32bit)
+ target = target->target_x32bit;
+ goto case_32bit;
+
case ARCH_LP32:
max_int_alignment = 4;
+ if (target->target_32bit)
+ target = target->target_32bit;
/* fallthrough */
- case ARCH_X32:
+ case_32bit:
bits_in_long = 32;
bits_in_pointer = 32;
pointer_alignment = 4;
@@ -228,8 +235,6 @@ void target_init(void)
uintmax_ctype = &ullong_ctype;
fast64_ctype = &llong_ctype;
ufast64_ctype = &ullong_ctype;
- if (target->target_32bit)
- target = target->target_32bit;
break;
case ARCH_LLP64:
diff --git a/target.h b/target.h
index 8ffd8e88..92b8af91 100644
--- a/target.h
+++ b/target.h
@@ -92,6 +92,7 @@ struct target {
unsigned int max_fp_alignment;
const struct target *target_32bit;
+ const struct target *target_x32bit;
const struct target *target_64bit;
const struct builtin_fn *builtins;