From patchwork Wed Feb 21 03:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203873 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp803462dyc; Tue, 20 Feb 2024 19:09:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX5Z+0vyvwWzh/wk0rhK9cEfZrHBSTHrAfumbz3VOOPztWSuX8p3yRRsRAkBsUwgQsTL+w38JOyq+357kmzJbmcWZrG6w== X-Google-Smtp-Source: AGHT+IE0yORjwltvVurBZsaz9W7rhWSsj40h/tVk12PhTptwg5Y7jyrGJ27Dc2sy3zMExEAVefIR X-Received: by 2002:a05:622a:514:b0:42d:a750:bd with SMTP id l20-20020a05622a051400b0042da75000bdmr18875484qtx.54.1708484996157; Tue, 20 Feb 2024 19:09:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484996; cv=pass; d=google.com; s=arc-20160816; b=tFEInfIN0zaCzVigUIvT7AjD2HMir6naoOpoFybYjpSw/3LxzzH60UAOteyrd9nKex 2Dv07vCjs/BmJFhhsryqHp3D84F5f557WqrNzK3aTeOpFjmIJZ/VrNG+JH/FSdwF1tXy kN+TZ+L6fLbx99B+5i8mkPnxeYgLH/KL60gBEeUEtaav+p2l8H6+9DUiqreWubaC4Mfy Dp98nXSpofLK00KOVHysSAZHBIb/vLKM0TwRC7Mn+NHOII6S2h2wVEJP+z5U2SjVFoeS F2tPlpmCwq3glBTLAjGcQ3bEi+EGp2AszAIulbC/VF+qH74O693bzVk5M2nomw4WEl4x LWHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=Eozw2JgMMK79RcHQmm3yUdfO+oC1X93mtjpo6R9ca3w=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=xlZWymaDtHX7VkZxhsmd05E2aRBkS/6QpSz7sMdn59daAb4L2aY0WfRZztrYvuUOvc RmoQvrweCYb1vxRz1OhZom0woIETNdlLsSjJ9Np6a29+2WJiqb2oM1cD4d3+S1iF5MSD xu0iz6g7xVZTP48eZqjY9ZneEJ6ff1dF66R6UbXYUw3mBFbhZ84xwMMwuni6eCf/Y2Kg KfQLGGEqp9yI9DZKU/L1J7KPxjIWQvxEwLg5wSHnqK0ufD0EaR+UbFBKhX0BjtgltWAh jtzoeyM0Iqam4/3O4JLrBVHWyQ84OwUnhChRadv/hl/UrieZL4XPMIw9OcS05KCOaSlG iWWA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id r13-20020ac867cd000000b0042c0fb47a11si9221327qtp.281.2024.02.20.19.09.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:09:56 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 D85A93858D3C for ; Wed, 21 Feb 2024 03:09:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 659743858D35 for ; Wed, 21 Feb 2024 03:08:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 659743858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 659743858D35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484941; cv=none; b=VbLdkqTIBllv7tRqM3f++uxw2OOg6GtThMrRYEy5ejPX+mbrpmIdr56cQBuAMHnlDO7MHrVTTh6P492U7P+7/ITIY4owKQJt47R+419Y2C1A4msJ+YXV6rRzqUI5Z+YNRZng/oXdEooboKEe7ZOsDCH2gDh0s97b0Wmb4brWAuE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484941; c=relaxed/simple; bh=ULHhaJIZuC3v2o+Iu9I7rqU3lW2Csj3OJOjCqFiFwcA=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=q/PPicZl28LV0LwamKdewntImV3Qx5EifuCWt10BD/RjOShgsbn/JjrJNJQOtkaRngmN8qwVFe72iAs6k0Usva6lyi/9CxGSrwT9CY5IPpwwCuaXN+M6E2cg7D8ouURYUy+wSWelHDU9/NTEBEqjBTyqMasqbBol0gqEFWqvkLw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rccye-0000KH-AS for gcc-patches@gcc.gnu.org; Tue, 20 Feb 2024 22:08:58 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8CxrutEadVlzacPAA--.40542S3; Wed, 21 Feb 2024 11:08:52 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLs88adVlyGw9AA--.26359S3; Wed, 21 Feb 2024 11:08:52 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v1 1/4] LoongArch: Delete macro definition ASM_OUTPUT_ALIGN_WITH_NOP. Date: Wed, 21 Feb 2024 11:08:38 +0800 Message-Id: <20240221030841.23454-2-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030841.23454-1-chenglulu@loongson.cn> References: <20240221030841.23454-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxLs88adVlyGw9AA--.26359S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7ury3Jr45JFyUCFyDJFWxXwc_yoW8Ar43p3 9xAwnrJFW8Jr1xGwnFq39Ygws0q3srKr12qF1agr48Ca15Jr1j9Fs3trWkXFy0gws5ZF1a qr18Kr43XF90yagCm3ZEXasCq-sJn29KB7ZKAUJUUUU3529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUB2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1ln4kS14v26r126r1DM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12 xvs2x26I8E6xACxx1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q 6rW5McIj6I8E87Iv67AKxVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64 vIr41lc7CjxVAaw2AFwI0_JF0_Jw1l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_ Jr0_Gr1l4IxYO2xFxVAFwI0_JF0_Jw1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8V AvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E 14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxU4Xo7DUUUU Received-SPF: pass client-ip=114.242.206.163; envelope-from=chenglulu@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_FAIL, SPF_HELO_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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791476363366138077 X-GMAIL-MSGID: 1791476363366138077 There are two reasons for removing this macro definition: 1. The default in the assembler is to use the nop instruction for filling. 2. For assembly directives: .align [abs-expr[, abs-expr[, abs-expr]]] The third expression it is the maximum number of bytes that should be skipped by this alignment directive. Therefore, it will affect the display of the specified alignment rules and affect the operating efficiency. This modification relies on binutils commit 1fb3cdd87ec61715a5684925fb6d6a6cf53bb97c. (Since the assembler will add nop based on the .align information when doing relax, it will cause the conditional branch to go out of bounds during the assembly process. This submission of binutils solves this problem.) gcc/ChangeLog: * config/loongarch/loongarch.h (ASM_OUTPUT_ALIGN_WITH_NOP): Delete. Co-authored-by: Chenghua Xu (cherry picked from commit b20c7ee066cb7d952fa193972e8bc6362c6e4063) --- gcc/config/loongarch/loongarch.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index f34a7a604cc..8d08b84c8eb 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -978,11 +978,6 @@ typedef struct { #define ASM_OUTPUT_ALIGN(STREAM, LOG) fprintf (STREAM, "\t.align\t%d\n", (LOG)) -/* "nop" instruction 54525952 (andi $r0,$r0,0) is - used for padding. */ -#define ASM_OUTPUT_ALIGN_WITH_NOP(STREAM, LOG) \ - fprintf (STREAM, "\t.align\t%d,54525952,4\n", (LOG)) - /* This is how to output an assembler line to advance the location counter by SIZE bytes. */ From patchwork Wed Feb 21 03:08:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203875 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp803781dyc; Tue, 20 Feb 2024 19:10:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXazbzcCurg7sMXocfHzcZKW7jx4FLMgwo884/RMdKEI1UZGvOpzZOX5uqzE3Wn23vxd7L4bdMV1E5f5HjUpct7q1RXIQ== X-Google-Smtp-Source: AGHT+IF9f9i0NnvXMhyvG92POZfJ/JdEORD0H6iBv2Pz4iKFwXBhphPHP9VbHC+p37kPQ8SbNel5 X-Received: by 2002:a05:6214:409:b0:68e:e94e:b43c with SMTP id z9-20020a056214040900b0068ee94eb43cmr21174167qvx.52.1708485058457; Tue, 20 Feb 2024 19:10:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708485058; cv=pass; d=google.com; s=arc-20160816; b=Fa7oFDGc/AbME79UrGNRgUfZHf1cxXWmwHlya5aGj8SPWNGx0CRjrQ+1TJ59boBduM itOSSJCW3zuNRth98ro2j/EKvWk+jhY5yLLZ7/jt4Ah3UHRXb6hWoH5+Z5dCtQGrFupU zINcjKtMWiIllfelw9bjx+KhRVZz6zZtZ0/pGg/ubZXX4s3GCHkECRcV9I6N3B66HwdK M5yh6NZmAgdK1KWZecuP2HlOAqdeYpbUrY+YawClAFBM/38iyQT+cf5sre9gXGrqWk/q ATNG6O+ivkHFwwYqjMbkEEF8BNfn+UqDkDHPZTaK+wzTpAiWftkDVN/88UwR3oS1llru LQYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=sAdCbvScUTRobayozzbFouINeKxl3iv709HwXhcEyY4=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=RguZxH20eEAj6UnNePhfA+OT45CoRPFEIgBXkgQAeyIL93qSiS+jrX2I0cOk1u7CMC lAth4JtAtIbzLTQ77vmUaYl6BieXDEDdaDfMRNxGrMoKRAaZ5sOKwkrw+CGfL6PzhwRH bVqMdIwPKG8yPg94nXogu2JRoI5XXxvK93bbKLI9zLB5gtqofua6GsC3p67d1xlohtVZ J8Qm6ZS5By146wntCs7MaPH83BNkKXyEDb2VZJwfp8SwGbcGLh87XFzO+juCRfLOFegK SOuHY1HAbCaz4wM+BM4pY/df0rQNS3DwQtQMbRzy0tm0sn7q0j7cKUnAHB1lmATHy0uW ffAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s5-20020a0562140ca500b0068f756764cbsi5232296qvs.281.2024.02.20.19.10.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:10:58 -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; arc=pass (i=1); 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 DA3553858C52 for ; Wed, 21 Feb 2024 03:10:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 9926B3858D3C for ; Wed, 21 Feb 2024 03:09:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9926B3858D3C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 9926B3858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2001:470:142:3::10 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484943; cv=none; b=HkrNwhdRwNdz1pXn8xffW+MJlW13VmFYdGy2Ui44UyNMg7vu23PwswuanKjmYFqfbd4izpe5hTHTurrvkc5rWcspWwEb/PuHNcwPg2iJCc245y83koaKBM+E3iT29tJ7U/l2mJsIcrgRZp3R5QHVcgI2aeC/pLBlfnAVn8a7yyg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484943; c=relaxed/simple; bh=r6kIL6i8tu/eznPHtijIZn2iCjRGV+OBy/ImDoHg0VU=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=TRWystAjHTC0N1dCfAwWGV/w+1zmjDNvTudGsWuSvTj9XolT7iSH8yrHnNVTR3GNjzAx8L24ac2chEAE+mIQxvJYqG/xHGLwmr/UvJnwIO1RUWoNEClod/Lzcb7dW0Hwv0lYLKhc3YsOeZvjbL/uvjanKhozREnqfVW22Pzj4N8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rccyg-0000KP-Et for gcc-patches@gcc.gnu.org; Tue, 20 Feb 2024 22:09:01 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8CxG+lHadVl0acPAA--.22281S3; Wed, 21 Feb 2024 11:08:55 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLs88adVlyGw9AA--.26359S4; Wed, 21 Feb 2024 11:08:52 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v1 2/4] LoongArch: Check whether binutils supports the relax function. If supported, explicit relocs are turned off by default. Date: Wed, 21 Feb 2024 11:08:39 +0800 Message-Id: <20240221030841.23454-3-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030841.23454-1-chenglulu@loongson.cn> References: <20240221030841.23454-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxLs88adVlyGw9AA--.26359S4 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3Gr48uFWrtr1kCF1Utr4rtFc_yoWxWFyDpr 9rZw1ayF48Grs3Gr4Dta4fWwn3Jr97Wr12va13Xr18Ca15Xr10vF40yrnrXFy7Xw4rWry2 vr1rKa129a1kAwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE 14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw 1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07j8 CztUUUUU= Received-SPF: pass client-ip=114.242.206.163; envelope-from=chenglulu@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_FAIL, SPF_HELO_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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791476428230203724 X-GMAIL-MSGID: 1791476428230203724 gcc/ChangeLog: * config.in: Regenerate. * config/loongarch/genopts/loongarch.opt.in: Add compilation option mrelax. And set the initial value of explicit-relocs according to the detection status. * config/loongarch/gnu-user.h: When compiling with -mno-relax, pass the --no-relax option to the linker. * config/loongarch/loongarch-driver.h (ASM_SPEC): When compiling with -mno-relax, pass the -mno-relax option to the assembler. * config/loongarch/loongarch-opts.h (HAVE_AS_MRELAX_OPTION): Define macro. * config/loongarch/loongarch.opt: Regenerate. * configure: Regenerate. * configure.ac: Add detection of support for binutils relax function. (cherry picked from commint 9bab65a77049edcc7afc59532173206ee816e726) --- gcc/config.in | 12 +++++++ gcc/config/loongarch/genopts/loongarch.opt.in | 5 +++ gcc/config/loongarch/gnu-user.h | 4 +-- gcc/config/loongarch/loongarch-opts.h | 4 +++ gcc/config/loongarch/loongarch.opt | 5 +++ gcc/configure | 31 +++++++++++++++++++ gcc/configure.ac | 4 +++ 7 files changed, 63 insertions(+), 2 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index cc638759a40..f5b6287a96a 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -630,6 +630,12 @@ #endif +/* Define if your assembler supports -mrelax option. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_MRELAX_OPTION +#endif + + /* Define if your assembler supports .mspabi_attribute. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_MSPABI_ATTRIBUTE @@ -2214,6 +2220,12 @@ #endif +/* Define which stat syscall is able to handle 64bit indodes. */ +#ifndef USED_FOR_TARGET +#undef HOST_STAT_FOR_64BIT_INODES +#endif + + /* Define as const if the declaration of iconv() needs const. */ #ifndef USED_FOR_TARGET #undef ICONV_CONST diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 61e7d72a0a1..edc2ed045d7 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -177,3 +177,8 @@ Enum(cmodel) String(@@STR_CMODEL_EXTREME@@) Value(CMODEL_EXTREME) mcmodel= Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Specify the code model. + +mrelax +Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION) +Take advantage of linker relaxations to reduce the number of instructions +required to materialize symbol addresses. diff --git a/gcc/config/loongarch/gnu-user.h b/gcc/config/loongarch/gnu-user.h index f050078da52..28ac8b0e1f6 100644 --- a/gcc/config/loongarch/gnu-user.h +++ b/gcc/config/loongarch/gnu-user.h @@ -46,8 +46,8 @@ along with GCC; see the file COPYING3. If not see #define GNU_USER_TARGET_LINK_SPEC \ "%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \ "%{!shared: %{static} %{!static: %{rdynamic:-export-dynamic} " \ - "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" - + "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" \ + "%{mno-relax: --no-relax}" /* Similar to standard Linux, but adding -ffast-math support. */ #undef GNU_USER_TARGET_MATHFILE_SPEC diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index eaa6fc07448..60e682f57a0 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -87,4 +87,8 @@ loongarch_config_target (struct loongarch_target *target, while -m[no]-memcpy imposes a global constraint. */ #define TARGET_DO_OPTIMIZE_BLOCK_MOVE_P loongarch_do_optimize_block_move_p() +#ifndef HAVE_AS_MRELAX_OPTION +#define HAVE_AS_MRELAX_OPTION 0 +#endif + #endif /* LOONGARCH_OPTS_H */ diff --git a/gcc/config/loongarch/loongarch.opt b/gcc/config/loongarch/loongarch.opt index 3ff0d860413..78b5e0cc452 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -184,3 +184,8 @@ Enum(cmodel) String(extreme) Value(CMODEL_EXTREME) mcmodel= Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Specify the code model. + +mrelax +Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION) +Take advantage of linker relaxations to reduce the number of instructions +required to materialize symbol addresses. diff --git a/gcc/configure b/gcc/configure index b4907d258be..67cdd92a4f3 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28871,6 +28871,37 @@ if test $gcc_cv_as_loongarch_dtprelword != yes; then $as_echo "#define HAVE_AS_DTPRELWORD 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mrelax option" >&5 +$as_echo_n "checking assembler for -mrelax option... " >&6; } +if ${gcc_cv_as_loongarch_relax+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_loongarch_relax=no + if test x$gcc_cv_as != x; then + $as_echo '.text' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mrelax -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_loongarch_relax=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_loongarch_relax" >&5 +$as_echo "$gcc_cv_as_loongarch_relax" >&6; } +if test $gcc_cv_as_loongarch_relax = yes; then + +$as_echo "#define HAVE_AS_MRELAX_OPTION 1" >>confdefs.h + +fi + ;; s390*-*-*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .gnu_attribute support" >&5 diff --git a/gcc/configure.ac b/gcc/configure.ac index d369c4717b2..e08ac5f4b49 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5336,6 +5336,10 @@ x: .dtprelword x+0x8000],, [AC_DEFINE(HAVE_AS_DTPRELWORD, 1, [Define if your assembler supports .dtprelword.])]) + gcc_GAS_CHECK_FEATURE([-mrelax option], gcc_cv_as_loongarch_relax, + [-mrelax], [.text],, + [AC_DEFINE(HAVE_AS_MRELAX_OPTION, 1, + [Define if your assembler supports -mrelax option.])]) ;; s390*-*-*) gcc_GAS_CHECK_FEATURE([.gnu_attribute support], From patchwork Wed Feb 21 03:08:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203876 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp803838dyc; Tue, 20 Feb 2024 19:11:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLLz831s1uqa2anG6gSIFI7bvQ6upk4sXf6N62Kgm3BqMg4XqiimEyTZuWszL35EXD1F9VVAMXlWLBpb/HDYJNkcjOZg== X-Google-Smtp-Source: AGHT+IEnNHGidGZ2Ts46KwMHiHJaH5gVOuJm2fmjk3r5Dqwm4gmP9uIjxrX2hTuny9qFX+g3OymW X-Received: by 2002:ad4:5ba3:0:b0:68f:6bce:8500 with SMTP id 3-20020ad45ba3000000b0068f6bce8500mr8864624qvq.13.1708485069338; Tue, 20 Feb 2024 19:11:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708485069; cv=pass; d=google.com; s=arc-20160816; b=oLhMnbJbNYmh8UeMqYPIETZwA3OfBbakdpP9YtSPw9IXwvNDJvfaYourlM2AcI+2Yu 6fLFCHg8x14QGJ2acDOkYUb3cDI4I/pzGXDddDXN/xHYquwzTpMr1WbIlap1u4QNtIU2 j8fkgnf9jxmxQVzMPjTNAzi/0A6LVNUYrFnu/NNgrODGJifBaeKBXOgmoL48lf1Dsn2b dAD76NdikYmQbJKU+bZy7oP4YKN8qoz59q0ocd1eugTSYXtadoISnF7hahx3vF1nks1C 0k/uYQRhHrdmVIxfGn2y8DeaBlLwgR1m3jTooWGx/uJ6PBuXtbmKN60vKVTrbI4IZw4k NNaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=0XOiSJuUlYHJ5XDPJhOP9Mv6ohanvdAc5GMYAa9E0LA=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=dXPAFK/TLg2x0xgtNmJQo3OODCyExa1rMCK8meX7CX85BwJzcERoHwKWrNq/GVMBcq RkQwqLwWeWZ4nEDJ1V3Tb8w2JjXxYIAGmSymK/p5Lz1IWmd+IRNHLuq0uFHsGLZOHSTq 4gpde9O9iOk5juwjFqy8qIaxlo55JasU0h1SpKkdOMq99MxW3HCjhqotDu4N/TSF0IY9 oZF26qaCa3Z2KcKUPWkPWK+CHTs6S7YVHI0gsmpP3L5a7/btuJyjTvCiczcfvSv4MOF3 yI5QrPlGrdkj+fH/il9vnoTF7OTK7uVpGYF+x3v8hsscoODUXFvccGcjSCEHl+GNqdj3 RbBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); 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 (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u7-20020a0562141c0700b0068cf8ab1139si10251068qvc.374.2024.02.20.19.11.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:11:09 -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; arc=pass (i=1); 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 0BC3C3858C60 for ; Wed, 21 Feb 2024 03:11:09 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 40BA83858D20 for ; Wed, 21 Feb 2024 03:08:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 40BA83858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 40BA83858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484942; cv=none; b=Edtbyg96aR4PNRzdX1iJcZRc4G+x1ly3C2FPugmIvmO017Q6YybmecHTsimAM5XU7tv/W0+2vJEa2qDZ55k2ybkI/2KI7gv8QJThRhBtLH729HP9Rx166N8cge7+U2e2rsARdfyGb865vmBP2Cqs3o17KwbjJlAt1gg+TTCAK0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484942; c=relaxed/simple; bh=HnqPv7SDvjx9MTTdAypZryGQFa18Aw3L2T2YZzta04Q=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=ZMeZ5uoPww93DBxDFbalF2zD8aXZEz+4vaUQf6ffEB2yHeRL8u6S6beC7xFyxKPeX/f3cU95vtjc7OgtUDoO3kr3/Ngdt/J92zxInrmus9Ikv260+IOrT1LwPqID0cJh22kD3pYwfPyQhkv559eZsQqNyAO01mpdpF2Js/oEwak= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Dx6uhIadVl1acPAA--.21075S3; Wed, 21 Feb 2024 11:08:56 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLs88adVlyGw9AA--.26359S5; Wed, 21 Feb 2024 11:08:55 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v1 3/4] LoongArch: Disable relaxation if the assembler don't support conditional branch relaxation [PR112330] Date: Wed, 21 Feb 2024 11:08:40 +0800 Message-Id: <20240221030841.23454-4-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030841.23454-1-chenglulu@loongson.cn> References: <20240221030841.23454-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxLs88adVlyGw9AA--.26359S5 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3ury5ZFykKw13Gw4kWryxXrc_yoWDtw1Dpa 47urnxtF48Grn3Gw1Dt34fWwnxA3Z2gr12va1aqr18Ca15Xr10vF40yFnxXFn7Ww4rWry2 qrnYka17uF1DA3XCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUvIb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE 14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw 1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 4j6F4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jo sjUUUUUU= X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791476440180222042 X-GMAIL-MSGID: 1791476440180222042 From: Xi Ruoyao As the commit message of r14-4674 has indicated, if the assembler does not support conditional branch relaxation, a relocation overflow may happen on conditional branches when relaxation is enabled because the number of NOP instructions inserted by the assembler will be more than the number estimated by GCC. To work around this issue, disable relaxation by default if the assembler is detected incapable to perform conditional branch relaxation at GCC build time. We also need to pass -mno-relax to the assembler to really disable relaxation. But, if the assembler does not support -mrelax option at all, we should not pass -mno-relax to the assembler or it will immediately error out. Also handle this with the build time assembler capability probing, and add a pair of options -m[no-]pass-mrelax-to-as to allow using a different assembler from the build-time one. With this change, if GCC is built with GAS 2.41, relaxation will be disabled by default. So the default value of -mexplicit-relocs= is also changed to 'always' if -mno-relax is specified or implied by the build-time default, because using assembler macros for symbol addresses produces no benefit when relaxation is disabled. gcc/ChangeLog: PR target/112330 * config/loongarch/genopts/loongarch.opt.in: Add -m[no]-pass-relax-to-as. Change the default of -m[no]-relax to account conditional branch relaxation support status. * config/loongarch/loongarch.opt: Regenerate. * configure.ac (gcc_cv_as_loongarch_cond_branch_relax): Check if the assembler supports conditional branch relaxation. * configure: Regenerate. * config.in: Regenerate. Note that there are some unrelated changes introduced by r14-5424 (which does not contain a config.in regeneration). * config/loongarch/loongarch-opts.h (HAVE_AS_COND_BRANCH_RELAXATION): Define to 0 if not defined. * config/loongarch/loongarch-driver.h (ASM_MRELAX_DEFAULT): Define. (ASM_MRELAX_SPEC): Define. (ASM_SPEC): Use ASM_MRELAX_SPEC instead of "%{mno-relax}". * config/loongarch/loongarch.cc: Take the setting of -m[no-]relax into account when determining the default of -mexplicit-relocs=. * doc/invoke.texi: Document -m[no-]relax and -m[no-]pass-mrelax-to-as for LoongArch. Update the default value of -mexplicit-relocs=. (cherry picked from commit fe23a2ff1f5072559552be0e41ab55bf72f5c79f) --- gcc/config.in | 6 ++++ gcc/config/loongarch/genopts/loongarch.opt.in | 6 +++- gcc/config/loongarch/loongarch-opts.h | 4 +++ gcc/config/loongarch/loongarch.h | 17 ++++++++- gcc/config/loongarch/loongarch.opt | 6 +++- gcc/configure | 35 +++++++++++++++++++ gcc/configure.ac | 10 ++++++ gcc/doc/invoke.texi | 24 ++++++++++++- 8 files changed, 104 insertions(+), 4 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index f5b6287a96a..f3bdcb4cdda 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -367,6 +367,12 @@ #endif +/* Define if your assembler supports conditional branch relaxation. */ +#ifndef USED_FOR_TARGET +#undef HAVE_AS_COND_BRANCH_RELAXATION +#endif + + /* Define if your assembler supports the --debug-prefix-map option. */ #ifndef USED_FOR_TARGET #undef HAVE_AS_DEBUG_PREFIX_MAP diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index edc2ed045d7..420a3941b3b 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -179,6 +179,10 @@ Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Specify the code model. mrelax -Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION) +Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION && HAVE_AS_COND_BRANCH_RELAXATION) Take advantage of linker relaxations to reduce the number of instructions required to materialize symbol addresses. + +mpass-mrelax-to-as +Target Var(loongarch_pass_mrelax_to_as) Init(HAVE_AS_MRELAX_OPTION) +Pass -mrelax or -mno-relax option to the assembler. diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index 60e682f57a0..bdf79ecc193 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -91,4 +91,8 @@ loongarch_config_target (struct loongarch_target *target, #define HAVE_AS_MRELAX_OPTION 0 #endif +#ifndef HAVE_AS_COND_BRANCH_RELAXATION +#define HAVE_AS_COND_BRANCH_RELAXATION 0 +#endif + #endif /* LOONGARCH_OPTS_H */ diff --git a/gcc/config/loongarch/loongarch.h b/gcc/config/loongarch/loongarch.h index 8d08b84c8eb..28ab87eb660 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -69,8 +69,23 @@ along with GCC; see the file COPYING3. If not see #define SUBTARGET_ASM_SPEC "" #endif +#if HAVE_AS_MRELAX_OPTION && HAVE_AS_COND_BRANCH_RELAXATION +#define ASM_MRELAX_DEFAULT "%{!mrelax:%{!mno-relax:-mrelax}}" +#else +#define ASM_MRELAX_DEFAULT "%{!mrelax:%{!mno-relax:-mno-relax}}" +#endif + +#if HAVE_AS_MRELAX_OPTION +#define ASM_MRELAX_SPEC \ + "%{!mno-pass-mrelax-to-as:%{mrelax} %{mno-relax} " ASM_MRELAX_DEFAULT "}" +#else +#define ASM_MRELAX_SPEC \ + "%{mpass-mrelax-to-as:%{mrelax} %{mno-relax} " ASM_MRELAX_DEFAULT "}" +#endif + #undef ASM_SPEC -#define ASM_SPEC "%{mabi=*} %{subtarget_asm_spec}" +#define ASM_SPEC \ + "%{mabi=*} " ASM_MRELAX_SPEC " %(subtarget_asm_spec)" /* Extra switches sometimes passed to the linker. */ diff --git a/gcc/config/loongarch/loongarch.opt b/gcc/config/loongarch/loongarch.opt index 78b5e0cc452..3a39dcbd92e 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -186,6 +186,10 @@ Target RejectNegative Joined Enum(cmodel) Var(la_opt_cmodel) Init(CMODEL_NORMAL) Specify the code model. mrelax -Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION) +Target Var(loongarch_mrelax) Init(HAVE_AS_MRELAX_OPTION && HAVE_AS_COND_BRANCH_RELAXATION) Take advantage of linker relaxations to reduce the number of instructions required to materialize symbol addresses. + +mpass-mrelax-to-as +Target Var(loongarch_pass_mrelax_to_as) Init(HAVE_AS_MRELAX_OPTION) +Pass -mrelax or -mno-relax option to the assembler. diff --git a/gcc/configure b/gcc/configure index 67cdd92a4f3..ac904c88f9f 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28900,6 +28900,41 @@ if test $gcc_cv_as_loongarch_relax = yes; then $as_echo "#define HAVE_AS_MRELAX_OPTION 1" >>confdefs.h +fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for conditional branch relaxation support" >&5 +$as_echo_n "checking assembler for conditional branch relaxation support... " >&6; } +if ${gcc_cv_as_loongarch_cond_branch_relax+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_loongarch_cond_branch_relax=no + if test x$gcc_cv_as != x; then + $as_echo 'a: + .rept 32769 + nop + .endr + beq $a0,$a1,a' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_loongarch_cond_branch_relax=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_loongarch_cond_branch_relax" >&5 +$as_echo "$gcc_cv_as_loongarch_cond_branch_relax" >&6; } +if test $gcc_cv_as_loongarch_cond_branch_relax = yes; then + +$as_echo "#define HAVE_AS_COND_BRANCH_RELAXATION 1" >>confdefs.h + fi ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index e08ac5f4b49..87ae2d88e79 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5340,6 +5340,16 @@ x: [-mrelax], [.text],, [AC_DEFINE(HAVE_AS_MRELAX_OPTION, 1, [Define if your assembler supports -mrelax option.])]) + gcc_GAS_CHECK_FEATURE([conditional branch relaxation support], + gcc_cv_as_loongarch_cond_branch_relax, + [--fatal-warnings], + [a: + .rept 32769 + nop + .endr + beq $a0,$a1,a],, + [AC_DEFINE(HAVE_AS_COND_BRANCH_RELAXATION, 1, + [Define if your assembler supports conditional branch relaxation.])]) ;; s390*-*-*) gcc_GAS_CHECK_FEATURE([.gnu_attribute support], diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index f4fdd8e6509..8f5c7abea64 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1004,7 +1004,7 @@ Objective-C and Objective-C++ Dialects}. -mcond-move-float -mno-cond-move-float @gol -memcpy -mno-memcpy -mstrict-align -mno-strict-align @gol -mmax-inline-memcpy-size=@var{n} @gol --mcmodel=@var{code-model}} +-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as} @emph{M32R/D Options} @gccoptlist{-m32r2 -m32rx -m32r @gol @@ -24626,6 +24626,28 @@ global symbol: The data got table must be within +/-8EiB addressing space. @end itemize @end table The default code model is @code{normal}. + +@item -mrelax +@itemx -mno-relax +Take (do not take) advantage of linker relaxations. If +@option{-mpass-mrelax-to-as} is enabled, this option is also passed to +the assembler. The default is determined during GCC build-time by +detecting corresponding assembler support: +@option{-mrelax} if the assembler supports both the @option{-mrelax} +option and the conditional branch relaxation (it's required or the +@code{.align} directives and conditional branch instructions in the +assembly code outputted by GCC may be rejected by the assembler because +of a relocation overflow), @option{-mno-relax} otherwise. + +@item -mpass-mrelax-to-as +@itemx -mno-pass-mrelax-to-as +Pass (do not pass) the @option{-mrelax} or @option{-mno-relax} option +to the assembler. The default is determined during GCC build-time by +detecting corresponding assembler support: +@option{-mpass-mrelax-to-as} if the assembler supports the +@option{-mrelax} option, @option{-mno-pass-mrelax-to-as} otherwise. +This option is mostly useful for debugging, or interoperation with +assemblers different from the build-time one. @end table @node M32C Options From patchwork Wed Feb 21 03:08:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203874 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp803474dyc; Tue, 20 Feb 2024 19:09:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVGKUuE2HyKmaWg953JcTvChl9ogiqwkpG51astvvOePxKrjez1C1opMF13YJ5pJpKxOkONniqF4yVz6qJA63H4JXqilg== X-Google-Smtp-Source: AGHT+IFYYIIbfMW1OPqZNJnaqZlGTVwmI6Kv5Lnlffp8rVQndEvm2kVkTu1tVNsr086o/Ut+v7bK X-Received: by 2002:ac8:4909:0:b0:42d:f7d0:b6cb with SMTP id e9-20020ac84909000000b0042df7d0b6cbmr10295705qtq.51.1708484997744; Tue, 20 Feb 2024 19:09:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484997; cv=pass; d=google.com; s=arc-20160816; b=KqK7vylG/em1C9hYFMdO3qB5ic1Ih4nGkYRJTz7I7/WqYM9wbZCDUeJjoYEjuV5dJJ 2stvklRWxhB6CLCmE31HWc7gVN4ONT93WQRShMsYSpu+Z3cLDvHdGi1jcQbcQ+rvGxWK EAhglCXqyi3/76IG7P/zd98ewXa1BBBgAUalHjLYSG4KGRHWMXhmXnvT16GSXHKVP/cy oqJP5hNcxsxsW7G8jrGTLbvOV8Jol4D5/51tIn4PrOyTjhtyYzcsYldQHjoe1IFfMtBW Q5aK+05UnP3vNmQBNa9F+YmcNWEWc2gww30tZfTfP+8bNGBUZC7s2pJl2r7/aetmNplA vqdg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=c9FvseUrSk3iHd//o8vUhoIed666afg/MsvKQWoXBOI=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=Lwhnj/0QGsvwtEgavd7fhcf0X+son935f3rCoYVdUdQlXokOTuRoGzEobgXHu9iN4A DhGXM3LJzg/+k/v/tM40695SG+PR9Qep/Wc8OQ8nMuLStECQFMKLeJC1d9NkaHOagtTp rGmDsgM9e5n1GcIrTSQUxg2neGHtx4zM6qtU/Ac2QjSFKGi4dQNArcpKzTzm1B+4oFzU dzolcmUNI8C+9qUnZtyKu33P6Iqys3nD/zJYNH1Ss7QU5pKCE84yMarHO558QlBQh+rC 4mKkUJFpK63MOtL3lLkibJ1a7Kd/FrtZzl9+sSSzgrZkNVbuULmHUizDiKsz7hSwpwy5 W3eg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y16-20020a05622a121000b0042c4f58fce4si11278425qtx.48.2024.02.20.19.09.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:09:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 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 5B9B53858C53 for ; Wed, 21 Feb 2024 03:09:57 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 62CCC3858D33 for ; Wed, 21 Feb 2024 03:08:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 62CCC3858D33 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 62CCC3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484941; cv=none; b=qm3BbResEZOS8SB/lfVHGJwT6L+hAluz0Qg7D1s1MDL7NXE1P6scQ11VZq5cCiO1yAbXeRekW+DRSJodBsMYfemuHqLAPYd0BFuT6I44pgi0h07R3lwVIjdzZaPW1QDZUej+hhVlNyOQkygAqLYVZsocxYUbaCTgwHt3A2/GD9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484941; c=relaxed/simple; bh=6uAJMDiYvN5Hc3Z+evhF49Gqdj0sog0+pcfYZJLccto=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=CGGW6AY7ldVK5vhYGrlNgvxCC0CrmpuEN7cOOzsmHgbxrewMVdSjnh4GG1PQiBJ+1f6KpPYmQ3yVnOYABE+y0ZzZTfr7zEcMuNacK+zNbUM1CRrUwWVxSK++KkJP4thWCceC02vbF5ggL8Tj8XjZwWrYZ5sXau7CZeLEuAJi8O8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8CxrutJadVl16cPAA--.40544S3; Wed, 21 Feb 2024 11:08:57 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxLs88adVlyGw9AA--.26359S6; Wed, 21 Feb 2024 11:08:56 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, chenglulu@loongson.cn Subject: [PATCH v1 4/4] LoongArch: Define HAVE_AS_TLS to 0 if it's undefined [PR112299] Date: Wed, 21 Feb 2024 11:08:41 +0800 Message-Id: <20240221030841.23454-5-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030841.23454-1-chenglulu@loongson.cn> References: <20240221030841.23454-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxLs88adVlyGw9AA--.26359S6 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj9xXoWrZFWfXw45Gr47CFW8JF1fAFc_yoWfKFc_X3 Waqr9rWr48Ga10yw1qqFZ3t3WDXa1kJFnIvaykZr4fC3s8Jr13A3y7Wa45AF13KrW8XF98 urWkKr15ur17tosvyTuYvTs0mTUanT9S1TB71UUUUj7qnTZGkaVYY2UrUUUUj1kv1TuYvT s0mT0YCTnIWjqI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUI cSsGvfJTRUUUbS8YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20x vaj40_Wr0E3s1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW5JVW7JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr1j6F4UJwAaw2AFwI0_JF0_Jw1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0c Ia020Ex4CE44I27wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_ WrylYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwI xGrwCY1x0262kKe7AKxVWUAVWUtwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWU JVW8JwCFI7km07C267AKxVWUAVWUtwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4 vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IY x2IY67AKxVW5JVW7JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26c xKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7CjxVAF wI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jwhLnUUUUU= X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791476365407951760 X-GMAIL-MSGID: 1791476365407951760 From: Xi Ruoyao Now loongarch.md uses HAVE_AS_TLS, we need this to fix the failure building a cross compiler if the cross assembler is not installed yet. gcc/ChangeLog: PR target/112299 * config/loongarch/loongarch-opts.h (HAVE_AS_TLS): Define to 0 if not defined yet. (cherry picked from commit 6bf2cebe2bf49919c78814cb447d3aa6e3550d89) --- gcc/config/loongarch/loongarch-opts.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index bdf79ecc193..b4115dd7f85 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -95,4 +95,8 @@ loongarch_config_target (struct loongarch_target *target, #define HAVE_AS_COND_BRANCH_RELAXATION 0 #endif +#ifndef HAVE_AS_TLS +#define HAVE_AS_TLS 0 +#endif + #endif /* LOONGARCH_OPTS_H */