[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:18:16 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/4] [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/4] 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
>From 9906ab894192b1e82320aad540b2d14f88ee00cf Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 7 Nov 2024 16:08:54 -0800
Subject: [PATCH 3/4] fixup! remove IR
---
.../skip-mir-comment-trailing-whitespace.mir | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
index 6401b3bde01d9d..c67ae487147f38 100644
--- a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
+++ b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
@@ -1,28 +1,17 @@
# 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):
+ bb.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)
+ PseudoVSE8_V_MF8 %1, %0, %2, 3 /* e8 */ :: (store unknown-size, align 1)
PseudoRET
+## NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+# CHECK: {{.*}}
>From 90a1eef7abe6dcedc5ad0b86f1a57a502e79dbf7 Mon Sep 17 00:00:00 2001
From: Michael Maitland <michaeltmaitland at gmail.com>
Date: Thu, 7 Nov 2024 16:18:00 -0800
Subject: [PATCH 4/4] fixup! add tests manually
---
.../skip-mir-comment-trailing-whitespace.mir | 11 +++++++----
.../MIR/skip-mir-comment-trailing-whitespace.s | 17 +++++++++++++++++
2 files changed, 24 insertions(+), 4 deletions(-)
create mode 100644 llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.s
diff --git a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
index c67ae487147f38..b14f132c79da07 100644
--- a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
+++ b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.mir
@@ -1,11 +1,15 @@
-# 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
+# RUN: llc %s -mtriple=riscv64 -mattr=+v -o - | FileCheck %s
---
name: test_vse8
tracksRegLiveness: true
body: |
bb.0:
+ ; 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
liveins: $x10, $v8, $x11
%2:gprnox0 = COPY $x11
@@ -13,5 +17,4 @@ body: |
%0:gpr = COPY $x10
PseudoVSE8_V_MF8 %1, %0, %2, 3 /* e8 */ :: (store unknown-size, align 1)
PseudoRET
-## NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
-# CHECK: {{.*}}
+...
diff --git a/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.s b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.s
new file mode 100644
index 00000000000000..3d813a51300693
--- /dev/null
+++ b/llvm/test/CodeGen/MIR/skip-mir-comment-trailing-whitespace.s
@@ -0,0 +1,17 @@
+ .text
+ .attribute 4, 16
+ .attribute 5, "rv64i2p1_f2p2_d2p2_v1p0_zicsr2p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0"
+ .file "skip-mir-comment-trailing-whitespace.mir"
+ .globl test_vse8 # -- Begin function test_vse8
+ .type test_vse8, at function
+test_vse8: # @test_vse8
+ .cfi_startproc
+# %bb.0:
+ vsetvli zero, a1, e8, mf8, ta, ma
+ vse8.v v8, (a0)
+ ret
+.Lfunc_end0:
+ .size test_vse8, .Lfunc_end0-test_vse8
+ .cfi_endproc
+ # -- End function
+ .section ".note.GNU-stack","", at progbits
More information about the llvm-commits
mailing list