From patchwork Fri Dec 8 00:48:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Wilson X-Patchwork-Id: 845940 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-468735-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="D5vGNTMi"; 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 3ytDHs5M55z9s71 for ; Fri, 8 Dec 2017 11:48:57 +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:from :to:cc:subject:date:message-id; q=dns; s=default; b=BPCNMk85DQDU CeS2CvfhEACDhlgm/SVmqNIUrchZT0pjBq2OxMWWmDaH35WKoFNXxqftzp87iuR+ HRYR9VJ2ZBF41V+G/nc1k6gZt4QN47P1wgG/K6X6bl6jpwgPGXeWG3yepoSIZ/EC fCKw1B143hL+Ut7FCbZG6dmhSQDAhOc= 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:from :to:cc:subject:date:message-id; s=default; bh=oKWV65dKrZ8C+Vvm/z IqN7qKznw=; b=D5vGNTMi7U0ce81UDs06Gh4oENhjySdCwxKYsyfXAGamrtzwrW vuKZGVN/j34KZQdsCVT+WNBvvf2wbyFhLcZxx1lyFc6bywUE5YZUt0MdwalMKCuh blIEi4XhVxagUAqwxyzLLgkZ6/RmueEa5urb2xLSwNHFfEt8sXTQT4kM4= Received: (qmail 3734 invoked by alias); 8 Dec 2017 00:48:46 -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 2611 invoked by uid 89); 8 Dec 2017 00:48:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, 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=sk:categor, H*Ad:U*jimw X-HELO: mail-pf0-f170.google.com Received: from mail-pf0-f170.google.com (HELO mail-pf0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Dec 2017 00:48:44 +0000 Received: by mail-pf0-f170.google.com with SMTP id c204so5975510pfc.13 for ; Thu, 07 Dec 2017 16:48:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9HAS6mVO2pPzFbYMVlbdUPyghR5qtP7yNW/19KavgWw=; b=faiLsRUenrynjgYsmiE0y6NnQ8320hWAIZN0npMRaaguTEA3HDZr63leOOLlZhks5+ OH6r33JUzV2yn2y3EVMxIkMmJyxZMS26OuBRNejYjDE6MBIfxvCo/Xe8+Q31408MqMjM gsOU8FB6XAGzLqWUHbAYaB+g2eus0lpz0V+GbTMuK5pP+z41M6fIurIiLP48qm7V0hrr 8gdtBcZTCSKW/tESk6fLVTCpGJ47lQVzw8m5lXmYdBaBSCoAbBpxLFpqcSv5MK1r7owf X0cv104MlKGqRXBt7o/BOcab+sa7oMSCXlSFczg0P9LbvAAlObrtWJQcStOPwDx2X0Ja GzWw== X-Gm-Message-State: AJaThX7WNTtHjgBY2eB3Pcf5dhJ+1sFbw60d22e728FtJXRZyChGyXIP mh68NiA7zSKS+GMh9dljgEGJHf07D5Y= X-Google-Smtp-Source: AGs4zMZtTTbRGBdDj65SsduEnK8XYBVaDQv/9EC+7Qf+W5KYarjgWjgmCoBUNqwqKXO6bjdWP+uNSQ== X-Received: by 10.99.95.143 with SMTP id t137mr28093284pgb.442.1512694122919; Thu, 07 Dec 2017 16:48:42 -0800 (PST) Received: from rohan.internal.sifive.com ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id s11sm9881442pgn.80.2017.12.07.16.48.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 16:48:42 -0800 (PST) From: Jim Wilson To: gcc-patches@gcc.gnu.org Cc: Jim Wilson Subject: [PATCH] Add srodata section support to riscv port. Date: Thu, 7 Dec 2017 16:48:33 -0800 Message-Id: <20171208004833.5481-1-jimw@sifive.com> This adds srodata section support to the RISC-V port, putting small read-only data in the .srodata section instead of the .sdata section. There is already code to put small read-only rtx in .srodata* instead of .rodata*. This does the same for small read-only trees to be consistent. Tested with a rv32gc/ilp32 make check. There were no regressions. Committed. 2017-12-07 Andrew Waterman gcc/ * config/riscv/riscv.c (TARGET_ASM_SELECT_SECTION): New define. (TARGET_HAVE_SRODATA_SECTION): New define. (riscv_select_section): New function. --- gcc/config/riscv/riscv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/gcc/config/riscv/riscv.c b/gcc/config/riscv/riscv.c index c7283d02141..cfab2e77686 100644 --- a/gcc/config/riscv/riscv.c +++ b/gcc/config/riscv/riscv.c @@ -3042,6 +3042,22 @@ riscv_in_small_data_p (const_tree x) return riscv_size_ok_for_small_data_p (int_size_in_bytes (TREE_TYPE (x))); } +/* Switch to the appropriate section for output of DECL. */ + +static section * +riscv_select_section (tree decl, int reloc, + unsigned HOST_WIDE_INT align) +{ + switch (categorize_decl_for_section (decl, reloc)) + { + case SECCAT_SRODATA: + return get_named_section (decl, ".srodata", reloc); + + default: + return default_elf_select_section (decl, reloc, align); + } +} + /* Return a section for X, handling small data. */ static section * @@ -4320,6 +4336,12 @@ riscv_constant_alignment (const_tree exp, HOST_WIDE_INT align) #undef TARGET_IN_SMALL_DATA_P #define TARGET_IN_SMALL_DATA_P riscv_in_small_data_p +#undef TARGET_HAVE_SRODATA_SECTION +#define TARGET_HAVE_SRODATA_SECTION true + +#undef TARGET_ASM_SELECT_SECTION +#define TARGET_ASM_SELECT_SECTION riscv_select_section + #undef TARGET_ASM_SELECT_RTX_SECTION #define TARGET_ASM_SELECT_RTX_SECTION riscv_elf_select_rtx_section