From patchwork Fri Sep 2 23:08:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vineet Gupta X-Patchwork-Id: 941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp939729wro; Fri, 2 Sep 2022 16:08:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7sVUnrrjNrgG98UG24Ev0ubQ+RhmNHX5ZcBJYB6cptfAgazC7C6+YPuO+bq4Gifx2YWuBz X-Received: by 2002:a17:906:d54c:b0:750:5e1c:b88c with SMTP id cr12-20020a170906d54c00b007505e1cb88cmr3776761ejc.485.1662160133743; Fri, 02 Sep 2022 16:08:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662160133; cv=none; d=google.com; s=arc-20160816; b=ayj1kJRB+3qwOKYVGYptwZjtAwsAL0EMhlcOZqVt4lIqvZI+CEUvle1yz5XmJTsVjN Rh4qSZh0QK40CLhRnbv0Gf3O0ZQfH98KgMfV92YngQnZsQmAbY5JjWmIvT4xT5gt1DMf 3FpKv1UjmF7/Z7LspP70Z/v4KmVBpV4Ofd00H5Fq3ShO37buWXTBLuFU6Yod3qe2dKx6 p0RaCPj5fx7ZkZpxe97wOToSiMA12lhzxukJ4Eo6vayhnpUi37VoyVia2YcvYXllEDDO jueBZuvbku0jbggP67JK8Bz2+oJRYUaT6hp1JH0i+6xMu7yQWk+cnKYfwU+xJhJa+PI1 vAyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature:dmarc-filter:delivered-to; bh=nDI0zfGllyLVLTpwDSUaO7sRrbAXjiecN7DfldWkccc=; b=D1lOXCTeB3i4yxXBCIczrhtY231ztvpOg8/8CYeOKC/CRG7ouMM098rmX/7N8q4gDP eHP8cGCkMGwJfm5MVI8vDRq6LF6ELXopt6VnkP5MljV0a/06KgsMT6utXIZ7QREr34aC Z0t8bExCRT3pIzqHmN7ali/k/+kqeINbJX/2ms6yYKcJRquaNky0M9cUTBDmH+g2mqCL 5LRcK4dHzgAKU+FEIJ5gFnWBkTxpNvWezbkUAkux/UoeBjxAMNxKVnMzF51jqpfikuLM OQGiOm+h/G7nUuio8fLPihwbezpfvr//pKjAr9rY50V4LJ4UhhFhlnVjBsZrxh8ngEHm msOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=u8j+NnTX; 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 t12-20020a056402524c00b00446190ccceesi3022943edd.10.2022.09.02.16.08.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 16:08:53 -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=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=u8j+NnTX; 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 719DB3858035 for ; Fri, 2 Sep 2022 23:08:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id 6D2A33858D39 for ; Fri, 2 Sep 2022 23:08:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D2A33858D39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pf1-x430.google.com with SMTP id y29so3333245pfq.0 for ; Fri, 02 Sep 2022 16:08:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=nDI0zfGllyLVLTpwDSUaO7sRrbAXjiecN7DfldWkccc=; b=u8j+NnTXFRSfCyyL4RGZYNp195ufTPxaE9L8DquvFjucUVwwBh5D9Zi3IpnBgGBj4w ReZ9yhDhw0yMChwNxdROhsfRJf4yGx/mfaFqCBPVfrrGiAOJk7QrfKW9ehAu7x3XGw2n WHAMd4IR3ykSOc39Shyq0p6Jof9mXAFJGNbE14ozDTaP6XuNUSBCb1a9DXLBU1FHAqxr 2um/lq3LCEFUu9B4y1vBFHDHz3WyDX5Wr52oiWw9wOdsWZmE5kgBONvCTYHZZzTJ1Rez +VKFn5gVdRfgJjdRkAOMh80yFS1swzyWu1tZFiUenWtYUfffDkEWm4V8F8EshBdd7zlB 3VbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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; bh=nDI0zfGllyLVLTpwDSUaO7sRrbAXjiecN7DfldWkccc=; b=KYRHmItQBYz/X5CFTLH9vbJD+qDEzqYDojCLqOuGQcVqlNG3uGh1pVX+CtmdycqYDe BOk/8ZOzHsLscz0+MqY6cc/L2JUC598VXu3etuFhPbOLl+wDvFMyo0lkP3tGz1d7T5mY VgB73+onFEcqtoMFsGBGR8JG1B2drWXhCBzvFkY2yLSRcxluiPKx8wJmG1mC7W6MAkKc ZmiotP7q/KnOJyhc9UsYbEc64EtsEwxRaCdGFtZhx7qNSAu7qAhwZpjT9qKpIbAqRBMS eTHf7Nugw2I8GtTn9uG32KuB8ZlWaALSic1DBeTct1ryaf2ZqSWaUcCq34nIWaky13xc bksg== X-Gm-Message-State: ACgBeo3OszPnb9CQ/zxMYnSF7E/ux3uWfAZ/65UWzsFKq2n3zLp7Am7P f6gavgSWjHiZzXazFhf/ssJZ0lXuwEg2/UtX X-Received: by 2002:a05:6a00:4c85:b0:538:5500:4873 with SMTP id eb5-20020a056a004c8500b0053855004873mr24638962pfb.81.1662160103174; Fri, 02 Sep 2022 16:08:23 -0700 (PDT) Received: from vineetg-framework.ba.rivosinc.com (c-24-4-73-83.hsd1.ca.comcast.net. [24.4.73.83]) by smtp.gmail.com with ESMTPSA id 196-20020a6218cd000000b00517c84fd24asm2436327pfy.172.2022.09.02.16.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Sep 2022 16:08:22 -0700 (PDT) From: Vineet Gupta To: gcc-patches@gcc.gnu.org Subject: [PATCH] RISC-V: make USE_LOAD_ADDRESS_MACRO easier to understand Date: Fri, 2 Sep 2022 16:08:20 -0700 Message-Id: <20220902230820.381916-1-vineetg@rivosinc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <51ff4d6d-16be-579a-3a84-3f383c8d038e@rivosinc.com> References: <51ff4d6d-16be-579a-3a84-3f383c8d038e@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_BARRACUDACENTRAL, 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: , Cc: collison@rivosinc.com, gnu-toolchain@rivosinc.com, Vineet Gupta , kito.cheng@gmail.com, Philipp Tomsich 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?1742901224605550534?= X-GMAIL-MSGID: =?utf-8?q?1742901224605550534?= The current macro has several && and || making it really hard to understand the first time. Signed-off-by: Vineet Gupta --- Since we are on this topic, perhaps get this simplification too. But I'm not sure if the current checking of local symbol can be simplified a bit. Isn't the first line enough for GET_CODE == const case too ? --- gcc/config/riscv/riscv.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gcc/config/riscv/riscv.h b/gcc/config/riscv/riscv.h index eb1284e56d69..3e3f67ef8270 100644 --- a/gcc/config/riscv/riscv.h +++ b/gcc/config/riscv/riscv.h @@ -749,18 +749,19 @@ typedef struct { #define CASE_VECTOR_MODE SImode #define CASE_VECTOR_PC_RELATIVE (riscv_cmodel != CM_MEDLOW) +#define LOCAL_SYM(sym) \ + ((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \ + || ((GET_CODE (sym) == CONST) \ + && SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \ + && SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0)))) + /* The load-address macro is used for PC-relative addressing of symbols that bind locally. Don't use it for symbols that should be addressed via the GOT. Also, avoid it for CM_MEDLOW, where LUI addressing currently results in more opportunities for linker relaxation. */ #define USE_LOAD_ADDRESS_MACRO(sym) \ (!TARGET_EXPLICIT_RELOCS && \ - ((flag_pic \ - && ((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \ - || ((GET_CODE (sym) == CONST) \ - && SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \ - && SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0))))) \ - || riscv_cmodel == CM_MEDANY)) + ((flag_pic && LOCAL_SYM(sym)) || riscv_cmodel == CM_MEDANY)) /* Define this as 1 if `char' should by default be signed; else as 0. */ #define DEFAULT_SIGNED_CHAR 0