xref: /netbsd-src/external/gpl3/gcc.old/dist/gcc/objc/objc-runtime-hooks.h (revision 8feb0f0b7eaff0608f8350bbfa3098827b4bb91b)
136ac495dSmrg /* Hooks to abstract the runtime meta-data generation for Objective C.
2*8feb0f0bSmrg    Copyright (C) 2011-2020 Free Software Foundation, Inc.
336ac495dSmrg    Contributed by Iain Sandoe
436ac495dSmrg 
536ac495dSmrg This file is part of GCC.
636ac495dSmrg 
736ac495dSmrg GCC is free software; you can redistribute it and/or modify
836ac495dSmrg it under the terms of the GNU General Public License as published by
936ac495dSmrg the Free Software Foundation; either version 3, or (at your option)
1036ac495dSmrg any later version.
1136ac495dSmrg 
1236ac495dSmrg GCC is distributed in the hope that it will be useful,
1336ac495dSmrg but WITHOUT ANY WARRANTY; without even the implied warranty of
1436ac495dSmrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1536ac495dSmrg GNU General Public License for more details.
1636ac495dSmrg 
1736ac495dSmrg You should have received a copy of the GNU General Public License
1836ac495dSmrg along with GCC; see the file COPYING3.  If not see
1936ac495dSmrg <http://www.gnu.org/licenses/>.  */
2036ac495dSmrg 
2136ac495dSmrg #ifndef _OBJC_RUNTIME_HOOKS_H_
2236ac495dSmrg #define _OBJC_RUNTIME_HOOKS_H_
2336ac495dSmrg 
2436ac495dSmrg /* A set of hooks for the front end to obtain runtime-specific actions.  */
2536ac495dSmrg 
2636ac495dSmrg /* Objective-C supports several runtime library variants:
2736ac495dSmrg 
2836ac495dSmrg    "GNU" runtime selected by -fgnu-runtime (currently at ABI version 8).
2936ac495dSmrg    "NeXT" runtime (selected by -fnext-runtime) and installed on OSX/Darwin
3036ac495dSmrg    systems at API version 1 (for m32 code) and version 2 (for m64 code).
3136ac495dSmrg 
3236ac495dSmrg    The runtimes require different data types/layouts, method call mechanisms
3336ac495dSmrg    and so on, and the purpose of this interface is to abstract such
3436ac495dSmrg    differences from the parser's perspective.  */
3536ac495dSmrg 
3636ac495dSmrg /* TODO: Do we want the initial underscore ? */
3736ac495dSmrg struct objc_runtime_hooks
3836ac495dSmrg {
3936ac495dSmrg   /* TODO: Expand comments in this file.  */
4036ac495dSmrg 
4136ac495dSmrg   /* Initialize for this runtime.  */
4236ac495dSmrg   void (*initialize) (void);
4336ac495dSmrg   const char *default_constant_string_class_name;
4436ac495dSmrg 
4536ac495dSmrg   /* FIXME: Having to check this name should not be necessary.  */
4636ac495dSmrg   const char *tag_getclass;
4736ac495dSmrg   /* id for superclass class field - named differently in the existing
4836ac495dSmrg      runtimes.  */
4936ac495dSmrg   tree (*super_superclassfield_ident) (void);
5036ac495dSmrg 
5136ac495dSmrg   /* Obtain a class decl for the identifier.  */
5236ac495dSmrg   tree (*class_decl) (tree);
5336ac495dSmrg   /* Obtain a metaclass decl for the identifier.  */
5436ac495dSmrg   tree (*metaclass_decl) (tree);
5536ac495dSmrg   /* Obtain a category decl for the identifier.  */
5636ac495dSmrg   tree (*category_decl) (tree);
5736ac495dSmrg   /* Obtain a protocol decl for the identifier.  */
5836ac495dSmrg   tree (*protocol_decl) (tree);
5936ac495dSmrg   /* Obtain a string decl, to be placed in the nominated string-section.  */
6036ac495dSmrg   tree (*string_decl) (tree, const char *, string_section);
6136ac495dSmrg 
6236ac495dSmrg   /* Obtain a class reference, generating the fwd def. if necessary.  */
6336ac495dSmrg   tree (*get_class_reference) (tree);
6436ac495dSmrg   /* build/get selector reference.  */
6536ac495dSmrg   tree (*build_selector_reference) (location_t, tree, tree);
6636ac495dSmrg   /* Get a protocol reference, generating the forward def. if necessary.  */
6736ac495dSmrg   tree (*get_protocol_reference) (location_t, tree);
6836ac495dSmrg   /* Get an ivar ref. re the base.  */
6936ac495dSmrg   tree (*build_ivar_reference) (location_t, tree, tree);
7036ac495dSmrg   /* Get a reference to {meta}class' super.  */
7136ac495dSmrg   tree (*get_class_super_ref) (location_t, struct imp_entry *, bool);
7236ac495dSmrg   /* Get a reference to Category {meta}class' super.  */
7336ac495dSmrg   tree (*get_category_super_ref) (location_t, struct imp_entry *, bool);
7436ac495dSmrg 
7536ac495dSmrg   /* Receiver is class Object, check runtime-specific.  */
7636ac495dSmrg   tree (*receiver_is_class_object) (tree);
7736ac495dSmrg   /* Get the start of a method argument type list (receiver, _cmd).  */
7836ac495dSmrg   void (*get_arg_type_list_base) (vec<tree, va_gc> **, tree, int, int);
7936ac495dSmrg   /* Build method call.  */
8036ac495dSmrg   tree (*build_objc_method_call) (location_t, tree, tree, tree, tree, tree, int);
8136ac495dSmrg 
8236ac495dSmrg   /* Check for or otherwise handle a request to check that the constant
8336ac495dSmrg      string class reference is set-up & OK.  */
8436ac495dSmrg   bool (*setup_const_string_class_decl) (void);
8536ac495dSmrg   /* Return the tree reprenting a const string constructor for the arg.
8636ac495dSmrg      Most of the data are in global trees.  */
8736ac495dSmrg   tree (*build_const_string_constructor) (location_t, tree, int);
8836ac495dSmrg 
8936ac495dSmrg   /* Exceptions.  */
9036ac495dSmrg   tree (*build_throw_stmt) (location_t, tree, bool);
9136ac495dSmrg   tree (*build_exc_ptr) (struct objc_try_context **);
9236ac495dSmrg   tree (*begin_catch) (struct objc_try_context **, tree, tree, tree, bool);
9336ac495dSmrg   void (*finish_catch) (struct objc_try_context **, tree);
9436ac495dSmrg   tree (*finish_try_stmt) (struct objc_try_context **);
9536ac495dSmrg 
9636ac495dSmrg   /* Emit all the metadata required by the runtime - based on the tables built
9736ac495dSmrg      during parsing.  */
9836ac495dSmrg   void (*generate_metadata) (void);
9936ac495dSmrg 
10036ac495dSmrg };
10136ac495dSmrg 
10236ac495dSmrg /* For shared support that needs to access these.  */
10336ac495dSmrg extern objc_runtime_hooks runtime;
10436ac495dSmrg 
10536ac495dSmrg /* One per runtime at present.
10636ac495dSmrg    TODO: Make into some kind of configury-generated table.  */
10736ac495dSmrg extern bool objc_gnu_runtime_abi_01_init (objc_runtime_hooks *);
10836ac495dSmrg extern bool objc_next_runtime_abi_01_init (objc_runtime_hooks *);
10936ac495dSmrg extern bool objc_next_runtime_abi_02_init (objc_runtime_hooks *);
11036ac495dSmrg 
11136ac495dSmrg #endif /* _OBJC_RUNTIME_HOOKS_H_ */
112