diff options
author | DJ Delorie <dj@redhat.com> | 2014-10-14 15:44:36 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2014-10-14 15:44:36 -0400 |
commit | 78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49 (patch) | |
tree | e12f293c8d0e0b83e0dc6b0b250a64fb5d4bcd50 /gcc/c-family/c-common.c | |
parent | df3e34938d9b38a0906a8ebf491f8b73bda5346d (diff) | |
download | gcc-78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49.zip gcc-78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49.tar.gz gcc-78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49.tar.bz2 |
machmode.h (int_n_data_t): New.
* machmode.h (int_n_data_t): New.
(int_n_enabled_p): New.
(int_n_data): New.
* tree.c (int_n_enabled_p): New.
(int_n_trees): New.
(make_or_reuse_type): Check for all __intN types, not just
__int128.
(build_common_tree_nodes): Likewise. Also fill in integer_typs[]
entries.
* tree.h (int128_integer_type_node): Remove.
(int128_unsigned_type_node): Remove.
(int_n_trees_t): New.
(int_n_enabled_p): New.
(int_n_trees): New.
* toplev.c (standard_type_bitsize): New.
(do_compile): Check which __intN types are enabled for the current
run.
* builtin-types.def (BT_INT128): Remove.
(BT_UINT128): Remove.
* machmode.def: Add macro to create __int128 for all targets.
* stor-layout.c (mode_for_size): Support __intN types.
(smallest_mode_for_size): Likewise.
(initialize_sizetypes): Support __intN types.
* genmodes.c (struct mode_data): Add int_n field.
(blank_mode): Likewise.
(INT_N): New.
(make_int_n): New.
(emit_insn_modes_h): Count __intN entries and define
NUM_INT_N_ENTS.
(emit_mode_int_n): New.
(emit_insn_modes_c): Call it.
* gimple.c (gimple_signed_or_unsigned_type): Check for all __intN
types, not just __int128.
* tree-core.h (integer_type_kind): Remove __int128-specific
entries, reserve spots for __intN entries.
libstdc++-v3/
* src/c++11/limits.cc: Add support for __intN types.
* include/std/type_traits: Likewise.
* include/std/limits: Likewise.
* include/c_std/cstdlib: Likewise.
* include/bits/cpp_type_traits.h: Likewise.
* include/c_global/cstdlib: Likewise.
c-family/
* c-pretty-print.c (pp_c_integer_constant): Check for all __intN
types, not just __int128.
* c-cppbuiltin.c (c_cpp_builtins): Add builtins for all __intN
types, not just __int128.
(cpp_atomic_builtins): Round pointer sizes up.
(type_suffix): Use type precision, not specific types.
* c-common.c (c_common_reswords): Remove __int128 special case.
(c_common_type_for_size): Check for all __intN types, not just
__int128.
(c_common_type_for_mode): Likewise.
(c_common_signed_or_unsigned_type): Likewise.
(c_build_bitfield_integer_type): Likewise.
(c_common_nodes_and_builtins): Likewise.
(keyword_begins_type_specifier): Likewise.
* c-common.h (rid): Remove RID_INT128 and add RID_INT_N_* for all
__intN variants.
c/
* c-parser.c (c_parse_init): Add RID entries for each __intN.
(c_token_starts_typename): Check all __intN, not just __int128.
(c_token_starts_declspecs): Likewise.
(c_parser_declspecs): Likewise.
(c_parser_attribute_any_word): Likewise.
(c_parser_objc_selector): Likewise.
* c-tree.h (c_typespec_keyword): cts_int128 -> cts_int_n.
(struct c_declspecs): Add int_n_idx field to record *which* __intN
is specified.
* c-decl.c (declspecs_add_type): Check for all __intN, not just
__int128.
(finish_declspecs): Likewise.
testsuite/
* g++.dg/abi/mangle64.C: New.
cp/
* typeck.c (cp_common_type): Check for all __intN types, not just
__int128.
* decl.c (grokdeclarator): Likewise.
* rtti.c (emit_support_tinfos): Check for all __intN types, not just
__int128.
* parser.c (cp_lexer_next_token_is_decl_specifier_keyword): Check
for all __intN types, not just __int128.
(cp_parser_simple_type_specifier): Likewise.
* mangle.c (integer_type_codes): Remove int128-specific codes.
* cp-tree.h (cp_decl_specifier_seq): Add int_n_idx to store which
__intN was specified.
* lex.c (init_reswords): Reserve all __intN keywords.
lto/
* lto-lang.c (lto_build_c_type_nodes): Check intN types for
size-type as well.
(lto_init): Initialize all intN types, not just int128.
From-SVN: r216220
Diffstat (limited to 'gcc/c-family/c-common.c')
-rw-r--r-- | gcc/c-family/c-common.c | 82 |
1 files changed, 55 insertions, 27 deletions
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 23163f5..cd73e27 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -61,12 +61,10 @@ cpp_reader *parse_in; /* Declared in c-pragma.h. */ tree short_integer_type_node; tree long_integer_type_node; tree long_long_integer_type_node; - tree int128_integer_type_node; tree short_unsigned_type_node; tree long_unsigned_type_node; tree long_long_unsigned_type_node; - tree int128_unsigned_type_node; tree truthvalue_type_node; tree truthvalue_false_node; @@ -468,7 +466,6 @@ const struct c_common_resword c_common_reswords[] = { "__imag__", RID_IMAGPART, 0 }, { "__inline", RID_INLINE, 0 }, { "__inline__", RID_INLINE, 0 }, - { "__int128", RID_INT128, 0 }, { "__is_abstract", RID_IS_ABSTRACT, D_CXXONLY }, { "__is_base_of", RID_IS_BASE_OF, D_CXXONLY }, { "__is_class", RID_IS_CLASS, D_CXXONLY }, @@ -3449,6 +3446,8 @@ check_case_bounds (location_t loc, tree type, tree orig_type, tree c_common_type_for_size (unsigned int bits, int unsignedp) { + int i; + if (bits == TYPE_PRECISION (integer_type_node)) return unsignedp ? unsigned_type_node : integer_type_node; @@ -3465,10 +3464,11 @@ c_common_type_for_size (unsigned int bits, int unsignedp) return (unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node); - if (int128_integer_type_node - && bits == TYPE_PRECISION (int128_integer_type_node)) - return (unsignedp ? int128_unsigned_type_node - : int128_integer_type_node); + for (i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && bits == int_n_data[i].bitsize) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); if (bits == TYPE_PRECISION (widest_integer_literal_type_node)) return (unsignedp ? widest_unsigned_literal_type_node @@ -3532,6 +3532,7 @@ tree c_common_type_for_mode (enum machine_mode mode, int unsignedp) { tree t; + int i; if (mode == TYPE_MODE (integer_type_node)) return unsignedp ? unsigned_type_node : integer_type_node; @@ -3548,9 +3549,11 @@ c_common_type_for_mode (enum machine_mode mode, int unsignedp) if (mode == TYPE_MODE (long_long_integer_type_node)) return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node; - if (int128_integer_type_node - && mode == TYPE_MODE (int128_integer_type_node)) - return unsignedp ? int128_unsigned_type_node : int128_integer_type_node; + for (i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && mode == int_n_data[i].m) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); if (mode == TYPE_MODE (widest_integer_literal_type_node)) return unsignedp ? widest_unsigned_literal_type_node @@ -3748,6 +3751,7 @@ tree c_common_signed_or_unsigned_type (int unsignedp, tree type) { tree type1; + int i; /* This block of code emulates the behavior of the old c_common_unsigned_type. In particular, it returns @@ -3766,10 +3770,14 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type) return unsignedp ? long_unsigned_type_node : long_integer_type_node; if (type1 == long_long_integer_type_node || type1 == long_long_unsigned_type_node) return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node; - if (int128_integer_type_node - && (type1 == int128_integer_type_node - || type1 == int128_unsigned_type_node)) - return unsignedp ? int128_unsigned_type_node : int128_integer_type_node; + + for (i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && (type1 == int_n_trees[i].unsigned_type + || type1 == int_n_trees[i].signed_type)) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); + if (type1 == widest_integer_literal_type_node || type1 == widest_unsigned_literal_type_node) return unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node; #if HOST_BITS_PER_WIDE_INT >= 64 @@ -3884,9 +3892,14 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type) if (TYPE_OK (long_long_integer_type_node)) return (unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node); - if (int128_integer_type_node && TYPE_OK (int128_integer_type_node)) - return (unsignedp ? int128_unsigned_type_node - : int128_integer_type_node); + + for (i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && TYPE_MODE (type) == int_n_data[i].m + && TYPE_PRECISION (type) == int_n_data[i].bitsize) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); + if (TYPE_OK (widest_integer_literal_type_node)) return (unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node); @@ -3913,6 +3926,8 @@ c_common_signed_or_unsigned_type (int unsignedp, tree type) tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT width, int unsignedp) { + int i; + /* Extended integer types of the same width as a standard type have lesser rank, so those of the same width as int promote to int or unsigned int and are valid for printf formats expecting int or @@ -3930,10 +3945,11 @@ c_build_bitfield_integer_type (unsigned HOST_WIDE_INT width, int unsignedp) if (width == TYPE_PRECISION (long_long_integer_type_node)) return (unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node); - if (int128_integer_type_node - && width == TYPE_PRECISION (int128_integer_type_node)) - return (unsignedp ? int128_unsigned_type_node - : int128_integer_type_node); + for (i = 0; i < NUM_INT_N_ENTS; i ++) + if (int_n_enabled_p[i] + && width == int_n_data[i].bitsize) + return (unsignedp ? int_n_trees[i].unsigned_type + : int_n_trees[i].signed_type); return build_nonstandard_integer_type (width, unsignedp); } @@ -5338,6 +5354,7 @@ c_common_nodes_and_builtins (void) tree array_domain_type; tree va_list_ref_type_node; tree va_list_arg_type_node; + int i; build_common_tree_nodes (flag_signed_char, flag_short_double); @@ -5354,13 +5371,19 @@ c_common_nodes_and_builtins (void) record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node); record_builtin_type (RID_MAX, "long unsigned int", long_unsigned_type_node); - if (int128_integer_type_node != NULL_TREE) + + for (i = 0; i < NUM_INT_N_ENTS; i ++) { - record_builtin_type (RID_INT128, "__int128", - int128_integer_type_node); - record_builtin_type (RID_MAX, "__int128 unsigned", - int128_unsigned_type_node); + char name[25]; + + sprintf (name, "__int%d", int_n_data[i].bitsize); + record_builtin_type ((enum rid)(RID_FIRST_INT_N + i), xstrdup (name), + int_n_trees[i].signed_type); + sprintf (name, "__int%d unsigned", int_n_data[i].bitsize); + record_builtin_type (RID_MAX, xstrdup (name), + int_n_trees[i].unsigned_type); } + if (c_dialect_cxx ()) record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node); record_builtin_type (RID_MAX, "long long int", @@ -5396,6 +5419,8 @@ c_common_nodes_and_builtins (void) TYPE_DECL, NULL_TREE, intDI_type_node)); #if HOST_BITS_PER_WIDE_INT >= 64 + /* Note that this is different than the __int128 type that's part of + the generic __intN support. */ if (targetm.scalar_mode_supported_p (TImode)) lang_hooks.decls.pushdecl (build_decl (UNKNOWN_LOCATION, TYPE_DECL, @@ -11762,7 +11787,6 @@ keyword_begins_type_specifier (enum rid keyword) case RID_FLOAT: case RID_DOUBLE: case RID_VOID: - case RID_INT128: case RID_UNSIGNED: case RID_LONG: case RID_SHORT: @@ -11785,6 +11809,10 @@ keyword_begins_type_specifier (enum rid keyword) case RID_ENUM: return true; default: + if (keyword >= RID_FIRST_INT_N + && keyword < RID_FIRST_INT_N + NUM_INT_N_ENTS + && int_n_enabled_p[keyword-RID_FIRST_INT_N]) + return true; return false; } } |