public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: binutils@sourceware.org
Cc: nickc@redhat.com, jbeulich@suse.com
Subject: [PATCH v2 3/3] gas: Add macro tests for PR gas/32073
Date: Mon, 12 Aug 2024 06:26:02 -0700	[thread overview]
Message-ID: <20240812132602.2088063-4-hjl.tools@gmail.com> (raw)
In-Reply-To: <20240812132602.2088063-1-hjl.tools@gmail.com>

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

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 {
-- 
2.46.0


  parent reply	other threads:[~2024-08-12 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-12 13:25 [PATCH v2 0/3] Restore the original macro behaviors H.J. Lu
2024-08-12 13:26 ` [PATCH v2 1/3] Revert "gas: drop scrubber states 14 and 15" H.J. Lu
2024-08-12 13:26 ` [PATCH v2 2/3] Revert "gas: have scrubber retain more whitespace" H.J. Lu
2024-08-12 13:26 ` H.J. Lu [this message]
2024-08-12 13:51   ` [PATCH v2 3/3] gas: Add macro tests for PR gas/32073 Jan Beulich
2024-08-12 15:04     ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240812132602.2088063-4-hjl.tools@gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=jbeulich@suse.com \
    --cc=nickc@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).