Skip to content

Commit 7b4dfec

Browse files
committed
[MCAsmParser] Improve .rept/.irp tests
1 parent 2a97b50 commit 7b4dfec

File tree

4 files changed

+53
-29
lines changed

4 files changed

+53
-29
lines changed

llvm/test/MC/AsmParser/macro-irp.s

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,40 @@
1-
// RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
1+
# RUN: rm -rf %t && split-file %s %t && cd %t
2+
# RUN: llvm-mc -triple=x86_64 a.s | FileCheck %s
23

3-
.irp reg,%eax,%ebx
4-
pushl \reg
4+
#--- a.s
5+
# CHECK: pushq %rax
6+
# CHECK-NEXT: pushq %rbx
7+
# CHECK-NEXT: pushq %rcx
8+
.irp reg,%rax,%rbx
9+
pushq \reg
510
.endr
6-
pushl %ecx
7-
8-
// CHECK: pushl %eax
9-
// CHECK: pushl %ebx
10-
// CHECK-NEXT: pushl %ecx
11+
pushq %rcx
1112

13+
# CHECK: addl %eax, 4
14+
# CHECK-NEXT: addl %eax, 3
15+
# CHECK-NEXT: addl %eax, 5
16+
# CHECK-NEXT: addl %ebx, 4
17+
# CHECK-NEXT: addl %ebx, 3
18+
# CHECK-NEXT: addl %ebx, 5
19+
# CHECK-EMPTY:
20+
# CHECK-NEXT: nop
1221
.irp reg,%eax,%ebx
1322
.irp imm,4,3,5
1423
addl \reg, \imm
24+
.endr # comment after .endr
25+
.endr ;
26+
nop
27+
28+
# CHECK: xorl %eax, %eax
29+
# CHECK-EMPTY:
30+
# CHECK-NEXT: nop
31+
.irp reg,%eax
32+
xor \reg,\reg
1533
.endr
16-
.endr
34+
# 99 "a.s"
35+
nop
1736

18-
// CHECK: addl %eax, 4
19-
// CHECK: addl %eax, 3
20-
// CHECK: addl %eax, 5
21-
// CHECK: addl %ebx, 4
22-
// CHECK: addl %ebx, 3
23-
// CHECK: addl %ebx, 5
37+
# RUN: not llvm-mc -triple=x86_64 err1.s 2>&1 | FileCheck %s --check-prefix=ERR1
38+
# ERR1: .s:1:1: error: no matching '.endr' in definition
39+
#--- err1.s
40+
.irp reg,%eax

llvm/test/MC/AsmParser/macro-rept-err1.s

Lines changed: 0 additions & 6 deletions
This file was deleted.

llvm/test/MC/AsmParser/macro-rept-err2.s

Lines changed: 0 additions & 7 deletions
This file was deleted.

llvm/test/MC/AsmParser/macro-rept.s

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
# RUN: llvm-mc -triple x86_64 %s | FileCheck %s
1+
# RUN: rm -rf %t && split-file %s %t && cd %t
2+
# RUN: llvm-mc -triple=x86_64 a.s | FileCheck %s
23

4+
#--- a.s
35
.rept 2
46
.long 1
57
.endr
@@ -23,3 +25,21 @@
2325
# CHECK-NEXT: .long 0
2426
# CHECK-NEXT: .long 0
2527
# CHECK-NEXT: .long 42
28+
29+
# RUN: not llvm-mc -triple=x86_64 err1.s 2>&1 | FileCheck %s --check-prefix=ERR1
30+
# ERR1: .s:1:6: error: unmatched '.endr' directive
31+
#--- err1.s
32+
.endr
33+
34+
# RUN: not llvm-mc -triple=x86_64 err2.s 2>&1 | FileCheck %s --check-prefix=ERR2
35+
# ERR2: .s:1:1: error: no matching '.endr' in definition
36+
#--- err2.s
37+
.rept 3
38+
.long
39+
40+
# RUN: not llvm-mc -triple=x86_64 err3.s 2>&1 | FileCheck %s --check-prefix=ERR3
41+
# ERR3: .s:3:7: error: expected newline
42+
#--- err3.s
43+
.rept 1
44+
.long 0
45+
.endr ab

0 commit comments

Comments
 (0)