This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[HSA] Add new gate predicate
- From: Martin LiÅka <mliska at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 23 Sep 2015 11:18:11 +0200
- Subject: [HSA] Add new gate predicate
- Authentication-results: sourceware.org; auth=none
Hello.
Following patch does a small refactoring of HSA tree generation pass.
Martin
>From a887efce8fc6aa136a2a069ea5ddda10b4e28de6 Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Tue, 22 Sep 2015 18:58:12 +0200
Subject: [PATCH] HSA: add new gate predicate
gcc/ChangeLog:
2015-09-22 Martin Liska <mliska@suse.cz>
* hsa.h (hsa_gpu_implementation_p): New predicate.
* hsa-gen.c (pass_gen_hsail::gate): Use it.
(pass_gen_hsail::execute): Do not simulate gate predicate.
---
gcc/hsa-gen.c | 18 +++++++-----------
gcc/hsa.h | 13 +++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index 3a7ce5d..34cbe42 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -4492,9 +4492,10 @@ public:
/* Determine whether or not to run generation of HSAIL. */
bool
-pass_gen_hsail::gate (function *)
+pass_gen_hsail::gate (function *f)
{
- return hsa_gen_requested_p ();
+ return hsa_gen_requested_p ()
+ && hsa_gpu_implementation_p (f->decl);
}
unsigned int
@@ -4503,15 +4504,10 @@ pass_gen_hsail::execute (function *)
hsa_function_summary *s = hsa_summaries->get
(cgraph_node::get_create (current_function_decl));
- if (s->gpu_implementation_p)
- {
- convert_switch_statements ();
- generate_hsa (s->kind == HSA_KERNEL);
- TREE_ASM_WRITTEN (current_function_decl) = 1;
- return TODO_stop_pass_execution;
- }
-
- return 0;
+ convert_switch_statements ();
+ generate_hsa (s->kind == HSA_KERNEL);
+ TREE_ASM_WRITTEN (current_function_decl) = 1;
+ return TODO_stop_pass_execution;
}
} // anon namespace
diff --git a/gcc/hsa.h b/gcc/hsa.h
index 6164b86..16fe310 100644
--- a/gcc/hsa.h
+++ b/gcc/hsa.h
@@ -1042,4 +1042,17 @@ union hsa_bytes
uint64_t b64;
};
+/* Return true if a function DECL is an HSA implementation. */
+
+static inline bool
+hsa_gpu_implementation_p (tree decl)
+{
+ if (hsa_summaries == NULL)
+ return false;
+
+ hsa_function_summary *s = hsa_summaries->get (cgraph_node::get_create (decl));
+
+ return s->gpu_implementation_p;
+}
+
#endif /* HSA_H */
--
2.5.1