From patchwork Wed Nov 23 06:49:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenglulu X-Patchwork-Id: 24740 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2628917wrr; Tue, 22 Nov 2022 22:51:56 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mRcSMi945krNxpIp8bAvqCIHEsncASjXCzIgY+MXtCmQGkA5QzViv+HhYVZMzrH4nA69x X-Received: by 2002:a17:906:2612:b0:7ad:9c82:6cdb with SMTP id h18-20020a170906261200b007ad9c826cdbmr6077691ejc.233.1669186316377; Tue, 22 Nov 2022 22:51:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669186316; cv=none; d=google.com; s=arc-20160816; b=tc0/H/P/o9QxNKg/6xTlpBSOYQydp4fbD354Xru6t/CDruw+0kQexN3aEfoVgCoE+a Fy1uCjFG6SzA1ek8GBrnLX+JDEluGHjnrt/n+9lQ9b2aC6NtTAnePbffcjUKN851g6qQ hJymWEEDY6AZeajs+xRifk4Mc11ljbKQbIH/tU21ppXru8/35uWDkkkte0GcI+jpwvPr BktwZuFvuCmRnA5vc1n1S6oDo/qLxnK+ABEwEwSWPSJtKUcys2Tg5s5KTsJQZ45FlEwt Hmf8PWycAAaPaLgIKVnFTZXBEAuZUCTTsQxfLRupJKX4JIQkuXq8PNccbuFyAnnIwYdl cq1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dmarc-filter :delivered-to; bh=7jlvglQ7v2quN4tEJ2lOcwWBmwoNaUG2MTJEoD98cnE=; b=H+W8bIXJktDE3MFCOIYsxc1tQd0ZtsN426IJ4QcPThZWrrk7TnZR+ECQ3brYc+bk0o uEifFcahkWfG3Hat51OaImUrSyR1qM9N49z3dnuY+60eGQXCMqVEOrjm1SofM/R81D+L OH7qIbWuku/owcz1vUDS681ScknV7mwxomlzDOmnseCgVfxPLZaQrZHccHD+yUqNq4Bw oJPepQhy/Nod8yb8iWrA1xjGKsdR7xOSrunTpt7puuRcKwUC91NY4poeLSW7zGMiSKFS 0Gyo6+kcsZJlU+snnjV0ZZUtQTqJpUt+LH/aZKRctQ1LNedkRe8umJbMMr69gZ4KYS6t J9RQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id eb10-20020a0564020d0a00b00469047efecbsi13516708edb.62.2022.11.22.22.51.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 22:51:56 -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; 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 54880384F48A for ; Wed, 23 Nov 2022 06:51:47 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 9D5C0385456C for ; Wed, 23 Nov 2022 06:51:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9D5C0385456C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.2.5.5]) by gateway (Coremail) with SMTP id _____8AxB_Hmwn1jBy8AAA--.655S3; Wed, 23 Nov 2022 14:51:18 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxTuDQwn1jFpgYAA--.64211S2; Wed, 23 Nov 2022 14:51:17 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, Lulu Cheng Subject: [PATCH v1] LoongArch: Fixed a compilation failure with '%c' in inline assembly [PR107731]. Date: Wed, 23 Nov 2022 14:49:35 +0800 Message-Id: <20221123064934.1560808-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxTuDQwn1jFpgYAA--.64211S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBjvJXoWxArW8trW3Zw1UWFW3tFW5KFg_yoW5WF4xpF 9xur15tr48Cr9xGrsrJay5Xan0yrs7Gry29a4ftr92kwnrWryqv3W8tF9rXF4UGay5Jry2 qr4xuayUWF1jqwUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUj1kv1TuYvTs0mT0YCTnIWj qI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUIcSsGvfJTRUUU b28YFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20xvaj40_Wr0E3s 1l1IIY67AEw4v_JrI_Jryl8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwA2z4 x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv6xkF7I0E14v26r4UJVWxJr1l e2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27wAqx4xG64xvF2 IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26F4j6r4U JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64vIr41l4I 8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AK xVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcV AFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK8VAvwI8I cIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r 1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07Uimi_UUUUU= X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750268711039064406?= X-GMAIL-MSGID: =?utf-8?q?1750268711039064406?= gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_classify_address): Add precessint for CONST_INT. (loongarch_print_operand): Increase the processing of '%c'. gcc/testsuite/ChangeLog: * gcc.target/loongarch/tst-asm-const.c: Moved to... * gcc.target/loongarch/pr107731.c: ...here. --- gcc/config/loongarch/loongarch.cc | 14 ++++++++++++++ .../loongarch/{tst-asm-const.c => pr107731.c} | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) rename gcc/testsuite/gcc.target/loongarch/{tst-asm-const.c => pr107731.c} (78%) diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc index 8d5d8d965dd..7f02b0bab23 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -2029,6 +2029,11 @@ loongarch_classify_address (struct loongarch_address_info *info, rtx x, return (loongarch_valid_base_register_p (info->reg, mode, strict_p) && loongarch_valid_lo_sum_p (info->symbol_type, mode, info->offset)); + case CONST_INT: + /* Small-integer addresses don't occur very often, but they + are legitimate if $r0 is a valid base register. */ + info->type = ADDRESS_CONST_INT; + return IMM12_OPERAND (INTVAL (x)); default: return false; @@ -4889,6 +4894,7 @@ loongarch_print_operand_reloc (FILE *file, rtx op, bool hi64_part, 'A' Print a _DB suffix if the memory model requires a release. 'b' Print the address of a memory operand, without offset. + 'c' print an integer. 'C' Print the integer branch condition for comparison OP. 'd' Print CONST_INT OP in decimal. 'F' Print the FPU branch condition for comparison OP. @@ -4935,6 +4941,14 @@ loongarch_print_operand (FILE *file, rtx op, int letter) fputs ("_db", file); break; + case 'c': + if (CONST_INT_P (op)) + fprintf (file, HOST_WIDE_INT_PRINT_DEC, INTVAL (op)); + else + output_operand_lossage ("unsupported operand for code '%c'", letter); + + break; + case 'C': loongarch_print_int_branch_condition (file, code, letter); break; diff --git a/gcc/testsuite/gcc.target/loongarch/tst-asm-const.c b/gcc/testsuite/gcc.target/loongarch/pr107731.c similarity index 78% rename from gcc/testsuite/gcc.target/loongarch/tst-asm-const.c rename to gcc/testsuite/gcc.target/loongarch/pr107731.c index 2e04b99e301..80d84c48c6e 100644 --- a/gcc/testsuite/gcc.target/loongarch/tst-asm-const.c +++ b/gcc/testsuite/gcc.target/loongarch/pr107731.c @@ -1,13 +1,13 @@ -/* Test asm const. */ /* { dg-do compile } */ /* { dg-final { scan-assembler-times "foo:.*\\.long 1061109567.*\\.long 52" 1 } } */ + int foo () { __asm__ volatile ( "foo:" "\n\t" - ".long %a0\n\t" - ".long %a1\n\t" + ".long %c0\n\t" + ".long %c1\n\t" : :"i"(0x3f3f3f3f), "i"(52) :