cpupi.pas 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. { This unit contains the CPU specific part of tprocinfo. }
  19. unit cpupi;
  20. {$i fpcdefs.inc}
  21. interface
  22. uses
  23. cutils,
  24. procinfo,cpuinfo,psub;
  25. type
  26. tppcprocinfo = class(tcgprocinfo)
  27. { offset where the frame pointer from the outer procedure is stored. }
  28. parent_framepointer_offset : longint;
  29. constructor create(aparent:tprocinfo);override;
  30. procedure set_first_temp_offset;override;
  31. procedure allocate_push_parasize(size: longint);override;
  32. function calc_stackframe_size:longint;override;
  33. end;
  34. implementation
  35. uses
  36. globtype,globals,systems,
  37. cpubase,
  38. aasmtai,
  39. tgobj,
  40. symconst,symsym,paramgr,symutil,
  41. verbose;
  42. constructor tppcprocinfo.create(aparent:tprocinfo);
  43. begin
  44. inherited create(aparent);
  45. maxpushedparasize:=0;
  46. end;
  47. procedure tppcprocinfo.set_first_temp_offset;
  48. var
  49. ofs : aword;
  50. locals: longint;
  51. begin
  52. if not(po_assembler in procdef.procoptions) then
  53. begin
  54. case target_info.abi of
  55. abi_powerpc_aix:
  56. ofs:=align(maxpushedparasize+LinkageAreaSizeAIX,16);
  57. abi_powerpc_sysv:
  58. ofs:=align(maxpushedparasize+LinkageAreaSizeSYSV,16);
  59. else
  60. internalerror(200402191);
  61. end;
  62. tg.setfirsttemp(ofs);
  63. end
  64. else
  65. begin
  66. locals := 0;
  67. current_procinfo.procdef.localst.foreach_static(@count_locals,@locals);
  68. if locals <> 0 then
  69. { at 0(r1), the previous value of r1 will be stored }
  70. tg.setfirsttemp(4);
  71. end;
  72. end;
  73. (*
  74. procedure tppcprocinfo.after_pass1;
  75. begin
  76. if not(po_assembler in procdef.procoptions) then
  77. begin
  78. if cs_asm_source in aktglobalswitches then
  79. aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
  80. if cs_asm_source in aktglobalswitches then
  81. aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
  82. firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
  83. if cs_asm_source in aktglobalswitches then
  84. aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(firsttemp_offset))));
  85. //!!!! tg.setfirsttemp(firsttemp_offset);
  86. tg.firsttemp:=firsttemp_offset;
  87. tg.lasttemp:=firsttemp_offset;
  88. inherited after_pass1;
  89. end;
  90. end;
  91. *)
  92. procedure tppcprocinfo.allocate_push_parasize(size:longint);
  93. begin
  94. if size>maxpushedparasize then
  95. maxpushedparasize:=size;
  96. end;
  97. function tppcprocinfo.calc_stackframe_size:longint;
  98. var
  99. first_save_fpu_register: longint;
  100. begin
  101. { more or less copied from cgcpu.pas/g_stackframe_entry }
  102. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  103. case target_info.abi of
  104. abi_powerpc_aix:
  105. first_save_fpu_register := 14;
  106. abi_powerpc_sysv:
  107. first_save_fpu_register := 9;
  108. else
  109. internalerror(2003122903);
  110. end;
  111. if not (po_assembler in procdef.procoptions) then
  112. result := align(align((31-13+1)*4+(31-first_save_fpu_register+1)*8,16)+tg.lasttemp,16)
  113. else
  114. result := align(tg.lasttemp,16);
  115. end;
  116. begin
  117. cprocinfo:=tppcprocinfo;
  118. end.
  119. {
  120. $Log$
  121. Revision 1.36 2004-10-15 09:30:13 mazen
  122. - remove $IFDEF DELPHI and related code
  123. - remove $IFDEF FPCPROCVAR and related code
  124. Revision 1.35 2004/06/20 08:55:32 florian
  125. * logs truncated
  126. Revision 1.34 2004/02/19 17:07:42 florian
  127. * fixed arg. area calculation
  128. }