[PATCH] D117565: [RISCV] Fix incomplete asm statement parsing
Luís Marques via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 18 07:23:07 PST 2022
luismarques created this revision.
luismarques added reviewers: asb, mundaym, craig.topper, jrtc27.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, frasercrmck, evandro, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
luismarques requested review of this revision.
Herald added subscribers: llvm-commits, eopXD, MaskRay.
Herald added a project: LLVM.
For instructions without operands, the final `AsmToken::EndOfStatement` wasn't being consumed. In the context of inline assembly, the resulting empty statements would cause extraneous empty lines to be emitted. Fix the issue by consuming the `EndOfStatement` token.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117565
Files:
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/test/CodeGen/RISCV/large-stack.ll
Index: llvm/test/CodeGen/RISCV/large-stack.ll
===================================================================
--- llvm/test/CodeGen/RISCV/large-stack.ll
+++ llvm/test/CodeGen/RISCV/large-stack.ll
@@ -64,12 +64,10 @@
; RV32I-FPELIM-NEXT: add a1, a2, a1
; RV32I-FPELIM-NEXT: #APP
; RV32I-FPELIM-NEXT: nop
-; RV32I-FPELIM-EMPTY:
; RV32I-FPELIM-NEXT: #NO_APP
; RV32I-FPELIM-NEXT: sw a0, 0(a1)
; RV32I-FPELIM-NEXT: #APP
; RV32I-FPELIM-NEXT: nop
-; RV32I-FPELIM-EMPTY:
; RV32I-FPELIM-NEXT: #NO_APP
; RV32I-FPELIM-NEXT: lui a0, 97
; RV32I-FPELIM-NEXT: addi a0, a0, 672
@@ -104,12 +102,10 @@
; RV32I-WITHFP-NEXT: add a1, a2, a1
; RV32I-WITHFP-NEXT: #APP
; RV32I-WITHFP-NEXT: nop
-; RV32I-WITHFP-EMPTY:
; RV32I-WITHFP-NEXT: #NO_APP
; RV32I-WITHFP-NEXT: sw a0, 0(a1)
; RV32I-WITHFP-NEXT: #APP
; RV32I-WITHFP-NEXT: nop
-; RV32I-WITHFP-EMPTY:
; RV32I-WITHFP-NEXT: #NO_APP
; RV32I-WITHFP-NEXT: lui a0, 97
; RV32I-WITHFP-NEXT: addi a0, a0, 688
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===================================================================
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -1912,8 +1912,10 @@
Operands.push_back(RISCVOperand::createToken(Name, NameLoc, isRV64()));
// If there are no more operands, then finish
- if (getLexer().is(AsmToken::EndOfStatement))
+ if (getLexer().is(AsmToken::EndOfStatement)) {
+ getParser().Lex(); // Consume the EndOfStatement.
return false;
+ }
// Parse first operand
if (parseOperand(Operands, Name))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117565.400840.patch
Type: text/x-patch
Size: 1641 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220118/2486e465/attachment.bin>
More information about the llvm-commits
mailing list