Skip to content

Commit c8d7958

Browse files
iainsfxcoudert
authored andcommitted
Darwin, Arm64 : Initial definitions for the port.
This is enough to make a buildable cross-compiler on x86_64 Darwin and compile trivial codes. Although the link phase might not succeed - one can link objects manually and get an exe that works. There's an initial implementation of the rule changes for darwinpcs. There's an initial (pretty hacky) set of changes to deal with the post-fix assembly notation for Mach-O relocs. There are a few places where ELF was assumed, and we need to prevent incompatible output for Mach-O (probably there are other ways to do this). + Pick up atomic builtins from the libgcc.a CHECKME: should these be exported from the shared lib? (at present, that doesn't seem to be ideal). Look at what's done for the clang toolchain. + long double is DF not TF :( We will need to figure out what to do about supporting XXX*16 a some point. + Fix ptrdiff type. This was wrong (the size needs to track the 64-bitness and was failing to do so. + Add in driver sef-specs. Ensure that we issue the Darwin driver self specs and set the mabi and little-endian flags. clang accepts -mabi=darwinpcs so we allow that (but it means the same as lp64 at present since the target is determined at configuration time). + Fix an other build error for Darwin. Since we don't emit ELF function decorations this means that some of the variables are unused. + Initial implementation for EH without .cfi_xxxx While we can (most likely) make the .cfi_ codegen work, there are comments in the Ada code that suggest the capabilities of the unwinder are somewhat restricted. At least this option allows for the case of using libgcc_eh when an exe is self-contained. + Just whitespace fixes NFC. + We don't yet support TF, so reject 'q' suffix. The floating point literal suffix 'q' is specifically stated to be used for _float128, which we don't yet support. + Connect up the subtarget builtins i.e. __builtin_cfstring. The idea of OS-specific subtarget builtins doesn't fit too well with the general organisation of the aarch64 ones. What this does is to add it into the "GENERAL" class (but the darwin-specific code has no idea that the builtin code number has subfields). + Build fix for subtarget builtins. One either needs to define SUBTARGET_INIT_BUILTINS to empty or conditionalize its use + Connect up the sub-target attribute table. Darwin has some Mach-O / OS attributes, add these to the end of the aarch64 set.. + Connect up the pragma table. Darwin has some Mach-O / OS-specific pragmas, connected these to the end of the aarch64 table. gcc/ChangeLog: * config.gcc: Handle aarch64 and arm64 darwin. * config/aarch64/aarch64-protos.h (enum aarch64_symbol_type): Provide for symbol classifications for Mach-O. * config/aarch64/aarch64.c (aarch64_elf_asm_destructor): Don't define these for Mach-O (it's not ELF!). (handle_aarch64_vector_pcs_attribute): Handle darwinpcs. (aarch64_reg_save_mode): Likewise. (aarch64_load_symref_appropriately): Handle Mach-O. (aarch64_expand_mov_immediate): Likewise. (aarch64_layout_arg): Handle darwinpcs rules. (aarch64_function_arg): Likewise. (aarch64_init_cumulative_args): Likewise. (aarch64_function_arg_advance): Likewise. (aarch64_print_operand): Likewise (we can probably do better). (aarch64_print_address_internal): Likewise. (aarch64_asm_output_labelref): Likewise. (initialize_aarch64_code_model): Accept large PIC for Mach-O - of course, that doesn't mean it works. (aarch64_classify_symbol): Only emit ELF directives if they are available. (aarch64_declare_function_name): Likewise. (aarch64_asm_output_alias): Likewise. (aarch64_sls_emit_shared_blr_thunks): Likewise. (TARGET_ASM_UNALIGNED_HI_OP): New. (TARGET_ASM_UNALIGNED_SI_OP): New. (TARGET_ASM_UNALIGNED_DI_OP): New. * config/aarch64/aarch64.h (TARGET_MACHO): Declare as 0. (enum arm_pcs): Add darwinpcs. (SUBTARGET_EXTRA_SPECS): New. (EXTRA_SPECS): Allow for sub-target specs. * config/aarch64/aarch64.md (unspec enum): Add UNSPEC_MACHOPIC_OFFSET. (ldr_got_small_<mode>): Allow for postfix assembler syntax. (ldr_got_small_<mode>): Likewise. * config/aarch64/darwin.h: New file. * config/aarch64/t-aarch64-darwin: New file.
1 parent 1da8c29 commit c8d7958

File tree

10 files changed

+407
-15
lines changed

10 files changed

+407
-15
lines changed

gcc/config.gcc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,11 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
11211121
done
11221122
TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
11231123
;;
1124+
aarch64-*-darwin* | arm64-*-darwin*)
1125+
tm_file="${tm_file} aarch64/aarch64-errata.h"
1126+
tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-darwin"
1127+
tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
1128+
;;
11241129
aarch64*-*-freebsd*)
11251130
tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}"
11261131
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h"

gcc/config/aarch64/aarch64-builtins.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ enum aarch64_builtins
523523
AARCH64_MEMTAG_BUILTIN_SET_TAG,
524524
AARCH64_MEMTAG_BUILTIN_GET_TAG,
525525
AARCH64_MEMTAG_BUILTIN_END,
526+
/* OS-specific */
527+
AARCH64_BUILTIN_CFSTRING,
526528
AARCH64_BUILTIN_MAX
527529
};
528530

@@ -1461,6 +1463,14 @@ aarch64_general_init_builtins (void)
14611463
aarch64_init_memtag_builtins ();
14621464
}
14631465

1466+
void
1467+
aarch64_init_subtarget_builtins (void)
1468+
{
1469+
#ifdef SUBTARGET_INIT_BUILTINS
1470+
SUBTARGET_INIT_BUILTINS;
1471+
#endif
1472+
}
1473+
14641474
/* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group. */
14651475
tree
14661476
aarch64_general_builtin_decl (unsigned code, bool)

gcc/config/aarch64/aarch64-c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,8 @@ aarch64_register_pragmas (void)
361361
targetm.check_builtin_call = aarch64_check_builtin_call;
362362

363363
c_register_pragma ("GCC", "aarch64", aarch64_pragma_aarch64);
364+
365+
#ifdef REGISTER_SUBTARGET_PRAGMAS
366+
REGISTER_SUBTARGET_PRAGMAS ();
367+
#endif
364368
}

gcc/config/aarch64/aarch64-protos.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ enum aarch64_symbol_type
108108
SYMBOL_TLSLE24,
109109
SYMBOL_TLSLE32,
110110
SYMBOL_TLSLE48,
111+
SYMBOL_MO_SMALL_ABS,
112+
SYMBOL_MO_SMALL_PCR,
113+
SYMBOL_MO_SMALL_GOT,
114+
SYMBOL_MO_SMALL_TLS,
115+
SYMBOL_MO_LARGE_ABS,
116+
SYMBOL_MO_LARGE_PCR,
117+
SYMBOL_MO_LARGE_GOT,
118+
SYMBOL_MO_LARGE_TLS,
111119
SYMBOL_FORCE_TO_MEM
112120
};
113121

@@ -952,6 +960,7 @@ void aarch64_override_options_internal (struct gcc_options *);
952960

953961
const char *aarch64_general_mangle_builtin_type (const_tree);
954962
void aarch64_general_init_builtins (void);
963+
void aarch64_init_subtarget_builtins (void);
955964
tree aarch64_general_fold_builtin (unsigned int, tree, unsigned int, tree *);
956965
gimple *aarch64_general_gimple_fold_builtin (unsigned int, gcall *);
957966
rtx aarch64_general_expand_builtin (unsigned int, tree, rtx, int);

0 commit comments

Comments
 (0)