aboutsummaryrefslogtreecommitdiff
path: root/gcc/machmode.h
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@linaro.org>2017-08-30 11:21:04 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2017-08-30 11:21:04 +0000
commita97390bf6e92f6f9b0f4e20aff4390ca5c609e37 (patch)
tree887cbbdf7eab9b228fc8dbc63e7d4c06f9b255eb /gcc/machmode.h
parent382615c64cad28fb4aa0566b25b3f1921b3d6a3d (diff)
downloadgcc-a97390bf6e92f6f9b0f4e20aff4390ca5c609e37.zip
gcc-a97390bf6e92f6f9b0f4e20aff4390ca5c609e37.tar.gz
gcc-a97390bf6e92f6f9b0f4e20aff4390ca5c609e37.tar.bz2
[77/77] Add a complex_mode class
This patch adds another machine_mode wrapper for modes that are known to be COMPLEX_MODE_P. There aren't yet many places that make use of it, but that might change in future. 2017-08-30 Richard Sandiford <richard.sandiford@linaro.org> Alan Hayward <alan.hayward@arm.com> David Sherwood <david.sherwood@arm.com> gcc/ * coretypes.h (complex_mode): New type. * gdbhooks.py (build_pretty_printer): Handle it. * machmode.h (complex_mode): New class. (complex_mode::includes_p): New function. (is_complex_int_mode): Likewise. (is_complex_float_mode): Likewise. * genmodes.c (get_mode_class): Handle complex mode classes. * function.c (expand_function_end): Use is_complex_int_mode. gcc/go/ * go-lang.c (go_langhook_type_for_mode): Use is_complex_float_mode. Co-Authored-By: Alan Hayward <alan.hayward@arm.com> Co-Authored-By: David Sherwood <david.sherwood@arm.com> From-SVN: r251527
Diffstat (limited to 'gcc/machmode.h')
-rw-r--r--gcc/machmode.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/gcc/machmode.h b/gcc/machmode.h
index 73c45be..b331f07 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -450,6 +450,30 @@ scalar_mode::includes_p (machine_mode m)
}
}
+/* Represents a machine mode that is known to be a COMPLEX_MODE_P. */
+class complex_mode
+{
+public:
+ typedef mode_traits<complex_mode>::from_int from_int;
+
+ ALWAYS_INLINE complex_mode () {}
+ ALWAYS_INLINE complex_mode (from_int m) : m_mode (machine_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 is a complex_mode. */
+
+inline bool
+complex_mode::includes_p (machine_mode m)
+{
+ return COMPLEX_MODE_P (m);
+}
+
/* Return the base GET_MODE_SIZE value for MODE. */
ALWAYS_INLINE unsigned short
@@ -771,6 +795,36 @@ is_float_mode (machine_mode mode, T *float_mode)
return false;
}
+/* Return true if MODE has class MODE_COMPLEX_INT, storing it as
+ a complex_mode in *CMODE if so. */
+
+template<typename T>
+inline bool
+is_complex_int_mode (machine_mode mode, T *cmode)
+{
+ if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT)
+ {
+ *cmode = complex_mode (complex_mode::from_int (mode));
+ return true;
+ }
+ return false;
+}
+
+/* Return true if MODE has class MODE_COMPLEX_FLOAT, storing it as
+ a complex_mode in *CMODE if so. */
+
+template<typename T>
+inline bool
+is_complex_float_mode (machine_mode mode, T *cmode)
+{
+ if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
+ {
+ *cmode = complex_mode (complex_mode::from_int (mode));
+ return true;
+ }
+ return false;
+}
+
namespace mode_iterator
{
/* Start mode iterator *ITER at the first mode in class MCLASS, if any. */