cpupi.pas 3.4 KB

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