diff mbox

[gomp4,2/3] OpenACC data construct implementation in terms of GF_OMP_TARGET_KIND_OACC_DATA.

Message ID 878usffs29.fsf@kepler.schwinge.homeip.net
State New
Headers show

Commit Message

Thomas Schwinge March 12, 2014, 1:46 p.m. UTC
Hi!

On Fri, 21 Feb 2014 21:32:14 +0100, I wrote:
> --- gcc/omp-low.c
> +++ gcc/omp-low.c
> @@ -1499,6 +1499,30 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
>  {
>    tree c, decl;
>    bool scan_array_reductions = false;
> +  bool offloaded;
> +  switch (gimple_code (ctx->stmt))
> +    {
> +    case GIMPLE_OACC_PARALLEL:
> +      offloaded = true;
> +      break;
> +    case GIMPLE_OMP_TARGET:
> +      switch (gimple_omp_target_kind (ctx->stmt))
> +	{
> +	case GF_OMP_TARGET_KIND_REGION:
> +	  offloaded = true;
> +	  break;
> +	case GF_OMP_TARGET_KIND_DATA:
> +	case GF_OMP_TARGET_KIND_UPDATE:
> +	case GF_OMP_TARGET_KIND_OACC_DATA:
> +	  offloaded = false;
> +	  break;
> +	default:
> +	  gcc_unreachable ();
> +	}
> +      break;
> +    default:
> +      offloaded = false;
> +    }

I now have a need for this information elsewhere; in gomp-4_0-branch
r208513 changed as follows:

commit 326592ef8fe7501f9ba7e67157d68c6c541e5601
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Mar 12 13:40:07 2014 +0000

    is_gimple_omp_offloaded.
    
    	gcc/
    	* omp-low.c (scan_sharing_clauses): Move offloaded logic into...
    	* gimple.h (is_gimple_omp_offloaded): ... this new static inline
    	function.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@208513 138bc75d-0d04-0410-961f-82ee72b054a4



Grüße,
 Thomas
diff mbox

Patch

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 79030d6..4ee843f 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,9 @@ 
+2014-03-12  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* omp-low.c (scan_sharing_clauses): Move offloaded logic into...
+	* gimple.h (is_gimple_omp_offloaded): ... this new static inline
+	function.
+
 2014-02-28  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* gimple.def (GIMPLE_OACC_KERNELS): New code.
diff --git gcc/gimple.h gcc/gimple.h
index 514af32..910072d 100644
--- gcc/gimple.h
+++ gcc/gimple.h
@@ -5823,6 +5823,31 @@  is_gimple_omp_oacc_specifically (const_gimple stmt)
 }
 
 
+/* Return true if OMP_* STMT is offloaded.  */
+
+static inline bool
+is_gimple_omp_offloaded (const_gimple stmt)
+{
+  gcc_assert (is_gimple_omp (stmt));
+  switch (gimple_code (stmt))
+    {
+    case GIMPLE_OACC_KERNELS:
+    case GIMPLE_OACC_PARALLEL:
+      return true;
+    case GIMPLE_OMP_TARGET:
+      switch (gimple_omp_target_kind (stmt))
+	{
+	case GF_OMP_TARGET_KIND_REGION:
+	  return true;
+	default:
+	  return false;
+	}
+    default:
+      return false;
+    }
+}
+
+
 /* Returns TRUE if statement G is a GIMPLE_NOP.  */
 
 static inline bool
diff --git gcc/omp-low.c gcc/omp-low.c
index 2f13fb4..6b676e5 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -1499,31 +1499,6 @@  scan_sharing_clauses (tree clauses, omp_context *ctx)
 {
   tree c, decl;
   bool scan_array_reductions = false;
-  bool offloaded;
-  switch (gimple_code (ctx->stmt))
-    {
-    case GIMPLE_OACC_KERNELS:
-    case GIMPLE_OACC_PARALLEL:
-      offloaded = true;
-      break;
-    case GIMPLE_OMP_TARGET:
-      switch (gimple_omp_target_kind (ctx->stmt))
-	{
-	case GF_OMP_TARGET_KIND_REGION:
-	  offloaded = true;
-	  break;
-	case GF_OMP_TARGET_KIND_DATA:
-	case GF_OMP_TARGET_KIND_UPDATE:
-	case GF_OMP_TARGET_KIND_OACC_DATA:
-	  offloaded = false;
-	  break;
-	default:
-	  gcc_unreachable ();
-	}
-      break;
-    default:
-      offloaded = false;
-    }
 
   for (c = clauses; c; c = OMP_CLAUSE_CHAIN (c))
     {
@@ -1696,7 +1671,8 @@  scan_sharing_clauses (tree clauses, omp_context *ctx)
 	      /* Ignore OMP_CLAUSE_MAP_POINTER kind for arrays in
 		 target regions that are not offloaded; there is nothing to map for
 		 those.  */
-	      if (!offloaded && !POINTER_TYPE_P (TREE_TYPE (decl)))
+	      if (!is_gimple_omp_offloaded (ctx->stmt)
+		  && !POINTER_TYPE_P (TREE_TYPE (decl)))
 		break;
 	    }
 	  if (DECL_P (decl))
@@ -1721,7 +1697,7 @@  scan_sharing_clauses (tree clauses, omp_context *ctx)
 		    install_var_field (decl, true, 7, ctx);
 		  else
 		    install_var_field (decl, true, 3, ctx);
-		  if (offloaded)
+		  if (is_gimple_omp_offloaded (ctx->stmt))
 		    install_var_local (decl, ctx);
 		}
 	    }
@@ -1845,7 +1821,7 @@  scan_sharing_clauses (tree clauses, omp_context *ctx)
 	  gcc_assert (gimple_code (ctx->stmt) != GIMPLE_OMP_TARGET
 		      || (gimple_omp_target_kind (ctx->stmt)
 			  != GF_OMP_TARGET_KIND_UPDATE));
-	  if (!offloaded)
+	  if (!is_gimple_omp_offloaded (ctx->stmt))
 	    break;
 	  decl = OMP_CLAUSE_DECL (c);
 	  if (DECL_P (decl)