From patchwork Thu May 5 19:23:34 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 94301 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 B63B5B6FE5 for ; Fri, 6 May 2011 05:23:53 +1000 (EST) Received: (qmail 21149 invoked by alias); 5 May 2011 19:23:52 -0000 Received: (qmail 21140 invoked by uid 22791); 5 May 2011 19:23:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, TW_XG, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 05 May 2011 19:23:37 +0000 Received: (qmail 24800 invoked from network); 5 May 2011 19:23:36 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 5 May 2011 19:23:36 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1QI498-0005TN-Ge; Thu, 05 May 2011 19:23:34 +0000 Date: Thu, 5 May 2011 19:23:34 +0000 (UTC) From: "Joseph S. Myers" To: gcc-patches@gcc.gnu.org cc: geoffk@geoffk.org, dje.gcc@gmail.com Subject: rs6000_handle_option global state avoidance, part 2 Message-ID: MIME-Version: 1.0 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 This patch continues work on avoiding global state in rs6000_handle_option by cleaning up the handling of -mabi= options. The part using global state, a test for TARGET_SPE_ABI, is moved to rs6000_option_override_internal (so now testing the state after all options are applied). The -mabi= option is really several separate options, setting different variables, and so is most naturally represented as multiple options in the .opt file (instead of one option using Enum). This patch represents it that way in the .opt file; the only option handler code now needed for these options is to make -mabi=altivec and -mabi=spe override each other, because all the other semantics can be described directly in the .opt file. Tested building cc1 and xgcc for cross to powerpc-eabi. Will commit to trunk in the absence of target maintainer objections. 2011-05-05 Joseph Myers * config/rs6000/rs6000.opt (rs6000_ieeequad, rs6000_altivec_abi, rs6000_spe_abi, rs6000_darwin64_abi): Remove TargetVariable entries. (mabi=): Replace with separate entries for mabi=altivec, mabi=no-altivec, mabi=spe, mabi=no-spe, mabi=d64, mabi=d32, mabi=ieeelongdouble and mabi=ibmlongdouble. * config/rs6000/rs6000.c (rs6000_option_override_internal): Move check for -mabi=spe without SPE ABI support here. (rs6000_handle_option): Replace OPT_mabi_ handling with OPT_mabi_altivec and OPT_mabi_spe handling. Index: gcc/config/rs6000/rs6000.opt =================================================================== --- gcc/config/rs6000/rs6000.opt (revision 173434) +++ gcc/config/rs6000/rs6000.opt (working copy) @@ -47,22 +47,6 @@ enum rs6000_dependence_cost rs6000_sched TargetVariable enum rs6000_nop_insertion rs6000_sched_insert_nops = sched_finish_none -;; IEEE quad extended precision long double. -TargetVariable -unsigned char rs6000_ieeequad - -;; Nonzero to use AltiVec ABI. -TargetVariable -unsigned char rs6000_altivec_abi - -;; Nonzero if we want SPE ABI extensions. -TargetVariable -unsigned char rs6000_spe_abi - -;; Nonzero if we want Darwin's struct-by-value-in-regs ABI. -TargetVariable -unsigned char rs6000_darwin64_abi - ;; Non-zero to allow overriding loop alignment. TargetVariable unsigned char can_override_loop_align @@ -385,9 +369,37 @@ mdebug= Target RejectNegative Joined -mdebug= Enable debug output -mabi= -Target RejectNegative Joined --mabi= Specify ABI to use +mabi=altivec +Target RejectNegative Var(rs6000_altivec_abi) Save +Use the AltiVec ABI extensions + +mabi=no-altivec +Target RejectNegative Var(rs6000_altivec_abi, 0) +Do not use the AltiVec ABI extensions + +mabi=spe +Target RejectNegative Var(rs6000_spe_abi) Save +Use the SPE ABI extensions + +mabi=no-spe +Target RejectNegative Var(rs6000_spe_abi, 0) +Do not use the SPE ABI extensions + +; These are here for testing during development only, do not document +; in the manual please. + +; If we want Darwin's struct-by-value-in-regs ABI. +mabi=d64 +Target RejectNegative Undocumented Warn(using darwin64 ABI) Var(rs6000_darwin64_abi) Save + +mabi=d32 +Target RejectNegative Undocumented Warn(using old darwin ABI) Var(rs6000_darwin64_abi, 0) + +mabi=ieeelongdouble +Target RejectNegative Undocumented Warn(using IEEE extended precision long double) Var(rs6000_ieeequad) Save + +mabi=ibmlongdouble +Target RejectNegative Undocumented Warn(using IBM extended precision long double) Var(rs6000_ieeequad, 0) mcpu= Target RejectNegative Joined Index: gcc/config/rs6000/rs6000.c =================================================================== --- gcc/config/rs6000/rs6000.c (revision 173434) +++ gcc/config/rs6000/rs6000.c (working copy) @@ -2665,6 +2665,11 @@ rs6000_option_override_internal (bool gl warning (0, "-malign-power is not supported for 64-bit Darwin;" " it is incompatible with the installed C and C++ libraries"); + if (global_options_set.x_rs6000_spe_abi + && rs6000_spe_abi + && !TARGET_SPE_ABI) + error ("not configured for SPE ABI"); + /* Numerous experiment shows that IRA based loop pressure calculation works better for RTL loop invariant motion on targets with enough (>= 32) registers. It is an expensive optimization. @@ -4340,65 +4345,13 @@ rs6000_handle_option (struct gcc_options break; #endif - case OPT_mabi_: - if (!strcmp (arg, "altivec")) - { - opts_set->x_rs6000_altivec_abi = true; - opts->x_rs6000_altivec_abi = 1; - - /* Enabling the AltiVec ABI turns off the SPE ABI. */ - opts->x_rs6000_spe_abi = 0; - } - else if (! strcmp (arg, "no-altivec")) - { - opts_set->x_rs6000_altivec_abi = true; - opts->x_rs6000_altivec_abi = 0; - } - else if (! strcmp (arg, "spe")) - { - opts_set->x_rs6000_spe_abi = true; - opts->x_rs6000_spe_abi = 1; - opts->x_rs6000_altivec_abi = 0; - if (!TARGET_SPE_ABI) - error_at (loc, "not configured for ABI: '%s'", arg); - } - else if (! strcmp (arg, "no-spe")) - { - opts_set->x_rs6000_spe_abi = true; - opts->x_rs6000_spe_abi = 0; - } - - /* These are here for testing during development only, do not - document in the manual please. */ - else if (! strcmp (arg, "d64")) - { - opts->x_rs6000_darwin64_abi = 1; - warning_at (loc, 0, "using darwin64 ABI"); - } - else if (! strcmp (arg, "d32")) - { - opts->x_rs6000_darwin64_abi = 0; - warning_at (loc, 0, "using old darwin ABI"); - } - - else if (! strcmp (arg, "ibmlongdouble")) - { - opts_set->x_rs6000_ieeequad = true; - opts->x_rs6000_ieeequad = 0; - warning_at (loc, 0, "using IBM extended precision long double"); - } - else if (! strcmp (arg, "ieeelongdouble")) - { - opts_set->x_rs6000_ieeequad = true; - opts->x_rs6000_ieeequad = 1; - warning_at (loc, 0, "using IEEE extended precision long double"); - } + case OPT_mabi_altivec: + /* Enabling the AltiVec ABI turns off the SPE ABI. */ + opts->x_rs6000_spe_abi = 0; + break; - else - { - error_at (loc, "unknown ABI specified: '%s'", arg); - return false; - } + case OPT_mabi_spe: + opts->x_rs6000_altivec_abi = 0; break; case OPT_mcpu_: