cpupara.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {*****************************************************************************}
  2. { File : cpupara.pas }
  3. { Author : Mazen NEIFER }
  4. { Project : Free Pascal Compiler (FPC) }
  5. { Creation date : 2002\07\13 }
  6. { Last modification date : 2002\08\20 }
  7. { Licence : GPL }
  8. { Bug report : [email protected] }
  9. {*****************************************************************************}
  10. {
  11. $Id$
  12. Copyright (c) 2002 by Florian Klaempfl
  13. PowerPC specific calling conventions
  14. This program is free software; you can redistribute it and/or modify
  15. it under the terms of the GNU General Public License as published by
  16. the Free Software Foundation; either version 2 of the License, or
  17. (at your option) any later version.
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. GNU General Public License for more details.
  22. You should have received a copy of the GNU General Public License
  23. along with this program; if not, write to the Free Software
  24. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  25. ****************************************************************************}
  26. UNIT cpupara;
  27. {SPARC specific calling conventions are handled by this unit}
  28. {$INCLUDE fpcdefs.inc}
  29. INTERFACE
  30. USES
  31. cpubase,
  32. symconst,symbase,symdef,paramgr;
  33. TYPE
  34. TSparcParaManager=CLASS(TParaManager)
  35. FUNCTION getintparaloc(nr:longint):tparalocation;OVERRIDE;
  36. PROCEDURE create_param_loc_info(p:tabstractprocdef);OVERRIDE;
  37. FUNCTION GetSelfLocation(p:tabstractprocdef):tparalocation;OVERRIDE;
  38. end;
  39. IMPLEMENTATION
  40. USES
  41. verbose,
  42. cpuinfo,
  43. symtype;
  44. FUNCTION TSparcParaManager.getintparaloc(nr : longint) : tparalocation;
  45. BEGIN
  46. fillchar(result,sizeof(tparalocation),0);
  47. if nr<1
  48. then
  49. internalerror(2002070801)
  50. else if nr<=8
  51. then
  52. BEGIN
  53. result.loc:=LOC_REGISTER;
  54. result.register:=tregister(longint(R_O0)+nr);
  55. end
  56. else
  57. BEGIN
  58. result.loc:=LOC_REFERENCE;
  59. result.reference.index:=stack_pointer_reg;
  60. result.reference.offset:=(nr-8)*4;
  61. end;
  62. end;
  63. FUNCTION getparaloc(p : tdef) : tloc;
  64. BEGIN
  65. case p.deftype of
  66. orddef:
  67. getparaloc:=LOC_REGISTER;
  68. floatdef:
  69. getparaloc:=LOC_FPUREGISTER;
  70. enumdef:
  71. getparaloc:=LOC_REGISTER;
  72. pointerdef:
  73. getparaloc:=LOC_REGISTER;
  74. else
  75. internalerror(2002071001);
  76. end;
  77. end;
  78. PROCEDURE TSparcParaManager.create_param_loc_info(p : tabstractprocdef);
  79. var
  80. nextintreg,nextfloatreg,nextmmreg : tregister;
  81. stack_offset : aword;
  82. hp : tparaitem;
  83. loc : tloc;
  84. BEGIN
  85. nextintreg:=R_G3;
  86. nextfloatreg:=R_F1;
  87. nextmmreg:=R_L1;
  88. stack_offset:=0;
  89. { pointer for structured results ? }
  90. { !!!nextintreg:=R_4; }
  91. { frame pointer for nested procedures? }
  92. { inc(nextintreg); }
  93. { constructor? }
  94. { destructor? }
  95. hp:=tparaitem(p.para.last);
  96. while assigned(hp) do
  97. BEGIN
  98. loc:=getparaloc(hp.paratype.def);
  99. case loc of
  100. LOC_REGISTER:
  101. BEGIN
  102. if nextintreg<=R_I7 then
  103. BEGIN
  104. hp.paraloc.loc:=LOC_REGISTER;
  105. hp.paraloc.register:=nextintreg;
  106. inc(nextintreg);
  107. end
  108. else
  109. BEGIN
  110. {!!!!!!!}
  111. internalerror(2002071003);
  112. end;
  113. end;
  114. else
  115. internalerror(2002071002);
  116. end;
  117. hp:=tparaitem(hp.previous);
  118. end;
  119. end;
  120. FUNCTION TSparcParaManager.GetSelfLocation(p:tabstractprocdef):tparalocation;
  121. BEGIN
  122. getselflocation.loc:=LOC_REFERENCE;
  123. getselflocation.reference.index:=R_G3{R_ESP};
  124. getselflocation.reference.offset:=4;
  125. END;
  126. BEGIN
  127. paramanager:=TSparcParaManager.create;
  128. end.
  129. {
  130. $Log$
  131. Revision 1.1 2002-08-21 13:30:07 mazen
  132. *** empty log message ***
  133. Revision 1.2 2002/07/11 14:41:34 florian
  134. * start of the new generic parameter handling
  135. Revision 1.1 2002/07/07 09:44:32 florian
  136. * powerpc target fixed, very simple units can be compiled
  137. }