procinfo.pas 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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,cgutils,
  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. gotlabel : tasmlabel;
  67. { Holds the reference used to store all saved registers. }
  68. save_regs_ref : treference;
  69. { label to leave the sub routine }
  70. aktexitlabel : tasmlabel;
  71. {# The code for the routine itself, excluding entry and
  72. exit code. This is a linked list of tai classes.
  73. }
  74. aktproccode : taasmoutput;
  75. { Data (like jump tables) that belongs to this routine }
  76. aktlocaldata : taasmoutput;
  77. { max. of space need for parameters }
  78. maxpushedparasize : aint;
  79. constructor create(aparent:tprocinfo);virtual;
  80. destructor destroy;override;
  81. procedure allocate_push_parasize(size:longint);virtual;
  82. function calc_stackframe_size:longint;virtual;
  83. { Set the address of the first temp, can be used to allocate
  84. space for pushing parameters }
  85. procedure set_first_temp_offset;virtual;
  86. { Generate parameter information }
  87. procedure generate_parameter_info;virtual;
  88. end;
  89. tcprocinfo = class of tprocinfo;
  90. var
  91. cprocinfo : tcprocinfo;
  92. { information about the current sub routine being parsed (@var(pprocinfo))}
  93. current_procinfo : tprocinfo;
  94. implementation
  95. uses
  96. cutils,systems,
  97. tgobj,cgobj,
  98. paramgr
  99. ;
  100. {****************************************************************************
  101. TProcInfo
  102. ****************************************************************************}
  103. constructor tprocinfo.create(aparent:tprocinfo);
  104. begin
  105. parent:=aparent;
  106. procdef:=nil;
  107. para_stack_size:=0;
  108. flags:=[];
  109. framepointer:=NR_FRAME_POINTER_REG;
  110. maxpushedparasize:=0;
  111. { asmlists }
  112. aktproccode:=Taasmoutput.Create;
  113. aktlocaldata:=Taasmoutput.Create;
  114. reference_reset(save_regs_ref);
  115. { labels }
  116. objectlibrary.getlabel(aktexitlabel);
  117. objectlibrary.getlabel(gotlabel);
  118. end;
  119. destructor tprocinfo.destroy;
  120. begin
  121. aktproccode.free;
  122. aktlocaldata.free;
  123. end;
  124. procedure tprocinfo.allocate_push_parasize(size:longint);
  125. begin
  126. end;
  127. function tprocinfo.calc_stackframe_size:longint;
  128. begin
  129. result:=Align(tg.direction*tg.lasttemp,aktalignment.localalignmin);
  130. end;
  131. procedure tprocinfo.set_first_temp_offset;
  132. begin
  133. end;
  134. procedure tprocinfo.generate_parameter_info;
  135. begin
  136. { generate callee paraloc register info, it returns the size that
  137. is allocated on the stack }
  138. para_stack_size:=paramanager.create_paraloc_info(procdef,calleeside);
  139. end;
  140. end.
  141. {
  142. $Log$
  143. Revision 1.17 2004-10-31 21:45:03 peter
  144. * generic tlocation
  145. * move tlocation to cgutils
  146. Revision 1.16 2004/06/20 08:55:30 florian
  147. * logs truncated
  148. Revision 1.15 2004/06/16 20:07:09 florian
  149. * dwarf branch merged
  150. Revision 1.14.2.2 2004/05/03 20:18:52 peter
  151. * fixes for tprintf
  152. Revision 1.14.2.1 2004/04/27 18:18:26 peter
  153. * aword -> aint
  154. Revision 1.14 2004/03/02 17:32:12 florian
  155. * make cycle fixed
  156. + pic support for darwin
  157. + support of importing vars from shared libs on darwin implemented
  158. Revision 1.13 2004/02/27 10:21:05 florian
  159. * top_symbol killed
  160. + refaddr to treference added
  161. + refsymbol to treference added
  162. * top_local stuff moved to an extra record to save memory
  163. + aint introduced
  164. * tppufile.get/putint64/aint implemented
  165. }