2
0

cpupi.pas 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. This unit contains the CPU specific part of tprocinfo
  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 cpupi;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. cutils,
  23. procinfo,cpuinfo,
  24. psub;
  25. type
  26. TSparcProcInfo=class(tcgprocinfo)
  27. private
  28. maxpushedparasize : longint;
  29. public
  30. constructor create(aparent:tprocinfo);override;
  31. procedure allocate_push_parasize(size:longint);override;
  32. function calc_stackframe_size:longint;override;
  33. end;
  34. implementation
  35. uses
  36. globtype,systems,globals,
  37. tgobj,paramgr,symconst,symsym;
  38. constructor tsparcprocinfo.create(aparent:tprocinfo);
  39. begin
  40. inherited create(aparent);
  41. maxpushedparasize:=0;
  42. end;
  43. procedure tsparcprocinfo.allocate_push_parasize(size:longint);
  44. begin
  45. if size>maxpushedparasize then
  46. maxpushedparasize:=size;
  47. end;
  48. function TSparcProcInfo.calc_stackframe_size:longint;
  49. var
  50. savearea : longint;
  51. begin
  52. { ABI requires at least space to save 6 arguments }
  53. savearea:=max(maxpushedparasize,6*4);
  54. {
  55. Stackframe layout:
  56. %fp
  57. <locals>
  58. <temp>
  59. <arguments for calling>
  60. <return pointer for calling>
  61. <register window save area for calling>
  62. %sp
  63. Alignment must be the max available, as doubles require
  64. 8 byte alignment
  65. }
  66. result:=Align(tg.direction*tg.lasttemp+savearea+target_info.first_parm_offset,aktalignment.localalignmax);
  67. end;
  68. begin
  69. cprocinfo:=TSparcProcInfo;
  70. end.
  71. {
  72. $Log$
  73. Revision 1.23 2004-01-12 22:11:39 peter
  74. * use localalign info for alignment for locals and temps
  75. * sparc fpu flags branching added
  76. * moved powerpc copy_valye_openarray to generic
  77. Revision 1.22 2003/10/01 20:34:50 peter
  78. * procinfo unit contains tprocinfo
  79. * cginfo renamed to cgbase
  80. * moved cgmessage to verbose
  81. * fixed ppc and sparc compiles
  82. Revision 1.21 2003/09/14 19:19:05 peter
  83. * updates for new ra
  84. Revision 1.20 2003/09/03 15:55:01 peter
  85. * NEWRA branch merged
  86. Revision 1.19.2.1 2003/09/01 21:02:55 peter
  87. * sparc updates for new tregister
  88. Revision 1.19 2003/08/20 17:48:49 peter
  89. * fixed stackalloc to not allocate localst.datasize twice
  90. * order of stackalloc code fixed for implicit init/final
  91. Revision 1.18 2003/07/06 17:58:22 peter
  92. * framepointer fixes for sparc
  93. * parent framepointer code more generic
  94. Revision 1.17 2003/06/13 21:19:32 peter
  95. * current_procdef removed, use current_procinfo.procdef instead
  96. Revision 1.16 2003/05/30 23:57:08 peter
  97. * more sparc cleanup
  98. * accumulator removed, splitted in function_return_reg (called) and
  99. function_result_reg (caller)
  100. Revision 1.15 2003/05/23 22:33:48 florian
  101. * fix some small flaws which prevent sparc linux system unit from compiling
  102. * some reformatting done
  103. Revision 1.14 2003/04/27 11:21:36 peter
  104. * aktprocdef renamed to current_procinfo.procdef
  105. * procinfo renamed to current_procinfo
  106. * procinfo will now be stored in current_module so it can be
  107. cleaned up properly
  108. * gen_main_procsym changed to create_main_proc and release_main_proc
  109. to also generate a tprocinfo structure
  110. * fixed unit implicit initfinal
  111. Revision 1.13 2003/04/27 07:48:05 peter
  112. * updated for removed lexlevel
  113. Revision 1.12 2003/02/06 22:36:55 mazen
  114. * fixing bug related to errornous program main entry stack frame
  115. Revision 1.11 2003/01/05 21:32:35 mazen
  116. * fixing several bugs compiling the RTL
  117. Revision 1.10 2002/12/24 21:30:20 mazen
  118. - some writeln(s) removed in compiler
  119. + many files added to RTL
  120. * some errors fixed in RTL
  121. Revision 1.9 2002/12/21 23:21:47 mazen
  122. + added support for the shift nodes
  123. + added debug output on screen with -an command line option
  124. Revision 1.8 2002/11/17 17:49:09 mazen
  125. + return_result_reg and FUNCTION_RESULT_REG are now used, in all plateforms, to pass functions result between called function and its caller. See the explanation of each one
  126. Revision 1.7 2002/11/14 21:42:08 mazen
  127. * fixing return value variable address
  128. Revision 1.6 2002/11/10 19:07:46 mazen
  129. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  130. Revision 1.5 2002/11/03 20:22:40 mazen
  131. * parameter handling updated
  132. Revision 1.4 2002/10/20 19:01:38 mazen
  133. + op_raddr_reg and op_caddr_reg added to fix functions prologue
  134. Revision 1.3 2002/10/10 15:10:39 mazen
  135. * Internal error fixed, but usually i386 parameter model used
  136. Revision 1.2 2002/08/29 11:02:36 mazen
  137. added support for SPARC processors
  138. Revision 1.1 2002/08/23 10:08:28 mazen
  139. *** empty log message ***
  140. Revision 1.2 2002/08/18 20:06:30 peter
  141. * inlining is now also allowed in interface
  142. * renamed write/load to ppuwrite/ppuload
  143. * tnode storing in ppu
  144. * nld,ncon,nbas are already updated for storing in ppu
  145. Revision 1.1 2002/08/17 09:23:49 florian
  146. * first part of procinfo rewrite
  147. }