cpupi.pas 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. globtype,cutils,
  24. procinfo,cpuinfo,psub;
  25. type
  26. tarmprocinfo = class(tcgprocinfo)
  27. floatregstart : aint;
  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. globals,systems,
  37. cpubase,
  38. aasmtai,
  39. tgobj,
  40. symconst,symsym,paramgr,
  41. cgbase,
  42. cgobj;
  43. procedure tarmprocinfo.set_first_temp_offset;
  44. begin
  45. { We allocate enough space to save all registers because we can't determine
  46. the necessary space because the used registers aren't known before
  47. secondpass is run. Even worse, patching
  48. the local offsets after generating the code could cause trouble because
  49. "shifter" constants could change to non-"shifter" constants. This
  50. is especially a problem when taking the address of a local. For now,
  51. this extra memory should hurt less than generating all local contants with offsets
  52. >256 as non shifter constants }
  53. tg.setfirsttemp(-12-28);
  54. end;
  55. procedure tarmprocinfo.allocate_push_parasize(size:longint);
  56. begin
  57. if size>maxpushedparasize then
  58. maxpushedparasize:=size;
  59. end;
  60. function tarmprocinfo.calc_stackframe_size:longint;
  61. var
  62. firstfloatreg,lastfloatreg,
  63. r : byte;
  64. floatsavesize : aword;
  65. begin
  66. maxpushedparasize:=align(maxpushedparasize,max(aktalignment.localalignmin,4));
  67. firstfloatreg:=RS_NO;
  68. { save floating point registers? }
  69. for r:=RS_F0 to RS_F7 do
  70. if r in cg.rg[R_FPUREGISTER].used_in_proc-paramanager.get_volatile_registers_fpu(pocall_stdcall) then
  71. begin
  72. if firstfloatreg=RS_NO then
  73. firstfloatreg:=r;
  74. lastfloatreg:=r;
  75. end;
  76. if firstfloatreg<>RS_NO then
  77. floatsavesize:=(lastfloatreg-firstfloatreg+1)*12
  78. else
  79. floatsavesize:=0;
  80. floatsavesize:=align(floatsavesize,max(aktalignment.localalignmin,4));
  81. result:=Align(tg.direction*tg.lasttemp,max(aktalignment.localalignmin,4))+maxpushedparasize+floatsavesize;
  82. floatregstart:=-result+maxpushedparasize;
  83. end;
  84. begin
  85. cprocinfo:=tarmprocinfo;
  86. end.
  87. {
  88. $Log$
  89. Revision 1.11 2005-02-14 17:13:09 peter
  90. * truncate log
  91. }