@@ -1,5 +1,12 @@
2015-08-25 Martin Jambor <mjambor@suse.cz>
+ * hsa.h (hsa_callable_function_p): Declare.
+ * hsa.c (hsa_callable_function_p): New function.
+ * hsa-gen.c (gen_hsa_insns_for_call): Use it.
+ (pass_gen_hsail::execute): Likewise.
+
+2015-08-25 Martin Jambor <mjambor@suse.cz>
+
* hsa-gen.c (gen_hsa_unaryop_for_builtin): New function.
2015-08-25 Martin Jambor <mjambor@suse.cz>
@@ -3255,7 +3255,7 @@ gen_hsa_insns_for_call (gimple stmt, hsa_bb *hbb,
return;
}
- if (lookup_attribute ("hsafunc", DECL_ATTRIBUTES (function_decl)))
+ if (hsa_callable_function_p (function_decl))
gen_hsa_insns_for_direct_call (stmt, hbb, ssa_map);
else if (!gen_hsa_insns_for_known_library_call (stmt, hbb, ssa_map))
sorry ("HSA does support only call for functions with 'hsafunc' "
@@ -4102,8 +4102,7 @@ pass_gen_hsail::execute (function *)
|| lookup_attribute ("hsakernel",
DECL_ATTRIBUTES (current_function_decl)))
return generate_hsa (true);
- else if (lookup_attribute ("hsafunc",
- DECL_ATTRIBUTES (current_function_decl)))
+ else if (hsa_callable_function_p (current_function_decl))
return generate_hsa (false);
else
return wrap_all_hsa_calls ();
@@ -103,6 +103,15 @@ hash_table <hsa_free_symbol_hasher> *hsa_global_variable_symbols;
/* True if compilation unit-wide data are already allocated and initialized. */
static bool compilation_unit_data_initialized;
+/* Return true if FNDECL represents an HSA-callable function. */
+
+bool
+hsa_callable_function_p (tree fndecl)
+{
+ return lookup_attribute ("hsafunc", DECL_ATTRIBUTES (fndecl))
+ || lookup_attribute ("omp declare target", DECL_ATTRIBUTES (fndecl));
+}
+
/* Allocate HSA structures that are are used when dealing with different
functions. */
@@ -898,6 +898,7 @@ extern struct hsa_function_representation *hsa_cfun;
extern hash_table <hsa_free_symbol_hasher> *hsa_global_variable_symbols;
extern hash_map <tree, vec <char *> *> *hsa_decl_kernel_dependencies;
extern unsigned hsa_kernel_calls_counter;
+bool hsa_callable_function_p (tree fndecl);
void hsa_init_compilation_unit_data (void);
void hsa_deinit_compilation_unit_data (void);
bool hsa_machine_large_p (void);