/* rust-target.def -- Target hook definitions for the Rust front end.
   Copyright (C) 2020-2021 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 "Rust Target Hook"

HOOK_VECTOR (TARGETRUSTM_INITIALIZER, gcc_targetrustm)

#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"

/* Environmental CPU info and features (e.g. endianness, pointer size) relating to the target CPU.  */
DEFHOOK
(rust_cpu_info,
 "Declare all environmental CPU info and features relating to the target CPU\n\
using the function @code{rust_add_target_info}, which takes a string representing\n\
the feature key and a string representing the feature value.  Configuration pairs\n\
predefined by this hook apply to all files that are being compiled.",
 void, (void),
 hook_void_void)

// TODO: remove: format of DEFHOOK is return type, (param types), default value for function that it translates to

/* Environmental OS info relating to the target OS.  */
DEFHOOK
(/*d_os_versions*/rust_os_info,
 "Similar to @code{TARGET_RUST_CPU_INFO}, but is used for configuration info\n\
relating to the target operating system.",
 void, (void),
 hook_void_void)

/* The sizeof CRITICAL_SECTION or pthread_mutex_t.  */
/*DEFHOOK
(d_critsec_size,
 "Returns the size of the data structure used by the target operating system\n\
for critical sections and monitors.  For example, on Microsoft Windows this\n\
would return the @code{sizeof(CRITICAL_SECTION)}, while other platforms that\n\
implement pthreads would return @code{sizeof(pthread_mutex_t)}.",
 unsigned, (void),
 hook_uint_void_0)*/

 /* TODO: add more if required. Possible ones include static C runtime, target_env
  * or vendor (if not covered by OS), and flags from the driver that may or may not
  * require a target hook (might instead require a different type of hook) like 
  * test, debug_assertions, and proc_macro. */

 /* TODO: rustc target support by tier:
  *   Tier 1 (definitely work):
  *   -  i686-pc-windows-gnu
  *   -  i686-pc-windows-msvc
  *   -  i686-unknown-linux-gnu
  *   -  x86_64-apple-darwin
  *   -  x86_64-pc-windows-gnu
  *   -  x86_64-pc-windows-msvc
  *   -  x86_64-unknown-linux-gnu
  *   - Basically, 32-bit and 64-bit x86 for windows (MinGW and MSVC), gnu/linux, and osx
  *   Other tiers have too much crap, but basic breakdown is:
  *   Tier 2:
  *   -  archs: ARM64 (aarch64), ARMv7, ARMv6, asm.js, i586 (32-bit x86 without SSE), mips, 
  *      mips64, powerpc, powerpc64, risc-v, s390x, sparc, webasm, netbsd, redox (does gcc have support?),
  *      cloudabi (never head of it; i imagine no gcc support)
  *   -  oses: ios, fuchsia, android, windows (msvc and mingw), gnu/linux, freebsd, netbsd
  *   Tier 2.5:
  *   - powerpc SPE linux, various cloudabi stuff, sparc
  *   Tier 3:
  *   - more obscure stuff like UWP support, vxworks, openbsd, dragonflybsd, haiku, bitrig, windows xp,
  *     cuda, hexagon, and combinations of them and earlier stuff */

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