cpupi.pas 3.2 KB

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