cpupi.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. cgbase,cpuinfo,psub;
  25. type
  26. tarmprocinfo = class(tcgprocinfo)
  27. { max. of space need for parameters, currently used by the PowerPC port only }
  28. maxpushedparasize : aword;
  29. constructor create(aparent:tprocinfo);override;
  30. procedure handle_body_start;override;
  31. procedure after_pass1;override;
  32. procedure allocate_push_parasize(size: longint);override;
  33. function calc_stackframe_size:longint;override;
  34. end;
  35. implementation
  36. uses
  37. globtype,globals,systems,
  38. cpubase,
  39. aasmtai,
  40. tgobj,
  41. symconst,symsym,paramgr;
  42. constructor tarmprocinfo.create(aparent:tprocinfo);
  43. begin
  44. inherited create(aparent);
  45. maxpushedparasize:=0;
  46. end;
  47. procedure tarmprocinfo.handle_body_start;
  48. var
  49. ofs : aword;
  50. begin
  51. if not(po_assembler in procdef.procoptions) then
  52. begin
  53. {!!!!!!!!
  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. end;
  60. }
  61. inc(procdef.parast.address_fixup,ofs);
  62. procdef.localst.address_fixup:=procdef.parast.address_fixup+procdef.parast.datasize;
  63. end;
  64. inherited handle_body_start;
  65. end;
  66. procedure tarmprocinfo.after_pass1;
  67. begin
  68. if not(po_assembler in procdef.procoptions) then
  69. begin
  70. if cs_asm_source in aktglobalswitches then
  71. aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
  72. if cs_asm_source in aktglobalswitches then
  73. aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
  74. firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
  75. if cs_asm_source in aktglobalswitches then
  76. aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(firsttemp_offset))));
  77. //!!!! tg.setfirsttemp(firsttemp_offset);
  78. tg.firsttemp:=firsttemp_offset;
  79. tg.lasttemp:=firsttemp_offset;
  80. inherited after_pass1;
  81. end;
  82. end;
  83. procedure tarmprocinfo.allocate_push_parasize(size:longint);
  84. begin
  85. if size>maxpushedparasize then
  86. maxpushedparasize:=size;
  87. end;
  88. function tarmprocinfo.calc_stackframe_size:longint;
  89. begin
  90. { more or less copied from cgcpu.pas/g_stackframe_entry }
  91. if not (po_assembler in procdef.procoptions) then
  92. result := align(align((31-13+1)*4+(31-14+1)*8,16)+tg.lasttemp,16)
  93. else
  94. result := align(tg.lasttemp,16);
  95. end;
  96. begin
  97. cprocinfo:=tarmprocinfo;
  98. end.
  99. {
  100. $Log$
  101. Revision 1.1 2003-08-20 15:50:13 florian
  102. * more arm stuff
  103. }