From patchwork Sun May 28 21:15:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 767967 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wbXkJ3VJVz9s2Q for ; Mon, 29 May 2017 07:16:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="whGKkSxb"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=AUSQqvdDXaYjy51rfL0p4TQguvXJLmATKdSM8YF0gVf+1K B6OsbQs5LbgMXyzjfYlzXfe9WfncZEBYFM8mswaf+Ihg3p+4L9mAZdSOhCRGXEgC boi2M7GQSsP8TAPvCyKkaPlyhG6TsaXVSK7JOlFiPxsj6rfkfIkwgBGb4yek0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=oW9aOc40rbPIBrZD1AkbsB8ALh8=; b=whGKkSxb1RzAD3Gr5D4L XWTzX6n+GeD0urmFPW6hBMoFSXNWM1IVV7EZZDvJ5kv0OMYX33FPJs6bc882K6oz gPpGWIpIplLCMbcAVgb1M3LuyekYXhx9AHD9QlKSlCrZdTVJ6zUi/iuzn/CHYjvr DdJjB9QRkpmsHZxEoWwgWqQ= Received: (qmail 73764 invoked by alias); 28 May 2017 21:15:54 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 67618 invoked by uid 89); 28 May 2017 21:15:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=scheduled X-HELO: mail-ua0-f177.google.com Received: from mail-ua0-f177.google.com (HELO mail-ua0-f177.google.com) (209.85.217.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 28 May 2017 21:15:34 +0000 Received: by mail-ua0-f177.google.com with SMTP id e28so27347400uah.0 for ; Sun, 28 May 2017 14:15:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=5RFgvBt4/GNLUXbMBkGylhFMiqaj2I0OOq7aMHPAZBY=; b=Xdnli3MLXsRGEWWA9jqPj6lKahYi7xmYg0384NSTdf3pLTQR2WjIIjEQZ05/eNSyTH 4kZHhv/LHSZWVSpzmBICDdKBSS1g/8kex/Ijmjy94tJR+RwL082M2jVRctxYoLQcmsKy /MlcS+96mpM3x1KPexqxn4yofgN/TwdIgJAZnX0OFGYKc/40mhLcng4fAgGcClk4awzq yn3SOCO84Y7+YA0fycHQzMK/KV8HoNqBnrtW/ntbnF55t0qDgLPJsIPtKef0H7v2IhCR mhhAzwdewheeRIgaaOgwAdOL0ZEfAAPGlegJOhXAltNwAae1UG74QZid4rNmdbQ1QXi4 PjZw== X-Gm-Message-State: AODbwcCNplNB8Kxupa/CYGn0ZGN8JW+v9qpvSr/slfs2VrbCVxZqKkDA mpsix07ENvdGR8w+BL5TnBO1n6YmiVaF X-Received: by 10.159.48.81 with SMTP id i17mr6371508uab.144.1496006130092; Sun, 28 May 2017 14:15:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.96.201 with HTTP; Sun, 28 May 2017 14:15:29 -0700 (PDT) From: Iain Buclaw Date: Sun, 28 May 2017 23:15:29 +0200 Message-ID: Subject: [PATCH 7/13] D: Add D language support to GCC targets. To: gcc-patches X-IsSubscribed: yes This patch add D language support to targets of GCC itself. These are 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. [PATCH 7/13] D: Add D language support to GCC targets. This patch add D language support to targets of GCC itself. These are 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. --- gcc/ChangeLog: * config/aarch64/aarch64.h (TARGET_CPU_D_BUILTINS): Define. * config/alpha/alpha.h (TARGET_CPU_D_BUILTINS): Define. * config/alpha/linux.h (TARGET_OS_D_BUILTINS): Define. * config/arm/arm.h (TARGET_CPU_D_BUILTINS): Define. * config/arm/linux-eabi.h (TARGET_OS_D_BUILTINS): Define. * config/darwin.h (TARGET_OS_D_BUILTINS): Define. * config/freebsd.h (TARGET_OS_D_BUILTINS): Define. * config/gnu.h (TARGET_OS_D_BUILTINS): Define. * config/i386/cygwin.h (TARGET_OS_D_BUILTINS): Define. * config/i386/i386.h (TARGET_CPU_D_BUILTINS): Define. * config/i386/linux-common.h (TARGET_OS_D_BUILTINS): Define. * config/i386/mingw32.h (TARGET_OS_D_BUILTINS): Define. (TARGET_GENERIC_MINGW_OS_D_BUILTINS): Define. * config/ia64/ia64.h (TARGET_CPU_D_BUILTINS): Define. * config/kfreebsd-gnu.h (TARGET_OS_D_BUILTINS): Define. * config/kopernsolaris-gnu.h (TARGET_OS_D_BUILTINS): Define. * config/linux-android.h (ANDROID_TARGET_OS_D_BUILTINS): Define. * config/linux.h (TARGET_OS_D_BUILTINS): Define. (TARGET_GENERIC_LINUX_OS_D_BUILTINS): Define. * config/mips/linux-common.h (TARGET_OS_D_BUILTINS): Define. * config/mips/mips.h (TARGET_CPU_D_BUILTINS): Define. * config/netbsd.h (TARGET_OS_D_BUILTINS): Define. * config/openbsd.h (TARGET_OS_D_BUILTINS): Define. * config/pa.h (TARGET_CPU_D_BUILTINS): Define. * config/rs6000/aix.h (TARGET_OS_D_BUILTINS): Define. * config/rs6000/linux.h (TARGET_OS_D_BUILTINS): Define. * config/rs6000/linux64.h (TARGET_OS_D_BUILTINS): Define. * config/rs6000/rs6000.h (TARGET_CPU_D_BUILTINS): Define. * config/s390/s390.h (TARGET_CPU_D_BUILTINS): Define. * config/sh/sh.h (TARGET_CPU_D_BUILTINS): Define. * config/sparc/sparc.h (TARGET_CPU_D_BUILTINS): Define. diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index e4fb96fd037..00eef196000 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -26,6 +26,14 @@ #define TARGET_CPU_CPP_BUILTINS() \ aarch64_cpu_cpp_builtins (pfile) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + builtin_define ("AArch64"); \ + builtin_define ("D_HardFloat"); \ + } while (0) + #define REGISTER_TARGET_PRAGMAS() aarch64_register_pragmas () diff --git a/gcc/config/alpha/alpha.h b/gcc/config/alpha/alpha.h index 460e83715d9..2fba4741ba4 100644 --- a/gcc/config/alpha/alpha.h +++ b/gcc/config/alpha/alpha.h @@ -72,6 +72,23 @@ along with GCC; see the file COPYING3. If not see SUBTARGET_LANGUAGE_CPP_BUILTINS(); \ } while (0) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + builtin_define ("Alpha"); \ + if (TARGET_SOFT_FP) \ + { \ + builtin_define ("D_SoftFloat"); \ + builtin_define ("Alpha_SoftFloat"); \ + } \ + else \ + { \ + builtin_define ("D_HardFloat"); \ + builtin_define ("Alpha_HardFloat"); \ + } \ +} while (0) + #ifndef SUBTARGET_LANGUAGE_CPP_BUILTINS #define SUBTARGET_LANGUAGE_CPP_BUILTINS() \ do \ diff --git a/gcc/config/alpha/linux.h b/gcc/config/alpha/linux.h index e15013eb96a..413de60d7f0 100644 --- a/gcc/config/alpha/linux.h +++ b/gcc/config/alpha/linux.h @@ -33,6 +33,16 @@ along with GCC; see the file COPYING3. If not see builtin_define ("_GNU_SOURCE"); \ } while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do { \ + if (OPTION_GLIBC) \ + builtin_define ("GNU_GLibc"); \ + \ + builtin_define ("linux"); \ + builtin_define ("Posix"); \ + } while (0) + #undef LIB_SPEC #define LIB_SPEC \ "%{pthread:-lpthread} \ diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 275004af938..86307fb3a4b 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -47,6 +47,31 @@ extern char arm_arch_name[]; /* Target CPU builtins. */ #define TARGET_CPU_CPP_BUILTINS() arm_cpu_cpp_builtins (pfile) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + builtin_define ("ARM"); \ + \ + if (TARGET_THUMB || TARGET_THUMB2) \ + builtin_define ("ARM_Thumb"); \ + \ + if (TARGET_HARD_FLOAT_ABI) \ + builtin_define ("ARM_HardFloat"); \ + else \ + { \ + if(TARGET_SOFT_FLOAT) \ + builtin_define ("ARM_SoftFloat"); \ + else if(TARGET_HARD_FLOAT) \ + builtin_define ("ARM_SoftFP"); \ + } \ + \ + if(TARGET_SOFT_FLOAT) \ + builtin_define ("D_SoftFloat"); \ + else if(TARGET_HARD_FLOAT) \ + builtin_define ("D_HardFloat"); \ + } while (0) + #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 a08cfb34377..07c995a9589 100644 --- a/gcc/config/arm/linux-eabi.h +++ b/gcc/config/arm/linux-eabi.h @@ -30,6 +30,15 @@ } \ while (false) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \ + ANDROID_TARGET_OS_D_BUILTINS(); \ + } \ + while (false) + /* 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/darwin.h b/gcc/config/darwin.h index a8397cd2331..e628c69c98d 100644 --- a/gcc/config/darwin.h +++ b/gcc/config/darwin.h @@ -968,4 +968,10 @@ extern void darwin_driver_init (unsigned int *,struct cl_decoded_option **); #define DEF_LD64 LD64_VERSION #endif +#define TARGET_OS_D_BUILTINS() \ + do { \ + builtin_define ("OSX"); \ + builtin_define ("Posix"); \ + } while (0) + #endif /* CONFIG_DARWIN_H */ diff --git a/gcc/config/freebsd.h b/gcc/config/freebsd.h index a2724556925..a4070e851cd 100644 --- a/gcc/config/freebsd.h +++ b/gcc/config/freebsd.h @@ -32,6 +32,13 @@ along with GCC; see the file COPYING3. If not see #undef TARGET_OS_CPP_BUILTINS #define TARGET_OS_CPP_BUILTINS() FBSD_TARGET_OS_CPP_BUILTINS() +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do { \ + builtin_define ("FreeBSD"); \ + builtin_define ("Posix"); \ + } while (0) + #undef CPP_SPEC #define CPP_SPEC FBSD_CPP_SPEC diff --git a/gcc/config/gnu.h b/gcc/config/gnu.h index 42be8952337..3fad9bbc064 100644 --- a/gcc/config/gnu.h +++ b/gcc/config/gnu.h @@ -31,3 +31,11 @@ along with GCC. If not, see . builtin_assert ("system=unix"); \ builtin_assert ("system=posix"); \ } while (0) + +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do { \ + \ + builtin_define ("Hurd"); \ + builtin_define ("Posix"); \ + } while (0) diff --git a/gcc/config/i386/cygwin.h b/gcc/config/i386/cygwin.h index a4683b4662e..c0362537360 100644 --- a/gcc/config/i386/cygwin.h +++ b/gcc/config/i386/cygwin.h @@ -29,6 +29,13 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define TARGET_OS_D_BUILTINS() \ + do { \ + builtin_define ("Windows"); \ + builtin_define ("Cygwin"); \ + builtin_define ("Posix"); \ + } while (0) + #undef CPP_SPEC #define CPP_SPEC "%(cpp_cpu) %{posix:-D_POSIX_SOURCE} \ %{!ansi:-Dunix} \ diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 5366f1fc88f..b2bf3f7c83e 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -669,6 +669,24 @@ extern const char *host_detect_local_cpu (int argc, const char **argv); /* Target CPU builtins. */ #define TARGET_CPU_CPP_BUILTINS() ix86_target_macros () +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do { \ + if (TARGET_64BIT) \ + { \ + builtin_define("X86_64"); \ + if (TARGET_X32) \ + builtin_define("D_X32"); \ + } \ + else \ + builtin_define("X86"); \ + \ + if (TARGET_80387) \ + builtin_define("D_HardFloat"); \ + else \ + builtin_define("D_SoftFloat"); \ + } while (0) + /* Target Pragmas. */ #define REGISTER_TARGET_PRAGMAS() ix86_register_pragmas () diff --git a/gcc/config/i386/linux-common.h b/gcc/config/i386/linux-common.h index 6380639b204..d80b216da21 100644 --- a/gcc/config/i386/linux-common.h +++ b/gcc/config/i386/linux-common.h @@ -27,6 +27,15 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \ + ANDROID_TARGET_OS_D_BUILTINS(); \ + } \ + while (0) + #undef CC1_SPEC #define CC1_SPEC \ LINUX_OR_ANDROID_CC (GNU_USER_TARGET_CC1_SPEC, \ diff --git a/gcc/config/i386/mingw-w64.h b/gcc/config/i386/mingw-w64.h index 270ec0dd037..e4c80a4c485 100644 --- a/gcc/config/i386/mingw-w64.h +++ b/gcc/config/i386/mingw-w64.h @@ -89,3 +89,10 @@ along with GCC; see the file COPYING3. If not see %{static:-Bstatic} %{!static:-Bdynamic} \ %{shared|mdll: " SUB_LINK_ENTRY " --enable-auto-image-base} \ %(shared_libgcc_undefs)" + +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do { \ + TARGET_GENERIC_MINGW_OS_D_BUILTINS(); \ + builtin_define ("GNU_MinGW64"); \ + } while (0) diff --git a/gcc/config/i386/mingw32.h b/gcc/config/i386/mingw32.h index 5f36909a8bf..12c383f862d 100644 --- a/gcc/config/i386/mingw32.h +++ b/gcc/config/i386/mingw32.h @@ -53,6 +53,18 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define TARGET_OS_D_BUILTINS() TARGET_GENERIC_MINGW_OS_D_BUILTINS() +#define TARGET_GENERIC_MINGW_OS_D_BUILTINS() \ + do { \ + builtin_define ("Windows"); \ + builtin_define ("MinGW"); \ + \ + if (TARGET_64BIT && ix86_abi == MS_ABI) \ + builtin_define ("Win64"); \ + else if (!TARGET_64BIT) \ + builtin_define ("Win32"); \ + } while (0) + #ifndef TARGET_USE_PTHREAD_BY_DEFAULT #define SPEC_PTHREAD1 "pthread" #define SPEC_PTHREAD2 "!no-pthread" diff --git a/gcc/config/ia64/ia64.h b/gcc/config/ia64/ia64.h index 8e68a740e31..9bd1aaa314f 100644 --- a/gcc/config/ia64/ia64.h +++ b/gcc/config/ia64/ia64.h @@ -40,6 +40,13 @@ do { \ builtin_define("__BIG_ENDIAN__"); \ } while (0) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ +do { \ + builtin_define ("IA64"); \ + builtin_define ("D_HardFloat"); \ +} while (0) + #ifndef SUBTARGET_EXTRA_SPECS #define SUBTARGET_EXTRA_SPECS #endif diff --git a/gcc/config/kfreebsd-gnu.h b/gcc/config/kfreebsd-gnu.h index 26a8cef8753..251fcd18f8d 100644 --- a/gcc/config/kfreebsd-gnu.h +++ b/gcc/config/kfreebsd-gnu.h @@ -29,6 +29,14 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do { \ + builtin_define ("FreeBSD"); \ + builtin_define ("Posix"); \ + builtin_define ("GNU_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 67150eb0cba..d3d7b5e1ba3 100644 --- a/gcc/config/kopensolaris-gnu.h +++ b/gcc/config/kopensolaris-gnu.h @@ -30,5 +30,15 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + builtin_define ("Solaris"); \ + builtin_define ("Posix"); \ + builtin_define ("GNU_OpenSolaris"); \ + builtin_define ("GNU_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 19c55c3a5c7..b62118f9700 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_OS_D_BUILTINS() \ + do { \ + if (TARGET_ANDROID) \ + builtin_define ("Android"); \ + } while (0) + #if ANDROID_DEFAULT # define NOANDROID "mno-android" #else diff --git a/gcc/config/linux.h b/gcc/config/linux.h index b3a9e85e77f..518644b1c1a 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -53,6 +53,28 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see builtin_assert ("system=posix"); \ } while (0) +#define TARGET_OS_D_BUILTINS() TARGET_GENERIC_LINUX_OS_D_BUILTINS() +#define TARGET_GENERIC_LINUX_OS_D_BUILTINS() \ + do { \ + if (OPTION_GLIBC) \ + { \ + builtin_define ("GNU_GLibc"); \ + builtin_define ("CRuntime_Glibc"); \ + } \ + else if (OPTION_UCLIBC) \ + { \ + builtin_define ("GNU_UCLibc"); \ + } \ + else if (OPTION_BIONIC) \ + { \ + builtin_define ("GNU_Bionic"); \ + builtin_define ("CRuntime_Bionic"); \ + } \ + \ + builtin_define ("linux"); \ + builtin_define ("Posix"); \ + } 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 6c8fda7184e..aece8fc7fb0 100644 --- a/gcc/config/mips/linux-common.h +++ b/gcc/config/mips/linux-common.h @@ -27,6 +27,15 @@ along with GCC; see the file COPYING3. If not see ANDROID_TARGET_OS_CPP_BUILTINS(); \ } while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + TARGET_GENERIC_LINUX_OS_D_BUILTINS(); \ + ANDROID_TARGET_OS_D_BUILTINS(); \ + } \ + while (0) + #undef LINK_SPEC #define LINK_SPEC \ LINUX_OR_ANDROID_LD (GNU_USER_TARGET_LINK_SPEC, \ diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index 23e1672b586..a8a1e94e3f1 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -644,6 +644,54 @@ struct mips_cpu_info { } \ while (0) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + if (TARGET_64BIT) \ + builtin_define("MIPS64"); \ + else \ + builtin_define("MIPS32"); \ + \ + switch (mips_abi) \ + { \ + case ABI_32: \ + builtin_define("MIPS_O32"); \ + break; \ + \ + case ABI_O64: \ + builtin_define("MIPS_O64"); \ + break; \ + \ + case ABI_N32: \ + builtin_define("MIPS_N32"); \ + break; \ + \ + case ABI_64: \ + builtin_define("MIPS_N64"); \ + break; \ + \ + case ABI_EABI: \ + builtin_define("MIPS_EABI"); \ + break; \ + \ + default: \ + gcc_unreachable(); \ + } \ + \ + if (TARGET_HARD_FLOAT_ABI) \ + { \ + builtin_define("MIPS_HardFloat"); \ + builtin_define("D_HardFloat"); \ + } \ + else if (TARGET_SOFT_FLOAT_ABI) \ + { \ + builtin_define("MIPS_SoftFloat"); \ + builtin_define("D_SoftFloat"); \ + } \ + } \ + while (0) + /* Default target_flags if no switches are specified */ #ifndef TARGET_DEFAULT diff --git a/gcc/config/netbsd.h b/gcc/config/netbsd.h index 4001f240d58..fd631dc77c0 100644 --- a/gcc/config/netbsd.h +++ b/gcc/config/netbsd.h @@ -29,6 +29,14 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + builtin_define ("NetBSD"); \ + builtin_define ("Posix"); \ + } \ + while (0) + /* CPP_SPEC parts common to all NetBSD targets. */ #define NETBSD_CPP_SPEC \ "%{posix:-D_POSIX_SOURCE} \ diff --git a/gcc/config/openbsd.h b/gcc/config/openbsd.h index 1048e31f77f..8500f555752 100644 --- a/gcc/config/openbsd.h +++ b/gcc/config/openbsd.h @@ -84,6 +84,14 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + builtin_define ("OpenBSD"); \ + builtin_define ("Posix"); \ + } \ + while (0) + /* TARGET_OS_CPP_BUILTINS() common to all OpenBSD ELF targets. */ #define OPENBSD_OS_CPP_BUILTINS_ELF() \ do \ diff --git a/gcc/config/pa/pa.h b/gcc/config/pa/pa.h index 65df53e54b0..a822fc0a507 100644 --- a/gcc/config/pa/pa.h +++ b/gcc/config/pa/pa.h @@ -179,6 +179,20 @@ do { \ builtin_define("_PA_RISC1_0"); \ } while (0) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ +do { \ + if(TARGET_64BIT) \ + builtin_define("HPPA64"); \ + else \ + builtin_define("HPPA"); \ + \ + if(TARGET_SOFT_FLOAT) \ + builtin_define ("D_SoftFloat"); \ + else \ + builtin_define ("D_HardFloat"); \ +} while (0) + /* An old set of OS defines for various BSD-like systems. */ #define TARGET_OS_CPP_BUILTINS() \ do \ diff --git a/gcc/config/rs6000/aix.h b/gcc/config/rs6000/aix.h index b90e2b06519..d95a01a1585 100644 --- a/gcc/config/rs6000/aix.h +++ b/gcc/config/rs6000/aix.h @@ -164,6 +164,13 @@ } \ while (0) +#define TARGET_OS_D_BUILTINS() \ + do { \ + \ + builtin_define ("AIX"); \ + builtin_define ("Posix"); \ + } while (0) + /* Define appropriate architecture macros for preprocessor depending on target switches. */ diff --git a/gcc/config/rs6000/linux.h b/gcc/config/rs6000/linux.h index 684afd6c190..745fc4d869b 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -57,6 +57,17 @@ } \ while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + builtin_define ("linux"); \ + builtin_define ("Posix"); \ + if (OPTION_GLIBC) \ + builtin_define ("GNU_GLibc"); \ + } \ + 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 71e35b709ad..98fd95d430c 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -391,6 +391,17 @@ extern int dot_symbols; } \ while (0) +#undef TARGET_OS_D_BUILTINS +#define TARGET_OS_D_BUILTINS() \ + do \ + { \ + builtin_define ("linux"); \ + builtin_define ("Posix"); \ + if (OPTION_GLIBC) \ + builtin_define ("GNU_GLibc"); \ + } \ + while (0) + #undef CPP_OS_DEFAULT_SPEC #define CPP_OS_DEFAULT_SPEC "%(cpp_os_linux) %(include_extra)" diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h index c4e98dd2f13..0234ef40def 100644 --- a/gcc/config/rs6000/rs6000.h +++ b/gcc/config/rs6000/rs6000.h @@ -822,6 +822,28 @@ extern unsigned char rs6000_recip_bits[]; #define TARGET_CPU_CPP_BUILTINS() \ rs6000_cpu_cpp_builtins (pfile) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + if (TARGET_64BIT) \ + builtin_define ("PPC64"); \ + else \ + builtin_define ("PPC"); \ + \ + if (TARGET_HARD_FLOAT) \ + { \ + builtin_define ("PPC_HardFloat"); \ + builtin_define ("D_HardFloat"); \ + } \ + else if (TARGET_SOFT_FLOAT) \ + { \ + builtin_define ("PPC_SoftFloat"); \ + builtin_define ("D_SoftFloat"); \ + } \ + } \ + while (0) + /* 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/s390/s390.h b/gcc/config/s390/s390.h index a372981ff3a..c2e5f04830f 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -194,6 +194,22 @@ enum processor_flags /* Target CPU builtins. */ #define TARGET_CPU_CPP_BUILTINS() s390_cpu_cpp_builtins (pfile) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + if (TARGET_64BIT) \ + builtin_define ("S390X"); \ + else \ + builtin_define ("S390"); \ + \ + if(TARGET_SOFT_FLOAT) \ + builtin_define ("D_SoftFloat"); \ + else if(TARGET_HARD_FLOAT) \ + builtin_define ("D_HardFloat"); \ + } \ + while (0) + #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/sh/sh.h b/gcc/config/sh/sh.h index b13d1b3c943..028960bd1eb 100644 --- a/gcc/config/sh/sh.h +++ b/gcc/config/sh/sh.h @@ -31,6 +31,19 @@ extern int code_for_indirect_jump_scratch; #define TARGET_CPU_CPP_BUILTINS() sh_cpu_cpp_builtins (pfile) +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ + do \ + { \ + builtin_define ("SH"); \ + \ + if (TARGET_FPU_ANY) \ + builtin_define ("D_HardFloat"); \ + else \ + builtin_define ("D_SoftFloat"); \ + } \ + while (0) + /* Value should be nonzero if functions must have frame pointers. Zero means the frame pointer need not be set up (and parms may be accessed via the stack pointer) in functions that seem suitable. */ diff --git a/gcc/config/sparc/sparc.h b/gcc/config/sparc/sparc.h index 686a3d52193..fe4bc8f438e 100644 --- a/gcc/config/sparc/sparc.h +++ b/gcc/config/sparc/sparc.h @@ -27,6 +27,31 @@ along with GCC; see the file COPYING3. If not see #define TARGET_CPU_CPP_BUILTINS() sparc_target_macros () +/* Target CPU builtins for D. */ +#define TARGET_CPU_D_BUILTINS() \ +do \ + { \ + if (TARGET_64BIT) \ + builtin_define ("SPARC64"); \ + else \ + builtin_define ("SPARC"); \ + \ + if(TARGET_V8PLUS) \ + builtin_define ("SPARC_V8Plus"); \ + \ + if(TARGET_FPU) \ + { \ + builtin_define ("D_HardFloat"); \ + builtin_define ("SPARC_HardFloat"); \ + } \ + else \ + { \ + builtin_define ("D_SoftFloat"); \ + builtin_define ("SPARC_SoftFloat"); \ + } \ + } \ + while (0) + /* Specify this in a cover file to provide bi-architecture (32/64) support. */ /* #define SPARC_BI_ARCH */