xref: /netbsd-src/external/gpl3/gdb/dist/sim/common/sim-inline.h (revision 88241920d21b339bf319c0e979ffda80c49a2936)
14e98e3e1Schristos /* The common simulator framework for GDB, the GNU Debugger.
24e98e3e1Schristos 
3*88241920Schristos    Copyright 2002-2024 Free Software Foundation, Inc.
44e98e3e1Schristos 
54e98e3e1Schristos    Contributed by Andrew Cagney and Red Hat.
64e98e3e1Schristos 
74e98e3e1Schristos    This file is part of GDB.
84e98e3e1Schristos 
94e98e3e1Schristos    This program is free software; you can redistribute it and/or modify
104e98e3e1Schristos    it under the terms of the GNU General Public License as published by
114e98e3e1Schristos    the Free Software Foundation; either version 3 of the License, or
124e98e3e1Schristos    (at your option) any later version.
134e98e3e1Schristos 
144e98e3e1Schristos    This program is distributed in the hope that it will be useful,
154e98e3e1Schristos    but WITHOUT ANY WARRANTY; without even the implied warranty of
164e98e3e1Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
174e98e3e1Schristos    GNU General Public License for more details.
184e98e3e1Schristos 
194e98e3e1Schristos    You should have received a copy of the GNU General Public License
204e98e3e1Schristos    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
214e98e3e1Schristos 
224e98e3e1Schristos 
234e98e3e1Schristos #ifndef SIM_INLINE_H
244e98e3e1Schristos #define SIM_INLINE_H
254e98e3e1Schristos 
264b169a6bSchristos #include "ansidecl.h"
274e98e3e1Schristos 
284e98e3e1Schristos /* INLINE CODE SELECTION:
294e98e3e1Schristos 
304e98e3e1Schristos    GCC -O3 attempts to inline any function or procedure in scope.  The
314e98e3e1Schristos    options below facilitate finer grained control over what is and
324e98e3e1Schristos    what is not inlined.  In particular, it allows the selection of
334e98e3e1Schristos    modules for inlining.  Doing this allows the compiler to both
344e98e3e1Schristos    eliminate the overhead of function calls and (as a consequence)
354e98e3e1Schristos    also eliminate further dead code.
364e98e3e1Schristos 
374e98e3e1Schristos    On a CISC (x86) I've found that I can achieve an order of magnitude
384e98e3e1Schristos    speed improvement (x3-x5).  In the case of RISC (sparc) while the
394e98e3e1Schristos    performance gain isn't as great it is still significant.
404e98e3e1Schristos 
414e98e3e1Schristos    Each module is controled by the macro <module>_INLINE which can
424e98e3e1Schristos    have the values described below
434e98e3e1Schristos 
444e98e3e1Schristos        0 (ZERO)
454e98e3e1Schristos 
464e98e3e1Schristos          Do not inline any thing for the given module
474e98e3e1Schristos 
484e98e3e1Schristos    The following bit fields values can be combined:
494e98e3e1Schristos 
504e98e3e1Schristos       H_REVEALS_MODULE:
514e98e3e1Schristos       C_REVEALS_MODULE:
524e98e3e1Schristos 
534e98e3e1Schristos          Include the C file for the module into the file being
544e98e3e1Schristos          compiled.  The actual inlining is controlled separatly.
554e98e3e1Schristos 
564e98e3e1Schristos 	 While of no apparent benefit, this makes it possible for the
574e98e3e1Schristos 	 included module, when compiled, to inline its calls to what
584e98e3e1Schristos 	 would otherwize be external functions.
594e98e3e1Schristos 
604e98e3e1Schristos 	 {C_,H_} Determines where the module is inlined.  A
614e98e3e1Schristos 	 H_REVEALS_MODULE will be included everywhere.
624e98e3e1Schristos 
634e98e3e1Schristos       INLINE_GLOBALS:
644e98e3e1Schristos 
654e98e3e1Schristos          Make external functions within the module `inline'.  Thus if
664e98e3e1Schristos          the module is included into a file being compiled, calls to
674e98e3e1Schristos 	 the included modules funtions can be eliminated.  INLINE_MODULE
684e98e3e1Schristos 	 implies REVEAL_MODULE.
694e98e3e1Schristos 
704e98e3e1Schristos       INLINE_LOCALS:
714e98e3e1Schristos 
724e98e3e1Schristos          Make internal (static) functions within the module `inline'.
734e98e3e1Schristos 
744e98e3e1Schristos 
754e98e3e1Schristos    CODING STYLE:
764e98e3e1Schristos 
774e98e3e1Schristos    The inline ability is enabled by specifying every data and function
784e98e3e1Schristos    declaration and definition using one of the following methods:
794e98e3e1Schristos 
804e98e3e1Schristos 
814e98e3e1Schristos        GLOBAL INLINE FUNCTIONS:
824e98e3e1Schristos 
834e98e3e1Schristos           Such functions are small and used heavily.  Inlining them
844e98e3e1Schristos           will eliminate an unnecessary function call overhead.
854e98e3e1Schristos 
864e98e3e1Schristos 	  .h: INLINE_OURPKG (void) ourpkg_func
874e98e3e1Schristos 	      (int x,
884e98e3e1Schristos 	       int y);
894e98e3e1Schristos 
904e98e3e1Schristos 	  .c: INLINE_OURPKG (void)
914e98e3e1Schristos 	      ourpkg_func (int x,
924e98e3e1Schristos 	                   int y)
934e98e3e1Schristos 	      {
944e98e3e1Schristos 	        ...
954e98e3e1Schristos 	      }
964e98e3e1Schristos 
974e98e3e1Schristos 
984e98e3e1Schristos        GLOBAL INLINE VARIABLES:
994e98e3e1Schristos 
1004e98e3e1Schristos           This doesn't make much sense.
1014e98e3e1Schristos 
1024e98e3e1Schristos 
1034e98e3e1Schristos        GLOBAL NON-INLINE (EXTERN) FUNCTIONS AND VARIABLES:
1044e98e3e1Schristos 
1054e98e3e1Schristos           These include functions with varargs parameters.  It can
1064e98e3e1Schristos           also include large rarely used functions that contribute
1074e98e3e1Schristos           little when inlined.
1084e98e3e1Schristos 
1094e98e3e1Schristos 	  .h: extern int ourpkg_print
1104e98e3e1Schristos 	      (char *fmt, ...);
1114e98e3e1Schristos 	      extern int a_global_variable;
1124e98e3e1Schristos 
1134e98e3e1Schristos 	  .c: #if EXTERN_OURPKG_P
1144e98e3e1Schristos 	      int
1154e98e3e1Schristos 	      ourpkg_print (char *fmt,
1164e98e3e1Schristos 	                    ...)
1174e98e3e1Schristos               {
1184e98e3e1Schristos 	         ...
1194e98e3e1Schristos 	      }
1204e98e3e1Schristos 	      #endif
1214e98e3e1Schristos 	      #if EXTERN_OURPKG_P
1224e98e3e1Schristos 	      int a_global_variable = 1;
1234e98e3e1Schristos 	      #endif
1244e98e3e1Schristos 
1254e98e3e1Schristos 
1264e98e3e1Schristos        LOCAL (STATIC) FUNCTIONS:
1274e98e3e1Schristos 
1284e98e3e1Schristos           These can either be marked inline or just static static vis:
1294e98e3e1Schristos 
1304e98e3e1Schristos 	  .h: STATIC_INLINE_OURPKG (int) ourpkg_staticf (void);
1314e98e3e1Schristos 	  .c: STATIC_INLINE_OURPKG (int)
1324e98e3e1Schristos 	      ourpkg_staticf (void)
1334e98e3e1Schristos 	      {
1344e98e3e1Schristos 	        ..
1354e98e3e1Schristos 	      }
1364e98e3e1Schristos 
1374e98e3e1Schristos 	  .h: STATIC_OURPKG (int) ourpkg_staticf (void);
1384e98e3e1Schristos 	  .c: STATIC_OURPKG (int)
1394e98e3e1Schristos 	      ourpkg_staticf (void)
1404e98e3e1Schristos 	      {
1414e98e3e1Schristos 	        ..
1424e98e3e1Schristos 	      }
1434e98e3e1Schristos 
1444e98e3e1Schristos 
1454e98e3e1Schristos        All .h files:
1464e98e3e1Schristos 
1474e98e3e1Schristos 
1484e98e3e1Schristos           All modules must wrap their .h code in the following:
1494e98e3e1Schristos 
1504e98e3e1Schristos 	  #ifndef OURPKG_H
1514e98e3e1Schristos 	  #define OURPKG_H
1524e98e3e1Schristos 	  ... code proper ...
1534e98e3e1Schristos 	  #endif
1544e98e3e1Schristos 
1554e98e3e1Schristos           In addition, modules that want to allow global inlining must
1564e98e3e1Schristos           include the lines (below) at the end of the .h file. (FIXME:
1574e98e3e1Schristos           Shouldn't be needed).
1584e98e3e1Schristos 
1594e98e3e1Schristos           #if H_REVEALS_MODULE_P (OURPKG_INLINE)
1604e98e3e1Schristos           #include "ourpkg.c"
1614e98e3e1Schristos           #endif
1624e98e3e1Schristos 
1634e98e3e1Schristos 
1644e98e3e1Schristos        All .c files:
1654e98e3e1Schristos 
1664e98e3e1Schristos           All modules must wrap their .c code in the following
1674e98e3e1Schristos 
1684e98e3e1Schristos 	  #ifndef OURPKG_C
1694e98e3e1Schristos 	  #define OURPKG_C
1704e98e3e1Schristos 	  ... code proper ...
1714e98e3e1Schristos 	  #endif
1724e98e3e1Schristos 
1734e98e3e1Schristos 
1744e98e3e1Schristos    NOW IT WORKS:
1754e98e3e1Schristos 
1764e98e3e1Schristos       0:
1774e98e3e1Schristos 
1784e98e3e1Schristos       Since no inlining is defined. All macro's get standard defaults
1794e98e3e1Schristos       (extern, static, ...).
1804e98e3e1Schristos 
1814e98e3e1Schristos 
1824e98e3e1Schristos 
1834e98e3e1Schristos       H_REVEALS_MODULE (alt includes our):
1844e98e3e1Schristos 
1854e98e3e1Schristos 
1864e98e3e1Schristos       altprog.c defines ALTPROG_C and then includes sim-inline.h.
1874e98e3e1Schristos 
1884e98e3e1Schristos       In sim-inline.h the expression `` H_REVEALS_MODULE_P
1894e98e3e1Schristos       (OURPROG_INLINE) && !  defined (OURPROG_C) && REVEAL_MODULE_P
1904e98e3e1Schristos       (OURPROG_INLINE) '' is TRUE so it defines *_OURPROG as static
1914e98e3e1Schristos       and EXTERN_OURPROG_P as FALSE.
1924e98e3e1Schristos 
1934e98e3e1Schristos       altprog.c includes ourprog.h.
1944e98e3e1Schristos 
1954e98e3e1Schristos       In ourprog.h the expression ``H_REVEALS_MODULE_P
1964e98e3e1Schristos       (OURPROG_INLINE)'' is TRUE so it includes ourprog.c.
1974e98e3e1Schristos 
1984e98e3e1Schristos       Consequently, all the code in ourprog.c is visible and static in
1994e98e3e1Schristos       the file altprog.c
2004e98e3e1Schristos 
2014e98e3e1Schristos 
2024e98e3e1Schristos 
2034e98e3e1Schristos       H_REVEALS_MODULE (our includes our):
2044e98e3e1Schristos 
2054e98e3e1Schristos 
2064e98e3e1Schristos       ourprog.c defines OURPROG_C and then includes sim-inline.h.
2074e98e3e1Schristos 
2084e98e3e1Schristos       In sim-inline.h the term `` ! defined (OURPROG_C) '' is FALSE so
2094e98e3e1Schristos       it defines *_OURPROG as non-static and EXTERN_OURPROG_P as TRUE.
2104e98e3e1Schristos 
2114e98e3e1Schristos       ourprog.c includes ourprog.h.
2124e98e3e1Schristos 
2134e98e3e1Schristos       In ourprog.h the expression ``H_REVEALS_MODULE_P
2144e98e3e1Schristos       (OURPROG_INLINE)'' is true so it includes ourprog.c.
2154e98e3e1Schristos 
2164e98e3e1Schristos       In ourprog.c (second include) the expression defined (OURPROG_C)
2174e98e3e1Schristos       and so the body is not re-included.
2184e98e3e1Schristos 
2194e98e3e1Schristos       Consequently, ourprog.o will contain a non-static copy of all
2204e98e3e1Schristos       the exported symbols.
2214e98e3e1Schristos 
2224e98e3e1Schristos 
2234e98e3e1Schristos 
2244e98e3e1Schristos       C_REVEALS_MODULE (alt includes our):
2254e98e3e1Schristos 
2264e98e3e1Schristos 
2274e98e3e1Schristos       altprog.c defines ALTPROG_C and then includes sim-inline.c
2284e98e3e1Schristos 
2294e98e3e1Schristos       sim-inline.c defines C_INLINE_C and then includes sim-inline.h
2304e98e3e1Schristos 
2314e98e3e1Schristos       In sim-inline.h the expression `` defined (SIM_INLINE) && !
2324e98e3e1Schristos       defined (OURPROG_C) && REVEAL_MODULE_P (OURPROG_INLINE) '' is
2334e98e3e1Schristos       true so it defines *_OURPROG as static and EXTERN_OURPROG_P as
2344e98e3e1Schristos       FALSE.
2354e98e3e1Schristos 
2364e98e3e1Schristos       In sim-inline.c the expression ``C_REVEALS_MODULE_P
2374e98e3e1Schristos       (OURPROG_INLINE)'' is true so it includes ourprog.c.
2384e98e3e1Schristos 
2394e98e3e1Schristos       Consequently, all the code in ourprog.c is visible and static in
2404e98e3e1Schristos       the file altprog.c.
2414e98e3e1Schristos 
2424e98e3e1Schristos 
2434e98e3e1Schristos 
2444e98e3e1Schristos       C_REVEALS_MODULE (our includes our):
2454e98e3e1Schristos 
2464e98e3e1Schristos 
2474e98e3e1Schristos       ourprog.c defines OURPROG_C and then includes sim-inline.c
2484e98e3e1Schristos 
2494e98e3e1Schristos       sim-inline.c defines C_INLINE_C and then includes sim-inline.h
2504e98e3e1Schristos 
2514e98e3e1Schristos       In sim-inline.h the term `` !  defined (OURPROG_C) '' is FALSE
2524e98e3e1Schristos       so it defines *_OURPROG as non-static and EXTERN_OURPROG_P as
2534e98e3e1Schristos       TRUE.
2544e98e3e1Schristos 
2554e98e3e1Schristos       Consequently, ourprog.o will contain a non-static copy of all
2564e98e3e1Schristos       the exported symbols.
2574e98e3e1Schristos 
2584e98e3e1Schristos 
2594e98e3e1Schristos 
2604e98e3e1Schristos    REALITY CHECK:
2614e98e3e1Schristos 
2624e98e3e1Schristos    This is not for the faint hearted.  I've seen GCC get up to 500mb
2634e98e3e1Schristos    trying to compile what this can create. */
2644e98e3e1Schristos 
2654e98e3e1Schristos #define H_REVEALS_MODULE		1
2664e98e3e1Schristos #define C_REVEALS_MODULE		2
2674e98e3e1Schristos #define INLINE_GLOBALS			4
2684e98e3e1Schristos #define INLINE_LOCALS			8
2694e98e3e1Schristos 
2704e98e3e1Schristos #define ALL_H_INLINE (H_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
2714e98e3e1Schristos #define ALL_C_INLINE (C_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
2724e98e3e1Schristos 
2734e98e3e1Schristos 
2744e98e3e1Schristos /* Default macro to simplify control several of key the inlines */
2754e98e3e1Schristos 
2764e98e3e1Schristos #ifndef DEFAULT_INLINE
2774e98e3e1Schristos #define	DEFAULT_INLINE			INLINE_LOCALS
2784e98e3e1Schristos #endif
2794e98e3e1Schristos 
2804e98e3e1Schristos #define REVEAL_MODULE_P(X) (X & (H_REVEALS_MODULE | C_REVEALS_MODULE))
2814e98e3e1Schristos #define H_REVEALS_MODULE_P(X) ((X & H_REVEALS_MODULE))
2824e98e3e1Schristos #define C_REVEALS_MODULE_P(X) ((X & C_REVEALS_MODULE))
2834e98e3e1Schristos 
2844e98e3e1Schristos 
2854e98e3e1Schristos #ifndef HAVE_INLINE
2864e98e3e1Schristos #ifdef __GNUC__
2874e98e3e1Schristos #define HAVE_INLINE
2884e98e3e1Schristos #endif
2894e98e3e1Schristos #endif
2904e98e3e1Schristos 
2914e98e3e1Schristos 
2924e98e3e1Schristos /* Your compilers inline prefix */
2934e98e3e1Schristos 
2944e98e3e1Schristos #ifndef INLINE
2954e98e3e1Schristos #if defined (__GNUC__) && defined (__OPTIMIZE__)
2964e98e3e1Schristos #define INLINE __inline__
2974e98e3e1Schristos #else
2984e98e3e1Schristos #define INLINE /*inline*/
2994e98e3e1Schristos #endif
3004e98e3e1Schristos #endif
3014e98e3e1Schristos 
3024e98e3e1Schristos /* ??? Temporary, pending decision to always use extern inline and do a vast
3034e98e3e1Schristos    cleanup of inline support.  */
3044e98e3e1Schristos #ifndef INLINE2
305212397c6Schristos #if defined (__GNUC_GNU_INLINE__) || defined (__GNUC_STDC_INLINE__)
306212397c6Schristos #define INLINE2 __inline__ __attribute__ ((__gnu_inline__))
307212397c6Schristos #elif defined (__GNUC__)
3084e98e3e1Schristos #define INLINE2 __inline__
3094e98e3e1Schristos #else
3104e98e3e1Schristos #define INLINE2 /*inline*/
3114e98e3e1Schristos #endif
3124e98e3e1Schristos #endif
3134e98e3e1Schristos 
3144e98e3e1Schristos 
3154e98e3e1Schristos /* Your compiler's static inline prefix */
3164e98e3e1Schristos 
3174e98e3e1Schristos #ifndef STATIC_INLINE
3184e98e3e1Schristos #define STATIC_INLINE static INLINE
3194e98e3e1Schristos #endif
3204e98e3e1Schristos 
3214e98e3e1Schristos 
3224e98e3e1Schristos /* Your compiler's extern inline prefix */
3234e98e3e1Schristos 
3244e98e3e1Schristos #ifndef EXTERN_INLINE
3254e98e3e1Schristos #define EXTERN_INLINE extern INLINE2
3264e98e3e1Schristos #endif
3274e98e3e1Schristos 
3284e98e3e1Schristos 
3294e98e3e1Schristos /* Your compilers's unused reserved word */
3304e98e3e1Schristos 
3314e98e3e1Schristos #if !defined (UNUSED)
3324b169a6bSchristos #define UNUSED ATTRIBUTE_UNUSED
3334e98e3e1Schristos #endif
3344e98e3e1Schristos 
3354e98e3e1Schristos 
3364e98e3e1Schristos 
3374e98e3e1Schristos 
3388dffb485Schristos 
3398dffb485Schristos /* sim_arange */
3408dffb485Schristos 
3418dffb485Schristos #if !defined (SIM_ARANGE_INLINE) && (DEFAULT_INLINE)
3428dffb485Schristos # define SIM_ARANGE_INLINE (ALL_H_INLINE)
3438dffb485Schristos #endif
3448dffb485Schristos 
3458dffb485Schristos #if ((H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) || defined (SIM_INLINE_C)) \
3468dffb485Schristos      && !defined (SIM_ARANGE_C) \
3478dffb485Schristos      && (REVEAL_MODULE_P (SIM_ARANGE_INLINE)))
3488dffb485Schristos # if (SIM_ARANGE_INLINE & INLINE_GLOBALS)
3494b169a6bSchristos #  define INLINE_SIM_ARANGE(TYPE) static INLINE UNUSED TYPE
3508dffb485Schristos #  define EXTERN_SIM_ARANGE_P 0
3518dffb485Schristos # else
3524b169a6bSchristos #  define INLINE_SIM_ARANGE(TYPE) static UNUSED TYPE
3538dffb485Schristos #  define EXTERN_SIM_ARANGE_P 0
3548dffb485Schristos # endif
3558dffb485Schristos #else
3568dffb485Schristos # define INLINE_SIM_ARANGE(TYPE) TYPE
3578dffb485Schristos # define EXTERN_SIM_ARANGE_P 1
3588dffb485Schristos #endif
3598dffb485Schristos 
3608dffb485Schristos #if (SIM_ARANGE_INLINE & INLINE_LOCALS)
3618dffb485Schristos # define STATIC_INLINE_SIM_ARANGE(TYPE) static INLINE TYPE
3628dffb485Schristos #else
3638dffb485Schristos # define STATIC_INLINE_SIM_ARANGE(TYPE) static TYPE
3648dffb485Schristos #endif
3658dffb485Schristos 
3668dffb485Schristos #define STATIC_SIM_ARANGE(TYPE) static TYPE
3678dffb485Schristos 
3688dffb485Schristos 
3698dffb485Schristos 
3704e98e3e1Schristos /* *****
3714e98e3e1Schristos    sim-bits and sim-endian are treated differently from the rest
3724e98e3e1Schristos    of the modules below.  Their default value is ALL_H_INLINE.
3734e98e3e1Schristos    The rest are ALL_C_INLINE.  Don't blink, you'll miss it!
3744e98e3e1Schristos    *****
3754e98e3e1Schristos    */
3764e98e3e1Schristos 
3774e98e3e1Schristos /* sim-bits */
3784e98e3e1Schristos 
3794e98e3e1Schristos #if !defined (SIM_BITS_INLINE) && (DEFAULT_INLINE)
3804e98e3e1Schristos # define SIM_BITS_INLINE (ALL_H_INLINE)
3814e98e3e1Schristos #endif
3824e98e3e1Schristos 
3834e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_BITS_INLINE) || defined (SIM_INLINE_C)) \
3844e98e3e1Schristos      && !defined (SIM_BITS_C) \
3854e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_BITS_INLINE)))
3864e98e3e1Schristos # if (SIM_BITS_INLINE & INLINE_GLOBALS)
3874b169a6bSchristos #  define INLINE_SIM_BITS(TYPE) static INLINE UNUSED TYPE
3884e98e3e1Schristos #  define EXTERN_SIM_BITS_P 0
3894e98e3e1Schristos # else
3904b169a6bSchristos #  define INLINE_SIM_BITS(TYPE) static UNUSED TYPE
3914e98e3e1Schristos #  define EXTERN_SIM_BITS_P 0
3924e98e3e1Schristos # endif
3934e98e3e1Schristos #else
394ba340e45Schristos # define INLINE_SIM_BITS(TYPE) TYPE
3954e98e3e1Schristos # define EXTERN_SIM_BITS_P 1
3964e98e3e1Schristos #endif
3974e98e3e1Schristos 
3984e98e3e1Schristos #if (SIM_BITS_INLINE & INLINE_LOCALS)
3994e98e3e1Schristos # define STATIC_INLINE_SIM_BITS(TYPE) static INLINE TYPE
4004e98e3e1Schristos #else
401ba340e45Schristos # define STATIC_INLINE_SIM_BITS(TYPE) static TYPE
4024e98e3e1Schristos #endif
4034e98e3e1Schristos 
4044e98e3e1Schristos #define STATIC_SIM_BITS(TYPE) static TYPE
4054e98e3e1Schristos 
4064e98e3e1Schristos 
4074e98e3e1Schristos 
4084e98e3e1Schristos /* sim-core */
4094e98e3e1Schristos 
4104e98e3e1Schristos #if !defined (SIM_CORE_INLINE) && (DEFAULT_INLINE)
4114e98e3e1Schristos # define SIM_CORE_INLINE ALL_C_INLINE
4124e98e3e1Schristos #endif
4134e98e3e1Schristos 
4144e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_CORE_INLINE) || defined (SIM_INLINE_C)) \
4154e98e3e1Schristos      && !defined (SIM_CORE_C) \
4164e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_CORE_INLINE)))
4174e98e3e1Schristos # if (SIM_CORE_INLINE & INLINE_GLOBALS)
4184b169a6bSchristos #  define INLINE_SIM_CORE(TYPE) static INLINE UNUSED TYPE
4194e98e3e1Schristos #  define EXTERN_SIM_CORE_P 0
4204e98e3e1Schristos #else
4214b169a6bSchristos #  define INLINE_SIM_CORE(TYPE) static UNUSED TYPE
4224e98e3e1Schristos #  define EXTERN_SIM_CORE_P 0
4234e98e3e1Schristos #endif
4244e98e3e1Schristos #else
425ba340e45Schristos # define INLINE_SIM_CORE(TYPE) TYPE
4264e98e3e1Schristos # define EXTERN_SIM_CORE_P 1
4274e98e3e1Schristos #endif
4284e98e3e1Schristos 
4294e98e3e1Schristos #if (SIM_CORE_INLINE & INLINE_LOCALS)
4304e98e3e1Schristos # define STATIC_INLINE_SIM_CORE(TYPE) static INLINE TYPE
4314e98e3e1Schristos #else
432ba340e45Schristos # define STATIC_INLINE_SIM_CORE(TYPE) static TYPE
4334e98e3e1Schristos #endif
4344e98e3e1Schristos 
4354e98e3e1Schristos #define STATIC_SIM_CORE(TYPE) static TYPE
4364e98e3e1Schristos 
4374e98e3e1Schristos 
4384e98e3e1Schristos 
4394e98e3e1Schristos /* sim-endian */
4404e98e3e1Schristos 
4414e98e3e1Schristos #if !defined (SIM_ENDIAN_INLINE) && (DEFAULT_INLINE)
4424e98e3e1Schristos # define SIM_ENDIAN_INLINE ALL_H_INLINE
4434e98e3e1Schristos #endif
4444e98e3e1Schristos 
4454e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_ENDIAN_INLINE) || defined (SIM_INLINE_C)) \
4464e98e3e1Schristos      && !defined (SIM_ENDIAN_C) \
4474e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
4484e98e3e1Schristos # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
4494b169a6bSchristos #  define INLINE_SIM_ENDIAN(TYPE) static INLINE UNUSED TYPE
4504e98e3e1Schristos #  define EXTERN_SIM_ENDIAN_P 0
4514e98e3e1Schristos # else
4524b169a6bSchristos #  define INLINE_SIM_ENDIAN(TYPE) static UNUSED TYPE
4534e98e3e1Schristos #  define EXTERN_SIM_ENDIAN_P 0
4544e98e3e1Schristos # endif
4554e98e3e1Schristos #else
456ba340e45Schristos # define INLINE_SIM_ENDIAN(TYPE) TYPE
4574e98e3e1Schristos # define EXTERN_SIM_ENDIAN_P 1
4584e98e3e1Schristos #endif
4594e98e3e1Schristos 
4604e98e3e1Schristos #if (SIM_ENDIAN_INLINE & INLINE_LOCALS)
4614e98e3e1Schristos # define STATIC_INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE
4624e98e3e1Schristos #else
463ba340e45Schristos # define STATIC_INLINE_SIM_ENDIAN(TYPE) static TYPE
4644e98e3e1Schristos #endif
4654e98e3e1Schristos 
4664e98e3e1Schristos #define STATIC_SIM_ENDIAN(TYPE) static TYPE
4674e98e3e1Schristos 
4684e98e3e1Schristos 
4694e98e3e1Schristos 
4704e98e3e1Schristos /* sim-events */
4714e98e3e1Schristos 
4724e98e3e1Schristos #if !defined (SIM_EVENTS_INLINE) && (DEFAULT_INLINE)
4734e98e3e1Schristos # define SIM_EVENTS_INLINE ALL_C_INLINE
4744e98e3e1Schristos #endif
4754e98e3e1Schristos 
4764e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_EVENTS_INLINE) || defined (SIM_INLINE_C)) \
4774e98e3e1Schristos      && !defined (SIM_EVENTS_C) \
4784e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_EVENTS_INLINE)))
4794e98e3e1Schristos # if (SIM_EVENTS_INLINE & INLINE_GLOBALS)
4804b169a6bSchristos #  define INLINE_SIM_EVENTS(TYPE) static INLINE UNUSED TYPE
4814e98e3e1Schristos #  define EXTERN_SIM_EVENTS_P 0
4824e98e3e1Schristos # else
4834b169a6bSchristos #  define INLINE_SIM_EVENTS(TYPE) static UNUSED TYPE
4844e98e3e1Schristos #  define EXTERN_SIM_EVENTS_P 0
4854e98e3e1Schristos # endif
4864e98e3e1Schristos #else
487ba340e45Schristos # define INLINE_SIM_EVENTS(TYPE) TYPE
4884e98e3e1Schristos # define EXTERN_SIM_EVENTS_P 1
4894e98e3e1Schristos #endif
4904e98e3e1Schristos 
4914e98e3e1Schristos #if (SIM_EVENTS_INLINE & INLINE_LOCALS)
4924e98e3e1Schristos # define STATIC_INLINE_SIM_EVENTS(TYPE) static INLINE TYPE
4934e98e3e1Schristos #else
494ba340e45Schristos # define STATIC_INLINE_SIM_EVENTS(TYPE) static TYPE
4954e98e3e1Schristos #endif
4964e98e3e1Schristos 
4974e98e3e1Schristos #define STATIC_SIM_EVENTS(TYPE) static TYPE
4984e98e3e1Schristos 
4994e98e3e1Schristos 
5004e98e3e1Schristos 
5014e98e3e1Schristos /* sim-fpu */
5024e98e3e1Schristos 
5034e98e3e1Schristos #if !defined (SIM_FPU_INLINE) && (DEFAULT_INLINE)
5044e98e3e1Schristos # define SIM_FPU_INLINE ALL_C_INLINE
5054e98e3e1Schristos #endif
5064e98e3e1Schristos 
5074e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_FPU_INLINE) || defined (SIM_INLINE_C)) \
5084e98e3e1Schristos      && !defined (SIM_FPU_C) \
5094e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_FPU_INLINE)))
5104e98e3e1Schristos # if (SIM_FPU_INLINE & INLINE_GLOBALS)
5114b169a6bSchristos #  define INLINE_SIM_FPU(TYPE) static INLINE UNUSED TYPE
5124e98e3e1Schristos #  define EXTERN_SIM_FPU_P 0
5134e98e3e1Schristos # else
5144b169a6bSchristos #  define INLINE_SIM_FPU(TYPE) static UNUSED TYPE
5154e98e3e1Schristos #  define EXTERN_SIM_FPU_P 0
5164e98e3e1Schristos # endif
5174e98e3e1Schristos #else
518ba340e45Schristos # define INLINE_SIM_FPU(TYPE) TYPE
5194e98e3e1Schristos # define EXTERN_SIM_FPU_P 1
5204e98e3e1Schristos #endif
5214e98e3e1Schristos 
5224e98e3e1Schristos #if (SIM_FPU_INLINE & INLINE_LOCALS)
5234e98e3e1Schristos # define STATIC_INLINE_SIM_FPU(TYPE) static INLINE TYPE
5244e98e3e1Schristos #else
525ba340e45Schristos # define STATIC_INLINE_SIM_FPU(TYPE) static TYPE
5264e98e3e1Schristos #endif
5274e98e3e1Schristos 
5284e98e3e1Schristos #define STATIC_SIM_FPU(TYPE) static TYPE
5294e98e3e1Schristos 
5304e98e3e1Schristos 
5314e98e3e1Schristos 
5324e98e3e1Schristos /* sim-types */
5334e98e3e1Schristos 
5344e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_TYPES_INLINE) || defined (SIM_INLINE_C)) \
5354e98e3e1Schristos      && !defined (SIM_TYPES_C) \
5364e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_TYPES_INLINE)))
5374e98e3e1Schristos # if (SIM_TYPES_INLINE & INLINE_GLOBALS)
5384b169a6bSchristos #  define INLINE_SIM_TYPES(TYPE) static INLINE UNUSED TYPE
5394e98e3e1Schristos #  define EXTERN_SIM_TYPES_P 0
5404e98e3e1Schristos # else
5414b169a6bSchristos #  define INLINE_SIM_TYPES(TYPE) static UNUSED TYPE
5424e98e3e1Schristos #  define EXTERN_SIM_TYPES_P 0
5434e98e3e1Schristos # endif
5444e98e3e1Schristos #else
545ba340e45Schristos # define INLINE_SIM_TYPES(TYPE) TYPE
5464e98e3e1Schristos # define EXTERN_SIM_TYPES_P 1
5474e98e3e1Schristos #endif
5484e98e3e1Schristos 
5494e98e3e1Schristos #if (SIM_TYPES_INLINE & INLINE_LOCALS)
5504e98e3e1Schristos # define STATIC_INLINE_SIM_TYPES(TYPE) static INLINE TYPE
5514e98e3e1Schristos #else
552ba340e45Schristos # define STATIC_INLINE_SIM_TYPES(TYPE) static TYPE
5534e98e3e1Schristos #endif
5544e98e3e1Schristos 
5554e98e3e1Schristos #define STATIC_SIM_TYPES(TYPE) static TYPE
5564e98e3e1Schristos 
5574e98e3e1Schristos 
5584e98e3e1Schristos 
5594e98e3e1Schristos /* sim_main */
5604e98e3e1Schristos 
5614e98e3e1Schristos #if !defined (SIM_MAIN_INLINE) && (DEFAULT_INLINE)
5624e98e3e1Schristos # define SIM_MAIN_INLINE (ALL_C_INLINE)
5634e98e3e1Schristos #endif
5644e98e3e1Schristos 
5654e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SIM_MAIN_INLINE) || defined (SIM_INLINE_C)) \
5664e98e3e1Schristos      && !defined (SIM_MAIN_C) \
5674e98e3e1Schristos      && (REVEAL_MODULE_P (SIM_MAIN_INLINE)))
5684e98e3e1Schristos # if (SIM_MAIN_INLINE & INLINE_GLOBALS)
5694b169a6bSchristos #  define INLINE_SIM_MAIN(TYPE) static INLINE UNUSED TYPE
5704e98e3e1Schristos #  define EXTERN_SIM_MAIN_P 0
5714e98e3e1Schristos # else
5724b169a6bSchristos #  define INLINE_SIM_MAIN(TYPE) static UNUSED TYPE
5734e98e3e1Schristos #  define EXTERN_SIM_MAIN_P 0
5744e98e3e1Schristos # endif
5754e98e3e1Schristos #else
576ba340e45Schristos # define INLINE_SIM_MAIN(TYPE) TYPE
5774e98e3e1Schristos # define EXTERN_SIM_MAIN_P 1
5784e98e3e1Schristos #endif
5794e98e3e1Schristos 
5804e98e3e1Schristos #if (SIM_MAIN_INLINE & INLINE_LOCALS)
5814e98e3e1Schristos # define STATIC_INLINE_SIM_MAIN(TYPE) static INLINE TYPE
5824e98e3e1Schristos #else
583ba340e45Schristos # define STATIC_INLINE_SIM_MAIN(TYPE) static TYPE
5844e98e3e1Schristos #endif
5854e98e3e1Schristos 
5864e98e3e1Schristos #define STATIC_SIM_MAIN(TYPE) static TYPE
5874e98e3e1Schristos 
5884e98e3e1Schristos /* engine */
5894e98e3e1Schristos 
5904e98e3e1Schristos #if ((H_REVEALS_MODULE_P (ENGINE_INLINE) || defined (SIM_INLINE_C)) \
5914e98e3e1Schristos      && !defined (ENGINE_C) \
5924e98e3e1Schristos      && (REVEAL_MODULE_P (ENGINE_INLINE)))
5934e98e3e1Schristos # if (ENGINE_INLINE & INLINE_GLOBALS)
5944b169a6bSchristos #  define INLINE_ENGINE(TYPE) static INLINE UNUSED TYPE
5954e98e3e1Schristos #  define EXTERN_ENGINE_P 0
5964e98e3e1Schristos # else
5974b169a6bSchristos #  define INLINE_ENGINE(TYPE) static UNUSED TYPE
5984e98e3e1Schristos #  define EXTERN_ENGINE_P 0
5994e98e3e1Schristos # endif
6004e98e3e1Schristos #else
601ba340e45Schristos # define INLINE_ENGINE(TYPE) TYPE
6024e98e3e1Schristos # define EXTERN_ENGINE_P 1
6034e98e3e1Schristos #endif
6044e98e3e1Schristos 
6054e98e3e1Schristos #if (ENGINE_INLINE & INLINE_LOCALS)
6064e98e3e1Schristos # define STATIC_INLINE_ENGINE(TYPE) static INLINE TYPE
6074e98e3e1Schristos #else
608ba340e45Schristos # define STATIC_INLINE_ENGINE(TYPE) static TYPE
6094e98e3e1Schristos #endif
6104e98e3e1Schristos 
6114e98e3e1Schristos #define STATIC_ENGINE(TYPE) static TYPE
6124e98e3e1Schristos 
6134e98e3e1Schristos 
6144e98e3e1Schristos 
6154e98e3e1Schristos /* icache */
6164e98e3e1Schristos 
6174e98e3e1Schristos #if ((H_REVEALS_MODULE_P (ICACHE_INLINE) || defined (SIM_INLINE_C)) \
6184e98e3e1Schristos      && !defined (ICACHE_C) \
6194e98e3e1Schristos      && (REVEAL_MODULE_P (ICACHE_INLINE)))
6204e98e3e1Schristos # if (ICACHE_INLINE & INLINE_GLOBALS)
6214b169a6bSchristos #  define INLINE_ICACHE(TYPE) static INLINE UNUSED TYPE
6224e98e3e1Schristos #  define EXTERN_ICACHE_P 0
6234e98e3e1Schristos #else
6244b169a6bSchristos #  define INLINE_ICACHE(TYPE) static UNUSED TYPE
6254e98e3e1Schristos #  define EXTERN_ICACHE_P 0
6264e98e3e1Schristos #endif
6274e98e3e1Schristos #else
628ba340e45Schristos # define INLINE_ICACHE(TYPE) TYPE
6294e98e3e1Schristos # define EXTERN_ICACHE_P 1
6304e98e3e1Schristos #endif
6314e98e3e1Schristos 
6324e98e3e1Schristos #if (ICACHE_INLINE & INLINE_LOCALS)
6334e98e3e1Schristos # define STATIC_INLINE_ICACHE(TYPE) static INLINE TYPE
6344e98e3e1Schristos #else
635ba340e45Schristos # define STATIC_INLINE_ICACHE(TYPE) static TYPE
6364e98e3e1Schristos #endif
6374e98e3e1Schristos 
6384e98e3e1Schristos #define STATIC_ICACHE(TYPE) static TYPE
6394e98e3e1Schristos 
6404e98e3e1Schristos 
6414e98e3e1Schristos 
6424e98e3e1Schristos /* idecode */
6434e98e3e1Schristos 
6444e98e3e1Schristos #if ((H_REVEALS_MODULE_P (IDECODE_INLINE) || defined (SIM_INLINE_C)) \
6454e98e3e1Schristos      && !defined (IDECODE_C) \
6464e98e3e1Schristos      && (REVEAL_MODULE_P (IDECODE_INLINE)))
6474e98e3e1Schristos # if (IDECODE_INLINE & INLINE_GLOBALS)
6484b169a6bSchristos #  define INLINE_IDECODE(TYPE) static INLINE UNUSED TYPE
6494e98e3e1Schristos #  define EXTERN_IDECODE_P 0
6504e98e3e1Schristos #else
6514b169a6bSchristos #  define INLINE_IDECODE(TYPE) static UNUSED TYPE
6524e98e3e1Schristos #  define EXTERN_IDECODE_P 0
6534e98e3e1Schristos #endif
6544e98e3e1Schristos #else
655ba340e45Schristos # define INLINE_IDECODE(TYPE) TYPE
6564e98e3e1Schristos # define EXTERN_IDECODE_P 1
6574e98e3e1Schristos #endif
6584e98e3e1Schristos 
6594e98e3e1Schristos #if (IDECODE_INLINE & INLINE_LOCALS)
6604e98e3e1Schristos # define STATIC_INLINE_IDECODE(TYPE) static INLINE TYPE
6614e98e3e1Schristos #else
662ba340e45Schristos # define STATIC_INLINE_IDECODE(TYPE) static TYPE
6634e98e3e1Schristos #endif
6644e98e3e1Schristos 
6654e98e3e1Schristos #define STATIC_IDECODE(TYPE) static TYPE
6664e98e3e1Schristos 
6674e98e3e1Schristos 
6684e98e3e1Schristos 
6694e98e3e1Schristos /* semantics */
6704e98e3e1Schristos 
6714e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SEMANTICS_INLINE) || defined (SIM_INLINE_C)) \
6724e98e3e1Schristos      && !defined (SEMANTICS_C) \
6734e98e3e1Schristos      && (REVEAL_MODULE_P (SEMANTICS_INLINE)))
6744e98e3e1Schristos # if (SEMANTICS_INLINE & INLINE_GLOBALS)
6754b169a6bSchristos #  define INLINE_SEMANTICS(TYPE) static INLINE UNUSED TYPE
6764e98e3e1Schristos #  define EXTERN_SEMANTICS_P 0
6774e98e3e1Schristos #else
6784b169a6bSchristos #  define INLINE_SEMANTICS(TYPE) static UNUSED TYPE
6794e98e3e1Schristos #  define EXTERN_SEMANTICS_P 0
6804e98e3e1Schristos #endif
6814e98e3e1Schristos #else
682ba340e45Schristos # define INLINE_SEMANTICS(TYPE) TYPE
6834e98e3e1Schristos # define EXTERN_SEMANTICS_P 1
6844e98e3e1Schristos #endif
6854e98e3e1Schristos 
6864e98e3e1Schristos #if EXTERN_SEMANTICS_P
687ba340e45Schristos # define EXTERN_SEMANTICS(TYPE) TYPE
6884e98e3e1Schristos #else
6894b169a6bSchristos # define EXTERN_SEMANTICS(TYPE) static UNUSED TYPE
6904e98e3e1Schristos #endif
6914e98e3e1Schristos 
6924e98e3e1Schristos #if (SEMANTICS_INLINE & INLINE_LOCALS)
6934e98e3e1Schristos # define STATIC_INLINE_SEMANTICS(TYPE) static INLINE TYPE
6944e98e3e1Schristos #else
695ba340e45Schristos # define STATIC_INLINE_SEMANTICS(TYPE) static TYPE
6964e98e3e1Schristos #endif
6974e98e3e1Schristos 
6984e98e3e1Schristos #define STATIC_SEMANTICS(TYPE) static TYPE
6994e98e3e1Schristos 
7004e98e3e1Schristos 
7014e98e3e1Schristos 
7024e98e3e1Schristos /* support */
7034e98e3e1Schristos 
7044e98e3e1Schristos #if !defined (SUPPORT_INLINE) && (DEFAULT_INLINE)
7054e98e3e1Schristos # define SUPPORT_INLINE ALL_C_INLINE
7064e98e3e1Schristos #endif
7074e98e3e1Schristos 
7084e98e3e1Schristos #if ((H_REVEALS_MODULE_P (SUPPORT_INLINE) || defined (SIM_INLINE_C)) \
7094e98e3e1Schristos      && !defined (SUPPORT_C) \
7104e98e3e1Schristos      && (REVEAL_MODULE_P (SUPPORT_INLINE)))
7114e98e3e1Schristos # if (SUPPORT_INLINE & INLINE_GLOBALS)
7124b169a6bSchristos #  define INLINE_SUPPORT(TYPE) static INLINE UNUSED TYPE
7134e98e3e1Schristos #  define EXTERN_SUPPORT_P 0
7144e98e3e1Schristos #else
7154b169a6bSchristos #  define INLINE_SUPPORT(TYPE) static UNUSED TYPE
7164e98e3e1Schristos #  define EXTERN_SUPPORT_P 0
7174e98e3e1Schristos #endif
7184e98e3e1Schristos #else
719ba340e45Schristos # define INLINE_SUPPORT(TYPE) TYPE
7204e98e3e1Schristos # define EXTERN_SUPPORT_P 1
7214e98e3e1Schristos #endif
7224e98e3e1Schristos 
7234e98e3e1Schristos #if (SUPPORT_INLINE & INLINE_LOCALS)
7244e98e3e1Schristos # define STATIC_INLINE_SUPPORT(TYPE) static INLINE TYPE
7254e98e3e1Schristos #else
726ba340e45Schristos # define STATIC_INLINE_SUPPORT(TYPE) static TYPE
7274e98e3e1Schristos #endif
7284e98e3e1Schristos 
7294e98e3e1Schristos #define STATIC_SUPPORT(TYPE) static TYPE
7304e98e3e1Schristos 
7314e98e3e1Schristos 
7324e98e3e1Schristos 
7334e98e3e1Schristos #endif
734