cpupi.pas 3.1 KB

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