| 1 | /* The common simulator framework for GDB, the GNU Debugger. |
| 2 | |
| 3 | Copyright 2002 Free Software Foundation, Inc. |
| 4 | |
| 5 | Contributed by Andrew Cagney and Red Hat. |
| 6 | |
| 7 | This file is part of GDB. |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation; either version 2 of the License, or |
| 12 | (at your option) any later version. |
| 13 | |
| 14 | This program is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with this program; if not, write to the Free Software |
| 21 | Foundation, Inc., 59 Temple Place - Suite 330, |
| 22 | Boston, MA 02111-1307, USA. */ |
| 23 | |
| 24 | |
| 25 | #ifndef SIM_INLINE_H |
| 26 | #define SIM_INLINE_H |
| 27 | |
| 28 | |
| 29 | /* INLINE CODE SELECTION: |
| 30 | |
| 31 | GCC -O3 attempts to inline any function or procedure in scope. The |
| 32 | options below facilitate finer grained control over what is and |
| 33 | what is not inlined. In particular, it allows the selection of |
| 34 | modules for inlining. Doing this allows the compiler to both |
| 35 | eliminate the overhead of function calls and (as a consequence) |
| 36 | also eliminate further dead code. |
| 37 | |
| 38 | On a CISC (x86) I've found that I can achieve an order of magintude |
| 39 | speed improvement (x3-x5). In the case of RISC (sparc) while the |
| 40 | performance gain isn't as great it is still significant. |
| 41 | |
| 42 | Each module is controled by the macro <module>_INLINE which can |
| 43 | have the values described below |
| 44 | |
| 45 | 0 (ZERO) |
| 46 | |
| 47 | Do not inline any thing for the given module |
| 48 | |
| 49 | The following bit fields values can be combined: |
| 50 | |
| 51 | H_REVEALS_MODULE: |
| 52 | C_REVEALS_MODULE: |
| 53 | |
| 54 | Include the C file for the module into the file being |
| 55 | compiled. The actual inlining is controlled separatly. |
| 56 | |
| 57 | While of no apparent benefit, this makes it possible for the |
| 58 | included module, when compiled, to inline its calls to what |
| 59 | would otherwize be external functions. |
| 60 | |
| 61 | {C_,H_} Determines where the module is inlined. A |
| 62 | H_REVEALS_MODULE will be included everywhere. |
| 63 | |
| 64 | INLINE_GLOBALS: |
| 65 | |
| 66 | Make external functions within the module `inline'. Thus if |
| 67 | the module is included into a file being compiled, calls to |
| 68 | the included modules funtions can be eliminated. INLINE_MODULE |
| 69 | implies REVEAL_MODULE. |
| 70 | |
| 71 | INLINE_LOCALS: |
| 72 | |
| 73 | Make internal (static) functions within the module `inline'. |
| 74 | |
| 75 | |
| 76 | CODING STYLE: |
| 77 | |
| 78 | The inline ability is enabled by specifying every data and function |
| 79 | declaration and definition using one of the following methods: |
| 80 | |
| 81 | |
| 82 | GLOBAL INLINE FUNCTIONS: |
| 83 | |
| 84 | Such functions are small and used heavily. Inlining them |
| 85 | will eliminate an unnecessary function call overhead. |
| 86 | |
| 87 | .h: INLINE_OURPKG (void) ourpkg_func |
| 88 | (int x, |
| 89 | int y); |
| 90 | |
| 91 | .c: INLINE_OURPKG (void) |
| 92 | ourpkg_func (int x, |
| 93 | int y) |
| 94 | { |
| 95 | ... |
| 96 | } |
| 97 | |
| 98 | |
| 99 | GLOBAL INLINE VARIABLES: |
| 100 | |
| 101 | This doesn't make much sense. |
| 102 | |
| 103 | |
| 104 | GLOBAL NON-INLINE (EXTERN) FUNCTIONS AND VARIABLES: |
| 105 | |
| 106 | These include functions with varargs parameters. It can |
| 107 | also include large rarely used functions that contribute |
| 108 | little when inlined. |
| 109 | |
| 110 | .h: extern int ourpkg_print |
| 111 | (char *fmt, ...); |
| 112 | extern int a_global_variable; |
| 113 | |
| 114 | .c: #if EXTERN_OURPKG_P |
| 115 | int |
| 116 | ourpkg_print (char *fmt, |
| 117 | ...) |
| 118 | { |
| 119 | ... |
| 120 | } |
| 121 | #endif |
| 122 | #if EXTERN_OURPKG_P |
| 123 | int a_global_variable = 1; |
| 124 | #endif |
| 125 | |
| 126 | |
| 127 | LOCAL (STATIC) FUNCTIONS: |
| 128 | |
| 129 | These can either be marked inline or just static static vis: |
| 130 | |
| 131 | .h: STATIC_INLINE_OURPKG (int) ourpkg_staticf (void); |
| 132 | .c: STATIC_INLINE_OURPKG (int) |
| 133 | ourpkg_staticf (void) |
| 134 | { |
| 135 | .. |
| 136 | } |
| 137 | |
| 138 | .h: STATIC_OURPKG (int) ourpkg_staticf (void); |
| 139 | .c: STATIC_OURPKG (int) |
| 140 | ourpkg_staticf (void) |
| 141 | { |
| 142 | .. |
| 143 | } |
| 144 | |
| 145 | |
| 146 | All .h files: |
| 147 | |
| 148 | |
| 149 | All modules must wrap their .h code in the following: |
| 150 | |
| 151 | #ifndef OURPKG_H |
| 152 | #define OURPKG_H |
| 153 | ... code proper ... |
| 154 | #endif |
| 155 | |
| 156 | In addition, modules that want to allow global inlining must |
| 157 | include the lines (below) at the end of the .h file. (FIXME: |
| 158 | Shouldn't be needed). |
| 159 | |
| 160 | #if H_REVEALS_MODULE_P (OURPKG_INLINE) |
| 161 | #include "ourpkg.c" |
| 162 | #endif |
| 163 | |
| 164 | |
| 165 | All .c files: |
| 166 | |
| 167 | All modules must wrap their .c code in the following |
| 168 | |
| 169 | #ifndef OURPKG_C |
| 170 | #define OURPKG_C |
| 171 | ... code proper ... |
| 172 | #endif |
| 173 | |
| 174 | |
| 175 | NOW IT WORKS: |
| 176 | |
| 177 | 0: |
| 178 | |
| 179 | Since no inlining is defined. All macro's get standard defaults |
| 180 | (extern, static, ...). |
| 181 | |
| 182 | |
| 183 | |
| 184 | H_REVEALS_MODULE (alt includes our): |
| 185 | |
| 186 | |
| 187 | altprog.c defines ALTPROG_C and then includes sim-inline.h. |
| 188 | |
| 189 | In sim-inline.h the expression `` H_REVEALS_MODULE_P |
| 190 | (OURPROG_INLINE) && ! defined (OURPROG_C) && REVEAL_MODULE_P |
| 191 | (OURPROG_INLINE) '' is TRUE so it defines *_OURPROG as static |
| 192 | and EXTERN_OURPROG_P as FALSE. |
| 193 | |
| 194 | altprog.c includes ourprog.h. |
| 195 | |
| 196 | In ourprog.h the expression ``H_REVEALS_MODULE_P |
| 197 | (OURPROG_INLINE)'' is TRUE so it includes ourprog.c. |
| 198 | |
| 199 | Consequently, all the code in ourprog.c is visible and static in |
| 200 | the file altprog.c |
| 201 | |
| 202 | |
| 203 | |
| 204 | H_REVEALS_MODULE (our includes our): |
| 205 | |
| 206 | |
| 207 | ourprog.c defines OURPROG_C and then includes sim-inline.h. |
| 208 | |
| 209 | In sim-inline.h the term `` ! defined (OURPROG_C) '' is FALSE so |
| 210 | it defines *_OURPROG as non-static and EXTERN_OURPROG_P as TRUE. |
| 211 | |
| 212 | ourprog.c includes ourprog.h. |
| 213 | |
| 214 | In ourprog.h the expression ``H_REVEALS_MODULE_P |
| 215 | (OURPROG_INLINE)'' is true so it includes ourprog.c. |
| 216 | |
| 217 | In ourprog.c (second include) the expression defined (OURPROG_C) |
| 218 | and so the body is not re-included. |
| 219 | |
| 220 | Consequently, ourprog.o will contain a non-static copy of all |
| 221 | the exported symbols. |
| 222 | |
| 223 | |
| 224 | |
| 225 | C_REVEALS_MODULE (alt includes our): |
| 226 | |
| 227 | |
| 228 | altprog.c defines ALTPROG_C and then includes sim-inline.c |
| 229 | |
| 230 | sim-inline.c defines C_INLINE_C and then includes sim-inline.h |
| 231 | |
| 232 | In sim-inline.h the expression `` defined (SIM_INLINE) && ! |
| 233 | defined (OURPROG_C) && REVEAL_MODULE_P (OURPROG_INLINE) '' is |
| 234 | true so it defines *_OURPROG as static and EXTERN_OURPROG_P as |
| 235 | FALSE. |
| 236 | |
| 237 | In sim-inline.c the expression ``C_REVEALS_MODULE_P |
| 238 | (OURPROG_INLINE)'' is true so it includes ourprog.c. |
| 239 | |
| 240 | Consequently, all the code in ourprog.c is visible and static in |
| 241 | the file altprog.c. |
| 242 | |
| 243 | |
| 244 | |
| 245 | C_REVEALS_MODULE (our includes our): |
| 246 | |
| 247 | |
| 248 | ourprog.c defines OURPROG_C and then includes sim-inline.c |
| 249 | |
| 250 | sim-inline.c defines C_INLINE_C and then includes sim-inline.h |
| 251 | |
| 252 | In sim-inline.h the term `` ! defined (OURPROG_C) '' is FALSE |
| 253 | so it defines *_OURPROG as non-static and EXTERN_OURPROG_P as |
| 254 | TRUE. |
| 255 | |
| 256 | Consequently, ourprog.o will contain a non-static copy of all |
| 257 | the exported symbols. |
| 258 | |
| 259 | |
| 260 | |
| 261 | REALITY CHECK: |
| 262 | |
| 263 | This is not for the faint hearted. I've seen GCC get up to 500mb |
| 264 | trying to compile what this can create. */ |
| 265 | \f |
| 266 | #define H_REVEALS_MODULE 1 |
| 267 | #define C_REVEALS_MODULE 2 |
| 268 | #define INLINE_GLOBALS 4 |
| 269 | #define INLINE_LOCALS 8 |
| 270 | |
| 271 | #define REGPARM_MODULE 32 |
| 272 | |
| 273 | #define ALL_H_INLINE (H_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS) |
| 274 | #define ALL_C_INLINE (C_REVEALS_MODULE | INLINE_GLOBALS | INLINE_LOCALS) |
| 275 | |
| 276 | |
| 277 | /* Default macro to simplify control several of key the inlines */ |
| 278 | |
| 279 | #ifndef DEFAULT_INLINE |
| 280 | #define DEFAULT_INLINE INLINE_LOCALS |
| 281 | #endif |
| 282 | |
| 283 | #define REVEAL_MODULE_P(X) (X & (H_REVEALS_MODULE | C_REVEALS_MODULE)) |
| 284 | #define H_REVEALS_MODULE_P(X) ((X & H_REVEALS_MODULE)) |
| 285 | #define C_REVEALS_MODULE_P(X) ((X & C_REVEALS_MODULE)) |
| 286 | |
| 287 | |
| 288 | #ifndef HAVE_INLINE |
| 289 | #ifdef __GNUC__ |
| 290 | #define HAVE_INLINE |
| 291 | #endif |
| 292 | #endif |
| 293 | |
| 294 | |
| 295 | /* Your compilers inline prefix */ |
| 296 | |
| 297 | #ifndef INLINE |
| 298 | #if defined (__GNUC__) && defined (__OPTIMIZE__) |
| 299 | #define INLINE __inline__ |
| 300 | #else |
| 301 | #define INLINE /*inline*/ |
| 302 | #endif |
| 303 | #endif |
| 304 | |
| 305 | /* ??? Temporary, pending decision to always use extern inline and do a vast |
| 306 | cleanup of inline support. */ |
| 307 | #ifndef INLINE2 |
| 308 | #if defined (__GNUC__) |
| 309 | #define INLINE2 __inline__ |
| 310 | #else |
| 311 | #define INLINE2 /*inline*/ |
| 312 | #endif |
| 313 | #endif |
| 314 | |
| 315 | |
| 316 | /* Your compiler's static inline prefix */ |
| 317 | |
| 318 | #ifndef STATIC_INLINE |
| 319 | #define STATIC_INLINE static INLINE |
| 320 | #endif |
| 321 | |
| 322 | |
| 323 | /* Your compiler's extern inline prefix */ |
| 324 | |
| 325 | #ifndef EXTERN_INLINE |
| 326 | #define EXTERN_INLINE extern INLINE2 |
| 327 | #endif |
| 328 | |
| 329 | |
| 330 | /* Your compiler's no-return reserved word */ |
| 331 | |
| 332 | #ifndef NORETURN |
| 333 | #define NORETURN |
| 334 | #endif |
| 335 | |
| 336 | |
| 337 | |
| 338 | /* Your compilers's unused reserved word */ |
| 339 | |
| 340 | #if !defined (UNUSED) |
| 341 | #if (!defined (__GNUC__) \ |
| 342 | || (__GNUC__ < 2) \ |
| 343 | || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)) |
| 344 | #define UNUSED |
| 345 | #else |
| 346 | #define UNUSED __attribute__((__unused__)) |
| 347 | #endif |
| 348 | #endif |
| 349 | |
| 350 | |
| 351 | |
| 352 | |
| 353 | /* Your compilers nonstandard function call mechanism prefix */ |
| 354 | |
| 355 | #if !defined REGPARM |
| 356 | #if defined (__GNUC__) && (defined (__i386__) || defined (__i486__) || defined (__i586__) || defined (__i686__)) |
| 357 | #if (WITH_REGPARM && WITH_STDCALL) |
| 358 | #define REGPARM __attribute__((__regparm__(WITH_REGPARM),__stdcall__)) |
| 359 | #else |
| 360 | #if (WITH_REGPARM && !WITH_STDCALL) |
| 361 | #define REGPARM __attribute__((__regparm__(WITH_REGPARM))) |
| 362 | #else |
| 363 | #if (!WITH_REGPARM && WITH_STDCALL) |
| 364 | #define REGPARM __attribute__((__stdcall__)) |
| 365 | #endif |
| 366 | #endif |
| 367 | #endif |
| 368 | #endif |
| 369 | #endif |
| 370 | |
| 371 | #if !defined REGPARM |
| 372 | #define REGPARM |
| 373 | #endif |
| 374 | |
| 375 | |
| 376 | \f |
| 377 | /* ***** |
| 378 | sim-bits and sim-endian are treated differently from the rest |
| 379 | of the modules below. Their default value is ALL_H_INLINE. |
| 380 | The rest are ALL_C_INLINE. Don't blink, you'll miss it! |
| 381 | ***** |
| 382 | */ |
| 383 | |
| 384 | /* sim-bits */ |
| 385 | |
| 386 | #if !defined (SIM_BITS_INLINE) && (DEFAULT_INLINE) |
| 387 | # define SIM_BITS_INLINE (ALL_H_INLINE) |
| 388 | #endif |
| 389 | |
| 390 | #if (SIM_BITS_INLINE & REGPARM_MODULE) |
| 391 | # define REGPARM_SIM_BITS REGPARM |
| 392 | #else |
| 393 | # define REGPARM_SIM_BITS |
| 394 | #endif |
| 395 | |
| 396 | #if ((H_REVEALS_MODULE_P (SIM_BITS_INLINE) || defined (SIM_INLINE_C)) \ |
| 397 | && !defined (SIM_BITS_C) \ |
| 398 | && (REVEAL_MODULE_P (SIM_BITS_INLINE))) |
| 399 | # if (SIM_BITS_INLINE & INLINE_GLOBALS) |
| 400 | # define INLINE_SIM_BITS(TYPE) static INLINE TYPE UNUSED |
| 401 | # define EXTERN_SIM_BITS_P 0 |
| 402 | # else |
| 403 | # define INLINE_SIM_BITS(TYPE) static TYPE UNUSED REGPARM_SIM_BITS |
| 404 | # define EXTERN_SIM_BITS_P 0 |
| 405 | # endif |
| 406 | #else |
| 407 | # define INLINE_SIM_BITS(TYPE) TYPE REGPARM_SIM_BITS |
| 408 | # define EXTERN_SIM_BITS_P 1 |
| 409 | #endif |
| 410 | |
| 411 | #if (SIM_BITS_INLINE & INLINE_LOCALS) |
| 412 | # define STATIC_INLINE_SIM_BITS(TYPE) static INLINE TYPE |
| 413 | #else |
| 414 | # define STATIC_INLINE_SIM_BITS(TYPE) static TYPE REGPARM_SIM_BITS |
| 415 | #endif |
| 416 | |
| 417 | #define STATIC_SIM_BITS(TYPE) static TYPE |
| 418 | |
| 419 | |
| 420 | |
| 421 | /* sim-core */ |
| 422 | |
| 423 | #if !defined (SIM_CORE_INLINE) && (DEFAULT_INLINE) |
| 424 | # define SIM_CORE_INLINE ALL_C_INLINE |
| 425 | #endif |
| 426 | |
| 427 | #if (SIM_CORE_INLINE & REGPARM_MODULE) |
| 428 | # define REGPARM_SIM_CORE REGPARM |
| 429 | #else |
| 430 | # define REGPARM_SIM_CORE |
| 431 | #endif |
| 432 | |
| 433 | #if ((H_REVEALS_MODULE_P (SIM_CORE_INLINE) || defined (SIM_INLINE_C)) \ |
| 434 | && !defined (SIM_CORE_C) \ |
| 435 | && (REVEAL_MODULE_P (SIM_CORE_INLINE))) |
| 436 | # if (SIM_CORE_INLINE & INLINE_GLOBALS) |
| 437 | # define INLINE_SIM_CORE(TYPE) static INLINE TYPE UNUSED |
| 438 | # define EXTERN_SIM_CORE_P 0 |
| 439 | #else |
| 440 | # define INLINE_SIM_CORE(TYPE) static TYPE UNUSED REGPARM_SIM_CORE |
| 441 | # define EXTERN_SIM_CORE_P 0 |
| 442 | #endif |
| 443 | #else |
| 444 | # define INLINE_SIM_CORE(TYPE) TYPE REGPARM_SIM_CORE |
| 445 | # define EXTERN_SIM_CORE_P 1 |
| 446 | #endif |
| 447 | |
| 448 | #if (SIM_CORE_INLINE & INLINE_LOCALS) |
| 449 | # define STATIC_INLINE_SIM_CORE(TYPE) static INLINE TYPE |
| 450 | #else |
| 451 | # define STATIC_INLINE_SIM_CORE(TYPE) static TYPE REGPARM_SIM_CORE |
| 452 | #endif |
| 453 | |
| 454 | #define STATIC_SIM_CORE(TYPE) static TYPE |
| 455 | |
| 456 | |
| 457 | |
| 458 | /* sim-endian */ |
| 459 | |
| 460 | #if !defined (SIM_ENDIAN_INLINE) && (DEFAULT_INLINE) |
| 461 | # define SIM_ENDIAN_INLINE ALL_H_INLINE |
| 462 | #endif |
| 463 | |
| 464 | #if (SIM_ENDIAN_INLINE & REGPARM_MODULE) |
| 465 | # define REGPARM_SIM_ENDIAN REGPARM |
| 466 | #else |
| 467 | # define REGPARM_SIM_ENDIAN |
| 468 | #endif |
| 469 | |
| 470 | #if ((H_REVEALS_MODULE_P (SIM_ENDIAN_INLINE) || defined (SIM_INLINE_C)) \ |
| 471 | && !defined (SIM_ENDIAN_C) \ |
| 472 | && (REVEAL_MODULE_P (SIM_ENDIAN_INLINE))) |
| 473 | # if (SIM_ENDIAN_INLINE & INLINE_GLOBALS) |
| 474 | # define INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE UNUSED |
| 475 | # define EXTERN_SIM_ENDIAN_P 0 |
| 476 | # else |
| 477 | # define INLINE_SIM_ENDIAN(TYPE) static TYPE UNUSED REGPARM_SIM_ENDIAN |
| 478 | # define EXTERN_SIM_ENDIAN_P 0 |
| 479 | # endif |
| 480 | #else |
| 481 | # define INLINE_SIM_ENDIAN(TYPE) TYPE REGPARM_SIM_ENDIAN |
| 482 | # define EXTERN_SIM_ENDIAN_P 1 |
| 483 | #endif |
| 484 | |
| 485 | #if (SIM_ENDIAN_INLINE & INLINE_LOCALS) |
| 486 | # define STATIC_INLINE_SIM_ENDIAN(TYPE) static INLINE TYPE |
| 487 | #else |
| 488 | # define STATIC_INLINE_SIM_ENDIAN(TYPE) static TYPE REGPARM_SIM_ENDIAN |
| 489 | #endif |
| 490 | |
| 491 | #define STATIC_SIM_ENDIAN(TYPE) static TYPE |
| 492 | |
| 493 | |
| 494 | |
| 495 | /* sim-events */ |
| 496 | |
| 497 | #if !defined (SIM_EVENTS_INLINE) && (DEFAULT_INLINE) |
| 498 | # define SIM_EVENTS_INLINE ALL_C_INLINE |
| 499 | #endif |
| 500 | |
| 501 | #if (SIM_EVENTS_INLINE & REGPARM_MODULE) |
| 502 | # define REGPARM_SIM_EVENTS REGPARM |
| 503 | #else |
| 504 | # define REGPARM_SIM_EVENTS |
| 505 | #endif |
| 506 | |
| 507 | #if ((H_REVEALS_MODULE_P (SIM_EVENTS_INLINE) || defined (SIM_INLINE_C)) \ |
| 508 | && !defined (SIM_EVENTS_C) \ |
| 509 | && (REVEAL_MODULE_P (SIM_EVENTS_INLINE))) |
| 510 | # if (SIM_EVENTS_INLINE & INLINE_GLOBALS) |
| 511 | # define INLINE_SIM_EVENTS(TYPE) static INLINE TYPE UNUSED |
| 512 | # define EXTERN_SIM_EVENTS_P 0 |
| 513 | # else |
| 514 | # define INLINE_SIM_EVENTS(TYPE) static TYPE UNUSED REGPARM_SIM_EVENTS |
| 515 | # define EXTERN_SIM_EVENTS_P 0 |
| 516 | # endif |
| 517 | #else |
| 518 | # define INLINE_SIM_EVENTS(TYPE) TYPE REGPARM_SIM_EVENTS |
| 519 | # define EXTERN_SIM_EVENTS_P 1 |
| 520 | #endif |
| 521 | |
| 522 | #if (SIM_EVENTS_INLINE & INLINE_LOCALS) |
| 523 | # define STATIC_INLINE_SIM_EVENTS(TYPE) static INLINE TYPE |
| 524 | #else |
| 525 | # define STATIC_INLINE_SIM_EVENTS(TYPE) static TYPE REGPARM_SIM_EVENTS |
| 526 | #endif |
| 527 | |
| 528 | #define STATIC_SIM_EVENTS(TYPE) static TYPE |
| 529 | |
| 530 | |
| 531 | |
| 532 | /* sim-fpu */ |
| 533 | |
| 534 | #if !defined (SIM_FPU_INLINE) && (DEFAULT_INLINE) |
| 535 | # define SIM_FPU_INLINE ALL_C_INLINE |
| 536 | #endif |
| 537 | |
| 538 | #if (SIM_FPU_INLINE & REGPARM_MODULE) |
| 539 | # define REGPARM_SIM_FPU REGPARM |
| 540 | #else |
| 541 | # define REGPARM_SIM_FPU |
| 542 | #endif |
| 543 | |
| 544 | #if ((H_REVEALS_MODULE_P (SIM_FPU_INLINE) || defined (SIM_INLINE_C)) \ |
| 545 | && !defined (SIM_FPU_C) \ |
| 546 | && (REVEAL_MODULE_P (SIM_FPU_INLINE))) |
| 547 | # if (SIM_FPU_INLINE & INLINE_GLOBALS) |
| 548 | # define INLINE_SIM_FPU(TYPE) static INLINE TYPE UNUSED |
| 549 | # define EXTERN_SIM_FPU_P 0 |
| 550 | # else |
| 551 | # define INLINE_SIM_FPU(TYPE) static TYPE UNUSED REGPARM_SIM_FPU |
| 552 | # define EXTERN_SIM_FPU_P 0 |
| 553 | # endif |
| 554 | #else |
| 555 | # define INLINE_SIM_FPU(TYPE) TYPE REGPARM_SIM_FPU |
| 556 | # define EXTERN_SIM_FPU_P 1 |
| 557 | #endif |
| 558 | |
| 559 | #if (SIM_FPU_INLINE & INLINE_LOCALS) |
| 560 | # define STATIC_INLINE_SIM_FPU(TYPE) static INLINE TYPE |
| 561 | #else |
| 562 | # define STATIC_INLINE_SIM_FPU(TYPE) static TYPE REGPARM_SIM_FPU |
| 563 | #endif |
| 564 | |
| 565 | #define STATIC_SIM_FPU(TYPE) static TYPE |
| 566 | |
| 567 | |
| 568 | |
| 569 | /* sim-types */ |
| 570 | |
| 571 | #if (SIM_TYPES_INLINE & REGPARM_MODULE) |
| 572 | # define REGPARM_SIM_TYPES REGPARM |
| 573 | #else |
| 574 | # define REGPARM_SIM_TYPES |
| 575 | #endif |
| 576 | |
| 577 | #if ((H_REVEALS_MODULE_P (SIM_TYPES_INLINE) || defined (SIM_INLINE_C)) \ |
| 578 | && !defined (SIM_TYPES_C) \ |
| 579 | && (REVEAL_MODULE_P (SIM_TYPES_INLINE))) |
| 580 | # if (SIM_TYPES_INLINE & INLINE_GLOBALS) |
| 581 | # define INLINE_SIM_TYPES(TYPE) static INLINE TYPE UNUSED |
| 582 | # define EXTERN_SIM_TYPES_P 0 |
| 583 | # else |
| 584 | # define INLINE_SIM_TYPES(TYPE) static TYPE UNUSED REGPARM_SIM_TYPES |
| 585 | # define EXTERN_SIM_TYPES_P 0 |
| 586 | # endif |
| 587 | #else |
| 588 | # define INLINE_SIM_TYPES(TYPE) TYPE REGPARM_SIM_TYPES |
| 589 | # define EXTERN_SIM_TYPES_P 1 |
| 590 | #endif |
| 591 | |
| 592 | #if (SIM_TYPES_INLINE & INLINE_LOCALS) |
| 593 | # define STATIC_INLINE_SIM_TYPES(TYPE) static INLINE TYPE |
| 594 | #else |
| 595 | # define STATIC_INLINE_SIM_TYPES(TYPE) static TYPE REGPARM_SIM_TYPES |
| 596 | #endif |
| 597 | |
| 598 | #define STATIC_SIM_TYPES(TYPE) static TYPE |
| 599 | |
| 600 | |
| 601 | |
| 602 | /* sim_main */ |
| 603 | |
| 604 | #if !defined (SIM_MAIN_INLINE) && (DEFAULT_INLINE) |
| 605 | # define SIM_MAIN_INLINE (ALL_C_INLINE) |
| 606 | #endif |
| 607 | |
| 608 | #if (SIM_MAIN_INLINE & REGPARM_MODULE) |
| 609 | # define REGPARM_SIM_MAIN REGPARM |
| 610 | #else |
| 611 | # define REGPARM_SIM_MAIN |
| 612 | #endif |
| 613 | |
| 614 | #if ((H_REVEALS_MODULE_P (SIM_MAIN_INLINE) || defined (SIM_INLINE_C)) \ |
| 615 | && !defined (SIM_MAIN_C) \ |
| 616 | && (REVEAL_MODULE_P (SIM_MAIN_INLINE))) |
| 617 | # if (SIM_MAIN_INLINE & INLINE_GLOBALS) |
| 618 | # define INLINE_SIM_MAIN(TYPE) static INLINE TYPE UNUSED |
| 619 | # define EXTERN_SIM_MAIN_P 0 |
| 620 | # else |
| 621 | # define INLINE_SIM_MAIN(TYPE) static TYPE UNUSED REGPARM_SIM_MAIN |
| 622 | # define EXTERN_SIM_MAIN_P 0 |
| 623 | # endif |
| 624 | #else |
| 625 | # define INLINE_SIM_MAIN(TYPE) TYPE REGPARM_SIM_MAIN |
| 626 | # define EXTERN_SIM_MAIN_P 1 |
| 627 | #endif |
| 628 | |
| 629 | #if (SIM_MAIN_INLINE & INLINE_LOCALS) |
| 630 | # define STATIC_INLINE_SIM_MAIN(TYPE) static INLINE TYPE |
| 631 | #else |
| 632 | # define STATIC_INLINE_SIM_MAIN(TYPE) static TYPE REGPARM_SIM_MAIN |
| 633 | #endif |
| 634 | |
| 635 | #define STATIC_SIM_MAIN(TYPE) static TYPE |
| 636 | \f |
| 637 | /* engine */ |
| 638 | |
| 639 | #if (ENGINE_INLINE & REGPARM_MODULE) |
| 640 | # define REGPARM_ENGINE REGPARM |
| 641 | #else |
| 642 | # define REGPARM_ENGINE |
| 643 | #endif |
| 644 | |
| 645 | #if ((H_REVEALS_MODULE_P (ENGINE_INLINE) || defined (SIM_INLINE_C)) \ |
| 646 | && !defined (ENGINE_C) \ |
| 647 | && (REVEAL_MODULE_P (ENGINE_INLINE))) |
| 648 | # if (ENGINE_INLINE & INLINE_GLOBALS) |
| 649 | # define INLINE_ENGINE(TYPE) static INLINE TYPE UNUSED |
| 650 | # define EXTERN_ENGINE_P 0 |
| 651 | # else |
| 652 | # define INLINE_ENGINE(TYPE) static TYPE UNUSED REGPARM_ENGINE |
| 653 | # define EXTERN_ENGINE_P 0 |
| 654 | # endif |
| 655 | #else |
| 656 | # define INLINE_ENGINE(TYPE) TYPE REGPARM_ENGINE |
| 657 | # define EXTERN_ENGINE_P 1 |
| 658 | #endif |
| 659 | |
| 660 | #if (ENGINE_INLINE & INLINE_LOCALS) |
| 661 | # define STATIC_INLINE_ENGINE(TYPE) static INLINE TYPE |
| 662 | #else |
| 663 | # define STATIC_INLINE_ENGINE(TYPE) static TYPE REGPARM_ENGINE |
| 664 | #endif |
| 665 | |
| 666 | #define STATIC_ENGINE(TYPE) static TYPE |
| 667 | |
| 668 | |
| 669 | |
| 670 | /* icache */ |
| 671 | |
| 672 | #if (ICACHE_INLINE & REGPARM_MODULE) |
| 673 | # define REGPARM_ICACHE REGPARM |
| 674 | #else |
| 675 | # define REGPARM_ICACHE |
| 676 | #endif |
| 677 | |
| 678 | #if ((H_REVEALS_MODULE_P (ICACHE_INLINE) || defined (SIM_INLINE_C)) \ |
| 679 | && !defined (ICACHE_C) \ |
| 680 | && (REVEAL_MODULE_P (ICACHE_INLINE))) |
| 681 | # if (ICACHE_INLINE & INLINE_GLOBALS) |
| 682 | # define INLINE_ICACHE(TYPE) static INLINE TYPE UNUSED |
| 683 | # define EXTERN_ICACHE_P 0 |
| 684 | #else |
| 685 | # define INLINE_ICACHE(TYPE) static TYPE UNUSED REGPARM_ICACHE |
| 686 | # define EXTERN_ICACHE_P 0 |
| 687 | #endif |
| 688 | #else |
| 689 | # define INLINE_ICACHE(TYPE) TYPE REGPARM_ICACHE |
| 690 | # define EXTERN_ICACHE_P 1 |
| 691 | #endif |
| 692 | |
| 693 | #if (ICACHE_INLINE & INLINE_LOCALS) |
| 694 | # define STATIC_INLINE_ICACHE(TYPE) static INLINE TYPE |
| 695 | #else |
| 696 | # define STATIC_INLINE_ICACHE(TYPE) static TYPE REGPARM_ICACHE |
| 697 | #endif |
| 698 | |
| 699 | #define STATIC_ICACHE(TYPE) static TYPE |
| 700 | |
| 701 | |
| 702 | |
| 703 | /* idecode */ |
| 704 | |
| 705 | #if (IDECODE_INLINE & REGPARM_MODULE) |
| 706 | # define REGPARM_IDECODE REGPARM |
| 707 | #else |
| 708 | # define REGPARM_IDECODE |
| 709 | #endif |
| 710 | |
| 711 | #if ((H_REVEALS_MODULE_P (IDECODE_INLINE) || defined (SIM_INLINE_C)) \ |
| 712 | && !defined (IDECODE_C) \ |
| 713 | && (REVEAL_MODULE_P (IDECODE_INLINE))) |
| 714 | # if (IDECODE_INLINE & INLINE_GLOBALS) |
| 715 | # define INLINE_IDECODE(TYPE) static INLINE TYPE UNUSED |
| 716 | # define EXTERN_IDECODE_P 0 |
| 717 | #else |
| 718 | # define INLINE_IDECODE(TYPE) static TYPE UNUSED REGPARM_IDECODE |
| 719 | # define EXTERN_IDECODE_P 0 |
| 720 | #endif |
| 721 | #else |
| 722 | # define INLINE_IDECODE(TYPE) TYPE REGPARM_IDECODE |
| 723 | # define EXTERN_IDECODE_P 1 |
| 724 | #endif |
| 725 | |
| 726 | #if (IDECODE_INLINE & INLINE_LOCALS) |
| 727 | # define STATIC_INLINE_IDECODE(TYPE) static INLINE TYPE |
| 728 | #else |
| 729 | # define STATIC_INLINE_IDECODE(TYPE) static TYPE REGPARM_IDECODE |
| 730 | #endif |
| 731 | |
| 732 | #define STATIC_IDECODE(TYPE) static TYPE |
| 733 | |
| 734 | |
| 735 | |
| 736 | /* semantics */ |
| 737 | |
| 738 | #if (SEMANTICS_INLINE & REGPARM_MODULE) |
| 739 | # define REGPARM_SEMANTICS REGPARM |
| 740 | #else |
| 741 | # define REGPARM_SEMANTICS |
| 742 | #endif |
| 743 | |
| 744 | #if ((H_REVEALS_MODULE_P (SEMANTICS_INLINE) || defined (SIM_INLINE_C)) \ |
| 745 | && !defined (SEMANTICS_C) \ |
| 746 | && (REVEAL_MODULE_P (SEMANTICS_INLINE))) |
| 747 | # if (SEMANTICS_INLINE & INLINE_GLOBALS) |
| 748 | # define INLINE_SEMANTICS(TYPE) static INLINE TYPE UNUSED |
| 749 | # define EXTERN_SEMANTICS_P 0 |
| 750 | #else |
| 751 | # define INLINE_SEMANTICS(TYPE) static TYPE UNUSED REGPARM_SEMANTICS |
| 752 | # define EXTERN_SEMANTICS_P 0 |
| 753 | #endif |
| 754 | #else |
| 755 | # define INLINE_SEMANTICS(TYPE) TYPE REGPARM_SEMANTICS |
| 756 | # define EXTERN_SEMANTICS_P 1 |
| 757 | #endif |
| 758 | |
| 759 | #if EXTERN_SEMANTICS_P |
| 760 | # define EXTERN_SEMANTICS(TYPE) TYPE REGPARM_SEMANTICS |
| 761 | #else |
| 762 | # define EXTERN_SEMANTICS(TYPE) static TYPE UNUSED REGPARM_SEMANTICS |
| 763 | #endif |
| 764 | |
| 765 | #if (SEMANTICS_INLINE & INLINE_LOCALS) |
| 766 | # define STATIC_INLINE_SEMANTICS(TYPE) static INLINE TYPE |
| 767 | #else |
| 768 | # define STATIC_INLINE_SEMANTICS(TYPE) static TYPE REGPARM_SEMANTICS |
| 769 | #endif |
| 770 | |
| 771 | #define STATIC_SEMANTICS(TYPE) static TYPE |
| 772 | |
| 773 | |
| 774 | |
| 775 | /* support */ |
| 776 | |
| 777 | #if !defined (SUPPORT_INLINE) && (DEFAULT_INLINE) |
| 778 | # define SUPPORT_INLINE ALL_C_INLINE |
| 779 | #endif |
| 780 | |
| 781 | #if (SUPPORT_INLINE & REGPARM_MODULE) |
| 782 | # define REGPARM_SUPPORT REGPARM |
| 783 | #else |
| 784 | # define REGPARM_SUPPORT |
| 785 | #endif |
| 786 | |
| 787 | #if ((H_REVEALS_MODULE_P (SUPPORT_INLINE) || defined (SIM_INLINE_C)) \ |
| 788 | && !defined (SUPPORT_C) \ |
| 789 | && (REVEAL_MODULE_P (SUPPORT_INLINE))) |
| 790 | # if (SUPPORT_INLINE & INLINE_GLOBALS) |
| 791 | # define INLINE_SUPPORT(TYPE) static INLINE TYPE UNUSED |
| 792 | # define EXTERN_SUPPORT_P 0 |
| 793 | #else |
| 794 | # define INLINE_SUPPORT(TYPE) static TYPE UNUSED REGPARM_SUPPORT |
| 795 | # define EXTERN_SUPPORT_P 0 |
| 796 | #endif |
| 797 | #else |
| 798 | # define INLINE_SUPPORT(TYPE) TYPE REGPARM_SUPPORT |
| 799 | # define EXTERN_SUPPORT_P 1 |
| 800 | #endif |
| 801 | |
| 802 | #if (SUPPORT_INLINE & INLINE_LOCALS) |
| 803 | # define STATIC_INLINE_SUPPORT(TYPE) static INLINE TYPE |
| 804 | #else |
| 805 | # define STATIC_INLINE_SUPPORT(TYPE) static TYPE REGPARM_SUPPORT |
| 806 | #endif |
| 807 | |
| 808 | #define STATIC_SUPPORT(TYPE) static TYPE |
| 809 | |
| 810 | |
| 811 | |
| 812 | #endif |