From patchwork Wed Dec 1 05:32:00 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joern Rennecke X-Patchwork-Id: 73707 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 BFACB1007D1 for ; Wed, 1 Dec 2010 16:32:16 +1100 (EST) Received: (qmail 9747 invoked by alias); 1 Dec 2010 05:32:12 -0000 Received: (qmail 9728 invoked by uid 22791); 1 Dec 2010 05:32:09 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=AWL, BAYES_50, MIME_QP_LONG_LINE, RCVD_IN_DNSWL_LOW, TW_CR X-Spam-Check-By: sourceware.org Received: from c60.cesmail.net (HELO c60.cesmail.net) (216.154.195.49) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 01 Dec 2010 05:32:02 +0000 Received: from unknown (HELO epsilon2) ([192.168.1.60]) by c60.cesmail.net with ESMTP; 01 Dec 2010 00:32:00 -0500 Received: from 89.241.155.143 ([89.241.155.143]) by webmail.spamcop.net (Horde MIME library) with HTTP; Wed, 01 Dec 2010 00:32:00 -0500 Message-ID: <20101201003200.tzlku02bwoswsg0g-nzlynne@webmail.spamcop.net> Date: Wed, 01 Dec 2010 00:32:00 -0500 From: Joern Rennecke To: gcc-patches@gcc.gnu.org Subject: RFA: hookize BOOL_TYPE_SIZE and ADA_LONG_TYPE_SIZE MIME-Version: 1.0 User-Agent: Internet Messaging Program (IMP) H3 (4.1.4) 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 bootstrapped & regtested on x86_64-pc-linux-gnu cross-tested on x86_64-pc-linux-gnu for the following targets: ppc-darwin alpha-linux-gnu hppa-linux-gnu mips-elf sh-elf arc-elf ia64-elf sparc-elf arm-eabi iq2000-elf mn10300-elf spu-elf avr-elf lm32-elf moxie-elf v850-elf m32c-elf pdp11-aout cris-elf m32r-elf picochip-elf xstormy16-elf crx-elf m68hc11-elf ppc-elf xtensa-elf fr30-elf m68k-elf rx-elf mcore-elf s390-linux-gnu h8300-elf mep-elf score-elf bootstrapped on i686-pc-linux-gnu cross-tested on i686-pc-linux-gnu for targets: bfin-elf frv-elf mmix-knuth-mmixware vax-linux-gnu Ada testing for microblaze is currently not possible because of PR46738. 2010-12-01 Joern Rennecke PR other/46677 gcc: * doc/tm.texi: Regenerate. * doc/tm.texi.in (ADA_LONG_TYPE_SIZE, BOOL_TYPE_SIZE): Delete. (TARGET_ADA_LONG_TYPE_SIZE, TARGET_BOOL_TYPE_SIZE): New hook. * targhooks.c (default_bool_type_size): New function. (default_ada_long_type_size): Likewise. * targhooks.h (default_bool_type_size): Declare. (default_ada_long_type_size): Likewise. * hooks.c (hook_int_void_64): New function. * hooks.h (hook_int_void_64): Declare. * target.def (bool_type_size, ada_long_type_size): New hooks. * defaults.h (BOOL_TYPE_SIZE): Delete. * tree.c (free_lang_data): Use targetm.bool_type_size. (build_common_tree_nodes): Likewise. * config/alpha/vms.h (ADA_LONG_TYPE_SIZE): Delete. (TARGET_ADA_LONG_TYPE_SIZE): Define. * config/ia64/vms.h (ADA_LONG_TYPE_SIZE): Delete. (TARGET_ADA_LONG_TYPE_SIZE): Define. * config/rs6000/darwin.h (BOOL_TYPE_SIZE): Delete. (darwin_bool_type_size): Declare. (TARGET_BOOL_TYPE_SIZE): Define. * config/darwin.c (darwin_bool_type_size): New function. * system.h (BOOL_TYPE_SIZE, ADA_LONG_TYPE_SIZE): Poison. gcc/ada: * gcc-interface/targtyps.c: Include target.h (ADA_LONG_TYPE_SIZE): Don't define. (get_target_long_size): Use targetm.ada_long_type_size. * gcc-interface/Make-lang.in (ada/targtyps.o): Depend on $(TARGET_H) . gcc/fortran: * iso-c-binding.def (c_bool): Use targetm.bool_type_size. * trans-types.c (gfc_build_logical_type): Likewise. * types.def (BT_BOOL): Likewise. Index: doc/tm.texi =================================================================== --- doc/tm.texi (revision 167318) +++ doc/tm.texi (working copy) @@ -1468,13 +1468,9 @@ target machine. If you don't define this, the default is one word. @end defmac -@defmac ADA_LONG_TYPE_SIZE -On some machines, the size used for the Ada equivalent of the type -@code{long} by a native Ada compiler differs from that used by C@. In -that situation, define this macro to be a C expression to be used for -the size of that type. If you don't define this, the default is the -value of @code{LONG_TYPE_SIZE}. -@end defmac +@deftypefn {Target Hook} int TARGET_ADA_LONG_TYPE_SIZE (void) +The size, in bits, of the long type used by Ada. By default this is the same as for C. +@end deftypefn @defmac LONG_LONG_TYPE_SIZE A C expression for the size in bits of the type @code{long long} on the @@ -1489,11 +1485,9 @@ @code{BITS_PER_UNIT}. @end defmac -@defmac BOOL_TYPE_SIZE -A C expression for the size in bits of the C++ type @code{bool} and -C99 type @code{_Bool} on the target machine. If you don't define -this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}. -@end defmac +@deftypefn {Target Hook} int TARGET_BOOL_TYPE_SIZE (void) +The size, in bits, of the boolean type used by most frontends that have such a type. (Java is an exception, because the language defines the type size). The default is @code{CHAR_TYPE_SIZE}. +@end deftypefn @defmac FLOAT_TYPE_SIZE A C expression for the size in bits of the type @code{float} on the Index: doc/tm.texi.in =================================================================== --- doc/tm.texi.in (revision 167318) +++ doc/tm.texi.in (working copy) @@ -1458,13 +1458,7 @@ target machine. If you don't define this, the default is one word. @end defmac -@defmac ADA_LONG_TYPE_SIZE -On some machines, the size used for the Ada equivalent of the type -@code{long} by a native Ada compiler differs from that used by C@. In -that situation, define this macro to be a C expression to be used for -the size of that type. If you don't define this, the default is the -value of @code{LONG_TYPE_SIZE}. -@end defmac +@hook TARGET_ADA_LONG_TYPE_SIZE @defmac LONG_LONG_TYPE_SIZE A C expression for the size in bits of the type @code{long long} on the @@ -1479,11 +1473,7 @@ @code{BITS_PER_UNIT}. @end defmac -@defmac BOOL_TYPE_SIZE -A C expression for the size in bits of the C++ type @code{bool} and -C99 type @code{_Bool} on the target machine. If you don't define -this, and you probably shouldn't, the default is @code{CHAR_TYPE_SIZE}. -@end defmac +@hook TARGET_BOOL_TYPE_SIZE @defmac FLOAT_TYPE_SIZE A C expression for the size in bits of the type @code{float} on the Index: targhooks.c =================================================================== --- targhooks.c (revision 167318) +++ targhooks.c (working copy) @@ -437,6 +437,19 @@ return !!FLOAT_WORDS_BIG_ENDIAN; } +/* `bool' has size and alignment `1', on almost all platforms. */ +int +default_bool_type_size (void) +{ + return CHAR_TYPE_SIZE; +} + +int +default_ada_long_type_size (void) +{ + return LONG_TYPE_SIZE; +} + /* True if the target supports decimal floating point. */ bool Index: targhooks.h =================================================================== --- targhooks.h (revision 167318) +++ targhooks.h (working copy) @@ -71,6 +71,8 @@ extern bool targhook_words_big_endian (void); extern bool targhook_float_words_big_endian (void); extern bool default_decimal_float_supported_p (void); +extern int default_bool_type_size (void); +extern int default_ada_long_type_size (void); extern bool default_fixed_point_supported_p (void); extern const char * default_invalid_within_doloop (const_rtx); Index: hooks.c =================================================================== --- hooks.c (revision 167318) +++ hooks.c (working copy) @@ -375,3 +375,10 @@ hook_void_gcc_optionsp (struct gcc_options *opts ATTRIBUTE_UNUSED) { } + +/* Generic hook that returns 64. */ +int +hook_int_void_64 (void) +{ + return 64; +} Index: hooks.h =================================================================== --- hooks.h (revision 167318) +++ hooks.h (working copy) @@ -90,4 +90,5 @@ extern const char *hook_constcharptr_const_tree_const_tree_null (const_tree, const_tree); extern const char *hook_constcharptr_int_const_tree_null (int, const_tree); extern const char *hook_constcharptr_int_const_tree_const_tree_null (int, const_tree, const_tree); +extern int hook_int_void_64 (void); #endif Index: target.def =================================================================== --- target.def (revision 167318) +++ target.def (working copy) @@ -1178,6 +1178,21 @@ bool, (void), targhook_float_words_big_endian) +DEFHOOK +(bool_type_size, + "The size, in bits, of the boolean type used by most frontends that have such\ + a type. (Java is an exception, because the language defines the type size). \ + The default is @code{CHAR_TYPE_SIZE}.", + int, (void), + default_bool_type_size) + +DEFHOOK +(ada_long_type_size, + "The size, in bits, of the long type used by Ada. By default this is the\ + same as for C.", + int, (void), + default_ada_long_type_size) + /* True if the target supports decimal floating point. */ DEFHOOK (decimal_float_supported_p, Index: defaults.h =================================================================== --- defaults.h (revision 167318) +++ defaults.h (working copy) @@ -431,11 +431,6 @@ #define CHAR_TYPE_SIZE BITS_PER_UNIT #endif -#ifndef BOOL_TYPE_SIZE -/* `bool' has size and alignment `1', on almost all platforms. */ -#define BOOL_TYPE_SIZE CHAR_TYPE_SIZE -#endif - #ifndef SHORT_TYPE_SIZE #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2)) #endif Index: tree.c =================================================================== --- tree.c (revision 167318) +++ tree.c (working copy) @@ -5087,11 +5087,11 @@ fileptr_type_node = ptr_type_node; if (TREE_CODE (boolean_type_node) != BOOLEAN_TYPE || (TYPE_MODE (boolean_type_node) - != mode_for_size (BOOL_TYPE_SIZE, MODE_INT, 0)) + != mode_for_size (targetm.bool_type_size (), MODE_INT, 0)) || TYPE_PRECISION (boolean_type_node) != 1 || !TYPE_UNSIGNED (boolean_type_node)) { - boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); + boolean_type_node = make_unsigned_type (targetm.bool_type_size ()); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1); TYPE_PRECISION (boolean_type_node) = 1; @@ -9014,10 +9014,11 @@ } #endif /* Define a boolean type. This type only represents boolean values but - may be larger than char depending on the value of BOOL_TYPE_SIZE. + may be larger than char depending on the value of + targetm.bool_type_size (). Front ends which want to override this size (i.e. Java) can redefine boolean_type_node before calling build_common_tree_nodes_2. */ - boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE); + boolean_type_node = make_unsigned_type (targetm.bool_type_size ()); TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE); TYPE_MAX_VALUE (boolean_type_node) = build_int_cst (boolean_type_node, 1); TYPE_PRECISION (boolean_type_node) = 1; Index: ada/gcc-interface/targtyps.c =================================================================== --- ada/gcc-interface/targtyps.c (revision 167318) +++ ada/gcc-interface/targtyps.c (working copy) @@ -31,6 +31,7 @@ #include "tree.h" #include "tm.h" #include "tm_p.h" +#include "target.h" #include "ada.h" #include "types.h" @@ -48,12 +49,6 @@ #include "ada-tree.h" #include "gigi.h" -/* If we don't have a specific size for Ada's equivalent of `long', use that - of C. */ -#ifndef ADA_LONG_TYPE_SIZE -#define ADA_LONG_TYPE_SIZE LONG_TYPE_SIZE -#endif - #ifndef WIDEST_HARDWARE_FP_SIZE #define WIDEST_HARDWARE_FP_SIZE LONG_DOUBLE_TYPE_SIZE #endif @@ -101,7 +96,7 @@ Pos get_target_long_size (void) { - return ADA_LONG_TYPE_SIZE; + return targetm.ada_long_type_size (); } Pos Index: fortran/iso-c-binding.def =================================================================== --- fortran/iso-c-binding.def (revision 167318) +++ fortran/iso-c-binding.def (working copy) @@ -116,7 +116,7 @@ get_real_kind_from_node (long_double_type_node)) NAMED_LOGCST (ISOCBINDING_BOOL, "c_bool", \ - get_int_kind_from_width (BOOL_TYPE_SIZE)) + get_int_kind_from_width (targetm.bool_type_size ())) NAMED_CHARKNDCST (ISOCBINDING_CHAR, "c_char", gfc_default_character_kind) Index: fortran/trans-types.c =================================================================== --- fortran/trans-types.c (revision 167318) +++ fortran/trans-types.c (working copy) @@ -771,7 +771,7 @@ int bit_size = info->bit_size; tree new_type; - if (bit_size == BOOL_TYPE_SIZE) + if (bit_size == targetm.bool_type_size ()) { info->c_bool = 1; return boolean_type_node; Index: fortran/types.def =================================================================== --- fortran/types.def (revision 167318) +++ fortran/types.def (working copy) @@ -51,7 +51,8 @@ DEF_PRIMITIVE_TYPE (BT_VOID, void_type_node) DEF_PRIMITIVE_TYPE (BT_BOOL, - (*lang_hooks.types.type_for_size) (BOOL_TYPE_SIZE, 1)) + (*lang_hooks.types.type_for_size) + (targetm.bool_type_size (), 1)) DEF_PRIMITIVE_TYPE (BT_INT, integer_type_node) DEF_PRIMITIVE_TYPE (BT_UINT, unsigned_type_node) DEF_PRIMITIVE_TYPE (BT_LONG, long_integer_type_node) Index: system.h =================================================================== --- system.h (revision 167318) +++ system.h (working copy) @@ -759,7 +759,7 @@ LABEL_ALIGN_MAX_SKIP LOOP_ALIGN_MAX_SKIP \ LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP JUMP_ALIGN_MAX_SKIP \ CAN_DEBUG_WITHOUT_FP UNLIKELY_EXECUTED_TEXT_SECTION_NAME \ - HOT_TEXT_SECTION_NAME + HOT_TEXT_SECTION_NAME BOOL_TYPE_SIZE ADA_LONG_TYPE_SIZE /* Other obsolete target macros, or macros that used to be in target headers and were not used, and may be obsolete or may never have Index: config/alpha/vms.h =================================================================== --- config/alpha/vms.h (revision 167318) +++ config/alpha/vms.h (working copy) @@ -62,7 +62,7 @@ /* "long" is 32 bits, but 64 bits for Ada. */ #undef LONG_TYPE_SIZE #define LONG_TYPE_SIZE 32 -#define ADA_LONG_TYPE_SIZE 64 +#define TARGET_ADA_LONG_TYPE_SIZE hook_int_void_64 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended. */ #undef POINTER_SIZE Index: config/ia64/vms.h =================================================================== --- config/ia64/vms.h (revision 167318) +++ config/ia64/vms.h (working copy) @@ -52,7 +52,7 @@ /* "long" is 32 bits, but 64 bits for Ada. */ #undef LONG_TYPE_SIZE #define LONG_TYPE_SIZE 32 -#define ADA_LONG_TYPE_SIZE 64 +#define TARGET_ADA_LONG_TYPE_SIZE hook_int_void_64 /* Pointer is 32 bits but the hardware has 64-bit addresses, sign extended. */ #undef POINTER_SIZE Index: config/rs6000/darwin.h =================================================================== --- config/rs6000/darwin.h (revision 167318) +++ config/rs6000/darwin.h (working copy) @@ -369,7 +369,8 @@ /* For binary compatibility with 2.95; Darwin C APIs use bool from stdbool.h, which was an int-sized enum in 2.95. Users can explicitly choose to have sizeof(bool)==1 with the -mone-byte-bool switch. */ -#define BOOL_TYPE_SIZE (darwin_one_byte_bool ? CHAR_TYPE_SIZE : INT_TYPE_SIZE) +extern int darwin_bool_type_size (void); +#define TARGET_BOOL_TYPE_SIZE darwin_bool_type_size #undef REGISTER_TARGET_PRAGMAS #define REGISTER_TARGET_PRAGMAS() \ Index: config/darwin.c =================================================================== --- config/darwin.c (revision 167318) +++ config/darwin.c (working copy) @@ -2998,4 +2998,10 @@ } } +int +darwin_bool_type_size (void) +{ + return darwin_one_byte_bool ? CHAR_TYPE_SIZE : INT_TYPE_SIZE; +} + #include "gt-darwin.h" Index: ada/gcc-interface/Make-lang.in =================================================================== --- ada/gcc-interface/Make-lang.in (revision 167318) +++ ada/gcc-interface/Make-lang.in (working copy) @@ -1242,7 +1242,7 @@ coretypes.h $(TM_H) $(TM_P_H) $(TREE_H) ada/gcc-interface/ada.h \ ada/types.h ada/atree.h ada/elists.h ada/namet.h ada/nlists.h \ ada/snames.h ada/stringt.h ada/uintp.h ada/urealp.h ada/fe.h ada/sinfo.h \ - ada/einfo.h $(ADA_TREE_H) ada/gcc-interface/gigi.h + ada/einfo.h $(ADA_TREE_H) ada/gcc-interface/gigi.h $(TARGET_H) $(COMPILER) -c $(ALL_COMPILERFLAGS) -I.. $(ALL_CPPFLAGS) $< -o $@ ada/trans.o : ada/gcc-interface/trans.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \