extern void c_omp_declare_simd_clauses_to_decls (tree, tree);
extern bool c_omp_predefined_variable (tree);
extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree);
+extern enum omp_clause_defaultmap_kind c_omp_predetermined_mapping (tree);
extern tree c_omp_check_context_selector (location_t, tree);
extern void c_omp_mark_declare_variant (location_t, tree, tree);
extern const char *c_omp_map_clause_name (tree, bool);
return false;
}
-/* True if OpenMP sharing attribute of DECL is predetermined. */
+/* OMP_CLAUSE_DEFAULT_UNSPECIFIED unless OpenMP sharing attribute of DECL
+ is predetermined. */
enum omp_clause_default_kind
c_omp_predetermined_sharing (tree decl)
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+/* OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED unless OpenMP mapping attribute
+ of DECL is predetermined. */
+
+enum omp_clause_defaultmap_kind
+c_omp_predetermined_mapping (tree decl)
+{
+ /* Predetermine artificial variables holding integral values, those
+ are usually result of gimplify_one_sizepos or SAVE_EXPR
+ gimplification. */
+ if (VAR_P (decl)
+ && DECL_ARTIFICIAL (decl)
+ && INTEGRAL_TYPE_P (TREE_TYPE (decl)))
+ return OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE;
+
+ if (c_omp_predefined_variable (decl))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+
+ return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
+}
+
+
/* Diagnose errors in an OpenMP context selector, return CTX if
it is correct or error_mark_node otherwise. */
#undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING c_omp_predetermined_sharing
+#undef LANG_HOOKS_OMP_PREDETERMINED_MAPPING
+#define LANG_HOOKS_OMP_PREDETERMINED_MAPPING c_omp_predetermined_mapping
+
#undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR
#define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR c_omp_clause_copy_ctor
return false;
}
-/* True if OpenMP sharing attribute of DECL is predetermined. */
+/* OMP_CLAUSE_DEFAULT_UNSPECIFIED unless OpenMP sharing attribute
+ of DECL is predetermined. */
enum omp_clause_default_kind
cxx_omp_predetermined_sharing_1 (tree decl)
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+enum omp_clause_defaultmap_kind
+cxx_omp_predetermined_mapping (tree decl)
+{
+ /* Predetermine artificial variables holding integral values, those
+ are usually result of gimplify_one_sizepos or SAVE_EXPR
+ gimplification. */
+ if (VAR_P (decl)
+ && DECL_ARTIFICIAL (decl)
+ && INTEGRAL_TYPE_P (TREE_TYPE (decl))
+ && !(DECL_LANG_SPECIFIC (decl)
+ && DECL_OMP_PRIVATIZED_MEMBER (decl)))
+ return OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE;
+
+ if (c_omp_predefined_variable (decl))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+
+ return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
+}
+
/* Finalize an implicitly determined clause. */
void
#undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING cxx_omp_predetermined_sharing
+#undef LANG_HOOKS_OMP_PREDETERMINED_MAPPING
+#define LANG_HOOKS_OMP_PREDETERMINED_MAPPING cxx_omp_predetermined_mapping
#undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR
#define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR cxx_omp_clause_default_ctor
#undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR
extern bool cxx_omp_const_qual_no_mutable (tree);
extern enum omp_clause_default_kind cxx_omp_predetermined_sharing_1 (tree);
extern enum omp_clause_default_kind cxx_omp_predetermined_sharing (tree);
+extern enum omp_clause_defaultmap_kind cxx_omp_predetermined_mapping (tree);
extern tree cxx_omp_clause_default_ctor (tree, tree, tree);
extern tree cxx_omp_clause_copy_ctor (tree, tree, tree);
extern tree cxx_omp_clause_assign_op (tree, tree, tree);
#undef LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT
#undef LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE
#undef LANG_HOOKS_OMP_PREDETERMINED_SHARING
+#undef LANG_HOOKS_OMP_PREDETERMINED_MAPPING
#undef LANG_HOOKS_OMP_REPORT_DECL
#undef LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR
#undef LANG_HOOKS_OMP_CLAUSE_COPY_CTOR
#define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT gfc_omp_check_optional_argument
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE gfc_omp_privatize_by_reference
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING gfc_omp_predetermined_sharing
+#define LANG_HOOKS_OMP_PREDETERMINED_MAPPING gfc_omp_predetermined_mapping
#define LANG_HOOKS_OMP_REPORT_DECL gfc_omp_report_decl
#define LANG_HOOKS_OMP_CLAUSE_DEFAULT_CTOR gfc_omp_clause_default_ctor
#define LANG_HOOKS_OMP_CLAUSE_COPY_CTOR gfc_omp_clause_copy_ctor
return false;
}
-/* True if OpenMP sharing attribute of DECL is predetermined. */
+/* OMP_CLAUSE_DEFAULT_UNSPECIFIED unless OpenMP sharing attribute
+ of DECL is predetermined. */
enum omp_clause_default_kind
gfc_omp_predetermined_sharing (tree decl)
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+
+/* OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED unless OpenMP mapping attribute
+ of DECL is predetermined. */
+
+enum omp_clause_defaultmap_kind
+gfc_omp_predetermined_mapping (tree decl)
+{
+ if (DECL_ARTIFICIAL (decl)
+ && ! GFC_DECL_RESULT (decl)
+ && ! (DECL_LANG_SPECIFIC (decl)
+ && GFC_DECL_SAVED_DESCRIPTOR (decl)))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+
+ /* These are either array or derived parameters, or vtables. */
+ if (VAR_P (decl) && TREE_READONLY (decl)
+ && (TREE_STATIC (decl) || DECL_EXTERNAL (decl)))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+
+ return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
+}
+
+
/* Return decl that should be used when reporting DEFAULT(NONE)
diagnostics. */
tree gfc_omp_array_data (tree, bool);
bool gfc_omp_privatize_by_reference (const_tree);
enum omp_clause_default_kind gfc_omp_predetermined_sharing (tree);
+enum omp_clause_defaultmap_kind gfc_omp_predetermined_mapping (tree);
tree gfc_omp_report_decl (tree);
tree gfc_omp_clause_default_ctor (tree, tree, tree);
tree gfc_omp_clause_copy_ctor (tree, tree, tree);
if (!is_declare_target)
{
int gdmk;
+ enum omp_clause_defaultmap_kind kind;
if (TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
|| (TREE_CODE (TREE_TYPE (decl)) == REFERENCE_TYPE
&& (TREE_CODE (TREE_TYPE (TREE_TYPE (decl)))
gdmk = GDMK_SCALAR;
else
gdmk = GDMK_AGGREGATE;
- if (ctx->defaultmap[gdmk] == 0)
+ kind = lang_hooks.decls.omp_predetermined_mapping (decl);
+ if (kind != OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED)
+ {
+ if (kind == OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE)
+ nflags |= GOVD_FIRSTPRIVATE;
+ else if (kind == OMP_CLAUSE_DEFAULTMAP_TO)
+ nflags |= GOVD_MAP | GOVD_MAP_TO_ONLY;
+ else
+ gcc_unreachable ();
+ }
+ else if (ctx->defaultmap[gdmk] == 0)
{
tree d = lang_hooks.decls.omp_report_decl (decl);
error ("%qE not specified in enclosing %<target%>",
/* Declarations for tree gimplification hooks. */
extern int lhd_gimplify_expr (tree *, gimple_seq *, gimple_seq *);
extern enum omp_clause_default_kind lhd_omp_predetermined_sharing (tree);
+extern enum omp_clause_defaultmap_kind lhd_omp_predetermined_mapping (tree);
extern tree lhd_omp_assignment (tree, tree, tree);
extern void lhd_omp_finish_clause (tree, gimple_seq *);
struct gimplify_omp_ctx;
#define LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT hook_tree_tree_bool_null
#define LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE hook_bool_const_tree_false
#define LANG_HOOKS_OMP_PREDETERMINED_SHARING lhd_omp_predetermined_sharing
+#define LANG_HOOKS_OMP_PREDETERMINED_MAPPING lhd_omp_predetermined_mapping
#define LANG_HOOKS_OMP_REPORT_DECL lhd_pass_through_t
#define LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR hook_bool_tree_bool_false
#define LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE hook_bool_tree_bool_false
LANG_HOOKS_OMP_CHECK_OPTIONAL_ARGUMENT, \
LANG_HOOKS_OMP_PRIVATIZE_BY_REFERENCE, \
LANG_HOOKS_OMP_PREDETERMINED_SHARING, \
+ LANG_HOOKS_OMP_PREDETERMINED_MAPPING, \
LANG_HOOKS_OMP_REPORT_DECL, \
LANG_HOOKS_OMP_DISREGARD_VALUE_EXPR, \
LANG_HOOKS_OMP_PRIVATE_DEBUG_CLAUSE, \
predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */
enum omp_clause_default_kind
-lhd_omp_predetermined_sharing (tree decl ATTRIBUTE_UNUSED)
+lhd_omp_predetermined_sharing (tree decl)
{
if (DECL_ARTIFICIAL (decl))
return OMP_CLAUSE_DEFAULT_SHARED;
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+/* Return sharing kind if OpenMP mapping attribute of DECL is
+ predetermined, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED otherwise. */
+
+enum omp_clause_defaultmap_kind
+lhd_omp_predetermined_mapping (tree decl)
+{
+ if (DECL_ARTIFICIAL (decl))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+ return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
+}
+
/* Generate code to copy SRC to DST. */
tree
predetermined, OMP_CLAUSE_DEFAULT_UNSPECIFIED otherwise. */
enum omp_clause_default_kind (*omp_predetermined_sharing) (tree);
+ /* Return mapping kind if OpenMP mapping attribute of DECL is
+ predetermined, OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED otherwise. */
+ enum omp_clause_defaultmap_kind (*omp_predetermined_mapping) (tree);
+
/* Return decl that should be reported for DEFAULT(NONE) failure
diagnostics. Usually the DECL passed in. */
tree (*omp_report_decl) (tree);
--- /dev/null
+/* { dg-do compile } */
+/* { dg-additional-options "-fdump-tree-gimple" } */
+
+#include <stddef.h>
+
+size_t
+vla (int array_li)
+{
+ float array[array_li];
+ size_t size1, size2;
+
+#pragma omp parallel default(none) shared(size1, array)
+ size1 = sizeof array;
+
+#pragma omp target defaultmap(none) map(from:size2) map(alloc:array)
+ size2 = sizeof array;
+
+ return size1 + size2;
+}
+
+/* { dg-final { scan-tree-dump "omp parallel .*shared\\(array_li\.\[0-9\]\\)" "gimple" } } */
+/* C */
+/* { dg-final { scan-tree-dump "omp target .*private\\(array_li\.\[0-9\]\\)" "gimple" { target { ! c++ } } } } */
+/* C++ */
+/* { dg-final { scan-tree-dump "omp target .*firstprivate\\(array_li\.\[0-9\]\\)" "gimple" { target { c++ } } } } */