aboutsummaryrefslogtreecommitdiff
path: root/gcc/config
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gcc.gnu.org>2018-10-28 19:51:47 +0000
committerIain Buclaw <ibuclaw@gcc.gnu.org>2018-10-28 19:51:47 +0000
commitb4c522fabd0df7be08882d2207df8b2765026110 (patch)
treeb5ffc312b0a441c1ba24323152aec463fdbe5e9f /gcc/config
parent01ce9e31a02c8039d88e90f983735104417bf034 (diff)
downloadgcc-b4c522fabd0df7be08882d2207df8b2765026110.zip
gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.gz
gcc-b4c522fabd0df7be08882d2207df8b2765026110.tar.bz2
Add D front-end, libphobos library, and D2 testsuite.
ChangeLog: * Makefile.def (target_modules): Add libphobos. (flags_to_pass): Add GDC, GDCFLAGS, GDC_FOR_TARGET and GDCFLAGS_FOR_TARGET. (dependencies): Make libphobos depend on libatomic, libbacktrace configure, and zlib configure. (language): Add language d. * Makefile.in: Rebuild. * Makefile.tpl (BUILD_EXPORTS): Add GDC and GDCFLAGS. (HOST_EXPORTS): Add GDC. (POSTSTAGE1_HOST_EXPORTS): Add GDC and GDC_FOR_BUILD. (BASE_TARGET_EXPORTS): Add GDC. (GDC_FOR_BUILD, GDC, GDCFLAGS): New variables. (GDC_FOR_TARGET, GDC_FLAGS_FOR_TARGET): New variables. (EXTRA_HOST_FLAGS): Add GDC. (STAGE1_FLAGS_TO_PASS): Add GDC. (EXTRA_TARGET_FLAGS): Add GDC and GDCFLAGS. * config-ml.in: Treat GDC and GDCFLAGS like other compiler/flag environment variables. * configure: Rebuild. * configure.ac: Add target-libphobos to target_libraries. Set and substitute GDC_FOR_BUILD and GDC_FOR_TARGET. config/ChangeLog: * multi.m4: Set GDC. gcc/ChangeLog: * Makefile.in (tm_d_file_list, tm_d_include_list): New variables. (TM_D_H, D_TARGET_DEF, D_TARGET_H, D_TARGET_OBJS): New variables. (tm_d.h, cs-tm_d.h, default-d.o): New rules. (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. * 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): Define. (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.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * 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/rs6000.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * config/rs6000/rs6000.h (TARGET_D_CPU_VERSIONS): Define. * 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. * configure: Regenerated. * configure.ac (tm_d_file): New variable. (tm_d_file_list, tm_d_include_list, d_target_objs): Add substitutes. * doc/contrib.texi (Contributors): Add self for the D frontend. * doc/frontends.texi (G++ and GCC): Mention D as a supported language. * doc/install.texi (Configuration): Mention libphobos as an option for --enable-shared. Mention d as an option for --enable-languages. (Testing): Mention check-d as a target. * doc/invoke.texi (Overall Options): Mention .d, .dd, and .di as file name suffixes. Mention d as a -x option. * doc/sourcebuild.texi (Top Level): Mention libphobos. * doc/standards.texi (Standards): Add section on D language. * doc/tm.texi: Regenerated. * doc/tm.texi.in: Add @node for D language and ABI, and @hook for TARGET_CPU_VERSIONS, TARGET_D_OS_VERSIONS, and TARGET_D_CRITSEC_SIZE. * dwarf2out.c (is_dlang): New function. (gen_compile_unit_die): Use DW_LANG_D for D. (declare_in_namespace): Return module die for D, instead of adding extra declarations into the namespace. (gen_namespace_die): Generate DW_TAG_module for D. (gen_decl_die): Handle CONST_DECLSs for D. (dwarf2out_decl): Likewise. (prune_unused_types_walk_local_classes): Handle DW_tag_interface_type. (prune_unused_types_walk): Handle DW_tag_interface_type same as other kinds of aggregates. * gcc.c (default_compilers): Add entries for .d, .dd and .di. * genhooks.c: Include d/d-target.def. gcc/po/ChangeLog: * EXCLUDES: Add sources from d/dmd. gcc/testsuite/ChangeLog: * gcc.misc-tests/help.exp: Add D to option descriptions check. * gdc.dg/asan/asan.exp: New file. * gdc.dg/asan/gdc272.d: New test. * gdc.dg/compilable.d: New test. * gdc.dg/dg.exp: New file. * gdc.dg/gdc254.d: New test. * gdc.dg/gdc260.d: New test. * gdc.dg/gdc270a.d: New test. * gdc.dg/gdc270b.d: New test. * gdc.dg/gdc282.d: New test. * gdc.dg/gdc283.d: New test. * gdc.dg/imports/gdc170.d: New test. * gdc.dg/imports/gdc231.d: New test. * gdc.dg/imports/gdc239.d: New test. * gdc.dg/imports/gdc241a.d: New test. * gdc.dg/imports/gdc241b.d: New test. * gdc.dg/imports/gdc251a.d: New test. * gdc.dg/imports/gdc251b.d: New test. * gdc.dg/imports/gdc253.d: New test. * gdc.dg/imports/gdc254a.d: New test. * gdc.dg/imports/gdc256.d: New test. * gdc.dg/imports/gdc27.d: New test. * gdc.dg/imports/gdcpkg256/package.d: New test. * gdc.dg/imports/runnable.d: New test. * gdc.dg/link.d: New test. * gdc.dg/lto/lto.exp: New file. * gdc.dg/lto/ltotests_0.d: New test. * gdc.dg/lto/ltotests_1.d: New test. * gdc.dg/runnable.d: New test. * gdc.dg/simd.d: New test. * gdc.test/gdc-test.exp: New file. * lib/gdc-dg.exp: New file. * lib/gdc.exp: New file. libphobos/ChangeLog: * Makefile.am: New file. * Makefile.in: New file. * acinclude.m4: New file. * aclocal.m4: New file. * config.h.in: New file. * configure: New file. * configure.ac: New file. * d_rules.am: New file. * libdruntime/Makefile.am: New file. * libdruntime/Makefile.in: New file. * libdruntime/__entrypoint.di: New file. * libdruntime/__main.di: New file. * libdruntime/gcc/attribute.d: New file. * libdruntime/gcc/backtrace.d: New file. * libdruntime/gcc/builtins.d: New file. * libdruntime/gcc/config.d.in: New file. * libdruntime/gcc/deh.d: New file. * libdruntime/gcc/libbacktrace.d.in: New file. * libdruntime/gcc/unwind/arm.d: New file. * libdruntime/gcc/unwind/arm_common.d: New file. * libdruntime/gcc/unwind/c6x.d: New file. * libdruntime/gcc/unwind/generic.d: New file. * libdruntime/gcc/unwind/package.d: New file. * libdruntime/gcc/unwind/pe.d: New file. * m4/autoconf.m4: New file. * m4/druntime.m4: New file. * m4/druntime/cpu.m4: New file. * m4/druntime/libraries.m4: New file. * m4/druntime/os.m4: New file. * m4/gcc_support.m4: New file. * m4/gdc.m4: New file. * m4/libtool.m4: New file. * src/Makefile.am: New file. * src/Makefile.in: New file. * src/libgphobos.spec.in: New file. * testsuite/Makefile.am: New file. * testsuite/Makefile.in: New file. * testsuite/config/default.exp: New file. * testsuite/lib/libphobos-dg.exp: New file. * testsuite/lib/libphobos.exp: New file. * testsuite/testsuite_flags.in: New file. From-SVN: r265573
Diffstat (limited to 'gcc/config')
-rw-r--r--gcc/config/aarch64/aarch64-d.c31
-rw-r--r--gcc/config/aarch64/aarch64-linux.h2
-rw-r--r--gcc/config/aarch64/aarch64-protos.h3
-rw-r--r--gcc/config/aarch64/aarch64.h3
-rw-r--r--gcc/config/aarch64/t-aarch644
-rw-r--r--gcc/config/arm/arm-d.c53
-rw-r--r--gcc/config/arm/arm-protos.h3
-rw-r--r--gcc/config/arm/arm.h3
-rw-r--r--gcc/config/arm/linux-eabi.h3
-rw-r--r--gcc/config/arm/t-arm4
-rw-r--r--gcc/config/default-d.c25
-rw-r--r--gcc/config/glibc-d.c64
-rw-r--r--gcc/config/gnu.h6
-rw-r--r--gcc/config/i386/i386-d.c44
-rw-r--r--gcc/config/i386/i386-protos.h3
-rw-r--r--gcc/config/i386/i386.h3
-rw-r--r--gcc/config/i386/linux-common.h6
-rw-r--r--gcc/config/i386/t-i3864
-rw-r--r--gcc/config/kfreebsd-gnu.h6
-rw-r--r--gcc/config/kopensolaris-gnu.h6
-rw-r--r--gcc/config/linux-android.h6
-rw-r--r--gcc/config/linux.h13
-rw-r--r--gcc/config/mips/linux-common.h3
-rw-r--r--gcc/config/mips/mips-d.c56
-rw-r--r--gcc/config/mips/mips-protos.h3
-rw-r--r--gcc/config/mips/mips.h3
-rw-r--r--gcc/config/mips/t-mips4
-rw-r--r--gcc/config/powerpcspe/linux.h13
-rw-r--r--gcc/config/powerpcspe/linux64.h13
-rw-r--r--gcc/config/powerpcspe/powerpcspe-d.c45
-rw-r--r--gcc/config/powerpcspe/powerpcspe-protos.h3
-rw-r--r--gcc/config/powerpcspe/powerpcspe.c5
-rw-r--r--gcc/config/powerpcspe/powerpcspe.h3
-rw-r--r--gcc/config/powerpcspe/t-powerpcspe4
-rw-r--r--gcc/config/riscv/riscv-d.c39
-rw-r--r--gcc/config/riscv/riscv-protos.h3
-rw-r--r--gcc/config/riscv/riscv.h3
-rw-r--r--gcc/config/riscv/t-riscv5
-rw-r--r--gcc/config/rs6000/linux.h13
-rw-r--r--gcc/config/rs6000/linux64.h13
-rw-r--r--gcc/config/rs6000/rs6000-d.c45
-rw-r--r--gcc/config/rs6000/rs6000-protos.h3
-rw-r--r--gcc/config/rs6000/rs6000.c5
-rw-r--r--gcc/config/rs6000/rs6000.h3
-rw-r--r--gcc/config/rs6000/t-rs60004
-rw-r--r--gcc/config/s390/s390-d.c41
-rw-r--r--gcc/config/s390/s390-protos.h3
-rw-r--r--gcc/config/s390/s390.h3
-rw-r--r--gcc/config/s390/t-s3904
-rw-r--r--gcc/config/sparc/sparc-d.c48
-rw-r--r--gcc/config/sparc/sparc-protos.h3
-rw-r--r--gcc/config/sparc/sparc.h3
-rw-r--r--gcc/config/sparc/t-sparc4
-rw-r--r--gcc/config/t-glibc4
54 files changed, 695 insertions, 4 deletions
diff --git a/gcc/config/aarch64/aarch64-d.c b/gcc/config/aarch64/aarch64-d.c
new file mode 100644
index 0000000..1394f1f
--- /dev/null
+++ b/gcc/config/aarch64/aarch64-d.c
@@ -0,0 +1,31 @@
+/* Subroutines for the D front end on the AArch64 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 AArch64 targets. */
+
+void
+aarch64_d_target_versions (void)
+{
+ d_add_builtin_version ("AArch64");
+ d_add_builtin_version ("D_HardFloat");
+}
diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h
index bf1327e..2bee7e5 100644
--- a/gcc/config/aarch64/aarch64-linux.h
+++ b/gcc/config/aarch64/aarch64-linux.h
@@ -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
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 5f18837..776e869 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -620,6 +620,9 @@ enum aarch64_parse_opt_result aarch64_parse_extension (const char *,
std::string aarch64_get_extension_string_for_isa_flags (unsigned long,
unsigned long);
+/* Defined in aarch64-d.c */
+extern void aarch64_d_target_versions (void);
+
rtl_opt_pass *make_pass_fma_steering (gcc::context *);
rtl_opt_pass *make_pass_track_speculation (gcc::context *);
rtl_opt_pass *make_pass_tag_collision_avoidance (gcc::context *);
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index fa9af26..0c833a8 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.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 ()
diff --git a/gcc/config/aarch64/t-aarch64 b/gcc/config/aarch64/t-aarch64
index 1576d05..e91dcce 100644
--- a/gcc/config/aarch64/t-aarch64
+++ b/gcc/config/aarch64/t-aarch64
@@ -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 \
diff --git a/gcc/config/arm/arm-d.c b/gcc/config/arm/arm-d.c
new file mode 100644
index 0000000..dbcf07e
--- /dev/null
+++ b/gcc/config/arm/arm-d.c
@@ -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");
+}
diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 0dfb3ac..cea9866 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -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
diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index 34894c0..8472312 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -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. */
diff --git a/gcc/config/arm/linux-eabi.h b/gcc/config/arm/linux-eabi.h
index 8585fde..4254b19 100644
--- a/gcc/config/arm/linux-eabi.h
+++ b/gcc/config/arm/linux-eabi.h
@@ -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. */
diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm
index c3a8c77..02b4626 100644
--- a/gcc/config/arm/t-arm
+++ b/gcc/config/arm/t-arm
@@ -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
diff --git a/gcc/config/default-d.c b/gcc/config/default-d.c
new file mode 100644
index 0000000..6c95205
--- /dev/null
+++ b/gcc/config/default-d.c
@@ -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;
diff --git a/gcc/config/glibc-d.c b/gcc/config/glibc-d.c
new file mode 100644
index 0000000..b73ee01f
--- /dev/null
+++ b/gcc/config/glibc-d.c
@@ -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;
diff --git a/gcc/config/gnu.h b/gcc/config/gnu.h
index 1cc744b..3aca4e3 100644
--- a/gcc/config/gnu.h
+++ b/gcc/config/gnu.h
@@ -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)
diff --git a/gcc/config/i386/i386-d.c b/gcc/config/i386/i386-d.c
new file mode 100644
index 0000000..34304b8
--- /dev/null
+++ b/gcc/config/i386/i386-d.c
@@ -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");
+}
diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h
index d1d5963..258bdd1 100644
--- a/gcc/config/i386/i386-protos.h
+++ b/gcc/config/i386/i386-protos.h
@@ -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);
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index b0d2f24..01d49a7 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -718,6 +718,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
diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h
index 3eeb66c..1e7a055 100644
--- a/gcc/config/i386/linux-common.h
+++ b/gcc/config/i386/linux-common.h
@@ -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, \
diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
index 8a5808c..261739e 100644
--- a/gcc/config/i386/t-i386
+++ b/gcc/config/i386/t-i386
@@ -40,6 +40,10 @@ x86-tune-sched-core.o: $(srcdir)/config/i386/x86-tune-sched-core.c
$(COMPILE) $<
$(POSTCOMPILE)
+i386-d.o: $(srcdir)/config/i386/i386-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
i386.o: i386-builtin-types.inc
i386-builtin-types.inc: s-i386-bt ; @true
diff --git a/gcc/config/kfreebsd-gnu.h b/gcc/config/kfreebsd-gnu.h
index aaeea44..923e7e4 100644
--- a/gcc/config/kfreebsd-gnu.h
+++ b/gcc/config/kfreebsd-gnu.h
@@ -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
diff --git a/gcc/config/kopensolaris-gnu.h b/gcc/config/kopensolaris-gnu.h
index 541f749..4b303cc 100644
--- a/gcc/config/kopensolaris-gnu.h
+++ b/gcc/config/kopensolaris-gnu.h
@@ -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"
diff --git a/gcc/config/linux-android.h b/gcc/config/linux-android.h
index 9f3985d..40da4c17 100644
--- a/gcc/config/linux-android.h
+++ b/gcc/config/linux-android.h
@@ -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
diff --git a/gcc/config/linux.h b/gcc/config/linux.h
index 2ea4ff9..0255359 100644
--- a/gcc/config/linux.h
+++ b/gcc/config/linux.h
@@ -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
diff --git a/gcc/config/mips/linux-common.h b/gcc/config/mips/linux-common.h
index 570151f..da9be6b 100644
--- a/gcc/config/mips/linux-common.h
+++ b/gcc/config/mips/linux-common.h
@@ -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, \
diff --git a/gcc/config/mips/mips-d.c b/gcc/config/mips/mips-d.c
new file mode 100644
index 0000000..8f0d967
--- /dev/null
+++ b/gcc/config/mips/mips-d.c
@@ -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");
+ }
+}
diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h
index d9d6e92..099120d 100644
--- a/gcc/config/mips/mips-protos.h
+++ b/gcc/config/mips/mips-protos.h
@@ -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 */
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index 6804b79..32a88ed 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.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
diff --git a/gcc/config/mips/t-mips b/gcc/config/mips/t-mips
index 7bdf83c..0466ba2 100644
--- a/gcc/config/mips/t-mips
+++ b/gcc/config/mips/t-mips
@@ -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)
diff --git a/gcc/config/powerpcspe/linux.h b/gcc/config/powerpcspe/linux.h
index c899f9d..fe755ef 100644
--- a/gcc/config/powerpcspe/linux.h
+++ b/gcc/config/powerpcspe/linux.h
@@ -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)"
diff --git a/gcc/config/powerpcspe/linux64.h b/gcc/config/powerpcspe/linux64.h
index b3a0cc4..f0e3f09 100644
--- a/gcc/config/powerpcspe/linux64.h
+++ b/gcc/config/powerpcspe/linux64.h
@@ -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)"
diff --git a/gcc/config/powerpcspe/powerpcspe-d.c b/gcc/config/powerpcspe/powerpcspe-d.c
new file mode 100644
index 0000000..84eb4e9
--- /dev/null
+++ b/gcc/config/powerpcspe/powerpcspe-d.c
@@ -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");
+ }
+}
diff --git a/gcc/config/powerpcspe/powerpcspe-protos.h b/gcc/config/powerpcspe/powerpcspe-protos.h
index 8ff9f4b..575a3ed 100644
--- a/gcc/config/powerpcspe/powerpcspe-protos.h
+++ b/gcc/config/powerpcspe/powerpcspe-protos.h
@@ -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
diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c
index 90170c3..b05b89c 100644
--- a/gcc/config/powerpcspe/powerpcspe.c
+++ b/gcc/config/powerpcspe/powerpcspe.c
@@ -31965,11 +31965,12 @@ rs6000_output_function_epilogue (FILE *file)
use language_string.
C is 0. Fortran is 1. Ada is 3. C++ is 9.
Java is 13. Objective-C is 14. Objective-C++ isn't assigned
- a number, so for now use 9. LTO, Go and JIT aren't assigned numbers
- either, so for now use 0. */
+ a number, so for now use 9. LTO, Go, D and JIT aren't assigned
+ numbers either, so for now use 0. */
if (lang_GNU_C ()
|| ! strcmp (language_string, "GNU GIMPLE")
|| ! strcmp (language_string, "GNU Go")
+ || ! strcmp (language_string, "GNU D")
|| ! strcmp (language_string, "libgccjit"))
i = 0;
else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/config/powerpcspe/powerpcspe.h b/gcc/config/powerpcspe/powerpcspe.h
index df0676a..2305ce3 100644
--- a/gcc/config/powerpcspe/powerpcspe.h
+++ b/gcc/config/powerpcspe/powerpcspe.h
@@ -702,6 +702,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() \
diff --git a/gcc/config/powerpcspe/t-powerpcspe b/gcc/config/powerpcspe/t-powerpcspe
index 460dd5d..e67c21c 100644
--- a/gcc/config/powerpcspe/t-powerpcspe
+++ b/gcc/config/powerpcspe/t-powerpcspe
@@ -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 > \
diff --git a/gcc/config/riscv/riscv-d.c b/gcc/config/riscv/riscv-d.c
new file mode 100644
index 0000000..9cad9dd
--- /dev/null
+++ b/gcc/config/riscv/riscv-d.c
@@ -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");
+}
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index f158ed0..5dce9c4 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -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);
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h
index 3c9f96d..13e15cc 100644
--- a/gcc/config/riscv/riscv.h
+++ b/gcc/config/riscv/riscv.h
@@ -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
diff --git a/gcc/config/riscv/t-riscv b/gcc/config/riscv/t-riscv
index 0765b49..ece3a75 100644
--- a/gcc/config/riscv/t-riscv
+++ b/gcc/config/riscv/t-riscv
@@ -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)
+
diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h
index 01b40c7..fd06b14 100644
--- a/gcc/config/rs6000/linux.h
+++ b/gcc/config/rs6000/linux.h
@@ -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)"
diff --git a/gcc/config/rs6000/linux64.h b/gcc/config/rs6000/linux64.h
index 44eab40..e6b4fd2 100644
--- a/gcc/config/rs6000/linux64.h
+++ b/gcc/config/rs6000/linux64.h
@@ -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)"
diff --git a/gcc/config/rs6000/rs6000-d.c b/gcc/config/rs6000/rs6000-d.c
new file mode 100644
index 0000000..84eb4e9
--- /dev/null
+++ b/gcc/config/rs6000/rs6000-d.c
@@ -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");
+ }
+}
diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index f1d5dff..bb2584b 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -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
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 726038e..a9d0388 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -28633,11 +28633,12 @@ rs6000_output_function_epilogue (FILE *file)
use language_string.
C is 0. Fortran is 1. Ada is 3. C++ is 9.
Java is 13. Objective-C is 14. Objective-C++ isn't assigned
- a number, so for now use 9. LTO, Go and JIT aren't assigned numbers
- either, so for now use 0. */
+ a number, so for now use 9. LTO, Go, D, and JIT aren't assigned
+ numbers either, so for now use 0. */
if (lang_GNU_C ()
|| ! strcmp (language_string, "GNU GIMPLE")
|| ! strcmp (language_string, "GNU Go")
+ || ! strcmp (language_string, "GNU D")
|| ! strcmp (language_string, "libgccjit"))
i = 0;
else if (! strcmp (language_string, "GNU F77")
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 4ab027c..f59c0b6 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -613,6 +613,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() \
diff --git a/gcc/config/rs6000/t-rs6000 b/gcc/config/rs6000/t-rs6000
index ad274d9..d9249b0 100644
--- a/gcc/config/rs6000/t-rs6000
+++ b/gcc/config/rs6000/t-rs6000
@@ -35,6 +35,10 @@ rs6000-p8swap.o: $(srcdir)/config/rs6000/rs6000-p8swap.c
$(COMPILE) $<
$(POSTCOMPILE)
+rs6000-d.o: $(srcdir)/config/rs6000/rs6000-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+
$(srcdir)/config/rs6000/rs6000-tables.opt: $(srcdir)/config/rs6000/genopt.sh \
$(srcdir)/config/rs6000/rs6000-cpus.def
$(SHELL) $(srcdir)/config/rs6000/genopt.sh $(srcdir)/config/rs6000 > \
diff --git a/gcc/config/s390/s390-d.c b/gcc/config/s390/s390-d.c
new file mode 100644
index 0000000..1ea0a9d
--- /dev/null
+++ b/gcc/config/s390/s390-d.c
@@ -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");
+}
diff --git a/gcc/config/s390/s390-protos.h b/gcc/config/s390/s390-protos.h
index 45fce6c..96fa705 100644
--- a/gcc/config/s390/s390-protos.h
+++ b/gcc/config/s390/s390-protos.h
@@ -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);
+/* s390-d.c routines */
+extern void s390_d_target_versions (void);
+
/* Pass management. */
namespace gcc { class context; }
class rtl_opt_pass;
diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h
index bf40b4c..3cfd345 100644
--- a/gcc/config/s390/s390.h
+++ b/gcc/config/s390/s390.h
@@ -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)
diff --git a/gcc/config/s390/t-s390 b/gcc/config/s390/t-s390
index 8ca0c78..97e6bf7 100644
--- a/gcc/config/s390/t-s390
+++ b/gcc/config/s390/t-s390
@@ -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)
diff --git a/gcc/config/sparc/sparc-d.c b/gcc/config/sparc/sparc-d.c
new file mode 100644
index 0000000..19fe5be
--- /dev/null
+++ b/gcc/config/sparc/sparc-d.c
@@ -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");
+ }
+}
diff --git a/gcc/config/sparc/sparc-protos.h b/gcc/config/sparc/sparc-protos.h
index 12613db..59c9b2a 100644
--- a/gcc/config/sparc/sparc-protos.h
+++ b/gcc/config/sparc/sparc-protos.h
@@ -111,4 +111,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__ */
diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h
index 520a6b3..8c15e2a 100644
--- a/gcc/config/sparc/sparc.h
+++ b/gcc/config/sparc/sparc.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 */
diff --git a/gcc/config/sparc/t-sparc b/gcc/config/sparc/t-sparc
index 7fb3029..30f15c9 100644
--- a/gcc/config/sparc/t-sparc
+++ b/gcc/config/sparc/t-sparc
@@ -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)
diff --git a/gcc/config/t-glibc b/gcc/config/t-glibc
index 582215f..29d7086 100644
--- a/gcc/config/t-glibc
+++ b/gcc/config/t-glibc
@@ -19,3 +19,7 @@
glibc-c.o: config/glibc-c.c
$(COMPILE) $<
$(POSTCOMPILE)
+
+glibc-d.o: config/glibc-d.c
+ $(COMPILE) $<
+ $(POSTCOMPILE)