From patchwork Sun May 28 21:15: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: 767965 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wbXjG6Lf7z9s2Q for ; Mon, 29 May 2017 07:16:01 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="sbaOoowN"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=RK6c1WeyJX/Ak2bPFUhyQ6UL8ANfz4JBkf94sF1TaOYFNT obgg3eDmGom96GXeje+bRPy2ESz9rBFl4I20rYgEqbBgxQxttJMYI25eouypiOsJ dHUdSZYZ2Jmv98wNR2Tzc78QNrejufg8DZFwT3gMGfHgQmkqtVuT+eDb/CH5s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=rlmwCvPRFrItYnd6SRRPL8Y6o4s=; b=sbaOoowNFh5ibOhtplxI q9yR7C/wsWyqMj7GeocxVq6eejW0aV7r9GkIvIrJ9/SJe/zzXGxWzvFxPrumeAyz nrQHDqNbWmCS4PEwhoL3TexLRlCIovCC00Ocx8Ms1zWz7hq5xQaxnUuHDIW76zqb qQLNppmh3FTNlXb/RBmeDUc= Received: (qmail 70798 invoked by alias); 28 May 2017 21:15:45 -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 66101 invoked by uid 89); 28 May 2017 21:15:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.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, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-vk0-f50.google.com Received: from mail-vk0-f50.google.com (HELO mail-vk0-f50.google.com) (209.85.213.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 28 May 2017 21:15:34 +0000 Received: by mail-vk0-f50.google.com with SMTP id p85so24076078vkd.3 for ; Sun, 28 May 2017 14:15: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; bh=KPpw+/Tc42UMBozffBHH9aNy3e/gkW7wrrzj/I8Avfs=; b=HlnUBHONwy7701vNGhmBAOD/nOvj3AGzZQ203SPSdRY/y/f5ap1XoeGBidNwYS3BDu i25bDc83P6+Pbv167AACo4rdYRuUShaKk+HTmWcVp9YdqG3zhmYg6FSI6aUNDsKyaAA7 oJxC4R0+ZI8xzpP0ZnJshbiXb1vrR0SIvRUG+QygAJbRHqC29vxuRPOepoiRlHrroZBy zxA5byMsrYxvBviQqALotwHgcTymqhIXYUpUAeqn9k0QfdzIEi2yUauyst7vk/XmNy0k 8HBJ69KmnztbpMrNhi2pZEO30X9HU0TnBOM1FwCWk/m1PAK7KVBbCInMolX9NIZLl/fW /Bqg== X-Gm-Message-State: AODbwcDGIi1CpRcpCqkJoAMgTnyHpz+RTQWhEmfcfiqD9nSSXsQzPMnK c+uaUcvsK/IDn5UDq09FUv6nvcxgndqL X-Received: by 10.31.107.138 with SMTP id k10mr1968076vki.51.1496006121514; Sun, 28 May 2017 14:15:21 -0700 (PDT) MIME-Version: 1.0 Received: by 10.31.96.201 with HTTP; Sun, 28 May 2017 14:15:21 -0700 (PDT) From: Iain Buclaw Date: Sun, 28 May 2017 23:15:21 +0200 Message-ID: Subject: [PATCH 6/13] D: Add D language support to GCC proper. To: gcc-patches X-IsSubscribed: yes This patch adds D language support to GCC itself. gcc/ChangeLog * 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". diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index b0d1dd95e5d..32f8527d940 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -31921,11 +31921,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 5ff45eb4efd..f4f32440695 100644 --- a/gcc/dwarf2out.c +++ b/gcc/dwarf2out.c @@ -5079,6 +5079,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. */ @@ -23595,6 +23605,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) @@ -25159,7 +25171,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); @@ -25182,7 +25194,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. */ @@ -25249,7 +25261,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. */ @@ -25796,7 +25808,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 4724276a318..6c3dd23a840 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1309,6 +1309,7 @@ static const struct compiler default_compilers[] = {".java", "#Java", 0, 0, 0}, {".class", "#Java", 0, 0, 0}, {".zip", "#Java", 0, 0, 0}, {".jar", "#Java", 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",