public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/107731] New: error: invalid 'asm': invalid use of '%c'
@ 2022-11-17 6:45 chenglulu at loongson dot cn
2022-11-17 7:38 ` [Bug target/107731] loongarch Operand Modifiers are not documented pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: chenglulu at loongson dot cn @ 2022-11-17 6:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
Bug ID: 107731
Summary: error: invalid 'asm': invalid use of '%c'
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: chenglulu at loongson dot cn
CC: paulhua at gcc dot gnu.org, xry111 at gcc dot gnu.org
Target Milestone: ---
Target: loongarch64-linux-gnu
void
test(void)
{
asm (".long %c0"
::"i"(10));
}
Compiling this test case under loongarch64 failed with the following
information:
test1.c: In function 'test':
test1.c:3:3: error: invalid 'asm': invalid use of '%c'
3 | asm (".long %c0"
| ^~~
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
@ 2022-11-17 7:38 ` pinskia at gcc dot gnu.org
2022-11-17 7:40 ` xry111 at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-17 7:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-11-17
Keywords| |documentation
Ever confirmed|0 |1
Summary|error: invalid 'asm': |loongarch Operand Modifiers
|invalid use of '%c' |are not documented
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
%c does not mean anything in loongarch.
The codes are not documented in the documentation for loonarch though but they
currently only documented in loongarch.cc:
'A' Print a _DB suffix if the memory model requires a release.
'b' Print the address of a memory operand, without offset.
'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.
'G' Print a DBAR insn if the memory model requires a release.
'H' Print address 52-61bit relocation associated with OP.
'h' Print the high-part relocation associated with OP.
'i' Print i if the operand is not a register.
'L' Print the low-part relocation associated with OP.
'm' Print one less than CONST_INT OP in decimal.
'N' Print the inverse of the integer branch condition for comparison OP.
'r' Print address 12-31bit relocation associated with OP.
'R' Print address 32-51bit relocation associated with OP.
'T' Print 'f' for (eq:CC ...), 't' for (ne:CC ...),
'z' for (eq:?I ...), 'n' for (ne:?I ...).
't' Like 'T', but with the EQ/NE cases reversed
'V' Print exact log2 of CONST_INT OP element 0 of a replicated
CONST_VECTOR in decimal.
'W' Print the inverse of the FPU branch condition for comparison OP.
'X' Print CONST_INT OP in hexadecimal format.
'x' Print the low 16 bits of CONST_INT OP in hexadecimal format.
'Y' Print loongarch_fp_conditions[INTVAL (OP)]
'y' Print exact log2 of CONST_INT OP in decimal.
'Z' Print OP and a comma for 8CC, otherwise print nothing.
'z' Print $0 if OP is zero, otherwise print OP normally. */
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
2022-11-17 7:38 ` [Bug target/107731] loongarch Operand Modifiers are not documented pinskia at gcc dot gnu.org
@ 2022-11-17 7:40 ` xry111 at gcc dot gnu.org
2022-11-17 7:41 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: xry111 at gcc dot gnu.org @ 2022-11-17 7:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #2 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> %c does not mean anything in loongarch.
>
> The codes are not documented in the documentation for loonarch though but
> they currently only documented in loongarch.cc:
> 'A' Print a _DB suffix if the memory model requires a release.
> 'b' Print the address of a memory operand, without offset.
> '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.
> 'G' Print a DBAR insn if the memory model requires a release.
> 'H' Print address 52-61bit relocation associated with OP.
> 'h' Print the high-part relocation associated with OP.
> 'i' Print i if the operand is not a register.
> 'L' Print the low-part relocation associated with OP.
> 'm' Print one less than CONST_INT OP in decimal.
> 'N' Print the inverse of the integer branch condition for comparison OP.
> 'r' Print address 12-31bit relocation associated with OP.
> 'R' Print address 32-51bit relocation associated with OP.
> 'T' Print 'f' for (eq:CC ...), 't' for (ne:CC ...),
> 'z' for (eq:?I ...), 'n' for (ne:?I ...).
> 't' Like 'T', but with the EQ/NE cases reversed
> 'V' Print exact log2 of CONST_INT OP element 0 of a replicated
> CONST_VECTOR in decimal.
> 'W' Print the inverse of the FPU branch condition for comparison OP.
> 'X' Print CONST_INT OP in hexadecimal format.
> 'x' Print the low 16 bits of CONST_INT OP in hexadecimal format.
> 'Y' Print loongarch_fp_conditions[INTVAL (OP)]
> 'y' Print exact log2 of CONST_INT OP in decimal.
> 'Z' Print OP and a comma for 8CC, otherwise print nothing.
> 'z' Print $0 if OP is zero, otherwise print OP normally. */
Interestingly it "worked" with GCC 12.2...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
2022-11-17 7:38 ` [Bug target/107731] loongarch Operand Modifiers are not documented pinskia at gcc dot gnu.org
2022-11-17 7:40 ` xry111 at gcc dot gnu.org
@ 2022-11-17 7:41 ` pinskia at gcc dot gnu.org
2022-11-17 7:44 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-17 7:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
MIPS nor RISCV does not define a %c either.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (2 preceding siblings ...)
2022-11-17 7:41 ` pinskia at gcc dot gnu.org
@ 2022-11-17 7:44 ` pinskia at gcc dot gnu.org
2022-11-17 7:47 ` xry111 at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-11-17 7:44 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #2)
> Interestingly it "worked" with GCC 12.2...
I don't see how it could work though.
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4499) default:
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4500) switch (code)
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4501) {
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4502) case REG:
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4503) {
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4504) unsigned
int regno = REGNO (op);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4505) if (letter
&& letter != 'z')
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4506)
output_operand_lossage ("invalid use of '%%%c'", letter);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4507) fprintf
(file, "%s", reg_names[regno]);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4508) }
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4509) break;
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4510)
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4511) case MEM:
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4512) if (letter ==
'D')
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4513)
output_address (GET_MODE (op),
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4514)
plus_constant (Pmode, XEXP (op, 0), 4));
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4515) else if
(letter == 'b')
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4516) {
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4517)
gcc_assert (REG_P (XEXP (op, 0)));
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4518)
loongarch_print_operand (file, XEXP (op, 0), 0);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4519) }
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4520) else if
(letter && letter != 'z')
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4521)
output_operand_lossage ("invalid use of '%%%c'", letter);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4522) else
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4523)
output_address (GET_MODE (op), XEXP (op, 0));
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4524) break;
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4525)
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4526) default:
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4527) if (letter ==
'z' && op == CONST0_RTX (GET_MODE (op)))
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4528) fputs
(reg_names[GP_REG_FIRST], file);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4529) else if
(letter && letter != 'z')
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4530)
output_operand_lossage ("invalid use of '%%%c'", letter);
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4531) else
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4532)
output_addr_const (file, loongarch_strip_unspec_address (op));
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4533) break;
62ec3b5352b3 (chenglulu 2021-11-27 14:58:21 +0800 4534) }
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (3 preceding siblings ...)
2022-11-17 7:44 ` pinskia at gcc dot gnu.org
@ 2022-11-17 7:47 ` xry111 at gcc dot gnu.org
2022-11-17 7:50 ` chenglulu at loongson dot cn
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: xry111 at gcc dot gnu.org @ 2022-11-17 7:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #4)
> (In reply to Xi Ruoyao from comment #2)
> > Interestingly it "worked" with GCC 12.2...
No it does not work. I guess I typed the test command in a wrong SSH
session...
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (4 preceding siblings ...)
2022-11-17 7:47 ` xry111 at gcc dot gnu.org
@ 2022-11-17 7:50 ` chenglulu at loongson dot cn
2022-11-17 7:54 ` chenglulu at loongson dot cn
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: chenglulu at loongson dot cn @ 2022-11-17 7:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #6 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Andrew Pinski from comment #1)
> %c does not mean anything in loongarch.
>
> The codes are not documented in the documentation for loonarch though but
> they currently only documented in loongarch.cc:
> 'A' Print a _DB suffix if the memory model requires a release.
> 'b' Print the address of a memory operand, without offset.
> '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.
> 'G' Print a DBAR insn if the memory model requires a release.
> 'H' Print address 52-61bit relocation associated with OP.
> 'h' Print the high-part relocation associated with OP.
> 'i' Print i if the operand is not a register.
> 'L' Print the low-part relocation associated with OP.
> 'm' Print one less than CONST_INT OP in decimal.
> 'N' Print the inverse of the integer branch condition for comparison OP.
> 'r' Print address 12-31bit relocation associated with OP.
> 'R' Print address 32-51bit relocation associated with OP.
> 'T' Print 'f' for (eq:CC ...), 't' for (ne:CC ...),
> 'z' for (eq:?I ...), 'n' for (ne:?I ...).
> 't' Like 'T', but with the EQ/NE cases reversed
> 'V' Print exact log2 of CONST_INT OP element 0 of a replicated
> CONST_VECTOR in decimal.
> 'W' Print the inverse of the FPU branch condition for comparison OP.
> 'X' Print CONST_INT OP in hexadecimal format.
> 'x' Print the low 16 bits of CONST_INT OP in hexadecimal format.
> 'Y' Print loongarch_fp_conditions[INTVAL (OP)]
> 'y' Print exact log2 of CONST_INT OP in decimal.
> 'Z' Print OP and a comma for 8CC, otherwise print nothing.
> 'z' Print $0 if OP is zero, otherwise print OP normally. */
Sorry, I'll put the ones that will be used in the document.(In reply to Xi
Ruoyao from comment #2)
> (In reply to Andrew Pinski from comment #1)
> > %c does not mean anything in loongarch.
> >
> > The codes are not documented in the documentation for loonarch though but
> > they currently only documented in loongarch.cc:
> > 'A' Print a _DB suffix if the memory model requires a release.
> > 'b' Print the address of a memory operand, without offset.
> > '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.
> > 'G' Print a DBAR insn if the memory model requires a release.
> > 'H' Print address 52-61bit relocation associated with OP.
> > 'h' Print the high-part relocation associated with OP.
> > 'i' Print i if the operand is not a register.
> > 'L' Print the low-part relocation associated with OP.
> > 'm' Print one less than CONST_INT OP in decimal.
> > 'N' Print the inverse of the integer branch condition for comparison OP.
> > 'r' Print address 12-31bit relocation associated with OP.
> > 'R' Print address 32-51bit relocation associated with OP.
> > 'T' Print 'f' for (eq:CC ...), 't' for (ne:CC ...),
> > 'z' for (eq:?I ...), 'n' for (ne:?I ...).
> > 't' Like 'T', but with the EQ/NE cases reversed
> > 'V' Print exact log2 of CONST_INT OP element 0 of a replicated
> > CONST_VECTOR in decimal.
> > 'W' Print the inverse of the FPU branch condition for comparison OP.
> > 'X' Print CONST_INT OP in hexadecimal format.
> > 'x' Print the low 16 bits of CONST_INT OP in hexadecimal format.
> > 'Y' Print loongarch_fp_conditions[INTVAL (OP)]
> > 'y' Print exact log2 of CONST_INT OP in decimal.
> > 'Z' Print OP and a comma for 8CC, otherwise print nothing.
> > 'z' Print $0 if OP is zero, otherwise print OP normally. */
>
> Interestingly it "worked" with GCC 12.2...
(In reply to Xi Ruoyao from comment #5)
> (In reply to Andrew Pinski from comment #4)
> > (In reply to Xi Ruoyao from comment #2)
> > > Interestingly it "worked" with GCC 12.2...
>
> No it does not work. I guess I typed the test command in a wrong SSH
> session...
I have found the error cause, I will push patch later
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (5 preceding siblings ...)
2022-11-17 7:50 ` chenglulu at loongson dot cn
@ 2022-11-17 7:54 ` chenglulu at loongson dot cn
2023-01-24 4:56 ` cvs-commit at gcc dot gnu.org
2023-01-24 5:00 ` chenglulu at loongson dot cn
8 siblings, 0 replies; 10+ messages in thread
From: chenglulu at loongson dot cn @ 2022-11-17 7:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #7 from chenglulu <chenglulu at loongson dot cn> ---
(In reply to Andrew Pinski from comment #3)
> MIPS nor RISCV does not define a %c either.
These two architectures can also fail under the following conditions:
void
test(void)
{
asm (".long %c0"
::"i"(0x12345678));
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (6 preceding siblings ...)
2022-11-17 7:54 ` chenglulu at loongson dot cn
@ 2023-01-24 4:56 ` cvs-commit at gcc dot gnu.org
2023-01-24 5:00 ` chenglulu at loongson dot cn
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-24 4:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by LuluCheng <chenglulu@gcc.gnu.org>:
https://gcc.gnu.org/g:b5ea0f071aca505c82cc8c062e57bf9892900277
commit r13-5319-gb5ea0f071aca505c82cc8c062e57bf9892900277
Author: Lulu Cheng <chenglulu@loongson.cn>
Date: Wed Jan 18 11:06:56 2023 +0800
LoongArch: Fixed a compilation failure with '%c' in inline assembly
[PR107731].
Co-authored-by: Yang Yujie <yangyujie@loongson.cn>
PR target/107731
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.
And port the public operand modifiers information to this document.
gcc/testsuite/ChangeLog:
* gcc.target/loongarch/tst-asm-const.c: Moved to...
* gcc.target/loongarch/pr107731.c: ...here.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug target/107731] loongarch Operand Modifiers are not documented
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
` (7 preceding siblings ...)
2023-01-24 4:56 ` cvs-commit at gcc dot gnu.org
@ 2023-01-24 5:00 ` chenglulu at loongson dot cn
8 siblings, 0 replies; 10+ messages in thread
From: chenglulu at loongson dot cn @ 2023-01-24 5:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107731
chenglulu <chenglulu at loongson dot cn> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|NEW |RESOLVED
--- Comment #9 from chenglulu <chenglulu at loongson dot cn> ---
Fixed
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2023-01-24 5:00 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 6:45 [Bug target/107731] New: error: invalid 'asm': invalid use of '%c' chenglulu at loongson dot cn
2022-11-17 7:38 ` [Bug target/107731] loongarch Operand Modifiers are not documented pinskia at gcc dot gnu.org
2022-11-17 7:40 ` xry111 at gcc dot gnu.org
2022-11-17 7:41 ` pinskia at gcc dot gnu.org
2022-11-17 7:44 ` pinskia at gcc dot gnu.org
2022-11-17 7:47 ` xry111 at gcc dot gnu.org
2022-11-17 7:50 ` chenglulu at loongson dot cn
2022-11-17 7:54 ` chenglulu at loongson dot cn
2023-01-24 4:56 ` cvs-commit at gcc dot gnu.org
2023-01-24 5:00 ` chenglulu at loongson dot cn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).