1101704Smjacob/* The common simulator framework for GDB, the GNU Debugger.
2139749Simp
3101704Smjacob   Copyright 2002-2020 Free Software Foundation, Inc.
4101704Smjacob
5101704Smjacob   Contributed by Andrew Cagney and Red Hat.
6101704Smjacob
7101704Smjacob   This file is part of GDB.
8101704Smjacob
9101704Smjacob   This program is free software; you can redistribute it and/or modify
10101704Smjacob   it under the terms of the GNU General Public License as published by
11101704Smjacob   the Free Software Foundation; either version 3 of the License, or
12101704Smjacob   (at your option) any later version.
13101704Smjacob
14101704Smjacob   This program is distributed in the hope that it will be useful,
15101704Smjacob   but WITHOUT ANY WARRANTY; without even the implied warranty of
16101704Smjacob   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17101704Smjacob   GNU General Public License for more details.
18101704Smjacob
19101704Smjacob   You should have received a copy of the GNU General Public License
20101704Smjacob   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
21101704Smjacob
22101704Smjacob
23101704Smjacob#ifndef SIM_INLINE_H
24101704Smjacob#define SIM_INLINE_H
25101704Smjacob
26101704Smjacob
27101704Smjacob/* INLINE CODE SELECTION:
28156000Smjacob
29156000Smjacob   GCC -O3 attempts to inline any function or procedure in scope.  The
30156000Smjacob   options below facilitate finer grained control over what is and
31156000Smjacob   what is not inlined.  In particular, it allows the selection of
32156000Smjacob   modules for inlining.  Doing this allows the compiler to both
33156000Smjacob   eliminate the overhead of function calls and (as a consequence)
34156000Smjacob   also eliminate further dead code.
35156000Smjacob
36156000Smjacob   On a CISC (x86) I've found that I can achieve an order of magnitude
37156000Smjacob   speed improvement (x3-x5).  In the case of RISC (sparc) while the
38156000Smjacob   performance gain isn't as great it is still significant.
39156000Smjacob
40156000Smjacob   Each module is controled by the macro <module>_INLINE which can
41156000Smjacob   have the values described below
42156000Smjacob
43156000Smjacob       0 (ZERO)
44156000Smjacob
45156000Smjacob         Do not inline any thing for the given module
46156000Smjacob
47156000Smjacob   The following bit fields values can be combined:
48156000Smjacob
49156000Smjacob      H_REVEALS_MODULE:
50156000Smjacob      C_REVEALS_MODULE:
51156000Smjacob
52156000Smjacob         Include the C file for the module into the file being
53156000Smjacob         compiled.  The actual inlining is controlled separatly.
54156000Smjacob
55156000Smjacob	 While of no apparent benefit, this makes it possible for the
56156000Smjacob	 included module, when compiled, to inline its calls to what
57156000Smjacob	 would otherwize be external functions.
58147883Sscottl
59156000Smjacob	 {C_,H_} Determines where the module is inlined.  A
60156000Smjacob	 H_REVEALS_MODULE will be included everywhere.
61159052Smjacob
62159052Smjacob      INLINE_GLOBALS:
63159052Smjacob
64159052Smjacob         Make external functions within the module `inline'.  Thus if
65101704Smjacob         the module is included into a file being compiled, calls to
66101704Smjacob	 the included modules funtions can be eliminated.  INLINE_MODULE
67147883Sscottl	 implies REVEAL_MODULE.
68147883Sscottl
69147883Sscottl      INLINE_LOCALS:
70147883Sscottl
71147883Sscottl         Make internal (static) functions within the module `inline'.
72147883Sscottl
73147883Sscottl
74147883Sscottl   CODING STYLE:
75147883Sscottl
76147883Sscottl   The inline ability is enabled by specifying every data and function
77147883Sscottl   declaration and definition using one of the following methods:
78147883Sscottl
79147883Sscottl
80147883Sscottl       GLOBAL INLINE FUNCTIONS:
81147883Sscottl
82148679Sgibbs          Such functions are small and used heavily.  Inlining them
83148679Sgibbs          will eliminate an unnecessary function call overhead.
84148679Sgibbs
85147883Sscottl	  .h: INLINE_OURPKG (void) ourpkg_func
86147883Sscottl	      (int x,
87147883Sscottl	       int y);
88147883Sscottl
89147883Sscottl	  .c: INLINE_OURPKG (void)
90147883Sscottl	      ourpkg_func (int x,
91147883Sscottl	                   int y)
92147883Sscottl	      {
93147883Sscottl	        ...
94147883Sscottl	      }
95147883Sscottl
96147883Sscottl
97101704Smjacob       GLOBAL INLINE VARIABLES:
98101704Smjacob
99101704Smjacob          This doesn't make much sense.
100101704Smjacob
101147883Sscottl
102147883Sscottl       GLOBAL NON-INLINE (EXTERN) FUNCTIONS AND VARIABLES:
103147883Sscottl
104147883Sscottl          These include functions with varargs parameters.  It can
105147883Sscottl          also include large rarely used functions that contribute
106147883Sscottl          little when inlined.
107147883Sscottl
108147883Sscottl	  .h: extern int ourpkg_print
109147883Sscottl	      (char *fmt, ...);
110147883Sscottl	      extern int a_global_variable;
111147883Sscottl
112147883Sscottl	  .c: #if EXTERN_OURPKG_P
113147883Sscottl	      int
114147883Sscottl	      ourpkg_print (char *fmt,
115147883Sscottl	                    ...)
116147883Sscottl              {
117147883Sscottl	         ...
118147883Sscottl	      }
119147883Sscottl	      #endif
120147883Sscottl	      #if EXTERN_OURPKG_P
121147883Sscottl	      int a_global_variable = 1;
122147883Sscottl	      #endif
123147883Sscottl
124147883Sscottl
125147883Sscottl       LOCAL (STATIC) FUNCTIONS:
126147883Sscottl
127157117Smjacob          These can either be marked inline or just static static vis:
128157117Smjacob
129159179Smjacob	  .h: STATIC_INLINE_OURPKG (int) ourpkg_staticf (void);
130157117Smjacob	  .c: STATIC_INLINE_OURPKG (int)
131157117Smjacob	      ourpkg_staticf (void)
132147883Sscottl	      {
133147883Sscottl	        ..
134155521Smjacob	      }
135155521Smjacob
136155521Smjacob	  .h: STATIC_OURPKG (int) ourpkg_staticf (void);
137155521Smjacob	  .c: STATIC_OURPKG (int)
138155521Smjacob	      ourpkg_staticf (void)
139155521Smjacob	      {
140155521Smjacob	        ..
141155521Smjacob	      }
142155521Smjacob
143147883Sscottl
144147883Sscottl       All .h files:
145147883Sscottl
146147883Sscottl
147147883Sscottl          All modules must wrap their .h code in the following:
148147883Sscottl
149147883Sscottl	  #ifndef OURPKG_H
150147883Sscottl	  #define OURPKG_H
151147883Sscottl	  ... code proper ...
152147883Sscottl	  #endif
153147883Sscottl
154147883Sscottl          In addition, modules that want to allow global inlining must
155147883Sscottl          include the lines (below) at the end of the .h file. (FIXME:
156147883Sscottl          Shouldn't be needed).
157147883Sscottl
158147883Sscottl          #if H_REVEALS_MODULE_P (OURPKG_INLINE)
159101704Smjacob          #include "ourpkg.c"
160101704Smjacob          #endif
161101704Smjacob
162147883Sscottl
163101704Smjacob       All .c files:
164157117Smjacob
165157117Smjacob          All modules must wrap their .c code in the following
166157117Smjacob
167157117Smjacob	  #ifndef OURPKG_C
168157117Smjacob	  #define OURPKG_C
169157117Smjacob	  ... code proper ...
170147883Sscottl	  #endif
171147883Sscottl
172147883Sscottl
173147883Sscottl   NOW IT WORKS:
174101704Smjacob
175147883Sscottl      0:
176147883Sscottl
177147883Sscottl      Since no inlining is defined. All macro's get standard defaults
178147883Sscottl      (extern, static, ...).
179157117Smjacob
180147883Sscottl
181147883Sscottl
182147883Sscottl      H_REVEALS_MODULE (alt includes our):
183147883Sscottl
184147883Sscottl
185147883Sscottl      altprog.c defines ALTPROG_C and then includes sim-inline.h.
186147883Sscottl
187147883Sscottl      In sim-inline.h the expression `` H_REVEALS_MODULE_P
188147883Sscottl      (OURPROG_INLINE) && !  defined (OURPROG_C) && REVEAL_MODULE_P
189147883Sscottl      (OURPROG_INLINE) '' is TRUE so it defines *_OURPROG as static
190147883Sscottl      and EXTERN_OURPROG_P as FALSE.
191147883Sscottl
192147883Sscottl      altprog.c includes ourprog.h.
193147883Sscottl
194147883Sscottl      In ourprog.h the expression ``H_REVEALS_MODULE_P
195147883Sscottl      (OURPROG_INLINE)'' is TRUE so it includes ourprog.c.
196147883Sscottl
197157117Smjacob      Consequently, all the code in ourprog.c is visible and static in
198147883Sscottl      the file altprog.c
199147883Sscottl
200147883Sscottl
201147883Sscottl
202147883Sscottl      H_REVEALS_MODULE (our includes our):
203147883Sscottl
204101704Smjacob
205101704Smjacob      ourprog.c defines OURPROG_C and then includes sim-inline.h.
206147883Sscottl
207101704Smjacob      In sim-inline.h the term `` ! defined (OURPROG_C) '' is FALSE so
208147883Sscottl      it defines *_OURPROG as non-static and EXTERN_OURPROG_P as TRUE.
209147883Sscottl
210101704Smjacob      ourprog.c includes ourprog.h.
211147883Sscottl
212147883Sscottl      In ourprog.h the expression ``H_REVEALS_MODULE_P
213101704Smjacob      (OURPROG_INLINE)'' is true so it includes ourprog.c.
214147883Sscottl
215147883Sscottl      In ourprog.c (second include) the expression defined (OURPROG_C)
216147883Sscottl      and so the body is not re-included.
217147883Sscottl
218147883Sscottl      Consequently, ourprog.o will contain a non-static copy of all
219147883Sscottl      the exported symbols.
220147883Sscottl
221147883Sscottl
222147883Sscottl
223147883Sscottl      C_REVEALS_MODULE (alt includes our):
224147883Sscottl
225147883Sscottl
226147883Sscottl      altprog.c defines ALTPROG_C and then includes sim-inline.c
227147883Sscottl
228147883Sscottl      sim-inline.c defines C_INLINE_C and then includes sim-inline.h
229147883Sscottl
230147883Sscottl      In sim-inline.h the expression `` defined (SIM_INLINE) && !
231147883Sscottl      defined (OURPROG_C) && REVEAL_MODULE_P (OURPROG_INLINE) '' is
232147883Sscottl      true so it defines *_OURPROG as static and EXTERN_OURPROG_P as
233147883Sscottl      FALSE.
234147883Sscottl
235147883Sscottl      In sim-inline.c the expression ``C_REVEALS_MODULE_P
236147883Sscottl      (OURPROG_INLINE)'' is true so it includes ourprog.c.
237147883Sscottl
238147883Sscottl      Consequently, all the code in ourprog.c is visible and static in
239147883Sscottl      the file altprog.c.
240147883Sscottl
241147883Sscottl
242147883Sscottl
243147883Sscottl      C_REVEALS_MODULE (our includes our):
244147883Sscottl
245147883Sscottl
246147883Sscottl      ourprog.c defines OURPROG_C and then includes sim-inline.c
247147883Sscottl
248147883Sscottl      sim-inline.c defines C_INLINE_C and then includes sim-inline.h
249147883Sscottl
250147883Sscottl      In sim-inline.h the term `` !  defined (OURPROG_C) '' is FALSE
251147883Sscottl      so it defines *_OURPROG as non-static and EXTERN_OURPROG_P as
252147883Sscottl      TRUE.
253147883Sscottl
254147883Sscottl      Consequently, ourprog.o will contain a non-static copy of all
255147883Sscottl      the exported symbols.
256147883Sscottl
257147883Sscottl
258147883Sscottl
259147883Sscottl   REALITY CHECK:
260147883Sscottl
261147883Sscottl   This is not for the faint hearted.  I've seen GCC get up to 500mb
262147883Sscottl   trying to compile what this can create. */
263147883Sscottl
264147883Sscottl#define H_REVEALS_MODULE		1
265147883Sscottl#define C_REVEALS_MODULE		2
266147883Sscottl#define INLINE_GLOBALS			4
267147883Sscottl#define INLINE_LOCALS			8
268147883Sscottl
269147883Sscottl#define ALL_H_INLINE (H_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
270147883Sscottl#define ALL_C_INLINE (C_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS)
271147883Sscottl
272147883Sscottl
273147883Sscottl/* Default macro to simplify control several of key the inlines */
274147883Sscottl
275147883Sscottl#ifndef DEFAULT_INLINE
276147883Sscottl#define	DEFAULT_INLINE			INLINE_LOCALS
277147883Sscottl#endif
278147883Sscottl
279147883Sscottl#define REVEAL_MODULE_P(X) (X & (H_REVEALS_MODULE | C_REVEALS_MODULE))
280147883Sscottl#define H_REVEALS_MODULE_P(X) ((X & H_REVEALS_MODULE))
281147883Sscottl#define C_REVEALS_MODULE_P(X) ((X & C_REVEALS_MODULE))
282147883Sscottl
283147883Sscottl
284147883Sscottl#ifndef HAVE_INLINE
285157354Smjacob#ifdef __GNUC__
286157354Smjacob#define HAVE_INLINE
287157354Smjacob#endif
288157354Smjacob#endif
289157354Smjacob
290157354Smjacob
291157354Smjacob/* Your compilers inline prefix */
292157354Smjacob
293147883Sscottl#ifndef INLINE
294147883Sscottl#if defined (__GNUC__) && defined (__OPTIMIZE__)
295147883Sscottl#define INLINE __inline__
296147883Sscottl#else
297147883Sscottl#define INLINE /*inline*/
298147883Sscottl#endif
299147883Sscottl#endif
300147883Sscottl
301157662Smjacob/* ??? Temporary, pending decision to always use extern inline and do a vast
302157662Smjacob   cleanup of inline support.  */
303147883Sscottl#ifndef INLINE2
304147883Sscottl#if defined (__GNUC_GNU_INLINE__) || defined (__GNUC_STDC_INLINE__)
305147883Sscottl#define INLINE2 __inline__ __attribute__ ((__gnu_inline__))
306147883Sscottl#elif defined (__GNUC__)
307147883Sscottl#define INLINE2 __inline__
308159312Smjacob#else
309155521Smjacob#define INLINE2 /*inline*/
310147883Sscottl#endif
311147883Sscottl#endif
312157117Smjacob
313157117Smjacob
314157117Smjacob/* Your compiler's static inline prefix */
315157117Smjacob
316157117Smjacob#ifndef STATIC_INLINE
317157117Smjacob#define STATIC_INLINE static INLINE
318157117Smjacob#endif
319157117Smjacob
320157117Smjacob
321157354Smjacob/* Your compiler's extern inline prefix */
322157117Smjacob
323157117Smjacob#ifndef EXTERN_INLINE
324157354Smjacob#define EXTERN_INLINE extern INLINE2
325157117Smjacob#endif
326157117Smjacob
327157117Smjacob
328157117Smjacob/* Your compiler's no-return reserved word */
329157117Smjacob
330157117Smjacob#ifndef NORETURN
331157117Smjacob#define NORETURN
332157117Smjacob#endif
333157117Smjacob
334157117Smjacob
335157117Smjacob
336157117Smjacob/* Your compilers's unused reserved word */
337157117Smjacob
338157117Smjacob#if !defined (UNUSED)
339157117Smjacob#if (!defined (__GNUC__) \
340157117Smjacob     || (__GNUC__ < 2) \
341157117Smjacob     || (__GNUC__ == 2 && __GNUC_MINOR__ < 7))
342157117Smjacob#define UNUSED
343157117Smjacob#else
344157117Smjacob#define UNUSED __attribute__((__unused__))
345157354Smjacob#endif
346157117Smjacob#endif
347157117Smjacob
348157117Smjacob
349157117Smjacob
350157354Smjacob
351157117Smjacob
352157117Smjacob/* sim_arange */
353157117Smjacob
354157117Smjacob#if !defined (SIM_ARANGE_INLINE) && (DEFAULT_INLINE)
355157117Smjacob# define SIM_ARANGE_INLINE (ALL_H_INLINE)
356157117Smjacob#endif
357157117Smjacob
358157117Smjacob#if ((H_REVEALS_MODULE_P (SIM_ARANGE_INLINE) || defined (SIM_INLINE_C)) \
359157117Smjacob     && !defined (SIM_ARANGE_C) \
360157117Smjacob     && (REVEAL_MODULE_P (SIM_ARANGE_INLINE)))
361157117Smjacob# if (SIM_ARANGE_INLINE & INLINE_GLOBALS)
362157117Smjacob#  define INLINE_SIM_ARANGE(TYPE) static INLINE TYPE UNUSED
363157662Smjacob#  define EXTERN_SIM_ARANGE_P 0
364157117Smjacob# else
365147883Sscottl#  define INLINE_SIM_ARANGE(TYPE) static TYPE UNUSED
366101704Smjacob#  define EXTERN_SIM_ARANGE_P 0
367147883Sscottl# endif
368147883Sscottl#else
369147883Sscottl# define INLINE_SIM_ARANGE(TYPE) TYPE
370147883Sscottl# define EXTERN_SIM_ARANGE_P 1
371147883Sscottl#endif
372147883Sscottl
373147883Sscottl#if (SIM_ARANGE_INLINE & INLINE_LOCALS)
374147883Sscottl# define STATIC_INLINE_SIM_ARANGE(TYPE) static INLINE TYPE
375147883Sscottl#else
376147883Sscottl# define STATIC_INLINE_SIM_ARANGE(TYPE) static TYPE
377147883Sscottl#endif
378147883Sscottl
379147883Sscottl#define STATIC_SIM_ARANGE(TYPE) static TYPE
380147883Sscottl
381147883Sscottl
382147883Sscottl
383147883Sscottl/* *****
384147883Sscottl   sim-bits and sim-endian are treated differently from the rest
385101704Smjacob   of the modules below.  Their default value is ALL_H_INLINE.
386157117Smjacob   The rest are ALL_C_INLINE.  Don't blink, you'll miss it!
387147883Sscottl   *****
388147883Sscottl   */
389147883Sscottl
390147883Sscottl/* sim-bits */
391157117Smjacob
392147883Sscottl#if !defined (SIM_BITS_INLINE) && (DEFAULT_INLINE)
393147883Sscottl# define SIM_BITS_INLINE (ALL_H_INLINE)
394147883Sscottl#endif
395101704Smjacob
396147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_BITS_INLINE) || defined (SIM_INLINE_C)) \
397147883Sscottl     && !defined (SIM_BITS_C) \
398147883Sscottl     && (REVEAL_MODULE_P (SIM_BITS_INLINE)))
399147883Sscottl# if (SIM_BITS_INLINE & INLINE_GLOBALS)
400147883Sscottl#  define INLINE_SIM_BITS(TYPE) static INLINE TYPE UNUSED
401147883Sscottl#  define EXTERN_SIM_BITS_P 0
402101704Smjacob# else
403147883Sscottl#  define INLINE_SIM_BITS(TYPE) static TYPE UNUSED
404147883Sscottl#  define EXTERN_SIM_BITS_P 0
405147883Sscottl# endif
406147883Sscottl#else
407101704Smjacob# define INLINE_SIM_BITS(TYPE) TYPE
408101704Smjacob# define EXTERN_SIM_BITS_P 1
409147883Sscottl#endif
410147883Sscottl
411147883Sscottl#if (SIM_BITS_INLINE & INLINE_LOCALS)
412147883Sscottl# define STATIC_INLINE_SIM_BITS(TYPE) static INLINE TYPE
413147883Sscottl#else
414147883Sscottl# define STATIC_INLINE_SIM_BITS(TYPE) static TYPE
415147883Sscottl#endif
416147883Sscottl
417147883Sscottl#define STATIC_SIM_BITS(TYPE) static TYPE
418147883Sscottl
419147883Sscottl
420147883Sscottl
421147883Sscottl/* sim-core */
422147883Sscottl
423147883Sscottl#if !defined (SIM_CORE_INLINE) && (DEFAULT_INLINE)
424147883Sscottl# define SIM_CORE_INLINE ALL_C_INLINE
425147883Sscottl#endif
426147883Sscottl
427147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_CORE_INLINE) || defined (SIM_INLINE_C)) \
428147883Sscottl     && !defined (SIM_CORE_C) \
429147883Sscottl     && (REVEAL_MODULE_P (SIM_CORE_INLINE)))
430147883Sscottl# if (SIM_CORE_INLINE & INLINE_GLOBALS)
431147883Sscottl#  define INLINE_SIM_CORE(TYPE) static INLINE TYPE UNUSED
432147883Sscottl#  define EXTERN_SIM_CORE_P 0
433147883Sscottl#else
434147883Sscottl#  define INLINE_SIM_CORE(TYPE) static TYPE UNUSED
435147883Sscottl#  define EXTERN_SIM_CORE_P 0
436147883Sscottl#endif
437147883Sscottl#else
438147883Sscottl# define INLINE_SIM_CORE(TYPE) TYPE
439101704Smjacob# define EXTERN_SIM_CORE_P 1
440101704Smjacob#endif
441147883Sscottl
442147883Sscottl#if (SIM_CORE_INLINE & INLINE_LOCALS)
443147883Sscottl# define STATIC_INLINE_SIM_CORE(TYPE) static INLINE TYPE
444147883Sscottl#else
445147883Sscottl# define STATIC_INLINE_SIM_CORE(TYPE) static TYPE
446147883Sscottl#endif
447147883Sscottl
448147883Sscottl#define STATIC_SIM_CORE(TYPE) static TYPE
449101704Smjacob
450147883Sscottl
451147883Sscottl
452147883Sscottl/* sim-endian */
453147883Sscottl
454158933Smjacob#if !defined (SIM_ENDIAN_INLINE) && (DEFAULT_INLINE)
455101704Smjacob# define SIM_ENDIAN_INLINE ALL_H_INLINE
456101704Smjacob#endif
457147883Sscottl
458147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_ENDIAN_INLINE) || defined (SIM_INLINE_C)) \
459147883Sscottl     && !defined (SIM_ENDIAN_C) \
460147883Sscottl     && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE)))
461147883Sscottl# if (SIM_ENDIAN_INLINE & INLINE_GLOBALS)
462147883Sscottl#  define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED
463147883Sscottl#  define EXTERN_SIM_ENDIAN_P 0
464147883Sscottl# else
465147883Sscottl#  define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED
466147883Sscottl#  define EXTERN_SIM_ENDIAN_P 0
467147883Sscottl# endif
468147883Sscottl#else
469147883Sscottl# define INLINE_SIM_ENDIAN(TYPE) TYPE
470147883Sscottl# define EXTERN_SIM_ENDIAN_P 1
471147883Sscottl#endif
472147883Sscottl
473101704Smjacob#if (SIM_ENDIAN_INLINE & INLINE_LOCALS)
474101704Smjacob# define STATIC_INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE
475147883Sscottl#else
476147883Sscottl# define STATIC_INLINE_SIM_ENDIAN(TYPE) static TYPE
477147883Sscottl#endif
478147883Sscottl
479147883Sscottl#define STATIC_SIM_ENDIAN(TYPE) static TYPE
480101704Smjacob
481147883Sscottl
482101704Smjacob
483147883Sscottl/* sim-events */
484147883Sscottl
485147883Sscottl#if !defined (SIM_EVENTS_INLINE) && (DEFAULT_INLINE)
486157662Smjacob# define SIM_EVENTS_INLINE ALL_C_INLINE
487147883Sscottl#endif
488147883Sscottl
489147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_EVENTS_INLINE) || defined (SIM_INLINE_C)) \
490157662Smjacob     && !defined (SIM_EVENTS_C) \
491147883Sscottl     && (REVEAL_MODULE_P (SIM_EVENTS_INLINE)))
492147883Sscottl# if (SIM_EVENTS_INLINE & INLINE_GLOBALS)
493160290Smjacob#  define INLINE_SIM_EVENTS(TYPE) static INLINE TYPE UNUSED
494157117Smjacob#  define EXTERN_SIM_EVENTS_P 0
495160290Smjacob# else
496157117Smjacob#  define INLINE_SIM_EVENTS(TYPE) static TYPE UNUSED
497157117Smjacob#  define EXTERN_SIM_EVENTS_P 0
498160290Smjacob# endif
499158982Smjacob#else
500147883Sscottl# define INLINE_SIM_EVENTS(TYPE) TYPE
501147883Sscottl# define EXTERN_SIM_EVENTS_P 1
502147883Sscottl#endif
503147883Sscottl
504147883Sscottl#if (SIM_EVENTS_INLINE & INLINE_LOCALS)
505147883Sscottl# define STATIC_INLINE_SIM_EVENTS(TYPE) static INLINE TYPE
506159178Smjacob#else
507157117Smjacob# define STATIC_INLINE_SIM_EVENTS(TYPE) static TYPE
508157117Smjacob#endif
509101704Smjacob
510160290Smjacob#define STATIC_SIM_EVENTS(TYPE) static TYPE
511160290Smjacob
512160290Smjacob
513147883Sscottl
514101704Smjacob/* sim-fpu */
515147883Sscottl
516147883Sscottl#if !defined (SIM_FPU_INLINE) && (DEFAULT_INLINE)
517147883Sscottl# define SIM_FPU_INLINE ALL_C_INLINE
518147883Sscottl#endif
519147883Sscottl
520147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_FPU_INLINE) || defined (SIM_INLINE_C)) \
521147883Sscottl     && !defined (SIM_FPU_C) \
522155521Smjacob     && (REVEAL_MODULE_P (SIM_FPU_INLINE)))
523157354Smjacob# if (SIM_FPU_INLINE & INLINE_GLOBALS)
524101704Smjacob#  define INLINE_SIM_FPU(TYPE) static INLINE TYPE UNUSED
525147883Sscottl#  define EXTERN_SIM_FPU_P 0
526147883Sscottl# else
527147883Sscottl#  define INLINE_SIM_FPU(TYPE) static TYPE UNUSED
528147883Sscottl#  define EXTERN_SIM_FPU_P 0
529147883Sscottl# endif
530147883Sscottl#else
531147883Sscottl# define INLINE_SIM_FPU(TYPE) TYPE
532157117Smjacob# define EXTERN_SIM_FPU_P 1
533102822Smjacob#endif
534147883Sscottl
535147883Sscottl#if (SIM_FPU_INLINE & INLINE_LOCALS)
536147883Sscottl# define STATIC_INLINE_SIM_FPU(TYPE) static INLINE TYPE
537147883Sscottl#else
538147883Sscottl# define STATIC_INLINE_SIM_FPU(TYPE) static TYPE
539147883Sscottl#endif
540147883Sscottl
541147883Sscottl#define STATIC_SIM_FPU(TYPE) static TYPE
542147883Sscottl
543147883Sscottl
544147883Sscottl
545147883Sscottl/* sim-types */
546147883Sscottl
547147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_TYPES_INLINE) || defined (SIM_INLINE_C)) \
548147883Sscottl     && !defined (SIM_TYPES_C) \
549147883Sscottl     && (REVEAL_MODULE_P (SIM_TYPES_INLINE)))
550147883Sscottl# if (SIM_TYPES_INLINE & INLINE_GLOBALS)
551147883Sscottl#  define INLINE_SIM_TYPES(TYPE) static INLINE TYPE UNUSED
552147883Sscottl#  define EXTERN_SIM_TYPES_P 0
553147883Sscottl# else
554147883Sscottl#  define INLINE_SIM_TYPES(TYPE) static TYPE UNUSED
555157117Smjacob#  define EXTERN_SIM_TYPES_P 0
556159919Smjacob# endif
557157117Smjacob#else
558159919Smjacob# define INLINE_SIM_TYPES(TYPE) TYPE
559147883Sscottl# define EXTERN_SIM_TYPES_P 1
560147883Sscottl#endif
561147883Sscottl
562158982Smjacob#if (SIM_TYPES_INLINE & INLINE_LOCALS)
563147883Sscottl# define STATIC_INLINE_SIM_TYPES(TYPE) static INLINE TYPE
564147883Sscottl#else
565147883Sscottl# define STATIC_INLINE_SIM_TYPES(TYPE) static TYPE
566147883Sscottl#endif
567147883Sscottl
568147883Sscottl#define STATIC_SIM_TYPES(TYPE) static TYPE
569147883Sscottl
570147883Sscottl
571147883Sscottl
572147883Sscottl/* sim_main */
573147883Sscottl
574147883Sscottl#if !defined (SIM_MAIN_INLINE) && (DEFAULT_INLINE)
575147883Sscottl# define SIM_MAIN_INLINE (ALL_C_INLINE)
576147883Sscottl#endif
577152444Skan
578147883Sscottl#if ((H_REVEALS_MODULE_P (SIM_MAIN_INLINE) || defined (SIM_INLINE_C)) \
579147883Sscottl     && !defined (SIM_MAIN_C) \
580147883Sscottl     && (REVEAL_MODULE_P (SIM_MAIN_INLINE)))
581147883Sscottl# if (SIM_MAIN_INLINE & INLINE_GLOBALS)
582147883Sscottl#  define INLINE_SIM_MAIN(TYPE) static INLINE TYPE UNUSED
583147883Sscottl#  define EXTERN_SIM_MAIN_P 0
584147883Sscottl# else
585147883Sscottl#  define INLINE_SIM_MAIN(TYPE) static TYPE UNUSED
586147883Sscottl#  define EXTERN_SIM_MAIN_P 0
587147883Sscottl# endif
588147883Sscottl#else
589147883Sscottl# define INLINE_SIM_MAIN(TYPE) TYPE
590147883Sscottl# define EXTERN_SIM_MAIN_P 1
591147883Sscottl#endif
592147883Sscottl
593147883Sscottl#if (SIM_MAIN_INLINE & INLINE_LOCALS)
594147883Sscottl# define STATIC_INLINE_SIM_MAIN(TYPE) static INLINE TYPE
595147883Sscottl#else
596147883Sscottl# define STATIC_INLINE_SIM_MAIN(TYPE) static TYPE
597147883Sscottl#endif
598147883Sscottl
599147883Sscottl#define STATIC_SIM_MAIN(TYPE) static TYPE
600147883Sscottl
601147883Sscottl/* engine */
602147883Sscottl
603147883Sscottl#if ((H_REVEALS_MODULE_P (ENGINE_INLINE) || defined (SIM_INLINE_C)) \
604147883Sscottl     && !defined (ENGINE_C) \
605147883Sscottl     && (REVEAL_MODULE_P (ENGINE_INLINE)))
606147883Sscottl# if (ENGINE_INLINE & INLINE_GLOBALS)
607147883Sscottl#  define INLINE_ENGINE(TYPE) static INLINE TYPE UNUSED
608147883Sscottl#  define EXTERN_ENGINE_P 0
609147883Sscottl# else
610147883Sscottl#  define INLINE_ENGINE(TYPE) static TYPE UNUSED
611157117Smjacob#  define EXTERN_ENGINE_P 0
612147883Sscottl# endif
613155521Smjacob#else
614155521Smjacob# define INLINE_ENGINE(TYPE) TYPE
615155521Smjacob# define EXTERN_ENGINE_P 1
616155521Smjacob#endif
617155521Smjacob
618147883Sscottl#if (ENGINE_INLINE & INLINE_LOCALS)
619147883Sscottl# define STATIC_INLINE_ENGINE(TYPE) static INLINE TYPE
620147883Sscottl#else
621147883Sscottl# define STATIC_INLINE_ENGINE(TYPE) static TYPE
622147883Sscottl#endif
623147883Sscottl
624147883Sscottl#define STATIC_ENGINE(TYPE) static TYPE
625147883Sscottl
626147883Sscottl
627147883Sscottl
628147883Sscottl/* icache */
629147883Sscottl
630147883Sscottl#if ((H_REVEALS_MODULE_P (ICACHE_INLINE) || defined (SIM_INLINE_C)) \
631147883Sscottl     && !defined (ICACHE_C) \
632147883Sscottl     && (REVEAL_MODULE_P (ICACHE_INLINE)))
633147883Sscottl# if (ICACHE_INLINE & INLINE_GLOBALS)
634147883Sscottl#  define INLINE_ICACHE(TYPE) static INLINE TYPE UNUSED
635147883Sscottl#  define EXTERN_ICACHE_P 0
636147883Sscottl#else
637147883Sscottl#  define INLINE_ICACHE(TYPE) static TYPE UNUSED
638157117Smjacob#  define EXTERN_ICACHE_P 0
639157354Smjacob#endif
640157354Smjacob#else
641157354Smjacob# define INLINE_ICACHE(TYPE) TYPE
642159312Smjacob# define EXTERN_ICACHE_P 1
643157354Smjacob#endif
644157117Smjacob
645157117Smjacob#if (ICACHE_INLINE & INLINE_LOCALS)
646157117Smjacob# define STATIC_INLINE_ICACHE(TYPE) static INLINE TYPE
647157117Smjacob#else
648157662Smjacob# define STATIC_INLINE_ICACHE(TYPE) static TYPE
649147883Sscottl#endif
650157117Smjacob
651157117Smjacob#define STATIC_ICACHE(TYPE) static TYPE
652157117Smjacob
653157117Smjacob
654157117Smjacob
655157117Smjacob/* idecode */
656157117Smjacob
657157117Smjacob#if ((H_REVEALS_MODULE_P (IDECODE_INLINE) || defined (SIM_INLINE_C)) \
658157662Smjacob     && !defined (IDECODE_C) \
659157117Smjacob     && (REVEAL_MODULE_P (IDECODE_INLINE)))
660157117Smjacob# if (IDECODE_INLINE & INLINE_GLOBALS)
661157117Smjacob#  define INLINE_IDECODE(TYPE) static INLINE TYPE UNUSED
662157662Smjacob#  define EXTERN_IDECODE_P 0
663157662Smjacob#else
664157117Smjacob#  define INLINE_IDECODE(TYPE) static TYPE UNUSED
665157117Smjacob#  define EXTERN_IDECODE_P 0
666159312Smjacob#endif
667147883Sscottl#else
668147883Sscottl# define INLINE_IDECODE(TYPE) TYPE
669147883Sscottl# define EXTERN_IDECODE_P 1
670147883Sscottl#endif
671147883Sscottl
672147883Sscottl#if (IDECODE_INLINE & INLINE_LOCALS)
673147883Sscottl# define STATIC_INLINE_IDECODE(TYPE) static INLINE TYPE
674159178Smjacob#else
675147883Sscottl# define STATIC_INLINE_IDECODE(TYPE) static TYPE
676147883Sscottl#endif
677147883Sscottl
678147883Sscottl#define STATIC_IDECODE(TYPE) static TYPE
679147883Sscottl
680147883Sscottl
681147883Sscottl
682157662Smjacob/* semantics */
683157662Smjacob
684157662Smjacob#if ((H_REVEALS_MODULE_P (SEMANTICS_INLINE) || defined (SIM_INLINE_C)) \
685157662Smjacob     && !defined (SEMANTICS_C) \
686157662Smjacob     && (REVEAL_MODULE_P (SEMANTICS_INLINE)))
687157662Smjacob# if (SEMANTICS_INLINE & INLINE_GLOBALS)
688157662Smjacob#  define INLINE_SEMANTICS(TYPE) static INLINE TYPE UNUSED
689157662Smjacob#  define EXTERN_SEMANTICS_P 0
690157662Smjacob#else
691157662Smjacob#  define INLINE_SEMANTICS(TYPE) static TYPE UNUSED
692157117Smjacob#  define EXTERN_SEMANTICS_P 0
693147883Sscottl#endif
694147883Sscottl#else
695147883Sscottl# define INLINE_SEMANTICS(TYPE) TYPE
696147883Sscottl# define EXTERN_SEMANTICS_P 1
697157662Smjacob#endif
698147883Sscottl
699147883Sscottl#if EXTERN_SEMANTICS_P
700147883Sscottl# define EXTERN_SEMANTICS(TYPE) TYPE
701147883Sscottl#else
702147883Sscottl# define EXTERN_SEMANTICS(TYPE) static TYPE UNUSED
703147883Sscottl#endif
704147883Sscottl
705147883Sscottl#if (SEMANTICS_INLINE & INLINE_LOCALS)
706147883Sscottl# define STATIC_INLINE_SEMANTICS(TYPE) static INLINE TYPE
707147883Sscottl#else
708147883Sscottl# define STATIC_INLINE_SEMANTICS(TYPE) static TYPE
709147883Sscottl#endif
710147883Sscottl
711147883Sscottl#define STATIC_SEMANTICS(TYPE) static TYPE
712147883Sscottl
713147883Sscottl
714147883Sscottl
715147883Sscottl/* support */
716147883Sscottl
717147883Sscottl#if !defined (SUPPORT_INLINE) && (DEFAULT_INLINE)
718147883Sscottl# define SUPPORT_INLINE ALL_C_INLINE
719147883Sscottl#endif
720147883Sscottl
721147883Sscottl#if ((H_REVEALS_MODULE_P (SUPPORT_INLINE) || defined (SIM_INLINE_C)) \
722147883Sscottl     && !defined (SUPPORT_C) \
723147883Sscottl     && (REVEAL_MODULE_P (SUPPORT_INLINE)))
724147883Sscottl# if (SUPPORT_INLINE & INLINE_GLOBALS)
725147883Sscottl#  define INLINE_SUPPORT(TYPE) static INLINE TYPE UNUSED
726147883Sscottl#  define EXTERN_SUPPORT_P 0
727147883Sscottl#else
728147883Sscottl#  define INLINE_SUPPORT(TYPE) static TYPE UNUSED
729147883Sscottl#  define EXTERN_SUPPORT_P 0
730147883Sscottl#endif
731147883Sscottl#else
732147883Sscottl# define INLINE_SUPPORT(TYPE) TYPE
733147883Sscottl# define EXTERN_SUPPORT_P 1
734147883Sscottl#endif
735147883Sscottl
736147883Sscottl#if (SUPPORT_INLINE & INLINE_LOCALS)
737147883Sscottl# define STATIC_INLINE_SUPPORT(TYPE) static INLINE TYPE
738147883Sscottl#else
739147883Sscottl# define STATIC_INLINE_SUPPORT(TYPE) static TYPE
740147883Sscottl#endif
741147883Sscottl
742147883Sscottl#define STATIC_SUPPORT(TYPE) static TYPE
743147883Sscottl
744157117Smjacob
745147883Sscottl
746147883Sscottl#endif
747147883Sscottl