1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[MC] Reorganize and improve macro tests

* Reorganize tests and add coverage
* Improve diagnostic testing
* Make assert() tests more relevant
* Rename tests to macro-* or altmacro-*

This is not NFC because a (previously untested) diagnostic message is changed.
This commit is contained in:
Fangrui Song 2020-04-12 22:02:55 -07:00
parent b8d9da6193
commit 93d7286ccd
14 changed files with 86 additions and 72 deletions

View File

@ -4382,9 +4382,9 @@ bool AsmParser::parseDirectiveMacro(SMLoc DirectiveLoc) {
while (getLexer().isNot(AsmToken::EndOfStatement)) {
if (!Parameters.empty() && Parameters.back().Vararg)
return Error(Lexer.getLoc(),
"Vararg parameter '" + Parameters.back().Name +
"' should be last one in the list of parameters.");
return Error(Lexer.getLoc(), "vararg parameter '" +
Parameters.back().Name +
"' should be the last parameter");
MCAsmMacroParameter Parameter;
if (parseIdentifier(Parameter.Name))

View File

@ -1,9 +0,0 @@
// RUN: not llvm-mc -triple x86_64-apple-darwin10 %s 2>&1 | FileCheck %s
.macro 23
// CHECK: expected identifier in '.macro' directive
.macro abc 33
// CHECK: expected identifier in '.macro' directive

View File

@ -1,9 +0,0 @@
// RUN: not llvm-mc -triple i686-linux -o /dev/null %s
.macro macro parameter=0
.if \parameter
.else
.endm
macro 1

View File

@ -44,3 +44,13 @@ double second = 1, 2
# CHECK-NEXT:double third = 0
# CHECK-NEXT: ^
double third = 0
# CHECK-NEXT:{{.*}}.s:[[#@LINE+3]]:8: error: expected identifier in '.macro' directive
# CHECK-NEXT:.macro 23
# CHECK-NEXT: ^
.macro 23
# CHECK-NEXT:{{.*}}.s:[[#@LINE+3]]:10: error: expected identifier in '.macro' directive
# CHECK-NEXT:.macro a 23
# CHECK-NEXT: ^
.macro a 23

View File

@ -1,3 +1,5 @@
;; Test that macros in inline assembly blocks share the same context,
;; thus a definition is available to the whole file. PR36110
; RUN: not llc < %s 2>&1 | FileCheck %s
; REQUIRES: default_triple

View File

@ -0,0 +1,17 @@
# RUN: not llvm-mc -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s --match-full-lines --strict-whitespace
# CHECK:{{.*}}.s:[[#@LINE+3]]:21: error: vararg parameter 'a' should be the last parameter
# CHECK-NEXT:.macro two a:vararg b:vararg
# CHECK-NEXT: ^
.macro two a:vararg b:vararg
# CHECK:{{.*}}.s:[[#@LINE+3]]:17: error: expected identifier in '.macro' directive
# CHECK-NEXT:.macro one a:req:vararg
# CHECK-NEXT: ^
.macro one a:req:vararg
# CHECK-NEXT:{{.*}}.s:[[#@LINE+3]]:32: warning: pointless default value for required parameter 'a' in macro 'pointless_default'
# CHECK-NEXT:.macro pointless_default a:req=default
# CHECK-NEXT: ^
.macro pointless_default a:req=default
.endm

View File

@ -0,0 +1,37 @@
# RUN: llvm-mc -triple=x86_64 %s | FileCheck %s
.macro one a:vararg
.ascii "|\a"
.endm
# CHECK: .byte 124
one
# CHECK: .ascii "|1"
one 1
## Difference: GNU as squeezes repeated spaces.
# CHECK: .ascii "|1 2"
one 1 2
## Difference: GNU as non-x86 drops the space before '(' (gas PR/25750)
# CHECK: .ascii "|1 (2 3"
one 1 (2 3
# CHECK: .ascii "|1 2 3)"
one 1 2 3)
.macro two a, b:vararg
.ascii "|\a|\b"
.endm
# CHECK: .ascii "||"
two
# CHECK: .ascii "|1|"
two 1
## Difference: GNU as squeezes repeated spaces.
# CHECK: .ascii "|1|2 3"
two 1 2 3
## Parameters can be separated by spaces
.macro two1 a b:vararg
.ascii "|\a|\b"
.endm
# CHECK: .ascii "|1|2"
two1 1 2

View File

@ -0,0 +1,12 @@
# RUN: not llvm-mc -triple x86_64 %s -o /dev/null 2>&1 | FileCheck %s
## This also tests that we don't assert due to an active macro instantiation.
# CHECK: <instantiation>:4:1: error: unmatched .ifs or .elses
.macro macro parameter=0
.if \parameter
.else
.endm
macro 1

View File

@ -0,0 +1,5 @@
# RUN: not llvm-mc -triple=x86_64 %s -o /dev/null 2>&1 | FileCheck %s
# CHECK: {{.*}}.s:6:1: error: unmatched .ifs or .elses
.if 1
.else

View File

@ -1,51 +0,0 @@
// RUN: llvm-mc -triple x86_64-linux-gnu %s | FileCheck %s
.macro ifcc arg:vararg
.if cc
\arg
.endif
.endm
.macro ifcc2 arg0 arg1:vararg
.if cc
movl \arg0, \arg1
.endif
.endm
.macro ifcc3 arg0, arg1:vararg
.if cc
movl \arg0, \arg1
.endif
.endm
.macro ifcc4 arg0, arg1:vararg
.if cc
movl \arg1, \arg0
.endif
.endm
.text
// CHECK: movl %esp, %ebp
// CHECK: subl $0, %esp
// CHECK: movl %eax, %ebx
// CHECK: movl %ecx, %ebx
// CHECK: movl %ecx, %eax
// CHECK: movl %eax, %ecx
// CHECK: movl %ecx, %eax
// CHECK: movl %eax, %ecx
.set cc,1
ifcc movl %esp, %ebp
subl $0, %esp
ifcc2 %eax %ebx
ifcc2 %ecx, %ebx
ifcc3 %ecx %eax
ifcc3 %eax, %ecx
ifcc4 %eax %ecx ## test
ifcc4 %ecx, %eax ## test
// CHECK-NOT: movl
// CHECK: subl $1, %esp
.set cc,0
ifcc movl %esp, %ebp
subl $1, %esp