From patchwork Sat Apr 2 00:23:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 89374 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 040A2B6FAC for ; Sat, 2 Apr 2011 11:23:13 +1100 (EST) Received: (qmail 18818 invoked by alias); 2 Apr 2011 00:23:10 -0000 Received: (qmail 18810 invoked by uid 22791); 2 Apr 2011 00:23:09 -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; Sat, 02 Apr 2011 00:23:05 +0000 Received: (qmail 22665 invoked from network); 2 Apr 2011 00:23:03 -0000 Received: from unknown (HELO digraph.polyomino.org.uk) (joseph@127.0.0.2) by mail.codesourcery.com with ESMTPA; 2 Apr 2011 00:23:03 -0000 Received: from jsm28 (helo=localhost) by digraph.polyomino.org.uk with local-esmtp (Exim 4.72) (envelope-from ) id 1Q5ocI-0002rS-FZ; Sat, 02 Apr 2011 00:23:02 +0000 Date: Sat, 2 Apr 2011 00:23:02 +0000 (UTC) From: "Joseph S. Myers" To: gcc-patches@gcc.gnu.org cc: nickc@redhat.com Subject: Add ToLower .opt facility 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 adds a ToLower .opt feature, for option arguments that are case-insensitive and should be converted to a canonical lowercase form. This is relevant to at least mips, mn10300 and rx. This patch makes rx use it, thereby causing an existing spec that tested only for a lowercase option form to start to work correctly with both variants (since specs only need to match canonical options). Bootstrapped with no regressions on x86_64-unknown-linux-gnu, and tested building cc1 and xgcc for cross to rx-elf. Will commit to trunk in the absence of target maintainer objections. 2011-04-01 Joseph Myers * doc/options.texi (ToLower): Document. * opt-functions.awk (switch_bit_fields): Initialize cl_tolower field. * opts-common.c (decode_cmdline_option): Handle cl_tolower. * opts.h (cl_option): Add cl_tolower field. * config/rx/rx.c (rx_handle_option): Use strcmp of -mcpu= arguments with lowercase strings. * config/rx/rx.opt (mcpu=): Add ToLower. * config/rx/t-rx (MULTILIB_MATCHES): Don't handle uppercase -mcpu= argument. Index: gcc/doc/options.texi =================================================================== --- gcc/doc/options.texi (revision 171804) +++ gcc/doc/options.texi (working copy) @@ -257,6 +257,11 @@ option handler. @code{UInteger} should @code{-falign-loops}=@var{n} are supported to make sure the saved options are given a full integer. +@item ToLower +The option's argument should be converted to lowercase as part of +putting it in canonical form, and before comparing with the strings +indicated by any @code{Enum} property. + @item NoDriverArg For an option marked @code{Separate}, the option only takes an argument in the compiler proper, not in the driver. This is for Index: gcc/opts-common.c =================================================================== --- gcc/opts-common.c (revision 171804) +++ gcc/opts-common.c (working copy) @@ -567,6 +567,19 @@ decode_cmdline_option (const char **argv if (!option_ok_for_language (option, lang_mask)) errors |= CL_ERR_WRONG_LANG; + /* Convert the argument to lowercase if appropriate. */ + if (arg && option->cl_tolower) + { + size_t j; + size_t len = strlen (arg); + char *arg_lower = XNEWVEC (char, len + 1); + + for (j = 0; j < len; j++) + arg_lower[j] = TOLOWER ((unsigned char) arg[j]); + arg_lower[len] = 0; + arg = arg_lower; + } + /* If the switch takes an integer, convert it. */ if (arg && option->cl_uinteger) { Index: gcc/opts.h =================================================================== --- gcc/opts.h (revision 171804) +++ gcc/opts.h (working copy) @@ -96,6 +96,8 @@ struct cl_option BOOL_BITFIELD cl_missing_ok : 1; /* Argument is an integer >=0. */ BOOL_BITFIELD cl_uinteger : 1; + /* Argument should be converted to lowercase. */ + BOOL_BITFIELD cl_tolower : 1; /* Report argument with -fverbose-asm */ BOOL_BITFIELD cl_report : 1; /* Offset of field for this option in struct gcc_options, or Index: gcc/opt-functions.awk =================================================================== --- gcc/opt-functions.awk (revision 171804) +++ gcc/opt-functions.awk (working copy) @@ -126,6 +126,7 @@ function switch_bit_fields (flags) flag_init("RejectNegative", flags) \ flag_init("JoinedOrMissing", flags) \ flag_init("UInteger", flags) \ + flag_init("ToLower", flags) \ flag_init("Report", flags) sub(", $", "", result) Index: gcc/config/rx/rx.c =================================================================== --- gcc/config/rx/rx.c (revision 171804) +++ gcc/config/rx/rx.c (working copy) @@ -2308,14 +2308,14 @@ rx_handle_option (struct gcc_options *op return value >= 0 && value <= 4; case OPT_mcpu_: - if (strcasecmp (arg, "RX610") == 0) + if (strcmp (arg, "rx610") == 0) rx_cpu_type = RX610; - else if (strcasecmp (arg, "RX200") == 0) + else if (strcmp (arg, "rx200") == 0) { target_flags |= MASK_NO_USE_FPU; rx_cpu_type = RX200; } - else if (strcasecmp (arg, "RX600") != 0) + else if (strcmp (arg, "rx600") != 0) warning (0, "unrecognized argument '%s' to -mcpu= option", arg); break; Index: gcc/config/rx/rx.opt =================================================================== --- gcc/config/rx/rx.opt (revision 171804) +++ gcc/config/rx/rx.opt (working copy) @@ -1,5 +1,5 @@ ; Command line options for the Renesas RX port of GCC. -; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +; Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. ; Contributed by Red Hat. ; ; This file is part of GCC. @@ -43,7 +43,7 @@ Enable the use of RX FPU instructions. ;--------------------------------------------------- mcpu= -Target RejectNegative Joined Var(rx_cpu_name) Report +Target RejectNegative Joined Var(rx_cpu_name) Report ToLower Specify the target RX cpu type. ;--------------------------------------------------- Index: gcc/config/rx/t-rx =================================================================== --- gcc/config/rx/t-rx (revision 171804) +++ gcc/config/rx/t-rx (working copy) @@ -1,5 +1,5 @@ # Makefile fragment for building GCC for the Renesas RX target. -# Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc. +# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. # Contributed by Red Hat. # # This file is part of GCC. @@ -23,7 +23,7 @@ MULTILIB_OPTIONS = m64bit-doubles nofpu mbig-endian-data MULTILIB_DIRNAMES = 64-bit-double no-fpu-libs big-endian-data -MULTILIB_MATCHES = nofpu=mnofpu nofpu=mcpu?rx200 nofpu=mcpu?RX200 +MULTILIB_MATCHES = nofpu=mnofpu nofpu=mcpu?rx200 MULTILIB_EXCEPTIONS = MULTILIB_EXTRA_OPTS =