cpupi.pas 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. {
  2. Copyright (c) 2002-2010 by Florian Klaempfl and Jonas Maebe
  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. unit cpupi;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. cutils,
  22. procinfo,cpuinfo, symtype,
  23. psub;
  24. type
  25. { tcpuprocinfo }
  26. tcpuprocinfo=class(tcgprocinfo)
  27. public
  28. procedure postprocess_code; override;
  29. procedure set_first_temp_offset;override;
  30. end;
  31. implementation
  32. uses
  33. systems,globals, tgcpu, aasmdata, aasmcpu,
  34. tgobj,paramgr,symconst;
  35. procedure tcpuprocinfo.postprocess_code;
  36. var
  37. templist : TAsmList;
  38. l : TWasmLocal;
  39. begin
  40. templist := TAsmList.create;
  41. l := ttgwasm(tg).localvars.first;
  42. while Assigned(l) do begin
  43. templist.Concat( tai_local.create(l.typ));
  44. l := l.nextseq;
  45. end;
  46. aktproccode.insertListBefore(nil, templist);
  47. templist.Free;
  48. inherited postprocess_code;
  49. end;
  50. procedure tcpuprocinfo.set_first_temp_offset;
  51. var
  52. sz : integer;
  53. i : integer;
  54. sym: tsym;
  55. begin
  56. {
  57. Stackframe layout:
  58. sp:
  59. <incoming parameters>
  60. sp+first_temp_offset:
  61. <locals>
  62. <temp>
  63. }
  64. procdef.init_paraloc_info(calleeside);
  65. sz := procdef.calleeargareasize;
  66. tg.setfirsttemp(sz);
  67. end;
  68. initialization
  69. cprocinfo:=tcpuprocinfo;
  70. end.