cpupi.pas 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. cutils,globtype,
  23. cgbase,aasmdata,
  24. procinfo,cpuinfo,psub;
  25. type
  26. trv32procinfo = class(tcgprocinfo)
  27. { for arm thumb, we need to know the stackframe size before
  28. starting procedure compilation, so this contains the stack frame size, the compiler
  29. should assume
  30. if this size is too little the procedure must be compiled again with a larger value }
  31. stackframesize,
  32. floatregstart : aint;
  33. stackpaddingreg: TSuperRegister;
  34. needs_frame_pointer: boolean;
  35. // procedure handle_body_start;override;
  36. // procedure after_pass1;override;
  37. constructor create(aparent: tprocinfo); override;
  38. procedure set_first_temp_offset;override;
  39. function calc_stackframe_size:longint;override;
  40. end;
  41. implementation
  42. uses
  43. globals,systems,
  44. cpubase,
  45. tgobj,
  46. symconst,symtype,symsym,symcpu,paramgr,
  47. cgutils,
  48. cgobj,
  49. defutil,
  50. aasmcpu;
  51. constructor trv32procinfo.create(aparent: tprocinfo);
  52. begin
  53. inherited create(aparent);
  54. maxpushedparasize := 0;
  55. end;
  56. procedure trv32procinfo.set_first_temp_offset;
  57. begin
  58. if (po_nostackframe in procdef.procoptions) then
  59. begin
  60. { maxpushedparasize sghould be zero,
  61. if not we will get an error later. }
  62. tg.setfirsttemp(maxpushedparasize);
  63. exit;
  64. end;
  65. if tg.direction = -1 then
  66. tg.setfirsttemp(-(1+12)*4)
  67. else
  68. tg.setfirsttemp(maxpushedparasize);
  69. end;
  70. function trv32procinfo.calc_stackframe_size:longint;
  71. var
  72. firstfloatreg,lastfloatreg,
  73. r : byte;
  74. floatsavesize : aword;
  75. regs: tcpuregisterset;
  76. begin
  77. maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,4));
  78. floatsavesize:=0;
  79. case current_settings.fputype of
  80. fpu_fd:
  81. begin
  82. floatsavesize:=0;
  83. regs:=cg.rg[R_FPUREGISTER].used_in_proc-paramanager.get_volatile_registers_fpu(pocall_stdcall);
  84. for r:=RS_F0 to RS_F31 do
  85. if r in regs then
  86. inc(floatsavesize,8);
  87. end;
  88. end;
  89. floatsavesize:=align(floatsavesize,max(current_settings.alignment.localalignmin,4));
  90. result:=Align(tg.direction*tg.lasttemp,max(current_settings.alignment.localalignmin,4))+maxpushedparasize+aint(floatsavesize);
  91. if tg.direction=1 then
  92. floatregstart:=result-aint(floatsavesize)
  93. else
  94. floatregstart:=-result+maxpushedparasize;
  95. end;
  96. begin
  97. cprocinfo:=trv32procinfo;
  98. end.