From patchwork Mon Mar 19 12:02:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tristan Gingold X-Patchwork-Id: 147492 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 E7091B6ED0 for ; Mon, 19 Mar 2012 23:03:13 +1100 (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=1332763396; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Subject:Mime-Version:Content-Type:From:In-Reply-To:Date: Cc:Content-Transfer-Encoding:Message-Id:References:To: Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:Sender:Delivered-To; bh=77a6/4rz5R9fGjBFcJkV ol2ki30=; b=OeGuSpqu6A1ys8QMBdKFUogsr6VFjs3b/TRBIrgdCrj9TIN9to6Z EGKToj/OJGaEEXAzCLtqI6d5vdpHLgmjlNpc6pIFsxID01Lsb4h/OTqtinspfcxi G1R1GYnoM4MfT4lthzng9F/LkPT3qLPmuE07RSqAS4/x90vJSxKQV9k= 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:Subject:Mime-Version:Content-Type:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=os/7dub69kpAeppY/BYS9PxnTslMuGyEABhbO2eL44mHcjaw2Zc3VfB37TAyq4 Nie41jzBo1TOBowVgJhEf4nWkrPs2B1tgIUckbh8ZC8E2LWRUikaqcUgtjk2YV62 4RGxNip5KW3BAnlX/rZvfjxuNGay+Icv67C4YUcJMZPC8=; Received: (qmail 16744 invoked by alias); 19 Mar 2012 12:03:07 -0000 Received: (qmail 16735 invoked by uid 22791); 19 Mar 2012 12:03:06 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (194.98.77.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 19 Mar 2012 12:02:31 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id D2575290037; Mon, 19 Mar 2012 13:02:32 +0100 (CET) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4Ib1OWdY1mY6; Mon, 19 Mar 2012 13:02:32 +0100 (CET) Received: from ulanbator.act-europe.fr (ulanbator.act-europe.fr [10.10.1.67]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id 8AD27290008; Mon, 19 Mar 2012 13:02:32 +0100 (CET) Subject: Re: [Patch]: Uncouple size_t and sizetype Mime-Version: 1.0 (Apple Message framework v1257) From: Tristan Gingold In-Reply-To: Date: Mon, 19 Mar 2012 13:02:29 +0100 Cc: GCC Patches Message-Id: <832267A6-06FF-4FF0-A625-14C7AD37E725@adacore.com> References: <9A88682B-4FC6-44BD-8D22-6C3B2F380CAE@adacore.com> To: Richard Guenther 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 On Mar 16, 2012, at 12:38 PM, Richard Guenther wrote: […] > Well, this setup is not well supported by the middle-end (and indeed m32c > has existing issues with that). So in your case decoupling sizetype from > size_t sounds like the more appropriate solution. > >>> Btw, while we are transitioning to target hooks in this case I'd prefer >>> a target macro alongside the existing SIZE_TYPE, etc. ones. >> >> Ok. > > I'd choose SIZETYPE (for confusion, heh), defaulting to SIZE_TYPE. > > Richard. Hi, here is the patch. As SIZETYPE was already used as a size_type_kind enumeration constant, I made a little renaming work. Bootstrapped, no regressions on x86_64-darwin. Tested on ia64-hp-openvms. Ok for trunk ? Tristan. 2012-03-19 Tristan Gingold * tree.h (enum size_type_kind): Add STK_ prefix to constants. (sizetype_tab, sizetype, bitsizetype, ssizetype, sbitsizetype) (size_int, ssize_int, bitsize_int, sbitsize_int): Adjust. * stor-layout.c (sizetype_tab): Adjust. (initialize_sizetypes): Use SIZETYPE instead of SIZE_TYPE. * tree-streamer.c (preload_common_nodes): Use STK_TYPE_KIND_LAST instead of TYPE_KIND_LAST. * tree-scalar-evolution.c (interpret_rhs_expr): Use size_int instead of size_int_kind. * doc/tm.texi.in (Type Layout): Document SIZETYPE. * doc/tm.texi: Regenerate. * defaults.h (SIZETYPE): Provide a default value. * config/vms/vms.h (SIZE_TYPE): Define as "unsigned int". (SIZETYPE): Define. diff --git a/gcc/config/vms/vms.h b/gcc/config/vms/vms.h index f2bc354..47028c8 100644 --- a/gcc/config/vms/vms.h +++ b/gcc/config/vms/vms.h @@ -60,15 +60,18 @@ extern void vms_c_register_includes (const char *, const char *, int); #define POINTER_SIZE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? 32 : 64) #define POINTERS_EXTEND_UNSIGNED 0 -/* FIXME: It should always be a 32 bit type. */ +/* Always a 32 bit type. */ #undef SIZE_TYPE -#define SIZE_TYPE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? \ - "unsigned int" : "long long unsigned int") +#define SIZE_TYPE "unsigned int" + /* ???: Defined as a 'int' by dec-c, but obstack.h doesn't like it. */ #undef PTRDIFF_TYPE #define PTRDIFF_TYPE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? \ "int" : "long long int") +#define SIZETYPE (flag_vms_pointer_size == VMS_POINTER_SIZE_NONE ? \ + "unsigned int" : "long long unsigned int") + #define C_COMMON_OVERRIDE_OPTIONS vms_c_common_override_options () /* VMS doesn't support other sections than .text for code. */ diff --git a/gcc/defaults.h b/gcc/defaults.h index 1780dda..296bb6a 100644 --- a/gcc/defaults.h +++ b/gcc/defaults.h @@ -582,6 +582,10 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see #define SIZE_TYPE "long unsigned int" #endif +#ifndef SIZETYPE +#define SIZETYPE SIZE_TYPE +#endif + #ifndef PID_TYPE #define PID_TYPE "int" #endif diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index 69f8aba..2891bb6 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -1642,6 +1642,18 @@ If you don't define this macro, the default is @code{"long unsigned int"}. @end defmac +@defmac SIZETYPE +GCC defines internal types (@code{sizetype}, @code{ssizetype}, +@code{bitsizetype} and @code{sbitsizetype}) for expressions +dealing with size. This macro is a C expression for a string describing +the name of the data type from which the precision of @code{sizetype} +is extracted. + +The string has the same restrictions as @code{SIZE_TYPE} string. + +If you don't define this macro, the default is @code{SIZE_TYPE}. +@end defmac + @defmac PTRDIFF_TYPE A C expression for a string describing the name of the data type to use for the result of subtracting two pointers. The typedef name diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index c24cf1e..a222654 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -1630,6 +1630,18 @@ If you don't define this macro, the default is @code{"long unsigned int"}. @end defmac +@defmac SIZETYPE +GCC defines internal types (@code{sizetype}, @code{ssizetype}, +@code{bitsizetype} and @code{sbitsizetype}) for expressions +dealing with size. This macro is a C expression for a string describing +the name of the data type from which the precision of @code{sizetype} +is extracted. + +The string has the same restrictions as @code{SIZE_TYPE} string. + +If you don't define this macro, the default is @code{SIZE_TYPE}. +@end defmac + @defmac PTRDIFF_TYPE A C expression for a string describing the name of the data type to use for the result of subtracting two pointers. The typedef name diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c index 98b7886..479c407 100644 --- a/gcc/stor-layout.c +++ b/gcc/stor-layout.c @@ -44,7 +44,7 @@ along with GCC; see the file COPYING3. If not see /* Data type for the expressions representing sizes of data types. It is the first integer type laid out. */ -tree sizetype_tab[(int) TYPE_KIND_LAST]; +tree sizetype_tab[(int) STK_TYPE_KIND_LAST]; /* If nonzero, this is an upper limit on alignment of structure fields. The value is measured in bits. */ @@ -2389,13 +2389,13 @@ initialize_sizetypes (void) int precision, bprecision; /* Get sizetypes precision from the SIZE_TYPE target macro. */ - if (strcmp (SIZE_TYPE, "unsigned int") == 0) + if (strcmp (SIZETYPE, "unsigned int") == 0) precision = INT_TYPE_SIZE; - else if (strcmp (SIZE_TYPE, "long unsigned int") == 0) + else if (strcmp (SIZETYPE, "long unsigned int") == 0) precision = LONG_TYPE_SIZE; - else if (strcmp (SIZE_TYPE, "long long unsigned int") == 0) + else if (strcmp (SIZETYPE, "long long unsigned int") == 0) precision = LONG_LONG_TYPE_SIZE; - else if (strcmp (SIZE_TYPE, "short unsigned int") == 0) + else if (strcmp (SIZETYPE, "short unsigned int") == 0) precision = SHORT_TYPE_SIZE; else gcc_unreachable (); diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index c719984..c6631b8 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -1758,7 +1758,7 @@ interpret_rhs_expr (struct loop *loop, gimple at_stmt, { gcc_assert ((bitpos % BITS_PER_UNIT) == 0); - unitpos = size_int_kind (bitpos / BITS_PER_UNIT, SIZETYPE); + unitpos = size_int (bitpos / BITS_PER_UNIT); chrec3 = analyze_scalar_evolution (loop, unitpos); chrec3 = chrec_convert (TREE_TYPE (unitpos), chrec3, at_stmt); res = chrec_fold_plus (type, res, chrec3); diff --git a/gcc/tree-streamer.c b/gcc/tree-streamer.c index 94d540b..fd7fae4 100644 --- a/gcc/tree-streamer.c +++ b/gcc/tree-streamer.c @@ -293,7 +293,7 @@ preload_common_nodes (struct streamer_tree_cache_d *cache) if (i != itk_char) record_common_node (cache, integer_types[i]); - for (i = 0; i < TYPE_KIND_LAST; i++) + for (i = 0; i < STK_TYPE_KIND_LAST; i++) record_common_node (cache, sizetype_tab[i]); for (i = 0; i < TI_MAX; i++) diff --git a/gcc/tree.h b/gcc/tree.h index c0340aa..46556e7 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -4787,18 +4787,18 @@ extern HOST_WIDE_INT int_byte_position (const_tree); enum size_type_kind { - SIZETYPE, /* Normal representation of sizes in bytes. */ - SSIZETYPE, /* Signed representation of sizes in bytes. */ - BITSIZETYPE, /* Normal representation of sizes in bits. */ - SBITSIZETYPE, /* Signed representation of sizes in bits. */ - TYPE_KIND_LAST}; + STK_SIZETYPE, /* Normal representation of sizes in bytes. */ + STK_SSIZETYPE, /* Signed representation of sizes in bytes. */ + STK_BITSIZETYPE, /* Normal representation of sizes in bits. */ + STK_SBITSIZETYPE, /* Signed representation of sizes in bits. */ + STK_TYPE_KIND_LAST}; -extern GTY(()) tree sizetype_tab[(int) TYPE_KIND_LAST]; +extern GTY(()) tree sizetype_tab[(int) STK_TYPE_KIND_LAST]; -#define sizetype sizetype_tab[(int) SIZETYPE] -#define bitsizetype sizetype_tab[(int) BITSIZETYPE] -#define ssizetype sizetype_tab[(int) SSIZETYPE] -#define sbitsizetype sizetype_tab[(int) SBITSIZETYPE] +#define sizetype sizetype_tab[(int) STK_SIZETYPE] +#define bitsizetype sizetype_tab[(int) STK_BITSIZETYPE] +#define ssizetype sizetype_tab[(int) STK_SSIZETYPE] +#define sbitsizetype sizetype_tab[(int) STK_SBITSIZETYPE] extern tree size_int_kind (HOST_WIDE_INT, enum size_type_kind); #define size_binop(CODE,T1,T2)\ @@ -4808,10 +4808,10 @@ extern tree size_binop_loc (location_t, enum tree_code, tree, tree); size_diffop_loc (UNKNOWN_LOCATION, T1, T2) extern tree size_diffop_loc (location_t, tree, tree); -#define size_int(L) size_int_kind (L, SIZETYPE) -#define ssize_int(L) size_int_kind (L, SSIZETYPE) -#define bitsize_int(L) size_int_kind (L, BITSIZETYPE) -#define sbitsize_int(L) size_int_kind (L, SBITSIZETYPE) +#define size_int(L) size_int_kind (L, STK_SIZETYPE) +#define ssize_int(L) size_int_kind (L, STK_SSIZETYPE) +#define bitsize_int(L) size_int_kind (L, STK_BITSIZETYPE) +#define sbitsize_int(L) size_int_kind (L, STK_SBITSIZETYPE) #define round_up(T,N) round_up_loc (UNKNOWN_LOCATION, T, N) extern tree round_up_loc (location_t, tree, int);