cpupi.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. cgbase,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,
  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:=procdef.parast.address_fixup+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. }
  64. result:=procdef.localst.datasize+tg.gettempsize+savearea;
  65. end;
  66. begin
  67. cprocinfo:=TSparcProcInfo;
  68. end.
  69. {
  70. $Log$
  71. Revision 1.18 2003-07-06 17:58:22 peter
  72. * framepointer fixes for sparc
  73. * parent framepointer code more generic
  74. Revision 1.17 2003/06/13 21:19:32 peter
  75. * current_procdef removed, use current_procinfo.procdef instead
  76. Revision 1.16 2003/05/30 23:57:08 peter
  77. * more sparc cleanup
  78. * accumulator removed, splitted in function_return_reg (called) and
  79. function_result_reg (caller)
  80. Revision 1.15 2003/05/23 22:33:48 florian
  81. * fix some small flaws which prevent sparc linux system unit from compiling
  82. * some reformatting done
  83. Revision 1.14 2003/04/27 11:21:36 peter
  84. * aktprocdef renamed to current_procinfo.procdef
  85. * procinfo renamed to current_procinfo
  86. * procinfo will now be stored in current_module so it can be
  87. cleaned up properly
  88. * gen_main_procsym changed to create_main_proc and release_main_proc
  89. to also generate a tprocinfo structure
  90. * fixed unit implicit initfinal
  91. Revision 1.13 2003/04/27 07:48:05 peter
  92. * updated for removed lexlevel
  93. Revision 1.12 2003/02/06 22:36:55 mazen
  94. * fixing bug related to errornous program main entry stack frame
  95. Revision 1.11 2003/01/05 21:32:35 mazen
  96. * fixing several bugs compiling the RTL
  97. Revision 1.10 2002/12/24 21:30:20 mazen
  98. - some writeln(s) removed in compiler
  99. + many files added to RTL
  100. * some errors fixed in RTL
  101. Revision 1.9 2002/12/21 23:21:47 mazen
  102. + added support for the shift nodes
  103. + added debug output on screen with -an command line option
  104. Revision 1.8 2002/11/17 17:49:09 mazen
  105. + 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
  106. Revision 1.7 2002/11/14 21:42:08 mazen
  107. * fixing return value variable address
  108. Revision 1.6 2002/11/10 19:07:46 mazen
  109. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  110. Revision 1.5 2002/11/03 20:22:40 mazen
  111. * parameter handling updated
  112. Revision 1.4 2002/10/20 19:01:38 mazen
  113. + op_raddr_reg and op_caddr_reg added to fix functions prologue
  114. Revision 1.3 2002/10/10 15:10:39 mazen
  115. * Internal error fixed, but usually i386 parameter model used
  116. Revision 1.2 2002/08/29 11:02:36 mazen
  117. added support for SPARC processors
  118. Revision 1.1 2002/08/23 10:08:28 mazen
  119. *** empty log message ***
  120. Revision 1.2 2002/08/18 20:06:30 peter
  121. * inlining is now also allowed in interface
  122. * renamed write/load to ppuwrite/ppuload
  123. * tnode storing in ppu
  124. * nld,ncon,nbas are already updated for storing in ppu
  125. Revision 1.1 2002/08/17 09:23:49 florian
  126. * first part of procinfo rewrite
  127. }