https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80759
Daniel Santos <daniel.santos at pobox dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #41533|0 |1
is obsolete| |
Attachment #41544|0 |1
is obsolete| |
--- Comment #47 from Daniel Santos <daniel.santos at pobox dot com> ---
Created attachment 41587
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41587&action=edit
proposed fix v6 1/2 (testsuite)
I'm sorry for the delay again. I've been having some health problems
infringing upon my hacking time.
I wanted to study the use of __USER_LABEL_PREFIX__ to make sure I understand
the implications. I'm not completely clear on rather or not this is
automatically applied when a back end uses gen_rtx_SYMBOL_REF (or some such),
but guess is that it is. It is also plausible to omit Darwin support for now,
as I've learned that 64-bit Wine isn't yet working for Darwin either. If there
are further problems, then that might be the smartest way to go since I don't
have access to such a machine witch which I can test, experiment, debug, etc.
But if this does the trick, then all the better.
I changed the C() macro to ASMNAME() just because I prefer helpful names and I
decided to yank out all of the FUNC_BEGIN/FUNC_END macros from ms-sysv.c and
just use #if directives directly in the string definition. There's no sense in
maintaining a separate set of asm support macros dealing in strings when
there's only one use site.
I also noticed a possible "gotcha" with the #if __x86_64__ and __SSE2__ -- not
that I would expect necessarily expect it to happen.
In hopes of making your review easier, below is a delta between this new (v6)
patch set and your last posted patches.
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
index 40e119b6cc3..4a4f2e42c61 100644
--- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
+++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/do-test.S
@@ -23,40 +23,42 @@ a copy of the GCC Runtime Library Exception along with this
program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
-#ifdef __x86_64__
-
-# ifdef __ELF__
-# define ELFFN_BEGIN(fn) .type fn,@function
-# define ELFFN_END(fn) .size fn,.-fn
-# else
-# define ELFFN_BEGIN(fn)
-# define ELFFN_END(fn)
-# endif
-
-#define C2(X, Y) X ## Y
-#define C1(X, Y) C2(X, Y)
+#if defined(__x86_64__) && defined(__SSE2__)
+
+/* These macros currently support GNU/Linux, Solaris and Darwin. */
+
+#ifdef __ELF__
+# define FN_TYPE(fn) .type fn,@function
+# define FN_SIZE(fn) .size fn,.-fn
+#else
+# define FN_TYPE(fn)
+# define FN_SIZE(fn)
+#endif
+
#ifdef __USER_LABEL_PREFIX__
-# define C(X) C1(__USER_LABEL_PREFIX__, X)
+# define ASMNAME2(prefix, name) prefix ## name
+# define ASMNAME1(prefix, name) ASMNAME2(prefix, name)
+# define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name)
#else
-# define C(X) X
+# define ASMNAME(name) name
#endif
-# define FUNC(fn) \
- .globl C(fn); \
- ELFFN_BEGIN(C(fn)); \
-C(fn):
+#define FUNC_BEGIN(fn) \
+ .globl ASMNAME(fn); \
+ FN_TYPE (ASMNAME(fn)); \
+ASMNAME(fn):
-#define FUNC_END(fn) ELFFN_END(fn)
+#define FUNC_END(fn) FN_SIZE(ASMNAME(fn))
-# ifdef __AVX__
-# define MOVAPS vmovaps
-# else
-# define MOVAPS movaps
-# endif
+#ifdef __AVX__
+# define MOVAPS vmovaps
+#else
+# define MOVAPS movaps
+#endif
.text
-FUNC(regs_to_mem)
+FUNC_BEGIN(regs_to_mem)
MOVAPS %xmm6, (%rax)
MOVAPS %xmm7, 0x10(%rax)
MOVAPS %xmm8, 0x20(%rax)
@@ -78,7 +80,7 @@ FUNC(regs_to_mem)
retq
FUNC_END(regs_to_mem)
-FUNC(mem_to_regs)
+FUNC_BEGIN(mem_to_regs)
MOVAPS (%rax), %xmm6
MOVAPS 0x10(%rax),%xmm7
MOVAPS 0x20(%rax),%xmm8
@@ -101,8 +103,7 @@ FUNC(mem_to_regs)
FUNC_END(mem_to_regs)
# NOTE: Not MT safe
-FUNC(do_test_unaligned)
- #.cfi_startproc
+FUNC_BEGIN(do_test_unaligned)
# The below alignment checks are to verify correctness of the test
# its self.
@@ -112,7 +113,7 @@ FUNC(do_test_unaligned)
jne L0
int $3 # Stack not unaligned
-FUNC(do_test_aligned)
+FUNC_BEGIN(do_test_aligned)
# Verify that incoming stack is aligned
pushf
test $0xf, %rsp
@@ -120,8 +121,7 @@ FUNC(do_test_aligned)
int $3 # Stack not aligned
L0:
popf
- jmp C(do_test_body)
- #.cfi_endproc
+ jmp ASMNAME(do_test_body)
FUNC_END(do_test_aligned)
FUNC_END(do_test_unaligned)
diff --git a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c
b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c
index 2880f6fc9a2..81c9c1ffdac 100644
--- a/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c
+++ b/gcc/testsuite/gcc.target/x86_64/abi/ms-sysv/ms-sysv.c
@@ -62,8 +62,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If
not, see
#include <errno.h>
#include <ctype.h>
-#ifndef __x86_64__
-# error Test only valid on x86_64
+#if !defined(__x86_64__) || !defined(__SSE2__)
+# error Test only valid on x86_64 with -msse2
#endif
enum reg_data_sets
@@ -147,37 +147,33 @@ static __attribute__((ms_abi)) long
static int arbitrarily_fail;
static const char *argv0;
-#ifdef __ELF__
-# define ELFFN_BEGIN(fn) "\t.type " fn ",@function\n"
-# define ELFFN_END(fn) "\t.size " fn ",.-" fn "\n"
+
+#ifdef __USER_LABEL_PREFIX__
+# define ASMNAME3(name) #name
+# define ASMNAME2(prefix, name) ASMNAME3(prefix ## name)
+# define ASMNAME1(prefix, name) ASMNAME2(prefix, name)
+# define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name)
#else
-# define ELFFN_BEGIN(fn)
-# define ELFFN_END(fn)
+# define ASMNAME(name) #name
#endif
-#define C(X) C2 (__USER_LABEL_PREFIX__, X)
-#define C2(X, Y) STRING (X) Y
-#define STRING(X) #X
-
-#define FUNC_BEGIN(fn) \
- " .globl " C(fn) "\n" \
- ELFFN_BEGIN(C(fn)) \
- C(fn) ":\n"
-#define FUNC_END(fn) ELFFN_END(C(fn))
-
void __attribute__((used))
do_test_body0 (void)
{
__asm__ ("\n"
- FUNC_BEGIN("do_test_body")
+ " .globl " ASMNAME(do_test_body) "\n"
+#ifdef __ELF__
+ " .type " ASMNAME(do_test_body) ",@function\n"
+#endif
+ ASMNAME(do_test_body) ":\n"
"\n"
" # Save registers.\n"
" lea %0, %%rax\n"
- " call " C("regs_to_mem") "\n"
+ " call " ASMNAME(regs_to_mem) "\n"
"\n"
" # Load registers with random data.\n"
" lea %1, %%rax\n"
- " call " C("mem_to_regs") "\n"
+ " call " ASMNAME(mem_to_regs) "\n"
"\n"
" # Save original return address.\n"
" pop %%rax\n"
@@ -194,14 +190,16 @@ do_test_body0 (void)
" # resulting register values.\n"
" push %%rax\n"
" lea %2, %%rax\n"
- " call " C("regs_to_mem") "\n"
+ " call " ASMNAME(regs_to_mem) "\n"
"\n"
" # Restore registers.\n"
" lea %0, %%rax\n"
- " call " C("mem_to_regs") "\n"
+ " call " ASMNAME(mem_to_regs) "\n"
" pop %%rax\n"
" retq\n"
- FUNC_END(do_test_body)
+#ifdef __ELF__
+ " .size " ASMNAME(do_test_body) ",.-" ASMNAME(do_test_body) "\n"
+#endif
::
"m"(test_data.regdata[REG_SET_SAVE]),
"m"(test_data.regdata[REG_SET_INPUT]),
diff --git a/libgcc/config/i386/i386-asm.h b/libgcc/config/i386/i386-asm.h
index 285f75f76ac..1387fd24b4f 100644
--- a/libgcc/config/i386/i386-asm.h
+++ b/libgcc/config/i386/i386-asm.h
@@ -26,39 +26,45 @@ see the files COPYING3 and COPYING.RUNTIME respectively.
If not, see
#ifndef I386_ASM_H
#define I386_ASM_H
+#include "auto-host.h"
+
+/* These macros currently support GNU/Linux, Solaris and Darwin. */
+
#ifdef __ELF__
-# define ELFFN(fn) .type fn,@function
+# define FN_TYPE(fn) .type fn,@function
+# define FN_SIZE(fn) .size fn,.-fn
+# ifdef HAVE_GAS_HIDDEN
+# define FN_HIDDEN(fn) .hidden fn
+# endif
#else
-# define ELFFN(fn)
+# define FN_TYPE(fn)
+# define FN_SIZE(fn)
+#endif
+
+#ifndef FN_HIDDEN
+# define FN_HIDDEN(fn)
#endif
-#define C2(X, Y) X ## Y
-#define C1(X, Y) C2(X, Y)
#ifdef __USER_LABEL_PREFIX__
-# define C(X) C1(__USER_LABEL_PREFIX__, X)
+# define ASMNAME2(prefix, name) prefix ## name
+# define ASMNAME1(prefix, name) ASMNAME2(prefix, name)
+# define ASMNAME(name) ASMNAME1(__USER_LABEL_PREFIX__, name)
#else
-# define C(X) X
+# define ASMNAME(name) name
#endif
-#define FUNC_START(fn)\
- .globl C(fn); \
- ELFFN (C(fn)); \
-fn:
+#define FUNC_BEGIN(fn) \
+ .globl ASMNAME(fn); \
+ FN_TYPE (ASMNAME(fn)); \
+ASMNAME(fn):
-#ifdef __ELF__
-# define HIDDEN_FUNC(fn)\
- FUNC_START (fn) \
- .hidden C(fn);
-#else
-# define HIDDEN_FUNC(fn)\
- FUNC_START (fn)
-#endif
+#define HIDDEN_FUNC(fn) \
+ .globl ASMNAME(fn); \
+ FN_TYPE(ASMNAME(fn)); \
+ FN_HIDDEN(ASMNAME(fn)); \
+ASMNAME(fn):
-#ifdef __ELF__
-# define FUNC_END(fn) .size fn,.-fn
-#else
-# define FUNC_END(fn)
-#endif
+#define FUNC_END(fn) FN_SIZE(ASMNAME(fn))
#ifdef __SSE2__
# ifdef __AVX__