diff mbox

[hsa] Unify two implementations of hsa_type_float_p

Message ID 20150619191316.GX18873@virgil.suse
State New
Headers show

Commit Message

Martin Jambor June 19, 2015, 7:13 p.m. UTC
Hi,

hsa_type_float_p is another function that we had implemented twice on
the HSA branch, unified thusly.

Martin

2015-06-19  Martin Jambor  <mjambor@suse.cz>

	* hsa-brig.c (float_type_p): Moved from here...
	* hsa-gen.c (hsa_type_float_p): ...and here...
	* hsa.c (hsa_type_float_p): ...to here.
	* hsa.h (hsa_type_float_p): Declare.
---
 gcc/ChangeLog.hsa |  7 +++++++
 gcc/hsa-brig.c    | 22 +++-------------------
 gcc/hsa-gen.c     | 16 ----------------
 gcc/hsa.c         | 16 ++++++++++++++++
 gcc/hsa.h         |  1 +
 5 files changed, 27 insertions(+), 35 deletions(-)
diff mbox

Patch

diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c
index 8526061..0a6855b 100644
--- a/gcc/hsa-brig.c
+++ b/gcc/hsa-brig.c
@@ -1246,22 +1246,6 @@  emit_branch_insn (hsa_insn_br *br)
   brig_insn_count++;
 }
 
-/* Return true iff TYPE is a floating point number type.  */
-
-static bool
-float_type_p (BrigType16_t t)
-{
-  switch (t & BRIG_TYPE_BASE_MASK)
-    {
-    case BRIG_TYPE_F16:
-    case BRIG_TYPE_F32:
-    case BRIG_TYPE_F64:
-      return true;
-    default:
-      return false;
-    }
-}
-
 /* Emit a HSA convert instruction and all necessary directives, schedule
    necessary operands for writing.  */
 
@@ -1300,8 +1284,8 @@  emit_cvt_insn (hsa_insn_basic *insn)
   repr.modifier.allBits = 0;
   /* float to smaller float requires a rounding setting (we default
      to 'near'.  */
-  if (float_type_p (insn->type)
-      && (!float_type_p (srctype)
+  if (hsa_type_float_p (insn->type)
+      && (!hsa_type_float_p (srctype)
          || ((insn->type & BRIG_TYPE_BASE_MASK)
              < (srctype & BRIG_TYPE_BASE_MASK))))
     repr.round = BRIG_ROUND_FLOAT_NEAR_EVEN;
@@ -1469,7 +1453,7 @@  emit_basic_insn (hsa_insn_basic *insn)
 
   if ((type & BRIG_TYPE_PACK_MASK) != BRIG_TYPE_PACK_NONE)
     {
-      if (float_type_p (type))
+      if (hsa_type_float_p (type))
 	repr.round = BRIG_ROUND_FLOAT_NEAR_EVEN;
       else
 	repr.round = 0;
diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index e73b775..f5e7b0f 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -443,22 +443,6 @@  hsa_type_for_tree_type (const_tree type, unsigned HOST_WIDE_INT *dim_p)
   return hsa_type_for_scalar_tree_type (type, false);
 }
 
-/* Return true iff TYPE is a floating point number type.  */
-
-static bool
-hsa_type_float_p (BrigType16_t type)
-{
-  switch (type & BRIG_TYPE_BASE_MASK)
-    {
-    case BRIG_TYPE_F16:
-    case BRIG_TYPE_F32:
-    case BRIG_TYPE_F64:
-      return true;
-    default:
-      return false;
-    }
-}
-
 /* Returns true if converting from STYPE into DTYPE needs the _CVT
    opcode.  If false a normal _MOV is enough.  */
 
diff --git a/gcc/hsa.c b/gcc/hsa.c
index 04a0d7b..df41118 100644
--- a/gcc/hsa.c
+++ b/gcc/hsa.c
@@ -247,6 +247,22 @@  hsa_bittype_for_type (BrigType16_t t)
     }
 }
 
+/* Return true iff TYPE is a floating point number type.  */
+
+bool
+hsa_type_float_p (BrigType16_t type)
+{
+  switch (type & BRIG_TYPE_BASE_MASK)
+    {
+    case BRIG_TYPE_F16:
+    case BRIG_TYPE_F32:
+    case BRIG_TYPE_F64:
+      return true;
+    default:
+      return false;
+    }
+}
+
 /* Create a mapping between the original function DECL and kernel name NAME.  */
 
 void
diff --git a/gcc/hsa.h b/gcc/hsa.h
index c44d1d3..1239d6c 100644
--- a/gcc/hsa.h
+++ b/gcc/hsa.h
@@ -615,6 +615,7 @@  bool hsa_full_profile_p (void);
 bool hsa_opcode_op_output_p (BrigOpcode16_t, int);
 unsigned hsa_type_bit_size (BrigType16_t t);
 BrigType16_t hsa_bittype_for_type (BrigType16_t t);
+bool hsa_type_float_p (BrigType16_t type);
 void hsa_add_kern_decl_mapping (tree decl, char *name);
 unsigned hsa_get_number_decl_kernel_mappings (void);
 tree hsa_get_decl_kernel_mapping_decl (unsigned i);