cpupi.pas 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. {
  2. Copyright (c) 2002-2006 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. psub,procinfo;
  23. type
  24. tx86_64procinfo = class(tcgprocinfo)
  25. procedure set_first_temp_offset;override;
  26. procedure generate_parameter_info;override;
  27. function calc_stackframe_size:longint;override;
  28. end;
  29. implementation
  30. uses
  31. systems,
  32. globals,
  33. cutils,
  34. symconst,
  35. tgobj;
  36. procedure tx86_64procinfo.set_first_temp_offset;
  37. begin
  38. if target_info.system=system_x86_64_win64 then
  39. begin
  40. if not(po_assembler in procdef.procoptions) and
  41. (tg.direction > 0) then
  42. tg.setfirsttemp(tg.direction*maxpushedparasize+4*8);
  43. end
  44. else
  45. tg.setfirsttemp(tg.direction*maxpushedparasize);
  46. end;
  47. procedure tx86_64procinfo.generate_parameter_info;
  48. begin
  49. inherited generate_parameter_info;
  50. if target_info.system=system_x86_64_win64 then
  51. para_stack_size:=0;
  52. end;
  53. function tx86_64procinfo.calc_stackframe_size:longint;
  54. begin
  55. maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,16));
  56. { RSP should be aligned on 16 bytes }
  57. result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,16);
  58. if target_info.system=system_x86_64_win64 then
  59. inc(result,4*8);
  60. end;
  61. begin
  62. cprocinfo:=tx86_64procinfo;
  63. end.