procinfo.pas 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. Information about the current procedure that is being compiled
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit procinfo;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. { common }
  23. cclasses,
  24. { global }
  25. globtype,globals,verbose,
  26. { symtable }
  27. symconst,symtype,symdef,symsym,
  28. { aasm }
  29. cpubase,cpuinfo,cgbase,
  30. aasmbase,aasmtai
  31. ;
  32. const
  33. inherited_inlining_flags : tprocinfoflags = [pi_do_call];
  34. type
  35. {# This object gives information on the current routine being
  36. compiled.
  37. }
  38. tprocinfo = class(tlinkedlistitem)
  39. { pointer to parent in nested procedures }
  40. parent : tprocinfo;
  41. {# the definition of the routine itself }
  42. procdef : tprocdef;
  43. { procinfo of the main procedure that is inlining
  44. the current function, only used in tcgcallnode.inlined_pass2 }
  45. inlining_procinfo : tprocinfo;
  46. { file location of begin of procedure }
  47. entrypos : tfileposinfo;
  48. { file location of end of procedure }
  49. exitpos : tfileposinfo;
  50. { local switches at begin of procedure }
  51. entryswitches : tlocalswitches;
  52. { local switches at end of procedure }
  53. exitswitches : tlocalswitches;
  54. { Size of the parameters on the stack }
  55. para_stack_size : longint;
  56. { Offset of temp after para/local are allocated }
  57. tempstart : longint;
  58. {# some collected informations about the procedure
  59. see pi_xxxx constants above
  60. }
  61. flags : tprocinfoflags;
  62. { register used as frame pointer }
  63. framepointer : tregister;
  64. { register containing currently the got }
  65. got : tregister;
  66. { Holds the reference used to store alll saved registers. }
  67. save_regs_ref : treference;
  68. { label to leave the sub routine }
  69. aktexitlabel : tasmlabel;
  70. {# The code for the routine itself, excluding entry and
  71. exit code. This is a linked list of tai classes.
  72. }
  73. aktproccode : taasmoutput;
  74. { Data (like jump tables) that belongs to this routine }
  75. aktlocaldata : taasmoutput;
  76. { max. of space need for parameters }
  77. maxpushedparasize : aword;
  78. constructor create(aparent:tprocinfo);virtual;
  79. destructor destroy;override;
  80. procedure allocate_push_parasize(size:longint);virtual;
  81. function calc_stackframe_size:longint;virtual;
  82. { Set the address of the first temp, can be used to allocate
  83. space for pushing parameters }
  84. procedure set_first_temp_offset;virtual;
  85. { Generate parameter information }
  86. procedure generate_parameter_info;virtual;
  87. end;
  88. tcprocinfo = class of tprocinfo;
  89. var
  90. cprocinfo : tcprocinfo;
  91. { information about the current sub routine being parsed (@var(pprocinfo))}
  92. current_procinfo : tprocinfo;
  93. implementation
  94. uses
  95. cutils,systems,
  96. tgobj,cgutils,cgobj,
  97. paramgr
  98. ;
  99. {****************************************************************************
  100. TProcInfo
  101. ****************************************************************************}
  102. constructor tprocinfo.create(aparent:tprocinfo);
  103. begin
  104. parent:=aparent;
  105. procdef:=nil;
  106. para_stack_size:=0;
  107. flags:=[];
  108. framepointer:=NR_FRAME_POINTER_REG;
  109. { asmlists }
  110. aktproccode:=Taasmoutput.Create;
  111. aktlocaldata:=Taasmoutput.Create;
  112. reference_reset(save_regs_ref);
  113. { labels }
  114. objectlibrary.getlabel(aktexitlabel);
  115. end;
  116. destructor tprocinfo.destroy;
  117. begin
  118. aktproccode.free;
  119. aktlocaldata.free;
  120. end;
  121. procedure tprocinfo.allocate_push_parasize(size:longint);
  122. begin
  123. end;
  124. function tprocinfo.calc_stackframe_size:longint;
  125. begin
  126. result:=Align(tg.direction*tg.lasttemp,aktalignment.localalignmin);
  127. end;
  128. procedure tprocinfo.set_first_temp_offset;
  129. begin
  130. end;
  131. procedure tprocinfo.generate_parameter_info;
  132. begin
  133. { generate callee paraloc register info, it returns the size that
  134. is allocated on the stack }
  135. para_stack_size:=paramanager.create_paraloc_info(procdef,calleeside);
  136. end;
  137. end.
  138. {
  139. $Log$
  140. Revision 1.13 2004-02-27 10:21:05 florian
  141. * top_symbol killed
  142. + refaddr to treference added
  143. + refsymbol to treference added
  144. * top_local stuff moved to an extra record to save memory
  145. + aint introduced
  146. * tppufile.get/putint64/aint implemented
  147. Revision 1.12 2004/02/19 17:07:42 florian
  148. * fixed arg. area calculation
  149. Revision 1.11 2003/12/26 14:02:30 peter
  150. * sparc updates
  151. * use registertype in spill_register
  152. Revision 1.10 2003/12/16 21:29:24 florian
  153. + inlined procedures inherit procinfo flags
  154. Revision 1.9 2003/12/03 23:13:20 peter
  155. * delayed paraloc allocation, a_param_*() gets extra parameter
  156. if it needs to allocate temp or real paralocation
  157. * optimized/simplified int-real loading
  158. Revision 1.8 2003/11/10 22:02:52 peter
  159. * cross unit inlining fixed
  160. Revision 1.7 2003/10/17 14:38:32 peter
  161. * 64k registers supported
  162. * fixed some memory leaks
  163. Revision 1.6 2003/10/14 00:30:48 florian
  164. + some code for PIC support added
  165. Revision 1.5 2003/10/10 17:48:13 peter
  166. * old trgobj moved to x86/rgcpu and renamed to trgx86fpu
  167. * tregisteralloctor renamed to trgobj
  168. * removed rgobj from a lot of units
  169. * moved location_* and reference_* to cgobj
  170. * first things for mmx register allocation
  171. Revision 1.4 2003/10/09 21:31:37 daniel
  172. * Register allocator splitted, ans abstract now
  173. Revision 1.3 2003/10/05 21:21:52 peter
  174. * c style array of const generates callparanodes
  175. * varargs paraloc fixes
  176. Revision 1.2 2003/10/03 22:00:33 peter
  177. * parameter alignment fixes
  178. Revision 1.1 2003/10/01 20:34:49 peter
  179. * procinfo unit contains tprocinfo
  180. * cginfo renamed to cgbase
  181. * moved cgmessage to verbose
  182. * fixed ppc and sparc compiles
  183. }