il.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* I N T E R N A L D A T A S T R U C T U R E S O F
  7. *
  8. * I N L I N E S U B S T I T U T I O N
  9. *
  10. */
  11. typedef struct actual *actual_p;
  12. typedef struct calcnt *calcnt_p;
  13. typedef short call_id;
  14. struct call {
  15. proc_p cl_caller; /* calling procedure */
  16. call_id cl_id; /* uniquely denotes a CAL instruction */
  17. proc_p cl_proc; /* the called procedure */
  18. byte cl_looplevel; /* loop nesting level of the CAL */
  19. bool cl_flags; /* flag bits */
  20. short cl_ratio; /* indicates 'speed gain / size lost' */
  21. call_p cl_cdr; /* link to next call */
  22. call_p cl_car; /* link to nested calls */
  23. actual_p cl_actuals; /* actual parameter expr. trees */
  24. };
  25. #define CLF_INLPARS 017 /* min(15,nr. of inline parameters) */
  26. #define CLF_SELECTED 020 /* is call selected for expansion? */
  27. #define CLF_EVER_EXPANDED 040 /* ever expanded? e.g. in a nested call. */
  28. #define CLF_FIRM 0100 /* indicates if the call takes place in a
  29. * firm block of a loop (i.e. one that
  30. * is always executed, except
  31. * -perhaps- at the last iteration).
  32. * Used for heuristics only.
  33. */
  34. struct actual {
  35. line_p ac_exp; /* copy of EM text */
  36. /* 0 for actuals that are not inline */
  37. offset ac_size; /* number of bytes of parameter */
  38. bool ac_inl; /* TRUE if it may be expanded in line */
  39. actual_p ac_next; /* link */
  40. };
  41. struct formal {
  42. offset f_offset; /* offsetin bytes */
  43. byte f_flags; /* flags FF_BAD etc. */
  44. byte f_type; /* SINGLE, DOUBLE,POINTER,UNKNOWN */
  45. formal_p f_next; /* link */
  46. };
  47. /* flags of formal: */
  48. #define FF_BAD 01
  49. #define FF_REG 02
  50. #define FF_ONCEUSED 04
  51. #define FF_OFTENUSED 06
  52. #define USEMASK 014
  53. /* types of formals: */
  54. #define SINGLE 1
  55. #define DOUBLE 2
  56. #define POINTER 3
  57. #define UNKNOWN 4
  58. /* 'call-count' information keeps track of the number
  59. * of times one procedure calls another. Conceptually,
  60. * it may be regarded as a two dimensional array, where
  61. * calcnt[p,q] is the number of times p calls q. As this
  62. * matrix would be very dense, we use a more efficient
  63. * list representation. Every procedure has a list
  64. * of calcnt structs.
  65. */
  66. struct calcnt {
  67. proc_p cc_proc; /* the called procedure */
  68. short cc_count; /* # times proc. is called in the
  69. * original text of the caller.
  70. */
  71. calcnt_p cc_next; /* link */
  72. };
  73. extern int complete_program;
  74. extern int calnr;
  75. extern calcnt_p cchead; /* calcnt info of current proc */
  76. /* Macro's for extended data structures */
  77. #define P_CALS p_extend->px_il.p_cals
  78. #define P_SIZE p_extend->px_il.p_size
  79. #define P_FORMALS p_extend->px_il.p_formals
  80. #define P_NRCALLED p_extend->px_il.p_nrcalled
  81. #define P_CCADDR p_extend->px_il.p_ccaddr
  82. #define P_LADDR p_extend->px_il.p_laddr
  83. #define P_ORGLABELS p_extend->px_il.p_orglabels
  84. #define P_ORGLOCALS p_extend->px_il.p_orglocals
  85. /* flags2: */
  86. #define PF_UNSUITABLE 01
  87. #define PF_NO_INLPARS 02
  88. #define PF_FALLTHROUGH 04
  89. #define PF_DISPENSABLE 010
  90. #define PF_CHANGED 020
  91. /* kinds of usages: */
  92. #define USE 0
  93. #define CHANGE 1
  94. #define ADDRESS 2
  95. /* We do not expand calls if:
  96. * - the called procedure has to many local variables
  97. * - the calling procedure is already very large
  98. * - the called procedure is to large.
  99. */
  100. #define MANY_LOCALS(p) (p->p_localbytes > LOCAL_THRESHOLD)
  101. #define LOCAL_THRESHOLD 200
  102. #define BIG_CALLER(p) (p->P_SIZE > CALLER_THRESHOLD)
  103. #define CALLER_THRESHOLD 500
  104. #define BIG_PROC(p) (p->P_SIZE > CALLEE_THRESHOLD)
  105. #define CALLEE_THRESHOLD 100
  106. #define FALLTHROUGH(p) (p->p_flags2 & PF_FALLTHROUGH)
  107. #define DISPENSABLE(p) p->p_flags2 |= PF_DISPENSABLE
  108. #define IS_DISPENSABLE(p) (p->p_flags2 & PF_DISPENSABLE)
  109. #define SELECTED(c) c->cl_flags |= CLF_SELECTED
  110. #define IS_SELECTED(c) (c->cl_flags & CLF_SELECTED)
  111. #define EVER_EXPANDED(c) c->cl_flags |= CLF_EVER_EXPANDED
  112. #define IS_EVER_EXPANDED(c) (c->cl_flags & CLF_EVER_EXPANDED)
  113. #define UNSUITABLE(p) p->p_flags2 |= PF_UNSUITABLE
  114. #define SUITABLE(p) (!(p->p_flags2&PF_UNSUITABLE))
  115. #define INLINE_PARS(p) (!(p->p_flags2&PF_NO_INLPARS))
  116. #define PARAMS_UNKNOWN(p) (p->p_nrformals == UNKNOWN_SIZE)
  117. extern int Ssubst;
  118. #ifdef VERBOSE
  119. extern int Senv,Srecursive,Slocals,Sinstrlab,Sparsefails,Spremoved,Scals;
  120. extern int Sbig_caller,Sdispensable,Schangedcallee,Sbigcallee,Sspace,Szeroratio;
  121. #endif
  122. /* extra core-allocation macros */
  123. #define newcall() (call_p) newstruct(call)
  124. #define newactual() (actual_p) newstruct(actual)
  125. #define newformal() (formal_p) newstruct(formal)
  126. #define newcalcnt() (calcnt_p) newstruct(calcnt)
  127. #define newilpx() (pext_p) newstruct(pext_il)
  128. #define oldcall(x) oldstruct(call,x)
  129. #define oldactual(x) oldstruct(actual,x)
  130. #define oldformal(x) oldstruct(formal,x)
  131. #define oldcalcnt(x) oldstruct(calcnt,x)
  132. #define oldilpx(x) oldstruct(pext_il,x)