/* Target hook definitions for C-family front ends.
   Copyright (C) 2001-2023 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 "C Target Hook"

HOOK_VECTOR (TARGETCM_INITIALIZER, gcc_targetcm)

#undef HOOK_PREFIX
#define HOOK_PREFIX "TARGET_"

/* Handle target switch CODE (an OPT_* value).  ARG is the argument
   passed to the switch; it is NULL if no argument was.  VALUE is the
   value of ARG if CODE specifies a UInteger option, otherwise it is
   1 if the positive form of the switch was used and 0 if the negative
   form was.  Return true if the switch was valid.  */
DEFHOOK
(handle_c_option,
 "",
 bool, (size_t code, const char *arg, int value),
 default_handle_c_option)

/* Targets may provide a string object type that can be used within
   and between C, C++, and Objective-C dialects.  */

DEFHOOK
(objc_construct_string_object,
 "Targets may provide a string object type that can be used within\n\
and between C, C++ and their respective Objective-C dialects.\n\
A string object might, for example, embed encoding and length information.\n\
These objects are considered opaque to the compiler and handled as references.\n\
An ideal implementation makes the composition of the string object\n\
match that of the Objective-C @code{NSString} (@code{NXString} for GNUStep),\n\
allowing efficient interworking between C-only and Objective-C code.\n\
If a target implements string objects then this hook should return a\n\
reference to such an object constructed from the normal `C' string\n\
representation provided in @var{string}.\n\
At present, the hook is used by Objective-C only, to obtain a\n\
 common-format string object when the target provides one.",
 tree, (tree string),
 NULL)

DEFHOOK
(objc_declare_unresolved_class_reference,
 "Declare that Objective C class @var{classname} is referenced\n\
by the current TU.",
 void, (const char *classname),
 NULL)

DEFHOOK
(objc_declare_class_definition,
 "Declare that Objective C class @var{classname} is defined\n\
by the current TU.",
 void, (const char *classname),
 NULL)

DEFHOOK
(string_object_ref_type_p,
 "If a target implements string objects then this hook should return\n\
@code{true} if @var{stringref} is a valid reference to such an object.",
 bool, (const_tree stringref),
 hook_bool_const_tree_false)

DEFHOOK
(check_string_object_format_arg,
 "If a target implements string objects then this hook should\n\
provide a facility to check the function arguments in @var{args_list}\n\
against the format specifiers in @var{format_arg} where the type of\n\
@var{format_arg} is one recognized as a valid string reference type.",
 void, (tree format_arg, tree args_list),
 NULL)

DEFHOOK
(c_preinclude,
 "Define this hook to return the name of a header file to be included at\n\
the start of all compilations, as if it had been included with\n\
@code{#include <@var{file}>}.  If this hook returns @code{NULL}, or is\n\
not defined, or the header is not found, or if the user specifies\n\
@option{-ffreestanding} or @option{-nostdinc}, no header is included.\n\
\n\
This hook can be used together with a header provided by the system C\n\
library to implement ISO C requirements for certain macros to be\n\
predefined that describe properties of the whole implementation rather\n\
than just the compiler.",
 const char *, (void),
 hook_constcharptr_void_null)

DEFHOOK
(cxx_implicit_extern_c,
 "Define this hook to add target-specific C++ implicit extern C functions.\n\
If this function returns true for the name of a file-scope function, that\n\
function implicitly gets extern \"C\" linkage rather than whatever language\n\
linkage the declaration would normally have.  An example of such function\n\
is WinMain on Win32 targets.",
 bool, (const char*),
 NULL)
 
HOOK_VECTOR_END (C90_EMPTY_HACK)
