This patch add D language support to targets of GCC itself.
These are mostly used to declare pre-defined version identifiers in the D language that describe something about the target that the front-end itself is unable to obtain. Version conditions in D can be thought of as being like the target macros of C, but that where the similarity ends.
The only other target hook present is TARGET_D_CRITSEC_SIZE, which returns the size of pthread_mutex_t, or whatever equivalent type the OS provides.
---
gcc/ChangeLog
* gcc/Makefile.in (tm_d_file_list, tm_d_include_list,
TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables.
(tm_d.h, cs-tm_d.h, default-d.o, d/d-target-hooks-def.h,
s-d-target-hooks-def-h): New rules.
(s-tm-texi): Also check timestamp on d-target.def.
(generated_files): Add TM_D_H and d-target-hooks-def.h.
(build/genhooks.o): Also depend on D_TARGET_DEF.
* gcc/config.gcc (tm_d_file, d_target_objs, target_has_targetdm):
New variables.
* config/aarch64/aarch64-d.c: New file.
* config/aarch64/aarch64-linux.h (GNU_USER_TARGET_D_CRITSEC_SIZE):
Define.
* config/aarch64/aarch64-protos.h (aarch64_d_target_versions): New
prototype.
* config/aarch64/aarch64.h (TARGET_D_CPU_VERSIONS): Define.
* config/aarch64/t-aarch64 (aarch64-d.o): New rule.
* config/arm/arm-d.c: New file.
* config/arm/arm-protos.h (arm_d_target_versions): New prototype.
* config/arm/arm.h (TARGET_D_CPU_VERSIONS): Define.
* config/arm/linux-eabi.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
* config/arm/t-arm (arm-d.o): New rule.
* config/default-d.c: New file.
* config/glibc-d.c: New file.
* config/gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/i386/i386-d.c: New file.
* config/i386/i386-protos.h (ix86_d_target_versions): New prototype.
* config/i386/i386.h (TARGET_D_CPU_VERSIONS): Define.
* config/i386/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS,
GNU_USER_TARGET_D_CRITSEC_SIZE): Define.
* config/i386/t-i386 (i386-d.o): New rule.
* config/kfreebsd-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/kopensolaris-gnu.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/linux-android.h (ANDROID_TARGET_D_OS_VERSIONS): Define.
* config/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/mips/linux-common.h (EXTRA_TARGET_D_OS_VERSIONS): Define.
* config/mips/mips-d.c: New file.
* config/mips/mips-protos.h (mips_d_target_versions): New prototype.
* config/mips/mips.h (TARGET_D_CPU_VERSIONS): Define.
* config/mips/t-mips (mips-d.o): New rule.
* config/powerpcspe/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/powerpcspe/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/powerpcspe/powerpcspe-d.c: New file.
* config/powerpcspe/powerpcspe-protos.h (rs6000_d_target_versions):
New prototype.
* config/powerpcspe/powerpcspe.h (TARGET_D_CPU_VERSIONS): Define.
* config/powerpcspe/t-powerpcspe (powerpcspe-d.o): New rule.
* config/riscv/riscv-d.c: New file.
* config/riscv/riscv-protos.h (riscv_d_target_versions): New
prototype.
* config/riscv/riscv.h (TARGET_D_CPU_VERSIONS): Define.
* config/riscv/t-riscv (riscv-d.o): New rule.
* config/rs6000/linux.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/rs6000/linux64.h (GNU_USER_TARGET_D_OS_VERSIONS): Define.
* config/rs6000/rs6000-d.c: New file.
* config/rs6000/rs6000-protos.h (rs6000_d_target_versions): New
prototype.
* config/rs6000/t-rs6000 (rs6000-d.o): New rule.
* config/s390/s390-d.c: New file.
* config/s390/s390-protos.h (s390_d_target_versions): New prototype.
* config/s390/s390.h (TARGET_D_CPU_VERSIONS): Define.
* config/s390/t-s390 (s390-d.o): New rule.
* config/sparc/sparc-d.c: New file.
* config/sparc/sparc-protos.h (sparc_d_target_versions): New prototype.
* config/sparc/sparc.h (TARGET_D_CPU_VERSIONS): Define.
* config/sparc/t-sparc (sparc-d.o): New rule.
* config/t-glibc (glibc-d.o): New rule.
* gcc/configure.ac (tm_d_file): New variable.
(tm_d_file_list, tm_d_include_list, d_target_objs): Add substitute.
* gcc/configure: Regenerated.
* doc/tm.texi.in: Add @node for D language, and @hook for
TARGET_D_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE.
* doc/tm.texi: Regenerated.
* gcc/genhooks.c: Include d/d-target.def.
---
gcc/Makefile.in | 37 +++++++++++--
gcc/config.gcc | 29 ++++++++++
gcc/config/aarch64/aarch64-d.c | 31 +++++++++++
gcc/config/aarch64/aarch64-linux.h | 2 +
gcc/config/aarch64/aarch64-protos.h | 3 ++
gcc/config/aarch64/aarch64.h | 3 ++
gcc/config/aarch64/t-aarch64 | 4 ++
gcc/config/arm/arm-d.c | 53 +++++++++++++++++++
gcc/config/arm/arm-protos.h | 3 ++
gcc/config/arm/arm.h | 3 ++
gcc/config/arm/linux-eabi.h | 3 ++
gcc/config/arm/t-arm | 4 ++
gcc/config/default-d.c | 25 +++++++++
gcc/config/glibc-d.c | 64 +++++++++++++++++++++++
gcc/config/gnu.h | 6 +++
gcc/config/i386/i386-d.c | 44 ++++++++++++++++
gcc/config/i386/i386-protos.h | 3 ++
gcc/config/i386/i386.h | 3 ++
gcc/config/i386/linux-common.h | 6 +++
gcc/config/i386/t-i386 | 4 ++
gcc/config/kfreebsd-gnu.h | 6 +++
gcc/config/kopensolaris-gnu.h | 6 +++
gcc/config/linux-android.h | 6 +++
gcc/config/linux.h | 13 +++++
gcc/config/mips/linux-common.h | 3 ++
gcc/config/mips/mips-d.c | 56 ++++++++++++++++++++
gcc/config/mips/mips-protos.h | 3 ++
gcc/config/mips/mips.h | 3 ++
gcc/config/mips/t-mips | 4 ++
gcc/config/powerpcspe/linux.h | 13 +++++
gcc/config/powerpcspe/linux64.h | 13 +++++
gcc/config/powerpcspe/powerpcspe-d.c | 45 ++++++++++++++++
gcc/config/powerpcspe/powerpcspe-protos.h | 3 ++
gcc/config/powerpcspe/powerpcspe.h | 3 ++
gcc/config/powerpcspe/t-powerpcspe | 4 ++
gcc/config/riscv/riscv-d.c | 39 ++++++++++++++
gcc/config/riscv/riscv-protos.h | 3 ++
gcc/config/riscv/riscv.h | 3 ++
gcc/config/riscv/t-riscv | 5 ++
gcc/config/rs6000/linux.h | 13 +++++
gcc/config/rs6000/linux64.h | 13 +++++
gcc/config/rs6000/rs6000-d.c | 45 ++++++++++++++++
gcc/config/rs6000/rs6000-protos.h | 3 ++
gcc/config/rs6000/rs6000.h | 3 ++
gcc/config/rs6000/t-rs6000 | 4 ++
gcc/config/s390/s390-d.c | 41 +++++++++++++++
gcc/config/s390/s390-protos.h | 3 ++
gcc/config/s390/s390.h | 3 ++
gcc/config/s390/t-s390 | 4 ++
gcc/config/sparc/sparc-d.c | 48 +++++++++++++++++
gcc/config/sparc/sparc-protos.h | 3 ++
gcc/config/sparc/sparc.h | 3 ++
gcc/config/sparc/t-sparc | 4 ++
gcc/config/t-glibc | 4 ++
gcc/configure | 26 ++++++++-
gcc/configure.ac | 19 +++++++
gcc/doc/tm.texi | 25 +++++++++
gcc/doc/tm.texi.in | 19 +++++++
gcc/genhooks.c | 1 +
59 files changed, 840 insertions(+), 5 deletions(-)
create mode 100644 gcc/config/aarch64/aarch64-d.c
create mode 100644 gcc/config/arm/arm-d.c
create mode 100644 gcc/config/default-d.c
create mode 100644 gcc/config/glibc-d.c
create mode 100644 gcc/config/i386/i386-d.c
create mode 100644 gcc/config/mips/mips-d.c
create mode 100644 gcc/config/powerpcspe/powerpcspe-d.c
create mode 100644 gcc/config/riscv/riscv-d.c
create mode 100644 gcc/config/rs6000/rs6000-d.c
create mode 100644 gcc/config/s390/s390-d.c
create mode 100644 gcc/config/sparc/sparc-d.c
@@ -554,6 +554,8 @@ tm_include_list=@tm_include_list@
tm_defines=@tm_defines@
tm_p_file_list=@tm_p_file_list@
tm_p_include_list=@tm_p_include_list@
+tm_d_file_list=@tm_d_file_list@
+tm_d_include_list=@tm_d_include_list@
build_xm_file_list=@build_xm_file_list@
build_xm_include_list=@build_xm_include_list@
build_xm_defines=@build_xm_defines@
@@ -848,6 +850,7 @@ BCONFIG_H = bconfig.h $(build_xm_file_list)
CONFIG_H = config.h $(host_xm_file_list)
TCONFIG_H = tconfig.h $(xm_file_list)
TM_P_H = tm_p.h $(tm_p_file_list)
+TM_D_H = tm_d.h $(tm_d_file_list)
GTM_H = tm.h $(tm_file_list) insn-constants.h
TM_H = $(GTM_H) insn-flags.h $(OPTIONS_H)
@@ -905,9 +908,11 @@ EXCEPT_H = except.h $(HASHTAB_H)
TARGET_DEF = target.def target-hooks-macros.h target-insns.def
C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
+D_TARGET_DEF = d/d-target.def target-hooks-macros.h
TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h insn-codes.h
C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
COMMON_TARGET_H = common/common-target.h $(INPUT_H) $(COMMON_TARGET_DEF)
+D_TARGET_H = d/d-target.h $(D_TARGET_DEF)
MACHMODE_H = machmode.h mode-classes.def
HOOKS_H = hooks.h
HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
@@ -1187,6 +1192,9 @@ C_TARGET_OBJS=@c_target_objs@
# Target specific, C++ specific object file
CXX_TARGET_OBJS=@cxx_target_objs@
+# Target specific, D specific object file
+D_TARGET_OBJS=@d_target_objs@
+
# Target specific, Fortran specific object file
FORTRAN_TARGET_OBJS=@fortran_target_objs@
@@ -1785,6 +1793,7 @@ bconfig.h: cs-bconfig.h ; @true
tconfig.h: cs-tconfig.h ; @true
tm.h: cs-tm.h ; @true
tm_p.h: cs-tm_p.h ; @true
+tm_d.h: cs-tm_d.h ; @true
cs-config.h: Makefile
TARGET_CPU_DEFAULT="" \
@@ -1811,6 +1820,11 @@ cs-tm_p.h: Makefile
HEADERS="$(tm_p_include_list)" DEFINES="" \
$(SHELL) $(srcdir)/mkconfig.sh tm_p.h
+cs-tm_d.h: Makefile
+ TARGET_CPU_DEFAULT="" \
+ HEADERS="$(tm_d_include_list)" DEFINES="" \
+ $(SHELL) $(srcdir)/mkconfig.sh tm_d.h
+
# Don't automatically run autoconf, since configure.ac might be accidentally
# newer than configure. Also, this writes into the source directory which
# might be on a read-only file system. If configured for maintainer mode
@@ -2177,6 +2191,12 @@ default-c.o: config/default-c.c
CFLAGS-prefix.o += -DPREFIX=\"$(prefix)\" -DBASEVER=$(BASEVER_s)
prefix.o: $(BASEVER)
+# Files used by the D language front end.
+
+default-d.o: config/default-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
# Language-independent files.
DRIVER_DEFINES = \
@@ -2473,6 +2493,15 @@ s-common-target-hooks-def-h: build/genhooks$(build_exeext)
common/common-target-hooks-def.h
$(STAMP) s-common-target-hooks-def-h
+d/d-target-hooks-def.h: s-d-target-hooks-def-h; @true
+
+s-d-target-hooks-def-h: build/genhooks$(build_exeext)
+ $(RUN_GEN) build/genhooks$(build_exeext) "D Target Hook" \
+ > tmp-d-target-hooks-def.h
+ $(SHELL) $(srcdir)/../move-if-change tmp-d-target-hooks-def.h \
+ d/d-target-hooks-def.h
+ $(STAMP) s-d-target-hooks-def-h
+
# check if someone mistakenly only changed tm.texi.
# We use a different pathname here to avoid a circular dependency.
s-tm-texi: $(srcdir)/doc/../doc/tm.texi
@@ -2496,6 +2525,7 @@ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
&& ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
|| test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
|| test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
+ || test $(srcdir)/doc/tm.texi -nt $(srcdir)/d/d-target.def \
); then \
echo >&2 ; \
echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
@@ -2633,14 +2663,15 @@ s-gtype: build/gengtype$(build_exeext) $(filter-out [%], $(GTFILES)) \
-r gtype.state
$(STAMP) s-gtype
-generated_files = config.h tm.h $(TM_P_H) $(TM_H) multilib.h \
+generated_files = config.h tm.h $(TM_P_H) $(TM_D_H) $(TM_H) multilib.h \
$(simple_generated_h) specs.h \
tree-check.h genrtl.h insn-modes.h insn-modes-inline.h \
tm-preds.h tm-constrs.h \
$(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gcov-iov.h \
options.h target-hooks-def.h insn-opinit.h \
common/common-target-hooks-def.h pass-instances.def \
- c-family/c-target-hooks-def.h params.list params.options case-cfn-macros.h \
+ c-family/c-target-hooks-def.h d/d-target-hooks-def.h \
+ params.list params.options case-cfn-macros.h \
cfn-operators.pd
#
@@ -2784,7 +2815,7 @@ build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H) \
$(HASH_TABLE_H) inchash.h
build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF) \
- $(COMMON_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
+ $(COMMON_TARGET_DEF) $(D_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
build/genmddump.o : genmddump.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H) \
$(CORETYPES_H) $(GTM_H) errors.h $(READ_MD_H) $(GENSUPPORT_H)
build/genmatch.o : genmatch.c $(BCONFIG_H) $(SYSTEM_H) \
@@ -86,6 +86,9 @@
# tm_p_file Location of file with declarations for functions
# in $out_file.
#
+# tm_d_file A list of headers with definitions of target hook
+# macros for the D compiler.
+#
# out_file The name of the machine description C support
# file, if different from "$cpu_type/$cpu_type.c".
#
@@ -139,6 +142,9 @@
# cxx_target_objs List of extra target-dependent objects that be
# linked into the C++ compiler only.
#
+# d_target_objs List of extra target-dependent objects that be
+# linked into the D compiler only.
+#
# fortran_target_objs List of extra target-dependent objects that be
# linked into the fortran compiler only.
#
@@ -191,6 +197,9 @@
#
# target_has_targetm_common Set to yes or no depending on whether the
# target has its own definition of targetm_common.
+#
+# target_has_targetdm Set to yes or no depending on whether the target
+# has its own definition of targetdm.
out_file=
common_out_file=
@@ -206,9 +215,11 @@ extra_gcc_objs=
extra_options=
c_target_objs=
cxx_target_objs=
+d_target_objs=
fortran_target_objs=
target_has_targetcm=no
target_has_targetm_common=yes
+target_has_targetdm=no
tm_defines=
xm_defines=
# Set this to force installation and use of collect2.
@@ -304,6 +315,7 @@ aarch64*-*-*)
extra_headers="arm_fp16.h arm_neon.h arm_acle.h"
c_target_objs="aarch64-c.o"
cxx_target_objs="aarch64-c.o"
+ d_target_objs="aarch64-d.o"
extra_objs="aarch64-builtins.o aarch-common.o cortex-a57-fma-steering.o aarch64-speculation.o falkor-tag-collision-avoidance.o"
target_gtfiles="\$(srcdir)/config/aarch64/aarch64-builtins.c"
target_has_targetm_common=yes
@@ -329,6 +341,7 @@ arm*-*-*)
target_type_format_char='%'
c_target_objs="arm-c.o"
cxx_target_objs="arm-c.o"
+ d_target_objs="arm-d.o"
extra_options="${extra_options} arm/arm-tables.opt"
target_gtfiles="\$(srcdir)/config/arm/arm-builtins.c"
;;
@@ -361,6 +374,7 @@ i[34567]86-*-*)
cpu_type=i386
c_target_objs="i386-c.o"
cxx_target_objs="i386-c.o"
+ d_target_objs="i386-d.o"
extra_objs="x86-tune-sched.o x86-tune-sched-bd.o x86-tune-sched-atom.o x86-tune-sched-core.o"
extra_options="${extra_options} fused-madd.opt"
extra_headers="cpuid.h mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h
@@ -391,6 +405,7 @@ x86_64-*-*)
cpu_type=i386
c_target_objs="i386-c.o"
cxx_target_objs="i386-c.o"
+ d_target_objs="i386-d.o"
extra_options="${extra_options} fused-madd.opt"
extra_objs="x86-tune-sched.o x86-tune-sched-bd.o x86-tune-sched-atom.o x86-tune-sched-core.o"
extra_headers="cpuid.h mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h
@@ -441,6 +456,7 @@ microblaze*-*-*)
;;
mips*-*-*)
cpu_type=mips
+ d_target_objs="mips-d.o"
extra_headers="loongson.h msa.h"
extra_objs="frame-header-opt.o"
extra_options="${extra_options} g.opt fused-madd.opt mips/mips-tables.opt"
@@ -496,6 +512,7 @@ powerpc*-*-*)
riscv*)
cpu_type=riscv
extra_objs="riscv-builtins.o riscv-c.o"
+ d_target_objs="riscv-d.o"
;;
rs6000*-*-*)
extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt"
@@ -505,6 +522,7 @@ sparc*-*-*)
cpu_type=sparc
c_target_objs="sparc-c.o"
cxx_target_objs="sparc-c.o"
+ d_target_objs="sparc-d.o"
extra_headers="visintrin.h"
;;
spu*-*-*)
@@ -512,6 +530,7 @@ spu*-*-*)
;;
s390*-*-*)
cpu_type=s390
+ d_target_objs="s390-d.o"
extra_options="${extra_options} fused-madd.opt"
extra_headers="s390intrin.h htmintrin.h htmxlintrin.h vecintrin.h"
;;
@@ -541,10 +560,13 @@ tilepro*-*-*)
esac
tm_file=${cpu_type}/${cpu_type}.h
+tm_d_file=${cpu_type}/${cpu_type}.h
if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-protos.h
then
tm_p_file=${cpu_type}/${cpu_type}-protos.h
+ tm_d_file="${tm_d_file} ${cpu_type}/${cpu_type}-protos.h"
fi
+
extra_modes=
if test -f ${srcdir}/config/${cpu_type}/${cpu_type}-modes.def
then
@@ -814,8 +836,10 @@ case ${target} in
esac
c_target_objs="${c_target_objs} glibc-c.o"
cxx_target_objs="${cxx_target_objs} glibc-c.o"
+ d_target_objs="${d_target_objs} glibc-d.o"
tmake_file="${tmake_file} t-glibc"
target_has_targetcm=yes
+ target_has_targetdm=yes
;;
*-*-netbsd*)
tm_p_file="${tm_p_file} netbsd-protos.h"
@@ -3231,6 +3255,10 @@ if [ "$common_out_file" = "" ]; then
fi
fi
+if [ "$target_has_targetdm" = "no" ]; then
+ d_target_objs="$d_target_objs default-d.o"
+fi
+
# Support for --with-cpu and related options (and a few unrelated options,
# too).
case ${with_cpu} in
@@ -4845,6 +4873,7 @@ case ${target} in
out_file="${cpu_type}/${cpu_type}.c"
c_target_objs="${c_target_objs} ${cpu_type}-c.o"
cxx_target_objs="${cxx_target_objs} ${cpu_type}-c.o"
+ d_target_objs="${d_target_objs} ${cpu_type}-d.o"
tmake_file="${cpu_type}/t-${cpu_type} ${tmake_file}"
;;
new file mode 100644
@@ -0,0 +1,31 @@
+/* Subroutines for the D front end on the ARM64 architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for ARM64 targets. */
+
+void
+aarch64_d_target_versions (void)
+{
+ d_add_builtin_version ("AArch64");
+ d_add_builtin_version ("D_HardFloat");
+}
@@ -81,6 +81,8 @@
} \
while (0)
+#define GNU_USER_TARGET_D_CRITSEC_SIZE 48
+
#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
/* Uninitialized common symbols in non-PIE executables, even with
@@ -626,4 +626,7 @@ poly_uint64 aarch64_regmode_natural_size (machine_mode);
bool aarch64_high_bits_all_ones_p (HOST_WIDE_INT);
+/* Defined in aarch64-d.c */
+extern void aarch64_d_target_versions (void);
+
#endif /* GCC_AARCH64_PROTOS_H */
@@ -26,6 +26,9 @@
#define TARGET_CPU_CPP_BUILTINS() \
aarch64_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS aarch64_d_target_versions
+
#define REGISTER_TARGET_PRAGMAS() aarch64_register_pragmas ()
@@ -56,6 +56,10 @@ aarch64-c.o: $(srcdir)/config/aarch64/aarch64-c.c $(CONFIG_H) $(SYSTEM_H) \
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/aarch64/aarch64-c.c
+aarch64-d.o: $(srcdir)/config/aarch64/aarch64-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
PASSES_EXTRA += $(srcdir)/config/aarch64/aarch64-passes.def
cortex-a57-fma-steering.o: $(srcdir)/config/aarch64/cortex-a57-fma-steering.c \
new file mode 100644
@@ -0,0 +1,53 @@
+/* Subroutines for the D front end on the ARM architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for ARM targets. */
+
+void
+arm_d_target_versions (void)
+{
+ d_add_builtin_version ("ARM");
+
+ if (TARGET_THUMB || TARGET_THUMB2)
+ {
+ d_add_builtin_version ("Thumb");
+ d_add_builtin_version ("ARM_Thumb");
+ }
+
+ if (TARGET_HARD_FLOAT_ABI)
+ d_add_builtin_version ("ARM_HardFloat");
+ else
+ {
+ if (TARGET_SOFT_FLOAT)
+ d_add_builtin_version ("ARM_SoftFloat");
+ else if (TARGET_HARD_FLOAT)
+ d_add_builtin_version ("ARM_SoftFP");
+ }
+
+ if (TARGET_SOFT_FLOAT)
+ d_add_builtin_version ("D_SoftFloat");
+ else if (TARGET_HARD_FLOAT)
+ d_add_builtin_version ("D_HardFloat");
+}
@@ -375,6 +375,9 @@ extern void arm_lang_object_attributes_init (void);
extern void arm_register_target_pragmas (void);
extern void arm_cpu_cpp_builtins (struct cpp_reader *);
+/* Defined in arm-d.c */
+extern void arm_d_target_versions (void);
+
extern bool arm_is_constant_pool_ref (rtx);
/* The bits in this mask specify which instruction scheduling options should
@@ -47,6 +47,9 @@ extern char arm_arch_name[];
/* Target CPU builtins. */
#define TARGET_CPU_CPP_BUILTINS() arm_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS arm_d_target_versions
+
#include "config/arm/arm-opts.h"
/* The processor for which instructions should be scheduled. */
@@ -30,6 +30,9 @@
} \
while (false)
+#define EXTRA_TARGET_D_OS_VERSIONS() \
+ ANDROID_TARGET_D_OS_VERSIONS();
+
/* We default to a soft-float ABI so that binaries can run on all
target hardware. If you override this to use the hard-float ABI then
change the setting of GLIBC_DYNAMIC_LINKER_DEFAULT as well. */
@@ -152,6 +152,10 @@ arm-c.o: $(srcdir)/config/arm/arm-c.c $(CONFIG_H) $(SYSTEM_H) \
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/arm/arm-c.c
+arm-d.o: $(srcdir)/config/arm/arm-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
arm-common.o: arm-cpu-cdata.h
driver-arm.o: arm-native.h
new file mode 100644
@@ -0,0 +1,25 @@
+/* Default D language target hooks initializer.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm_d.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
new file mode 100644
@@ -0,0 +1,64 @@
+/* Glibc support needed only by D front-end.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "memmodel.h"
+#include "tm_p.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_OS_VERSIONS for Glibc targets. */
+
+static void
+glibc_d_os_builtins (void)
+{
+ d_add_builtin_version ("Posix");
+
+#define builtin_version(TXT) d_add_builtin_version (TXT)
+
+#ifdef GNU_USER_TARGET_D_OS_VERSIONS
+ GNU_USER_TARGET_D_OS_VERSIONS ();
+#endif
+
+#ifdef EXTRA_TARGET_D_OS_VERSIONS
+ EXTRA_TARGET_D_OS_VERSIONS ();
+#endif
+}
+
+/* Implement TARGET_D_CRITSEC_SIZE for Glibc targets. */
+
+static unsigned
+glibc_d_critsec_size (void)
+{
+ /* This is the sizeof pthread_mutex_t. */
+#ifdef GNU_USER_TARGET_D_CRITSEC_SIZE
+ return GNU_USER_TARGET_D_CRITSEC_SIZE;
+#else
+ return (POINTER_SIZE == 64) ? 40 : 24;
+#endif
+}
+
+#undef TARGET_D_OS_VERSIONS
+#define TARGET_D_OS_VERSIONS glibc_d_os_builtins
+
+#undef TARGET_D_CRITSEC_SIZE
+#define TARGET_D_CRITSEC_SIZE glibc_d_critsec_size
+
+struct gcc_targetdm targetdm = TARGETDM_INITIALIZER;
@@ -31,3 +31,9 @@ along with GCC. If not, see <http://www.gnu.org/licenses/>.
builtin_assert ("system=unix"); \
builtin_assert ("system=posix"); \
} while (0)
+
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("Hurd"); \
+ builtin_version ("CRuntime_Glibc"); \
+ } while (0)
new file mode 100644
@@ -0,0 +1,44 @@
+/* Subroutines for the D front end on the x86 architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for x86 targets. */
+
+void
+ix86_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ {
+ d_add_builtin_version ("X86_64");
+
+ if (TARGET_X32)
+ d_add_builtin_version ("D_X32");
+ }
+ else
+ d_add_builtin_version ("X86");
+
+ if (TARGET_80387)
+ d_add_builtin_version ("D_HardFloat");
+ else
+ d_add_builtin_version ("D_SoftFloat");
+}
@@ -236,6 +236,9 @@ extern void ix86_expand_sse2_abs (rtx, rtx);
extern void ix86_target_macros (void);
extern void ix86_register_pragmas (void);
+/* In i386-d.c */
+extern void ix86_d_target_versions (void);
+
/* In winnt.c */
extern void i386_pe_unique_section (tree, int);
extern void i386_pe_declare_function_type (FILE *, const char *, int);
@@ -710,6 +710,9 @@ extern const char *host_detect_local_cpu (int argc, const char **argv);
/* Target Pragmas. */
#define REGISTER_TARGET_PRAGMAS() ix86_register_pragmas ()
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS ix86_d_target_versions
+
#ifndef CC1_SPEC
#define CC1_SPEC "%(cc1_cpu) "
#endif
@@ -27,6 +27,12 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define EXTRA_TARGET_D_OS_VERSIONS() \
+ ANDROID_TARGET_D_OS_VERSIONS();
+
+#define GNU_USER_TARGET_D_CRITSEC_SIZE \
+ (TARGET_64BIT ? (POINTER_SIZE == 64 ? 40 : 32) : 24)
+
#undef CC1_SPEC
#define CC1_SPEC \
LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \
@@ -24,6 +24,10 @@ i386-c.o: $(srcdir)/config/i386/i386-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+i386-d.o: $(srcdir)/config/i386/i386-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
x86-tune-sched.o: $(srcdir)/config/i386/x86-tune-sched.c
$(COMPILE) $<
$(POSTCOMPILE)
@@ -29,6 +29,12 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("FreeBSD"); \
+ builtin_version ("CRuntime_Glibc"); \
+ } while (0)
+
#define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER32 GLIBC_DYNAMIC_LINKER32
#define GNU_USER_DYNAMIC_LINKER64 GLIBC_DYNAMIC_LINKER64
@@ -30,5 +30,11 @@ along with GCC; see the file COPYING3. If not see
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("Solaris"); \
+ builtin_version ("CRuntime_Glibc"); \
+ } while (0)
+
#undef GNU_USER_DYNAMIC_LINKER
#define GNU_USER_DYNAMIC_LINKER "/lib/ld.so.1"
@@ -25,6 +25,12 @@
builtin_define ("__ANDROID__"); \
} while (0)
+#define ANDROID_TARGET_D_OS_VERSIONS() \
+ do { \
+ if (TARGET_ANDROID) \
+ builtin_version ("Android"); \
+ } while (0)
+
#if ANDROID_DEFAULT
# define NOANDROID "mno-android"
#else
@@ -53,6 +53,19 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
builtin_assert ("system=posix"); \
} while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("linux"); \
+ if (OPTION_GLIBC) \
+ builtin_version ("CRuntime_Glibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_version ("CRuntime_UClibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_version ("CRuntime_Bionic"); \
+ else if (OPTION_MUSL) \
+ builtin_version ("CRuntime_Musl"); \
+ } while (0)
+
/* Determine which dynamic linker to use depending on whether GLIBC or
uClibc or Bionic or musl is the default C library and whether
-muclibc or -mglibc or -mbionic or -mmusl has been passed to change
@@ -27,6 +27,9 @@ along with GCC; see the file COPYING3. If not see
ANDROID_TARGET_OS_CPP_BUILTINS(); \
} while (0)
+#define EXTRA_TARGET_D_OS_VERSIONS() \
+ ANDROID_TARGET_D_OS_VERSIONS();
+
#undef LINK_SPEC
#define LINK_SPEC \
LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \
new file mode 100644
@@ -0,0 +1,56 @@
+/* Subroutines for the D front end on the MIPS architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for MIPS targets. */
+
+void
+mips_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ d_add_builtin_version ("MIPS64");
+ else
+ d_add_builtin_version ("MIPS32");
+
+ if (mips_abi == ABI_32)
+ d_add_builtin_version ("MIPS_O32");
+ else if (mips_abi == ABI_EABI)
+ d_add_builtin_version ("MIPS_EABI");
+ else if (mips_abi == ABI_N32)
+ d_add_builtin_version ("MIPS_N32");
+ else if (mips_abi == ABI_64)
+ d_add_builtin_version ("MIPS_N64");
+ else if (mips_abi == ABI_O64)
+ d_add_builtin_version ("MIPS_O64");
+
+ if (TARGET_HARD_FLOAT_ABI)
+ {
+ d_add_builtin_version ("MIPS_HardFloat");
+ d_add_builtin_version ("D_HardFloat");
+ }
+ else if (TARGET_SOFT_FLOAT_ABI)
+ {
+ d_add_builtin_version ("MIPS_SoftFloat");
+ d_add_builtin_version ("D_SoftFloat");
+ }
+}
@@ -385,4 +385,7 @@ extern mulsidi3_gen_fn mips_mulsidi3_gen_fn (enum rtx_code);
extern void mips_register_frame_header_opt (void);
extern void mips_expand_vec_cond_expr (machine_mode, machine_mode, rtx *);
+/* Routines implemented in mips-d.c */
+extern void mips_d_target_versions (void);
+
#endif /* ! GCC_MIPS_PROTOS_H */
@@ -645,6 +645,9 @@ struct mips_cpu_info {
} \
while (0)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS mips_d_target_versions
+
/* Default target_flags if no switches are specified */
#ifndef TARGET_DEFAULT
@@ -24,3 +24,7 @@ $(srcdir)/config/mips/mips-tables.opt: $(srcdir)/config/mips/genopt.sh \
frame-header-opt.o: $(srcdir)/config/mips/frame-header-opt.c
$(COMPILE) $<
$(POSTCOMPILE)
+
+mips-d.o: $(srcdir)/config/mips/mips-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
@@ -57,6 +57,19 @@
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("linux"); \
+ if (OPTION_GLIBC) \
+ builtin_version ("CRuntime_Glibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_version ("CRuntime_UClibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_version ("CRuntime_Bionic"); \
+ else if (OPTION_MUSL) \
+ builtin_version ("CRuntime_Musl"); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
@@ -391,6 +391,19 @@ extern int dot_symbols;
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("linux"); \
+ if (OPTION_GLIBC) \
+ builtin_version ("CRuntime_Glibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_version ("CRuntime_UClibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_version ("CRuntime_Bionic"); \
+ else if (OPTION_MUSL) \
+ builtin_version ("CRuntime_Musl"); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux) %(include_extra)"
new file mode 100644
@@ -0,0 +1,45 @@
+/* Subroutines for the D front end on the PowerPC architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for PowerPC targets. */
+
+void
+rs6000_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ d_add_builtin_version ("PPC64");
+ else
+ d_add_builtin_version ("PPC");
+
+ if (TARGET_HARD_FLOAT)
+ {
+ d_add_builtin_version ("PPC_HardFloat");
+ d_add_builtin_version ("D_HardFloat");
+ }
+ else if (TARGET_SOFT_FLOAT)
+ {
+ d_add_builtin_version ("PPC_SoftFloat");
+ d_add_builtin_version ("D_SoftFloat");
+ }
+}
@@ -231,6 +231,9 @@ extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT, HOST_WIDE_INT);
extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT,
HOST_WIDE_INT);
+/* Declare functions in powerpcspe-d.c */
+extern void rs6000_d_target_versions (void);
+
#if TARGET_MACHO
char *output_call (rtx_insn *, rtx *, int, int);
#endif
@@ -822,6 +822,9 @@ extern unsigned char rs6000_recip_bits[];
#define TARGET_CPU_CPP_BUILTINS() \
rs6000_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS rs6000_d_target_versions
+
/* This is used by rs6000_cpu_cpp_builtins to indicate the byte order
we're compiling for. Some configurations may need to override it. */
#define RS6000_CPU_CPP_ENDIAN_BUILTINS() \
@@ -26,6 +26,10 @@ powerpcspe-c.o: $(srcdir)/config/powerpcspe/powerpcspe-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+powerpcspe-d.o: $(srcdir)/config/powerpcspe/powerpcspe-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
$(srcdir)/config/powerpcspe/powerpcspe-tables.opt: $(srcdir)/config/powerpcspe/genopt.sh \
$(srcdir)/config/powerpcspe/powerpcspe-cpus.def
$(SHELL) $(srcdir)/config/powerpcspe/genopt.sh $(srcdir)/config/powerpcspe > \
new file mode 100644
@@ -0,0 +1,39 @@
+/* Subroutines for the D front end on the RISC-V architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "target.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for RISC-V targets. */
+
+void
+riscv_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ d_add_builtin_version ("RISCV64");
+ else
+ d_add_builtin_version ("RISCV32");
+
+ if (TARGET_HARD_FLOAT)
+ d_add_builtin_version ("D_HardFloat");
+ else
+ d_add_builtin_version ("D_SoftFloat");
+}
@@ -75,6 +75,9 @@ extern bool riscv_expand_block_move (rtx, rtx, rtx);
/* Routines implemented in riscv-c.c. */
void riscv_cpu_cpp_builtins (cpp_reader *);
+/* Routines implemented in riscv-d.c */
+extern void riscv_d_target_versions (void);
+
/* Routines implemented in riscv-builtins.c. */
extern void riscv_atomic_assign_expand_fenv (tree *, tree *, tree *);
extern rtx riscv_expand_builtin (tree, rtx, rtx, machine_mode, int);
@@ -27,6 +27,9 @@ along with GCC; see the file COPYING3. If not see
/* Target CPU builtins. */
#define TARGET_CPU_CPP_BUILTINS() riscv_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS riscv_d_target_versions
+
/* Default target_flags if no switches are specified */
#ifndef TARGET_DEFAULT
@@ -9,3 +9,8 @@ riscv-c.o: $(srcdir)/config/riscv/riscv-c.c $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TM_H) $(TREE_H) output.h $(C_COMMON_H) $(TARGET_H)
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/riscv/riscv-c.c
+
+riscv-d.o: $(srcdir)/config/riscv/riscv-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
@@ -57,6 +57,19 @@
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("linux"); \
+ if (OPTION_GLIBC) \
+ builtin_version ("CRuntime_Glibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_version ("CRuntime_UClibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_version ("CRuntime_Bionic"); \
+ else if (OPTION_MUSL) \
+ builtin_version ("CRuntime_Musl"); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux)"
@@ -391,6 +391,19 @@ extern int dot_symbols;
} \
while (0)
+#define GNU_USER_TARGET_D_OS_VERSIONS() \
+ do { \
+ builtin_version ("linux"); \
+ if (OPTION_GLIBC) \
+ builtin_version ("CRuntime_Glibc"); \
+ else if (OPTION_UCLIBC) \
+ builtin_version ("CRuntime_UClibc"); \
+ else if (OPTION_BIONIC) \
+ builtin_version ("CRuntime_Bionic"); \
+ else if (OPTION_MUSL) \
+ builtin_version ("CRuntime_Musl"); \
+ } while (0)
+
#undef CPP_OS_DEFAULT_SPEC
#define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux) %(include_extra)"
new file mode 100644
@@ -0,0 +1,45 @@
+/* Subroutines for the D front end on the PowerPC architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for PowerPC targets. */
+
+void
+rs6000_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ d_add_builtin_version ("PPC64");
+ else
+ d_add_builtin_version ("PPC");
+
+ if (TARGET_HARD_FLOAT)
+ {
+ d_add_builtin_version ("PPC_HardFloat");
+ d_add_builtin_version ("D_HardFloat");
+ }
+ else if (TARGET_SOFT_FLOAT)
+ {
+ d_add_builtin_version ("PPC_SoftFloat");
+ d_add_builtin_version ("D_SoftFloat");
+ }
+}
@@ -224,6 +224,9 @@ extern void rs6000_target_modify_macros (bool, HOST_WIDE_INT, HOST_WIDE_INT);
extern void (*rs6000_target_modify_macros_ptr) (bool, HOST_WIDE_INT,
HOST_WIDE_INT);
+/* Declare functions in rs6000-d.c */
+extern void rs6000_d_target_versions (void);
+
#if TARGET_MACHO
char *output_call (rtx_insn *, rtx *, int, int);
#endif
@@ -743,6 +743,9 @@ extern unsigned char rs6000_recip_bits[];
#define TARGET_CPU_CPP_BUILTINS() \
rs6000_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS rs6000_d_target_versions
+
/* This is used by rs6000_cpu_cpp_builtins to indicate the byte order
we're compiling for. Some configurations may need to override it. */
#define RS6000_CPU_CPP_ENDIAN_BUILTINS() \
@@ -27,6 +27,10 @@ rs6000-c.o: $(srcdir)/config/rs6000/rs6000-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+rs6000-d.o: $(srcdir)/config/rs6000/rs6000-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
rs6000-string.o: $(srcdir)/config/rs6000/rs6000-string.c
$(COMPILE) $<
$(POSTCOMPILE)
new file mode 100644
@@ -0,0 +1,41 @@
+/* Subroutines for the D front end on the IBM S/390 and zSeries architectures.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for S/390 and zSeries targets. */
+
+void
+s390_d_target_versions (void)
+{
+ if (TARGET_ZARCH)
+ d_add_builtin_version ("SystemZ");
+ else if (TARGET_64BIT)
+ d_add_builtin_version ("S390X");
+ else
+ d_add_builtin_version ("S390");
+
+ if (TARGET_SOFT_FLOAT)
+ d_add_builtin_version ("D_SoftFloat");
+ else if (TARGET_HARD_FLOAT)
+ d_add_builtin_version ("D_HardFloat");
+}
@@ -166,6 +166,9 @@ extern void s390_register_target_pragmas (void);
/* Routines for s390-c.c */
extern bool s390_const_operand_ok (tree, int, int, tree);
+/* Routines for s390-d.c */
+extern void s390_d_target_versions (void);
+
/* Pass management. */
namespace gcc { class context; }
class rtl_opt_pass;
@@ -200,6 +200,9 @@ enum processor_flags
/* Target CPU builtins. */
#define TARGET_CPU_CPP_BUILTINS() s390_cpu_cpp_builtins (pfile)
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS s390_d_target_versions
+
#ifdef DEFAULT_TARGET_64BIT
#define TARGET_DEFAULT (MASK_64BIT | MASK_ZARCH | MASK_HARD_DFP \
| MASK_OPT_HTM | MASK_OPT_VX)
@@ -26,3 +26,7 @@ s390-c.o: $(srcdir)/config/s390/s390-c.c \
$(TARGET_H) $(TARGET_DEF_H) $(CPPLIB_H) $(C_PRAGMA_H)
$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
$(srcdir)/config/s390/s390-c.c
+
+s390-d.o: $(srcdir)/config/s390/s390-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
new file mode 100644
@@ -0,0 +1,48 @@
+/* Subroutines for the D front end on the SPARC architecture.
+ Copyright (C) 2017-2018 Free Software Foundation, Inc.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3. If not see
+<http://www.gnu.org/licenses/>. */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "d/d-target.h"
+#include "d/d-target-def.h"
+
+/* Implement TARGET_D_CPU_VERSIONS for SPARC targets. */
+
+void
+sparc_d_target_versions (void)
+{
+ if (TARGET_64BIT)
+ d_add_builtin_version ("SPARC64");
+ else
+ d_add_builtin_version ("SPARC");
+
+ if (TARGET_V8PLUS)
+ d_add_builtin_version ("SPARC_V8Plus");
+
+ if (TARGET_FPU)
+ {
+ d_add_builtin_version ("D_HardFloat");
+ d_add_builtin_version ("SPARC_HardFloat");
+ }
+ else
+ {
+ d_add_builtin_version ("D_SoftFloat");
+ d_add_builtin_version ("SPARC_SoftFloat");
+ }
+}
@@ -110,4 +110,7 @@ unsigned int sparc_regmode_natural_size (machine_mode);
extern rtl_opt_pass *make_pass_work_around_errata (gcc::context *);
+/* Routines implemented in sparc-d.c */
+extern void sparc_d_target_versions (void);
+
#endif /* __SPARC_PROTOS_H__ */
@@ -27,6 +27,9 @@ along with GCC; see the file COPYING3. If not see
#define TARGET_CPU_CPP_BUILTINS() sparc_target_macros ()
+/* Target CPU versions for D. */
+#define TARGET_D_CPU_VERSIONS sparc_d_target_versions
+
/* Specify this in a cover file to provide bi-architecture (32/64) support. */
/* #define SPARC_BI_ARCH */
@@ -23,3 +23,7 @@ PASSES_EXTRA += $(srcdir)/config/sparc/sparc-passes.def
sparc-c.o: $(srcdir)/config/sparc/sparc-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+
+sparc-d.o: $(srcdir)/config/sparc/sparc-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
@@ -19,3 +19,7 @@
glibc-c.o: config/glibc-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+
+glibc-d.o: config/glibc-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
@@ -612,6 +612,7 @@ ISLLIBS
GMPINC
GMPLIBS
target_cpu_default
+d_target_objs
fortran_target_objs
cxx_target_objs
c_target_objs
@@ -619,6 +620,8 @@ use_gcc_stdint
xm_defines
xm_include_list
xm_file_list
+tm_d_include_list
+tm_d_file_list
tm_p_include_list
tm_p_file_list
tm_defines
@@ -11822,6 +11825,7 @@ fi
tm_file="${tm_file} defaults.h"
tm_p_file="${tm_p_file} tm-preds.h"
+tm_d_file="${tm_d_file} defaults.h"
host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
# We don't want ansidecl.h in target files, write code there in ISO/GNU C.
@@ -12194,6 +12198,21 @@ for f in $tm_p_file; do
esac
done
+tm_d_file_list=
+tm_d_include_list="options.h insn-constants.h"
+for f in $tm_d_file; do
+ case $f in
+ defaults.h )
+ tm_d_file_list="${tm_d_file_list} \$(srcdir)/$f"
+ tm_d_include_list="${tm_d_include_list} $f"
+ ;;
+ * )
+ tm_d_file_list="${tm_d_file_list} \$(srcdir)/config/$f"
+ tm_d_include_list="${tm_d_include_list} config/$f"
+ ;;
+ esac
+done
+
xm_file_list=
xm_include_list=
for f in $xm_file; do
@@ -18463,7 +18482,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 18466 "configure"
+#line 18485 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -18569,7 +18588,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 18572 "configure"
+#line 18591 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -29815,6 +29834,9 @@ fi
+
+
+
@@ -1729,6 +1729,7 @@ AC_SUBST(build_subdir)
tm_file="${tm_file} defaults.h"
tm_p_file="${tm_p_file} tm-preds.h"
+tm_d_file="${tm_d_file} defaults.h"
host_xm_file="auto-host.h ansidecl.h ${host_xm_file}"
build_xm_file="${build_auto} ansidecl.h ${build_xm_file}"
# We don't want ansidecl.h in target files, write code there in ISO/GNU C.
@@ -1954,6 +1955,21 @@ for f in $tm_p_file; do
esac
done
+tm_d_file_list=
+tm_d_include_list="options.h insn-constants.h"
+for f in $tm_d_file; do
+ case $f in
+ defaults.h )
+ tm_d_file_list="${tm_d_file_list} \$(srcdir)/$f"
+ tm_d_include_list="${tm_d_include_list} $f"
+ ;;
+ * )
+ tm_d_file_list="${tm_d_file_list} \$(srcdir)/config/$f"
+ tm_d_include_list="${tm_d_include_list} config/$f"
+ ;;
+ esac
+done
+
xm_file_list=
xm_include_list=
for f in $xm_file; do
@@ -6419,6 +6435,8 @@ AC_SUBST(tm_include_list)
AC_SUBST(tm_defines)
AC_SUBST(tm_p_file_list)
AC_SUBST(tm_p_include_list)
+AC_SUBST(tm_d_file_list)
+AC_SUBST(tm_d_include_list)
AC_SUBST(xm_file_list)
AC_SUBST(xm_include_list)
AC_SUBST(xm_defines)
@@ -6426,6 +6444,7 @@ AC_SUBST(use_gcc_stdint)
AC_SUBST(c_target_objs)
AC_SUBST(cxx_target_objs)
AC_SUBST(fortran_target_objs)
+AC_SUBST(d_target_objs)
AC_SUBST(target_cpu_default)
AC_SUBST_FILE(language_hooks)
@@ -52,6 +52,7 @@ through the macros defined in the @file{.h} file.
* MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
* PCH Target:: Validity checking for precompiled headers.
* C++ ABI:: Controlling C++ ABI changes.
+* D Language and ABI:: Controlling D ABI changes.
* Named Address Spaces:: Adding support for named address spaces
* Misc:: Everything else.
@end menu
@@ -106,6 +107,14 @@ documented as ``Common Target Hook''. This is declared in
@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
default definition is used.
+Similarly, there is a @code{targetdm} variable for hooks that are
+specific to the D language front end, documented as ``D Target Hook''.
+This is declared in @file{d/d-target.h}, the initializer
+@code{TARGETDM_INITIALIZER} in @file{d/d-target-def.h}. If targets
+initialize @code{targetdm} themselves, they should set
+@code{target_has_targetdm=yes} in @file{config.gcc}; otherwise a default
+definition is used.
+
@node Driver
@section Controlling the Compilation Driver, @file{gcc}
@cindex driver
@@ -10659,6 +10668,22 @@ unloaded. The default is to return false.
Return target-specific mangling context of @var{decl} or @code{NULL_TREE}.
@end deftypefn
+@node D Language and ABI
+@section D ABI parameters
+@cindex parameters, d abi
+
+@deftypefn {D Target Hook} void TARGET_D_CPU_VERSIONS (void)
+Declare all environmental version identifiers relating to the target CPU using the function @code{builtin_version}, which takes a string representing the name of the version. Version identifiers predefined by this hook apply to all modules and being compiled and imported.
+@end deftypefn
+
+@deftypefn {D Target Hook} void TARGET_D_OS_VERSIONS (void)
+Similarly to @code{TARGET_D_CPU_VERSIONS}, but is used for versions relating to the target operating system.
+@end deftypefn
+
+@deftypefn {D Target Hook} unsigned TARGET_D_CRITSEC_SIZE (void)
+Returns the size of the data structure used by the targeted operating system for critical sections and monitors. For example, on Microsoft Windows this would return the @code{sizeof(CRITICAL_SECTION)}, while other platforms that implement pthreads would return @code{sizeof(pthread_mutex_t)}.
+@end deftypefn
+
@node Named Address Spaces
@section Adding support for named address spaces
@cindex named address spaces
@@ -52,6 +52,7 @@ through the macros defined in the @file{.h} file.
* MIPS Coprocessors:: MIPS coprocessor support and how to customize it.
* PCH Target:: Validity checking for precompiled headers.
* C++ ABI:: Controlling C++ ABI changes.
+* D Language and ABI:: Controlling D ABI changes.
* Named Address Spaces:: Adding support for named address spaces
* Misc:: Everything else.
@end menu
@@ -106,6 +107,14 @@ documented as ``Common Target Hook''. This is declared in
@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
default definition is used.
+Similarly, there is a @code{targetdm} variable for hooks that are
+specific to the D language front end, documented as ``D Target Hook''.
+This is declared in @file{d/d-target.h}, the initializer
+@code{TARGETDM_INITIALIZER} in @file{d/d-target-def.h}. If targets
+initialize @code{targetdm} themselves, they should set
+@code{target_has_targetdm=yes} in @file{config.gcc}; otherwise a default
+definition is used.
+
@node Driver
@section Controlling the Compilation Driver, @file{gcc}
@cindex driver
@@ -7308,6 +7317,16 @@ floating-point support; they are not included in this mechanism.
@hook TARGET_CXX_DECL_MANGLING_CONTEXT
+@node D Language and ABI
+@section D ABI parameters
+@cindex parameters, d abi
+
+@hook TARGET_D_CPU_VERSIONS
+
+@hook TARGET_D_OS_VERSIONS
+
+@hook TARGET_D_CRITSEC_SIZE
+
@node Named Address Spaces
@section Adding support for named address spaces
@cindex named address spaces
@@ -34,6 +34,7 @@ static struct hook_desc hook_array[] = {
#include "target.def"
#include "c-family/c-target.def"
#include "common/common-target.def"
+#include "d/d-target.def"
#undef DEFHOOK
};
--
2.17.1