From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Google-Smtp-Source: AA6agR5eUOJHg1CjFYvMDTwDcUu0nWfS7ACiIqDx3ug7wHBU51/+31CUwqLhvbkcLJesSTOV2GAQag== 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 Cc: kito.cheng@gmail.com, jim.wilson.gcc@gmail.com, Palmer Dabbelt , Philipp Tomsich , =?UTF-8?q?Christoph=20M=C3=BCllner?= , collison@rivosinc.com, gnu-toolchain@rivosinc.com, Vineet Gupta 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 Content-Transfer-Encoding: 8bit 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 List-Id: 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 -- 2.32.0