public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFC: PATCH: Add -maddress-mode=short|long for x86
@ 2012-03-12 17:48 H.J. Lu
  2012-03-14 19:07 ` Uros Bizjak
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2012-03-12 17:48 UTC (permalink / raw)
  To: gcc-patches, Uros Bizjak, Richard Henderson

Hi,

Trunk can now use SImode or DImode for Pmode with -mx32.  Pmode == SImode
will avoid many conversions from SImode to DImode:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50797

It will use 0x67 address size prefix instead.  This patch adds a new
command line option, -maddress-mode=short|long, for x86.  Any comments?

Thanks.


H.J.
----
2012-03-12  H.J. Lu  <hongjiu.lu@intel.com>

	* config/i386/i386-opts.h (pmode): New.

	* config/i386/i386.c (ix86_option_override_internal): Properly
	check and set ix86_pmode.

	* config/i386/i386.h (Pmode): Check ix86_pmode instead of
	TARGET_64BIT.

	* config/i386/i386.opt (maddress-mode=): New.

	* doc/invoke.texi: Document -maddress-mode=short|long for x86.

diff --git a/gcc/config/i386/i386-opts.h b/gcc/config/i386/i386-opts.h
index 3cc2253..eea85fd 100644
--- a/gcc/config/i386/i386-opts.h
+++ b/gcc/config/i386/i386-opts.h
@@ -71,6 +71,11 @@ enum cmodel {
   CM_LARGE_PIC	/* No assumptions.  */
 };
 
+enum pmode {
+  PMODE_SI,	/* Pmode == SImode. */
+  PMODE_DI 	/* Pmode == DImode. */
+};
+
 enum asm_dialect {
   ASM_ATT,
   ASM_INTEL
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index dbcf5a9..8d9c801 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -3172,6 +3172,17 @@ ix86_option_override_internal (bool main_args_p)
   else
     ix86_arch_specified = 1;
 
+  if (global_options_set.x_ix86_pmode)
+    {
+      if ((TARGET_LP64 && ix86_pmode == PMODE_SI)
+	   || (!TARGET_64BIT && ix86_pmode == PMODE_DI))
+	error ("address mode %qs not supported in the %s bit mode",
+	       TARGET_64BIT ? "short" : "long",
+	       TARGET_64BIT ? "64" : "32");
+    }
+  else
+    ix86_pmode = TARGET_LP64 ? PMODE_DI : PMODE_SI;
+
   if (!global_options_set.x_ix86_abi)
     ix86_abi = DEFAULT_ABI;
 
diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index c77070b..3fcd209 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -1745,7 +1745,7 @@ do {							\
 /* Specify the machine mode that pointers have.
    After generation of rtl, the compiler makes no further distinction
    between pointers and any other objects of this machine mode.  */
-#define Pmode (TARGET_64BIT ? DImode : SImode)
+#define Pmode (ix86_pmode == PMODE_DI ? DImode : SImode)
 
 /* A C expression whose value is zero if pointers that need to be extended
    from being `POINTER_SIZE' bits wide to `Pmode' are sign-extended and
diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt
index 1d8dc44..29f1082 100644
--- a/gcc/config/i386/i386.opt
+++ b/gcc/config/i386/i386.opt
@@ -159,6 +159,20 @@ Enum(cmodel) String(32) Value(CM_32)
 EnumValue
 Enum(cmodel) String(kernel) Value(CM_KERNEL)
 
+maddress-mode=
+Target RejectNegative Joined Enum(pmode) Var(ix86_pmode) Init(PMODE_SI)
+Use given address mode
+
+Enum
+Name(pmode) Type(enum pmode)
+Known address mode (for use with the -maddress-mode= option):
+
+EnumValue
+Enum(pmode) String(short) Value(PMODE_SI)
+
+EnumValue
+Enum(pmode) String(long) Value(PMODE_DI)
+
 mcpu=
 Target RejectNegative Joined Undocumented Alias(mtune=) Warn(%<-mcpu=%> is deprecated; use %<-mtune=%> or %<-march=%> instead)
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 5f5397b..e9188db 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -634,7 +634,7 @@ Objective-C and Objective-C++ Dialects}.
 -mveclibabi=@var{type} -mvect8-ret-in-mem @gol
 -mpc32 -mpc64 -mpc80 -mstackrealign @gol
 -momit-leaf-frame-pointer  -mno-red-zone -mno-tls-direct-seg-refs @gol
--mcmodel=@var{code-model} -mabi=@var{name} @gol
+-mcmodel=@var{code-model} -mabi=@var{name} -maddress-mode=@var{mode} @gol
 -m32 -m64 -mx32 -mlarge-data-threshold=@var{num} @gol
 -msse2avx -mfentry -m8bit-idiv @gol
 -mavx256-split-unaligned-load -mavx256-split-unaligned-store}
@@ -13938,6 +13938,18 @@ be statically or dynamically linked.
 @opindex mcmodel=large
 Generate code for the large model.  This model makes no assumptions
 about addresses and sizes of sections.
+
+@item -maddress-mode=long
+@opindex maddress-mode=long
+Generate code for long address mode.  It is only supported for 64-bit
+and x32 environments.  This is the default address mode for 64-bit
+environment.
+
+@item -maddress-mode=short
+@opindex maddress-mode=short
+Generate code for short address mode.  It is only supported for 32-bit
+and x32 environments.  This is the default address mode for 32-bit and
+x32 environments.
 @end table
 
 @node i386 and x86-64 Windows Options

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-12 17:48 RFC: PATCH: Add -maddress-mode=short|long for x86 H.J. Lu
@ 2012-03-14 19:07 ` Uros Bizjak
  2012-03-14 20:13   ` Joseph S. Myers
  2012-03-14 21:57   ` Gerald Pfeifer
  0 siblings, 2 replies; 7+ messages in thread
From: Uros Bizjak @ 2012-03-14 19:07 UTC (permalink / raw)
  To: H.J. Lu; +Cc: gcc-patches, Richard Henderson, Joseph S. Myers, Gerald Pfeifer

On Mon, Mar 12, 2012 at 6:48 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:

> Trunk can now use SImode or DImode for Pmode with -mx32.  Pmode == SImode
> will avoid many conversions from SImode to DImode:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50797
>
> It will use 0x67 address size prefix instead.  This patch adds a new
> command line option, -maddress-mode=short|long, for x86.  Any comments?

I think this is good option, I as a developer will be able to
benchmark different approaches for new target with this flag.

> 2012-03-12  H.J. Lu  <hongjiu.lu@intel.com>
>
>        * config/i386/i386-opts.h (pmode): New.
>
>        * config/i386/i386.c (ix86_option_override_internal): Properly
>        check and set ix86_pmode.
>
>        * config/i386/i386.h (Pmode): Check ix86_pmode instead of
>        TARGET_64BIT.
>
>        * config/i386/i386.opt (maddress-mode=): New.
>
>        * doc/invoke.texi: Document -maddress-mode=short|long for x86.

Please refer to PR target/50797 in the ChangeLog.

The patch is technically OK for mainline, Joseph - can you please
review option stuff?

I have also added Gerald to CC, to check if everything is OK with
added documentation.

Thanks,
Uros.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-14 19:07 ` Uros Bizjak
@ 2012-03-14 20:13   ` Joseph S. Myers
  2012-03-14 21:57   ` Gerald Pfeifer
  1 sibling, 0 replies; 7+ messages in thread
From: Joseph S. Myers @ 2012-03-14 20:13 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: H.J. Lu, gcc-patches, Richard Henderson, Gerald Pfeifer

On Wed, 14 Mar 2012, Uros Bizjak wrote:

> The patch is technically OK for mainline, Joseph - can you please
> review option stuff?

The option changes look fine to me.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-14 19:07 ` Uros Bizjak
  2012-03-14 20:13   ` Joseph S. Myers
@ 2012-03-14 21:57   ` Gerald Pfeifer
  2012-03-14 22:34     ` H.J. Lu
  1 sibling, 1 reply; 7+ messages in thread
From: Gerald Pfeifer @ 2012-03-14 21:57 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: H.J. Lu, gcc-patches, Richard Henderson, Joseph S. Myers

On Wed, 14 Mar 2012, Uros Bizjak wrote:
> I have also added Gerald to CC, to check if everything is OK with
> added documentation.

Joseph is better with that than I am, but I'll give it a try. :-)

+@item -maddress-mode=long
+@opindex maddress-mode=long
+Generate code for long address mode.  It is only supported for 64-bit
+and x32 environments.  This is the default address mode for 64-bit
+environment.

I cannot formally explain why, but would swap "It" and "This" in
this paragraph and the other.

In any case "64-bit environments" (Plural).

Fine with these changes.


Apart from the above, at least invoke.texi does not define what an x32 
environment is.  Shouldn't that done somewhere (before this terminology
is used)?

Gerald

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-14 21:57   ` Gerald Pfeifer
@ 2012-03-14 22:34     ` H.J. Lu
  2012-03-18 22:17       ` Gerald Pfeifer
  0 siblings, 1 reply; 7+ messages in thread
From: H.J. Lu @ 2012-03-14 22:34 UTC (permalink / raw)
  To: Gerald Pfeifer
  Cc: Uros Bizjak, gcc-patches, Richard Henderson, Joseph S. Myers

[-- Attachment #1: Type: text/plain, Size: 1038 bytes --]

On Wed, Mar 14, 2012 at 2:57 PM, Gerald Pfeifer <gerald@pfeifer.com> wrote:
> On Wed, 14 Mar 2012, Uros Bizjak wrote:
>> I have also added Gerald to CC, to check if everything is OK with
>> added documentation.
>
> Joseph is better with that than I am, but I'll give it a try. :-)
>
> +@item -maddress-mode=long
> +@opindex maddress-mode=long
> +Generate code for long address mode.  It is only supported for 64-bit
> +and x32 environments.  This is the default address mode for 64-bit
> +environment.
>
> I cannot formally explain why, but would swap "It" and "This" in
> this paragraph and the other.
>
> In any case "64-bit environments" (Plural).
>
> Fine with these changes.

I checked in the updated patch.

>
> Apart from the above, at least invoke.texi does not define what an x32
> environment is.  Shouldn't that done somewhere (before this terminology
> is used)?
>

I am not sure where to put it.  In any case, here is a patch to update
GCC 4.7.0 changes with link to x32 website.


-- 
H.J.

[-- Attachment #2: gcc-x32-www.patch --]
[-- Type: text/x-patch, Size: 781 bytes --]

Index: htdocs/gcc-4.7/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v
retrieving revision 1.96
diff -u -p -r1.96 changes.html
--- htdocs/gcc-4.7/changes.html	7 Mar 2012 14:15:35 -0000	1.96
+++ htdocs/gcc-4.7/changes.html	14 Mar 2012 22:31:50 -0000
@@ -720,6 +720,8 @@ int add_values (const __flash int *p, in
       for Windows mingw targets.</li>
     <li>Support for new AMD family 15h processors (Piledriver core) is now available
       through <code>-march=bdver2</code> and <code>-mtune=bdver2</code> options.</li>
+    <li>Support for <a href="http://sites.google.com/site/x32abi/">x32 psABI</a>
+      is now available through <code>-mx32</code> option.
     <li>...</li>
   </ul>
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-14 22:34     ` H.J. Lu
@ 2012-03-18 22:17       ` Gerald Pfeifer
  2012-03-19 16:02         ` H.J. Lu
  0 siblings, 1 reply; 7+ messages in thread
From: Gerald Pfeifer @ 2012-03-18 22:17 UTC (permalink / raw)
  To: H.J. Lu; +Cc: Uros Bizjak, gcc-patches, Richard Henderson, Joseph S. Myers

[-- Attachment #1: Type: TEXT/PLAIN, Size: 417 bytes --]

On Wed, 14 Mar 2012, H.J. Lu wrote:
>> Apart from the above, at least invoke.texi does not define what an x32
>> environment is.  Shouldn't that done somewhere (before this terminology
>> is used)?
> I am not sure where to put it.  In any case, here is a patch to update
> GCC 4.7.0 changes with link to x32 website.

Please add two "the"s, once for the ABI and once for the options;
fine with this change.

Gerald

[-- Attachment #2: Type: TEXT/X-PATCH, Size: 781 bytes --]

Index: htdocs/gcc-4.7/changes.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.7/changes.html,v
retrieving revision 1.96
diff -u -p -r1.96 changes.html
--- htdocs/gcc-4.7/changes.html	7 Mar 2012 14:15:35 -0000	1.96
+++ htdocs/gcc-4.7/changes.html	14 Mar 2012 22:31:50 -0000
@@ -720,6 +720,8 @@ int add_values (const __flash int *p, in
       for Windows mingw targets.</li>
     <li>Support for new AMD family 15h processors (Piledriver core) is now available
       through <code>-march=bdver2</code> and <code>-mtune=bdver2</code> options.</li>
+    <li>Support for <a href="http://sites.google.com/site/x32abi/">x32 psABI</a>
+      is now available through <code>-mx32</code> option.
     <li>...</li>
   </ul>
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: RFC: PATCH: Add -maddress-mode=short|long for x86
  2012-03-18 22:17       ` Gerald Pfeifer
@ 2012-03-19 16:02         ` H.J. Lu
  0 siblings, 0 replies; 7+ messages in thread
From: H.J. Lu @ 2012-03-19 16:02 UTC (permalink / raw)
  To: Gerald Pfeifer
  Cc: Uros Bizjak, gcc-patches, Richard Henderson, Joseph S. Myers

On Sun, Mar 18, 2012 at 3:17 PM, Gerald Pfeifer <gerald@pfeifer.com> wrote:
> On Wed, 14 Mar 2012, H.J. Lu wrote:
>>> Apart from the above, at least invoke.texi does not define what an x32
>>> environment is.  Shouldn't that done somewhere (before this terminology
>>> is used)?
>> I am not sure where to put it.  In any case, here is a patch to update
>> GCC 4.7.0 changes with link to x32 website.
>
> Please add two "the"s, once for the ABI and once for the options;
> fine with this change.
>

Done.  Thanks.


-- 
H.J.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-03-19 16:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-12 17:48 RFC: PATCH: Add -maddress-mode=short|long for x86 H.J. Lu
2012-03-14 19:07 ` Uros Bizjak
2012-03-14 20:13   ` Joseph S. Myers
2012-03-14 21:57   ` Gerald Pfeifer
2012-03-14 22:34     ` H.J. Lu
2012-03-18 22:17       ` Gerald Pfeifer
2012-03-19 16:02         ` H.J. Lu

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).