From patchwork Fri Apr 28 06:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christoph_M=C3=BCllner?= X-Patchwork-Id: 88458 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp729715vqo; Thu, 27 Apr 2023 23:18:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nd8UAWJHJuAb7H1bH08Wln2oP0ErXAzt1WaphDr5teXE48Q7Z+++ZH0otcZOhuA5AzVOU X-Received: by 2002:a17:906:dc93:b0:94e:8e40:3473 with SMTP id cs19-20020a170906dc9300b0094e8e403473mr4609109ejc.40.1682662687205; Thu, 27 Apr 2023 23:18:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682662687; cv=none; d=google.com; s=arc-20160816; b=UiRNiedwmh8bDMPIOhKvB0J6WlScOggT9hnTZdNtsGMKi7O22OW3vqUnHUYULHk0lo LiYA93eNis+cTegDkZi6S2wPp3sDQBBtBUDSzkpdymPv8Aa4W/mTyshunkp4SJ/RNGMK y9/25XbeQEDwD5k1bIk0qXkZZ7i33aSPjkIWItfScU08okWIZKERl8/S4XDqQOfoOK4E ugkm5cCpQojEaNvbeBkCv8C9LFN2WPtym6AQQQycaiKnUpvPVQKYmGGzqT2/i4iyOLeU S6w89CjLX1g3JOUunIr9rVWuLn7PipJpVMAAG1dwvvENaXiB+oE5z00pYG+pURFQAi1B ON1Q== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=Q2rIE0bSLPOwlqs6mR+CtgV5kwDGjSD14SB46dSlE5U=; b=Cuc2sVdiF8L6Z7qf0eIBMigyXmTEHwgoZ4fxx3Hs7DZfRuVbbMRMBwN3Tx0KlVXyDY Rb1oGcEMyTpGfxLv3KeNLmp6kfpNmxmMXwBVuImFN6kXOKCGCdjgipzLV9uYt/qaIypN DeX3MbC40HCc9nGa+zxbChG5rFqky7gtv6goQA9QlN6K10adTSkYqz9Y6WXfcn1dfYxk 3vxXP209ZS2+8ZV7Y9CBT8fpD8Vgzt3J9UPNR5QvNpQGsVlO6d8krcve1KICQ8AK5qmA EYJE2HsZ2vsbCnPTRBU6JxaKZc2Cio2EERpxISJIRRnPhka1pMw5XIK+Ysemrd2oHISm rqVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@vrull.eu header.s=google header.b=RusKbAmE; 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 ds16-20020a170907725000b0094f5777ef96si17889571ejc.1000.2023.04.27.23.18.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 23:18:07 -0700 (PDT) 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=RusKbAmE; 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 0B5923856DF5 for ; Fri, 28 Apr 2023 06:13:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by sourceware.org (Postfix) with ESMTPS id 61810385701A for ; Fri, 28 Apr 2023 06:12:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 61810385701A 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-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5066ce4f725so13700239a12.1 for ; Thu, 27 Apr 2023 23:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vrull.eu; s=google; t=1682662345; x=1685254345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Q2rIE0bSLPOwlqs6mR+CtgV5kwDGjSD14SB46dSlE5U=; b=RusKbAmEvK8JXqV5x3XI3KKbSN76mmLlaUE2rKMnCH2Ee/FOBwjOZpTJ3/v6wafwwy ohWYcA/yvjQqRsX5L9GwLN71tvX5+jFJ2SUEhs/NmLU9gOqWTA3cKvTJ5CjeW39M7wHO vff2IHjCuzkfqm6v+A+fl79N9KqSGRbmQ8zIH4SnTEWu5CAuIZjH2G9+2QL4JLDvhoXU Kiw3XP0yasnI5ekGf/kWtwzfcFZxlkghUnrUFkctKFZmhHZTSwI0ogTIjlrIZdoO31si LLEs8kXoO2DLUQTr4K12A5EW0EMgsKWSrHiA5FSqP4iRhAIA6TxSFkExjP3oCu4k8D+4 Ecyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682662345; x=1685254345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q2rIE0bSLPOwlqs6mR+CtgV5kwDGjSD14SB46dSlE5U=; b=UD0BrrvFWUnQM5aOq6h3EbzApQLvfU59BMEGRV0VbMxXA/JOAZs/8ORDRevQXXJGWQ zl7G+WakRY5eOuifDcsE4pIZtVxneiE88ddTQlvLZSVqidVkZ6jTpUbEqRjHkhOPQwy8 1o5D+xTr9ZVrMkNGnvU2yh0qdxUQ93qPjhMx6Tua60vIuqp8iV7Dy+vyyakLz1AAencD cmPFhLyFhg2Ntdv/uJVo9HFo8Nm2G8+DI++F9UReUZa9ttznV16OZZic3NN9Nc6YTnO3 RDt8e3lQ9KW5aKkmzWgjcG53vPTrwJ0fTgzVf3hlUiiYdMvzBp3NHiv2kAko7GQptweX yrmw== X-Gm-Message-State: AC+VfDxXRoJTS149zkGLdL/1N7Y3NrlVu3uewrXKew7ndvJiJ0we6ekk GTtIbyN7vP2lcLQlJ0GWaM6zq5UjzVYgY277tLM= X-Received: by 2002:a50:fe91:0:b0:504:af14:132d with SMTP id d17-20020a50fe91000000b00504af14132dmr4123719edt.13.1682662345346; Thu, 27 Apr 2023 23:12:25 -0700 (PDT) Received: from beast.fritz.box (62-178-148-172.cable.dynamic.surfer.at. [62.178.148.172]) by smtp.gmail.com with ESMTPSA id x20-20020aa7d394000000b00504803f4071sm8669431edq.44.2023.04.27.23.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 23:12:24 -0700 (PDT) From: Christoph Muellner To: gcc-patches@gcc.gnu.org, Kito Cheng , Jim Wilson , Palmer Dabbelt , Andrew Waterman , Philipp Tomsich , Cooper Qu , Lifang Xia , Yunhai Shang , Zhiwei Liu Cc: =?utf-8?q?Christoph_M=C3=BCllner?= Subject: [PATCH 08/11] riscv: Prepare backend for index registers Date: Fri, 28 Apr 2023 08:12:09 +0200 Message-Id: <20230428061210.2988035-9-christoph.muellner@vrull.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230428061210.2988035-1-christoph.muellner@vrull.eu> References: <20230428061210.2988035-1-christoph.muellner@vrull.eu> MIME-Version: 1.0 X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_MANYTO, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764399709510502824?= X-GMAIL-MSGID: =?utf-8?q?1764399709510502824?= From: Christoph Müllner RISC-V does currently not support index registers. However, there are some vendor extensions that specify them. Let's do the necessary changes in the backend so that we can add support for such a vendor extension in the future. This is a non-functional change without any intended side-effects. gcc/ChangeLog: * config/riscv/riscv-protos.h (riscv_regno_ok_for_index_p): New prototype. (riscv_index_reg_class): Likewise. * config/riscv/riscv.cc (riscv_regno_ok_for_index_p): New function. (riscv_index_reg_class): New function. * config/riscv/riscv.h (INDEX_REG_CLASS): Call new function riscv_index_reg_class(). (REGNO_OK_FOR_INDEX_P): Call new function riscv_regno_ok_for_index_p(). Signed-off-by: Christoph Müllner --- gcc/config/riscv/riscv-protos.h | 2 ++ gcc/config/riscv/riscv.cc | 20 ++++++++++++++++++++ gcc/config/riscv/riscv.h | 6 ++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h index 628c64cf628..b7417e97d99 100644 --- a/gcc/config/riscv/riscv-protos.h +++ b/gcc/config/riscv/riscv-protos.h @@ -82,6 +82,8 @@ struct riscv_address_info { extern enum riscv_symbol_type riscv_classify_symbolic_expression (rtx); extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *); extern int riscv_regno_mode_ok_for_base_p (int, machine_mode, bool); +extern enum reg_class riscv_index_reg_class (); +extern int riscv_regno_ok_for_index_p (int); extern int riscv_address_insns (rtx, machine_mode, bool); extern int riscv_const_insns (rtx); extern int riscv_split_const_insns (rtx); diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 8388235d8cc..a33f0fff8ea 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -827,6 +827,26 @@ riscv_regno_mode_ok_for_base_p (int regno, return GP_REG_P (regno); } +/* Get valid index register class. + The RISC-V base instructions don't support index registers, + but extensions might support that. */ + +enum reg_class +riscv_index_reg_class () +{ + return NO_REGS; +} + +/* Return true if register REGNO is a valid index register. + The RISC-V base instructions don't support index registers, + but extensions might support that. */ + +int +riscv_regno_ok_for_index_p (int regno) +{ + return 0; +} + /* Return true if X is a valid base register for mode MODE. STRICT_P is true if REG_OK_STRICT is in effect. */ diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index 90746fe14e3..21b81c22dea 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -535,7 +535,7 @@ enum reg_class factor or added to another register (as well as added to a displacement). */ -#define INDEX_REG_CLASS NO_REGS +#define INDEX_REG_CLASS riscv_index_reg_class() /* We generally want to put call-clobbered registers ahead of call-saved ones. (IRA expects this.) */ @@ -705,7 +705,9 @@ typedef struct { /* Addressing modes, and classification of registers for them. */ -#define REGNO_OK_FOR_INDEX_P(REGNO) 0 +#define REGNO_OK_FOR_INDEX_P(REGNO) \ + riscv_regno_ok_for_index_p (REGNO) + #define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \ riscv_regno_mode_ok_for_base_p (REGNO, MODE, 1)