From patchwork Mon Oct 2 08:57:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 820390 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463309-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="arfj/mXf"; dkim-atps=neutral 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 3y5GKG3sM9z9t50 for ; Mon, 2 Oct 2017 19:58:07 +1100 (AEDT) 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:cc:content-type; q=dns; s=default; b=UD4R8IpFuRm7dlMfhz5NdoQ3fRA7sc8t1glp4BxJw52 9e6jKJYXlKJEbydeVFXCsxCgr/ASawTDhsjDQnKyOV+KtMbaRVEKRAPi5k5NXEjl eErbSRvh0893MdDPftqwkF8Sp5Gix8cpqx+McdIbCNMXypKEz0EoQFv0iMf0XYz0 = 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:cc:content-type; s=default; bh=Yd6TsDieYXsdu8lyhgy5Re7aeLo=; b=arfj/mXfFLdZAIr8H z6uFXJHuy75b+VVssrdVIesaNVgmGA7q8MBJ/BzcVHMoLOzM18Rl3ptjt0K4UAEE ZODIrUzyuNQkU9Bl2kg69OdhCmvBh+K66nlckXTjoQ0AfGEw4d+6zFN1507L6KMj facIy6RxjXpSrHyFDT+WcHkpXw= Received: (qmail 46738 invoked by alias); 2 Oct 2017 08:57:33 -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 46637 invoked by uid 89); 2 Oct 2017 08:57:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-21.7 required=5.0 tests=AWL, BAYES_50, 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=intimate, Joe, buck, steering X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 08:57:24 +0000 Received: by mail-qk0-f179.google.com with SMTP id k123so1004131qke.3 for ; Mon, 02 Oct 2017 01:57:23 -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:cc; bh=0xniT8J2o6oxNgeCS115WNM7Sk2cbUNSNdMSdjNwS+c=; b=f9XHn9yC4ic2FtPqjwxZTBVOgQ2mnrI9cOFX1BWxgUDlOn1cIaPF7BTDmCwK9pSTnJ Ooa2bb1xOtLyUkJkj/BnzG86OjQFQCUnaqpRHI+HajCBdKY0qyncyzX8tbd8tF4BlA8T 5tMiEKE4seSIYTQ74aAglountUQZToNKpfW8VWCiTMgJ+nijsKCT/Exh3p6qoOiSUoH5 WlnbT0nKP/FLPivnXYqWGmZpC9bWRkraZxZYljUgiFsfWv3ClDtqaef/wbQYB2y4MgXJ t1XBnL9ov6hbDn8uHaFkEYoPtxAYkZurQjEVGX5fZ+W286ShvJ65YcV9A4huz0aesf56 Qu7A== X-Gm-Message-State: AMCzsaVdFLCIGYzm4/xf5byR5/KL749gPH1JJ9y2C10DZUIvk82734yz 83XFUycTFI8LBjhF6VJqkgtNO4VS+QbK3Hda7Ik= X-Google-Smtp-Source: AOwi7QDZJvQPsB4SG2JcwFNhFHqb7vn25LrH+g6KF16NTyewZymIp11hbx6dpEQltMZmB8dxRrnEwSv/1m3dte57NA4= X-Received: by 10.55.39.145 with SMTP id n139mr3553576qkn.70.1506934642378; Mon, 02 Oct 2017 01:57:22 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.172.6 with HTTP; Mon, 2 Oct 2017 01:57:21 -0700 (PDT) From: Iain Buclaw Date: Mon, 2 Oct 2017 10:57:21 +0200 Message-ID: Subject: [PATCH v3 5/14] D: GCC configuration file changes and documentation. To: Jeff Law Cc: gcc-patches X-IsSubscribed: yes No change from the previous, just rebasing against trunk. ChangeLog: * Makefile.def (target_modules): Add libphobos. (flags_to_pass): Add GDC_FOR_TARGET and GDCFLAGS_FOR_TARGET. (dependencies): Add dependency from configure-target-libphobos to configure-target-zlib. Add dependency from all-target-libphobos to all-target-zlib and all-target-libatomic. (language): Add languge d. * Makefile.in: Rebuild. * Makefile.tpl (BUILT_EXPORTS): Add GDC and GDCFLAGS. (HOST_EXPORTS): Add GDC. (BASE_TARGET_EXPORTS): Add GDC. (GDC_FOR_BUILD, GDC_FOR_TARGET): New variables. (GDCFLAGS, GDCFLAGS_FOR_TARGET): New variables. (EXTRA_HOST_FLAGS): 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: * 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. diff --git a/Makefile.def b/Makefile.def index bd7b080d905..786f3174bfe 100644 --- a/Makefile.def +++ b/Makefile.def @@ -158,6 +158,7 @@ target_modules = { module= libgfortran; }; target_modules = { module= libobjc; }; target_modules = { module= libgo; }; target_modules = { module= libhsail-rt; }; +target_modules = { module= libphobos; }; target_modules = { module= libtermcap; no_check=true; missing=mostlyclean; missing=clean; @@ -283,6 +284,8 @@ flags_to_pass = { flag= FLAGS_FOR_TARGET ; }; flags_to_pass = { flag= GFORTRAN_FOR_TARGET ; }; flags_to_pass = { flag= GOC_FOR_TARGET ; }; flags_to_pass = { flag= GOCFLAGS_FOR_TARGET ; }; +flags_to_pass = { flag= GDC_FOR_TARGET ; }; +flags_to_pass = { flag= GDCFLAGS_FOR_TARGET ; }; flags_to_pass = { flag= LD_FOR_TARGET ; }; flags_to_pass = { flag= LIPO_FOR_TARGET ; }; flags_to_pass = { flag= LDFLAGS_FOR_TARGET ; }; @@ -550,6 +553,9 @@ dependencies = { module=configure-target-libgo; on=all-target-libstdc++-v3; }; dependencies = { module=all-target-libgo; on=all-target-libbacktrace; }; dependencies = { module=all-target-libgo; on=all-target-libffi; }; dependencies = { module=all-target-libgo; on=all-target-libatomic; }; +dependencies = { module=configure-target-libphobos; on=configure-target-zlib; }; +dependencies = { module=all-target-libphobos; on=all-target-zlib; }; +dependencies = { module=all-target-libphobos; on=all-target-libatomic; }; dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; }; dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; }; dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; }; @@ -563,6 +569,7 @@ dependencies = { module=all-target-liboffloadmic; on=all-target-libgomp; }; dependencies = { module=install-target-libgo; on=install-target-libatomic; }; dependencies = { module=install-target-libgfortran; on=install-target-libquadmath; }; dependencies = { module=install-target-libgfortran; on=install-target-libgcc; }; +dependencies = { module=install-target-libphobos; on=install-target-libatomic; }; dependencies = { module=install-target-libsanitizer; on=install-target-libstdc++-v3; }; dependencies = { module=install-target-libsanitizer; on=install-target-libgcc; }; dependencies = { module=install-target-libvtv; on=install-target-libstdc++-v3; }; @@ -605,6 +612,8 @@ languages = { language=go; gcc-check-target=check-go; lib-check-target=check-gotools; }; languages = { language=brig; gcc-check-target=check-brig; lib-check-target=check-target-libhsail-rt; }; +languages = { language=d; gcc-check-target=check-d; + lib-check-target=check-target-libphobos; }; // Toplevel bootstrap bootstrap_stage = { id=1 ; }; diff --git a/Makefile.in b/Makefile.in index 78db0982ba2..8ecae7fdf37 100644 --- a/Makefile.in +++ b/Makefile.in @@ -156,6 +156,8 @@ BUILD_EXPORTS = \ GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ GOC="$(GOC_FOR_BUILD)"; export GOC; \ GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \ + GDC="$(GDC_FOR_BUILD)"; export GDC; \ + GDCFLAGS="$(GDCFLAGS_FOR_BUILD)"; export GDCFLAGS; \ DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \ LD="$(LD_FOR_BUILD)"; export LD; \ LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \ @@ -192,6 +194,7 @@ HOST_EXPORTS = \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \ GOC="$(GOC)"; export GOC; \ + GDC="$(GDC)"; export GDC; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ @@ -278,6 +281,7 @@ BASE_TARGET_EXPORTS = \ CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \ GOC="$(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GOC; \ + GDC="$(GDC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GDC; \ DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \ LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \ LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \ @@ -342,6 +346,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ GFORTRAN_FOR_BUILD = @GFORTRAN_FOR_BUILD@ GOC_FOR_BUILD = @GOC_FOR_BUILD@ +GDC_FOR_BUILD = @GDC_FOR_BUILD@ LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ LD_FOR_BUILD = @LD_FOR_BUILD@ NM_FOR_BUILD = @NM_FOR_BUILD@ @@ -408,6 +413,7 @@ LIBCFLAGS = $(CFLAGS) CXXFLAGS = @CXXFLAGS@ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates GOCFLAGS = $(CFLAGS) +GDCFLAGS = $(CFLAGS) CREATE_GCOV = create_gcov @@ -564,6 +570,7 @@ CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ GOC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GOC_FOR_TARGET@ +GDC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GDC_FOR_TARGET@ DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@ LD_FOR_TARGET=@LD_FOR_TARGET@ @@ -588,6 +595,7 @@ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET) LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_TARGET@ GOCFLAGS_FOR_TARGET = -O2 -g +GDCFLAGS_FOR_TARGET = -O2 -g FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@ @@ -787,6 +795,8 @@ BASE_FLAGS_TO_PASS = \ "GFORTRAN_FOR_TARGET=$(GFORTRAN_FOR_TARGET)" \ "GOC_FOR_TARGET=$(GOC_FOR_TARGET)" \ "GOCFLAGS_FOR_TARGET=$(GOCFLAGS_FOR_TARGET)" \ + "GDC_FOR_TARGET=$(GDC_FOR_TARGET)" \ + "GDCFLAGS_FOR_TARGET=$(GDCFLAGS_FOR_TARGET)" \ "LD_FOR_TARGET=$(LD_FOR_TARGET)" \ "LIPO_FOR_TARGET=$(LIPO_FOR_TARGET)" \ "LDFLAGS_FOR_TARGET=$(LDFLAGS_FOR_TARGET)" \ @@ -849,6 +859,7 @@ EXTRA_HOST_FLAGS = \ 'DLLTOOL=$(DLLTOOL)' \ 'GFORTRAN=$(GFORTRAN)' \ 'GOC=$(GOC)' \ + 'GDC=$(GDC)' \ 'LD=$(LD)' \ 'LIPO=$(LIPO)' \ 'NM=$(NM)' \ @@ -905,6 +916,8 @@ EXTRA_TARGET_FLAGS = \ 'GFORTRAN=$$(GFORTRAN_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ 'GOC=$$(GOC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ 'GOCFLAGS=$$(GOCFLAGS_FOR_TARGET)' \ + 'GDC=$$(GDC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ + 'GDCFLAGS=$$(GDCFLAGS_FOR_TARGET)' \ 'LD=$(COMPILER_LD_FOR_TARGET)' \ 'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \ 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \ @@ -1008,6 +1021,7 @@ configure-target: \ maybe-configure-target-libobjc \ maybe-configure-target-libgo \ maybe-configure-target-libhsail-rt \ + maybe-configure-target-libphobos \ maybe-configure-target-libtermcap \ maybe-configure-target-winsup \ maybe-configure-target-libgloss \ @@ -1174,6 +1188,7 @@ all-target: maybe-all-target-libgfortran all-target: maybe-all-target-libobjc all-target: maybe-all-target-libgo all-target: maybe-all-target-libhsail-rt +all-target: maybe-all-target-libphobos all-target: maybe-all-target-libtermcap all-target: maybe-all-target-winsup all-target: maybe-all-target-libgloss @@ -1267,6 +1282,7 @@ info-target: maybe-info-target-libgfortran info-target: maybe-info-target-libobjc info-target: maybe-info-target-libgo info-target: maybe-info-target-libhsail-rt +info-target: maybe-info-target-libphobos info-target: maybe-info-target-libtermcap info-target: maybe-info-target-winsup info-target: maybe-info-target-libgloss @@ -1353,6 +1369,7 @@ dvi-target: maybe-dvi-target-libgfortran dvi-target: maybe-dvi-target-libobjc dvi-target: maybe-dvi-target-libgo dvi-target: maybe-dvi-target-libhsail-rt +dvi-target: maybe-dvi-target-libphobos dvi-target: maybe-dvi-target-libtermcap dvi-target: maybe-dvi-target-winsup dvi-target: maybe-dvi-target-libgloss @@ -1439,6 +1456,7 @@ pdf-target: maybe-pdf-target-libgfortran pdf-target: maybe-pdf-target-libobjc pdf-target: maybe-pdf-target-libgo pdf-target: maybe-pdf-target-libhsail-rt +pdf-target: maybe-pdf-target-libphobos pdf-target: maybe-pdf-target-libtermcap pdf-target: maybe-pdf-target-winsup pdf-target: maybe-pdf-target-libgloss @@ -1525,6 +1543,7 @@ html-target: maybe-html-target-libgfortran html-target: maybe-html-target-libobjc html-target: maybe-html-target-libgo html-target: maybe-html-target-libhsail-rt +html-target: maybe-html-target-libphobos html-target: maybe-html-target-libtermcap html-target: maybe-html-target-winsup html-target: maybe-html-target-libgloss @@ -1611,6 +1630,7 @@ TAGS-target: maybe-TAGS-target-libgfortran TAGS-target: maybe-TAGS-target-libobjc TAGS-target: maybe-TAGS-target-libgo TAGS-target: maybe-TAGS-target-libhsail-rt +TAGS-target: maybe-TAGS-target-libphobos TAGS-target: maybe-TAGS-target-libtermcap TAGS-target: maybe-TAGS-target-winsup TAGS-target: maybe-TAGS-target-libgloss @@ -1697,6 +1717,7 @@ install-info-target: maybe-install-info-target-libgfortran install-info-target: maybe-install-info-target-libobjc install-info-target: maybe-install-info-target-libgo install-info-target: maybe-install-info-target-libhsail-rt +install-info-target: maybe-install-info-target-libphobos install-info-target: maybe-install-info-target-libtermcap install-info-target: maybe-install-info-target-winsup install-info-target: maybe-install-info-target-libgloss @@ -1783,6 +1804,7 @@ install-pdf-target: maybe-install-pdf-target-libgfortran install-pdf-target: maybe-install-pdf-target-libobjc install-pdf-target: maybe-install-pdf-target-libgo install-pdf-target: maybe-install-pdf-target-libhsail-rt +install-pdf-target: maybe-install-pdf-target-libphobos install-pdf-target: maybe-install-pdf-target-libtermcap install-pdf-target: maybe-install-pdf-target-winsup install-pdf-target: maybe-install-pdf-target-libgloss @@ -1869,6 +1891,7 @@ install-html-target: maybe-install-html-target-libgfortran install-html-target: maybe-install-html-target-libobjc install-html-target: maybe-install-html-target-libgo install-html-target: maybe-install-html-target-libhsail-rt +install-html-target: maybe-install-html-target-libphobos install-html-target: maybe-install-html-target-libtermcap install-html-target: maybe-install-html-target-winsup install-html-target: maybe-install-html-target-libgloss @@ -1955,6 +1978,7 @@ installcheck-target: maybe-installcheck-target-libgfortran installcheck-target: maybe-installcheck-target-libobjc installcheck-target: maybe-installcheck-target-libgo installcheck-target: maybe-installcheck-target-libhsail-rt +installcheck-target: maybe-installcheck-target-libphobos installcheck-target: maybe-installcheck-target-libtermcap installcheck-target: maybe-installcheck-target-winsup installcheck-target: maybe-installcheck-target-libgloss @@ -2041,6 +2065,7 @@ mostlyclean-target: maybe-mostlyclean-target-libgfortran mostlyclean-target: maybe-mostlyclean-target-libobjc mostlyclean-target: maybe-mostlyclean-target-libgo mostlyclean-target: maybe-mostlyclean-target-libhsail-rt +mostlyclean-target: maybe-mostlyclean-target-libphobos mostlyclean-target: maybe-mostlyclean-target-libtermcap mostlyclean-target: maybe-mostlyclean-target-winsup mostlyclean-target: maybe-mostlyclean-target-libgloss @@ -2127,6 +2152,7 @@ clean-target: maybe-clean-target-libgfortran clean-target: maybe-clean-target-libobjc clean-target: maybe-clean-target-libgo clean-target: maybe-clean-target-libhsail-rt +clean-target: maybe-clean-target-libphobos clean-target: maybe-clean-target-libtermcap clean-target: maybe-clean-target-winsup clean-target: maybe-clean-target-libgloss @@ -2213,6 +2239,7 @@ distclean-target: maybe-distclean-target-libgfortran distclean-target: maybe-distclean-target-libobjc distclean-target: maybe-distclean-target-libgo distclean-target: maybe-distclean-target-libhsail-rt +distclean-target: maybe-distclean-target-libphobos distclean-target: maybe-distclean-target-libtermcap distclean-target: maybe-distclean-target-winsup distclean-target: maybe-distclean-target-libgloss @@ -2299,6 +2326,7 @@ maintainer-clean-target: maybe-maintainer-clean-target-libgfortran maintainer-clean-target: maybe-maintainer-clean-target-libobjc maintainer-clean-target: maybe-maintainer-clean-target-libgo maintainer-clean-target: maybe-maintainer-clean-target-libhsail-rt +maintainer-clean-target: maybe-maintainer-clean-target-libphobos maintainer-clean-target: maybe-maintainer-clean-target-libtermcap maintainer-clean-target: maybe-maintainer-clean-target-winsup maintainer-clean-target: maybe-maintainer-clean-target-libgloss @@ -2441,6 +2469,7 @@ check-target: \ maybe-check-target-libobjc \ maybe-check-target-libgo \ maybe-check-target-libhsail-rt \ + maybe-check-target-libphobos \ maybe-check-target-libtermcap \ maybe-check-target-winsup \ maybe-check-target-libgloss \ @@ -2623,6 +2652,7 @@ install-target: \ maybe-install-target-libobjc \ maybe-install-target-libgo \ maybe-install-target-libhsail-rt \ + maybe-install-target-libphobos \ maybe-install-target-libtermcap \ maybe-install-target-winsup \ maybe-install-target-libgloss \ @@ -2729,6 +2759,7 @@ install-strip-target: \ maybe-install-strip-target-libobjc \ maybe-install-strip-target-libgo \ maybe-install-strip-target-libhsail-rt \ + maybe-install-strip-target-libphobos \ maybe-install-strip-target-libtermcap \ maybe-install-strip-target-winsup \ maybe-install-strip-target-libgloss \ @@ -48681,6 +48712,464 @@ maintainer-clean-target-libhsail-rt: +.PHONY: configure-target-libphobos maybe-configure-target-libphobos +maybe-configure-target-libphobos: +@if gcc-bootstrap +configure-target-libphobos: stage_current +@endif gcc-bootstrap +@if target-libphobos +maybe-configure-target-libphobos: configure-target-libphobos +configure-target-libphobos: + @: $(MAKE); $(unstage) + @r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + echo "Checking multilib configuration for libphobos..."; \ + $(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libphobos; \ + $(CC_FOR_TARGET) --print-multi-lib > $(TARGET_SUBDIR)/libphobos/multilib.tmp 2> /dev/null; \ + if test -r $(TARGET_SUBDIR)/libphobos/multilib.out; then \ + if cmp -s $(TARGET_SUBDIR)/libphobos/multilib.tmp $(TARGET_SUBDIR)/libphobos/multilib.out; then \ + rm -f $(TARGET_SUBDIR)/libphobos/multilib.tmp; \ + else \ + rm -f $(TARGET_SUBDIR)/libphobos/Makefile; \ + mv $(TARGET_SUBDIR)/libphobos/multilib.tmp $(TARGET_SUBDIR)/libphobos/multilib.out; \ + fi; \ + else \ + mv $(TARGET_SUBDIR)/libphobos/multilib.tmp $(TARGET_SUBDIR)/libphobos/multilib.out; \ + fi; \ + test ! -f $(TARGET_SUBDIR)/libphobos/Makefile || exit 0; \ + $(SHELL) $(srcdir)/mkinstalldirs $(TARGET_SUBDIR)/libphobos; \ + $(NORMAL_TARGET_EXPORTS) \ + echo Configuring in $(TARGET_SUBDIR)/libphobos; \ + cd "$(TARGET_SUBDIR)/libphobos" || exit 1; \ + case $(srcdir) in \ + /* | [A-Za-z]:[\\/]*) topdir=$(srcdir) ;; \ + *) topdir=`echo $(TARGET_SUBDIR)/libphobos/ | \ + sed -e 's,\./,,g' -e 's,[^/]*/,../,g' `$(srcdir) ;; \ + esac; \ + module_srcdir=libphobos; \ + rm -f no-such-file || : ; \ + CONFIG_SITE=no-such-file $(SHELL) \ + $$s/$$module_srcdir/configure \ + --srcdir=$${topdir}/$$module_srcdir \ + $(TARGET_CONFIGARGS) --build=${build_alias} --host=${target_alias} \ + --target=${target_alias} \ + || exit 1 +@endif target-libphobos + + + + + +.PHONY: all-target-libphobos maybe-all-target-libphobos +maybe-all-target-libphobos: +@if gcc-bootstrap +all-target-libphobos: stage_current +@endif gcc-bootstrap +@if target-libphobos +TARGET-target-libphobos=all +maybe-all-target-libphobos: all-target-libphobos +all-target-libphobos: configure-target-libphobos + @: $(MAKE); $(unstage) + @r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) $(EXTRA_TARGET_FLAGS) \ + $(TARGET-target-libphobos)) +@endif target-libphobos + + + + + +.PHONY: check-target-libphobos maybe-check-target-libphobos +maybe-check-target-libphobos: +@if target-libphobos +maybe-check-target-libphobos: check-target-libphobos + +check-target-libphobos: + @: $(MAKE); $(unstage) + @r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(TARGET_FLAGS_TO_PASS) check) + +@endif target-libphobos + +.PHONY: install-target-libphobos maybe-install-target-libphobos +maybe-install-target-libphobos: +@if target-libphobos +maybe-install-target-libphobos: install-target-libphobos + +install-target-libphobos: installdirs + @: $(MAKE); $(unstage) + @r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(TARGET_FLAGS_TO_PASS) install) + +@endif target-libphobos + +.PHONY: install-strip-target-libphobos maybe-install-strip-target-libphobos +maybe-install-strip-target-libphobos: +@if target-libphobos +maybe-install-strip-target-libphobos: install-strip-target-libphobos + +install-strip-target-libphobos: installdirs + @: $(MAKE); $(unstage) + @r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(TARGET_FLAGS_TO_PASS) install-strip) + +@endif target-libphobos + +# Other targets (info, dvi, pdf, etc.) + +.PHONY: maybe-info-target-libphobos info-target-libphobos +maybe-info-target-libphobos: +@if target-libphobos +maybe-info-target-libphobos: info-target-libphobos + +info-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing info in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + info) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-dvi-target-libphobos dvi-target-libphobos +maybe-dvi-target-libphobos: +@if target-libphobos +maybe-dvi-target-libphobos: dvi-target-libphobos + +dvi-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing dvi in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + dvi) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-pdf-target-libphobos pdf-target-libphobos +maybe-pdf-target-libphobos: +@if target-libphobos +maybe-pdf-target-libphobos: pdf-target-libphobos + +pdf-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing pdf in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + pdf) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-html-target-libphobos html-target-libphobos +maybe-html-target-libphobos: +@if target-libphobos +maybe-html-target-libphobos: html-target-libphobos + +html-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing html in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + html) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-TAGS-target-libphobos TAGS-target-libphobos +maybe-TAGS-target-libphobos: +@if target-libphobos +maybe-TAGS-target-libphobos: TAGS-target-libphobos + +TAGS-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing TAGS in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + TAGS) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-install-info-target-libphobos install-info-target-libphobos +maybe-install-info-target-libphobos: +@if target-libphobos +maybe-install-info-target-libphobos: install-info-target-libphobos + +install-info-target-libphobos: \ + configure-target-libphobos \ + info-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing install-info in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + install-info) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-install-pdf-target-libphobos install-pdf-target-libphobos +maybe-install-pdf-target-libphobos: +@if target-libphobos +maybe-install-pdf-target-libphobos: install-pdf-target-libphobos + +install-pdf-target-libphobos: \ + configure-target-libphobos \ + pdf-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing install-pdf in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + install-pdf) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-install-html-target-libphobos install-html-target-libphobos +maybe-install-html-target-libphobos: +@if target-libphobos +maybe-install-html-target-libphobos: install-html-target-libphobos + +install-html-target-libphobos: \ + configure-target-libphobos \ + html-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing install-html in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + install-html) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-installcheck-target-libphobos installcheck-target-libphobos +maybe-installcheck-target-libphobos: +@if target-libphobos +maybe-installcheck-target-libphobos: installcheck-target-libphobos + +installcheck-target-libphobos: \ + configure-target-libphobos + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing installcheck in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + installcheck) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-mostlyclean-target-libphobos mostlyclean-target-libphobos +maybe-mostlyclean-target-libphobos: +@if target-libphobos +maybe-mostlyclean-target-libphobos: mostlyclean-target-libphobos + +mostlyclean-target-libphobos: + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing mostlyclean in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + mostlyclean) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-clean-target-libphobos clean-target-libphobos +maybe-clean-target-libphobos: +@if target-libphobos +maybe-clean-target-libphobos: clean-target-libphobos + +clean-target-libphobos: + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing clean in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + clean) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-distclean-target-libphobos distclean-target-libphobos +maybe-distclean-target-libphobos: +@if target-libphobos +maybe-distclean-target-libphobos: distclean-target-libphobos + +distclean-target-libphobos: + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing distclean in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + distclean) \ + || exit 1 + +@endif target-libphobos + +.PHONY: maybe-maintainer-clean-target-libphobos maintainer-clean-target-libphobos +maybe-maintainer-clean-target-libphobos: +@if target-libphobos +maybe-maintainer-clean-target-libphobos: maintainer-clean-target-libphobos + +maintainer-clean-target-libphobos: + @: $(MAKE); $(unstage) + @[ -f $(TARGET_SUBDIR)/libphobos/Makefile ] || exit 0; \ + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(NORMAL_TARGET_EXPORTS) \ + echo "Doing maintainer-clean in $(TARGET_SUBDIR)/libphobos"; \ + for flag in $(EXTRA_TARGET_FLAGS); do \ + eval `echo "$$flag" | sed -e "s|^\([^=]*\)=\(.*\)|\1='\2'; export \1|"`; \ + done; \ + (cd $(TARGET_SUBDIR)/libphobos && \ + $(MAKE) $(BASE_FLAGS_TO_PASS) "AR=$${AR}" "AS=$${AS}" \ + "CC=$${CC}" "CXX=$${CXX}" "LD=$${LD}" "NM=$${NM}" \ + "RANLIB=$${RANLIB}" \ + "DLLTOOL=$${DLLTOOL}" "WINDRES=$${WINDRES}" "WINDMC=$${WINDMC}" \ + maintainer-clean) \ + || exit 1 + +@endif target-libphobos + + + + + .PHONY: configure-target-libtermcap maybe-configure-target-libtermcap maybe-configure-target-libtermcap: @if gcc-bootstrap @@ -54062,6 +54551,14 @@ check-gcc-brig: (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-brig); check-brig: check-gcc-brig check-target-libhsail-rt +.PHONY: check-gcc-d check-d +check-gcc-d: + r=`${PWD_COMMAND}`; export r; \ + s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ + $(HOST_EXPORTS) \ + (cd gcc && $(MAKE) $(GCC_FLAGS_TO_PASS) check-d); +check-d: check-gcc-d check-target-libphobos + # The gcc part of install-no-fixedincludes, which relies on an intimate # knowledge of how a number of gcc internal targets (inter)operate. Delegate. @@ -57264,6 +57761,7 @@ configure-target-libgfortran: stage_last configure-target-libobjc: stage_last configure-target-libgo: stage_last configure-target-libhsail-rt: stage_last +configure-target-libphobos: stage_last configure-target-libtermcap: stage_last configure-target-winsup: stage_last configure-target-libgloss: stage_last @@ -57300,6 +57798,7 @@ configure-target-libgfortran: maybe-all-gcc configure-target-libobjc: maybe-all-gcc configure-target-libgo: maybe-all-gcc configure-target-libhsail-rt: maybe-all-gcc +configure-target-libphobos: maybe-all-gcc configure-target-libtermcap: maybe-all-gcc configure-target-winsup: maybe-all-gcc configure-target-libgloss: maybe-all-gcc @@ -58416,6 +58915,9 @@ configure-target-libgo: maybe-all-target-libstdc++-v3 all-target-libgo: maybe-all-target-libbacktrace all-target-libgo: maybe-all-target-libffi all-target-libgo: maybe-all-target-libatomic +configure-target-libphobos: maybe-configure-target-zlib +all-target-libphobos: maybe-all-target-zlib +all-target-libphobos: maybe-all-target-libatomic configure-target-libstdc++-v3: maybe-configure-target-libgomp configure-stage1-target-libstdc++-v3: maybe-configure-stage1-target-libgomp @@ -58465,6 +58967,7 @@ all-target-liboffloadmic: maybe-all-target-libgomp install-target-libgo: maybe-install-target-libatomic install-target-libgfortran: maybe-install-target-libquadmath install-target-libgfortran: maybe-install-target-libgcc +install-target-libphobos: maybe-install-target-libatomic install-target-libsanitizer: maybe-install-target-libstdc++-v3 install-target-libsanitizer: maybe-install-target-libgcc install-target-libvtv: maybe-install-target-libstdc++-v3 @@ -58552,6 +59055,7 @@ configure-target-libgfortran: maybe-all-target-libgcc configure-target-libobjc: maybe-all-target-libgcc configure-target-libgo: maybe-all-target-libgcc configure-target-libhsail-rt: maybe-all-target-libgcc +configure-target-libphobos: maybe-all-target-libgcc configure-target-libtermcap: maybe-all-target-libgcc configure-target-winsup: maybe-all-target-libgcc configure-target-libgloss: maybe-all-target-libgcc @@ -58595,6 +59099,8 @@ configure-target-libgo: maybe-all-target-newlib maybe-all-target-libgloss configure-target-libhsail-rt: maybe-all-target-newlib maybe-all-target-libgloss +configure-target-libphobos: maybe-all-target-newlib maybe-all-target-libgloss + configure-target-libtermcap: maybe-all-target-newlib maybe-all-target-libgloss configure-target-winsup: maybe-all-target-newlib maybe-all-target-libgloss diff --git a/Makefile.tpl b/Makefile.tpl index 5fcd7e358d9..348127e707e 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -159,6 +159,8 @@ BUILD_EXPORTS = \ GFORTRAN="$(GFORTRAN_FOR_BUILD)"; export GFORTRAN; \ GOC="$(GOC_FOR_BUILD)"; export GOC; \ GOCFLAGS="$(GOCFLAGS_FOR_BUILD)"; export GOCFLAGS; \ + GDC="$(GDC_FOR_BUILD)"; export GDC; \ + GDCFLAGS="$(GDCFLAGS_FOR_BUILD)"; export GDCFLAGS; \ DLLTOOL="$(DLLTOOL_FOR_BUILD)"; export DLLTOOL; \ LD="$(LD_FOR_BUILD)"; export LD; \ LDFLAGS="$(LDFLAGS_FOR_BUILD)"; export LDFLAGS; \ @@ -195,6 +197,7 @@ HOST_EXPORTS = \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN)"; export GFORTRAN; \ GOC="$(GOC)"; export GOC; \ + GDC="$(GDC)"; export GDC; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ @@ -281,6 +284,7 @@ BASE_TARGET_EXPORTS = \ CXXFLAGS="$(CXXFLAGS_FOR_TARGET)"; export CXXFLAGS; \ GFORTRAN="$(GFORTRAN_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GFORTRAN; \ GOC="$(GOC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GOC; \ + GDC="$(GDC_FOR_TARGET) $(XGCC_FLAGS_FOR_TARGET) $$TFLAGS"; export GDC; \ DLLTOOL="$(DLLTOOL_FOR_TARGET)"; export DLLTOOL; \ LD="$(COMPILER_LD_FOR_TARGET)"; export LD; \ LDFLAGS="$(LDFLAGS_FOR_TARGET)"; export LDFLAGS; \ @@ -345,6 +349,7 @@ CXX_FOR_BUILD = @CXX_FOR_BUILD@ DLLTOOL_FOR_BUILD = @DLLTOOL_FOR_BUILD@ GFORTRAN_FOR_BUILD = @GFORTRAN_FOR_BUILD@ GOC_FOR_BUILD = @GOC_FOR_BUILD@ +GDC_FOR_BUILD = @GDC_FOR_BUILD@ LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ LD_FOR_BUILD = @LD_FOR_BUILD@ NM_FOR_BUILD = @NM_FOR_BUILD@ @@ -411,6 +416,7 @@ LIBCFLAGS = $(CFLAGS) CXXFLAGS = @CXXFLAGS@ LIBCXXFLAGS = $(CXXFLAGS) -fno-implicit-templates GOCFLAGS = $(CFLAGS) +GDCFLAGS = $(CFLAGS) CREATE_GCOV = create_gcov @@ -487,6 +493,7 @@ CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @CXX_FOR_TARGET@ RAW_CXX_FOR_TARGET=$(STAGE_CC_WRAPPER) @RAW_CXX_FOR_TARGET@ GFORTRAN_FOR_TARGET=$(STAGE_CC_WRAPPER) @GFORTRAN_FOR_TARGET@ GOC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GOC_FOR_TARGET@ +GDC_FOR_TARGET=$(STAGE_CC_WRAPPER) @GDC_FOR_TARGET@ DLLTOOL_FOR_TARGET=@DLLTOOL_FOR_TARGET@ LD_FOR_TARGET=@LD_FOR_TARGET@ @@ -511,6 +518,7 @@ LIBCFLAGS_FOR_TARGET = $(CFLAGS_FOR_TARGET) LIBCXXFLAGS_FOR_TARGET = $(CXXFLAGS_FOR_TARGET) -fno-implicit-templates LDFLAGS_FOR_TARGET = @LDFLAGS_FOR_TARGET@ GOCFLAGS_FOR_TARGET = -O2 -g +GDCFLAGS_FOR_TARGET = -O2 -g FLAGS_FOR_TARGET = @FLAGS_FOR_TARGET@ SYSROOT_CFLAGS_FOR_TARGET = @SYSROOT_CFLAGS_FOR_TARGET@ @@ -612,6 +620,7 @@ EXTRA_HOST_FLAGS = \ 'DLLTOOL=$(DLLTOOL)' \ 'GFORTRAN=$(GFORTRAN)' \ 'GOC=$(GOC)' \ + 'GDC=$(GDC)' \ 'LD=$(LD)' \ 'LIPO=$(LIPO)' \ 'NM=$(NM)' \ @@ -668,6 +677,8 @@ EXTRA_TARGET_FLAGS = \ 'GFORTRAN=$$(GFORTRAN_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ 'GOC=$$(GOC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ 'GOCFLAGS=$$(GOCFLAGS_FOR_TARGET)' \ + 'GDC=$$(GDC_FOR_TARGET) $$(XGCC_FLAGS_FOR_TARGET) $$(TFLAGS)' \ + 'GDCFLAGS=$$(GDCFLAGS_FOR_TARGET)' \ 'LD=$(COMPILER_LD_FOR_TARGET)' \ 'LDFLAGS=$$(LDFLAGS_FOR_TARGET)' \ 'LIBCFLAGS=$$(LIBCFLAGS_FOR_TARGET)' \ diff --git a/config-ml.in b/config-ml.in index 47f153350e4..3e37f875c88 100644 --- a/config-ml.in +++ b/config-ml.in @@ -512,6 +512,7 @@ multi-do: prefix="$(prefix)" \ exec_prefix="$(exec_prefix)" \ GOCFLAGS="$(GOCFLAGS) $${flags}" \ + GDCFLAGS="$(GDCFLAGS) $${flags}" \ CXXFLAGS="$(CXXFLAGS) $${flags}" \ LIBCFLAGS="$(LIBCFLAGS) $${flags}" \ LIBCXXFLAGS="$(LIBCXXFLAGS) $${flags}" \ @@ -745,7 +746,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then break fi done - ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" F77="${F77_}$flags" GFORTRAN="${GFORTRAN_}$flags" GOC="${GOC_}$flags"' + ml_config_env='CC="${CC_}$flags" CXX="${CXX_}$flags" F77="${F77_}$flags" GFORTRAN="${GFORTRAN_}$flags" GOC="${GOC_}$flags" GDC="${GDC_}$flags"' if [ "${with_target_subdir}" = "." ]; then CC_=$CC' ' @@ -753,6 +754,7 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then F77_=$F77' ' GFORTRAN_=$GFORTRAN' ' GOC_=$GOC' ' + GDC_=$GDC' ' else # Create a regular expression that matches any string as long # as ML_POPDIR. @@ -817,6 +819,18 @@ if [ -n "${multidirs}" ] && [ -z "${ml_norecursion}" ]; then esac done + GDC_= + for arg in ${GDC}; do + case $arg in + -[BIL]"${ML_POPDIR}"/*) + GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + "${ML_POPDIR}"/*) + GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;; + *) + GDC_="${GDC_}${arg} " ;; + esac + done + if test "x${LD_LIBRARY_PATH+set}" = xset; then LD_LIBRARY_PATH_= for arg in `echo "$LD_LIBRARY_PATH" | tr ':' ' '`; do diff --git a/config/multi.m4 b/config/multi.m4 index bba338a8265..10680a5b32b 100644 --- a/config/multi.m4 +++ b/config/multi.m4 @@ -64,4 +64,5 @@ multi_basedir="$multi_basedir" CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} CC="$CC" CXX="$CXX" -GFORTRAN="$GFORTRAN"])])dnl +GFORTRAN="$GFORTRAN" +GDC="$GDC"])])dnl diff --git a/configure b/configure index 8e5c7ab7969..61cb8f7b9e5 100755 --- a/configure +++ b/configure @@ -580,6 +580,7 @@ LD_FOR_TARGET DLLTOOL_FOR_TARGET AS_FOR_TARGET AR_FOR_TARGET +GDC_FOR_TARGET GOC_FOR_TARGET GFORTRAN_FOR_TARGET GCC_FOR_TARGET @@ -612,6 +613,7 @@ RANLIB_FOR_BUILD NM_FOR_BUILD LD_FOR_BUILD LDFLAGS_FOR_BUILD +GDC_FOR_BUILD GOC_FOR_BUILD GFORTRAN_FOR_BUILD DLLTOOL_FOR_BUILD @@ -830,6 +832,7 @@ CXX_FOR_TARGET GCC_FOR_TARGET GFORTRAN_FOR_TARGET GOC_FOR_TARGET +GDC_FOR_TARGET AR_FOR_TARGET AS_FOR_TARGET DLLTOOL_FOR_TARGET @@ -1613,6 +1616,8 @@ Some influential environment variables: GFORTRAN for the target GOC_FOR_TARGET GOC for the target + GDC_FOR_TARGET + GDC for the target AR_FOR_TARGET AR for the target AS_FOR_TARGET @@ -2766,7 +2771,8 @@ target_libraries="target-libgcc \ target-libffi \ target-libobjc \ target-libada \ - target-libgo" + target-libgo \ + target-libphobos" # these tools are built using the target libraries, and are intended to # run only in the target environment @@ -3960,6 +3966,7 @@ if test "${build}" != "${host}" ; then CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo} + GDC_FOR_BUILD=${GDC_FOR_BUILD-gdc} DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool} LD_FOR_BUILD=${LD_FOR_BUILD-ld} NM_FOR_BUILD=${NM_FOR_BUILD-nm} @@ -3973,6 +3980,7 @@ else CXX_FOR_BUILD="\$(CXX)" GFORTRAN_FOR_BUILD="\$(GFORTRAN)" GOC_FOR_BUILD="\$(GOC)" + GDC_FOR_BUILD="\$(GDC)" DLLTOOL_FOR_BUILD="\$(DLLTOOL)" LD_FOR_BUILD="\$(LD)" NM_FOR_BUILD="\$(NM)" @@ -7690,6 +7698,7 @@ done + # Generate default definitions for YACC, M4, LEX and other programs that run # on the build machine. These are used if the Makefile can't locate these # programs in objdir. @@ -10744,6 +10753,167 @@ fi +if test -n "$GDC_FOR_TARGET"; then + ac_cv_prog_GDC_FOR_TARGET=$GDC_FOR_TARGET +elif test -n "$ac_cv_prog_GDC_FOR_TARGET"; then + GDC_FOR_TARGET=$ac_cv_prog_GDC_FOR_TARGET +fi + +if test -n "$ac_cv_prog_GDC_FOR_TARGET"; then + for ncn_progname in gdc; do + # Extract the first word of "${ncn_progname}", so it can be a program name with args. +set dummy ${ncn_progname}; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_GDC_FOR_TARGET+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GDC_FOR_TARGET"; then + ac_cv_prog_GDC_FOR_TARGET="$GDC_FOR_TARGET" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_GDC_FOR_TARGET="${ncn_progname}" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +GDC_FOR_TARGET=$ac_cv_prog_GDC_FOR_TARGET +if test -n "$GDC_FOR_TARGET"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDC_FOR_TARGET" >&5 +$as_echo "$GDC_FOR_TARGET" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + done +fi + +if test -z "$ac_cv_prog_GDC_FOR_TARGET" && test -n "$with_build_time_tools"; then + for ncn_progname in gdc; do + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ncn_progname} in $with_build_time_tools" >&5 +$as_echo_n "checking for ${ncn_progname} in $with_build_time_tools... " >&6; } + if test -x $with_build_time_tools/${ncn_progname}; then + ac_cv_prog_GDC_FOR_TARGET=$with_build_time_tools/${ncn_progname} + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + break + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + fi + done +fi + +if test -z "$ac_cv_prog_GDC_FOR_TARGET"; then + for ncn_progname in gdc; do + if test -n "$ncn_target_tool_prefix"; then + # Extract the first word of "${ncn_target_tool_prefix}${ncn_progname}", so it can be a program name with args. +set dummy ${ncn_target_tool_prefix}${ncn_progname}; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_GDC_FOR_TARGET+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GDC_FOR_TARGET"; then + ac_cv_prog_GDC_FOR_TARGET="$GDC_FOR_TARGET" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_GDC_FOR_TARGET="${ncn_target_tool_prefix}${ncn_progname}" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +GDC_FOR_TARGET=$ac_cv_prog_GDC_FOR_TARGET +if test -n "$GDC_FOR_TARGET"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDC_FOR_TARGET" >&5 +$as_echo "$GDC_FOR_TARGET" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi + if test -z "$ac_cv_prog_GDC_FOR_TARGET" && test $build = $target ; then + # Extract the first word of "${ncn_progname}", so it can be a program name with args. +set dummy ${ncn_progname}; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if test "${ac_cv_prog_GDC_FOR_TARGET+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$GDC_FOR_TARGET"; then + ac_cv_prog_GDC_FOR_TARGET="$GDC_FOR_TARGET" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_GDC_FOR_TARGET="${ncn_progname}" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +GDC_FOR_TARGET=$ac_cv_prog_GDC_FOR_TARGET +if test -n "$GDC_FOR_TARGET"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GDC_FOR_TARGET" >&5 +$as_echo "$GDC_FOR_TARGET" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi + test -n "$ac_cv_prog_GDC_FOR_TARGET" && break + done +fi + +if test -z "$ac_cv_prog_GDC_FOR_TARGET" ; then + set dummy gdc + if test $build = $target ; then + GDC_FOR_TARGET="$2" + else + GDC_FOR_TARGET="${ncn_target_tool_prefix}$2" + fi +else + GDC_FOR_TARGET="$ac_cv_prog_GDC_FOR_TARGET" +fi + + + cat > conftest.c << \EOF #ifdef __GNUC__ gcc_yay; @@ -14140,6 +14310,51 @@ $as_echo "pre-installed" >&6; } fi fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target gdc" >&5 +$as_echo_n "checking where to find the target gdc... " >&6; } +if test "x${build}" != "x${host}" ; then + if expr "x$GDC_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $GDC_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + else + # Canadian cross, just use what we found + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +else + ok=yes + case " ${configdirs} " in + *" gcc "*) ;; + *) ok=no ;; + esac + case ,${enable_languages}, in + *,d,*) ;; + *) ok=no ;; + esac + if test $ok = yes; then + # An in-tree tool is available and we can use it + GDC_FOR_TARGET='$$r/$(HOST_SUBDIR)/gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: just compiled" >&5 +$as_echo "just compiled" >&6; } + elif expr "x$GDC_FOR_TARGET" : "x/" > /dev/null; then + # We already found the complete path + ac_dir=`dirname $GDC_FOR_TARGET` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed in $ac_dir" >&5 +$as_echo "pre-installed in $ac_dir" >&6; } + elif test "x$target" = "x$host"; then + # We can use an host tool + GDC_FOR_TARGET='$(GDC)' + { $as_echo "$as_me:${as_lineno-$LINENO}: result: host tool" >&5 +$as_echo "host tool" >&6; } + else + # We need a cross tool + { $as_echo "$as_me:${as_lineno-$LINENO}: result: pre-installed" >&5 +$as_echo "pre-installed" >&6; } + fi +fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking where to find the target ld" >&5 $as_echo_n "checking where to find the target ld... " >&6; } if test "x${build}" != "x${host}" ; then diff --git a/configure.ac b/configure.ac index 173443fc247..faa6c6a5c1e 100644 --- a/configure.ac +++ b/configure.ac @@ -165,7 +165,8 @@ target_libraries="target-libgcc \ target-libffi \ target-libobjc \ target-libada \ - target-libgo" + target-libgo \ + target-libphobos" # these tools are built using the target libraries, and are intended to # run only in the target environment @@ -1269,6 +1270,7 @@ if test "${build}" != "${host}" ; then CXX_FOR_BUILD=${CXX_FOR_BUILD-g++} GFORTRAN_FOR_BUILD=${GFORTRAN_FOR_BUILD-gfortran} GOC_FOR_BUILD=${GOC_FOR_BUILD-gccgo} + GDC_FOR_BUILD=${GDC_FOR_BUILD-gdc} DLLTOOL_FOR_BUILD=${DLLTOOL_FOR_BUILD-dlltool} LD_FOR_BUILD=${LD_FOR_BUILD-ld} NM_FOR_BUILD=${NM_FOR_BUILD-nm} @@ -1282,6 +1284,7 @@ else CXX_FOR_BUILD="\$(CXX)" GFORTRAN_FOR_BUILD="\$(GFORTRAN)" GOC_FOR_BUILD="\$(GOC)" + GDC_FOR_BUILD="\$(GDC)" DLLTOOL_FOR_BUILD="\$(DLLTOOL)" LD_FOR_BUILD="\$(LD)" NM_FOR_BUILD="\$(NM)" @@ -3269,6 +3272,7 @@ AC_SUBST(CXX_FOR_BUILD) AC_SUBST(DLLTOOL_FOR_BUILD) AC_SUBST(GFORTRAN_FOR_BUILD) AC_SUBST(GOC_FOR_BUILD) +AC_SUBST(GDC_FOR_BUILD) AC_SUBST(LDFLAGS_FOR_BUILD) AC_SUBST(LD_FOR_BUILD) AC_SUBST(NM_FOR_BUILD) @@ -3378,6 +3382,7 @@ NCN_STRICT_CHECK_TARGET_TOOLS(CXX_FOR_TARGET, c++ g++ cxx gxx) NCN_STRICT_CHECK_TARGET_TOOLS(GCC_FOR_TARGET, gcc, ${CC_FOR_TARGET}) NCN_STRICT_CHECK_TARGET_TOOLS(GFORTRAN_FOR_TARGET, gfortran) NCN_STRICT_CHECK_TARGET_TOOLS(GOC_FOR_TARGET, gccgo) +NCN_STRICT_CHECK_TARGET_TOOLS(GDC_FOR_TARGET, gdc) ACX_CHECK_INSTALLED_TARGET_TOOL(AR_FOR_TARGET, ar) ACX_CHECK_INSTALLED_TARGET_TOOL(AS_FOR_TARGET, as) @@ -3411,6 +3416,8 @@ GCC_TARGET_TOOL(gfortran, GFORTRAN_FOR_TARGET, GFORTRAN, [gcc/gfortran -B$$r/$(HOST_SUBDIR)/gcc/], fortran) GCC_TARGET_TOOL(gccgo, GOC_FOR_TARGET, GOC, [gcc/gccgo -B$$r/$(HOST_SUBDIR)/gcc/], go) +GCC_TARGET_TOOL(gdc, GDC_FOR_TARGET, GDC, + [gcc/gdc -B$$r/$(HOST_SUBDIR)/gcc/], d) GCC_TARGET_TOOL(ld, LD_FOR_TARGET, LD, [ld/ld-new]) GCC_TARGET_TOOL(lipo, LIPO_FOR_TARGET, LIPO) GCC_TARGET_TOOL(nm, NM_FOR_TARGET, NM, [binutils/nm-new]) diff --git a/gcc/doc/contrib.texi b/gcc/doc/contrib.texi index 60b71026779..1b7acdbff33 100644 --- a/gcc/doc/contrib.texi +++ b/gcc/doc/contrib.texi @@ -139,6 +139,9 @@ Joe Buck for his direction via the steering committee from its creation to 2013. @item +Iain Buclaw for the D frontend. + +@item Craig Burley for leadership of the G77 Fortran effort. @item diff --git a/gcc/doc/frontends.texi b/gcc/doc/frontends.texi index 09c2081d20c..11267d2f54b 100644 --- a/gcc/doc/frontends.texi +++ b/gcc/doc/frontends.texi @@ -9,6 +9,7 @@ @cindex GNU Compiler Collection @cindex GNU C Compiler @cindex Ada +@cindex D @cindex Fortran @cindex Go @cindex Objective-C @@ -16,7 +17,7 @@ GCC stands for ``GNU Compiler Collection''. GCC is an integrated distribution of compilers for several major programming languages. These languages currently include C, C++, Objective-C, Objective-C++, -Fortran, Ada, Go, and BRIG (HSAIL). +Fortran, Ada, D, Go, and BRIG (HSAIL). The abbreviation @dfn{GCC} has multiple meanings in common use. The current official meaning is ``GNU Compiler Collection'', which refers diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index da360da1c50..140c85b1db0 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -916,7 +916,7 @@ only for the listed packages. For other packages, only static libraries will be built. Package names currently recognized in the GCC tree are @samp{libgcc} (also known as @samp{gcc}), @samp{libstdc++} (not @samp{libstdc++-v3}), @samp{libffi}, @samp{zlib}, @samp{boehm-gc}, -@samp{ada}, @samp{libada}, @samp{libgo}, and @samp{libobjc}. +@samp{ada}, @samp{libada}, @samp{libgo}, @samp{libobjc}, and @samp{libphobos}. Note @samp{libiberty} does not support shared libraries at all. Use @option{--disable-shared} to build only static libraries. Note that @@ -1626,12 +1626,12 @@ their runtime libraries should be built. For a list of valid values for grep ^language= */config-lang.in @end smallexample Currently, you can use any of the following: -@code{all}, @code{default}, @code{ada}, @code{c}, @code{c++}, @code{fortran}, -@code{go}, @code{jit}, @code{lto}, @code{objc}, @code{obj-c++}. +@code{all}, @code{default}, @code{ada}, @code{c}, @code{c++}, @code{d}, +@code{fortran}, @code{go}, @code{jit}, @code{lto}, @code{objc}, @code{obj-c++}. Building the Ada compiler has special requirements, see below. If you do not pass this flag, or specify the option @code{default}, then the default languages available in the @file{gcc} sub-tree will be configured. -Ada, Go, Jit, and Objective-C++ are not default languages. LTO is not a +Ada, D, Go, Jit, and Objective-C++ are not default languages. LTO is not a default language, but is built by default because @option{--enable-lto} is enabled by default. The other languages are default languages. If @code{all} is specified, then all available languages are built. An @@ -2716,7 +2716,7 @@ on a simulator as described at @uref{http://gcc.gnu.org/simtest-howto.html}. In order to run sets of tests selectively, there are targets @samp{make check-gcc} and language specific @samp{make check-c}, -@samp{make check-c++}, @samp{make check-fortran}, +@samp{make check-c++}, @samp{make check-d} @samp{make check-fortran}, @samp{make check-ada}, @samp{make check-objc}, @samp{make check-obj-c++}, @samp{make check-lto} in the @file{gcc} subdirectory of the object directory. You can also diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f862b7f8c99..a6a09184c90 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1351,6 +1351,15 @@ Go source code. @item @var{file}.brig BRIG files (binary representation of HSAIL). +@item @var{file}.d +D source code. + +@item @var{file}.di +D interface file. + +@item @var{file}.dd +D documentation code (Ddoc). + @item @var{file}.ads Ada source code file that contains a library unit declaration (a declaration of a package, subprogram, or generic, or a generic @@ -1397,6 +1406,7 @@ objective-c objective-c-header objective-c-cpp-output objective-c++ objective-c++-header objective-c++-cpp-output assembler assembler-with-cpp ada +d f77 f77-cpp-input f95 f95-cpp-input go brig diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 56e1b4eb103..1c4c9bda846 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -106,6 +106,10 @@ The Objective-C and Objective-C++ runtime library. @item libquadmath The runtime support library for quad-precision math operations. +@item libphobos +The D standard and runtime library. The bulk of this library is mirrored +from the @uref{https://github.com/@/dlang, master D repositories}. + @item libssp The Stack protector runtime library. diff --git a/gcc/doc/standards.texi b/gcc/doc/standards.texi index d4112b37863..0c6e450d6e8 100644 --- a/gcc/doc/standards.texi +++ b/gcc/doc/standards.texi @@ -307,6 +307,12 @@ capability is typically utilized to implement the HSA runtime API's HSAIL finalization extension for a gcc supported processor. HSA standards are freely available at @uref{http://www.hsafoundation.com/standards/}. +@section D language + +GCC supports the D 2.0 programming language. The D language itself is +currently defined by its reference implementation and supporting language +specification, described at @uref{https://dlang.org/spec/spec.html}. + @section References for Other Languages @xref{Top, GNAT Reference Manual, About This Guide, gnat_rm, From patchwork Mon Oct 2 08:58:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 820392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463310-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="v51G0Omy"; dkim-atps=neutral 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 3y5GLN467xz9t4Z for ; Mon, 2 Oct 2017 19:59:08 +1100 (AEDT) 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:cc:content-type; q=dns; s=default; b=d7Dys+uAq2GEMZ+GL0zupVrvfOJm3GzgcZy+F06uO+Z PL1SVXXuKW57kMEzfn10nXmBy4CZ5xMBsI2NE/ZFVXmbBPa0IJSV16/hlfHXeVc+ rNNy7igwHwc8APRZMOzDFSbuhb7jQTidLFU6VyCIQ2kGzz3RCWKK6lnkDJbPOyJ4 = 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:cc:content-type; s=default; bh=7Y/S3Pu/DWdgNX1XjgUy++QIOYQ=; b=v51G0Omyw1r8wl/xq hHHU+8P9tD32j+pEQU67UY97pB3JzjEdEdnW0UUEteUSqToy4PPoH8bpEAOF07aZ mf8s01rUIkZQiq2Brk7q3KE0BZNBsAjBJ5dIn9Idt4EDdYDUjTDyB0PJV5THqDZ1 LwHpBAt0lF9YXsHSrSESiwNoes= Received: (qmail 49212 invoked by alias); 2 Oct 2017 08:58:29 -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 49184 invoked by uid 89); 2 Oct 2017 08:58:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 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=JIT X-HELO: mail-qk0-f179.google.com Received: from mail-qk0-f179.google.com (HELO mail-qk0-f179.google.com) (209.85.220.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 08:58:26 +0000 Received: by mail-qk0-f179.google.com with SMTP id b15so2377662qkg.9 for ; Mon, 02 Oct 2017 01:58:26 -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:cc; bh=F+r8ceHn0L2L1GQXAJihHUPaeDQuMM9dSGsxllzoSlg=; b=W9OPG3Vh1UGkN1nNJHHwi6K/69BlSHkW72TSCcR9EvADaGm0QyWENqF4bg7zzV+gQR 6QqLduJPJgyZgG5/JIG6MhcNrvJlYuv2pyVUAUYU5TYGceCBILn+Y9GA+n0zsHsbdfGx 6THYVCSayIdZ6s04yT87eGFyYUZv8ZoQcj6Fi0fuw+KuAD8H6WBqaIftPbDhgI2Y/j56 wok2DXG1h6CLbjFAthbYZHnMykk7thkB+SDHFGYxEZCdEtXxtlnM9ErBOvpxbpBKs6yd P0Bgpeqm1q9AX6y98WoyCp6J8cCXjqxIgP2FBKhspUWc+DtT5sWhXoV55a3+EOkUo4VO p9wA== X-Gm-Message-State: AMCzsaUToRXAH53EfDYANnGxTXEYpTtIyOwEvGL4SBmP6rg18NSwBV4J inSbH+spGoIlYwlCUYEKlnFCSe2BilqGhF0Gey8= X-Google-Smtp-Source: AOwi7QDZrUDN63VnrjR8Bgtps2t+5/5esdj5Xa5KiC6Ir185GLMLjgcvAww6/8sy70VJdF8GA/W38drL1opsXzBQPhw= X-Received: by 10.55.23.131 with SMTP id 3mr11838821qkx.237.1506934705183; Mon, 02 Oct 2017 01:58:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.172.6 with HTTP; Mon, 2 Oct 2017 01:58:23 -0700 (PDT) From: Iain Buclaw Date: Mon, 2 Oct 2017 10:58:23 +0200 Message-ID: Subject: [PATCH v3 6/14] D: Add D language support to GCC proper. To: Jeff Law Cc: Mike Stump , gcc-patches X-IsSubscribed: yes No changes from previous, just rebased against trunk. Regards Iain gcc/ChangeLog * config/powerpcspe/powerpcspe.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * config/rs6000/rs6000.c (rs6000_output_function_epilogue): Support GNU D by using 0 as the language type. * 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, dwarf2out_decl): Handle CONST_DECLSs for D. * gcc.c (default_compilers): Add entries for ".d", ".dd" and ".di". gcc/po/ChangeLog: * EXCLUDES: Add sources from d/dfrontend. diff --git a/gcc/config/powerpcspe/powerpcspe.c b/gcc/config/powerpcspe/powerpcspe.c index 12af88417ba..b322b91a652 100644 --- a/gcc/config/powerpcspe/powerpcspe.c +++ b/gcc/config/powerpcspe/powerpcspe.c @@ -32019,11 +32019,12 @@ rs6000_output_function_epilogue (FILE *file) use language_string. C is 0. Fortran is 1. Pascal is 2. 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.c b/gcc/config/rs6000/rs6000.c index 1e794a0faa6..3e1cfc65ad7 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -29214,11 +29214,12 @@ rs6000_output_function_epilogue (FILE *file) use language_string. C is 0. Fortran is 1. Pascal is 2. 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/dwarf2out.c b/gcc/dwarf2out.c index e97ceb61b46..732851faf36 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5176,6 +5176,16 @@ is_ada (void) return lang == DW_LANG_Ada95 || lang == DW_LANG_Ada83; } +/* Return TRUE if the language is D. */ + +static inline bool +is_dlang (void) +{ + unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language); + + return lang == DW_LANG_D; +} + /* Remove the specified attribute if present. Return TRUE if removal was successful. */ @@ -23535,6 +23545,8 @@ gen_compile_unit_die (const char *filename) language = DW_LANG_ObjC; else if (strcmp (language_string, "GNU Objective-C++") == 0) language = DW_LANG_ObjC_plus_plus; + else if (strcmp (language_string, "GNU D") == 0) + language = DW_LANG_D; else if (dwarf_version >= 5 || !dwarf_strict) { if (strcmp (language_string, "GNU Go") == 0) @@ -25138,7 +25150,7 @@ declare_in_namespace (tree thing, dw_die_ref context_die) if (ns_context != context_die) { - if (is_fortran ()) + if (is_fortran () || is_dlang ()) return ns_context; if (DECL_P (thing)) gen_decl_die (thing, NULL, NULL, ns_context); @@ -25161,7 +25173,7 @@ gen_namespace_die (tree decl, dw_die_ref context_die) { /* Output a real namespace or module. */ context_die = setup_namespace_context (decl, comp_unit_die ()); - namespace_die = new_die (is_fortran () + namespace_die = new_die (is_fortran () || is_dlang () ? DW_TAG_module : DW_TAG_namespace, context_die, decl); /* For Fortran modules defined in different CU don't add src coords. */ @@ -25233,7 +25245,7 @@ gen_decl_die (tree decl, tree origin, struct vlr_context *ctx, break; case CONST_DECL: - if (!is_fortran () && !is_ada ()) + if (!is_fortran () && !is_ada () && !is_dlang ()) { /* The individual enumerators of an enum type get output when we output the Dwarf representation of the relevant enum type itself. */ @@ -25807,7 +25819,7 @@ dwarf2out_decl (tree decl) case CONST_DECL: if (debug_info_level <= DINFO_LEVEL_TERSE) return; - if (!is_fortran () && !is_ada ()) + if (!is_fortran () && !is_ada () && !is_dlang ()) return; if (TREE_STATIC (decl) && decl_function_context (decl)) context_die = lookup_decl_die (DECL_CONTEXT (decl)); diff --git a/gcc/gcc.c b/gcc/gcc.c index cec3ed5be5f..44896630e5e 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1307,6 +1307,7 @@ static const struct compiler default_compilers[] = {".f08", "#Fortran", 0, 0, 0}, {".F08", "#Fortran", 0, 0, 0}, {".r", "#Ratfor", 0, 0, 0}, {".go", "#Go", 0, 1, 0}, + {".d", "#D", 0, 1, 0}, {".dd", "#D", 0, 1, 0}, {".di", "#D", 0, 1, 0}, /* Next come the entries for C. */ {".c", "@c", 0, 0, 1}, {"@c", diff --git a/gcc/po/EXCLUDES b/gcc/po/EXCLUDES index da6906552bd..2f8e4f40489 100644 --- a/gcc/po/EXCLUDES +++ b/gcc/po/EXCLUDES @@ -53,3 +53,43 @@ genrecog.c gensupport.c gensupport.h read-md.c + +# These files are part of the front end to D, and have no i18n support. +d/dfrontend/arrayop.c +d/dfrontend/attrib.c +d/dfrontend/canthrow.c +d/dfrontend/cond.c +d/dfrontend/constfold.c +d/dfrontend/cppmangle.c +d/dfrontend/ctfeexpr.c +d/dfrontend/dcast.c +d/dfrontend/dclass.c +d/dfrontend/declaration.c +d/dfrontend/denum.c +d/dfrontend/dimport.c +d/dfrontend/dinterpret.c +d/dfrontend/dmangle.c +d/dfrontend/dmodule.c +d/dfrontend/doc.c +d/dfrontend/dscope.c +d/dfrontend/dstruct.c +d/dfrontend/dsymbol.c +d/dfrontend/dtemplate.c +d/dfrontend/dversion.c +d/dfrontend/expression.c +d/dfrontend/func.c +d/dfrontend/init.c +d/dfrontend/inline.c +d/dfrontend/lexer.c +d/dfrontend/mtype.c +d/dfrontend/nogc.c +d/dfrontend/nspace.c +d/dfrontend/objc.c +d/dfrontend/opover.c +d/dfrontend/optimize.c +d/dfrontend/parse.c +d/dfrontend/sideeffect.c +d/dfrontend/statement.c +d/dfrontend/statementsem.c +d/dfrontend/staticassert.c +d/dfrontend/traits.c From patchwork Mon Oct 2 09:00:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 820393 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463311-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Bow+WUZD"; dkim-atps=neutral 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 3y5GNG2z03z9t4Z for ; Mon, 2 Oct 2017 20:00:46 +1100 (AEDT) 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:cc:content-type; q=dns; s=default; b=D/SE2ghbnJl3eVxgJhKfW58APnc8H3g5RiDpMit30d/ /JNm1KxHf8gM4i6/pICl90OJUzxNbbBAnuRjVpspW/9h2N0/nfX/ZkZTbxQoABJS u0ISeuxpf+fqxh4KpJ6v/D11zhlppTs1MdD+sCfOymqqHt0lsN6jdjAhKzItgrkw = 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:cc:content-type; s=default; bh=1YuEKqw2jEwg3i84UsDoOyVqSR4=; b=Bow+WUZD282/adBKg jEMx1Vv9Hoz4LpMpkNRSjVxYd3pd1RNjLqHTmPyOz1TTt7Qmbkbs1NzdtvgRygVA mWtQU0dM1CohO0V0C17wAmCyKjSN5gtsNM/Bc3R1Bwxx0BNlXFMfrJffhDaf1flh xHE32ofb4pCfiJUvybZwBYS04A= Received: (qmail 52236 invoked by alias); 2 Oct 2017 09:00:25 -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 52195 invoked by uid 89); 2 Oct 2017 09:00:23 -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, SPF_PASS autolearn=ham version=3.3.2 spammy=co, environmental, txt, TXT X-HELO: mail-qk0-f173.google.com Received: from mail-qk0-f173.google.com (HELO mail-qk0-f173.google.com) (209.85.220.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 09:00:14 +0000 Received: by mail-qk0-f173.google.com with SMTP id 17so4481470qkq.8 for ; Mon, 02 Oct 2017 02:00:10 -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:cc; bh=Cz1BriGq+LrnGcQzxZ/P8Ruj9NWQs5R8859Zqtb4ytY=; b=Gr7CO3YY2d+ugjRyYR2BFjHHQUSaQp79oJV/djPDk3mLO0UbCPiScDrNSYBsRCpex9 FUN+kMuZH1xup2eBuHcv1a2gZ4Db8D+XdxizbiTwvrMB4NYyDM9DhV3S1dPlYmc005S+ dYC+Meeb2/Bl5TocZcQgE8JgslmFVhYHA5qS6axStvPBbj598D6CzJWSa1GrA/oIj351 zyvQ8nhmWV5Ys88lqUDtC+JBcUVm6HjJlTAqWBzfjEJG6EbBaAGG4bmg3x+GXVrTRqYZ dQ/db//Ufa7OINwfCHfiVdVA/ShtdLA11xpL7i8a+WDVcUMifdQfdcorLmWUddHprnrn qBQw== X-Gm-Message-State: AMCzsaV6rzEOnG5CTj47VuSER3zEQWhdGHqJSwI66+llpgpZgZJ+V2lJ ps6lZcGQxdqbOoSg09bpSjUWWKrLUYA/6RVvTt6E7g== X-Google-Smtp-Source: AOwi7QDrwwj4CP3qbcjErnWoGv8NgIUtMC0kDf5/u5V40fp6kd1dDINPsqXN3GI2ioWfK+hofTdfP7ZGR5837zKitpw= X-Received: by 10.55.23.131 with SMTP id 3mr11843096qkx.237.1506934808891; Mon, 02 Oct 2017 02:00:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.172.6 with HTTP; Mon, 2 Oct 2017 02:00:08 -0700 (PDT) From: Iain Buclaw Date: Mon, 2 Oct 2017 11:00:08 +0200 Message-ID: Subject: [PATCH v3 7/14] D: Add D language support to GCC targets. To: gcc-patches Cc: "Joseph S. Myers" , Jeff Law X-IsSubscribed: yes This patch add D language support to targets of GCC itself. Changes since previous are just removing patches for untested target configurations, these can be re-added later on an as-per basis. 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/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. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0bde7acf914..c8b58bb8d23 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -546,6 +546,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@ @@ -840,6 +842,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) @@ -897,9 +900,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) @@ -1174,6 +1179,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@ @@ -1762,6 +1770,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="" \ @@ -1788,6 +1797,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 @@ -2151,6 +2165,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 = \ @@ -2446,6 +2466,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 @@ -2469,6 +2498,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 ; \ @@ -2607,14 +2637,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 # @@ -2757,7 +2788,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) \ diff --git a/gcc/config.gcc b/gcc/config.gcc index 7a2e2cfffe5..e01c65a4c08 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -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. @@ -303,6 +314,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" target_gtfiles="\$(srcdir)/config/aarch64/aarch64-builtins.c" target_has_targetm_common=yes @@ -328,6 +340,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" ;; @@ -360,6 +373,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_options="${extra_options} fused-madd.opt" extra_headers="cpuid.h mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h tmmintrin.h ammintrin.h smmintrin.h @@ -383,6 +397,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_headers="cpuid.h mmintrin.h mm3dnow.h xmmintrin.h emmintrin.h pmmintrin.h tmmintrin.h ammintrin.h smmintrin.h @@ -426,6 +441,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" @@ -480,6 +496,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*-*-*) @@ -487,6 +504,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" ;; @@ -516,10 +534,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 @@ -788,8 +809,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" @@ -3130,6 +3153,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 @@ -4608,6 +4635,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}" ;; diff --git a/gcc/config/aarch64/aarch64-d.c b/gcc/config/aarch64/aarch64-d.c new file mode 100644 index 00000000000..80045f4641f --- /dev/null +++ b/gcc/config/aarch64/aarch64-d.c @@ -0,0 +1,31 @@ +/* Subroutines for the D front end on the ARM64 architecture. + Copyright (C) 2017 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 +. */ + +#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"); +} diff --git a/gcc/config/aarch64/aarch64-linux.h b/gcc/config/aarch64/aarch64-linux.h index 2103344a47c..16dfbc4a1ec 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 e67c2ed5e80..286bc8e88d7 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -482,6 +482,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 *ctxt); #endif /* GCC_AARCH64_PROTOS_H */ diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 0786b283719..e85c7e29fcc 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 32532864cae..cae6a061b30 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 00000000000..e2bec6e36ec --- /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 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 +. */ + +#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 4538078fe60..56c854fbad6 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -352,6 +352,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 a3ca800f7a5..de965026207 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 a08cfb34377..ad217c48e9b 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 d9ff654ba41..7f669668bdb 100644 --- a/gcc/config/arm/t-arm +++ b/gcc/config/arm/t-arm @@ -144,4 +144,8 @@ 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 diff --git a/gcc/config/default-d.c b/gcc/config/default-d.c new file mode 100644 index 00000000000..935ae4f6091 --- /dev/null +++ b/gcc/config/default-d.c @@ -0,0 +1,25 @@ +/* Default D language target hooks initializer. + Copyright (C) 2017 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 +. */ + +#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 00000000000..6f31f8215cb --- /dev/null +++ b/gcc/config/glibc-d.c @@ -0,0 +1,73 @@ +/* Glibc support needed only by D front-end. + Copyright (C) 2017 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 +. */ + +#include "config.h" +#include "system.h" +#include "coretypes.h" +#include "tm.h" +#include "memmodel.h" +#include "d/d-target.h" +#include "d/d-target-def.h" +#include "tm_p.h" + +/* Implement TARGET_D_OS_VERSIONS for Glibc targets. */ + +static void +glibc_d_os_builtins (void) +{ + if (OPTION_GLIBC) + d_add_builtin_version ("CRuntime_Glibc"); + else if (OPTION_UCLIBC) + d_add_builtin_version ("CRuntime_UClibc"); + else if (OPTION_BIONIC) + d_add_builtin_version ("CRuntime_Bionic"); + else if (OPTION_MUSL) + d_add_builtin_version ("CRuntime_Musl"); + + 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 42be8952337..b6c2fbde84c 100644 --- a/gcc/config/gnu.h +++ b/gcc/config/gnu.h @@ -31,3 +31,6 @@ along with GCC. If not, see . builtin_assert ("system=unix"); \ builtin_assert ("system=posix"); \ } while (0) + +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("Hurd") diff --git a/gcc/config/i386/i386-d.c b/gcc/config/i386/i386-d.c new file mode 100644 index 00000000000..2a1790178e2 --- /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 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 +. */ + +#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 fbe9f271434..b9bf720e202 100644 --- a/gcc/config/i386/i386-protos.h +++ b/gcc/config/i386/i386-protos.h @@ -243,6 +243,9 @@ extern bool ix86_bnd_prefixed_insn_p (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 899ba8b3706..38b03a72a6b 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -668,6 +668,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 6380639b204..ad4e2518217 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 0a8524bfbe2..1587c8930e7 100644 --- a/gcc/config/i386/t-i386 +++ b/gcc/config/i386/t-i386 @@ -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) + 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 26a8cef8753..3fe857c6394 100644 --- a/gcc/config/kfreebsd-gnu.h +++ b/gcc/config/kfreebsd-gnu.h @@ -29,6 +29,9 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("FreeBSD") + #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..fbb5a83505a 100644 --- a/gcc/config/kopensolaris-gnu.h +++ b/gcc/config/kopensolaris-gnu.h @@ -30,5 +30,8 @@ along with GCC; see the file COPYING3. If not see } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("Solaris") + #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..8dbe7ea5ed1 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 b3a9e85e77f..950f3a557b1 100644 --- a/gcc/config/linux.h +++ b/gcc/config/linux.h @@ -53,6 +53,9 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see builtin_assert ("system=posix"); \ } while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("linux") + /* 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..2035ef29d22 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 00000000000..7e940d1499f --- /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 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 +. */ + +#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 1c4167a836a..8741e5c2f9b 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -386,4 +386,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 a2d8c7c1350..f9a4e30c98d 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -644,6 +644,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 774506e3279..79f27227851 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 684afd6c190..390a1182d6a 100644 --- a/gcc/config/powerpcspe/linux.h +++ b/gcc/config/powerpcspe/linux.h @@ -57,6 +57,9 @@ } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("linux") + #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 88cbeca6fe9..54bd279c736 100644 --- a/gcc/config/powerpcspe/linux64.h +++ b/gcc/config/powerpcspe/linux64.h @@ -391,6 +391,9 @@ extern int dot_symbols; } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("linux") + #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 00000000000..3f7c4e1807d --- /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 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 +. */ + +#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 78baeecad38..a0678a297d4 100644 --- a/gcc/config/powerpcspe/powerpcspe-protos.h +++ b/gcc/config/powerpcspe/powerpcspe-protos.h @@ -233,6 +233,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.h b/gcc/config/powerpcspe/powerpcspe.h index 8381785067c..69ff0cb1561 100644 --- a/gcc/config/powerpcspe/powerpcspe.h +++ b/gcc/config/powerpcspe/powerpcspe.h @@ -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() \ diff --git a/gcc/config/powerpcspe/t-powerpcspe b/gcc/config/powerpcspe/t-powerpcspe index fba99508757..8cc0f14969d 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/rs6000/linux.h b/gcc/config/rs6000/linux.h index e4158d26abb..e751c09856a 100644 --- a/gcc/config/rs6000/linux.h +++ b/gcc/config/rs6000/linux.h @@ -57,6 +57,9 @@ } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("linux") + #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 13b769211b1..336aeab2aa4 100644 --- a/gcc/config/rs6000/linux64.h +++ b/gcc/config/rs6000/linux64.h @@ -391,6 +391,9 @@ extern int dot_symbols; } \ while (0) +#define GNU_USER_TARGET_D_OS_VERSIONS() \ + builtin_version ("linux") + #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 00000000000..3f7c4e1807d --- /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 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 +. */ + +#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 781349b850e..b4cfd56c341 100644 --- a/gcc/config/rs6000/rs6000-protos.h +++ b/gcc/config/rs6000/rs6000-protos.h @@ -234,6 +234,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/t-rs6000 b/gcc/config/rs6000/t-rs6000 index 304f322f435..7bd4bef9f80 100644 --- a/gcc/config/rs6000/t-rs6000 +++ b/gcc/config/rs6000/t-rs6000 @@ -26,6 +26,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) diff --git a/gcc/config/s390/s390-d.c b/gcc/config/s390/s390-d.c new file mode 100644 index 00000000000..477982fd5d0 --- /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 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 +. */ + +#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 84b30704d9e..b8d84900f72 100644 --- a/gcc/config/s390/s390-protos.h +++ b/gcc/config/s390/s390-protos.h @@ -153,3 +153,6 @@ 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); diff --git a/gcc/config/s390/s390.h b/gcc/config/s390/s390.h index 52eee948bdf..6d995ceda78 100644 --- a/gcc/config/s390/s390.h +++ b/gcc/config/s390/s390.h @@ -194,6 +194,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 69ce684669a..ee11f482561 100644 --- a/gcc/config/s390/t-s390 +++ b/gcc/config/s390/t-s390 @@ -25,3 +25,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 00000000000..59de10a02c8 --- /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 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 +. */ + +#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 507f0b1bd41..bbd65ebc0c0 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 9ac741f569b..91caeb23a4e 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 f512937cfa9..6883649b797 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 99094f8d020..25bb4fea3fd 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) diff --git a/gcc/configure b/gcc/configure index 13f97cd3663..ef5b9385804 100755 --- a/gcc/configure +++ b/gcc/configure @@ -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 @@ -11802,6 +11805,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. @@ -12171,6 +12175,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 @@ -18440,7 +18459,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18443 "configure" +#line 18462 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -18546,7 +18565,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 18549 "configure" +#line 18568 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -29541,6 +29560,9 @@ fi + + + # Echo link setup. if test x${build} = x${host} ; then if test x${host} = x${target} ; then diff --git a/gcc/configure.ac b/gcc/configure.ac index 82711389281..88dc0bd57e5 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1724,6 +1724,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. @@ -1946,6 +1947,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 @@ -6211,6 +6227,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) @@ -6218,6 +6236,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) diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 8f503e1904e..a9470d0452f 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -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 @@ -10501,6 +10510,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 diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 15b3f1f6771..77748cc182b 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -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 @@ -7277,6 +7286,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 diff --git a/gcc/genhooks.c b/gcc/genhooks.c index fb380c586ff..cefe0a14831 100644 --- a/gcc/genhooks.c +++ b/gcc/genhooks.c @@ -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 }; From patchwork Mon Oct 2 09:05:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 820394 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463313-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="rDxR6L2a"; dkim-atps=neutral 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 3y5GV23kB7z9s4s for ; Mon, 2 Oct 2017 20:05:45 +1100 (AEDT) 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:cc:content-type; q=dns; s=default; b=Lqm1+nTFtRcSn3ILT2TbDDf54vBVzekoN5DhTsR9CAE 4zsnqSBVKDBNIfDJq4dsx7LLgkJ/M9iRyVFolS+j+XWo0zscDez0TkyE8KXMpBt9 B5Hdv5MWkBBBQfeLalA/Na0US+uJtGiY54x3sDecvFIWUjtDXdsaVF1kBnsfugO8 = 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:cc:content-type; s=default; bh=qnjBSrWecaypHGZ3nDX0cTU4iNw=; b=rDxR6L2auxZjFYdut SN187pSD5h0If0GZy3R3MfWRrGXZfb7QVQxsmwnv/3DXN/AnGlt302sZC3lz75u2 eU1WsJ0s+V0T7wrEZB91/kDZ/g8xiyF72rdn0i810gGVXL7GSUcNC2yro2S924TH CXAD/rpAYDM/Swwv/jHRbl8B4M= Received: (qmail 62369 invoked by alias); 2 Oct 2017 09:05:19 -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 62349 invoked by uid 89); 2 Oct 2017 09:05:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.3 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=Path, sk:shared-, tmpdir, sk:shared X-HELO: mail-qt0-f176.google.com Received: from mail-qt0-f176.google.com (HELO mail-qt0-f176.google.com) (209.85.216.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 09:05:13 +0000 Received: by mail-qt0-f176.google.com with SMTP id b21so535668qte.2 for ; Mon, 02 Oct 2017 02:05:13 -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:cc; bh=4Oxf4xi+Md1biGN3sPSn5bfAuc9gYd0RrGZPr0R+Bn0=; b=TKkIOQsGOEi1VADXKOlNn92pE5G/fZWRwvoz7Ez50LRhxDNIwIXBTg6NNZZCoFj7fk 1mD67HASsYewSoSM3aokR9eYMqLn1SrF98nSnehclViem63qL2fJfpZmDrRhlyqp3I2P vvsWV6ZO/HikaiK4c2ycM5PGwjgbybJOTZJLdLzEHpT6VLBSixXiTqd/5tRw0DcryJLE hpXwIbS7P/nexIXdyn2EOUbmVNyzp9/JRbDxRJzf7AuoUY4HkpZV81gxKiF26gKmevPm T/wuEg3eEKk2STaBdi6/o92EyctalBR4LSwYm4f1LJp/dZCN3QHkbto9C72Ghio0m7P0 oTDA== X-Gm-Message-State: AMCzsaXKiBfJW5JfWQiYN65NBc950CQnT0K/0b2WNRci6zz+EuksE6HQ 5nKQI8/jZbbsyk85qvpUmjJuSBZ5UXh63ug0NqeJng== X-Google-Smtp-Source: AOwi7QBA62Do+xVqzPNGvsqBoc1u2hQnR8MJDPi4y93EvXJZS6+wCOy5zhu82/lW597KPZtKK9eQtej5Hh+M+4A2XF8= X-Received: by 10.237.58.7 with SMTP id n7mr18253623qte.205.1506935111470; Mon, 02 Oct 2017 02:05:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.172.6 with HTTP; Mon, 2 Oct 2017 02:05:10 -0700 (PDT) From: Iain Buclaw Date: Mon, 2 Oct 2017 11:05:10 +0200 Message-ID: Subject: [PATCH v3 9/14] D: D2 Testsuite Dejagnu files. To: gcc-patches Cc: Mike Stump , Jeff Law X-IsSubscribed: yes No changes from previous patch, just a refresh. Mike, you don't need to look at this, just an FYI. diff --git a/gcc/testsuite/gdc.test/d_do_test.exp b/gcc/testsuite/gdc.test/d_do_test.exp new file mode 100644 index 00000000000..4c03989443c --- /dev/null +++ b/gcc/testsuite/gdc.test/d_do_test.exp @@ -0,0 +1,387 @@ +# Copyright (C) 2012-2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# Test using the DMD testsuite. +# Load support procs. +load_lib gdc-dg.exp + +# +# Convert DMD arguments to GDC equivalent +# + +proc gdc-convert-args { base args } { + set out "" + + foreach arg [split [lindex $args 0] " "] { + # List of switches kept in ASCII collated order. + if { [regexp -- {^-I([\w+/-]+)} $arg pattern path] } { + lappend out "-I$base/$path" + + } elseif { [regexp -- {^-J([\w+/-]+)} $arg pattern path] } { + lappend out "-J$base/$path" + + } elseif [string match "-allinst" $arg] { + lappend out "-femit-templates" + + } elseif { [string match "-boundscheck" $arg] + || [string match "-boundscheck=on" $arg] } { + lappend out "-fbounds-check" + + } elseif { [string match "-boundscheck=off" $arg] + || [string match "-noboundscheck" $arg] } { + lappend out "-fno-bounds-check" + + } elseif [string match "-boundscheck=safeonly" $arg] { + lappend out "-fbounds-check=safeonly" + + } elseif [string match "-c" $arg] { + lappend out "-c" + + } elseif [string match "-d" $arg] { + lappend out "-Wno-deprecated" + + } elseif [string match "-de" $arg] { + lappend out "-Wdeprecated" + lappend out "-Werror" + + } elseif [string match "-debug" $arg] { + lappend out "-fdebug" + + } elseif [string match "-dip1000" $arg] { + lappend out "-ftransition=safe" + + } elseif [string match "-dip25" $arg] { + lappend out "-ftransition=dip25" + + } elseif [string match "-dw" $arg] { + lappend out "-Wdeprecated" + lappend out "-Wno-error" + + } elseif [string match "-fPIC" $arg] { + lappend out "-fPIC" + + } elseif { [string match "-g" $arg] + || [string match "-gc" $arg] } { + lappend out "-g" + + } elseif [string match "-inline" $arg] { + lappend out "-finline-functions" + + } elseif [regexp -- {^-mv=([\w+=./-]+)} $arg pattern value] { + lappend out "-fmodule-filepath=$value" + + } elseif [string match "-O" $arg] { + lappend out "-O2" + + } elseif [string match "-property" $arg] { + lappend out "-fproperty" + + } elseif [string match "-release" $arg] { + lappend out "-frelease" + + } elseif [regexp -- {^-transition=(\w+)} $arg pattern value] { + lappend out "-ftransition=$value" + + } elseif [string match "-unittest" $arg] { + lappend out "-funittest" + + } elseif [string match "-verrors=spec" $arg] { + lappend out "-Wspeculative" + + } elseif [regexp -- {^-verrors=(\d+)} $arg pattern num] { + lappend out "-fmax-errors=$num" + + } elseif [regexp -- {^-version=(\w+)} $arg pattern value] { + lappend out "-fversion=$value" + + } elseif [string match "-w" $arg] { + lappend out "-Wall" + lappend out "-Werror" + + } elseif [string match "-wi" $arg] { + lappend out "-Wall" + lappend out "-Wno-error" + + } else { + # print "Unhandled Argument: $arg" + } + } + + return $out +} + +proc gdc-copy-extra { base extra } { + # Split base, folder/file. + set type [file dirname $extra] + + # print "Filename: $base - $extra" + + set fdin [open $base/$extra r] + fconfigure $fdin -encoding binary + + file mkdir $type + set fdout [open $extra w] + fconfigure $fdout -encoding binary + + while { [gets $fdin copy_line] >= 0 } { + set out_line $copy_line + puts $fdout $out_line + } + + close $fdin + close $fdout + + return $extra +} + +# +# Translate DMD test directives to dejagnu equivalent. +# +# COMPILE_SEPARATELY: Not handled. +# EXECUTE_ARGS: Parameters to add to the execution of the test. +# EXTRA_SOURCES: List of extra sources to build and link along with +# the test. +# EXTRA_FILES: List of extra files to copy for the test runs. +# PERMUTE_ARGS: The set of arguments to permute in multiple compiler +# invocations. An empty set means only one permutation +# with no arguments. +# TEST_OUTPUT: The output expected from the compilation. +# POST_SCRIPT: Not handled. +# REQUIRED_ARGS: Arguments to add to the compiler command line. +# DISABLED: Not handled. +# + +proc dmd2dg { base test } { + global DEFAULT_DFLAGS + global PERMUTE_ARGS + global GDC_EXECUTE_ARGS + + set PERMUTE_ARGS $DEFAULT_DFLAGS + set GDC_EXECUTE_ARGS "" + + # Split base, folder/file. + set type [file dirname $test] + + # print "Filename: $base - $test" + + set fdin [open $base/$test r] + #fconfigure $fdin -encoding binary + + file mkdir $type + set fdout [open $test w] + #fconfigure $fdout -encoding binary + + while { [gets $fdin copy_line] >= 0 } { + set out_line $copy_line + + if [regexp -- {COMPILE_SEPARATELY} $copy_line] { + # COMPILE_SEPARATELY is not handled. + regsub -- {COMPILE_SEPARATELY.*$} $copy_line "" out_line + + } elseif [regexp -- {DISABLED} $copy_line] { + # DISABLED is not handled. + regsub -- {DISABLED.*$} $copy_line "" out_line + + } elseif [regexp -- {POST_SCRIPT} $copy_line] { + # POST_SCRIPT is not handled + regsub -- {POST_SCRIPT.*$} $copy_line "" out_line + + } elseif [regexp -- {PERMUTE_ARGS\s*:\s*(.*)} $copy_line match args] { + # PERMUTE_ARGS is handled by gdc-do-test. + set PERMUTE_ARGS [gdc-convert-args $base $args] + regsub -- {PERMUTE_ARGS.*$} $copy_line "" out_line + + } elseif [regexp -- {EXECUTE_ARGS\s*:\s*(.*)} $copy_line match args] { + # EXECUTE_ARGS is handled by gdc_load. + foreach arg $args { + lappend GDC_EXECUTE_ARGS $arg + } + regsub -- {EXECUTE_ARGS.*$} $copy_line "" out_line + + } elseif [regexp -- {REQUIRED_ARGS\s*:\s*(.*)} $copy_line match args] { + # Convert all listed arguments to from dmd to gdc-style. + set new_option "{ dg-additional-options \"[gdc-convert-args $base $args]\" }" + regsub -- {REQUIRED_ARGS.*$} $copy_line $new_option out_line + + } elseif [regexp -- {EXTRA_SOURCES\s*:\s*(.*)} $copy_line match sources] { + # Copy all sources to the testsuite build directory. + foreach import $sources { + # print "Import: $base $type/$import" + gdc-copy-extra $base "$type/$import" + } + set new_option "{ dg-additional-sources \"$sources\" }" + regsub -- {EXTRA_SOURCES.*$} $copy_line $new_option out_line + + } elseif [regexp -- {EXTRA_CPP_SOURCES\s*:\s*(.*)} $copy_line match sources] { + # Copy all sources to the testsuite build directory. + foreach import $sources { + # print "Import: $base $type/$import" + gdc-copy-extra $base "$type/$import" + } + set new_option "{ dg-additional-sources \"$sources\" }" + regsub -- {EXTRA_CPP_SOURCES.*$} $copy_line $new_option out_line + + } elseif [regexp -- {EXTRA_FILES\s*:\s*(.*)} $copy_line match files] { + # Copy all sources to the testsuite build directory. + foreach import $files { + # print "Import: $base $type/$import" + gdc-copy-extra $base "$type/$import" + } + set new_option "{ dg-additional-files \"$files\" }" + regsub -- {EXTRA_FILES.*$} $copy_line $new_option out_line + + } + + puts $fdout $out_line + } + + # Add specific options for test type + + # DMD's testsuite is extremely verbose, compiler messages from constructs + # such as pragma(msg, ...) would otherwise cause tests to fail. + set out_line "// { dg-prune-output .* }" + puts $fdout $out_line + + # Since GCC 6-20160131 blank lines are not allowed in the output by default. + dg-allow-blank-lines-in-output { 1 } + + # Compilable files are successful if an output is generated. + # Fail compilable are successful if an output is not generated. + # Runnable must compile, link, and return 0 to be successful by default. + switch [file dirname $test] { + compilable { + set out_line "// { dg-final { output-exists } }" + puts $fdout $out_line + } + + fail_compilation { + set out_line "// { dg-final { output-exists-not } }" + puts $fdout $out_line + } + } + + close $fdin + close $fdout + + return $test +} + +proc gdc-permute-options { options } { + set result { } + set n [expr 1<<[llength $options]] + for { set i 0 } { $i<$n } { incr i } { + set option "" + for { set j 0 } { $j<[llength $options] } { incr j } { + if [expr $i & 1 << $j] { + append option [lindex $options $j] + append option " " + } + } + lappend result $option + + } + return $result +} + + +proc gdc-do-test { } { + global srcdir subdir + global dg-do-what-default + global verbose + + # If a testcase doesn't have special options, use these. + global DEFAULT_DFLAGS + if ![info exists DEFAULT_DFLAGS] then { + set DEFAULT_DFLAGS "-g -O2 -frelease" + #set DEFAULT_DFLAGS "-O2" + } + + # These are special options to use on testcase, and override DEFAULT_DFLAGS + global PERMUTE_ARGS + + # Set if an extra option should be passed to link to shared druntime. + global SHARED_OPTION + + # Additional arguments for gdc_load + global GDC_EXECUTE_ARGS + + # Initialize `dg'. + dg-init + + # Main loop. + + # set verbose 1 + # set dg-final-code "" + # Find all tests and pass to routine. + foreach test [lsort [find $srcdir/$subdir *]] { + regexp -- "(.*)/(.+)/(.+)\.(.+)$" $test match base dir name ext + + # Skip invalid test directory + if { [lsearch "runnable compilable fail_compilation" $dir] == -1 } { + continue + } + + # Skip invalid test extensions + if { [lsearch "d" $ext] == -1 } { + continue + } + + # Convert to DG test. + set imports [format "-I%s/%s" $base $dir] + set filename [dmd2dg $base $dir/$name.$ext] + + if { $dir == "runnable" } { + append PERMUTE_ARGS " $SHARED_OPTION" + } + set options [gdc-permute-options $PERMUTE_ARGS] + + switch $dir { + runnable { + for { set i 0 } { $i<[llength $options] } { incr i } { + set flags [lindex $options $i] + set dg-do-what-default "run" + gdc-dg-runtest $filename $flags $imports + } + } + + compilable { + for { set i 0 } { $i<[llength $options] } { incr i } { + set flags [lindex $options $i] + #set dg-do-what-default "compile" + set dg-do-what-default "assemble" + gdc-dg-runtest $filename $flags $imports + } + } + + fail_compilation { + for { set i 0 } { $i<[llength $options] } { incr i } { + set flags [lindex $options $i] + set dg-do-what-default "assemble" + gdc-dg-runtest $filename $flags $imports + } + } + } + + # Cleanup + #file delete $filename + } + + # All done. + dg-finish +} + +gdc-do-test + diff --git a/gcc/testsuite/lib/gdc-dg.exp b/gcc/testsuite/lib/gdc-dg.exp new file mode 100644 index 00000000000..d9eae5b9035 --- /dev/null +++ b/gcc/testsuite/lib/gdc-dg.exp @@ -0,0 +1,88 @@ +# Copyright (C) 2012-2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +load_lib gcc-dg.exp + +# Define gdc callbacks for dg.exp. + +proc gdc-dg-test { prog do_what extra_tool_flags } { + set result \ + [gcc-dg-test-1 gdc_target_compile $prog $do_what $extra_tool_flags] + + set comp_output [lindex $result 0] + set output_file [lindex $result 1] + + return [list $comp_output $output_file] +} + +proc gdc-dg-prune { system text } { + return [gcc-dg-prune $system $text] +} + +# Utility routines. + +# +# Modified dg-runtest that can cycle through a list of optimization options +# as c-torture does. +# + +proc gdc-dg-runtest { testcases flags default-extra-flags } { + global runtests + + foreach test $testcases { + # If we're only testing specific files and this isn't one of + # them, skip it. + if ![runtest_file_p $runtests $test] { + continue + } + + # Use TORTURE_OPTIONS to cycle through an option list. + if [torture-options-exist] then { + global torture_with_loops + set option_list $torture_with_loops + } else { + set option_list { "" } + } + + set nshort [file tail [file dirname $test]]/[file tail $test] + + foreach flags_t $option_list { + verbose "Testing $nshort, $flags $flags_t" 1 + dg-test $test "$flags $flags_t" ${default-extra-flags} + } + } +} + +# +# gdc_load -- wrapper around default gdc_load to handle tests that +# require program arguments passed to them. +# + +if { [info procs gdc_load] != [list] \ + && [info procs prev_gdc_load] == [list] } { + rename gdc_load prev_gdc_load + + proc gdc_load { program args } { + global GDC_EXECUTE_ARGS + if [info exists GDC_EXECUTE_ARGS] then { + set args [concat "{$GDC_EXECUTE_ARGS}"] + } + #print "Running: $program [lindex $args 0]" + set result [eval [list prev_gdc_load $program] $args ] + return $result + } +} + diff --git a/gcc/testsuite/lib/gdc.exp b/gcc/testsuite/lib/gdc.exp new file mode 100644 index 00000000000..30b73f62672 --- /dev/null +++ b/gcc/testsuite/lib/gdc.exp @@ -0,0 +1,277 @@ +# Copyright (C) 2012-2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# +# gdc support library routines +# + +load_lib prune.exp +load_lib gcc-defs.exp +load_lib timeout.exp +load_lib target-libpath.exp + +# +# GDC_UNDER_TEST is the compiler under test. +# + +set gdc_compile_options "" + + +# +# gdc_version -- extract and print the version number of the compiler +# + +proc gdc_version { } { + global GDC_UNDER_TEST + + gdc_init + + # ignore any arguments after the command + set compiler [lindex $GDC_UNDER_TEST 0] + + # verify that the compiler exists + if { [is_remote host] || [which $compiler] != 0 } then { + set tmp [remote_exec host "$compiler -v"] + set status [lindex $tmp 0] + set output [lindex $tmp 1] + regexp " version \[^\n\r\]*" $output version + if { $status == 0 && [info exists version] } then { + if [is_remote host] { + clone_output "$compiler $version\n" + } else { + clone_output "[which $compiler] $version\n" + } + } else { + clone_output "Couldn't determine version of [which $compiler]\n" + } + } else { + # compiler does not exist (this should have already been detected) + warning "$compiler does not exist" + } +} + +# +# gdc_include_flags -- include flags for the gcc tree structure +# + +proc gdc_include_flags { paths } { + global srcdir + global TESTING_IN_BUILD_TREE + + set flags "" + + if { [is_remote host] || ![info exists TESTING_IN_BUILD_TREE] } { + return "${flags}" + } + + set gccpath ${paths} + set target [file tail [file normalize ${paths}]] + + if { $gccpath != "" } { + if [file exists "${gccpath}/libphobos/libdruntime"] { + append flags "-I${gccpath}/libphobos/libdruntime " + } + } + append flags "-I${srcdir}/../../libphobos/libdruntime " + append flags "-I${srcdir}/../../libphobos/src " + + # For the tests that mix C++ and D, we should try and handle this better. + if { $gccpath != "" } { + if [file exists "${gccpath}/libstdc++-v3/include"] { + append flags "-I${gccpath}/libstdc++-v3/include " + append flags "-I${gccpath}/libstdc++-v3/include/$target " + } + } + append flags "-I${srcdir}/../../libstdc++-v3/libsupc++" +} + +# +# gdc_link_flags -- linker flags for the gcc tree structure +# + +proc gdc_link_flags { paths } { + global srcdir + global ld_library_path + global GDC_UNDER_TEST + global shlib_ext + global SHARED_OPTION + + set gccpath ${paths} + set libio_dir "" + set flags "" + set ld_library_path "." + set shlib_ext [get_shlib_extension] + set SHARED_OPTION "" + verbose "shared lib extension: $shlib_ext" + + if { $gccpath != "" } { + # Path to libgphobos.spec. + append flags "-B${gccpath}/libphobos/src " + + if { [file exists "${gccpath}/libphobos/src/.libs/libgphobos.a"] \ + || [file exists "${gccpath}/libphobos/src/.libs/libgphobos.${shlib_ext}"] } { + append flags "-L${gccpath}/libphobos/src/.libs " + append ld_library_path ":${gccpath}/libphobos/src/.libs" + } + if { [file exists "${gccpath}/libphobos/libdruntime/.libs/libgdruntime.a"] \ + || [file exists "${gccpath}/libphobos/libdruntime/.libs/libgdruntime.${shlib_ext}"] } { + append flags "-L${gccpath}/libphobos/libdruntime/.libs " + append ld_library_path ":${gccpath}/libphobos/libdruntime/.libs" + } + # Static linking is default. If only the shared lib is available adjust + # flags to always use it. If both are available, set SHARED_OPTION which + # will be added to PERMUTE_ARGS + if { [file exists "${gccpath}/libphobos/libdruntime/.libs/libgdruntime.${shlib_ext}"] } { + if { [file exists "${gccpath}/libphobos/libdruntime/.libs/libgdruntime.a"] } { + set SHARED_OPTION "-shared-libphobos" + } else { + append flags "-shared-libphobos " + } + } + if [file exists "${gccpath}/libiberty/libiberty.a"] { + append flags "-L${gccpath}/libiberty " + } + # For the tests that mix C++ and D, we should try and handle this better. + if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \ + || [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } { + append flags "-L${gccpath}/libstdc++-v3/src/.libs " + append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs" + } + append ld_library_path [gcc-set-multilib-library-path $GDC_UNDER_TEST] + } else { + global tool_root_dir + + set libphobos [lookfor_file ${tool_root_dir} libgphobos] + if { $libphobos != "" } { + append flags "-B${libphobos} -L${libphobos} " + append ld_library_path ":${libphobos}" + } + set libdruntime [lookfor_file ${tool_root_dir} libgdruntime] + if { $libdruntime != "" } { + append flags "-L${libdruntime} " + append ld_library_path ":${libdruntime}" + } + set libiberty [lookfor_file ${tool_root_dir} libiberty] + if { $libiberty != "" } { + append flags "-L${libiberty} " + } + } + + set_ld_library_path_env_vars + + return "$flags" +} + +# +# gdc_init -- called at the start of each subdir of tests +# + +proc gdc_init { args } { + global subdir + global gdc_initialized + global base_dir + global tmpdir + global libdir + global gluefile wrap_flags + global objdir srcdir + global ALWAYS_DFLAGS + global TOOL_EXECUTABLE TOOL_OPTIONS + global GDC_UNDER_TEST + global TESTING_IN_BUILD_TREE + global TEST_ALWAYS_FLAGS + + # We set LC_ALL and LANG to C so that we get the same error messages as expected. + setenv LC_ALL C + setenv LANG C + + if ![info exists GDC_UNDER_TEST] then { + if [info exists TOOL_EXECUTABLE] { + set GDC_UNDER_TEST $TOOL_EXECUTABLE + } else { + if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } { + set GDC_UNDER_TEST [transform gdc] + } else { + set GDC_UNDER_TEST [findfile $base_dir/../../gdc "$base_dir/../../gdc -B$base_dir/../../" [findfile $base_dir/gdc "$base_dir/gdc -B$base_dir/" [transform gdc]]] + } + } + } + + if ![is_remote host] { + if { [which $GDC_UNDER_TEST] == 0 } then { + perror "GDC_UNDER_TEST ($GDC_UNDER_TEST) does not exist" + exit 1 + } + } + if ![info exists tmpdir] { + set tmpdir "/tmp" + } + + if [info exists gluefile] { + unset gluefile + } + + gdc_maybe_build_wrapper "${tmpdir}/d-testglue.o" + + set ALWAYS_DFLAGS "" + + # TEST_ALWAYS_FLAGS are flags that should be passed to every + # compilation. They are passed first to allow individual + # tests to override them. + if [info exists TEST_ALWAYS_FLAGS] { + lappend ALWAYS_DFLAGS "additional_flags=$TEST_ALWAYS_FLAGS" + } + + if ![is_remote host] { + if [info exists TOOL_OPTIONS] { + lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs ${TOOL_OPTIONS}] ]" + lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs ${TOOL_OPTIONS}] ]" + } else { + lappend ALWAYS_DFLAGS "additional_flags=[gdc_include_flags [get_multilibs] ]" + lappend ALWAYS_DFLAGS "ldflags=[gdc_link_flags [get_multilibs] ]" + } + } + + if [info exists TOOL_OPTIONS] { + lappend ALWAYS_DFLAGS "additional_flags=$TOOL_OPTIONS" + } + + verbose -log "ALWAYS_DFLAGS set to $ALWAYS_DFLAGS" + + verbose "gdc is initialized" 3 +} + +# +# gdc_target_compile -- compile a source file +# + +proc gdc_target_compile { source dest type options } { + global tmpdir + global gluefile wrap_flags + global ALWAYS_DFLAGS + global GDC_UNDER_TEST + + if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } { + lappend options "libs=${gluefile}" + lappend options "ldflags=${wrap_flags}" + } + + lappend options "timeout=[timeout_value]" + lappend options "compiler=$GDC_UNDER_TEST" + + set options [concat "$ALWAYS_DFLAGS" $options] + set options [dg-additional-files-options $options $source] + return [target_compile $source $dest $type $options] +} From patchwork Mon Oct 2 09:06:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 820395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463315-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="s/xLlJVz"; dkim-atps=neutral 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 3y5GYm42hxz9sDB for ; Mon, 2 Oct 2017 20:09:00 +1100 (AEDT) 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:cc:content-type; q=dns; s=default; b=l6JkUQS1tcBCR3mBe8nCD9QJepzCI4ZkSnIGn29uwWN 0unsCoXWBAPNWdr2dOhLDi1iEI290+zAmUJe+1NIgU0jEh2Ya0cU2fxGx4/JZfGg vjOxQsQCXXqTHTOnG30MjaHUVeg3TLlZ/IZnJCetYYF9FUZs+8AvwIzp5/KQJIjE = 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:cc:content-type; s=default; bh=eWA3B2UedKx+gtw8xTlV8rh6qgk=; b=s/xLlJVzH1s6Ly/ny iROfNYTsg2SvaYL0zUm4020StUZ/dRCP/ufRPq89XNV/kt3iWeXb/Ge5ViFe/myN w6D5whLaYpEg2t7+U0qMza9QcynABC3QTay8+BClDds6cZDGIrTrJy2dYsYhJnEU 8zmlFV5+LkYt1pV+uG4u0E2w9M= Received: (qmail 73361 invoked by alias); 2 Oct 2017 09:07:13 -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 73162 invoked by uid 89); 2 Oct 2017 09:07:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.7 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=ca, by, (unknown), sa X-HELO: mail-qk0-f196.google.com Received: from mail-qk0-f196.google.com (HELO mail-qk0-f196.google.com) (209.85.220.196) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Oct 2017 09:06:55 +0000 Received: by mail-qk0-f196.google.com with SMTP id q8so3477714qkl.5 for ; Mon, 02 Oct 2017 02:06:55 -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:cc; bh=TbdXUaLoUhp5MVDuz1chshhkrQul/klT6hs83+JMPlc=; b=EHcvWl3LyCRa1bjKwG9vxnTpq5W+l+x1cOpN/L72v/S4Cyk3WqNksy6tqg+eUylaDH TJKVkkdidMktddcCgl9P66U+AtiJRDcKdYPS3+G4N8yj/7ct9KVZchVM0cEVlU9iTtBq 6y6cgf+ZdyTDiaLI4vInBbqxuf1leRwRt5NrgFCUgnoS/ddJN7Z6Tli6x4keaHEs9vHn afL/sYivMi5BAfrgKEV0EC1GZUPW33NhDjXrK/U2ezn751YFQF4WlWo32a5rtOb/T786 aN9WjNHoSXVw7pNTU+AbvwnpDDS74Sx6hLzaxP218cFuySdySBaPJhYvPr7izJM+WdLO oSNQ== X-Gm-Message-State: AMCzsaUhXKsZVg4hLhY400heEAa4cwMJa/Kwx8/fKtOWGffZIUaJNqLg oIW9vFS6JEjTav7B0tzg3xXXwKZFyrh3NjJuAdy/MQ== X-Google-Smtp-Source: AOwi7QDLFAyYCilCDlxzAiKhJiPkx9bSAN00FSeXCd+QePu65UlDjYBBi8kslW5FKzwHY19Ua5fD0+q6rQjFb9rSAZM= X-Received: by 10.55.20.78 with SMTP id e75mr14271423qkh.250.1506935213477; Mon, 02 Oct 2017 02:06:53 -0700 (PDT) MIME-Version: 1.0 Received: by 10.12.172.6 with HTTP; Mon, 2 Oct 2017 02:06:52 -0700 (PDT) From: Iain Buclaw Date: Mon, 2 Oct 2017 11:06:52 +0200 Message-ID: Subject: [PATCH v3 10/14] D: GDC Testsuite tests and config. To: gcc-patches Cc: Mike Stump , Jeff Law X-IsSubscribed: yes This was split out from patch 9/14. Added test directories for ASAN and LTO tests. Regards Iain. diff --git a/gcc/testsuite/gdc.dg/asan/asan.exp b/gcc/testsuite/gdc.dg/asan/asan.exp new file mode 100644 index 00000000000..83bff4693e7 --- /dev/null +++ b/gcc/testsuite/gdc.dg/asan/asan.exp @@ -0,0 +1,32 @@ +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# Load support procs. +load_lib gdc-dg.exp +load_lib asan-dg.exp + +# Initialize `dg'. +dg-init +asan_init + +# Main loop. +if [check_effective_target_fsanitize_address] { + gdc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.d]] "" "" +} + +# All done. +asan_finish +dg-finish diff --git a/gcc/testsuite/gdc.dg/asan/gdc272.d b/gcc/testsuite/gdc.dg/asan/gdc272.d new file mode 100644 index 00000000000..c3de64b4c82 --- /dev/null +++ b/gcc/testsuite/gdc.dg/asan/gdc272.d @@ -0,0 +1,16 @@ +/* { dg-options "-fsanitize=address" } */ +/* { dg-do compile } */ + +module asantests; + + +/******************************************/ + +// Bug 272 + +extern(C) void my_memcmp(const(void) *s1, const(void) *s2); + +void bug(const(char)* p) +{ + my_memcmp(p, "__FILE__".ptr); +} diff --git a/gcc/testsuite/gdc.dg/dg.exp b/gcc/testsuite/gdc.dg/dg.exp new file mode 100644 index 00000000000..736d09ed599 --- /dev/null +++ b/gcc/testsuite/gdc.dg/dg.exp @@ -0,0 +1,50 @@ +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# GCC testsuite that uses the `dg.exp' driver. + +# Load support procs. +load_lib gdc-dg.exp + +# The default option list can be overridden by +# TORTURE_OPTIONS="{ { list1 } ... { listN } }" + +if ![info exists TORTURE_OPTIONS] { + set TORTURE_OPTIONS [list \ + { -O0 } { -O1 } { -O2 } { -O3 } { -Os } \ + { -O0 -frelease } { -O0 -g } { -O0 -frelease -g } \ + { -O1 -frelease } { -O1 -g } { -O1 -frelease -g } \ + { -O2 -frelease } { -O2 -g } { -O2 -frelease -g } \ + { -O3 -frelease } { -O3 -g } { -O3 -frelease -g } \ + { -Os -frelease } { -Os -g } { -Os -frelease -g }] +} + +# Initialize `dg'. +dg-init + +# Initialize use of torture lists. +torture-init +set-torture-options $TORTURE_OPTIONS + +# Main loop. +gdc-dg-runtest [lsort \ + [glob -nocomplain $srcdir/$subdir/*.d ] ] "" "" + +# Finalize use of torture lists. +torture-finish + +# All done. +dg-finish diff --git a/gcc/testsuite/gdc.dg/gdc170.d b/gcc/testsuite/gdc.dg/gdc170.d new file mode 100644 index 00000000000..8ad73c5bad6 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc170.d @@ -0,0 +1,18 @@ +// { dg-options "-I $srcdir/gdc.dg" } +import imports.gdc170a; + +void main() +{ + foo!void.foo1!void(); + foo!void.foo2!void(); + foo!void.foo3(); + foo!void.foo3!void(); + foo!void.foo4(); + foo!void.foo4!void(); + foo!void.foo5!void(null); + foo!void.foo6!void(null); + foo!void.foo7(null); + foo!void.foo7!void(null); + foo!void.foo8(null); + foo!void.foo8!void(null); +} diff --git a/gcc/testsuite/gdc.dg/gdc204.d b/gcc/testsuite/gdc.dg/gdc204.d new file mode 100644 index 00000000000..de90766da0a --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc204.d @@ -0,0 +1,9 @@ +interface I204 +{ + void f(); +} + +class C204 : I204 +{ + void f(); +} diff --git a/gcc/testsuite/gdc.dg/gdc212.d b/gcc/testsuite/gdc.dg/gdc212.d new file mode 100644 index 00000000000..bfe4b960794 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc212.d @@ -0,0 +1,45 @@ +template hasElaborateAssign(S) +{ + enum hasElaborateAssign = is(typeof(S.init.opAssign(rvalueOf!S))) || + is(typeof(lvalueOf!S)) ; +} + +T rvalueOf(T)(); + +T lvalueOf(T)(); + + +template TypeTuple(TList...) +{ + alias TypeTuple = TList; +} + +template Tuple() +{ + struct Tuple + { + void opAssign(R)(R) + { + if (hasElaborateAssign!R) + { + } + } + } +} + +ref emplaceRef() +{ + static if (!hasElaborateAssign!(Tuple!())) + chunk; +} + +class TaskPool +{ + void reduce() + { + Tuple!() seed = void; + Tuple!()[] results; + foreach(i; TypeTuple!(0, 1)) + results[i] = seed; + } +} diff --git a/gcc/testsuite/gdc.dg/gdc213.d b/gcc/testsuite/gdc.dg/gdc213.d new file mode 100644 index 00000000000..3d73add2c90 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc213.d @@ -0,0 +1,13 @@ +import core.simd; + +struct S213 +{ + int4 vec; +} + +void test213() +{ + S213 s, b; + + assert(s == b); +} diff --git a/gcc/testsuite/gdc.dg/gdc218.d b/gcc/testsuite/gdc.dg/gdc218.d new file mode 100644 index 00000000000..257ec1c1f39 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc218.d @@ -0,0 +1,38 @@ +struct S218a +{ + this(int* pdata_) + { + pdata = pdata_; + } + + void opIndexAssign(int, size_t) { } + int* pdata; +}; + +struct S218 +{ + S218a getS218a() + { + return S218a(data.ptr); + } + + int[] data; + int[] tab2; +}; + +S218 f() +{ + S218 r; + + for(int i = 0; i < 1; ++i) + r.getS218a()[0] = 0; + + return r; +} + +S218 var; + +static this() +{ + var = f(); +} diff --git a/gcc/testsuite/gdc.dg/gdc223.d b/gcc/testsuite/gdc.dg/gdc223.d new file mode 100644 index 00000000000..8e44d07a56b --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc223.d @@ -0,0 +1,62 @@ +import gcc.attribute; + +/* Test all gdc supported attributes. */ + +@attribute("forceinline") +void forceinline() +{ +} + +@attribute("noinline") +void noinline() +{ +} + +@attribute("flatten") +void flatten() +{ +} + + +/* Issue 223: Test comparisons which could emit a memcmp */ +struct S223 +{ + long[8] field; +} + +class C223 +{ + long[8] field; +} + +S223 test223_1(); +real test223_2(); +string[long[8]] test223_3(); +C223 test223_4(); +long test223_5(); +long[] test223_6(); +long[8] test223_7(); +C223[8] test223_8(); +void delegate() test223_9(); + +bool test223() +{ + return test223_1() == test223_1() && + test223_1() is test223_1() && + test223_2() == test223_2() && + test223_2() is test223_2() && + test223_3() == test223_3() && + test223_3() is test223_3() && + test223_4() == test223_4() && + test223_4() is test223_4() && + test223_5() == test223_5() && + test223_5() is test223_5() && + test223_6() == test223_6() && + test223_6() is test223_6() && + test223_7() == test223_7() && + test223_7() is test223_7() && + test223_8() == test223_8() && + test223_8() is test223_8() && + test223_9() == test223_9() && + test223_9() is test223_9(); +} diff --git a/gcc/testsuite/gdc.dg/gdc231.d b/gcc/testsuite/gdc.dg/gdc231.d new file mode 100644 index 00000000000..d6dc74dd03a --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc231.d @@ -0,0 +1,16 @@ +// { dg-additional-sources "imports/gdc231a.d" } +module gdc231; + +import imports.gdc231a; + +class Range : Widget +{ + override void* getStruct() + { + return null; + } +} + +void main() +{ +} diff --git a/gcc/testsuite/gdc.dg/gdc239.d b/gcc/testsuite/gdc.dg/gdc239.d new file mode 100644 index 00000000000..1294d1260b7 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc239.d @@ -0,0 +1,7 @@ +// { dg-options "-I $srcdir/gdc.dg" } +import imports.gdc239a; + +class C239 +{ + C239a *foo; +} diff --git a/gcc/testsuite/gdc.dg/gdc241.d b/gcc/testsuite/gdc.dg/gdc241.d new file mode 100644 index 00000000000..d641c88a031 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc241.d @@ -0,0 +1,3 @@ +// { dg-options "-I $srcdir/gdc.dg" } +import imports.gdc241a; +import imports.gdc241b : S241, C241, E241, N241; diff --git a/gcc/testsuite/gdc.dg/gdc242.d b/gcc/testsuite/gdc.dg/gdc242.d new file mode 100644 index 00000000000..cc56005eec5 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc242.d @@ -0,0 +1,21 @@ +struct S242a +{ + enum M = S242a(); + void iter() { } +} + +void test242a() +{ + return S242a.M.iter; +} + +struct S242b +{ + enum M = S242b(); + void iter() { } +} + +void test242b() +{ + S242b.M.iter; +} diff --git a/gcc/testsuite/gdc.dg/gdc251.d b/gcc/testsuite/gdc.dg/gdc251.d new file mode 100644 index 00000000000..884ea733d3a --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc251.d @@ -0,0 +1,5 @@ +// { dg-options "-I $srcdir/gdc.dg" } +module gdc251; + +import imports.gdc251a; +import imports.gdc251b : C251; diff --git a/gcc/testsuite/gdc.dg/gdc253.d b/gcc/testsuite/gdc.dg/gdc253.d new file mode 100644 index 00000000000..8d9f9d82b78 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc253.d @@ -0,0 +1,8 @@ +// { dg-options "-I $srcdir/gdc.dg" } +import imports.gdc253a; + +class C253 : C253a +{ + void test253() { } +} + diff --git a/gcc/testsuite/gdc.dg/gdc254.d b/gcc/testsuite/gdc.dg/gdc254.d new file mode 100644 index 00000000000..e6accb91314 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc254.d @@ -0,0 +1,13 @@ +// { dg-options "-I $srcdir/gdc.dg" } +// { dg-shouldfail "interface function is not implemented" } + +import imports.gdc254a; + +interface A254 +{ + void F(); +} + +class C254 : B254, A254 // { dg-error "interface function '\[^\n\r]*' is not implemented" } +{ +} diff --git a/gcc/testsuite/gdc.dg/gdc255.d b/gcc/testsuite/gdc.dg/gdc255.d new file mode 100644 index 00000000000..b631f29c291 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc255.d @@ -0,0 +1,83 @@ +// Bug 255 + +class C255 +{ + void f2() + { + class C1 + { + void f1() + { + void f0() + { + class C0 + { + void test255() + { + f2(); + } + } + } + } + } + } +} + +class C255a +{ + void f3() + { + class C1 + { + void f2() + { + void f1() + { + void f0() + { + class C0 + { + void test255a() + { + f3(); + } + } + } + } + } + } + } +} + +class C255b +{ + void f4() + { + class C2 + { + void f3() + { + void f2() + { + class C1 + { + void f1() + { + void f0() + { + class C0 + { + void test255b() + { + f4(); + } + } + } + } + } + } + } + } + } +} + diff --git a/gcc/testsuite/gdc.dg/gdc256.d b/gcc/testsuite/gdc.dg/gdc256.d new file mode 100644 index 00000000000..dfc7cf7ed03 --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc256.d @@ -0,0 +1,4 @@ +// { dg-options "-I $srcdir/gdc.dg -I $srcdir/gdc.dg/imports" } +module gdc256; + +import imports.gdcpkg256 : gdc256a; diff --git a/gcc/testsuite/gdc.dg/gdc260.d b/gcc/testsuite/gdc.dg/gdc260.d new file mode 100644 index 00000000000..8a8295c390e --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc260.d @@ -0,0 +1,7 @@ +// { dg-options "-Wall -Werror" } +import gcc.builtins; + +char *bug260(char *buffer) +{ + return __builtin_strcat(&buffer[0], "Li"); +} diff --git a/gcc/testsuite/gdc.dg/gdc261.d b/gcc/testsuite/gdc.dg/gdc261.d new file mode 100644 index 00000000000..4ba031b11aa --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc261.d @@ -0,0 +1,16 @@ +void test261() +{ + class C1 + { + void f1() + { + class C2 + { + void f2() + { + auto v = &f1; + } + } + } + } +} diff --git a/gcc/testsuite/gdc.dg/gdc27.d b/gcc/testsuite/gdc.dg/gdc27.d new file mode 100644 index 00000000000..a1d32c178ac --- /dev/null +++ b/gcc/testsuite/gdc.dg/gdc27.d @@ -0,0 +1,18 @@ +// { dg-additional-sources "imports/gdc27a.d" } +module gdc27; + +import imports.gdc27a; + +interface I_B : I_A +{ + void b(); +} + +abstract class C_B : C_A, I_B +{ + abstract void b(); +} + +void main() +{ +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc170a.d b/gcc/testsuite/gdc.dg/imports/gdc170a.d new file mode 100644 index 00000000000..24a5399192b --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc170a.d @@ -0,0 +1,18 @@ +module imports.gdc170a; + +class bar(T) +{ + void undefined_reference() {} +} + +template foo(T) +{ + bar!T foo1(T2)() if (true) body { return null; } + bar!T foo2(T2)() { return null; } + bar!T foo3(T2 = void)() if (true) body { return null; } + bar!T foo4(T2 = void)() { return null; } + void foo5(T2)(bar!T x) if (true) body {} + void foo6(T2)(bar!T x) {} + void foo7(T2 = void)(bar!T x) if (true) body {} + void foo8(T2 = void)(bar!T x) {} +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc231a.d b/gcc/testsuite/gdc.dg/imports/gdc231a.d new file mode 100644 index 00000000000..c777f1eaf3b --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc231a.d @@ -0,0 +1,24 @@ +module imports.gdc231a; + +interface ImplementorIF +{ + void* getImplementorStruct(); + void* getStruct(); +} + +template ImplementorT() +{ + void* getImplementorStruct() + { + return null; + } +} + +class Widget : ImplementorIF +{ + mixin ImplementorT; + void* getStruct() + { + return null; + } +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc239a.d b/gcc/testsuite/gdc.dg/imports/gdc239a.d new file mode 100644 index 00000000000..3378d74bd9b --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc239a.d @@ -0,0 +1,9 @@ +import std.path : buildNormalizedPath; + +class C239a +{ + auto bar() + { + auto path = buildNormalizedPath("/", "foo"); + } +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc241a.d b/gcc/testsuite/gdc.dg/imports/gdc241a.d new file mode 100644 index 00000000000..b781e3a5394 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc241a.d @@ -0,0 +1,6 @@ +import gdc241; + +S241 *s241; // Use indirectly imported struct +C241 *c241; // Use indirectly imported class +E241 *e241; // Use indirectly imported enum +N241.T *n241; // Use indirectly imported namespace diff --git a/gcc/testsuite/gdc.dg/imports/gdc241b.d b/gcc/testsuite/gdc.dg/imports/gdc241b.d new file mode 100644 index 00000000000..3632575ba0d --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc241b.d @@ -0,0 +1,8 @@ + +class C241 { } + +enum E241 { a } + +struct S241 { } + +extern(C++, N241) { struct T { } } diff --git a/gcc/testsuite/gdc.dg/imports/gdc251a.d b/gcc/testsuite/gdc.dg/imports/gdc251a.d new file mode 100644 index 00000000000..4ba927f91a7 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc251a.d @@ -0,0 +1,6 @@ +module imports.gdc251a; + +import imports.gdc251b; +import gdc251; + +C251 config; diff --git a/gcc/testsuite/gdc.dg/imports/gdc251b.d b/gcc/testsuite/gdc.dg/imports/gdc251b.d new file mode 100644 index 00000000000..e70823f1ed6 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc251b.d @@ -0,0 +1,3 @@ +module imports.gdc251b; + +class C251 { } diff --git a/gcc/testsuite/gdc.dg/imports/gdc253a.d b/gcc/testsuite/gdc.dg/imports/gdc253a.d new file mode 100644 index 00000000000..8e629102aa3 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc253a.d @@ -0,0 +1,23 @@ +module imports.gdc253a; + +interface I253a +{ +} + +interface I253b +{ + size_t printf(...); + void flush(); +} + +class C253a : I253a , I253b +{ + size_t printf(...) + { + return 0; + } + + void flush() + { + } +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc254a.d b/gcc/testsuite/gdc.dg/imports/gdc254a.d new file mode 100644 index 00000000000..2a2a50d2f06 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc254a.d @@ -0,0 +1,10 @@ +module imports.gdc254a; + +class B254 +{ + void F() + { + if (Error) return; + } + +} diff --git a/gcc/testsuite/gdc.dg/imports/gdc256a.d b/gcc/testsuite/gdc.dg/imports/gdc256a.d new file mode 100644 index 00000000000..dfbac24bbf2 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc256a.d @@ -0,0 +1 @@ +module gdc256a; diff --git a/gcc/testsuite/gdc.dg/imports/gdc27a.d b/gcc/testsuite/gdc.dg/imports/gdc27a.d new file mode 100644 index 00000000000..ed1d76193e6 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdc27a.d @@ -0,0 +1,14 @@ +module imports.gdc27a; + +interface I_A +{ + bool a(); +} + +class C_A : I_A +{ + bool a() + { + return false; + } +} diff --git a/gcc/testsuite/gdc.dg/imports/gdcpkg256/package.d b/gcc/testsuite/gdc.dg/imports/gdcpkg256/package.d new file mode 100644 index 00000000000..fb9a124fa60 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/gdcpkg256/package.d @@ -0,0 +1,3 @@ +module imports.gdcpkg256; + +public import gdc256a; diff --git a/gcc/testsuite/gdc.dg/imports/runnablea.d b/gcc/testsuite/gdc.dg/imports/runnablea.d new file mode 100644 index 00000000000..061bc41ddb8 --- /dev/null +++ b/gcc/testsuite/gdc.dg/imports/runnablea.d @@ -0,0 +1,25 @@ +module imports.runnablea; + +private import runnable; + +/******************************************/ + +// Bug 36 + +void test36d_1() +{ + auto parser = Parser!(char[])(); +} + +/******************************************/ + +// Bug 253 + +class B253 : A253 +{ + void test253(int[int] a) + { + if (a.get(0, 1)) + return; + } +} diff --git a/gcc/testsuite/gdc.dg/link.d b/gcc/testsuite/gdc.dg/link.d new file mode 100644 index 00000000000..b8dce31a897 --- /dev/null +++ b/gcc/testsuite/gdc.dg/link.d @@ -0,0 +1,10 @@ +// { dg-do link { target arm*-*-* i?86-*-* x86_64-*-* } } + +class A() +{ + static struct S { A a; } +} + +enum e = is(A!()); + +void main() {} diff --git a/gcc/testsuite/gdc.dg/lto/lto.exp b/gcc/testsuite/gdc.dg/lto/lto.exp new file mode 100644 index 00000000000..b23d7c28408 --- /dev/null +++ b/gcc/testsuite/gdc.dg/lto/lto.exp @@ -0,0 +1,56 @@ +# Copyright (C) 2017 Free Software Foundation, Inc. + +# This program 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 of the License, or +# (at your option) any later version. +# +# This program 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 +# . + +# Test link-time optimization across multiple files. +# +# Programs are broken into multiple files. Each one is compiled +# separately with LTO information. The final executable is generated +# by collecting all the generated object files using regular LTO or WHOPR. + +if $tracelevel then { + strace $tracelevel +} + +# Load procedures from common libraries. +load_lib standard.exp +load_lib gdc-dg.exp + +# Load the language-independent compabibility support procedures. +load_lib lto.exp + +# If LTO has not been enabled, bail. +if { ![check_effective_target_lto] } { + return +} + +lto_init no-mathlib + +# Define an identifier for use with this suite to avoid name conflicts +# with other lto tests running at the same time. +set sid "d_lto" + +# Main loop. +foreach src [lsort [find $srcdir/$subdir *_0.d]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + + lto-execute $src $sid +} + +lto_finish + diff --git a/gcc/testsuite/gdc.dg/lto/ltotests_0.d b/gcc/testsuite/gdc.dg/lto/ltotests_0.d new file mode 100644 index 00000000000..c10226fe12b --- /dev/null +++ b/gcc/testsuite/gdc.dg/lto/ltotests_0.d @@ -0,0 +1,76 @@ +module ltotests_0; + +import core.stdc.stdio; + + +/******************************************/ + +/+ XBUG: lto1: internal compiler error: in get_odr_type +interface I284 +{ + void m284(); +} + +class C284 : I284 +{ + void m284() { } +} ++/ + +/******************************************/ + +/+ XBUG: lto1: internal compiler error: in get_odr_type +class C304 +{ +} + +C304 c304; ++/ + +/******************************************/ + +// Bug 61 + +struct S61a +{ + void a() { } + void b() { } +} + +struct S61b +{ + S61a other; + + void foo() + { + bar(); + } + + void bar() + { + try + other.a(); + catch + other.b(); + } +} + +/******************************************/ + +// Bug 88 + +extern(C) int test88a(); + +void test88() +{ + test88a(); +} + +/******************************************/ + +void main(string[]) +{ + test88(); + + printf("Success!\n"); +} diff --git a/gcc/testsuite/gdc.dg/lto/ltotests_1.d b/gcc/testsuite/gdc.dg/lto/ltotests_1.d new file mode 100644 index 00000000000..1693e6a7f95 --- /dev/null +++ b/gcc/testsuite/gdc.dg/lto/ltotests_1.d @@ -0,0 +1,9 @@ +module ltotests_1; + +/******************************************/ +// Bug 88 + +extern(C) int test88a() +{ + return 0; +} diff --git a/gcc/testsuite/gdc.dg/runnable.d b/gcc/testsuite/gdc.dg/runnable.d new file mode 100644 index 00000000000..a54e8c59cfd --- /dev/null +++ b/gcc/testsuite/gdc.dg/runnable.d @@ -0,0 +1,1532 @@ +// { dg-additional-sources "imports/runnablea.d" } +// { dg-do run { target arm*-*-* i?86-*-* x86_64-*-* } } + +module runnable; + +import imports.runnablea; +import core.stdc.stdio; +import gcc.attribute; + + +/******************************************/ + +// Bug 2 + +struct S +{ + string toString() { return "foo"; } +} + +void test2() +{ + import std.string : format; + assert(format("%s", S()) == "foo"); +} + +/******************************************/ + +// Bug 4 + +void test4() +{ + string str = "allo"; + static assert(!__traits(compiles, str.reverse)); + static assert(!__traits(compiles, str.sort)); +} + +/******************************************/ + +// Bug 15 + +class B +{ + class A { } + A a; +} + +class C +{ + void visit(B b) + { + import std.algorithm : map; + auto as = [b.a]; + as.map!(d => d); + } +} + +/******************************************/ + +// Bug 16 + +void test16() +{ + import std.parallelism : taskPool; + + taskPool.reduce!"a+b"([0, 1, 2, 3]); +} + +/******************************************/ + +// Bug 17 + +/** + * Parameters are not copied into a frame to be accessed from + * the method's __require function. + */ +void contractTest(string path) +{ + assert(path[0] == 't'); + assert(path.length == 9); + assert(path[8] == 'i'); +} + +interface ModuleSaver +{ + void save(string str) + in + { + contractTest(str); + } +} + +class ModuleWriter : ModuleSaver +{ + void save (string str) + in {} + body + { + } +} + +void test17() +{ + (new ModuleWriter()).save ("test.0.mci"); +} + +/******************************************/ + +// Bug 18 + +class C18 +{ + struct Link + { + int x; + int y; + } + + void sort_links() + { + import std.algorithm : sort; + import std.array : empty; + import std.exception : enforce; + + enforce(!_link.empty); + + bool lt(Link a, Link b) + { + if(a.x > b.x) + return false; + if(a.x < b.x) + return true; + if(a.y >= b.y) + return false; + else + return true; + } + sort!(lt)(_link); + } + + this() + { + _link ~= Link(8, 3); + _link ~= Link(4, 7); + _link ~= Link(4, 6); + _link ~= Link(3, 7); + _link ~= Link(2, 7); + _link ~= Link(2, 2); + _link ~= Link(4, 1); + } + + Link[] _link; +} + +void test18() +{ + C18 foo = new C18; + foo.sort_links(); +} + +/******************************************/ + +// Bug 19 + +void test19() +{ + byte b; + --b = b; +} + +/******************************************/ + +// Bug 24 + +void test24() +{ + struct S24 + { + char[1] b; + } + + S24 a; + + if (*a.b.ptr) + return; +} + +/******************************************/ + +// Bug 29 + +void test29() +{ + import std.string : format; + import std.conv : text; + + string s; + for (auto i = 0; i < 100000; i++) + { + s = format("%d", i); + s = text(i); + } +} + +/******************************************/ + +// Bug 31 + +class RedBlackTree(T, alias less) +{ + struct Range + { + @property empty() { } + } + + Range opSlice() + { + return Range(); + } +} + +auto redBlackTree(alias less, E)() +{ + return new RedBlackTree!(E, less); +} + +void test31() +{ + redBlackTree!((a){}, double)(); +} + +/******************************************/ + +// Bug 35 + +/** + * Here the BinaryHeap instance uses an alias parameter and therefore + * the instance's functions (percolateDown) need to be generated in + * topNIndex->BinaryHeap scope and not in the declaration scope + * (module->BinaryHeap). + */ +void topNIndex()() +{ + bool indirectLess(int a, int b) + { + return a > b; + } + + auto a = BinaryHeap!(indirectLess)(); +} + +struct BinaryHeap(alias less) +{ + void percolateDown() + { + less(0, 1); + } +} + +void test35a() +{ + topNIndex(); +} + +/* + * Similar as test35a but with an additional indirection. + * The nested function chain for percolateDown should look like this: + * topNIndex2->BinaryHeap2->percolateDown. + */ +void topNIndex2()() +{ + bool indirectLess(int a, int b) + { + return a > b; + } + auto a = BinaryHeap2!(S35b!(indirectLess)())(); +} + +struct S35b(alias a) +{ + void foo() + { + a(0, 0); + } +} + +struct BinaryHeap2(alias less) +{ + void percolateDown() + { + less.foo(); + } +} + +void test35b() +{ + topNIndex2(); +} + +void test35() +{ + test35a(); + test35b(); +} + +/******************************************/ + +// Bug 36 + +/** + * Here getChar is a function in a template where template.isnested == false + * but getChar still is a nested function and needs to get a static chain + * containing test36a. + */ +void test36a()(char val) +{ + void error() + { + } + + void getChar()() + { + error(); + } + + void parseString() + { + getChar(); + } +} + +/** + * Similar as test36a, but a little more complicated: + * Here getChar is nested in a struct template which is nested in a function. + * getChar's static chain still needs to contain test36b. + */ +void test36b()(char val) +{ + void error() + { + } + + struct S(T) + { + void getChar() + { + error(); + } + } + + + void parseString() + { + S!(int)().getChar(); + } +} + +/** + * If g had accessed a, the frontend would have generated a closure. + * + * As we do not access it, there's no closure. We have to be careful + * not to set a static chain for g containing test36c_1 though, + * as g can be called from outside (here from test1c). In the end + * we have to treat this as if everything in test36c_1 was declared + * at module scope. + */ +auto test36c_1() +{ + int a; + void c() {}; + class Result + { + int b; + void g() { c(); /*a = 42;*/ } + } + + return new Result(); +} + +void test36c() +{ + test36c_1().g(); +} + +/** + * empty is a (private) function which is nested in lightPostprocess. + * At the same time it's a template instance, so it has to be declared as + * weak or otherwise one-only. imports/runnablea.d creates another instance + * of Regex!char to verify that. + */ +struct Parser(R) +{ + @property program() + { + return Regex!char(); + } +} + +struct Regex(Char) +{ + @trusted lightPostprocess() + { + struct FixedStack(T) + { + @property empty() { return false; } + } + auto counterRange = FixedStack!uint(); + } +} + +void test36d() +{ + auto parser = Parser!(char[])(); + imports.runnablea.test36d_1; +} + +void test36() +{ + test36a('n'); + test36b('n'); + test36c(); + test36d(); +} + +/******************************************/ + +// Bug 37 + +struct S37 +{ + int bar(const S37 s) + { + return 0; + } +} + +int test37() +{ + S37 s; + return s.bar(s); +} + +/******************************************/ + +// Bug 43 + +void test43() +{ + import core.vararg; + import core.stdc.stdio; + + void formatArray(ref va_list argptr) + { + auto a = va_arg!(const(float)[])(argptr); + foreach(f; a) + { + printf("%f\n", f); + } + } + + void doFormat(TypeInfo[] arguments, va_list argptr) + { + formatArray(argptr); + } + + void format(...) + { + doFormat(_arguments, _argptr); + } + + format([1.0f, 2.0f, 3.0f]); +} + +/******************************************/ + +// Bug 47 + +template Foo47() +{ + void test47() + { + asm { "nop"; } + } +} + +mixin Foo47!(); + +/******************************************/ + +// Bug 51 + +struct S51 +{ + int x; + int pad; + + this(this) + { + ++x; + } +} + +void test51() +{ + S51 s; + auto sarr = new S51[1]; + auto sarr2 = sarr; + + // postblit all fields. + sarr2 ~= s; + + assert (sarr2[0].x == 1); + assert (sarr2[1].x == 1); + assert (sarr[0].x == 0); + assert (s.x == 0); +} + +/******************************************/ + +// Bug 52 + +class C52 +{ + C52 a; + + this() + { + printf("Construct: this=%p\n", cast(void*)this); + a = this; + } + + bool check() + { + printf("Check: this=%p a=%p\n", cast(void*)this, cast(void*)a); + return this is a; + } +} + +auto test52a() +{ + import std.conv, std.traits; + + struct Scoped + { + void[__traits (classInstanceSize, C52) ] Scoped_store = void; + + inout(C52) Scoped_payload() inout + { + void* alignedStore = cast(void*) Scoped_store.ptr; + return cast(inout (C52)) alignedStore; + } + alias Scoped_payload this; + } + + Scoped result; + emplace!(Unqual!C52)(result.Scoped_store); + assert(result.Scoped_payload().check); + return result; +} + +void test52() +{ + auto a1 = test52a(); + assert(a1.Scoped_payload().check); +} + +/******************************************/ + +// Bug 57 + +struct S57 +{ + int a; + long b; + // Doesn't happen for bigger structs +} + +S57 bar57() +{ + return S57(4, 42); +} + +void test57() +{ + S57 s = bar57(); + assert (s is S57(4, 42)); +} + +/******************************************/ + +// Bug 66 + +void test66() +{ + int pos = 0; + + foreach(x; 0 .. 64) + { + ++pos %= 4; + assert (pos != 4); + } +} + +/******************************************/ + +// Bug 67 + +__vector(float[4]) d[2]; // ICE + + +/******************************************/ + +// Bug 71 + +struct Leaf +{ + ubyte symbol; + ubyte codeLen; +} + +struct CanonicalHuffman +{ + Leaf[] table; + + void print() + { + import std.algorithm; + import std.range; + + auto list = zip(iota(table.length), table.dup).array + .sort!((a, b) => a[1].symbol < b[1].symbol) + .uniq!((a, b) => (a[0] & (1 << a[1].codeLen) - 1) == (b[0] & (1 << b[1].codeLen) - 1)); + } +} + +/******************************************/ + +// Bug 77 + +void fun(ubyte[3] buf) +{ + import std.bitmanip : bigEndianToNative; + bigEndianToNative!ushort(buf[0..2]); +} + +void test77() +{ + fun([1,2,3]); +} + +/******************************************/ + +// Bug 108 + +@attribute("forceinline") +void test108() +{ + import std.stdio : writeln; + writeln("Here"); +} + +/******************************************/ + +// Bug 115 + +void test115() +{ + union U + { + float f; + uint i; + } + float a = 123.0; + const l = U(a); + + assert(l.i == U(a).i); +} + +/******************************************/ + +// Bug 121 + +immutable char C121 = void; // ICE + +/******************************************/ + +// Bug 122 + +void test122() +{ + import std.algorithm : map; + import std.parallelism : taskPool; + import std.range : iota; + + immutable n = 10000; + enum delta = 1.0 / n; // XBUG: was 'immutable delta' https://issues.dlang.org/show_bug.cgi?id=17092 + immutable pi = 4.0 * delta * taskPool.reduce!"a + b"( + map!((int i) { immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x * x); })(iota(n))); +} + +/******************************************/ + +// Bug 127 + +int[0] test127a; // OK +int[1][0] test127b; // OK +int[0][1] test127c; // ICE + +/******************************************/ + +// Bug 131 + +struct S131 +{ + this(string ) { } + string opAssign(string v) { return v; } +} + +void test131() +{ + S131[string] s; + s["foo"] = "bar"; +} + +/******************************************/ + +// Bug 133 + +void delegate()[] D133; + +void test133a(void delegate() dg) +{ + D133 ~= dg; +} + +void test133() +{ + void nested() + {} + test133a(&nested); +} + +/******************************************/ + +// Bug 141 + +bool test141a(int a) +{ + return a > (a + 1); +} + +void test141() +{ + assert(test141a(int.min) == false); + assert(test141a(int.max) == true); +} + +/******************************************/ + +// Bug 142 + +@attribute("noinline") +int test142a()() +{ + return 142; +} + +void test142() +{ + enum E142 = test142a(); +} + +/******************************************/ + +// Bug 171 + +void test171a() +{ + int count = 0; + short a = -1; + while (a != 0) + { + a >>>= 1; + count++; + assert(count <= 16); + } +} + +void test171b() +{ + uint[3] lhs = [99, 201, 300], + rhs = [-1, 0, 0]; + long t = 0; + + for (int i = 0; i < 3; i++) + { + t += lhs[i]; + t -= rhs[i]; + lhs[i] = cast(uint) t; + t >>= uint.sizeof * 8; + } + + assert(lhs == [100, 200, 300]); +} + +void test171() +{ + test171a(); + test171b(); +} + +/******************************************/ + +// Bug 179 + +struct S179a +{ + @disable this(this); +} + +struct S179b +{ + S179a s1; + void connect() { printf("this=%p\n", &this); } +} + +class C179 +{ + private S179b s2; + ref S179b value() @property + { + printf("this=%p\n", &s2); + return s2; + } +} + +void test179() +{ + C179 a = new C179; + a.value.connect(); +} + +/******************************************/ + +// Bug 183 + +struct S183a +{ + union I183a + { + struct + { + double x, y, z; + } + struct + { + double a, b, c; + } + } + + I183a inner; + + this(double x, double y, double z) + { + this.inner.x = x; + this.inner.y = y; + this.inner.z = z; + } +} + +struct S183b +{ + @property get() + { + union Buf + { + void[0] result; + } + const Buf buf = { }; + return buf.result; + } +} + +struct S183c +{ + @property get() + { + union Buf + { + TypeInfo info; + void[0] result; + } + const Buf buf = { }; + return buf.result; + } +} + +void test183() +{ + auto v1 = S183a(0, 0, 0); + auto v2 = S183b().get; + auto v3 = S183c().get; +} + +/******************************************/ + +// Bug 186 + +struct S186 +{ + union + { + struct + { + ubyte fieldA; + byte fieldB = -1; + byte fieldC = -1; + } + size_t _complete; + } + + this(size_t complete) + { + this._complete = complete; + } +} + +void check186(in S186 obj, byte fieldB) +{ + assert(obj.fieldA == 2); + assert(obj.fieldB == 0); + assert(obj.fieldC == 0); + assert(obj._complete == 2); + assert(fieldB == 0); +} + +void test186a(size_t val) +{ + S186 obj = S186(val); + check186(obj, obj.fieldB); + + assert(obj.fieldA == 2); + assert(obj.fieldB == 0); + assert(obj.fieldC == 0); + assert(obj._complete == 2); + + obj = S186(val); + check186(obj, obj.fieldB); + + assert(obj.fieldA == 2); + assert(obj.fieldB == 0); + assert(obj.fieldC == 0); + assert(obj._complete == 2); +} + +void test186() +{ + test186a(2); +} + +/******************************************/ + +// Bug 187 + +align(1) struct S187b +{ + align(1) + { + uint unpaddedA; + ushort unpaddedB; + } +} + +struct S187a +{ + S187b[3] unpaddedArray; + ubyte wontInitialize = ubyte.init; +} + +struct S187 +{ + S187a interesting; +} + + +void prepareStack() +{ + byte[255] stackGarbage; + foreach(i, ref b; stackGarbage) + { + b = cast(byte)(-i); + } +} + +void test187() +{ + prepareStack(); + auto a = S187(S187a()); + assert(a.interesting.wontInitialize == 0); +} + +/******************************************/ + +// Bug 191 + +class C191 +{ + int count = 0; + + void testA() + { + class Inner + { + void test() + { + void localFunction() + { + if (++count != 5) + testA(); + } + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testB() + { + class Inner + { + void test() + { + void localFunction() + { + void anotherLocalFunction() + { + if (++count != 10) + testB(); + } + anotherLocalFunction(); + } + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testC() + { + class Inner + { + int a = 1; + + void test() + { + void localFunction() + { + count += a; + if (count != 15) + testC(); + assert(a == 1); + } + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testD() + { + class Inner + { + void test() + { + int a = 1; + + void localFunction() + { + count += a; + if (count != 20) + testD(); + assert(a == 1); + } + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testE() + { + class Inner + { + int a = 1; + + void test() + { + void localFunction() + { + void anotherLocalFunction() + { + count += a; + if (count != 25) + testE(); + assert(a == 1); + } + + anotherLocalFunction(); + } + + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testF() + { + class Inner + { + void test() + { + int a = 1; + + void localFunction() + { + void anotherLocalFunction() + { + count += a; + if (count != 30) + testF(); + assert(a == 1); + } + + anotherLocalFunction(); + } + + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } + + void testG() + { + class Inner + { + void test() + { + void localFunction() + { + int a = 1; + + void anotherLocalFunction() + { + count += a; + if (count != 35) + testG(); + assert(a == 1); + } + + anotherLocalFunction(); + } + + localFunction(); + } + } + scope ic = new Inner(); + ic.test(); + } +} + +void test191() +{ + scope oc = new C191(); + oc.testA(); + assert(oc.count == 5); + + oc.testB(); + assert(oc.count == 10); + + oc.testC(); + assert(oc.count == 15); + + oc.testD(); + assert(oc.count == 20); + + oc.testE(); + assert(oc.count == 25); + + oc.testF(); + assert(oc.count == 30); + + oc.testG(); + assert(oc.count == 35); +} + +/******************************************/ + +// Bug 194 + +auto test194(ref bool overflow) +{ + import core.checkedint; + + return adds(1, 1, overflow); +} + +/******************************************/ + +// Bug 196 + +class C196 +{ + int a; +} + +struct S196 +{ + int a; +} + +void test196() +{ + __gshared c = new C196(); + __gshared s = new S196(0); + c.a = 1; + s.a = 1; +} + +/******************************************/ + +// Bug 198 + +struct S198a +{ + union + { + float[3] v; + struct + { + float x; + float y; + float z; + } + } + + this(float x_, float y_, float z_) + { + x = x_; + y = y_; + z = z_; + } + + ref S198a opOpAssign(string op)(S198a operand) + if (op == "+") + { + x += operand.x; + y += operand.y; + z += operand.z; + return this; + } +} + +struct S198b +{ + @property get() + { + union Buf + { + void[0] result; + } + const Buf buf = { }; + return buf.result; + } +} + +struct S198c +{ + @property get() + { + union Buf + { + TypeInfo info; + void[0] result; + } + const Buf buf = { }; + return buf.result; + } +} + + +auto test198() +{ + S198a sum = S198a(0, 0, 0); + + foreach(size_t v; 0 .. 3) + sum += S198a(1, 2, 3); + + assert(sum.v == [3, 6, 9]); +} + +/******************************************/ + +// Bug 210 + +struct S210 +{ + ubyte a; + uint b; +} + +union U210 +{ + S210 a; + uint b; +} + +S210 test210a() +{ + S210 s = S210(1, 2); + return s; +} + +S210[2] test210b() +{ + S210[2] s = [S210(1, 2), S210(3, 4)]; + return s; +} + +U210 test210c() +{ + U210 s = U210(S210(1, 2)); + return s; +} + +U210[2] test210d() +{ + U210[2] s = [U210(S210(1, 2)), U210(S210(3, 4))]; + return s; +} + +void test210() +{ + S210 a = S210(1, 2); + assert(a == S210(1, 2)); + assert(a == test210a()); + assert(a != S210(2, 1)); + + S210[2] b = [S210(1, 2), S210(3, 4)]; + assert(b == [S210(1, 2), S210(3, 4)]); + assert(b == test210b()); + assert(b != [S210(2, 1), S210(3, 4)]); + + U210 c = U210(S210(1, 2)); + assert(c == U210(S210(1, 2))); + assert(c == test210c()); + assert(c != U210(S210(2, 1))); + + U210[2] d = [U210(S210(1, 2)), U210(S210(3, 4))]; + assert(d == [U210(S210(1, 2)), U210(S210(3, 4))]); + assert(d == test210d()); + assert(d != [U210(S210(2, 1)), U210(S210(3, 4))]); +} + +/******************************************/ + +// Bug 242 + +struct S242 +{ + enum M = S242(); + int a = 42; + + auto iter() + { + this.a = 24; + return this; + } +} + +S242 test242a() +{ + return S242.M.iter; +} + +void test242() +{ + assert(test242a() == S242(24)); +} + +/******************************************/ + +// Bug 248 + +class C248b +{ + bool isintegral() + { + return false; + } +} + +class C248a +{ + int count = 0; + + C248b getMemtype() + { + count++; + return new C248b(); + } +} + +class C248 +{ + C248a sym; + + this() + { + this.sym = new C248a(); + } + + bool isintegral() + { + return sym.getMemtype().isintegral(); + } +} + +void test248() +{ + C248 e = new C248(); + e.isintegral(); + assert(e.sym.count == 1); +} + +/******************************************/ + +// Bug 250 + +void test250() +{ + struct S + { + string data; + } + + auto a = S("hello"); + auto b = S("hello".dup); + + assert(a.data == b.data); + assert(a == b); + assert([a] == [b]); +} + +/******************************************/ + +// Bug 253 + +interface A253 +{ + void test253(int[int]); +} + +interface C253 : A253 +{ +} + +class D253 : B253, C253 +{ +} + +/******************************************/ + +// Bug 273 + +class B273 +{ + B273[] members; +} + +class D273 : B273 +{ +} + +void test273() +{ + auto noPointers = ClassInfo.ClassFlags.noPointers; + assert((B273.classinfo.m_flags & noPointers) == 0); + assert((D273.classinfo.m_flags & noPointers) == 0); +} + +/******************************************/ + +void main() +{ + test2(); + test4(); + test16(); + test17(); + test18(); + test35(); + test36(); + test43(); + test51(); + test52(); + test57(); + test66(); + test77(); + test108(); + test115(); + test131(); + test133(); + test141(); + test179(); + test186(); + test187(); + test191(); + test196(); + test198(); + test210(); + test248(); + test250(); + test273(); + + printf("Success!\n"); +} diff --git a/gcc/testsuite/gdc.dg/simd.d b/gcc/testsuite/gdc.dg/simd.d new file mode 100644 index 00000000000..bad4ceca139 --- /dev/null +++ b/gcc/testsuite/gdc.dg/simd.d @@ -0,0 +1,1735 @@ +// { dg-do run { target arm*-*-* i?86-*-* x86_64-*-* } } +import core.simd; +import core.stdc.string; +import std.stdio; + +alias TypeTuple(T...) = T; + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=16087 + +static assert(void8.sizeof == 8); +static assert(float2.sizeof == 8); +static assert(byte8.sizeof == 8); +static assert(ubyte8.sizeof == 8); +static assert(short4.sizeof == 8); +static assert(ushort4.sizeof == 8); +static assert(int2.sizeof == 8); +static assert(uint2.sizeof == 8); + +static assert(void16.alignof == 16); +static assert(double2.alignof == 16); +static assert(float4.alignof == 16); +static assert(byte16.alignof == 16); +static assert(ubyte16.alignof == 16); +static assert(short8.alignof == 16); +static assert(ushort8.alignof == 16); +static assert(int4.alignof == 16); +static assert(uint4.alignof == 16); +static assert(long2.alignof == 16); +static assert(ulong2.alignof == 16); + +static assert(void16.sizeof == 16); +static assert(double2.sizeof == 16); +static assert(float4.sizeof == 16); +static assert(byte16.sizeof == 16); +static assert(ubyte16.sizeof == 16); +static assert(short8.sizeof == 16); +static assert(ushort8.sizeof == 16); +static assert(int4.sizeof == 16); +static assert(uint4.sizeof == 16); +static assert(long2.sizeof == 16); +static assert(ulong2.sizeof == 16); + +static assert(void32.alignof == 32); +static assert(double4.alignof == 32); +static assert(float8.alignof == 32); +static assert(byte32.alignof == 32); +static assert(ubyte32.alignof == 32); +static assert(short16.alignof == 32); +static assert(ushort16.alignof == 32); +static assert(int8.alignof == 32); +static assert(uint8.alignof == 32); +static assert(long4.alignof == 32); +static assert(ulong4.alignof == 32); + +static assert(void32.sizeof == 32); +static assert(double4.sizeof == 32); +static assert(float8.sizeof == 32); +static assert(byte32.sizeof == 32); +static assert(ubyte32.sizeof == 32); +static assert(short16.sizeof == 32); +static assert(ushort16.sizeof == 32); +static assert(int8.sizeof == 32); +static assert(uint8.sizeof == 32); +static assert(long4.sizeof == 32); +static assert(ulong4.sizeof == 32); + +/*****************************************/ + +void test1() +{ + void16 v1 = void,v2 = void; + byte16 b; + v2 = b; + v1 = v2; + static assert(!__traits(compiles, v1 + v2)); + static assert(!__traits(compiles, v1 - v2)); + static assert(!__traits(compiles, v1 * v2)); + static assert(!__traits(compiles, v1 / v2)); + static assert(!__traits(compiles, v1 % v2)); + static assert(!__traits(compiles, v1 & v2)); + static assert(!__traits(compiles, v1 | v2)); + static assert(!__traits(compiles, v1 ^ v2)); + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + static assert(!__traits(compiles, v1 << 1)); + static assert(!__traits(compiles, v1 >> 1)); + static assert(!__traits(compiles, v1 >>> 1)); + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + static assert(!__traits(compiles, ~v1)); + static assert(!__traits(compiles, -v1)); + static assert(!__traits(compiles, +v1)); + static assert(!__traits(compiles, !v1)); + + static assert(!__traits(compiles, v1 += v2)); + static assert(!__traits(compiles, v1 -= v2)); + static assert(!__traits(compiles, v1 *= v2)); + static assert(!__traits(compiles, v1 /= v2)); + static assert(!__traits(compiles, v1 %= v2)); + static assert(!__traits(compiles, v1 &= v2)); + static assert(!__traits(compiles, v1 |= v2)); + static assert(!__traits(compiles, v1 ^= v2)); + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + static assert(!__traits(compiles, v1 <<= 1)); + static assert(!__traits(compiles, v1 >>= 1)); + static assert(!__traits(compiles, v1 >>>= 1)); + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2() +{ + byte16 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2b() +{ + ubyte16 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2c() +{ + short8 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + v1 = v1 * 3; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2d() +{ + ushort8 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2e() +{ + int4 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2f() +{ + uint4 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2g() +{ + long2 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2h() +{ + ulong2 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + v1 = v2 % v3; + v1 = v2 & v3; + v1 = v2 | v3; + v1 = v2 ^ v3; + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + v1 = v2 << 1; + v1 = v2 >> 1; + v1 = v2 >>> 1; + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + v1 = ~v2; + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + v1 %= v2; + v1 &= v2; + v1 |= v2; + v1 ^= v2; + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + v1 <<= 1; + v1 >>= 1; + v1 >>>= 1; + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2i() +{ + float4 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + static assert(!__traits(compiles, v1 % v2)); + static assert(!__traits(compiles, v1 & v2)); + static assert(!__traits(compiles, v1 | v2)); + static assert(!__traits(compiles, v1 ^ v2)); + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + static assert(!__traits(compiles, v1 << 1)); + static assert(!__traits(compiles, v1 >> 1)); + static assert(!__traits(compiles, v1 >>> 1)); + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + static assert(!__traits(compiles, ~v1)); + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + static assert(!__traits(compiles, v1 %= v2)); + static assert(!__traits(compiles, v1 &= v2)); + static assert(!__traits(compiles, v1 |= v2)); + static assert(!__traits(compiles, v1 ^= v2)); + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + static assert(!__traits(compiles, v1 <<= 1)); + static assert(!__traits(compiles, v1 >>= 1)); + static assert(!__traits(compiles, v1 >>>= 1)); + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test2j() +{ + double2 v1, v2 = 1, v3 = 1; + v1 = v2; + v1 = v2 + v3; + v1 = v2 - v3; + v1 = v2 * v3; + v1 = v2 / v3; + static assert(!__traits(compiles, v1 % v2)); + static assert(!__traits(compiles, v1 & v2)); + static assert(!__traits(compiles, v1 | v2)); + static assert(!__traits(compiles, v1 ^ v2)); + static assert(!__traits(compiles, v1 ~ v2)); + static assert(!__traits(compiles, v1 ^^ v2)); + static assert(!__traits(compiles, v1 is v2)); + static assert(!__traits(compiles, v1 !is v2)); + static assert(!__traits(compiles, v1 == v2)); + static assert(!__traits(compiles, v1 != v2)); + static assert(!__traits(compiles, v1 < v2)); + static assert(!__traits(compiles, v1 > v2)); + static assert(!__traits(compiles, v1 <= v2)); + static assert(!__traits(compiles, v1 >= v2)); + static assert(!__traits(compiles, v1 <> v2)); + static assert(!__traits(compiles, v1 !< v2)); + static assert(!__traits(compiles, v1 !> v2)); + static assert(!__traits(compiles, v1 !<> v2)); + static assert(!__traits(compiles, v1 <>= v2)); + static assert(!__traits(compiles, v1 !<= v2)); + static assert(!__traits(compiles, v1 !>= v2)); + static assert(!__traits(compiles, v1 !<>= v2)); + static assert(!__traits(compiles, v1 << 1)); + static assert(!__traits(compiles, v1 >> 1)); + static assert(!__traits(compiles, v1 >>> 1)); + static assert(!__traits(compiles, v1 && v2)); + static assert(!__traits(compiles, v1 || v2)); + static assert(!__traits(compiles, ~v1)); + v1 = -v2; + v1 = +v2; + static assert(!__traits(compiles, !v1)); + + v1 += v2; + v1 -= v2; + v1 *= v2; + v1 /= v2; + static assert(!__traits(compiles, v1 %= v2)); + static assert(!__traits(compiles, v1 &= v2)); + static assert(!__traits(compiles, v1 |= v2)); + static assert(!__traits(compiles, v1 ^= v2)); + static assert(!__traits(compiles, v1 ~= v2)); + static assert(!__traits(compiles, v1 ^^= v2)); + static assert(!__traits(compiles, v1 <<= 1)); + static assert(!__traits(compiles, v1 >>= 1)); + static assert(!__traits(compiles, v1 >>>= 1)); + + // A cast from vector to non-vector is allowed only when the target is same size Tsarray. + static assert(!__traits(compiles, cast(byte)v1)); // 1byte + static assert(!__traits(compiles, cast(short)v1)); // 2byte + static assert(!__traits(compiles, cast(int)v1)); // 4byte + static assert(!__traits(compiles, cast(long)v1)); // 8byte + static assert(!__traits(compiles, cast(float)v1)); // 4byte + static assert(!__traits(compiles, cast(double)v1)); // 8byte + static assert(!__traits(compiles, cast(int[2])v1)); // 8byte Tsarray + static assert( __traits(compiles, cast(int[4])v1)); // 16byte Tsarray, OK + static assert( __traits(compiles, cast(long[2])v1)); // 16byte Tsarray, OK +} + +/*****************************************/ + +void test4() +{ + int4 c = 7; + (cast(int[4])c)[3] = 4; + (cast(int*)&c)[2] = 4; + c.array[1] = 4; + c.ptr[3] = 4; + assert(c.length == 4); +} + +/*****************************************/ + +void BaseTypeOfVector(T : __vector(T[N]), size_t N)(int i) +{ + assert(is(T == int)); + assert(N == 4); +} + + +void test7411() +{ + BaseTypeOfVector!(__vector(int[4]))(3); +} + +/*****************************************/ +// 7951 + +float[4] test7951() +{ + float4 v1; + float4 v2; + + return cast(float[4])(v1+v2); +} + +/*****************************************/ + +void test7951_2() +{ + float[4] v1 = [1,2,3,4]; + float[4] v2 = [1,2,3,4]; + float4 f1, f2, f3; + f1.array = v1; + f2.array = v2; + f3 = f1 + f2; +} + +/*****************************************/ + +immutable ulong2 gulong2 = 0x8000_0000_0000_0000; +immutable uint4 guint4 = 0x8000_0000; +immutable ushort8 gushort8 = 0x8000; +immutable ubyte16 gubyte16 = 0x80; + +immutable long2 glong2 = 0x7000_0000_0000_0000; +immutable int4 gint4 = 0x7000_0000; +immutable short8 gshort8 = 0x7000; +immutable byte16 gbyte16 = 0x70; + +immutable float4 gfloat4 = 4.0; +immutable double2 gdouble2 = 8.0; + +void test7414() +{ + immutable ulong2 lulong2 = 0x8000_0000_0000_0000; + assert(memcmp(&lulong2, &gulong2, gulong2.sizeof) == 0); + + immutable uint4 luint4 = 0x8000_0000; + assert(memcmp(&luint4, &guint4, guint4.sizeof) == 0); + + immutable ushort8 lushort8 = 0x8000; + assert(memcmp(&lushort8, &gushort8, gushort8.sizeof) == 0); + + immutable ubyte16 lubyte16 = 0x80; + assert(memcmp(&lubyte16, &gubyte16, gubyte16.sizeof) == 0); + + + immutable long2 llong2 = 0x7000_0000_0000_0000; + assert(memcmp(&llong2, &glong2, glong2.sizeof) == 0); + + immutable int4 lint4 = 0x7000_0000; + assert(memcmp(&lint4, &gint4, gint4.sizeof) == 0); + + immutable short8 lshort8 = 0x7000; + assert(memcmp(&lshort8, &gshort8, gshort8.sizeof) == 0); + + immutable byte16 lbyte16 = 0x70; + assert(memcmp(&lbyte16, &gbyte16, gbyte16.sizeof) == 0); + + + immutable float4 lfloat4 = 4.0; + assert(memcmp(&lfloat4, &gfloat4, gfloat4.sizeof) == 0); + + immutable double2 ldouble2 = 8.0; + assert(memcmp(&ldouble2, &gdouble2, gdouble2.sizeof) == 0); +} + +/*****************************************/ + +void test7413() +{ + byte16 b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]; + assert(b.array[0] == 1); + assert(b.array[1] == 2); + assert(b.array[2] == 3); + assert(b.array[3] == 4); + assert(b.array[4] == 5); + assert(b.array[5] == 6); + assert(b.array[6] == 7); + assert(b.array[7] == 8); + assert(b.array[8] == 9); + assert(b.array[9] == 10); + assert(b.array[10] == 11); + assert(b.array[11] == 12); + assert(b.array[12] == 13); + assert(b.array[13] == 14); + assert(b.array[14] == 15); + assert(b.array[15] == 16); + + ubyte16 ub = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]; + assert(ub.array[0] == 1); + assert(ub.array[1] == 2); + assert(ub.array[2] == 3); + assert(ub.array[3] == 4); + assert(ub.array[4] == 5); + assert(ub.array[5] == 6); + assert(ub.array[6] == 7); + assert(ub.array[7] == 8); + assert(ub.array[8] == 9); + assert(ub.array[9] == 10); + assert(ub.array[10] == 11); + assert(ub.array[11] == 12); + assert(ub.array[12] == 13); + assert(ub.array[13] == 14); + assert(ub.array[14] == 15); + assert(ub.array[15] == 16); + + short8 s = [1,2,3,4,5,6,7,8]; + assert(s.array[0] == 1); + assert(s.array[1] == 2); + assert(s.array[2] == 3); + assert(s.array[3] == 4); + assert(s.array[4] == 5); + assert(s.array[5] == 6); + assert(s.array[6] == 7); + assert(s.array[7] == 8); + + ushort8 us = [1,2,3,4,5,6,7,8]; + assert(us.array[0] == 1); + assert(us.array[1] == 2); + assert(us.array[2] == 3); + assert(us.array[3] == 4); + assert(us.array[4] == 5); + assert(us.array[5] == 6); + assert(us.array[6] == 7); + assert(us.array[7] == 8); + + int4 i = [1,2,3,4]; + assert(i.array[0] == 1); + assert(i.array[1] == 2); + assert(i.array[2] == 3); + assert(i.array[3] == 4); + + uint4 ui = [1,2,3,4]; + assert(ui.array[0] == 1); + assert(ui.array[1] == 2); + assert(ui.array[2] == 3); + assert(ui.array[3] == 4); + + long2 l = [1,2]; + assert(l.array[0] == 1); + assert(l.array[1] == 2); + + ulong2 ul = [1,2]; + assert(ul.array[0] == 1); + assert(ul.array[1] == 2); + + float4 f = [1,2,3,4]; + assert(f.array[0] == 1); + assert(f.array[1] == 2); + assert(f.array[2] == 3); + assert(f.array[3] == 4); + + double2 d = [1,2]; + assert(d.array[0] == 1); + assert(d.array[1] == 2); +} + +/*****************************************/ + +byte16 b = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]; +ubyte16 ub = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]; +short8 s = [1,2,3,4,5,6,7,8]; +ushort8 us = [1,2,3,4,5,6,7,8]; +int4 i = [1,2,3,4]; +uint4 ui = [1,2,3,4]; +long2 l = [1,2]; +ulong2 ul = [1,2]; +float4 f = [1,2,3,4]; +double2 d = [1,2]; + +void test7413_2() +{ + assert(b.array[0] == 1); + assert(b.array[1] == 2); + assert(b.array[2] == 3); + assert(b.array[3] == 4); + assert(b.array[4] == 5); + assert(b.array[5] == 6); + assert(b.array[6] == 7); + assert(b.array[7] == 8); + assert(b.array[8] == 9); + assert(b.array[9] == 10); + assert(b.array[10] == 11); + assert(b.array[11] == 12); + assert(b.array[12] == 13); + assert(b.array[13] == 14); + assert(b.array[14] == 15); + assert(b.array[15] == 16); + + assert(ub.array[0] == 1); + assert(ub.array[1] == 2); + assert(ub.array[2] == 3); + assert(ub.array[3] == 4); + assert(ub.array[4] == 5); + assert(ub.array[5] == 6); + assert(ub.array[6] == 7); + assert(ub.array[7] == 8); + assert(ub.array[8] == 9); + assert(ub.array[9] == 10); + assert(ub.array[10] == 11); + assert(ub.array[11] == 12); + assert(ub.array[12] == 13); + assert(ub.array[13] == 14); + assert(ub.array[14] == 15); + assert(ub.array[15] == 16); + + assert(s.array[0] == 1); + assert(s.array[1] == 2); + assert(s.array[2] == 3); + assert(s.array[3] == 4); + assert(s.array[4] == 5); + assert(s.array[5] == 6); + assert(s.array[6] == 7); + assert(s.array[7] == 8); + + assert(us.array[0] == 1); + assert(us.array[1] == 2); + assert(us.array[2] == 3); + assert(us.array[3] == 4); + assert(us.array[4] == 5); + assert(us.array[5] == 6); + assert(us.array[6] == 7); + assert(us.array[7] == 8); + + assert(i.array[0] == 1); + assert(i.array[1] == 2); + assert(i.array[2] == 3); + assert(i.array[3] == 4); + + assert(ui.array[0] == 1); + assert(ui.array[1] == 2); + assert(ui.array[2] == 3); + assert(ui.array[3] == 4); + + assert(l.array[0] == 1); + assert(l.array[1] == 2); + + assert(ul.array[0] == 1); + assert(ul.array[1] == 2); + + assert(f.array[0] == 1); + assert(f.array[1] == 2); + assert(f.array[2] == 3); + assert(f.array[3] == 4); + + assert(d.array[0] == 1); + assert(d.array[1] == 2); +} + +/*****************************************/ + +float bug8060(float x) { + int i = *cast(int*)&x; + ++i; + return *cast(float*)&i; +} + +/*****************************************/ +/+ +// 9200 + +void bar9200(double[2] a) +{ + assert(a[0] == 1); + assert(a[1] == 2); +} + +double2 * v9200(double2* a) +{ + return a; +} + +void test9200() +{ + double2 a = [1, 2]; + + *v9200(&a) = a; + + bar9200(a.array); +} ++/ + +/*****************************************/ + +// 9304 and 9322 + +float4 foo9304(float4 a) +{ + return -a; +} + + +void test9304() +{ + auto a = foo9304([0, 1, 2, 3]); + //writeln(a.array); + assert(a.array == [0,-1,-2,-3]); +} + +/*****************************************/ + +void test9910() +{ + float4 f = [1, 1, 1, 1]; + auto works = f + 3; + auto bug = 3 + f; + + assert (works.array == [4,4,4,4]); + assert (bug.array == [4,4,4,4]); // no property 'array' for type 'int' +} + +/*****************************************/ + +bool normalize(double[] range, double sum = 1) +{ + double s = 0; + const length = range.length; + foreach (e; range) + { + s += e; + } + if (s == 0) + { + return false; + } + return true; +} + +void test12852() +{ + double[3] range = [0.0, 0.0, 0.0]; + assert(normalize(range[]) == false); + range[1] = 3.0; + assert(normalize(range[]) == true); +} + +/*****************************************/ + +void test9449() +{ + ubyte16[1] table; +} + +/*****************************************/ + +void test9449_2() +{ + float[4][2] m = [[2.0, 1, 3, 4], [5.0, 6, 7, 8]]; // segfault + + assert(m[0][0] == 2.0); + assert(m[0][1] == 1); + assert(m[0][2] == 3); + assert(m[0][3] == 4); + + assert(m[1][0] == 5.0); + assert(m[1][1] == 6); + assert(m[1][2] == 7); + assert(m[1][3] == 8); +} + +/*****************************************/ +// 13841 + +void test13841() +{ + alias Vector16s = TypeTuple!( + void16, byte16, short8, int4, long2, + ubyte16, ushort8, uint4, ulong2, float4, double2); + foreach (V1; Vector16s) + { + foreach (V2; Vector16s) + { + V1 v1 = void; + V2 v2 = void; + static if (is(V1 == V2)) + { + static assert( is(typeof(true ? v1 : v2) == V1)); + } + else + { + static assert(!is(typeof(true ? v1 : v2))); + } + } + } +} + +/*****************************************/ +// 12776 + +void test12776() +{ + alias Vector16s = TypeTuple!( + void16, byte16, short8, int4, long2, + ubyte16, ushort8, uint4, ulong2, float4, double2); + foreach (V; Vector16s) + { + static assert(is(typeof( V .init) == V )); + static assert(is(typeof( const(V).init) == const(V))); + static assert(is(typeof( inout( V).init) == inout( V))); + static assert(is(typeof( inout(const V).init) == inout(const V))); + static assert(is(typeof(shared( V).init) == shared( V))); + static assert(is(typeof(shared( const V).init) == shared( const V))); + static assert(is(typeof(shared(inout V).init) == shared(inout V))); + static assert(is(typeof(shared(inout const V).init) == shared(inout const V))); + static assert(is(typeof( immutable(V).init) == immutable(V))); + } +} + +/*****************************************/ + +void foo13988(double[] arr) +{ + static ulong repr(double d) { return *cast(ulong*)&d; } + foreach (x; arr) + assert(repr(arr[0]) == *cast(ulong*)&(arr[0])); +} + + +void test13988() +{ + double[] arr = [3.0]; + foo13988(arr); +} + +/*****************************************/ +// 15123 + +void test15123() +{ + alias Vector16s = TypeTuple!( + void16, byte16, short8, int4, long2, + ubyte16, ushort8, uint4, ulong2, float4, double2); + foreach (V; Vector16s) + { + auto x = V.init; + } +} + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=15144 + +void test15144() +{ + enum ubyte16 csXMM1 = ['a','b','c',0,0,0,0,0]; + __gshared ubyte16 csXMM2 = ['a','b','c',0,0,0,0,0]; + immutable ubyte16 csXMM3 = ['a','b','c',0,0,0,0,0]; +} + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=13927 + +void test13927(ulong2 a) +{ + ulong2 b = [long.min, long.min]; + auto tmp = a - b; +} + +/*****************************************/ + +// https://issues.dlang.org/show_bug.cgi?id=16488 + +void foo_byte16(byte t, byte s) +{ + byte16 f = s; + auto p = cast(byte*)&f; + foreach (i; 0 .. 16) + assert(p[i] == s); +} + +void foo_ubyte16(ubyte t, ubyte s) +{ + ubyte16 f = s; + auto p = cast(ubyte*)&f; + foreach (i; 0 .. 16) + assert(p[i] == s); +} + + +void foo_short8(short t, short s) +{ + short8 f = s; + auto p = cast(short*)&f; + foreach (i; 0 .. 8) + assert(p[i] == s); +} + +void foo_ushort8(ushort t, ushort s) +{ + ushort8 f = s; + auto p = cast(ushort*)&f; + foreach (i; 0 .. 8) + assert(p[i] == s); +} + + +void foo_int4(int t, int s) +{ + int4 f = s; + auto p = cast(int*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + +void foo_uint4(uint t, uint s, uint u) +{ + uint4 f = s; + auto p = cast(uint*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + + +void foo_long2(long t, long s, long u) +{ + long2 f = s; + auto p = cast(long*)&f; + foreach (i; 0 .. 2) + assert(p[i] == s); +} + +void foo_ulong2(ulong t, ulong s) +{ + ulong2 f = s; + auto p = cast(ulong*)&f; + foreach (i; 0 .. 2) + assert(p[i] == s); +} + +void foo_float4(float t, float s) +{ + float4 f = s; + auto p = cast(float*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + +void foo_double2(double t, double s, double u) +{ + double2 f = s; + auto p = cast(double*)&f; + foreach (i; 0 .. 2) + assert(p[i] == s); +} + + +void test16448() +{ + foo_byte16(5, -10); + foo_ubyte16(5, 11); + + foo_short8(5, -6); + foo_short8(5, 7); + + foo_int4(5, -6); + foo_uint4(5, 0x12345678, 22); + + foo_long2(5, -6, 1); + foo_ulong2(5, 0x12345678_87654321L); + + foo_float4(5, -6); + foo_double2(5, -6, 2); +} + +/*****************************************/ + +void foo_byte32(byte t, byte s) +{ + byte32 f = s; + auto p = cast(byte*)&f; + foreach (i; 0 .. 32) + assert(p[i] == s); +} + +void foo_ubyte32(ubyte t, ubyte s) +{ + ubyte32 f = s; + auto p = cast(ubyte*)&f; + foreach (i; 0 .. 32) + assert(p[i] == s); +} + +void foo_short16(short t, short s) +{ + short16 f = s; + auto p = cast(short*)&f; + foreach (i; 0 .. 16) + assert(p[i] == s); +} + +void foo_ushort16(ushort t, ushort s) +{ + ushort16 f = s; + auto p = cast(ushort*)&f; + foreach (i; 0 .. 16) + assert(p[i] == s); +} + +void foo_int8(int t, int s) +{ + int8 f = s; + auto p = cast(int*)&f; + foreach (i; 0 .. 8) + assert(p[i] == s); +} + +void foo_uint8(uint t, uint s, uint u) +{ + uint8 f = s; + auto p = cast(uint*)&f; + foreach (i; 0 .. 8) + assert(p[i] == s); +} + +void foo_long4(long t, long s, long u) +{ + long4 f = s; + auto p = cast(long*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + +void foo_ulong4(ulong t, ulong s) +{ + ulong4 f = s; + auto p = cast(ulong*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + +void foo_float8(float t, float s) +{ + float8 f = s; + auto p = cast(float*)&f; + foreach (i; 0 .. 8) + assert(p[i] == s); +} + +void foo_double4(double t, double s, double u) +{ + double4 f = s; + auto p = cast(double*)&f; + foreach (i; 0 .. 4) + assert(p[i] == s); +} + +void test16448_32() +{ + import core.cpuid; + if (!core.cpuid.avx) + return; + + foo_byte32(5, -10); + foo_ubyte32(5, 11); + + foo_short16(5, -6); + foo_short16(5, 7); + + foo_int8(5, -6); + foo_uint8(5, 0x12345678, 22); + + foo_long4(5, -6, 1); + foo_ulong4(5, 0x12345678_87654321L); + + foo_float8(5, -6); + foo_double4(5, -6, 2); +} + + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=16703 + +float index(float4 f4, size_t i) +{ + return f4[i]; + //return (*cast(float[4]*)&f4)[2]; +} + +float[4] slice(float4 f4) +{ + return f4[]; +} + +float slice2(float4 f4, size_t lwr, size_t upr, size_t i) +{ + float[] fa = f4[lwr .. upr]; + return fa[i]; +} + +void test16703() +{ + float4 f4 = [1,2,3,4]; + assert(index(f4, 0) == 1); + assert(index(f4, 1) == 2); + assert(index(f4, 2) == 3); + assert(index(f4, 3) == 4); + + float[4] fsa = slice(f4); + assert(fsa == [1.0f,2,3,4]); + + assert(slice2(f4, 1, 3, 0) == 2); + assert(slice2(f4, 1, 3, 1) == 3); +} + +/*****************************************/ + +struct Sunsto +{ + align (1): // make sure f4 is misaligned + byte b; + union + { + float4 f4; + ubyte[16] a; + } +} + +ubyte[16] foounsto() +{ + float4 vf = 6; + Sunsto s; + s.f4 = vf * 2; + vf = s.f4; + + return s.a; +} + +void testOPvecunsto() +{ + auto a = foounsto(); + assert(a == [0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65]); +} + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=10447 + +void test10447() +{ + immutable __vector(double[2]) a = [1.0, 2.0]; + __vector(double[2]) r; + r += a; + r = r * a; +} + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=17237 + +struct S17237 +{ + bool a; + struct + { + bool b; + int8 c; + } +} + +static assert(S17237.a.offsetof == 0); +static assert(S17237.b.offsetof == 32); +static assert(S17237.c.offsetof == 64); + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=16697 + +static assert(!is(float == __vector)); +static assert(!is(float[1] == __vector)); +static assert(!is(float[4] == __vector)); +static assert( is(__vector(float[4]) == __vector)); +static assert(!is(__vector(float[3]) == __vector)); +static assert(!is(__vector(float[5]) == __vector)); +static assert( is(__vector(float[4]) X == __vector) && is(X == float[4])); +static assert( is(__vector(byte[16]) X == __vector) && is(X == byte[16])); + +/*****************************************/ +// https://issues.dlang.org/show_bug.cgi?id=17720 + +void test17720() +{ + alias Vector16s = TypeTuple!( + void16, byte16, short8, int4, long2, + ubyte16, ushort8, uint4, ulong2, float4, double2); + alias Vector32s = TypeTuple!( + void32, byte32, short16, int8, long4, + ubyte32, ushort16, uint8, ulong4, float8, double4); + + // OK: __vector(T) -> __vector(void[]) of same size. + // NG: __vector(T) -> __vector(void[]) of different size. + // NG: explicit cast __vector(T) -> __vector(void[]) of different size. + foreach (V; Vector16s) + { + static assert( __traits(compiles, { void16 v = V.init; })); + static assert(!__traits(compiles, { void32 v = V.init; })); + static assert(!__traits(compiles, { void32 v = cast(void32)V.init; })); + } + foreach (V; Vector32s) + { + static assert( __traits(compiles, { void32 v = V.init; })); + static assert(!__traits(compiles, { void16 v = V.init; })); + static assert(!__traits(compiles, { void16 v = cast(void16)V.init; })); + } + + // NG: __vector(T) -> __vector(T) of same size. + // OK: explicit cast __vector(T) -> __vector(T) of same size. + // NG: __vector(T) -> __vector(T) of different size. + // NG: explicit cast __vector(T) -> __vector(T) of different size. + foreach (V; Vector16s) + { + static if (is(V == double2)) + { + static assert(!__traits(compiles, { long2 v = V.init; })); + static assert( __traits(compiles, { long2 v = cast(long2)V.init; })); + } + else + { + static assert(!__traits(compiles, { double2 v = V.init; })); + static assert( __traits(compiles, { double2 v = cast(double2)V.init; })); + } + static assert(!__traits(compiles, { double4 v = V.init; })); + static assert(!__traits(compiles, { double4 v = cast(double4)V.init; })); + } + foreach (V; Vector32s) + { + static if (is(V == double4)) + { + static assert(!__traits(compiles, { long4 v = V.init; })); + static assert( __traits(compiles, { long4 v = cast(long4)V.init; })); + } + else + { + static assert(!__traits(compiles, { double4 v = V.init; })); + static assert( __traits(compiles, { double4 v = cast(double4)V.init; })); + } + static assert(!__traits(compiles, { double2 v = V.init; })); + static assert(!__traits(compiles, { double2 v = cast(double2)V.init; })); + } +} + +/*****************************************/ + +// https://issues.dlang.org/show_bug.cgi?id=17695 + +void test17695(__vector(ubyte[16]) a) +{ + auto b = -a; +} + +/*****************************************/ + +int main() +{ + test1(); + test2(); + test2b(); + test2c(); + test2d(); + test2e(); + test2f(); + test2g(); + test2h(); + test2i(); + test2j(); + + test4(); + test7411(); + + test7951(); + test7951_2(); + test7414(); + test7413(); + test7413_2(); +// test9200(); + test9304(); + test9910(); + test12852(); + test9449(); + test9449_2(); + test13988(); + test16448(); + test16448_32(); + test16703(); + testOPvecunsto(); + test10447(); + + return 0; +}