]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/optabs-query.h
Widening optab cleanup
[thirdparty/gcc.git] / gcc / optabs-query.h
index 9c2d57404f0e59482ada89789cd53d4d15ebb3ee..2701e2594e6a1d2f333f1156e777b1c798584eab 100644 (file)
@@ -23,6 +23,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "insn-opinit.h"
 #include "target.h"
 
+/* Return true if OP is a conversion optab.  */
+
+inline bool
+convert_optab_p (optab op)
+{
+  return op > unknown_optab && op <= LAST_CONV_OPTAB;
+}
+
 /* Return the insn used to implement mode MODE of OP, or CODE_FOR_nothing
    if the target does not have such an insn.  */
 
@@ -43,7 +51,7 @@ convert_optab_handler (convert_optab op, machine_mode to_mode,
                       machine_mode from_mode)
 {
   unsigned scode = (op << 16) | (from_mode << 8) | to_mode;
-  gcc_assert (op > unknown_optab && op <= LAST_CONV_OPTAB);
+  gcc_assert (convert_optab_p (op));
   return raw_optab_handler (scode);
 }
 
@@ -167,12 +175,11 @@ enum insn_code can_float_p (machine_mode, machine_mode, int);
 enum insn_code can_fix_p (machine_mode, machine_mode, int, bool *);
 bool can_conditionally_move_p (machine_mode mode);
 bool can_vec_perm_p (machine_mode, bool, vec_perm_indices *);
-enum insn_code widening_optab_handler (optab, machine_mode, machine_mode);
 /* Find a widening optab even if it doesn't widen as much as we want.  */
-#define find_widening_optab_handler(A,B,C,D) \
-  find_widening_optab_handler_and_mode (A, B, C, D, NULL)
+#define find_widening_optab_handler(A, B, C) \
+  find_widening_optab_handler_and_mode (A, B, C, NULL)
 enum insn_code find_widening_optab_handler_and_mode (optab, machine_mode,
-                                                    machine_mode, int,
+                                                    machine_mode,
                                                     machine_mode *);
 int can_mult_highpart_p (machine_mode, bool);
 bool can_vec_mask_load_store_p (machine_mode, machine_mode, bool);
@@ -181,4 +188,20 @@ bool can_atomic_exchange_p (machine_mode, bool);
 bool can_atomic_load_p (machine_mode);
 bool lshift_cheap_p (bool);
 
+/* Version of find_widening_optab_handler_and_mode that operates on
+   specific mode types.  */
+
+template<typename T>
+inline enum insn_code
+find_widening_optab_handler_and_mode (optab op, const T &to_mode,
+                                     const T &from_mode, T *found_mode)
+{
+  machine_mode tmp;
+  enum insn_code icode = find_widening_optab_handler_and_mode
+    (op, machine_mode (to_mode), machine_mode (from_mode), &tmp);
+  if (icode != CODE_FOR_nothing && found_mode)
+    *found_mode = as_a <T> (tmp);
+  return icode;
+}
+
 #endif