This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Enable __declspec(align(N)) for x86
On Tue, Apr 03, 2007 at 06:32:01PM +0200, Richard Guenther wrote:
> On 4/3/07, H. J. Lu <hjl@lucon.org> wrote:
> >On Mon, Apr 02, 2007 at 03:41:29PM -0700, H. J. Lu wrote:
> >> On Mon, Apr 02, 2007 at 03:35:01PM -0700, Mike Stump wrote:
> >> > On Apr 2, 2007, at 3:18 PM, H. J. Lu wrote:
> >> > >- builtin_define ("__declspec(x)=__attribute__((x))");
> >> > >+ {
> >> > >+ builtin_define ("align(x)=aligned((x))");
> >> >
> >> > On second thought... I don't want this, too dangerous.. better to
> >> > have align accepted in an attribute.
> >>
> >
> >We can't include "c-common.h" in config/i386/i386.c since not
> >all frontends are linked with c-common.o. This patch adds
> >TARGET_ALIGN_DECL_ATTRIBUTES so that we can add align(N) to
> >c-common.o.
>
> I'd say we should rather accept it always. A target speciality for this
> just asks for typos to become portability problems.
>
Here it is.
H.J.
---
2007-04-03 H.J. Lu <hongjiu.lu@intel.com>
* c-common.c (c_common_attribute_table): Add align.
* config/i386/beos-elf.h (TARGET_DECLSPEC): Removed.
* config/i386/i386-interix.h (TARGET_DECLSPEC): Likewise.
* config/i386/i386.h (TARGET_DECLSPEC): Define as 1 if not
defined.
* doc/extend.texi: Document __declspec as an alias of
__attribute__ for i386/x86-64.
--- gcc/c-common.c.decl 2007-03-19 15:03:01.000000000 -0700
+++ gcc/c-common.c 2007-04-03 09:42:30.000000000 -0700
@@ -611,6 +611,8 @@ const struct attribute_spec c_common_att
handle_section_attribute },
{ "aligned", 0, 1, false, false, false,
handle_aligned_attribute },
+ { "align", 0, 1, false, false, false,
+ handle_aligned_attribute },
{ "weak", 0, 0, true, false, false,
handle_weak_attribute },
{ "alias", 1, 1, true, false, false,
--- gcc/config/i386/beos-elf.h.decl 2006-12-14 09:01:23.000000000 -0800
+++ gcc/config/i386/beos-elf.h 2007-04-03 08:42:36.000000000 -0700
@@ -56,8 +56,6 @@ Boston, MA 02110-1301, USA. */
#undef WCHAR_TYPE_SIZE
#define WCHAR_TYPE_SIZE 16
-#define TARGET_DECLSPEC 1
-
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
--- gcc/config/i386/i386-interix.h.decl 2007-03-30 17:36:04.000000000 -0700
+++ gcc/config/i386/i386-interix.h 2007-04-03 08:42:36.000000000 -0700
@@ -54,8 +54,6 @@ Boston, MA 02110-1301, USA. */
#define ASM_LOAD_ADDR(loc, reg) " leal " #loc "," #reg "\n"
-#define TARGET_DECLSPEC 1
-
/* cpp handles __STDC__ */
#define TARGET_OS_CPP_BUILTINS() \
do \
--- gcc/config/i386/i386.h.decl 2007-04-02 10:42:32.000000000 -0700
+++ gcc/config/i386/i386.h 2007-04-03 09:43:07.000000000 -0700
@@ -2419,6 +2419,11 @@ struct machine_function GTY(())
#define SYMBOL_REF_DLLEXPORT_P(X) \
((SYMBOL_REF_FLAGS (X) & SYMBOL_FLAG_DLLEXPORT) != 0)
+/* Enable __declspec(align(16)) by default. */
+#ifndef TARGET_DECLSPEC
+#define TARGET_DECLSPEC 1
+#endif
+
/*
Local variables:
version-control: t
--- gcc/doc/extend.texi.decl 2007-03-30 17:35:50.000000000 -0700
+++ gcc/doc/extend.texi 2007-04-03 10:00:33.000000000 -0700
@@ -1589,6 +1589,9 @@ each keyword. This allows you to use th
being concerned about a possible macro of the same name. For example,
you may use @code{__noreturn__} instead of @code{noreturn}.
+Some targets, e.g. i386/x86-64, support @code{__declspec} as an alias
+of @code{__attribute__}.
+
@xref{Attribute Syntax}, for details of the exact syntax for using
attributes.
@@ -3093,6 +3096,10 @@ up to a maximum of 8 byte alignment, the
in an @code{__attribute__} will still only provide you with 8 byte
alignment. See your linker documentation for further information.
+@cindex @code{align} attribute
+@item align (@var{alignment})
+This attribute is an alias of @code{aligned}.
+
@item cleanup (@var{cleanup_function})
@cindex @code{cleanup} attribute
The @code{cleanup} attribute runs a function when the variable goes