diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-08-30 11:19:17 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2017-08-30 11:19:17 +0000 |
commit | 9fcae33ea5c6eabe3073063a2576d7492685e433 (patch) | |
tree | 23cc0255a69adb29141d859194421f1c78fc961d /gcc/machmode.h | |
parent | cc9f5108bc0e206612961f241ae203c841b6337f (diff) | |
download | gcc-9fcae33ea5c6eabe3073063a2576d7492685e433.tar.gz |
[64/77] Add a scalar_mode class
This patch adds a scalar_mode class that can hold any scalar mode,
specifically:
- scalar integers
- scalar floating-point values
- scalar fractional modes
- scalar accumulator modes
- pointer bounds modes
To start with this patch uses this type for GET_MODE_INNER.
Later patches add more uses.
2017-08-30 Richard Sandiford <richard.sandiford@linaro.org>
Alan Hayward <alan.hayward@arm.com>
David Sherwood <david.sherwood@arm.com>
gcc/
* coretypes.h (scalar_mode): New class.
* machmode.h (scalar_mode): Likewise.
(scalar_mode::includes_p): New function.
(mode_to_inner): Return a scalar_mode rather than a machine_mode.
* gdbhooks.py (build_pretty_printers): Handle scalar_mode.
* genmodes.c (get_mode_class): Handle remaining scalar modes.
* cfgexpand.c (expand_debug_expr): Use scalar_mode.
* expmed.c (store_bit_field_1): Likewise.
(extract_bit_field_1): Likewise.
* expr.c (write_complex_part): Likewise.
(read_complex_part): Likewise.
(emit_move_complex_push): Likewise.
(expand_expr_real_2): Likewise.
* function.c (assign_parm_setup_reg): Likewise.
(assign_parms_unsplit_complex): Likewise.
* optabs.c (expand_binop): Likewise.
* rtlanal.c (subreg_get_info): Likewise.
* simplify-rtx.c (simplify_immed_subreg): Likewise.
* varasm.c (output_constant_pool_2): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@251515 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/machmode.h')
-rw-r--r-- | gcc/machmode.h | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h index 5f3e031324e..4586d62b81a 100644 --- a/gcc/machmode.h +++ b/gcc/machmode.h @@ -409,6 +409,47 @@ scalar_float_mode::includes_p (machine_mode m) return SCALAR_FLOAT_MODE_P (m); } +/* Represents a machine mode that is known to be scalar. */ +class scalar_mode +{ +public: + typedef mode_traits<scalar_mode>::from_int from_int; + + ALWAYS_INLINE scalar_mode () {} + ALWAYS_INLINE scalar_mode (from_int m) : m_mode (machine_mode (m)) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_float_mode &m) : m_mode (m) {} + ALWAYS_INLINE scalar_mode (const scalar_int_mode_pod &m) : m_mode (m) {} + ALWAYS_INLINE operator machine_mode () const { return m_mode; } + + static bool includes_p (machine_mode); + +protected: + machine_mode m_mode; +}; + +/* Return true if M represents some kind of scalar value. */ + +inline bool +scalar_mode::includes_p (machine_mode m) +{ + switch (GET_MODE_CLASS (m)) + { + case MODE_INT: + case MODE_PARTIAL_INT: + case MODE_FRACT: + case MODE_UFRACT: + case MODE_ACCUM: + case MODE_UACCUM: + case MODE_FLOAT: + case MODE_DECIMAL_FLOAT: + case MODE_POINTER_BOUNDS: + return true; + default: + return false; + } +} + /* Return the base GET_MODE_SIZE value for MODE. */ ALWAYS_INLINE unsigned short @@ -440,14 +481,15 @@ mode_to_precision (machine_mode mode) /* Return the base GET_MODE_INNER value for MODE. */ -ALWAYS_INLINE machine_mode +ALWAYS_INLINE scalar_mode mode_to_inner (machine_mode mode) { #if GCC_VERSION >= 4001 - return (machine_mode) (__builtin_constant_p (mode) - ? mode_inner_inline (mode) : mode_inner[mode]); + return scalar_mode::from_int (__builtin_constant_p (mode) + ? mode_inner_inline (mode) + : mode_inner[mode]); #else - return (machine_mode) mode_inner[mode]; + return scalar_mode::from_int (mode_inner[mode]); #endif } |