This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[hsa-branch 1/5] Allow putting local variables into group and global segments


Hi,

the following patch adds the capability to put local HSA variables
into the group or global segment as indicated by new declaration
attributes.  In the process I had to fix how we differentiate between
local and global attributes because context and allocation properties
now can diverge.

This patch does not do the things necessary to expose the attributes
to the user.  I wonder whether it even makes sense for OpenMP uses.  I
will do so when we provide the users with a more direct way of
generating HSAIL.

I will commit the patch to the HSA branch in a few moments.  The
ultimate goal is trunk but I'd like to keep it there for a number of
weeks.

Martin

2016-06-02  Martin Jambor  <mjambor@suse.cz>

	* hsa-gen.c (get_symbol_for_decl): Fix dinstinguishing between
	global and local functions.  Put local variables into a segment
	according to their attribute or static flag, if there is one.
---
 gcc/hsa-gen.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c
index c08f4a8..2ead76a 100644
--- a/gcc/hsa-gen.c
+++ b/gcc/hsa-gen.c
@@ -794,8 +794,8 @@ get_symbol_for_decl (tree decl)
 
   dummy.m_decl = decl;
 
-  bool is_in_global_vars
-    = TREE_CODE (decl) == VAR_DECL && is_global_var (decl);
+  bool is_in_global_vars = ((TREE_CODE (decl) == VAR_DECL)
+			    && !decl_function_context (decl));
 
   if (is_in_global_vars)
     slot = hsa_global_variable_symbols->find_slot (&dummy, INSERT);
@@ -861,8 +861,17 @@ get_symbol_for_decl (tree decl)
 	  /* PARM_DECL and RESULT_DECL should be already in m_local_symbols.  */
 	  gcc_assert (TREE_CODE (decl) == VAR_DECL);
 
-	  sym = new hsa_symbol (BRIG_TYPE_NONE, BRIG_SEGMENT_PRIVATE,
-				BRIG_LINKAGE_FUNCTION);
+	  BrigSegment8_t segment;
+	  if (lookup_attribute ("hsa_group_segment", DECL_ATTRIBUTES (decl)))
+	    segment = BRIG_SEGMENT_GROUP;
+	  else if (TREE_STATIC (decl)
+		   || lookup_attribute ("hsa_global_segment",
+					DECL_ATTRIBUTES (decl)))
+	    segment = BRIG_SEGMENT_GLOBAL;
+	  else
+	    segment = BRIG_SEGMENT_PRIVATE;
+
+	  sym = new hsa_symbol (BRIG_TYPE_NONE, segment, BRIG_LINKAGE_FUNCTION);
 	  sym->m_align = align;
 	  sym->fillup_for_decl (decl);
 	  hsa_cfun->m_private_variables.safe_push (sym);
-- 
2.8.2


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]