From patchwork Mon Jul 30 12:41:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurynas Biveinis X-Patchwork-Id: 174015 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 BB02F2C0092 for ; Mon, 30 Jul 2012 22:41:46 +1000 (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=1344256907; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=NWCdjAs qOqJvLcWx072CskB0a5Y=; b=YS9gKW2nQlo84aOtsTbJYvuPQndhNQvBZOTJF61 sbOAVIWc9002ZN7ixLUN42iyig2wlNnOLXXkReEWi1FWjb/4LOBpxgcvUA/+08CP LRhkSiKTlMC5ofDVNRv7CSmxidp/2aFkEDw4GIznyxkE4qSSyvpRp2SoeU2i/oyE GfS8= 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:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=bj+h7eQO3sJoqJ6f7AAg7veR2mT4zkAl5BlcIh+kjUPAVeO7d5zg3wsQX9gz3F 9OUT7ERmQKWA5Wq5Z14CHhcjUIoN/h51c9e1ik5FQryOBIxsdrEMiZHw5pS+Th5k RuBCmipY3jjAm1I/I7yvmFaVSRRTE5aAJPrNmVRxwmhGg=; Received: (qmail 8635 invoked by alias); 30 Jul 2012 12:41:39 -0000 Received: (qmail 8624 invoked by uid 22791); 30 Jul 2012 12:41:38 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-bk0-f47.google.com (HELO mail-bk0-f47.google.com) (209.85.214.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Jul 2012 12:41:24 +0000 Received: by bkcik5 with SMTP id ik5so2570605bkc.20 for ; Mon, 30 Jul 2012 05:41:23 -0700 (PDT) Received: by 10.204.147.1 with SMTP id j1mr1621764bkv.110.1343652082923; Mon, 30 Jul 2012 05:41:22 -0700 (PDT) Received: from [192.168.99.139] (office.pov.lt. [88.119.11.77]) by mx.google.com with ESMTPS id ht18sm3717311bkc.16.2012.07.30.05.41.20 (version=SSLv3 cipher=OTHER); Mon, 30 Jul 2012 05:41:21 -0700 (PDT) Message-ID: <501680EF.1050902@gmail.com> Date: Mon, 30 Jul 2012 15:41:19 +0300 From: Laurynas Biveinis User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org Subject: [PATCH] Follow-up to the last gengtype patch: handle DEF_VEC_A in gengtype X-IsSubscribed: yes 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 I only remembered to add DEF_VEC_A handlgin to gengtype.c a second after committing the previous patch [1]. Here it is, done as a follow up. With some luck, this will be short-lived code because of the C++ conversion. Bootstrapped and regtested on x86_64 linux. OK for trunk? 2012-07-30 Laurynas Biveinis * gengtype.h (enum gc_vec_type_kind): New. List individual vector kinds in the token codes. * gengtype-lex.l: Handle DEF_VEC_A, DEF_VEC_O, DEF_VEC_P, DEF_VEC_I individually. * gengtype-parse.c (token_names): Replace "DEF_VEC_[OP]" with individual vector token names. (def_vec): handle vector token types separately. (parse_file): handle the new vector token types. * gengtype.c (note_def_vec): remove is_scalar argument, introduce vec_type_argument instead. Create GTY option and resolve the vector element type according to vec_type_argument value. Index: gcc/gcc/gengtype-parse.c =================================================================== --- gcc/gcc/gengtype-parse.c (revision 189950) +++ gcc/gcc/gengtype-parse.c (working copy) @@ -77,9 +77,11 @@ "struct", "enum", "VEC", - "DEF_VEC_[OP]", + "DEF_VEC_A", + "DEF_VEC_O", + "DEF_VEC_P" "DEF_VEC_I", - "DEF_VEC_ALLOC_[IOP]", + "DEF_VEC_ALLOC_[AIOP]", "...", "ptr_alias", "nested_ptr", @@ -893,17 +895,37 @@ /* Definition of a generic VEC structure: - 'DEF_VEC_[IPO]' '(' id ')' ';' + 'DEF_VEC_[AIOP]' '(' id ')' ';' - Scalar VECs require slightly different treatment than otherwise - - that's handled in note_def_vec, we just pass it along.*/ +*/ static void def_vec (void) { - bool is_scalar = (token () == DEFVEC_I); + enum gc_vec_type_kind vec_type_kind; const char *type; - require2 (DEFVEC_OP, DEFVEC_I); + switch (token ()) + { + case DEFVEC_A: + vec_type_kind = VEC_TYPE_ATOMIC; + advance (); + break; + case DEFVEC_I: + vec_type_kind = VEC_TYPE_INTEGRAL; + advance (); + break; + case DEFVEC_O: + vec_type_kind = VEC_TYPE_OBJECT; + advance (); + break; + case DEFVEC_P: + vec_type_kind = VEC_TYPE_POINTER; + advance (); + break; + default: + gcc_unreachable (); + } + require ('('); type = require2 (ID, SCALAR); require (')'); @@ -912,13 +934,13 @@ if (!type) return; - note_def_vec (type, is_scalar, &lexer_line); + note_def_vec (type, vec_type_kind, &lexer_line); note_def_vec_alloc (type, "none", &lexer_line); } /* Definition of an allocation strategy for a VEC structure: - 'DEF_VEC_ALLOC_[IPO]' '(' id ',' id ')' ';' + 'DEF_VEC_ALLOC_[AIOP]' '(' id ',' id ')' ';' For purposes of gengtype, this just declares a wrapper structure. */ static void @@ -964,7 +986,9 @@ typedef_decl (); break; - case DEFVEC_OP: + case DEFVEC_A: + case DEFVEC_O: + case DEFVEC_P: case DEFVEC_I: def_vec (); break; Index: gcc/gcc/gengtype-lex.l =================================================================== --- gcc/gcc/gengtype-lex.l (revision 189950) +++ gcc/gcc/gengtype-lex.l (working copy) @@ -92,15 +92,23 @@ return STATIC; } -^{HWS}DEF_VEC_[OP]/{EOID} { +^{HWS}DEF_VEC_A/{EOID} { BEGIN(in_struct); - return DEFVEC_OP; + return DEFVEC_A; } +^{HWS}DEF_VEC_O/{EOID} { + BEGIN(in_struct); + return DEFVEC_O; +} +^{HWS}DEF_VEC_P/{EOID} { + BEGIN(in_struct); + return DEFVEC_P; +} ^{HWS}DEF_VEC_I/{EOID} { BEGIN(in_struct); return DEFVEC_I; } -^{HWS}DEF_VEC_ALLOC_[IOP]/{EOID} { +^{HWS}DEF_VEC_ALLOC_[AIOP]/{EOID} { BEGIN(in_struct); return DEFVEC_ALLOC; } Index: gcc/gcc/gengtype.c =================================================================== --- gcc/gcc/gengtype.c (revision 189951) +++ gcc/gcc/gengtype.c (working copy) @@ -4269,28 +4269,39 @@ typedef struct VEC__base GTY(()) { struct vec_prefix prefix; - GTY((length ("%h.prefix.num"))) vec[1]; + vec[1]; } VEC__base - where the GTY(()) tags are only present if is_scalar is _false_. */ - + where the depends on VEC_TYPE_KIND: it is GTY((atomic)) for + VEC_TYPE_ATOMIC, GTY((length ("%h.prefix.num"))) for VEC_TYPE_OBJECT and + VEC_TYPE_POINTER, and none for DEF_VEC_INTEGRAL. +*/ void -note_def_vec (const char *type_name, bool is_scalar, struct fileloc *pos) +note_def_vec (const char *type_name, enum gc_vec_type_kind vec_type_kind, + struct fileloc *pos) { pair_p fields; type_p t; options_p o; const char *name = concat ("VEC_", type_name, "_base", (char *) 0); - if (is_scalar) + switch (vec_type_kind) { + case VEC_TYPE_ATOMIC: + t = resolve_typedef (type_name, pos); + o = create_string_option(0, "atomic", ""); + break; + case VEC_TYPE_INTEGRAL: t = create_scalar_type (type_name); - o = 0; - } - else - { + o = NULL; + break; + case VEC_TYPE_OBJECT: + case VEC_TYPE_POINTER: t = resolve_typedef (type_name, pos); o = create_string_option (0, "length", "%h.prefix.num"); + break; + default: + gcc_unreachable(); } /* We assemble the field list in reverse order. */ fields = create_field_at (0, create_array (t, "1"), "vec", o, pos); Index: gcc/gcc/gengtype.h =================================================================== --- gcc/gcc/gengtype.h (revision 189950) +++ gcc/gcc/gengtype.h (working copy) @@ -233,6 +233,14 @@ GC_POINTED_TO }; +/* A kind of vector data element type */ +enum gc_vec_type_kind { + VEC_TYPE_ATOMIC, /* GC-managed type with no pointers in it */ + VEC_TYPE_INTEGRAL, /* Scalar */ + VEC_TYPE_OBJECT, /* GC-managed type with pointer in it */ + VEC_TYPE_POINTER /* Pointer */ +}; + /* We can have at most ten type parameters in parameterized structures. */ #define NUM_PARAM 10 @@ -424,7 +432,8 @@ extern type_p adjust_field_type (type_p, options_p); extern void note_variable (const char *s, type_p t, options_p o, struct fileloc *pos); -extern void note_def_vec (const char *type_name, bool is_scalar, +extern void note_def_vec (const char *type_name, + enum gc_vec_type_kind vec_type_kind, struct fileloc *pos); extern void note_def_vec_alloc (const char *type, const char *astrat, struct fileloc *pos); @@ -453,7 +462,9 @@ STRUCT, ENUM, VEC_TOKEN, - DEFVEC_OP, + DEFVEC_A, + DEFVEC_O, + DEFVEC_P, DEFVEC_I, DEFVEC_ALLOC, ELLIPSIS,