[v2,3/3] gas: Add macro tests for PR gas/32073

Message ID 20240812132602.2088063-4-hjl.tools@gmail.com
State Superseded
Headers
Series Restore the original macro behaviors |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 fail Patch failed to apply

Commit Message

H.J. Lu Aug. 12, 2024, 1:26 p.m. UTC
  1. Add a macro test with expression argument:

	.macro test arg1
	.byte \arg1
	.endm

	.data
 	test  0x10 + 0
 	test  0x10 + 1

2. Add a macro test for C preprocessor:

	.macro WRAPPER_IMPL_SSE2 callee
	call *\ callee@GOTPCREL(%rip)
	.endm

	.text
_start:
	WRAPPER_IMPL_SSE2 acos

	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 | 12 ++++++++++++
 gas/testsuite/gas/i386/x86-64-macro-1.s |  7 +++++++
 gas/testsuite/gas/i386/x86-64.exp       |  2 ++
 gas/testsuite/gas/macros/arg1.d         |  8 ++++++++
 gas/testsuite/gas/macros/arg1.s         |  7 +++++++
 gas/testsuite/gas/macros/macros.exp     |  2 ++
 6 files changed, 38 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

Jan Beulich Aug. 12, 2024, 1:51 p.m. UTC | #1
On 12.08.2024 15:26, H.J. Lu wrote:
> --- /dev/null
> +++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
> @@ -0,0 +1,7 @@
> +	.macro WRAPPER_IMPL_SSE2 callee
> +	call *\ callee@GOTPCREL(%rip)
> +	.endm
> +
> +	.text
> +_start:
> +	WRAPPER_IMPL_SSE2 acos

/If/ we really want such a test (applies similarly to the other one),
then clearly some comment is needed. One shouldn't need to go back to
the commit to find what's going on. (Right here I'm afraid I wouldn't
be able to deduce what these seemingly broken tests are about even
after having read the description).

Plus surely this test doesn't need to be x86-specific. In fact you
could simply fold it into ...

> --- /dev/null
> +++ b/gas/testsuite/gas/macros/arg1.s
> @@ -0,0 +1,7 @@
> +	.macro test arg1
> +	.byte \arg1

... here, adding a blank after the backslash (plus a comment clarifying
what this is about).

Jan
  
H.J. Lu Aug. 12, 2024, 3:04 p.m. UTC | #2
On Mon, Aug 12, 2024 at 6:51 AM Jan Beulich <jbeulich@suse.com> wrote:
>
> On 12.08.2024 15:26, H.J. Lu wrote:
> > --- /dev/null
> > +++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
> > @@ -0,0 +1,7 @@
> > +     .macro WRAPPER_IMPL_SSE2 callee
> > +     call *\ callee@GOTPCREL(%rip)
> > +     .endm
> > +
> > +     .text
> > +_start:
> > +     WRAPPER_IMPL_SSE2 acos
>
> /If/ we really want such a test (applies similarly to the other one),
> then clearly some comment is needed. One shouldn't need to go back to
> the commit to find what's going on. (Right here I'm afraid I wouldn't
> be able to deduce what these seemingly broken tests are about even
> after having read the description).
>
> Plus surely this test doesn't need to be x86-specific. In fact you
> could simply fold it into ...

Since the assembler errors are different:

 Error: too many positional arguments

vs

 Error: invalid character '\' in operand 1

I will keep the x86-64 test.

>
> > --- /dev/null
> > +++ b/gas/testsuite/gas/macros/arg1.s
> > @@ -0,0 +1,7 @@
> > +     .macro test arg1
> > +     .byte \arg1
>
> ... here, adding a blank after the backslash (plus a comment clarifying
> what this is about).

I will add it.

> Jan
  

Patch

diff --git a/gas/testsuite/gas/i386/x86-64-macro-1.d b/gas/testsuite/gas/i386/x86-64-macro-1.d
new file mode 100644
index 00000000000..8336da65804
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-macro-1.d
@@ -0,0 +1,12 @@ 
+#as: -mrelax-relocations=yes
+#objdump: -dwr
+#name: x86-64 macro from C preprocessor
+
+.*: +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
diff --git a/gas/testsuite/gas/i386/x86-64-macro-1.s b/gas/testsuite/gas/i386/x86-64-macro-1.s
new file mode 100644
index 00000000000..d3d01aa29da
--- /dev/null
+++ b/gas/testsuite/gas/i386/x86-64-macro-1.s
@@ -0,0 +1,7 @@ 
+	.macro WRAPPER_IMPL_SSE2 callee
+	call *\ callee@GOTPCREL(%rip)
+	.endm
+
+	.text
+_start:
+	WRAPPER_IMPL_SSE2 acos
diff --git a/gas/testsuite/gas/i386/x86-64.exp b/gas/testsuite/gas/i386/x86-64.exp
index a14ed32727f..57cb4aa165a 100644
--- a/gas/testsuite/gas/i386/x86-64.exp
+++ b/gas/testsuite/gas/i386/x86-64.exp
@@ -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"
diff --git a/gas/testsuite/gas/macros/arg1.d b/gas/testsuite/gas/macros/arg1.d
new file mode 100644
index 00000000000..84e9cf7e6c8
--- /dev/null
+++ b/gas/testsuite/gas/macros/arg1.d
@@ -0,0 +1,8 @@ 
+#objdump: -s -j .data
+#name expression argument
+
+.*: .*
+
+Contents of section .data:
+ 0000 1011                                 ..              
+#pass
diff --git a/gas/testsuite/gas/macros/arg1.s b/gas/testsuite/gas/macros/arg1.s
new file mode 100644
index 00000000000..8905f99e73b
--- /dev/null
+++ b/gas/testsuite/gas/macros/arg1.s
@@ -0,0 +1,7 @@ 
+	.macro test arg1
+	.byte \arg1
+	.endm
+
+	.data
+ 	test  0x10 + 0
+ 	test  0x10 + 1
diff --git a/gas/testsuite/gas/macros/macros.exp b/gas/testsuite/gas/macros/macros.exp
index bb5d4abf25b..3e84902c65f 100644
--- a/gas/testsuite/gas/macros/macros.exp
+++ b/gas/testsuite/gas/macros/macros.exp
@@ -75,6 +75,8 @@  if { ![istarget tic30-*-*] } {
     run_list_test app6 ""
 }
 
+run_dump_test arg1
+
 run_list_test badarg ""
 
 switch -glob $target_triplet {