From patchwork Thu Jan 30 22:56:10 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Stump X-Patchwork-Id: 315488 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 0FC442C00AB for ; Fri, 31 Jan 2014 09:56:22 +1100 (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=ixp9rzG2exedPDnEv xFF5BZvzyGHpe/9keY9G8MfUvJWPWUwfecL1fWkhHGdHDfhwjjQmONexSal49Qu2 Ja+WtR1m/Hc96FzQpeiHD2uHHdT+r+lVQSgq+V2bYn8crtwUpEo1hAhULbY37OCW vQbR31TNlSQHVjGrMNNlezjDgQ= 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=vufj13z4Am99rn5DkOiJBHB ARDM=; b=Z6mqYAXl4s1sK+MWoiSuO6/yZnxOvJkbTs9SDGdpRkp8+XhSzryHiAm x+qicz4pmorDwCUUVQ+s9TS5sHVGYmCP2t5YE01fEirlSPV3Bit/Ys0NZbqdOeFb YZaXOeC47ta4pPIxBcc9m1J+P20aJsjV5VMG/wLF/CuUff7Fv/54= Received: (qmail 24258 invoked by alias); 30 Jan 2014 22:56:15 -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 24244 invoked by uid 89); 30 Jan 2014 22:56:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_40, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: qmta02.emeryville.ca.mail.comcast.net Received: from qmta02.emeryville.ca.mail.comcast.net (HELO qmta02.emeryville.ca.mail.comcast.net) (76.96.30.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 30 Jan 2014 22:56:13 +0000 Received: from omta05.emeryville.ca.mail.comcast.net ([76.96.30.43]) by qmta02.emeryville.ca.mail.comcast.net with comcast id LLDh1n0030vp7WLA2NwBHw; Thu, 30 Jan 2014 22:56:11 +0000 Received: from up.mrs.kithrup.com ([24.4.193.8]) by omta05.emeryville.ca.mail.comcast.net with comcast id LNwA1n00Q0BKwT48RNwArX; Thu, 30 Jan 2014 22:56:11 +0000 Mime-Version: 1.0 (Mac OS X Mail 6.6 \(1510\)) Subject: Re: wide-int, gengtype From: Mike Stump In-Reply-To: <9995BD70-E5F5-4B1F-8B48-90A238D740ED@comcast.net> Date: Thu, 30 Jan 2014 14:56:10 -0800 Cc: Laurynas Biveinis , Mike Stump , Kenneth Zadeck Message-Id: References: <9995BD70-E5F5-4B1F-8B48-90A238D740ED@comcast.net> To: "gcc-patches@gcc.gnu.org Patches" X-IsSubscribed: yes 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. * 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"