cpupara.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. Generates the argument location information for 680x0
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published bymethodpointer
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. { Generates the argument location information for 680x0.
  19. }
  20. unit cpupara;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. globtype,
  25. cpubase,
  26. symconst,symdef,
  27. paramgr;
  28. type
  29. { Returns the location for the nr-st 32 Bit int parameter
  30. if every parameter before is an 32 Bit int parameter as well
  31. and if the calling conventions for the helper routines of the
  32. rtl are used.
  33. }
  34. tm68kparamanager = class(tparamanager)
  35. function getintparaloc(calloption : tproccalloption;nr : longint) : tparalocation;override;
  36. function create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;override;
  37. end;
  38. implementation
  39. uses
  40. verbose,
  41. globals,
  42. systems,
  43. cpuinfo,cgbase,
  44. defutil;
  45. function tm68kparamanager.getintparaloc(calloption : tproccalloption;nr : longint) : tparalocation;
  46. begin
  47. fillchar(result,sizeof(tparalocation),0);
  48. if nr<1 then
  49. internalerror(2002070801)
  50. else
  51. begin
  52. { warning : THIS ONLY WORKS WITH INTERNAL ROUTINES,
  53. WHICH MUST ALWAYS PASS 4-BYTE PARAMETERS!!
  54. }
  55. result.loc:=LOC_REFERENCE;
  56. result.reference.index:=NR_STACK_POINTER_REG;
  57. result.reference.offset:=target_info.first_parm_offset+nr*4;
  58. end;
  59. end;
  60. function tm68kparamanager.create_paraloc_info(p : tabstractprocdef; side: tcallercallee):longint;
  61. var
  62. param_offset : integer;
  63. hp : tparaitem;
  64. paraloc: tparalocation;
  65. l : longint;
  66. parasize : longint;
  67. begin
  68. { frame pointer for nested procedures? }
  69. { inc(nextintreg); }
  70. { constructor? }
  71. { destructor? }
  72. param_offset := target_info.first_parm_offset;
  73. hp:=tparaitem(p.para.last);
  74. while assigned(hp) do
  75. begin
  76. paraloc.size:=def_cgsize(hp.paratype.def);
  77. paraloc.loc:=LOC_REFERENCE;
  78. paraloc.alignment:=4;
  79. paraloc.reference.index:=NR_FRAME_POINTER_REG;
  80. l:=push_size(hp.paratyp,hp.paratype.def,p.proccalloption);
  81. paraloc.reference.offset:=parasize;
  82. parasize:=parasize+l;
  83. hp.paraloc[callerside]:=paraloc;
  84. hp:=tparaitem(hp.next);
  85. end;
  86. end;
  87. begin
  88. paramanager:=tm68kparamanager.create;
  89. end.
  90. {
  91. $Log$
  92. Revision 1.5 2004-01-30 12:17:18 florian
  93. * fixed some m68k compilation problems
  94. Revision 1.4 2003/02/02 19:25:54 carl
  95. * Several bugfixes for m68k target (register alloc., opcode emission)
  96. + VIS target
  97. + Generic add more complete (still not verified)
  98. Revision 1.3 2003/01/08 18:43:57 daniel
  99. * Tregister changed into a record
  100. Revision 1.2 2002/12/14 15:02:03 carl
  101. * maxoperands -> max_operands (for portability in rautils.pas)
  102. * fix some range-check errors with loadconst
  103. + add ncgadd unit to m68k
  104. * some bugfix of a_param_reg with LOC_CREFERENCE
  105. Revision 1.1 2002/08/12 15:08:44 carl
  106. + stab register indexes for powerpc (moved from gdb to cpubase)
  107. + tprocessor enumeration moved to cpuinfo
  108. + linker in target_info is now a class
  109. * many many updates for m68k (will soon start to compile)
  110. - removed some ifdef or correct them for correct cpu
  111. }