/* d-target.def -- Target hook definitions for the D front end.
   Copyright (C) 2017-2022 Free Software Foundation, Inc.

   This program 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.

   This program 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 this program; see the file COPYING3.  If not see
   <http://www.gnu.org/licenses/>.  */

/* See target-hooks-macros.h for details of macros that should be
   provided by the including file, and how to use them here.  */

#include "target-hooks-macros.h"

#undef HOOK_TYPE
#define HOOK_TYPE "D Target Hook"

HOOK_VECTOR (TARGETDM_INITIALIZER, gcc_targetdm)

#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"

/* Environmental version identifiers relating to the target CPU.  */
DEFHOOK
(d_cpu_versions,
 "Declare all environmental version identifiers relating to the target CPU\n\
using the function @code{builtin_version}, which takes a string representing\n\
the name of the version.  Version identifiers predefined by this hook apply\n\
to all modules that are being compiled and imported.",
 void, (void),
 hook_void_void)

/* Environmental version identifiers relating to the target OS.  */
DEFHOOK
(d_os_versions,
 "Similarly to @code{TARGET_D_CPU_VERSIONS}, but is used for versions\n\
relating to the target operating system.",
 void, (void),
 hook_void_void)

/* getTargetInfo keys relating to the target CPU.  */
DEFHOOK
(d_register_cpu_target_info,
 "Register all target information keys relating to the target CPU using the\n\
function @code{d_add_target_info_handlers}, which takes a\n\
@samp{struct d_target_info_spec} (defined in @file{d/d-target.h}).  The keys\n\
added by this hook are made available at compile time by the\n\
@code{__traits(getTargetInfo)} extension, the result is an expression\n\
describing the requested target information.",
 void, (void),
 hook_void_void)

/* getTargetInfo keys relating to the target OS.  */
DEFHOOK
(d_register_os_target_info,
 "Same as @code{TARGET_D_CPU_TARGET_INFO}, but is used for keys relating to\n\
the target operating system.",
 void, (void),
 hook_void_void)

/* ModuleInfo section name and brackets.  */
DEFHOOKPOD
(d_minfo_section,
 "Contains the name of the section in which module info references should be\n\
placed.  By default, the compiler puts all module info symbols in the\n\
@code{\"minfo\"} section.  Define this macro to override the string if a\n\
different section name should be used.  This section is expected to be\n\
bracketed by two symbols @code{TARGET_D_MINFO_SECTION_START} and \n\
@code{TARGET_D_MINFO_SECTION_END} to indicate the start and end address of\n\
the section, so that the runtime library can collect all modules for each\n\
loaded shared library and executable.  Setting the value to @code{NULL}\n\
disables the use of sections for storing module info altogether.",
 const char *, "minfo")

DEFHOOKPOD
(d_minfo_section_start,
 "If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined\n\
as the name of the symbol indicating the start address of the module info\n\
section",
 const char *, "__start_minfo")

DEFHOOKPOD
(d_minfo_section_end,
 "If @code{TARGET_D_MINFO_SECTION} is defined, then this must also be defined\n\
as the name of the symbol indicating the end address of the module info\n\
section",
 const char *, "__stop_minfo")

/* The "stdcall" convention is really supported on 32-bit x86/Windows only.
   The following hook is a helper to determine whether to apply the attribute
   on declarations with `extern(System)' and `extern(Windows)' linkage.  */
DEFHOOK
(d_has_stdcall_convention,
 "Returns @code{true} if the target supports the stdcall calling convention.\n\
The hook should also set @var{link_system} to @code{1} if the @code{stdcall}\n\
attribute should be applied to functions with @code{extern(System)} linkage,\n\
and @var{link_windows} to @code{1} to apply @code{stdcall} to functions with\n\
@code{extern(Windows)} linkage.",
 bool, (unsigned int *link_system, unsigned int *link_windows),
 hook_bool_uintp_uintp_false)

/* True if instantiations are always COMDAT if they have external linkage.  */
DEFHOOKPOD
(d_templates_always_comdat,
 "This flag is true if instantiated functions and variables are always COMDAT\n\
if they have external linkage.  If this flag is false, then instantiated\n\
decls will be emitted as weak symbols.  The default is @code{false}.",
 bool, false)

/* Close the 'struct gcc_targetdm' definition.  */
HOOK_VECTOR_END (C90_EMPTY_HACK)
