[llvm] r214799 - Enable Darwin vararg parameters support in assembler macros.
Kevin Enderby
enderby at apple.com
Mon Aug 4 16:14:38 PDT 2014
Author: enderby
Date: Mon Aug 4 18:14:37 2014
New Revision: 214799
URL: http://llvm.org/viewvc/llvm-project?rev=214799&view=rev
Log:
Enable Darwin vararg parameters support in assembler macros.
Duplicate the vararg tests for linux and add a tests which mixed
vararg arguments with darwin positional parameters.
Patch by: Janne Grunau <j at jannau.net>
Modified:
llvm/trunk/lib/MC/MCParser/AsmParser.cpp
llvm/trunk/test/MC/AsmParser/macros-darwin-vararg.s
Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=214799&r1=214798&r2=214799&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Mon Aug 4 18:14:37 2014
@@ -3302,7 +3302,7 @@ bool AsmParser::parseDirectiveMacro(SMLo
if (Qualifier == "req")
Parameter.Required = true;
- else if (Qualifier == "vararg" && !IsDarwin)
+ else if (Qualifier == "vararg")
Parameter.Vararg = true;
else
return Error(QualLoc, Qualifier + " is not a valid parameter qualifier "
Modified: llvm/trunk/test/MC/AsmParser/macros-darwin-vararg.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/macros-darwin-vararg.s?rev=214799&r1=214798&r2=214799&view=diff
==============================================================================
--- llvm/trunk/test/MC/AsmParser/macros-darwin-vararg.s (original)
+++ llvm/trunk/test/MC/AsmParser/macros-darwin-vararg.s Mon Aug 4 18:14:37 2014
@@ -1,8 +1,90 @@
-// RUN: not llvm-mc -triple i386-apple-darwin10 %s 2>&1 | FileCheck %s
+// RUN: llvm-mc -triple i386-apple-darwin10 %s 2>&1 | FileCheck %s
-// CHECK: error: vararg is not a valid parameter qualifier for 'arg' in macro 'abc'
-// CHECK: .macro abc arg:vararg
+.macro abc a b:vararg
+.globl "\a, \b"
+.endm
+
+// CHECK: .globl "zed0, zed1, zed2"
+abc zed0, zed1, zed2
+
+.purgem abc
+
+.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
-.macro abc arg:vararg
- \arg
+.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
+
+.macro abc arg:vararg=nop
+ \arg
+.endm
+
+.macro abcd arg0=%eax, arg1:vararg=%ebx
+ movl \arg0, \arg1
.endm
+
+.text
+
+// CHECK: nop
+ abc
+// CHECK: movl %eax, %ebx
+ abcd ,
+
+.macro .make_macro start, end, name, body:vararg
+\start \name
+\body
+\end
+.endmacro
+
+.make_macro .macro,.endmacro,.mybyte,.byte $0, $2, $1
+
+.data
+// CHECK: .byte 10
+// CHECK: .byte 12
+// CHECK: .byte 11
+.mybyte 10,11,12
More information about the llvm-commits
mailing list