1/* brig-module-handler.cc -- brig module directive handling
2   Copyright (C) 2016-2020 Free Software Foundation, Inc.
3   Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4   for General Processor Tech.
5
6   This file is part of GCC.
7
8   GCC is free software; you can redistribute it and/or modify it under
9   the terms of the GNU General Public License as published by the Free
10   Software Foundation; either version 3, or (at your option) any later
11   version.
12
13   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14   WARRANTY; without even the implied warranty of MERCHANTABILITY or
15   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16   for more details.
17
18   You should have received a copy of the GNU General Public License
19   along with GCC; see the file COPYING3.  If not see
20   <http://www.gnu.org/licenses/>.  */
21
22#include "brig-code-entry-handler.h"
23#include "diagnostic-core.h"
24
25size_t
26brig_directive_module_handler::operator () (const BrigBase *base)
27{
28  const BrigDirectiveModule* mod = (const BrigDirectiveModule*)base;
29  m_parent.m_module_name = m_parent.get_string (mod->name).substr (1);
30  if (mod->hsailMajor != 1 || mod->hsailMinor != 0)
31    fatal_error (UNKNOWN_LOCATION, PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE
32		 "HSAIL version not supported. HSAIL 1.0 required.");
33  if (mod->machineModel != BRIG_MACHINE_LARGE)
34    fatal_error (UNKNOWN_LOCATION, PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE
35		 "Only HSA 'large' machine model supported.");
36  /* Do not check for the profile as the runtime conformance suite tests
37     with 'full' profile BRIGs even though they don't use any full profile
38     features.  This allows us to run the conformance suite with the
39     BRIG FE.  */
40  return base->byteCount;
41}
42