cpupara.pas 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. PowerPC specific calling conventions
  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 by
  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. { PowerPC specific calling conventions are handled by this unit
  19. }
  20. unit cpupara;
  21. {$i fpcdefs.inc}
  22. interface
  23. uses
  24. cpubase,
  25. symconst,symbase,symdef,paramgr;
  26. type
  27. tppcparamanager = class(tparamanager)
  28. function getintparaloc(nr : longint) : tparalocation;override;
  29. procedure create_param_loc_info(p : tabstractprocdef);override;
  30. function getfuncretloc(p : tabstractprocdef) : tparalocation;override;
  31. end;
  32. implementation
  33. uses
  34. verbose,
  35. cpuinfo,
  36. symtype;
  37. function tppcparamanager.getintparaloc(nr : longint) : tparalocation;
  38. begin
  39. fillchar(result,sizeof(tparalocation),0);
  40. if nr<1 then
  41. internalerror(2002070801)
  42. else if nr<=8 then
  43. begin
  44. result.loc:=LOC_REGISTER;
  45. result.register:=tregister(longint(R_2)+nr);
  46. end
  47. else
  48. begin
  49. result.loc:=LOC_REFERENCE;
  50. result.reference.index:=stack_pointer_reg;
  51. result.reference.offset:=(nr-8)*4;
  52. end;
  53. end;
  54. function getparaloc(p : tdef) : tloc;
  55. begin
  56. case p.deftype of
  57. orddef:
  58. getparaloc:=LOC_REGISTER;
  59. floatdef:
  60. getparaloc:=LOC_FPUREGISTER;
  61. enumdef:
  62. getparaloc:=LOC_REGISTER;
  63. pointerdef:
  64. getparaloc:=LOC_REGISTER;
  65. else
  66. internalerror(2002071001);
  67. end;
  68. end;
  69. procedure tppcparamanager.create_param_loc_info(p : tabstractprocdef);
  70. var
  71. nextintreg,nextfloatreg,nextmmreg : tregister;
  72. stack_offset : aword;
  73. hp : tparaitem;
  74. loc : tloc;
  75. begin
  76. nextintreg:=R_3;
  77. nextfloatreg:=R_F1;
  78. nextmmreg:=R_M1;
  79. stack_offset:=0;
  80. { pointer for structured results ? }
  81. { !!!nextintreg:=R_4; }
  82. { frame pointer for nested procedures? }
  83. { inc(nextintreg); }
  84. { constructor? }
  85. { destructor? }
  86. hp:=tparaitem(p.para.last);
  87. while assigned(hp) do
  88. begin
  89. loc:=getparaloc(hp.paratype.def);
  90. case loc of
  91. LOC_REGISTER:
  92. begin
  93. if nextintreg<=R_8 then
  94. begin
  95. hp.paraloc.loc:=LOC_REGISTER;
  96. hp.paraloc.register:=nextintreg;
  97. inc(nextintreg);
  98. end
  99. else
  100. begin
  101. {!!!!!!!}
  102. internalerror(2002071003);
  103. end;
  104. end;
  105. else
  106. internalerror(2002071002);
  107. end;
  108. hp:=tparaitem(hp.previous);
  109. end;
  110. end;
  111. function tppcparamanager.getfuncretloc(p : tabstractprocdef) : tparalocation;
  112. begin
  113. getfuncretloc.loc:=LOC_REGISTER;
  114. getfuncretloc.register:=R_3;
  115. end;
  116. begin
  117. paramanager:=tppcparamanager.create;
  118. end.
  119. {
  120. $Log$
  121. Revision 1.2 2002-07-11 14:41:34 florian
  122. * start of the new generic parameter handling
  123. Revision 1.1 2002/07/07 09:44:32 florian
  124. * powerpc target fixed, very simple units can be compiled
  125. }