cpupi.pas 5.1 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. tarmprocinfo = class(tcgprocinfo)
  27. constructor create(aparent:tprocinfo);override;
  28. // procedure handle_body_start;override;
  29. // procedure after_pass1;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;
  41. constructor tarmprocinfo.create(aparent:tprocinfo);
  42. begin
  43. inherited create(aparent);
  44. maxpushedparasize:=0;
  45. end;
  46. (*
  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. *)
  84. procedure tarmprocinfo.set_first_temp_offset;
  85. begin
  86. { We allocate enough space to save all registers because we can't determine
  87. the necessary space because the used registers aren't known before
  88. secondpass is run. Even worse, patching
  89. the local offsets after generating the code could cause trouble because
  90. "shifter" constants could change to non-"shifter" constants. This
  91. is especially a problem when taking the address of a local. For now,
  92. this extra memory should hurt less than generating all local contants with offsets
  93. >256 as non shifter constants }
  94. tg.setfirsttemp(-12-28);
  95. end;
  96. procedure tarmprocinfo.allocate_push_parasize(size:longint);
  97. begin
  98. if size>maxpushedparasize then
  99. maxpushedparasize:=size;
  100. end;
  101. function tarmprocinfo.calc_stackframe_size:longint;
  102. begin
  103. { align to 4 bytes at least }
  104. result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,max(aktalignment.localalignmin,4));
  105. end;
  106. begin
  107. cprocinfo:=tarmprocinfo;
  108. end.
  109. {
  110. $Log$
  111. Revision 1.6 2004-03-06 20:35:20 florian
  112. * fixed arm compilation
  113. * cleaned up code generation for exported linux procedures
  114. Revision 1.5 2003/12/03 17:39:05 florian
  115. * fixed several arm calling conventions issues
  116. * fixed reference reading in the assembler reader
  117. * fixed a_loadaddr_ref_reg
  118. Revision 1.4 2003/11/30 19:35:29 florian
  119. * fixed several arm related problems
  120. Revision 1.3 2003/11/24 15:17:37 florian
  121. * changed some types to prevend range check errors
  122. Revision 1.2 2003/11/02 14:30:03 florian
  123. * fixed ARM for new reg. allocation scheme
  124. Revision 1.1 2003/08/20 15:50:13 florian
  125. * more arm stuff
  126. }