aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-05-17 23:49:01 -0700
committerFangrui Song <i@maskray.me>2024-05-17 23:49:01 -0700
commit7b4dfec8936f54145297fd2f14bf95a2b8c95f5f (patch)
tree53afd620040a9a1f1523284b453f960cd10b1a92
parent2a97b507dc643b7ee3bc651b3f21b754cfba433c (diff)
downloadllvm-7b4dfec8936f54145297fd2f14bf95a2b8c95f5f.zip
llvm-7b4dfec8936f54145297fd2f14bf95a2b8c95f5f.tar.gz
llvm-7b4dfec8936f54145297fd2f14bf95a2b8c95f5f.tar.bz2
[MCAsmParser] Improve .rept/.irp tests
-rw-r--r--llvm/test/MC/AsmParser/macro-irp.s47
-rw-r--r--llvm/test/MC/AsmParser/macro-rept-err1.s6
-rw-r--r--llvm/test/MC/AsmParser/macro-rept-err2.s7
-rw-r--r--llvm/test/MC/AsmParser/macro-rept.s22
4 files changed, 53 insertions, 29 deletions
diff --git a/llvm/test/MC/AsmParser/macro-irp.s b/llvm/test/MC/AsmParser/macro-irp.s
index 7d4c7cc..d2ddd2a 100644
--- a/llvm/test/MC/AsmParser/macro-irp.s
+++ b/llvm/test/MC/AsmParser/macro-irp.s
@@ -1,23 +1,40 @@
-// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -triple=x86_64 a.s | FileCheck %s
-.irp reg,%eax,%ebx
- pushl \reg
+#--- a.s
+# CHECK: pushq %rax
+# CHECK-NEXT: pushq %rbx
+# CHECK-NEXT: pushq %rcx
+.irp reg,%rax,%rbx
+ pushq \reg
.endr
-pushl %ecx
-
-// CHECK: pushl %eax
-// CHECK: pushl %ebx
-// CHECK-NEXT: pushl %ecx
+pushq %rcx
+# CHECK: addl %eax, 4
+# CHECK-NEXT: addl %eax, 3
+# CHECK-NEXT: addl %eax, 5
+# CHECK-NEXT: addl %ebx, 4
+# CHECK-NEXT: addl %ebx, 3
+# CHECK-NEXT: addl %ebx, 5
+# CHECK-EMPTY:
+# CHECK-NEXT: nop
.irp reg,%eax,%ebx
.irp imm,4,3,5
addl \reg, \imm
+.endr # comment after .endr
+.endr ;
+nop
+
+# CHECK: xorl %eax, %eax
+# CHECK-EMPTY:
+# CHECK-NEXT: nop
+.irp reg,%eax
+xor \reg,\reg
.endr
-.endr
+# 99 "a.s"
+nop
-// CHECK: addl %eax, 4
-// CHECK: addl %eax, 3
-// CHECK: addl %eax, 5
-// CHECK: addl %ebx, 4
-// CHECK: addl %ebx, 3
-// CHECK: addl %ebx, 5
+# RUN: not llvm-mc -triple=x86_64 err1.s 2>&1 | FileCheck %s --check-prefix=ERR1
+# ERR1: .s:1:1: error: no matching '.endr' in definition
+#--- err1.s
+.irp reg,%eax
diff --git a/llvm/test/MC/AsmParser/macro-rept-err1.s b/llvm/test/MC/AsmParser/macro-rept-err1.s
deleted file mode 100644
index cfa6687..0000000
--- a/llvm/test/MC/AsmParser/macro-rept-err1.s
+++ /dev/null
@@ -1,6 +0,0 @@
-// RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2> %t
-// RUN: FileCheck < %t %s
-
-.endr
-
-// CHECK: unmatched '.endr' directive
diff --git a/llvm/test/MC/AsmParser/macro-rept-err2.s b/llvm/test/MC/AsmParser/macro-rept-err2.s
deleted file mode 100644
index 678b4c7..0000000
--- a/llvm/test/MC/AsmParser/macro-rept-err2.s
+++ /dev/null
@@ -1,7 +0,0 @@
-// RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2> %t
-// RUN: FileCheck < %t %s
-
-.rept 3
-.long
-
-// CHECK: no matching '.endr' in definition
diff --git a/llvm/test/MC/AsmParser/macro-rept.s b/llvm/test/MC/AsmParser/macro-rept.s
index c1a90b2..5f4b607 100644
--- a/llvm/test/MC/AsmParser/macro-rept.s
+++ b/llvm/test/MC/AsmParser/macro-rept.s
@@ -1,5 +1,7 @@
-# RUN: llvm-mc -triple x86_64 %s | FileCheck %s
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -triple=x86_64 a.s | FileCheck %s
+#--- a.s
.rept 2
.long 1
.endr
@@ -23,3 +25,21 @@
# CHECK-NEXT: .long 0
# CHECK-NEXT: .long 0
# CHECK-NEXT: .long 42
+
+# RUN: not llvm-mc -triple=x86_64 err1.s 2>&1 | FileCheck %s --check-prefix=ERR1
+# ERR1: .s:1:6: error: unmatched '.endr' directive
+#--- err1.s
+.endr
+
+# RUN: not llvm-mc -triple=x86_64 err2.s 2>&1 | FileCheck %s --check-prefix=ERR2
+# ERR2: .s:1:1: error: no matching '.endr' in definition
+#--- err2.s
+.rept 3
+.long
+
+# RUN: not llvm-mc -triple=x86_64 err3.s 2>&1 | FileCheck %s --check-prefix=ERR3
+# ERR3: .s:3:7: error: expected newline
+#--- err3.s
+.rept 1
+.long 0
+.endr ab