cpupi.pas 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. psub,procinfo;
  23. type
  24. ti386procinfo = class(tcgprocinfo)
  25. constructor create(aparent:tprocinfo);override;
  26. procedure set_first_temp_offset;override;
  27. function calc_stackframe_size:longint;override;
  28. procedure generate_parameter_info;override;
  29. end;
  30. implementation
  31. uses
  32. cutils,
  33. systems,globals,
  34. tgobj,
  35. cpubase,
  36. cgutils,
  37. symconst;
  38. constructor ti386procinfo.create(aparent:tprocinfo);
  39. begin
  40. inherited create(aparent);
  41. got:=NR_EBX;
  42. end;
  43. procedure ti386procinfo.set_first_temp_offset;
  44. begin
  45. if use_fixed_stack then
  46. begin
  47. if not(po_assembler in procdef.procoptions) and
  48. (tg.direction > 0) then
  49. tg.setfirsttemp(tg.direction*maxpushedparasize);
  50. end;
  51. end;
  52. function ti386procinfo.calc_stackframe_size:longint;
  53. begin
  54. { align to 4 bytes at least
  55. otherwise all those subl $2,%esp are meaningless PM }
  56. if (target_info.system <> system_i386_darwin) then
  57. result:=Align(tg.direction*tg.lasttemp,min(current_settings.alignment.localalignmin,4))
  58. else
  59. result:=tg.direction*tg.lasttemp+maxpushedparasize;
  60. end;
  61. procedure ti386procinfo.generate_parameter_info;
  62. begin
  63. inherited generate_parameter_info;
  64. { Para_stack_size is only used to determine how many bytes to remove }
  65. { from the stack at the end of the procedure (in the "ret $xx"). }
  66. { If the stack is fixed, nothing has to be removed by the callee }
  67. if use_fixed_stack then
  68. para_stack_size := 0;
  69. end;
  70. begin
  71. cprocinfo:=ti386procinfo;
  72. end.