+++ /dev/null
-/* Copyright (C) 2017-2020 Free Software Foundation, Inc.
-
- This file is part of GCC.
-
- GCC is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3, or (at your option) any later
- version.
-
- GCC is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with GCC; see the file COPYING3. If not see
- <http://www.gnu.org/licenses/>. */
-
-INSERT_PASS_AFTER (pass_omp_target_link, 1, pass_omp_gcn);
#include "targhooks.h"
#include "langhooks-def.h"
-/* }}} */
-/* {{{ OMP GCN pass.
-
- This pass is intended to make any GCN-specfic transformations to OpenMP
- target regions.
-
- At present, its only purpose is to convert some "omp" built-in functions
- to use closer-to-the-metal "gcn" built-in functions. */
-
-unsigned int
-execute_omp_gcn (void)
-{
- tree thr_num_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_THREAD_NUM);
- tree thr_num_id = DECL_NAME (thr_num_tree);
- tree team_num_tree = builtin_decl_explicit (BUILT_IN_OMP_GET_TEAM_NUM);
- tree team_num_id = DECL_NAME (team_num_tree);
- basic_block bb;
- gimple_stmt_iterator gsi;
- unsigned int todo = 0;
-
- FOR_EACH_BB_FN (bb, cfun)
- for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
- {
- gimple *call = gsi_stmt (gsi);
- tree decl;
-
- if (is_gimple_call (call) && (decl = gimple_call_fndecl (call)))
- {
- tree decl_id = DECL_NAME (decl);
- tree lhs = gimple_get_lhs (call);
-
- if (decl_id == thr_num_id)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "Replace '%s' with __builtin_gcn_dim_pos.\n",
- IDENTIFIER_POINTER (decl_id));
-
- /* Transform this:
- lhs = __builtin_omp_get_thread_num ()
- to this:
- lhs = __builtin_gcn_dim_pos (1) */
- tree fn = targetm.builtin_decl (GCN_BUILTIN_OMP_DIM_POS, 0);
- tree fnarg = build_int_cst (unsigned_type_node, 1);
- gimple *stmt = gimple_build_call (fn, 1, fnarg);
- gimple_call_set_lhs (stmt, lhs);
- gsi_replace (&gsi, stmt, true);
-
- todo |= TODO_update_ssa;
- }
- else if (decl_id == team_num_id)
- {
- if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf (dump_file,
- "Replace '%s' with __builtin_gcn_dim_pos.\n",
- IDENTIFIER_POINTER (decl_id));
-
- /* Transform this:
- lhs = __builtin_omp_get_team_num ()
- to this:
- lhs = __builtin_gcn_dim_pos (0) */
- tree fn = targetm.builtin_decl (GCN_BUILTIN_OMP_DIM_POS, 0);
- tree fnarg = build_zero_cst (unsigned_type_node);
- gimple *stmt = gimple_build_call (fn, 1, fnarg);
- gimple_call_set_lhs (stmt, lhs);
- gsi_replace (&gsi, stmt, true);
-
- todo |= TODO_update_ssa;
- }
- }
- }
-
- return todo;
-}
-
-namespace
-{
-
- const pass_data pass_data_omp_gcn = {
- GIMPLE_PASS,
- "omp_gcn", /* name */
- OPTGROUP_NONE, /* optinfo_flags */
- TV_NONE, /* tv_id */
- 0, /* properties_required */
- 0, /* properties_provided */
- 0, /* properties_destroyed */
- 0, /* todo_flags_start */
- TODO_df_finish, /* todo_flags_finish */
- };
-
- class pass_omp_gcn : public gimple_opt_pass
- {
- public:
- pass_omp_gcn (gcc::context *ctxt)
- : gimple_opt_pass (pass_data_omp_gcn, ctxt)
- {
- }
-
- /* opt_pass methods: */
- virtual bool gate (function *)
- {
- return flag_openmp;
- }
-
- virtual unsigned int execute (function *)
- {
- return execute_omp_gcn ();
- }
-
- }; /* class pass_omp_gcn. */
-
-} /* anon namespace. */
-
-gimple_opt_pass *
-make_pass_omp_gcn (gcc::context *ctxt)
-{
- return new pass_omp_gcn (ctxt);
-}
-
/* }}} */
/* {{{ OpenACC reductions. */