From patchwork Fri Dec 9 09:41:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cheng X-Patchwork-Id: 61724 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F224C38DC1B6 for ; Fri, 9 Dec 2022 09:42:15 +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 AE8773AAA005; Fri, 9 Dec 2022 09:41:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AE8773AAA005 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 _____8DxtfDhApNjvmIEAA--.9981S3; Fri, 09 Dec 2022 17:41:54 +0800 (CST) Received: from 5.5.5 (unknown [10.2.5.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8BxTuDdApNj8hwpAA--.35188S2; Fri, 09 Dec 2022 17:41:53 +0800 (CST) From: Lulu Cheng To: gcc-patches@gcc.gnu.org, pinskia@gcc.gnu.org, richard.sandiford@arm.com Cc: xry111@xry111.site, i@xen0n.name, xuchenghua@loongson.cn, Lulu Cheng , Yang Yujie Subject: [PATCH v3] LoongArch: Fixed a compilation failure with '%c' in inline assembly [PR107731]. Date: Fri, 9 Dec 2022 17:41:42 +0800 Message-Id: <20221209094141.1565366-1-chenglulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8BxTuDdApNj8hwpAA--.35188S2 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129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TnIWIevJa73UjIFyTuYvjxU 74lkDUUUU 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" There is description of '%c' "%n" "%a" and "%l" in section 17.5 of gccint.pdf. So I can understand that these descriptors are the ones that the common code implementation back end has to support, right? But I don't see the use of these descriptors in gcc.pdf.Now I want to add the descriptor information under loongarch. I had to add '%c' to the schema section. Is there a better solution to this? V2 -> v3: 1. Correct a clerical error. 2. Adding document for loongarch operand modifiers. --- Co-authored-by: Yang Yujie gcc/ChangeLog: * config/loongarch/loongarch.cc (loongarch_classify_address): Add precessint for CONST_INT. (loongarch_print_operand_reloc): Operand modifier 'c' is supported. (loongarch_print_operand): Increase the processing of '%c'. * doc/extend.texi: Adds documents for LoongArch operand modifiers. gcc/testsuite/ChangeLog: * gcc.target/loongarch/tst-asm-const.c: Moved to... * gcc.target/loongarch/pr107731.c: ...here. --- gcc/config/loongarch/loongarch.cc | 14 ++++++++++++++ gcc/doc/extend.texi | 16 ++++++++++++++++ .../loongarch/{tst-asm-const.c => pr107731.c} | 6 +++--- 3 files changed, 33 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 c6b03fcf2f9..cdf190b985e 100644 --- a/gcc/config/loongarch/loongarch.cc +++ b/gcc/config/loongarch/loongarch.cc @@ -2075,6 +2075,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; @@ -4933,6 +4938,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. @@ -4979,6 +4985,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/doc/extend.texi b/gcc/doc/extend.texi index b1dd39e64b8..5a8b9489f3d 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -11374,6 +11374,22 @@ constant. Used to select the specified bit position. @item @code{x} @tab Equivialent to @code{X}, but only for pointers. @end multitable +@anchor{loongarchOperandmodifiers} +@subsubsection LoongArch Operand Modifiers + +The list below describes the supported modifiers and their effects for LoongArch. + +@multitable @columnfractions .10 .90 +@headitem Modifier @tab Description +@item @code{c} @tab Print a constant integer operand in decimal. +@item @code{d} @tab Same as @code{c}. +@item @code{i} @tab Print the character ''@code{i}'' if the operand is not a register. +@item @code{m} @tab Same as @code{c}, but the printed value is @code{operand - 1}. +@item @code{X} @tab Print a constant integer operand in hexadecimal. +@item @code{z} @tab Print the operand in its unmodified form, followed by a comma. +@end multitable + + @lowersections @include md.texi @raisesections 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) :