summaryrefslogtreecommitdiff
path: root/gcc/genmodes.c
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2014-10-14 15:44:36 -0400
committerDJ Delorie <dj@gcc.gnu.org>2014-10-14 15:44:36 -0400
commit78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49 (patch)
treee12f293c8d0e0b83e0dc6b0b250a64fb5d4bcd50 /gcc/genmodes.c
parentdf3e34938d9b38a0906a8ebf491f8b73bda5346d (diff)
downloadgcc-78a7c3172fe2e6cd959abb8bfc69f6b0dc747d49.tar.gz
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/genmodes.c')
-rw-r--r--gcc/genmodes.c87
1 files changed, 86 insertions, 1 deletions
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 0215a1883c8..1a32cdefeab 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -74,6 +74,7 @@ struct mode_data
unsigned int fbit; /* the number of fractional bits */
bool need_bytesize_adj; /* true if this mode need dynamic size
adjustment */
+ unsigned int int_n; /* If nonzero, then __int<INT_N> will be defined */
};
static struct mode_data *modes[MAX_MODE_CLASS];
@@ -84,7 +85,7 @@ static const struct mode_data blank_mode = {
0, "<unknown>", MAX_MODE_CLASS,
-1U, -1U, -1U, -1U,
0, 0, 0, 0, 0,
- "<unknown>", 0, 0, 0, 0, false
+ "<unknown>", 0, 0, 0, 0, false, 0
};
static htab_t modes_by_name;
@@ -632,6 +633,34 @@ reset_float_format (const char *name, const char *format,
m->format = format;
}
+/* __intN support. */
+#define INT_N(M,PREC) \
+ make_int_n (#M, PREC, __FILE__, __LINE__)
+static void ATTRIBUTE_UNUSED
+make_int_n (const char *m, int bitsize,
+ const char *file, unsigned int line)
+{
+ struct mode_data *component = find_mode (m);
+ if (!component)
+ {
+ error ("%s:%d: no mode \"%s\"", file, line, m);
+ return;
+ }
+ if (component->cl != MODE_INT
+ && component->cl != MODE_PARTIAL_INT)
+ {
+ error ("%s:%d: mode \"%s\" is not class INT or PARTIAL_INT", file, line, m);
+ return;
+ }
+ if (component->int_n != 0)
+ {
+ error ("%s:%d: mode \"%s\" already has an intN", file, line, m);
+ return;
+ }
+
+ component->int_n = bitsize;
+}
+
/* Partial integer modes are specified by relation to a full integer
mode. */
#define PARTIAL_INT_MODE(M,PREC,NAME) \
@@ -1010,6 +1039,7 @@ emit_insn_modes_h (void)
{
int c;
struct mode_data *m, *first, *last;
+ int n_int_n_ents = 0;
printf ("/* Generated automatically from machmode.def%s%s\n",
HAVE_EXTRA_MODES ? " and " : "",
@@ -1071,6 +1101,13 @@ enum machine_mode\n{");
printf ("#define CONST_MODE_IBIT%s\n", adj_ibit ? "" : " const");
printf ("#define CONST_MODE_FBIT%s\n", adj_fbit ? "" : " const");
emit_max_int ();
+
+ for_all_modes (c, m)
+ if (m->int_n)
+ n_int_n_ents ++;
+
+ printf ("#define NUM_INT_N_ENTS %d\n", n_int_n_ents);
+
puts ("\n#if GCC_VERSION >= 4001\n");
emit_mode_size_inline ();
emit_mode_nunits_inline ();
@@ -1520,6 +1557,53 @@ emit_mode_fbit (void)
print_closer ();
}
+/* Emit __intN for all modes. */
+
+static void
+emit_mode_int_n (void)
+{
+ int c;
+ struct mode_data *m;
+ struct mode_data **mode_sort;
+ int n_modes = 0;
+ int i, j;
+
+ print_decl ("int_n_data_t", "int_n_data", "");
+
+ n_modes = 0;
+ for_all_modes (c, m)
+ if (m->int_n)
+ n_modes ++;
+ mode_sort = XALLOCAVEC (struct mode_data *, n_modes);
+
+ n_modes = 0;
+ for_all_modes (c, m)
+ if (m->int_n)
+ mode_sort[n_modes++] = m;
+
+ /* Yes, this is a bubblesort, but there are at most four (and
+ usually only 1-2) entries to sort. */
+ for (i = 0; i<n_modes - 1; i++)
+ for (j = i + 1; j < n_modes; j++)
+ if (mode_sort[i]->int_n > mode_sort[j]->int_n)
+ {
+ m = mode_sort[i];
+ mode_sort[i] = mode_sort[j];
+ mode_sort[j] = m;
+ }
+
+ for (i = 0; i < n_modes; i ++)
+ {
+ m = mode_sort[i];
+ printf(" {\n");
+ tagged_printf ("%u", m->int_n, m->name);
+ printf ("%smode,", m->name);
+ printf(" },\n");
+ }
+
+ print_closer ();
+}
+
static void
emit_insn_modes_c (void)
@@ -1539,6 +1623,7 @@ emit_insn_modes_c (void)
emit_mode_adjustments ();
emit_mode_ibit ();
emit_mode_fbit ();
+ emit_mode_int_n ();
}
static void