[llvm] 7b4dfec - [MCAsmParser] Improve .rept/.irp tests

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 23:49:05 PDT 2024


Author: Fangrui Song
Date: 2024-05-17T23:49:01-07:00
New Revision: 7b4dfec8936f54145297fd2f14bf95a2b8c95f5f

URL: https://github.com/llvm/llvm-project/commit/7b4dfec8936f54145297fd2f14bf95a2b8c95f5f
DIFF: https://github.com/llvm/llvm-project/commit/7b4dfec8936f54145297fd2f14bf95a2b8c95f5f.diff

LOG: [MCAsmParser] Improve .rept/.irp tests

Added: 
    

Modified: 
    llvm/test/MC/AsmParser/macro-irp.s
    llvm/test/MC/AsmParser/macro-rept.s

Removed: 
    llvm/test/MC/AsmParser/macro-rept-err1.s
    llvm/test/MC/AsmParser/macro-rept-err2.s


################################################################################
diff  --git a/llvm/test/MC/AsmParser/macro-irp.s b/llvm/test/MC/AsmParser/macro-irp.s
index 7d4c7cc26942e..d2ddd2a24a0bc 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 cfa66878d9793..0000000000000
--- 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 678b4c7eeee02..0000000000000
--- 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 c1a90b22c9f21..5f4b607a2d557 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


        


More information about the llvm-commits mailing list