Skip to content

Commit 8452b4a

Browse files
iainscatap
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. (cherry picked from commit 419fa01def5a199dfe7aa230f6dc354b77b2b1a6) Signed-off-by: Kirill A. Korinsky <[email protected]>
1 parent 708ff23 commit 8452b4a

File tree

10 files changed

+407
-12
lines changed

10 files changed

+407
-12
lines changed

gcc/config.gcc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,11 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
11001100
done
11011101
TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
11021102
;;
1103+
aarch64-*-darwin* | arm64-*-darwin*)
1104+
tm_file="${tm_file} aarch64/aarch64-errata.h"
1105+
tmake_file="${tmake_file} aarch64/t-aarch64 aarch64/t-aarch64-darwin"
1106+
tm_defines="${tm_defines} TARGET_DEFAULT_ASYNC_UNWIND_TABLES=1"
1107+
;;
11031108
aarch64*-*-freebsd*)
11041109
tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file}"
11051110
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
@@ -493,6 +493,8 @@ enum aarch64_builtins
493493
AARCH64_MEMTAG_BUILTIN_SET_TAG,
494494
AARCH64_MEMTAG_BUILTIN_GET_TAG,
495495
AARCH64_MEMTAG_BUILTIN_END,
496+
/* OS-specific */
497+
AARCH64_BUILTIN_CFSTRING,
496498
AARCH64_BUILTIN_MAX
497499
};
498500

@@ -1312,6 +1314,14 @@ aarch64_general_init_builtins (void)
13121314
aarch64_init_memtag_builtins ();
13131315
}
13141316

1317+
void
1318+
aarch64_init_subtarget_builtins (void)
1319+
{
1320+
#ifdef SUBTARGET_INIT_BUILTINS
1321+
SUBTARGET_INIT_BUILTINS;
1322+
#endif
1323+
}
1324+
13151325
/* Implement TARGET_BUILTIN_DECL for the AARCH64_BUILTIN_GENERAL group. */
13161326
tree
13171327
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
@@ -360,4 +360,8 @@ aarch64_register_pragmas (void)
360360
targetm.check_builtin_call = aarch64_check_builtin_call;
361361

362362
c_register_pragma ("GCC", "aarch64", aarch64_pragma_aarch64);
363+
364+
#ifdef REGISTER_SUBTARGET_PRAGMAS
365+
REGISTER_SUBTARGET_PRAGMAS ();
366+
#endif
363367
}

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

@@ -716,6 +724,7 @@ void aarch64_override_options_internal (struct gcc_options *);
716724

717725
const char *aarch64_general_mangle_builtin_type (const_tree);
718726
void aarch64_general_init_builtins (void);
727+
void aarch64_init_subtarget_builtins (void);
719728
tree aarch64_general_fold_builtin (unsigned int, tree, unsigned int, tree *);
720729
gimple *aarch64_general_gimple_fold_builtin (unsigned int, gcall *);
721730
rtx aarch64_general_expand_builtin (unsigned int, tree, rtx, int);

0 commit comments

Comments
 (0)