diff options
author | davids <davids@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-19 15:23:11 +0000 |
---|---|---|
committer | davids <davids@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-08-19 15:23:11 +0000 |
commit | a0509d0eb68c41d64f1464de691818519c48aff0 (patch) | |
tree | 2b377ed532e090b8c3c26e8bb610668f7077e860 /gcc/genmodes.c | |
parent | 34bf6b7fe74f1721b8b9b71c98a3515fb77eee04 (diff) | |
download | gcc-a0509d0eb68c41d64f1464de691818519c48aff0.tar.gz |
2015-08-19 David Sherwood <david.sherwood@arm.com>
gcc/
* genmodes.c (emit_mode_unit_size_inline): New function.
(emit_mode_unit_precision_inline): New function.
(emit_insn_modes_h): Emit new #define. Emit new functions.
(emit_mode_unit_size): New function.
(emit_mode_unit_precision): New function.
(emit_mode_adjustments): Add mode_unit_size adjustments.
(emit_insn_modes_c): Emit new arrays.
* machmode.h (GET_MODE_UNIT_SIZE, GET_MODE_UNIT_PRECISION): Update to
use new inline methods.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@227013 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/genmodes.c')
-rw-r--r-- | gcc/genmodes.c | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/gcc/genmodes.c b/gcc/genmodes.c index f4db427ffe3..065ca54f30b 100644 --- a/gcc/genmodes.c +++ b/gcc/genmodes.c @@ -1047,6 +1047,79 @@ mode_inner_inline (machine_mode mode)\n\ }\n"); } +/* Emit mode_unit_size_inline routine into insn-modes.h header. */ +static void +emit_mode_unit_size_inline (void) +{ + int c; + struct mode_data *m; + + puts ("\ +#ifdef __cplusplus\n\ +inline __attribute__((__always_inline__))\n\ +#else\n\ +extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ +#endif\n\ +unsigned char\n\ +mode_unit_size_inline (machine_mode mode)\n\ +{\n\ + extern unsigned char mode_unit_size[NUM_MACHINE_MODES];\n\ + switch (mode)\n\ + {"); + + for_all_modes (c, m) + { + const char *name = m->name; + struct mode_data *m2 = m; + if (c != MODE_PARTIAL_INT && m2->component) + m2 = m2->component; + if (!m2->need_bytesize_adj) + printf (" case %smode: return %u;\n", name, m2->bytesize); + } + + puts ("\ + default: return mode_unit_size[mode];\n\ + }\n\ +}\n"); +} + +/* Emit mode_unit_precision_inline routine into insn-modes.h header. */ +static void +emit_mode_unit_precision_inline (void) +{ + int c; + struct mode_data *m; + + puts ("\ +#ifdef __cplusplus\n\ +inline __attribute__((__always_inline__))\n\ +#else\n\ +extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ +#endif\n\ +unsigned short\n\ +mode_unit_precision_inline (machine_mode mode)\n\ +{\n\ + extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];\n\ + switch (mode)\n\ + {"); + + for_all_modes (c, m) + { + struct mode_data *m2 + = (c != MODE_PARTIAL_INT && m->component) ? m->component : m; + if (m2->precision != (unsigned int)-1) + printf (" case %smode: return %u;\n", m->name, m2->precision); + else + printf (" case %smode: return %u*BITS_PER_UNIT;\n", + m->name, m2->bytesize); + } + + puts ("\ + default: return mode_unit_precision[mode];\n\ + }\n\ +}\n"); +} + static void emit_insn_modes_h (void) { @@ -1107,6 +1180,7 @@ enum machine_mode\n{"); /* I can't think of a better idea, can you? */ printf ("#define CONST_MODE_SIZE%s\n", adj_bytesize ? "" : " const"); + printf ("#define CONST_MODE_UNIT_SIZE%s\n", adj_bytesize ? "" : " const"); printf ("#define CONST_MODE_BASE_ALIGN%s\n", adj_alignment ? "" : " const"); #if 0 /* disabled for backward compatibility, temporary */ printf ("#define CONST_REAL_FORMAT_FOR_MODE%s\n", adj_format ? "" :" const"); @@ -1125,6 +1199,8 @@ enum machine_mode\n{"); emit_mode_size_inline (); emit_mode_nunits_inline (); emit_mode_inner_inline (); + emit_mode_unit_size_inline (); + emit_mode_unit_precision_inline (); puts ("#endif /* GCC_VERSION >= 4001 */"); puts ("\ @@ -1344,6 +1420,47 @@ emit_mode_inner (void) print_closer (); } +/* Emit mode_unit_size array into insn-modes.c file. */ +static void +emit_mode_unit_size (void) +{ + int c; + struct mode_data *m; + + print_maybe_const_decl ("%sunsigned char", "mode_unit_size", + "NUM_MACHINE_MODES", bytesize); + + for_all_modes (c, m) + tagged_printf ("%u", + c != MODE_PARTIAL_INT && m->component + ? m->component->bytesize : m->bytesize, m->name); + + print_closer (); +} + +/* Emit mode_unit_precision array into insn-modes.c file. */ +static void +emit_mode_unit_precision (void) +{ + int c; + struct mode_data *m; + + print_decl ("unsigned short", "mode_unit_precision", "NUM_MACHINE_MODES"); + + for_all_modes (c, m) + { + struct mode_data *m2 = (c != MODE_PARTIAL_INT && m->component) ? + m->component : m; + if (m2->precision != (unsigned int)-1) + tagged_printf ("%u", m2->precision, m->name); + else + tagged_printf ("%u*BITS_PER_UNIT", m2->bytesize, m->name); + } + + print_closer (); +} + + static void emit_mode_base_align (void) { @@ -1439,6 +1556,7 @@ emit_mode_adjustments (void) printf ("\n /* %s:%d */\n s = %s;\n", a->file, a->line, a->adjustment); printf (" mode_size[%smode] = s;\n", a->mode->name); + printf (" mode_unit_size[%smode] = s;\n", a->mode->name); printf (" mode_base_align[%smode] = s & (~s + 1);\n", a->mode->name); @@ -1449,6 +1567,7 @@ emit_mode_adjustments (void) case MODE_COMPLEX_INT: case MODE_COMPLEX_FLOAT: printf (" mode_size[%smode] = 2*s;\n", m->name); + printf (" mode_unit_size[%smode] = s;\n", m->name); printf (" mode_base_align[%smode] = s & (~s + 1);\n", m->name); break; @@ -1461,6 +1580,7 @@ emit_mode_adjustments (void) case MODE_VECTOR_UACCUM: printf (" mode_size[%smode] = %d*s;\n", m->name, m->ncomponents); + printf (" mode_unit_size[%smode] = s;\n", m->name); printf (" mode_base_align[%smode] = (%d*s) & (~(%d*s)+1);\n", m->name, m->ncomponents, m->ncomponents); break; @@ -1626,6 +1746,8 @@ emit_insn_modes_c (void) emit_mode_wider (); emit_mode_mask (); emit_mode_inner (); + emit_mode_unit_size (); + emit_mode_unit_precision (); emit_mode_base_align (); emit_class_narrowest_mode (); emit_real_format_for_mode (); |