[v4,3/3] gas: Add macro tests for PR gas/32073
Checks
Commit Message
1. Add a macro test for expression argument with inner white spaces and
a white space before argument added by C preprocessor.
2. Add a x86-64 specific macro test.
PR gas/32073
* testsuite/gas/i386/x86-64-macro-1.d: New file.
* testsuite/gas/i386/x86-64-macro-1.s: Likewise.
* testsuite/gas/i386/x86-64.exp: Run x86-64-macro-1.
* testsuite/gas/macros/arg1.d: New file.
* testsuite/gas/macros/arg1.s: Likewise.
* testsuite/gas/macros/macros.exp: Run arg1.
Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
---
gas/testsuite/gas/i386/x86-64-macro-1.d | 11 +++++++++++
gas/testsuite/gas/i386/x86-64-macro-1.s | 9 +++++++++
gas/testsuite/gas/i386/x86-64.exp | 2 ++
gas/testsuite/gas/macros/arg1.d | 7 +++++++
gas/testsuite/gas/macros/arg1.s | 12 ++++++++++++
gas/testsuite/gas/macros/macros.exp | 2 ++
6 files changed, 43 insertions(+)
create mode 100644 gas/testsuite/gas/i386/x86-64-macro-1.d
create mode 100644 gas/testsuite/gas/i386/x86-64-macro-1.s
create mode 100644 gas/testsuite/gas/macros/arg1.d
create mode 100644 gas/testsuite/gas/macros/arg1.s
Comments
On 12.08.2024 17:43, H.J. Lu wrote:
> --- /dev/null
> +++ b/gas/testsuite/gas/macros/arg1.s
> @@ -0,0 +1,12 @@
> +# Test expression argument with inner white spaces and a white space
> +# before argument added by C preprocessor.
> +
> + .macro test arg1, arg2, arg3
> + .byte \arg1
> + .byte \arg2
> + .byte \ arg3
> + .endm
> +
> + .data
> + test 0x10 + 0, 0x10 + 1, 0x10 + 2
> + test 0x10 + 3, 0x10 + 4, 0x15
Just to have mentioned it in public: If the goal really is to (long term)
retain the ability to use such expressions with inner whitespace and
without parentheses or quotes, then reverting a few more changes done in
preparation may be desirable:
a1b7023447d1 bfin: correct macro use in gas testsuite
2231ac9b9e88 ia64: correct macro use in gas testsuite
c0e9aca554e3 MIPS: correct macro use in gas and ld testsuites
6e892703fedb TilePro: correct macro use in gas testsuite
One might think that cfa18744d435 ("Arm: correct macro use in gas
testsuite") should also fall into this group, but imo the situation is
a little different there.
Jan
On Tue, Aug 13, 2024 at 8:12 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 12.08.2024 17:43, H.J. Lu wrote:
> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/arg1.s
> > @@ -0,0 +1,12 @@
> > +# Test expression argument with inner white spaces and a white space
> > +# before argument added by C preprocessor.
> > +
> > + .macro test arg1, arg2, arg3
> > + .byte \arg1
> > + .byte \arg2
> > + .byte \ arg3
> > + .endm
> > +
> > + .data
> > + test 0x10 + 0, 0x10 + 1, 0x10 + 2
> > + test 0x10 + 3, 0x10 + 4, 0x15
>
> Just to have mentioned it in public: If the goal really is to (long term)
I think it is the most sensible approach.
> retain the ability to use such expressions with inner whitespace and
> without parentheses or quotes, then reverting a few more changes done in
> preparation may be desirable:
>
> a1b7023447d1 bfin: correct macro use in gas testsuite
> 2231ac9b9e88 ia64: correct macro use in gas testsuite
> c0e9aca554e3 MIPS: correct macro use in gas and ld testsuites
> 6e892703fedb TilePro: correct macro use in gas testsuite
Yes, they should be reverted.
> One might think that cfa18744d435 ("Arm: correct macro use in gas
> testsuite") should also fall into this group, but imo the situation is
> a little different there.
ARM supports something like:
.macro cfi_pop advance, reg, cfa_offset
...
97: cfi_pop 97b - \unwind, 0xe, 0x0
which x86 doesn't. But there are no tests for that.
new file mode 100644
@@ -0,0 +1,11 @@
+#as: -mrelax-relocations=yes
+#objdump: -dwr
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+ <_start>:
+ +[a-f0-9]+: ff 15 00 00 00 00 call \*0x0\(%rip\) # 6 <_start\+0x6> 2: R_X86_64_GOTPCRELX acos-0x4
+#pass
new file mode 100644
@@ -0,0 +1,9 @@
+# Test a white space before argument added by C preprocessor.
+
+ .macro WRAPPER_IMPL_SSE2 callee
+ call *\ callee@GOTPCREL(%rip)
+ .endm
+
+ .text
+_start:
+ WRAPPER_IMPL_SSE2 acos
@@ -698,6 +698,8 @@ if [is_elf_format] then {
run_dump_test "x86-64-no-got"
+ run_dump_test "x86-64-macro-1"
+
run_dump_test "x86-64-addend"
run_dump_test "x86-64-nop-3"
run_dump_test "x86-64-nop-4"
new file mode 100644
@@ -0,0 +1,7 @@
+#objdump: -s -j .data
+
+.*: .*
+
+Contents of section .data:
+ 0000 10111213 1415 ......
+#pass
new file mode 100644
@@ -0,0 +1,12 @@
+# Test expression argument with inner white spaces and a white space
+# before argument added by C preprocessor.
+
+ .macro test arg1, arg2, arg3
+ .byte \arg1
+ .byte \arg2
+ .byte \ arg3
+ .endm
+
+ .data
+ test 0x10 + 0, 0x10 + 1, 0x10 + 2
+ test 0x10 + 3, 0x10 + 4, 0x15
@@ -75,6 +75,8 @@ if { ![istarget tic30-*-*] } {
run_list_test app6 ""
}
+run_dump_test arg1
+
run_list_test badarg ""
switch -glob $target_triplet {