Message ID | 20221113204119.4061447-1-philipp.tomsich@vrull.eu |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1825529wru; Sun, 13 Nov 2022 12:41:55 -0800 (PST) X-Google-Smtp-Source: AA0mqf7UUncJ8LJMOxkeS+gnd8Ke2R1zHs6OQU7HzHfUqxFnirBgxadWsIZ6Q4OdgubFBYD6yGzg X-Received: by 2002:a17:906:a144:b0:7ad:79c0:4662 with SMTP id bu4-20020a170906a14400b007ad79c04662mr8426009ejb.400.1668372115389; Sun, 13 Nov 2022 12:41:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668372115; cv=none; d=google.com; s=arc-20160816; b=psFkl5c5bZNCQbbOde4KwOQ+ZXtzxtx4wWDyS11+9nKjOuW7CVp64fIT2VRtqmcvOl tgEm5Lep0I41Jpcq6Svw2/r9SRL7Fcbr9B+TURMeP8mAQx2Sm9ZjjutH63cKL2tvbr5m RNV56C72yRzFZsisySFqjiUW0hrwkNhXjs3qNhKqs08afRSv1xs8r82QDFDDrWEggZKG c+akfxL0hFWUjh7WQPTBYLya/08fTph7wi+ZquU0S8YGlWZ8zQ2FnmWnq26cW7kWkk5N efUJNb1n6C/ciulVb5lTa6ZWI1lu9yC8LsoF0XvHex8EPaEEOORBND0GhNQK6l1mJioS OrtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dmarc-filter:delivered-to; bh=9z9dXf5b4/Jh1SbWc5vfHUlNVVH753KOW3qxJTq6eOY=; b=gGngNgox3gTK+ieykd9pMACvr6WwFe5N+qmzE6AoZKIj/30VmLMXUZEFQ0YRYnIOyD A5IUe7yS5ifxP/5J8N2RW5ZT5xmEThHU1k2DZ+8NtSJlpNBK57ONrMWLNqZdW+tXEtJN Rj1fkpT4CqhffZIjXKnIwowx9yAcBV05w6PJz/zcXKy9EexercZ0qhN3uPuURgAKXeK/ FgUSoD6WUtM/dCcl/JdipYq7YwxMvj6fEVhNckZ+7U5lHNYZLEmE3xJUqosYQNeunszs 8GfJphX3O8W1M+fxyYl7x7CObv+5MJTwS/GmNpQVzfMzTffdD8F6y1ERGjr35s9oGG/4 uf0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=LCKZyiDX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qf3-20020a1709077f0300b0078d85177210si8007810ejc.756.2022.11.13.12.41.55 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 12:41:55 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=LCKZyiDX; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 038F93857365 for <ouuuleilei@gmail.com>; Sun, 13 Nov 2022 20:41:51 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by sourceware.org (Postfix) with ESMTPS id 040253857BB3 for <gcc-patches@gcc.gnu.org>; Sun, 13 Nov 2022 20:41:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 040253857BB3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=vrull.eu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=vrull.eu Received: by mail-lf1-x134.google.com with SMTP id g7so16271767lfv.5 for <gcc-patches@gcc.gnu.org>; Sun, 13 Nov 2022 12:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9z9dXf5b4/Jh1SbWc5vfHUlNVVH753KOW3qxJTq6eOY=; b=LCKZyiDXUVk/cNi04I2PT7HFM4+uYpLTGittDQqtnQ9teU4bEDOeVNMF8HMpj7tniL sD+6BGhMtzNqmA3obKsUlZdbALlbdMmyqlnLglgbJZmfIhkF1cgEbj3GEWpnaqZfxyOq TgBFpmsi/zLFDzQNRSPAK6exlWchEDBTVEk2YXQ4UoBJ0JjGVL+cRys6XOyzoVp1/ky8 3a88fV5WiBDo0m3qcieoesRSFB9filYWEdM78WrV5eWSIR0F7/8U/d3n5/cgmQTv9W5l PvPbutLfygrwLZ5wdEuJJuI9zjTi5xusS+DsJQdAeg0EhEUJqjPup3vq7Gpf36pDdr6z yYNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9z9dXf5b4/Jh1SbWc5vfHUlNVVH753KOW3qxJTq6eOY=; b=HAMX1QRdBkItRBeLDPikEM1w3ARb5qPy0UPMUSGaZRutwjdVtPH/hRdGQlpmPLlAhj F8NuKLB4SyK+hnKCj7shJ/jfJ8N/O/xjThjigBpLsj+94r6mjtCvoXZ9SXuAkNGd/rGo IvOsykMLOk2r4EANB3t22faPbb+rp9PtDoeJrSgE4nJH4xeGFbiS2+FRwjrJaBjrL7TI Efq1BlNgHIfOI+Ud0b8/EKL6F7BHgyQY2HMVkGfHN3rnnhxInuy+L2+KkXIJTVlGSzYD iVJEr8fUkXBpWvzmzaR49kj9YA0M+gBJXTsTwkHinV9BznTkpJgb0Mi/En1xXvetx7TX +Wlw== X-Gm-Message-State: ANoB5pnKWvsRI4JgzIp3AogYaUNqPg+odIgLlexvdAosSPsNSXx2EW0D 3F34GCavLbCkNELdh2wKD1bvkRNsclpJJ2Pq X-Received: by 2002:a05:6512:714:b0:4b3:d036:a268 with SMTP id b20-20020a056512071400b004b3d036a268mr3106196lfs.282.1668372083129; Sun, 13 Nov 2022 12:41:23 -0800 (PST) Received: from ubuntu-focal.. ([2a01:4f9:3a:1e26::2]) by smtp.gmail.com with ESMTPSA id g12-20020a2eb5cc000000b0027775fb1f6bsm1631023ljn.118.2022.11.13.12.41.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 13 Nov 2022 12:41:22 -0800 (PST) From: Philipp Tomsich <philipp.tomsich@vrull.eu> To: gcc-patches@gcc.gnu.org Cc: Christoph Muellner <christoph.muellner@vrull.eu>, Palmer Dabbelt <palmer@rivosinc.com>, Vineet Gupta <vineetg@rivosinc.com>, Kito Cheng <kito.cheng@gmail.com>, Jeff Law <jlaw@ventanamicro.com>, Philipp Tomsich <philipp.tomsich@vrull.eu> Subject: [PATCH] RISC-V: Use .p2align for code-alignment Date: Sun, 13 Nov 2022 21:41:18 +0100 Message-Id: <20221113204119.4061447-1-philipp.tomsich@vrull.eu> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749414958819229134?= X-GMAIL-MSGID: =?utf-8?q?1749414958819229134?= |
Series |
RISC-V: Use .p2align for code-alignment
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Philipp Tomsich
Nov. 13, 2022, 8:41 p.m. UTC
RISC-V's .p2align (currently) ignores the max-skip argument. As we
have experimental patches underway to address this in a
backwards-compatible manner, let's prepare GCC for the day when
binutils gets updated.
gcc/ChangeLog:
* config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement.
Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
---
gcc/config/riscv/riscv.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
Comments
On 11/13/22 13:41, Philipp Tomsich wrote: > RISC-V's .p2align (currently) ignores the max-skip argument. As we > have experimental patches underway to address this in a > backwards-compatible manner, let's prepare GCC for the day when > binutils gets updated. > > gcc/ChangeLog: > > * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement. What are the implications if we start using p2align immediately when the current (broken?) state of the assembler? I'm pretty sure configure is already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build: auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1 jeff
Jeff, On Tue, 15 Nov 2022 at 17:37, Jeff Law <jeffreyalaw@gmail.com> wrote: > > > On 11/13/22 13:41, Philipp Tomsich wrote: > > RISC-V's .p2align (currently) ignores the max-skip argument. As we > have experimental patches underway to address this in a > backwards-compatible manner, let's prepare GCC for the day when > binutils gets updated. > > gcc/ChangeLog: > > * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement. > > > What are the implications if we start using p2align immediately when the current (broken?) state of the assembler? I'm pretty sure configure is already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build: > > > auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1 This is your tree, which has the (partial fix — i.e., the best we can do without breaking backward compatibility) for .p2align. When building against upstream binutils, this should not be defined. Philipp.
On Tue, 15 Nov 2022 at 22:14, Philipp Tomsich <philipp.tomsich@vrull.eu> wrote: > > Jeff, > > On Tue, 15 Nov 2022 at 17:37, Jeff Law <jeffreyalaw@gmail.com> wrote: > > > > > > On 11/13/22 13:41, Philipp Tomsich wrote: > > > > RISC-V's .p2align (currently) ignores the max-skip argument. As we > > have experimental patches underway to address this in a > > backwards-compatible manner, let's prepare GCC for the day when > > binutils gets updated. > > > > gcc/ChangeLog: > > > > * config/riscv/riscv.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Implement. > > > > > > What are the implications if we start using p2align immediately when the current (broken?) state of the assembler? I'm pretty sure configure is already turning on HAVE_GAS_SKIP_P2ALIGN. From a native risc-v build: > > > > > > auto-host.h:#define HAVE_GAS_MAX_SKIP_P2ALIGN 1 > > This is your tree, which has the (partial fix — i.e., the best we can > do without breaking backward compatibility) for .p2align. > When building against upstream binutils, this should not be defined. After rereading the generated configure-script, I've changed my mind The check the does nothing to ensure that the max-skip is actually honored and only tests whether it is accepted. Having the max-skip silently ignored may still be the lesser evil. Philipp.
diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 2d0d170645c..c216173cf6b 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -938,6 +938,24 @@ typedef struct { fprintf (STREAM, "\t.word\t%sL%d-%sL%d\n", \ LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL) +#ifdef HAVE_GAS_MAX_SKIP_P2ALIGN +/* Support for -falign-* switches. Use .p2align to ensure that code + sections are padded with NOP instructions, rather than zeros. */ +#define ASM_OUTPUT_MAX_SKIP_ALIGN(FILE, LOG, MAX_SKIP) \ + do \ + { \ + if ((LOG) != 0) \ + { \ + if ((MAX_SKIP) == 0) \ + fprintf ((FILE), "\t.p2align %d\n", (int) (LOG)); \ + else \ + fprintf ((FILE), "\t.p2align %d,,%d\n", \ + (int) (LOG), (int) (MAX_SKIP)); \ + } \ + } while (0) + +#endif /* HAVE_GAS_MAX_SKIP_P2ALIGN */ + /* This is how to output an assembler line that says to advance the location counter to a multiple of 2**LOG bytes. */