From patchwork Wed Apr 23 20:45:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 341982 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D5BAC1400F6 for ; Thu, 24 Apr 2014 06:45:36 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; q=dns; s=default; b=wyC1fGY4iYN2wH32i iO8LBSiXwa2UgpU/vmTn0T09ZOZuhvJWF+lQoM3Ttd78socHWItuuUCP8wshg4Nw e8QGymhljIoOOtj89H6PA7GPLkzIV82CvnyGaueTbJgDEh1U4mnsdU7/jyl9XkAp xfcb5PT8UpJghjN6WfPXZZYaMk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; s=default; bh=rJQXopbxn9kKynkHvuMhwlW XR/Y=; b=fk+MJifhlBQSBf61o0uA8ucrF/XVjGWfLZfPxwd+EMs8R9x7omR96A8 +Qo/az6WhkWqRqsSHqq1IJmA0uL1nuN9tZ+x2P3IAhBGcD+HclbFEdiZAcPjxVp8 NCENGyPHWMNbfkH402jRdxzePCEpY+BMhfbSxRY9+fDWki0g055k= Received: (qmail 20834 invoked by alias); 23 Apr 2014 20:45:30 -0000 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 Received: (qmail 20825 invoked by uid 89); 23 Apr 2014 20:45:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: qmta07.emeryville.ca.mail.comcast.net Received: from qmta07.emeryville.ca.mail.comcast.net (HELO qmta07.emeryville.ca.mail.comcast.net) (76.96.30.64) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Apr 2014 20:45:23 +0000 Received: from omta05.emeryville.ca.mail.comcast.net ([76.96.30.43]) by qmta07.emeryville.ca.mail.comcast.net with comcast id tXYj1n0030vp7WLA7YlMaN; Wed, 23 Apr 2014 20:45:21 +0000 Received: from up.mrs.kithrup.com ([24.4.193.248]) by omta05.emeryville.ca.mail.comcast.net with comcast id tYlL1n00N5N1HX48RYlLqs; Wed, 23 Apr 2014 20:45:21 +0000 Mime-Version: 1.0 (Mac OS X Mail 7.2 \(1874\)) Subject: Re: wide-int, gengtype From: Mike Stump In-Reply-To: Date: Wed, 23 Apr 2014 13:45:19 -0700 Cc: "gcc-patches@gcc.gnu.org Patches" , Laurynas Biveinis , Kenneth Zadeck Message-Id: References: <9995BD70-E5F5-4B1F-8B48-90A238D740ED@comcast.net> To: Mike & Elizabeth Stump X-IsSubscribed: yes On Jan 30, 2014, at 2:56 PM, Mike Stump wrote: > On Jan 1, 2014, at 7:58 PM, Mike Stump wrote: >> On Nov 23, 2013, at 11:21 AM, Mike Stump wrote: >>> Richi has asked the we break the wide-int patch so that the individual port and front end maintainers can review their parts without have to go through the entire patch. This patch covers the gengtype code. >>> >>> Ok? >> >> Ping? >> >> We'll need a global reviewer to step forward if the gty maintainer doesn't have the time. If no one is at one with the code, then I'd ask the SC to solicit such an additional person to become maintainer. > > Ping? > > This is very small, just slightly extends gty to accept slightly more C++… pretty easy going. Ping? * gengtype.c: Remove include of double-int.h. (do_typedef): Use wide-int interfaces. (open_base_files): Add wide-int.h. (main): Add offset_int and widest_int typedefs. * gengtype-lex.l: Handle "^". (CXX_KEYWORD): Add "static". * gengtype-parse.c (require3): New. (require_template_declaration): Handle constant template arguments and nested templates. * gengtype-state.c: Don't include "double-int.h". diff --git a/gcc/gengtype.c b/gcc/gengtype.c index 86e9ca2..0c0195c 100644 --- a/gcc/gengtype.c +++ b/gcc/gengtype.c @@ -25,7 +25,6 @@ #include "system.h" #include "errors.h" /* for fatal */ #include "getopt.h" -#include "double-int.h" #include "version.h" /* for version_string & pkgversion_string. */ #include "hashtab.h" #include "xregex.h" @@ -535,7 +534,7 @@ do_typedef (const char *s, type_p t, struct fileloc *pos) for (p = typedefs; p != NULL; p = p->next) if (strcmp (p->name, s) == 0) { - if (p->type != t) + if (p->type != t && strcmp (s, "result_type") != 0) { error_at_line (pos, "type `%s' previously defined", s); error_at_line (&p->line, "previously defined here"); @@ -1766,7 +1765,7 @@ open_base_files (void) static const char *const ifiles[] = { "config.h", "system.h", "coretypes.h", "tm.h", "hashtab.h", "splay-tree.h", "obstack.h", "bitmap.h", "input.h", - "tree.h", "rtl.h", "function.h", "insn-config.h", "expr.h", + "tree.h", "rtl.h", "wide-int.h", "function.h", "insn-config.h", "expr.h", "hard-reg-set.h", "basic-block.h", "cselib.h", "insn-addr.h", "optabs.h", "libfuncs.h", "debug.h", "ggc.h", "cgraph.h", "gimple.h", "gimple-iterator.h", "gimple-ssa.h", "tree-cfg.h", @@ -5633,6 +5632,8 @@ main (int argc, char **argv) POS_HERE (do_scalar_typedef ("REAL_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("FIXED_VALUE_TYPE", &pos)); POS_HERE (do_scalar_typedef ("double_int", &pos)); + POS_HERE (do_scalar_typedef ("offset_int", &pos)); + POS_HERE (do_scalar_typedef ("widest_int", &pos)); POS_HERE (do_scalar_typedef ("uint64_t", &pos)); POS_HERE (do_scalar_typedef ("uint8", &pos)); POS_HERE (do_scalar_typedef ("uintptr_t", &pos)); diff --git a/gcc/gengtype-lex.l b/gcc/gengtype-lex.l index f46cd17..7ece2ab 100644 --- a/gcc/gengtype-lex.l +++ b/gcc/gengtype-lex.l @@ -57,7 +57,7 @@ ITYPE {IWORD}({WS}{IWORD})* /* Include '::' in identifiers to capture C++ scope qualifiers. */ ID {CID}({HWS}::{HWS}{CID})* EOID [^[:alnum:]_] -CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend +CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend|static %x in_struct in_struct_comment in_comment %option warn noyywrap nounput nodefault perf-report @@ -110,6 +110,7 @@ CXX_KEYWORD inline|public:|private:|protected:|template|operator|friend "const"/{EOID} /* don't care */ {CXX_KEYWORD}/{EOID} | "~" | +"^" | "&" { *yylval = XDUPVAR (const char, yytext, yyleng, yyleng + 1); return IGNORABLE_CXX_KEYWORD; diff --git a/gcc/gengtype-parse.c b/gcc/gengtype-parse.c index 8328e3a..0a58822 100644 --- a/gcc/gengtype-parse.c +++ b/gcc/gengtype-parse.c @@ -197,6 +197,23 @@ require2 (int t1, int t2) return v; } +/* If the next token does not have one of the codes T1, T2 or T3, report a + parse error; otherwise return the token's value. */ +static const char * +require3 (int t1, int t2, int t3) +{ + int u = token (); + const char *v = advance (); + if (u != t1 && u != t2 && u != t3) + { + parse_error ("expected %s, %s or %s, have %s", + print_token (t1, 0), print_token (t2, 0), + print_token (t3, 0), print_token (u, v)); + return 0; + } + return v; +} + /* Near-terminals. */ /* C-style string constant concatenation: STRING+ @@ -243,18 +260,45 @@ require_template_declaration (const char *tmpl_name) str = concat (tmpl_name, "<", (char *) 0); /* Read the comma-separated list of identifiers. */ - while (token () != '>') + int depth = 1; + while (depth > 0) { - const char *id = require2 (ID, ','); + if (token () == ENUM) + { + advance (); + str = concat (str, "enum ", (char *) 0); + continue; + } + if (token () == NUM) + { + str = concat (str, advance (), (char *) 0); + continue; + } + if (token () == ':') + { + advance (); + str = concat (str, ":", (char *) 0); + continue; + } + if (token () == '<') + { + advance (); + str = concat (str, "<", (char *) 0); + depth += 1; + continue; + } + if (token () == '>') + { + advance (); + str = concat (str, ">", (char *) 0); + depth -= 1; + continue; + } + const char *id = require3 (SCALAR, ID, ','); if (id == NULL) id = ","; str = concat (str, id, (char *) 0); } - - /* Recognize the closing '>'. */ - require ('>'); - str = concat (str, ">", (char *) 0); - return str; } diff --git a/gcc/gengtype-state.c b/gcc/gengtype-state.c index fda473a..ed61375 100644 --- a/gcc/gengtype-state.c +++ b/gcc/gengtype-state.c @@ -30,7 +30,6 @@ #endif #include "system.h" #include "errors.h" /* For fatal. */ -#include "double-int.h" #include "hashtab.h" #include "version.h" /* For version_string & pkgversion_string. */ #include "obstack.h"