From patchwork Sat Mar 24 22:42:29 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: 148549 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 3D884B6EE8 for ; Sun, 25 Mar 2012 09:42:53 +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=1333233774; 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=SyGnEFsfs64Xzl/b/2GnaevZqAM=; b=aR1glK+unQXGFmj8ArQ9A6wei9+iof2Gq6G/FtSg2+tvBxU0tHGhLJcnv3V0PP WMfXpARDC2CMvxEfX1CqshtvpLcS2i7/obbDozk/QfVg9nlmwZ1spfkops0RudMv 6k2svD9SSDZaDEamlYKLCZnsl0gz1vYi5DLqRw9yUNA6o= 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=Xyb0/Bln7YqKVx0cYXQe32/+1rVG1mO9Iw3HVePdIvTcOr0DNnWZI0CaH4b4Ve UmGYdKAQL0U7ABMGV75YgNp9/P/BCanUL+mR+1+JCbzlL7Dl9E5EPTtGeKaSVQli 9jCIHWg1A4n9DtYjFcMgkFJvad4YbYJl/KxwQeKzQSAlI=; Received: (qmail 28186 invoked by alias); 24 Mar 2012 22:42:46 -0000 Received: (qmail 28178 invoked by uid 22791); 24 Mar 2012 22:42:44 -0000 X-SWARE-Spam-Status: No, hits=-4.5 required=5.0 tests=AWL, BAYES_00, NO_DNS_FOR_FROM, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mga03.intel.com (HELO mga03.intel.com) (143.182.124.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 24 Mar 2012 22:42:30 +0000 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 24 Mar 2012 15:42:30 -0700 X-ExtLoop1: 1 Received: from gnu-6.sc.intel.com ([10.3.194.135]) by azsmga001.ch.intel.com with ESMTP; 24 Mar 2012 15:42:29 -0700 Received: by gnu-6.sc.intel.com (Postfix, from userid 500) id B5859C1DE6; Sat, 24 Mar 2012 15:42:29 -0700 (PDT) Date: Sat, 24 Mar 2012 15:42:29 -0700 From: "H.J. Lu" To: gcc-patches@gcc.gnu.org, Uros Bizjak Subject: PATCH: Add OPTION_MASK_ISA_X86_64 and support TARGET_BI_ARCH == 2 Message-ID: <20120324224229.GA8465@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, In i386 option mask, there is OPTION_MASK_ISA_64BIT for -m64 or -mx32 code generations and OPTION_MASK_ISA_X32 for -mx32 code generation. We support -m64: OPTION_MASK_ISA_64BIT && !OPTION_MASK_ISA_X32 -mx32: OPTION_MASK_ISA_64BIT && OPTION_MASK_ISA_X32 -m32: !OPTION_MASK_ISA_64BIT i386.opt has -m64: Turn on OPTION_MASK_ISA_64BIT -mx32: Turn on OPTION_MASK_ISA_X32 -m32: Turn off OPTION_MASK_ISA_64BIT So it isn't possible to make -mx32 as default -m64 just turns on OPTION_MASK_ISA_64BIT and doesn't change anything. This option adds OPTION_MASK_ISA_X86_64 so that we can have OPTION_MASK_ISA_64BIT 32bit x86-64 code or 64bit x86-64 code OPTION_MASK_ISA_X86_64 64bit x86-64 code OPTION_MASK_ISA_X32 32bit x86-64 code and i386.opt becomes -m64: Turn on OPTION_MASK_ISA_X86_64 -mx32: Turn on OPTION_MASK_ISA_X32 -m32: Turn off OPTION_MASK_ISA_64BIT Both OPTION_MASK_ISA_X32 and OPTION_MASK_ISA_X86_64 imply OPTION_MASK_ISA_64BIT. OPTION_MASK_ISA_X32 clears OPTION_MASK_ISA_X86_64 and vice versa. I added a dummy command line option, -mx86-64, since we don't support ISA_64BIT in m32 Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) Var(ix86_isa_flags) Save Generate 32bit i386 code without a place holder for Mask(ISA_64BIT). Currectly when TARGET_BI_ARCH is defined, i386 backend will set the OPTION_MASK_ISA_64BIT bit by default to make -m64 as the default. This patch extends TARGET_BI_ARCH to support: 1. TARGET_BI_ARCH == 1: -m64 is the default by setting the OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X86_64 bits. 2. TARGET_BI_ARCH == 2: -mx32 is the default by setting the OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 bits. I will send a sparate patch to define TARGET_BI_ARCH to 2. Tested on Linux/x86-64. OK to install? Thanks. H.J. --- 2012-03-24 H.J. Lu * config/i386/biarch64.h (TARGET_64BIT_DEFAULT): Add OPTION_MASK_ISA_X86_64. * config/i386/gnu-user64.h (SPEC_64): Support TARGET_BI_ARCH == 2. (SPEC_X32): Likewise. (MULTILIB_DEFAULTS): Likewise. * config/i386/i386.c (ix86_option_override_internal): Properly set OPTION_MASK_ISA_64BIT and OPTION_MASK_ISA_X32 as well as handle -m32, -m64 and -mx32. * config/i386/i386.h (TARGET_X86_64): New. (TARGET_LP64): Changed to TARGET_X86_64. * config/i386/i386.opt (m64): Replace ISA_64BIT with ISA_X86_64. (mx86-64): New. diff --git a/gcc/config/i386/biarch64.h b/gcc/config/i386/biarch64.h index 629ec98..3dc9889 100644 --- a/gcc/config/i386/biarch64.h +++ b/gcc/config/i386/biarch64.h @@ -25,5 +25,5 @@ a copy of the GCC Runtime Library Exception along with this program; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ -#define TARGET_64BIT_DEFAULT OPTION_MASK_ISA_64BIT +#define TARGET_64BIT_DEFAULT (OPTION_MASK_ISA_64BIT | OPTION_MASK_ISA_X86_64) #define TARGET_BI_ARCH 1 diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h index 954f3b2..6f7b5de 100644 --- a/gcc/config/i386/gnu-user64.h +++ b/gcc/config/i386/gnu-user64.h @@ -58,8 +58,13 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #if TARGET_64BIT_DEFAULT #define SPEC_32 "m32" +#if TARGET_BI_ARCH == 2 +#define SPEC_64 "m64" +#define SPEC_X32 "m32|m64:;" +#else #define SPEC_64 "m32|mx32:;" #define SPEC_X32 "mx32" +#endif #else #define SPEC_32 "m64|mx32:;" #define SPEC_64 "m64" @@ -95,7 +100,11 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see %{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" #if TARGET_64BIT_DEFAULT +#if TARGET_BI_ARCH == 2 +#define MULTILIB_DEFAULTS { "mx32" } +#else #define MULTILIB_DEFAULTS { "m64" } +#endif #else #define MULTILIB_DEFAULTS { "m32" } #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index f93583f..4b6ceab 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -3097,8 +3097,45 @@ ix86_option_override_internal (bool main_args_p) SUBSUBTARGET_OVERRIDE_OPTIONS; #endif + /* Turn off both OPTION_MASK_ISA_X86_64 and OPTION_MASK_ISA_X32 if + TARGET_64BIT is false. */ + if (!TARGET_64BIT) + ix86_isa_flags &= ~(OPTION_MASK_ISA_X86_64 | OPTION_MASK_ISA_X32); +#ifdef TARGET_BI_ARCH + else + { +#if TARGET_BI_ARCH == 1 + /* When TARGET_BI_ARCH == 1, by default, OPTION_MASK_ISA_X86_64 + is on and OPTION_MASK_ISA_X32 is off. We turn off + OPTION_MASK_ISA_X86_64 if OPTION_MASK_ISA_X32 is turned on by + -mx32. */ + if (TARGET_X32) + ix86_isa_flags &= ~OPTION_MASK_ISA_X86_64; +#else + /* When TARGET_BI_ARCH == 2, by default, OPTION_MASK_ISA_X32 is + on and OPTION_MASK_ISA_X86_64 is off. We turn off + OPTION_MASK_ISA_X32 if OPTION_MASK_ISA_X86_64 is turned on by + -m64. */ + if (TARGET_X86_64) + ix86_isa_flags &= ~OPTION_MASK_ISA_X32; +#endif + } +#endif + if (TARGET_X32) - ix86_isa_flags |= OPTION_MASK_ISA_64BIT; + { + /* Always turn on OPTION_MASK_ISA_64BIT and turn off + OPTION_MASK_ISA_X86_64 for TARGET_X32. */ + ix86_isa_flags |= OPTION_MASK_ISA_64BIT; + ix86_isa_flags &= ~OPTION_MASK_ISA_X86_64; + } + else if (TARGET_X86_64) + { + /* Always turn on OPTION_MASK_ISA_64BIT and turn off + OPTION_MASK_ISA_X32 for TARGET_X86_64. */ + ix86_isa_flags |= OPTION_MASK_ISA_64BIT; + ix86_isa_flags &= ~OPTION_MASK_ISA_X32; + } /* -fPIC is the default for x86_64. */ if (TARGET_MACHO && TARGET_64BIT) diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 7721c46..39ff36a 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -41,6 +41,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see /* Redefines for option macros. */ +#define TARGET_X86_64 OPTION_ISA_X86_64 #define TARGET_64BIT OPTION_ISA_64BIT #define TARGET_X32 OPTION_ISA_X32 #define TARGET_MMX OPTION_ISA_MMX @@ -76,7 +77,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define TARGET_RDRND OPTION_ISA_RDRND #define TARGET_F16C OPTION_ISA_F16C -#define TARGET_LP64 (TARGET_64BIT && !TARGET_X32) +#define TARGET_LP64 TARGET_X86_64 /* SSE4.1 defines round instructions */ #define OPTION_MASK_ISA_ROUND OPTION_MASK_ISA_SSE4_1 diff --git a/gcc/config/i386/i386.opt b/gcc/config/i386/i386.opt index 6c516e7..16e99ed 100644 --- a/gcc/config/i386/i386.opt +++ b/gcc/config/i386/i386.opt @@ -411,13 +411,17 @@ Target RejectNegative Negative(m64) Report InverseMask(ISA_64BIT) Var(ix86_isa_f Generate 32bit i386 code m64 -Target RejectNegative Negative(mx32) Report Mask(ISA_64BIT) Var(ix86_isa_flags) Save +Target RejectNegative Negative(mx32) Report Mask(ISA_X86_64) Var(ix86_isa_flags) Save Generate 64bit x86-64 code mx32 Target RejectNegative Negative(m32) Report Mask(ISA_X32) Var(ix86_isa_flags) Save Generate 32bit x86-64 code +mx86-64 +Target Undocumented Mask(ISA_64BIT) Var(ix86_isa_flags) Save +Generate i386 code or x86-64 code + mmmx Target Report Mask(ISA_MMX) Var(ix86_isa_flags) Save Support MMX built-in functions