[llvm] [MIRLexer][RISCV] Eat a space after the Machine comment (PR #115365)
Michael Maitland via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 7 16:00:33 PST 2024
https://github.com/michaelmaitland updated https://github.com/llvm/llvm-project/pull/115365
>From fb9254b85bff14d72f3033ebde65cc437834bb3a Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 7 Nov 2024 11:36:26 -0800
Subject: [PATCH 1/2] [MIRLexer][RISCV] Eat a space after the Machine comment
The MIRPrinter emits ` :: ` at the start of a MMO. The MIRLexer eats all the
white space after the operand and before the `::` when there is no comment.
We need to eat the space after the comment to allow MIRLexer to parse comments
on a MMO.
---
llvm/lib/CodeGen/MIRParser/MILexer.cpp | 2 +-
.../skip-mir-comment-trailing-whitespace.mir | 28 +++++++++++++++++++
2 files changed, 29 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir
diff --git a/llvm/lib/CodeGen/MIRParser/MILexer.cpp b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
index 1c450b05f49e93..7153902fe2e7a6 100644
--- a/llvm/lib/CodeGen/MIRParser/MILexer.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MILexer.cpp
@@ -726,7 +726,7 @@ StringRef llvm::lexMIToken(StringRef Source, MIToken &Token,
return C.remaining();
}
- C = skipMachineOperandComment(C);
+ C = skipWhitespace(skipMachineOperandComment(C));
if (Cursor R = maybeLexMachineBasicBlock(C, Token, ErrorCallback))
return R.remaining();
diff --git a/llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir b/llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir
new file mode 100644
index 00000000000000..6401b3bde01d9d
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir
@@ -0,0 +1,28 @@
+# NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
+# RUN: llc %s -mtriple=riscv64 -mattr=+v | FileCheck %s
+
+--- |
+ define void @test_vse8(ptr noundef %base, <vscale x 1 x i8> %value, i64 noundef %vl) {
+ ; CHECK-LABEL: test_vse8:
+ ; CHECK: # %bb.0:
+ ; CHECK-NEXT: vsetvli zero, a1, e8, mf8, ta, ma
+ ; CHECK-NEXT: vse8.v v8, (a0)
+ ; CHECK-NEXT: ret
+ call void @llvm.riscv.vse.nxv1i8.i64(<vscale x 1 x i8> %value, ptr %base, i64 %vl)
+ ret void
+ }
+
+ declare void @llvm.riscv.vse.nxv1i8.i64(<vscale x 1 x i8>, ptr nocapture, i64)
+
+---
+name: test_vse8
+tracksRegLiveness: true
+body: |
+ bb.0 (%ir-block.0):
+ liveins: $x10, $v8, $x11
+
+ %2:gprnox0 = COPY $x11
+ %1:vr = COPY $v8
+ %0:gpr = COPY $x10
+ PseudoVSE8_V_MF8 %1, %0, %2, 3 /* e8 */ :: (store unknown-size into %ir.base, align 1)
+ PseudoRET
>From adbacd10ede6bf380dfd3c7c0bd08e50bf0d3b72 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 7 Nov 2024 16:00:09 -0800
Subject: [PATCH 2/2] fixup! move test
---
.../{RISCV => MIR}/skip-mir-comment-trailing-whitespace.mir | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename llvm/test/CodeGen/{RISCV => MIR}/skip-mir-comment-trailing-whitespace.mir (100%)
diff --git a/llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
similarity index 100%
rename from llvm/test/CodeGen/RISCV/skip-mir-comment-trailing-whitespace.mir
rename to llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
More information about the llvm-commits
mailing list