cpupi.pas 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {
  2. Copyright (c) 2002 by Florian Klaempfl
  3. This unit contains the CPU specific part of tprocinfo
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  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. procinfo,cpuinfo,psub;
  24. type
  25. tppcprocinfo = class(tcgprocinfo)
  26. { offset where the frame pointer from the outer procedure is stored. }
  27. parent_framepointer_offset : longint;
  28. constructor create(aparent:tprocinfo);override;
  29. procedure set_first_temp_offset;override;
  30. procedure allocate_push_parasize(size: longint);override;
  31. function calc_stackframe_size:longint;override;
  32. end;
  33. implementation
  34. uses
  35. globtype,globals,systems,
  36. cpubase,
  37. aasmtai,
  38. tgobj,
  39. symconst,symsym,paramgr,symutil,
  40. verbose;
  41. constructor tppcprocinfo.create(aparent:tprocinfo);
  42. begin
  43. inherited create(aparent);
  44. maxpushedparasize:=0;
  45. end;
  46. procedure tppcprocinfo.set_first_temp_offset;
  47. var
  48. ofs : aword;
  49. locals: longint;
  50. begin
  51. if not(po_assembler in procdef.procoptions) then
  52. begin
  53. case target_info.abi of
  54. abi_powerpc_aix:
  55. ofs:=align(maxpushedparasize+LinkageAreaSizeAIX,16);
  56. abi_powerpc_sysv:
  57. ofs:=align(maxpushedparasize+LinkageAreaSizeSYSV,16);
  58. else
  59. internalerror(200402191);
  60. end;
  61. tg.setfirsttemp(ofs);
  62. end
  63. else
  64. begin
  65. locals := 0;
  66. current_procinfo.procdef.localst.foreach_static(@count_locals,@locals);
  67. if locals <> 0 then
  68. { at 0(r1), the previous value of r1 will be stored }
  69. tg.setfirsttemp(4);
  70. end;
  71. end;
  72. (*
  73. procedure tppcprocinfo.after_pass1;
  74. begin
  75. if not(po_assembler in procdef.procoptions) then
  76. begin
  77. if cs_asm_source in aktglobalswitches then
  78. aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
  79. if cs_asm_source in aktglobalswitches then
  80. aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
  81. firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
  82. if cs_asm_source in aktglobalswitches then
  83. aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(firsttemp_offset))));
  84. //!!!! tg.setfirsttemp(firsttemp_offset);
  85. tg.firsttemp:=firsttemp_offset;
  86. tg.lasttemp:=firsttemp_offset;
  87. inherited after_pass1;
  88. end;
  89. end;
  90. *)
  91. procedure tppcprocinfo.allocate_push_parasize(size:longint);
  92. begin
  93. if size>maxpushedparasize then
  94. maxpushedparasize:=size;
  95. end;
  96. function tppcprocinfo.calc_stackframe_size:longint;
  97. var
  98. first_save_fpu_register: longint;
  99. begin
  100. { more or less copied from cgcpu.pas/g_stackframe_entry }
  101. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  102. case target_info.abi of
  103. abi_powerpc_aix:
  104. first_save_fpu_register := 14;
  105. abi_powerpc_sysv:
  106. first_save_fpu_register := 9;
  107. else
  108. internalerror(2003122903);
  109. end;
  110. if not (po_assembler in procdef.procoptions) then
  111. result := align(align((31-13+1)*4+(31-first_save_fpu_register+1)*8,16)+tg.lasttemp,16)
  112. else
  113. result := align(tg.lasttemp,16);
  114. end;
  115. begin
  116. cprocinfo:=tppcprocinfo;
  117. end.