From patchwork Mon Mar 12 17:48:06 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 146190 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 8E068B6F13 for ; Tue, 13 Mar 2012 04:48:24 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1332179305; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version: Content-Type:Content-Disposition:User-Agent:Mailing-List: Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:Sender:Delivered-To; bh=d57DPhdMImhQVR2apOxxOKQi2i8=; b=PbV5ybt2cPXjyE0LAJrDIApTeRmCP9bbbWrSb72BqItWSvPqs8zW7ZDAzTRGFY q5Q8LDN8K1fCTfKjhn9kxm8kRzmEgUm0esptZ1jRj+74FWGqtBJtDJzhdw7+BwFk KAO1yJwhXEus6nHK4EYXCzMOt7ghyy1uYTFEOGZXc2JOY= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:X-ExtLoop1:Received:Received:Date:From:To:Subject:Message-ID:Reply-To:MIME-Version:Content-Type:Content-Disposition:User-Agent:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=D8bKVDTwuMS6ZuPwCzuNoAdnATuOOSn/HFv4rlhYFPqNy1kFGbprFN2CWrvWDe FhiIHR+LgOQh/bHD2DnuxuvF+gmUFOkmycC+OfGK7vjLoHJsXnortznV4r93kZgV /mIWPx8XBaqS6JLK0HVCc/YvMnCI64AbRgek9c7BvlMXs=; Received: (qmail 17173 invoked by alias); 12 Mar 2012 17:48:21 -0000 Received: (qmail 17164 invoked by uid 22791); 12 Mar 2012 17:48:20 -0000 X-SWARE-Spam-Status: No, hits=-5.1 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_HI, TW_AV, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 12 Mar 2012 17:48:07 +0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 12 Mar 2012 10:48:07 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by fmsmga002.fm.intel.com with ESMTP; 12 Mar 2012 10:48:07 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id 0FC74C186C; Mon, 12 Mar 2012 10:48:06 -0700 (PDT) Date: Mon, 12 Mar 2012 10:48:06 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, Uros Bizjak , Richard Henderson Subject: RFC: PATCH: Add -maddress-mode=short|long for x86 Message-ID: <20120312174806.GA22970@intel.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 * 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