cpupi.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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,aasmdata,
  23. globtype, cgutils, cgbase,
  24. procinfo, cpuinfo, psub;
  25. type
  26. trv64procinfo = class(tcgprocinfo)
  27. stackframesize,
  28. floatregstart : aint;
  29. stackpaddingreg: TSuperRegister;
  30. needs_frame_pointer: boolean;
  31. constructor create(aparent: tprocinfo); override;
  32. procedure set_first_temp_offset; override;
  33. function calc_stackframe_size: longint; override;
  34. end;
  35. implementation
  36. uses
  37. globals, systems,
  38. cpubase,
  39. aasmtai,
  40. tgobj,cgobj,
  41. symconst, symsym, paramgr, symutil, symtable,
  42. verbose,
  43. aasmcpu;
  44. constructor trv64procinfo.create(aparent: tprocinfo);
  45. begin
  46. inherited create(aparent);
  47. maxpushedparasize := 0;
  48. end;
  49. procedure trv64procinfo.set_first_temp_offset;
  50. begin
  51. if (po_nostackframe in procdef.procoptions) then
  52. begin
  53. { maxpushedparasize sghould be zero,
  54. if not we will get an error later. }
  55. tg.setfirsttemp(maxpushedparasize);
  56. exit;
  57. end;
  58. if tg.direction = -1 then
  59. tg.setfirsttemp(-(1+12)*8)
  60. else
  61. tg.setfirsttemp(maxpushedparasize);
  62. end;
  63. function trv64procinfo.calc_stackframe_size: longint;
  64. var
  65. firstfloatreg,lastfloatreg,
  66. r : byte;
  67. floatsavesize : aword;
  68. regs: tcpuregisterset;
  69. begin
  70. maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,8));
  71. floatsavesize:=0;
  72. case current_settings.fputype of
  73. fpu_fd:
  74. begin
  75. floatsavesize:=0;
  76. regs:=cg.rg[R_FPUREGISTER].used_in_proc-paramanager.get_volatile_registers_fpu(pocall_stdcall);
  77. for r:=RS_F0 to RS_F31 do
  78. if r in regs then
  79. inc(floatsavesize,8);
  80. end;
  81. end;
  82. floatsavesize:=system.align(floatsavesize,max(current_settings.alignment.localalignmin,8));
  83. result:=Align(tg.direction*tg.lasttemp,max(current_settings.alignment.localalignmin,8))+maxpushedparasize+aint(floatsavesize);
  84. if tg.direction=1 then
  85. floatregstart:=result-aint(floatsavesize)
  86. else
  87. floatregstart:=-result+maxpushedparasize;
  88. end;
  89. begin
  90. cprocinfo := trv64procinfo;
  91. end.