cpupara.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. cpubase,
  25. symdef,paramgr;
  26. type
  27. { Returns the location for the nr-st 32 Bit int parameter
  28. if every parameter before is an 32 Bit int parameter as well
  29. and if the calling conventions for the helper routines of the
  30. rtl are used.
  31. }
  32. tm68kparamanager = class(tparamanager)
  33. function getintparaloc(nr : longint) : tparalocation;override;
  34. procedure create_param_loc_info(p : tabstractprocdef);override;
  35. function getselflocation(p : tabstractprocdef) : tparalocation;override;
  36. end;
  37. implementation
  38. uses
  39. verbose,
  40. globals,
  41. globtype,
  42. systems,
  43. cpuinfo,cginfo,cgbase,
  44. defutil;
  45. function tm68kparamanager.getintparaloc(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.enum:=frame_pointer_reg;
  57. result.reference.offset:=target_info.first_parm_offset
  58. +nr*4;
  59. end;
  60. end;
  61. procedure tm68kparamanager.create_param_loc_info(p : tabstractprocdef);
  62. var
  63. param_offset : integer;
  64. hp : tparaitem;
  65. begin
  66. { frame pointer for nested procedures? }
  67. { inc(nextintreg); }
  68. { constructor? }
  69. { destructor? }
  70. param_offset := target_info.first_parm_offset;
  71. hp:=tparaitem(p.para.last);
  72. while assigned(hp) do
  73. begin
  74. hp.paraloc.loc:=LOC_REFERENCE;
  75. hp.paraloc.sp_fixup:=0;
  76. hp.paraloc.reference.index.enum:=frame_pointer_reg;
  77. hp.paraloc.reference.offset:=param_offset;
  78. inc(param_offset,aktalignment.paraalign);
  79. hp.paraloc.size := def_cgsize(hp.paratype.def);
  80. hp:=tparaitem(hp.previous);
  81. end;
  82. end;
  83. function tm68kparamanager.getselflocation(p : tabstractprocdef) : tparalocation;
  84. begin
  85. getselflocation.loc:=LOC_REFERENCE;
  86. getselflocation.reference.index.enum:=R_SP;
  87. getselflocation.reference.offset:=4;
  88. end;
  89. begin
  90. paramanager:=tm68kparamanager.create;
  91. end.
  92. {
  93. $Log$
  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. }