On 9/5/18 7:40 AM, Andrew Stubbs wrote:
> This part initially failed to send due to size.
> 
> This is the main portion of the GCN back-end, plus the configuration
> adjustments needed to build it.
> 
> The config.sub patch is here so people can try it, but I'm aware that
> needs to
> be committed elsewhere first.
> 
> The back-end contains various bits that support OpenACC and OpenMP, but the
> middle-end and libgomp patches are missing.  I included them here because
> they're harmless and carving up the files seems like unnecessary effort.
>  The
> remaining offload support will be posted at a later date.
> 
> The gcn-run.c is a separate tool that can run a GCN program on a GPU using
> the ROCm drivers and HSA runtime libraries.
> 
> 2018-09-05  Andrew Stubbs  <a...@codesourcery.com>
>> .......    Kwok Cheung Yeung  <k...@codesourcery.com>
>> .......    Julian Brown  <jul...@codesourcery.com>
>> .......    Tom de Vries  <t...@codesourcery.com>
>> .......    Jan Hubicka  <hubi...@ucw.cz>
>> .......    Martin Jambor  <mjam...@suse.cz>
> 
>> .......* config.sub: Recognize amdgcn*-*-amdhsa.
>> .......* configure.ac: Likewise.
>> .......* configure: Regenerate.
> 
>> .......gcc/
>> .......* common/config/gcn/gcn-common.c: New file.
>> .......* config.gcc: Add amdgcn*-*-amdhsa configuration.
>> .......* config/gcn/constraints.md: New file.
>> .......* config/gcn/driver-gcn.c: New file.
>> .......* config/gcn/gcn-builtins.def: New file.
>> .......* config/gcn/gcn-hsa.h: New file.
>> .......* config/gcn/gcn-modes.def: New file.
>> .......* config/gcn/gcn-opts.h: New file.
>> .......* config/gcn/gcn-passes.def: New file.
>> .......* config/gcn/gcn-protos.h: New file.
>> .......* config/gcn/gcn-run.c: New file.
>> .......* config/gcn/gcn-tree.c: New file.
>> .......* config/gcn/gcn-valu.md: New file.
>> .......* config/gcn/gcn.c: New file.
>> .......* config/gcn/gcn.h: New file.
>> .......* config/gcn/gcn.md: New file.
>> .......* config/gcn/gcn.opt: New file.
>> .......* config/gcn/mkoffload.c: New file.
>> .......* config/gcn/offload.h: New file.
>> .......* config/gcn/predicates.md: New file.
>> .......* config/gcn/t-gcn-hsa: New file.
> 
> 0021-gcn-port-pt1.patch
> 

> +amdgcn-*-amdhsa)
> +     tm_file="dbxelf.h elfos.h gcn/gcn-hsa.h gcn/gcn.h newlib-stdint.h"
Please consider killing dbxelf.h :-)  I assume your default debugging
format is dwarf2, but do you really need to support embedded stabs?



> +
> +/* FIXME: review debug info settings */
> +#define PREFERRED_DEBUGGING_TYPE   DWARF2_DEBUG
> +#define DWARF2_DEBUGGING_INFO      1
> +#define DWARF2_ASM_LINE_DEBUG_INFO 1
> +#define EH_FRAME_THROUGH_COLLECT2  1
These look reasonable.  Essentially you're doing dwarf2 by default.
Maybe just look at EH_FRAME_THROUGH_COLLECT2 more closely to make sure
it still makes sense and isn't a remnant of early port hackery to get
things stumbling along.


> diff --git a/gcc/config/gcn/gcn-run.c b/gcc/config/gcn/gcn-run.c
> new file mode 100644
> index 0000000..3dea343
> --- /dev/null
> +++ b/gcc/config/gcn/gcn-run.c
I'm going to assume this is largely correct.  It looks like all the glue
code to run kernels on the unit.  It loads the code to be run AFACIT, so
it doesn't need an exception clause as it's not linked against the code
that is to be run IIUC.



> diff --git a/gcc/config/gcn/gcn-tree.c b/gcc/config/gcn/gcn-tree.c
> new file mode 100644
> index 0000000..0365baf
> --- /dev/null
> +++ b/gcc/config/gcn/gcn-tree.c
> @@ -0,0 +1,715 @@
> +/* Copyright (C) 2017-2018 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/>.  */
> +
> +/* {{{ Includes.  */
> +
> +#include "config.h"
> +#include "system.h"
> +#include "coretypes.h"
> +#include "backend.h"
> +#include "target.h"
> +#include "tree.h"
> +#include "gimple.h"
> +#include "tree-pass.h"
> +#include "gimple-iterator.h"
> +#include "cfghooks.h"
> +#include "cfgloop.h"
> +#include "tm_p.h"
> +#include "stringpool.h"
> +#include "fold-const.h"
> +#include "varasm.h"
> +#include "omp-low.h"
> +#include "omp-general.h"
> +#include "internal-fn.h"
> +#include "tree-vrp.h"
> +#include "tree-ssanames.h"
> +#include "tree-ssa-operands.h"
> +#include "gimplify.h"
> +#include "tree-phinodes.h"
> +#include "cgraph.h"
> +#include "targhooks.h"
> +#include "langhooks-def.h"
> +
> +/* }}}  */
> +/* {{{ OMP GCN pass.  */
> +
> +unsigned int
> +execute_omp_gcn (void)
So some documentation about what this pass is supposed to be doing would
be helpful in the future if anyone needs to change it.



There's a ton of work related to reduction setup, updates and teardown.
 I don't guess there's any generic code we can/should be re-using.  Sigh.


> diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md
> new file mode 100644
> index 0000000..0531c4f
> --- /dev/null
> +++ b/gcc/config/gcn/gcn-valu.md
> +
> +    if (can_create_pseudo_p ())
> +      {
> +        rtx exec = gcn_full_exec_reg ();
> +     rtx undef = gcn_gen_undef (<MODE>mode);
Looks like tabs-vs-spaces problem in here.  It's a nit obviously.  Might
as well fix it now and go a global search and replace in the other gcn
files so they're right from day 1.

WRT your move patterns.  I'm a bit concerned about using distinct
matters for so many different variants.  But they mostly seem confined
to vector variants.  Be aware you may need to squash them into a single
pattern over time to keep LRA happy.

Nothing looks too bad here...

jeff


Reply via email to