cpupi.pas 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. globtype,
  33. globals,
  34. cutils,
  35. symconst,
  36. tgobj;
  37. procedure tx86_64procinfo.set_first_temp_offset;
  38. begin
  39. if target_info.system=system_x86_64_win64 then
  40. begin
  41. { Fixes the case when there are calls done by low-level means
  42. (cg.a_call_name) but no child callnode }
  43. if (pi_do_call in flags) then
  44. allocate_push_parasize(32);
  45. if not(po_assembler in procdef.procoptions) and
  46. (tg.direction > 0) then
  47. { maxpushedparasize already contains 32 bytes of spilling area }
  48. tg.setfirsttemp(tg.direction*maxpushedparasize);
  49. end
  50. else
  51. tg.setfirsttemp(tg.direction*maxpushedparasize);
  52. end;
  53. procedure tx86_64procinfo.generate_parameter_info;
  54. begin
  55. inherited generate_parameter_info;
  56. if target_info.system=system_x86_64_win64 then
  57. para_stack_size:=0;
  58. end;
  59. function tx86_64procinfo.calc_stackframe_size:longint;
  60. begin
  61. maxpushedparasize:=align(maxpushedparasize,max(current_settings.alignment.localalignmin,16));
  62. { Note 1: when tg.direction>0, tg.lasttemp is already offset by maxpushedparasize
  63. (because tg.setfirsttemp also sets lasttemp)
  64. Note 2: Align to 8 bytes here. The final 16-byte alignment is handled in
  65. tcgx86.g_proc_entry, which considers saved rbp and the misalignment
  66. caused by the call itself. }
  67. if (tg.direction>0) then
  68. result:=Align(tg.lasttemp,8)
  69. else
  70. result:=Align(tg.direction*tg.lasttemp+maxpushedparasize,8);
  71. end;
  72. begin
  73. cprocinfo:=tx86_64procinfo;
  74. end.