cpupi.pas 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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. 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 set_first_temp_offset;override;
  33. procedure allocate_push_parasize(size: longint);override;
  34. function calc_stackframe_size:longint;override;
  35. end;
  36. implementation
  37. uses
  38. globtype,globals,systems,
  39. cpubase,
  40. aasmtai,
  41. tgobj,
  42. symconst,symsym,paramgr;
  43. constructor tarmprocinfo.create(aparent:tprocinfo);
  44. begin
  45. inherited create(aparent);
  46. maxpushedparasize:=0;
  47. end;
  48. (*
  49. procedure tarmprocinfo.handle_body_start;
  50. var
  51. ofs : aword;
  52. begin
  53. if not(po_assembler in procdef.procoptions) then
  54. begin
  55. {!!!!!!!!
  56. case target_info.abi of
  57. abi_powerpc_aix:
  58. ofs:=align(maxpushedparasize+LinkageAreaSizeAIX,16);
  59. abi_powerpc_sysv:
  60. ofs:=align(maxpushedparasize+LinkageAreaSizeSYSV,16);
  61. end;
  62. }
  63. inc(procdef.parast.address_fixup,ofs);
  64. procdef.localst.address_fixup:=procdef.parast.address_fixup+procdef.parast.datasize;
  65. end;
  66. inherited handle_body_start;
  67. end;
  68. procedure tarmprocinfo.after_pass1;
  69. begin
  70. if not(po_assembler in procdef.procoptions) then
  71. begin
  72. if cs_asm_source in aktglobalswitches then
  73. aktproccode.insert(Tai_comment.Create(strpnew('Parameter copies start at: r1+'+tostr(procdef.parast.address_fixup))));
  74. if cs_asm_source in aktglobalswitches then
  75. aktproccode.insert(Tai_comment.Create(strpnew('Locals start at: r1+'+tostr(procdef.localst.address_fixup))));
  76. firsttemp_offset:=align(procdef.localst.address_fixup+procdef.localst.datasize,16);
  77. if cs_asm_source in aktglobalswitches then
  78. aktproccode.insert(Tai_comment.Create(strpnew('Temp. space start: r1+'+tostr(firsttemp_offset))));
  79. //!!!! tg.setfirsttemp(firsttemp_offset);
  80. tg.firsttemp:=firsttemp_offset;
  81. tg.lasttemp:=firsttemp_offset;
  82. inherited after_pass1;
  83. end;
  84. end;
  85. *)
  86. procedure tarmprocinfo.set_first_temp_offset;
  87. begin
  88. { We allocate enough space to save all registers because we can't determine
  89. the necessary space because the used registers aren't known before
  90. secondpass is run. Even worse, patching
  91. the local offsets after generating the code could cause trouble because
  92. "shifter" constants could change to non-"shifter" constants. This
  93. is especially a problem when taking the address of a local. For now,
  94. this extra memory should hurt less than generating all local contants with offsets
  95. >256 as non shifter constants }
  96. tg.setfirsttemp(-12-28);
  97. end;
  98. procedure tarmprocinfo.allocate_push_parasize(size:longint);
  99. begin
  100. if size>maxpushedparasize then
  101. maxpushedparasize:=size;
  102. end;
  103. function tarmprocinfo.calc_stackframe_size:longint;
  104. begin
  105. { align to 4 bytes at least }
  106. result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,max(aktalignment.localalignmin,4));
  107. end;
  108. begin
  109. cprocinfo:=tarmprocinfo;
  110. end.
  111. {
  112. $Log$
  113. Revision 1.5 2003-12-03 17:39:05 florian
  114. * fixed several arm calling conventions issues
  115. * fixed reference reading in the assembler reader
  116. * fixed a_loadaddr_ref_reg
  117. Revision 1.4 2003/11/30 19:35:29 florian
  118. * fixed several arm related problems
  119. Revision 1.3 2003/11/24 15:17:37 florian
  120. * changed some types to prevend range check errors
  121. Revision 1.2 2003/11/02 14:30:03 florian
  122. * fixed ARM for new reg. allocation scheme
  123. Revision 1.1 2003/08/20 15:50:13 florian
  124. * more arm stuff
  125. }