cpupi.pas 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. { This unit contains the CPU specific part of tprocinfo. }
  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. { overall size of allocated stack space, currently this is used for the
  28. PowerPC only }
  29. LocalSize:aword;
  30. {max of space need for parameters, currently used by the PowerPC port only}
  31. maxpushedparasize:aword;
  32. constructor create(aparent:tprocinfo);override;
  33. { According the the SPARC ABI the standard stack frame must include :
  34. * 16 word save for the in and local registers in case of overflow/underflow.
  35. this save area always must exist at the %o6+0,
  36. * software conventions requires space for the aggregate return value pointer, even if the word is not used,
  37. * althogh the first six words of arguments reside in registers, the standard
  38. stack frame reserves space for them. Arguments beond the sixth reside on the
  39. stack as in the Intel architecture,
  40. * other areas depend on the compiler and the code being compiled. The
  41. standard calling sequence does not define a maximum stack frame size, nor does
  42. it restrict how a language system uses the "unspecified" areas of the standard
  43. stack frame.}
  44. procedure after_header;override;
  45. procedure after_pass1;override;
  46. end;
  47. implementation
  48. uses
  49. tgobj,paramgr,symsym,systems;
  50. constructor TSparcprocinfo.create(aparent:tprocinfo);
  51. begin
  52. inherited create(aparent);
  53. maxpushedparasize:=0;
  54. LocalSize:=(16+1)*4;
  55. {First 16 words are in the frame are used to save registers in case of a
  56. register overflow/underflow.The 17th word is used to save the address of
  57. the variable which will receive the return value of the called function}
  58. // Return_Offset:=16*4;
  59. end;
  60. procedure TSparcprocinfo.after_header;
  61. begin
  62. { this value is necessary for nested procedures }
  63. if assigned(procdef.localst) then
  64. procdef.localst.address_fixup:=align(procdef.parast.address_fixup+procdef.parast.datasize,16);
  65. end;
  66. procedure TSparcProcInfo.after_pass1;
  67. begin
  68. with ProcDef do
  69. begin
  70. {Reserve the stack for copying parameters passed into registers. By
  71. default we reserve space for the 6 input registers if the function had
  72. less parameters. Otherwise, we allocate data sizeof parameters}
  73. if parast.datasize>6*4
  74. then
  75. localst.address_fixup:=parast.address_fixup+parast.datasize
  76. else
  77. procdef.localst.address_fixup:=parast.address_fixup+6*4;
  78. firsttemp_offset:=localst.address_fixup+localst.datasize;
  79. with tg do
  80. begin
  81. SetFirstTemp(firsttemp_offset);
  82. //LastTemp:=firsttemp_offset;
  83. end;
  84. end;
  85. end;
  86. begin
  87. cprocinfo:=TSparcProcInfo;
  88. end.
  89. {
  90. $Log$
  91. Revision 1.17 2003-06-13 21:19:32 peter
  92. * current_procdef removed, use current_procinfo.procdef instead
  93. Revision 1.16 2003/05/30 23:57:08 peter
  94. * more sparc cleanup
  95. * accumulator removed, splitted in function_return_reg (called) and
  96. function_result_reg (caller)
  97. Revision 1.15 2003/05/23 22:33:48 florian
  98. * fix some small flaws which prevent sparc linux system unit from compiling
  99. * some reformatting done
  100. Revision 1.14 2003/04/27 11:21:36 peter
  101. * aktprocdef renamed to current_procinfo.procdef
  102. * procinfo renamed to current_procinfo
  103. * procinfo will now be stored in current_module so it can be
  104. cleaned up properly
  105. * gen_main_procsym changed to create_main_proc and release_main_proc
  106. to also generate a tprocinfo structure
  107. * fixed unit implicit initfinal
  108. Revision 1.13 2003/04/27 07:48:05 peter
  109. * updated for removed lexlevel
  110. Revision 1.12 2003/02/06 22:36:55 mazen
  111. * fixing bug related to errornous program main entry stack frame
  112. Revision 1.11 2003/01/05 21:32:35 mazen
  113. * fixing several bugs compiling the RTL
  114. Revision 1.10 2002/12/24 21:30:20 mazen
  115. - some writeln(s) removed in compiler
  116. + many files added to RTL
  117. * some errors fixed in RTL
  118. Revision 1.9 2002/12/21 23:21:47 mazen
  119. + added support for the shift nodes
  120. + added debug output on screen with -an command line option
  121. Revision 1.8 2002/11/17 17:49:09 mazen
  122. + 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
  123. Revision 1.7 2002/11/14 21:42:08 mazen
  124. * fixing return value variable address
  125. Revision 1.6 2002/11/10 19:07:46 mazen
  126. * SPARC calling mechanism almost OK (as in GCC./mppcsparc )
  127. Revision 1.5 2002/11/03 20:22:40 mazen
  128. * parameter handling updated
  129. Revision 1.4 2002/10/20 19:01:38 mazen
  130. + op_raddr_reg and op_caddr_reg added to fix functions prologue
  131. Revision 1.3 2002/10/10 15:10:39 mazen
  132. * Internal error fixed, but usually i386 parameter model used
  133. Revision 1.2 2002/08/29 11:02:36 mazen
  134. added support for SPARC processors
  135. Revision 1.1 2002/08/23 10:08:28 mazen
  136. *** empty log message ***
  137. Revision 1.2 2002/08/18 20:06:30 peter
  138. * inlining is now also allowed in interface
  139. * renamed write/load to ppuwrite/ppuload
  140. * tnode storing in ppu
  141. * nld,ncon,nbas are already updated for storing in ppu
  142. Revision 1.1 2002/08/17 09:23:49 florian
  143. * first part of procinfo rewrite
  144. }