From patchwork Wed Feb 21 03:04:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203869 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp802234dyc; Tue, 20 Feb 2024 19:06:03 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW++vF5pa1ftpm1dfWG0nYF3Kz1qu6GAR36MskAg1vl/Uzp55DNCjy2DsqU4nPzbXgs8xJMUPOeA0uzReV+oemnZTmFlw== X-Google-Smtp-Source: AGHT+IE/JN2Oh+vaanqwHSMh8E1rbRiR0yresQqvuTDxbz3DwUJ7sQ+0j0C6gflNt5R1QhBH7Mia X-Received: by 2002:ac8:5a87:0:b0:42d:add5:a866 with SMTP id c7-20020ac85a87000000b0042dadd5a866mr22267939qtc.49.1708484763032; Tue, 20 Feb 2024 19:06:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484763; cv=pass; d=google.com; s=arc-20160816; b=qFxcW/cgjQp6irKP0yaxmDMgxRy6v9DN2QUMrFDE8nN7ustYviIhuGds1d8Ah6Dw+Y q6dvYTfa5wAaAE/mkP2t6Q8F+fRY6X7fC/g36URp21ea8x2I6wJUZyt6NVFqU+U49F38 v2kWFnJUR9cBdiRqaV/6wOZCloVk4i1CiStOrw81mW8WT7ISjbDOyhqhn2tNbGrD4Pa0 9NDSUKz+87R8kZN5Da0tORsT6hWEl0TW2OzSnMusUqplFPNDmw6pO8GF9lR+zAXXBCqx xsUNizjUdlyKS6X2mCucEcWH69WIJXAnTdoZB86V7fK8cSuwE/qnaDHGfuqAv6x3SXJ/ ZSlA== 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=O+bN0W79Vf4f+LTQNMo57eDbtTOPsK0VyBcp4AoDLHQ=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=Lfi73POd/XTqBED2nbtc41we7KZReuMbfu58CLC2529V/pZP2/BEbdXhgSNM8bnOtN xF274vEx3jTxhA/esEeSyf1dFvG+3YYDAmOhH4p75TCgSdTd3i99j5sUwGEN0QjQhEZ5 LSbNsuZ5X93MdN2mb0AU409JsHkv55JeQeb7l2Onv87f0tSaPsxZtPBFv8j4w0LxdSyp NfLOpXLXFAU/WWKJrm+OlKB03mspxjckBS9be7s3rlU1hQ/aau2KizBjqGSjUq30tVCh f43dNe1kVqu8dVIp92FfnSOo6/hUxP4kqlGGNKo4hqWLdLT/eq033htVqLH40CK0Neso PL3w==; 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 i4-20020ac87644000000b0042e2cd06e25si2071680qtr.378.2024.02.20.19.06.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:06:03 -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 4780F3858439 for ; Wed, 21 Feb 2024 03:06:02 +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 8603D3858D20 for ; Wed, 21 Feb 2024 03:05:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8603D3858D20 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 8603D3858D20 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=1708484711; cv=none; b=WHfv7R7d0LLsbxLuZel96bCvksmJv9X82gsgJr7JAk4xFGLrDiULVU/nfnr9MLGoKRIXRqkxTHTiJm8qTu8L04ZtwqUraIOV+NJxwhQr8GIIqHdvknHgSlxfstVeVH8u15uthcO4QE7AjD9rCOYot6VkUkeA8qaljQhTy27UOQ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484711; c=relaxed/simple; bh=heNP0VQI3qE6u9/n4E8unxbAANI8/bb2S1oFnB71FUs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=JA2YFPWMoPjBAjZa90BkRRPrcgocDnQXUyWc4THluewljYOfn/ifetAtYGexR2hemWJhyPXurOxRSrQ/bA2ofmuXaKIK0Sje7Wz+KvYUeOVQrNBpGEhgWL2VCwsa9Ha66oys3Cm44yOV0EQP+EEPw2YtQUaeAZGTFmB5Dv2I3JA= 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 1rccuu-0008CN-DB for gcc-patches@gcc.gnu.org; Tue, 20 Feb 2024 22:05:08 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Bx3+tZaNVll6cPAA--.40379S3; Wed, 21 Feb 2024 11:04:57 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxHs9SaNVl8Ws9AA--.27359S3; Wed, 21 Feb 2024 11:04:57 +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:04:45 +0800 Message-Id: <20240221030448.21863-2-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030448.21863-1-chenglulu@loongson.cn> References: <20240221030448.21863-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxHs9SaNVl8Ws9AA--.27359S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7ury3Jr45JFyUCFyDJFWxXwc_yoW8Ar43p3 9xAwnrJFW8Jr1fKw1qqa93Wws0q3srKr12q3Wagr48CanxJr1UuF4ftrWkXFy0gws5ZFnI qr18Kr43XF90yagCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU7TKZDUUUU 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: 1791476118600446580 X-GMAIL-MSGID: 1791476118600446580 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 f0db67f8c7b..cc719d0c796 100644 --- a/gcc/config/loongarch/loongarch.h +++ b/gcc/config/loongarch/loongarch.h @@ -982,11 +982,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:04:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp802535dyc; Tue, 20 Feb 2024 19:07:01 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmE/Ryr8WthX+SZOjpS8Da+8RObGDX0x/hfF1pe0xdqAuUqHZoGmToPGaJBjyy3RCfS2oZt7I6UnS+XDTKm2dLwXbZbA== X-Google-Smtp-Source: AGHT+IHdNAFeJpXamKrSA8S3qEhZpsB6OBWD00IkeuFSjr1utAoIPrqEKz2UwwR7ZNJ88/gfqVDg X-Received: by 2002:ac8:1403:0:b0:42d:d026:f1b2 with SMTP id k3-20020ac81403000000b0042dd026f1b2mr15921905qtj.14.1708484821294; Tue, 20 Feb 2024 19:07:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484821; cv=pass; d=google.com; s=arc-20160816; b=wU/gCbG4JmRkVgNqy6BcKYUEpYYEksV2h0XKmMBXkkznLAqj7klVg4abgrRPwvwJTR pvQt+VHWBtzCWbWefqft0n4CPCaisVu+LEvg13XqzrENNinSQKm5sKHvJMJ99H18UUI+ tPCJ+wT8nryxtwYig6A6ZKD+6sCUPxvV6s122pnv0tO1z9vTnmPBiNRadYVAmOs3F2i5 GPCXayQfjUKSfkEZpzL2zVouw8Ai16MhRLF03lqe41yJ5ZFzGdKPZMitftFUYwMUn1AB jMjzIS41QNFMUi2fjhtzn/n/TDdSED8FORRvisuLohthezsJTDM0l3vgbLPuf086Dfd9 wV+w== 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=vKJLiV3kHtkRfy58tX5roLZO5qSAkecL+6DmHFRJP6w=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=BA339Rcq8hZ0Ip9yai1/VQMfABXJ44AbHWdAysn0/3monEOFiwdKrdGpPaXerapWxn xtkKtiP25x3V4qjmJpzASziE63p01sCHbiLEikVzs469byxdHEbhtxVaDh1NCUkUueKp JvQH1tiFGznsGusR/lylQ+2nAVpw9aZkQo5muHeUv3Togcv2qusWElPtHpMYe6PLZ6I/ ThYwjTJYnTDzX5uYj8IH5CJnVkSea9tQqZWP3FotyaLzBlS8bo0aEYNED3Jqlc0dWr8X HrLskwisMEncafuWFR/D9/kXVZuOSsVG7j+gQlJXA348CX5Wcdo84ulUiloLfZjtFMFq 4dhA==; 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 f2-20020a05622a104200b0042e2bda5b21si2553239qte.351.2024.02.20.19.07.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:07:01 -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 04C0C3858C30 for ; Wed, 21 Feb 2024 03:07:01 +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 993013858D33 for ; Wed, 21 Feb 2024 03:05:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 993013858D33 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 993013858D33 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=1708484711; cv=none; b=jQSQ87nXomTz94EY44G2MS3JnhU+lER0sqcbtUXnqTcuEWwDg5VGg4j6J+CkZCyzctjTW8SeGlD5tGyFretBTTn2/fTqao9MrxuasIRhue55fNNqxDzMY++AAidvgez5fD4J4KBApZR70/81r2jSwfHKl0p6WadYGjvQNukWbwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484711; c=relaxed/simple; bh=H1QEqJehQ7B147dtZ2a/uKYKF17Toar9D5C+GFObOIs=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=AnvtDehQPj5U/BnBxeLsXighctwJWo8lJuY+wGmJyG0IW+EXrfRAt7oFCHrMD1xKlGXatudEtWD47hXx74l+JaoWMVssgyC4siyQBrDzocA7JZ0Ts/WoUr93loV8kFYtmfx2wHvvkeYr3csS5+87ojDEzplk3uN/oRS+Kb+d5Sc= 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 1rccuu-0008Ci-Cz for gcc-patches@gcc.gnu.org; Tue, 20 Feb 2024 22:05:08 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Cx77taaNVlmqcPAA--.21120S3; Wed, 21 Feb 2024 11:04:58 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxHs9SaNVl8Ws9AA--.27359S4; Wed, 21 Feb 2024 11:04:57 +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:04:46 +0800 Message-Id: <20240221030448.21863-3-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030448.21863-1-chenglulu@loongson.cn> References: <20240221030448.21863-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxHs9SaNVl8Ws9AA--.27359S4 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3Gr48uFWrtr1kCF1Utr4rtFc_yoWxur4rpF y3Zw1ayF48GFs3Gw4Dt3yfWw45ArnrWr12va13tF48Ca1UZr10vF18Gr9rXFyUWa1rury2 qr1rKa1a9a1DAwbCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1a6r1DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUAVWUtwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUeZ2-UUUUU 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: 1791476180101214059 X-GMAIL-MSGID: 1791476180101214059 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 | 6 ++++ gcc/config/loongarch/genopts/loongarch.opt.in | 7 ++++- gcc/config/loongarch/gnu-user.h | 3 +- gcc/config/loongarch/loongarch-opts.h | 4 +++ gcc/config/loongarch/loongarch.opt | 7 ++++- gcc/configure | 31 +++++++++++++++++++ gcc/configure.ac | 4 +++ 7 files changed, 59 insertions(+), 3 deletions(-) diff --git a/gcc/config.in b/gcc/config.in index ef35af16f2f..36a74dd5974 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -636,6 +636,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 diff --git a/gcc/config/loongarch/genopts/loongarch.opt.in b/gcc/config/loongarch/genopts/loongarch.opt.in index 4b9b4ac273e..e7c32e61a50 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -155,7 +155,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS) +Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION) Use %reloc() assembly operators. ; The code model option names for -mcmodel. @@ -188,3 +188,8 @@ Specify the code model. mdirect-extern-access Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0) Avoid using the GOT to access external symbols. + +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 5f1bd60ada3..e9f4bcef1d4 100644 --- a/gcc/config/loongarch/gnu-user.h +++ b/gcc/config/loongarch/gnu-user.h @@ -48,7 +48,8 @@ along with GCC; see the file COPYING3. If not see "%{!shared: %{static} " \ "%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \ "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \ - "%{static-pie: -static -pie --no-dynamic-linker -z text}}" + "%{static-pie: -static -pie --no-dynamic-linker -z text}}" \ + "%{mno-relax: --no-relax}" /* Similar to standard Linux, but adding -ffast-math support. */ diff --git a/gcc/config/loongarch/loongarch-opts.h b/gcc/config/loongarch/loongarch-opts.h index b1ff54426e4..7ea02f4978c 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -92,4 +92,8 @@ loongarch_config_target (struct loongarch_target *target, #define HAVE_AS_EXPLICIT_RELOCS 0 #endif +#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 68018ade73f..e37ed9015de 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -162,7 +162,7 @@ Target Joined RejectNegative UInteger Var(loongarch_max_inline_memcpy_size) Init -mmax-inline-memcpy-size=SIZE Set the max size of memcpy to inline, default is 1024. mexplicit-relocs -Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS) +Target Var(TARGET_EXPLICIT_RELOCS) Init(HAVE_AS_EXPLICIT_RELOCS & !HAVE_AS_MRELAX_OPTION) Use %reloc() assembly operators. ; The code model option names for -mcmodel. @@ -195,3 +195,8 @@ Specify the code model. mdirect-extern-access Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0) Avoid using the GOT to access external symbols. + +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 dec2eca1a45..760bea9d4a0 100755 --- a/gcc/configure +++ b/gcc/configure @@ -29075,6 +29075,37 @@ if test $gcc_cv_as_loongarch_eh_frame_pcrel_encoding_support = yes; then $as_echo "#define HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT 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 ;; diff --git a/gcc/configure.ac b/gcc/configure.ac index c0d067ec271..4f3c4ebb5a5 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5366,6 +5366,10 @@ x: .cfi_endproc],, [AC_DEFINE(HAVE_AS_EH_FRAME_PCREL_ENCODING_SUPPORT, 1, [Define if your assembler supports eh_frame pcrel encoding.])]) + 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:04:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp802272dyc; Tue, 20 Feb 2024 19:06:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXFTaO4gEvIrYtKaJuW5pKFc7AfpszY6sPcI1Dgmrd2tLYv+JvMBPcgDhujlqRNYm6v9/cwBMrNRsALPUuBlZPK0jgodg== X-Google-Smtp-Source: AGHT+IFKYM9cfVMToBa+F7Cc/GfHFc5OZfWbLytVdhpFeB6H+ZDKg3EM8hhATY6Xb9b1PkJmPiR7 X-Received: by 2002:ae9:e30f:0:b0:787:3307:1258 with SMTP id v15-20020ae9e30f000000b0078733071258mr22172641qkf.8.1708484770622; Tue, 20 Feb 2024 19:06:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484770; cv=pass; d=google.com; s=arc-20160816; b=daZUa2HuybtM36vFgxnGQTKOoenxfbtuGhoZUWmlt37nEsO7n8zHHLLWuVRJPyXRwo qT/OZaUjMPLFMiSRz22tWDQOYZORcCURV4hmR6qXqfUL54AWs2IGMLQgXTZWoEwvlcgQ kjvVTM7Cv4+AfAfiMP7UPDspby2Rca9vSrFHHE9FCI0OfOesZaXpacRHdEpYLJrqhr03 Mmwtbx3cBo1lR+2/NxeU35xZsVr1EcqzLGFFkup3p31zGa2IJPUcFGxUOj4R06xp5ceB 8aJLIQZ7zD2Lx2CUgXUjZXSygFXebT0m0oFbS1H7evSUHdflOq919MYSak/Hfsp25gRJ UB9A== 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=TtultUTaJaMp8QuF/86FxhD8oJiUGSnDfWcFwA3NCjA=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=qnEvpA3hkTXcN7XdJ5Hr3423uL+mLgckpVeVchU0J8Ru4506TjmSg3aWDqla8Av2N7 ROvnSkeiS1yR7WzSsYhwKzdYFjPmeKCLemELkUxBfOirdXKhL8mK0D5WkINa38zU8tbt ZtkG2qb+S5V2/5Ox+kN1oVdTiMIoOIHU3TQUUAXBEpCFC2LVUjILdlKvZHXFqYRaZN6u 3thDLT1vDt5QcPyVGBKfvFiSnmA7ePMtUBtPasAc+xFwVCqCNsJM0gogfEQtK537zcuZ pluJVAiQ2kwVCsLlXrR4hw6EYBFxxW9lUbwD+azjHUXZQOb6WwgOPK6ZvOLZSRLsigtB q5AQ==; 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 dy31-20020a05620a60df00b0078741d84705si9719218qkb.381.2024.02.20.19.06.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:06:10 -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 4F8FF3858434 for ; Wed, 21 Feb 2024 03:06:10 +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 874063858D28 for ; Wed, 21 Feb 2024 03:05:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 874063858D28 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 874063858D28 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=1708484712; cv=none; b=IPrQATNJNDIu9YhH9e5bWSYqCapBi77xLRiK0uMiDk4rJ9MeFz+rYYChS4PMrXSxp7/8VqhHFnjiGF/VFbNCHCwx/5Xfydyxrm5IaZH7PKGmMeIUXT7at5SccQ/WBKsHvB3+RO9dfZeD/ZstcPdGhdR1dkAHCwItsh88aCwkL1Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484712; c=relaxed/simple; bh=YLvzOYkRAYOAsqvN5Cv17vXCM8ps5/mRKQRfqBZNfQc=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=oEbWvyOvEcP3gzs/z95ikZP0/P7BJwD3V17MytxVwHx3+KukczxMi65NJroVmVOqWuNKp0VdlD7qMIMxvUtICahYNukS11Fr6pB0BJVlpflCHwW1L1i8m5DnWH+Cvdw3fXadBTJuvX37CuQ61oV3cRWHoIVPWsos/sji+q9k0tM= 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 1rccut-0008Cb-Tx for gcc-patches@gcc.gnu.org; Tue, 20 Feb 2024 22:05:08 -0500 Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8DxbOlcaNVlnqcPAA--.30532S3; Wed, 21 Feb 2024 11:05:00 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxHs9SaNVl8Ws9AA--.27359S5; Wed, 21 Feb 2024 11:04:58 +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:04:47 +0800 Message-Id: <20240221030448.21863-4-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030448.21863-1-chenglulu@loongson.cn> References: <20240221030448.21863-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxHs9SaNVl8Ws9AA--.27359S5 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW3ury5ZFykKw13Gw4kGFyrKrX_yoWDKrWkpa 47uwn8tF48Grn3Gw1qq34fWwnxJ3Wqgr129anIqr18Ca15Xr10vF40yFsxXFn7Ww45Wry7 Xr1Fkaya93WDA3XCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r1Y6r17M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAF wI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxUcCD7UUUUU 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: 1791476126875137491 X-GMAIL-MSGID: 1791476126875137491 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 36a74dd5974..83c98ae1457 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -373,6 +373,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 e7c32e61a50..da6fedd153e 100644 --- a/gcc/config/loongarch/genopts/loongarch.opt.in +++ b/gcc/config/loongarch/genopts/loongarch.opt.in @@ -190,6 +190,10 @@ Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0) Avoid using the GOT to access external symbols. 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 7ea02f4978c..edd41c82b17 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -96,4 +96,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 cc719d0c796..d072522e3cf 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 e37ed9015de..59b1e06d3f2 100644 --- a/gcc/config/loongarch/loongarch.opt +++ b/gcc/config/loongarch/loongarch.opt @@ -197,6 +197,10 @@ Target Var(TARGET_DIRECT_EXTERN_ACCESS) Init(0) Avoid using the GOT to access external symbols. 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 760bea9d4a0..8a92601ef40 100755 --- a/gcc/configure +++ b/gcc/configure @@ -29106,6 +29106,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 4f3c4ebb5a5..f2e61a32d7e 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5370,6 +5370,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 49941bf0370..99657fb44d8 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -1030,7 +1030,7 @@ Objective-C and Objective-C++ Dialects}. -mmax-inline-memcpy-size=@var{n} -mexplicit-relocs -mno-explicit-relocs -mdirect-extern-access -mno-direct-extern-access --mcmodel=@var{code-model}} +-mcmodel=@var{code-model} -mrelax -mpass-mrelax-to-as} @emph{M32R/D Options} @gccoptlist{-m32r2 -m32rx -m32r @@ -25850,6 +25850,28 @@ environments where no dynamic link is performed, like firmwares, OS kernels, executables linked with @option{-static} or @option{-static-pie}. @option{-mdirect-extern-access} is not compatible with @option{-fPIC} or @option{-fpic}. + +@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:04:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 203868 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp802214dyc; Tue, 20 Feb 2024 19:06:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWD5TFzaDyEEyxUQLzwiywb9DseaJrQ7RSO9YzIf2HbqE0y61+mb5IlfRCQdrkNzkcLwNUKE+rz/x3fVIeiXHwMkbF/Og== X-Google-Smtp-Source: AGHT+IH8J5Z7/e45IL6j8mpEdlxzzrqdeN7HXafk3fA+50cI9Fcj1e9bfkbFHk0fh7KBUI1QrpFl X-Received: by 2002:a1f:edc1:0:b0:4cf:d149:9078 with SMTP id l184-20020a1fedc1000000b004cfd1499078mr2835438vkh.8.1708484760366; Tue, 20 Feb 2024 19:06:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708484760; cv=pass; d=google.com; s=arc-20160816; b=aqMFxQ2RWG0Q0PoWtTYE6BSXw954Uhp1AsgB4cIYG66iDI6f6aU6d78bCSh54DEc6p 23U13zjTIiBgs2r8ZUIcHUR2e552icovXP7WaVjxqZoGg1k77reTp6iNbeeX3i01eWIs YDZtZtKwFK/rAic8jMFIZAbOX6SoFt3zASrKKRGvX5tqO5/E/yT4w9giP9Fmt56pd/n9 En4nhY62VEYeXdOhgB80ffHwkWOJjWI++zQrtY2KuGSCSW4HxuRvsFKzl2jIMvCRBC2c rcFyp1/i65bsqCGbZVOP+NVgFqH+6c9jJ9XE3/V5NRSE087rk9mCkkpcm9sRVw6Vptue An5g== 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=HjV7xqEbr2Ia1s4RMvSDrUPoqQlUEhM7KzOXaxBWaXY=; fh=wYRiZnn9nDBltyuQH1H/s7FMOEBgw7D5UzXRQ9Hnwic=; b=pX2Byas0rtOL3Tsh9EjGpwdhh/rT1fs2xj8bs2DPFw40zCUVxGKeDoFIw/dkunbvnw +C1LQwXejPH54WQ6EIMAg2D7p2mxVj+lXYWFQHKHHCASBu2MdXZpc280wyCJLEJbfyIu 9+AkTMR/0XkYE0UZRsK1+e8xVkX3pU7nGuTkgk1vP4dpOZ2QzgAsT0C2/a1nedOkwOxB l2FyW4jHFDkTUdO/yKO7WM90FBzJ3zQ8Gs7gM3lTEZ8QRivPOXuD1rwK3GdAAHXXwGUc MArm6eMRGiE8Um5QEJIQ33bR1C/SsccNDwpHZSQKQnO4jUd6FKjudHD2GsVc3q7xJFnx 7bWQ==; 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 kd21-20020a056214401500b0068f7263c4a7si5733265qvb.571.2024.02.20.19.06.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 19:06:00 -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 E8DC43858C2D for ; Wed, 21 Feb 2024 03:05:59 +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 027343858C5E for ; Wed, 21 Feb 2024 03:05:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 027343858C5E 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 027343858C5E 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=1708484705; cv=none; b=iJcRkTney52lH7OvUmMt7kCd8HfBbk+ne4e1mN0gEOdg0kFbGVQfJ6o7fus/Ap+rOe9jqfPd2QYqjGhBoeppdlUOFUZXDf2bXq3E0VLCo86LrW7rqyF2UuOYPtv6affnITOJceTYP4nCEvz4+AaOvvn9UyusAnuYGxJBPiEWhrI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1708484705; c=relaxed/simple; bh=Qx3sYt/Kcwg37rTFUJFHbf51UcrbQDU7/OUieOjQHCo=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=JKLzyNKeiymgwybn5dzJP27oooLUjWJnkdUV01UxbgKCnYJ6aSVuDPhaVtAZOvLDPLfR73YTOoxJr+6F2auXyfOxErPGFn+rTtPl4zBsiF5Zv9OEfybfFWOk6vM+CDdyHzBfa9gu2qAZ217qWH47FmT2mHN/fNjgSZ7Wv/3FzAE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8CxWOhcaNVloKcPAA--.21227S3; Wed, 21 Feb 2024 11:05:00 +0800 (CST) Received: from loongson-pc.loongson.cn (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8AxHs9SaNVl8Ws9AA--.27359S6; Wed, 21 Feb 2024 11:04:59 +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:04:48 +0800 Message-Id: <20240221030448.21863-5-chenglulu@loongson.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240221030448.21863-1-chenglulu@loongson.cn> References: <20240221030448.21863-1-chenglulu@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8AxHs9SaNVl8Ws9AA--.27359S6 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj9xXoWrZFWfXw45Gr47CFW8JF1fAFc_yoWfKFX_X3 Waqr9rWr48Ja18Xw1qqFZ5t3WDXa18JFnIvayDZr4fC3sxJr13J3y7Wa45AF13KrW8XF9x Z3ykKrn8ur17tosvyTuYvTs0mTUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUj1kv1TuYvT s0mT0YCTnIWjqI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUI cSsGvfJTRUUUb7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20x vaj40_Wr0E3s1l1IIY67AEw4v_JF0_JFyl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AK xVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUco7KUUUUU 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: 1791476115780958564 X-GMAIL-MSGID: 1791476115780958564 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 edd41c82b17..02184e2991a 100644 --- a/gcc/config/loongarch/loongarch-opts.h +++ b/gcc/config/loongarch/loongarch-opts.h @@ -100,4 +100,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 */