nppccal.pas 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {
  2. $Id$
  3. Copyright (c) 2002 by Florian Klaempfl
  4. Implements the PowerPC specific part of call nodes
  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. unit nppccal;
  19. {$i fpcdefs.inc}
  20. interface
  21. uses
  22. symdef,node,ncal,ncgcal;
  23. type
  24. tppccallnode = class(tcgcallnode)
  25. function pass_1 : tnode;override;
  26. procedure load_framepointer;override;
  27. end;
  28. implementation
  29. uses
  30. globtype,systems,
  31. cutils,verbose,globals,
  32. symconst,symbase,symsym,symtable,defbase,paramgr,
  33. {$ifdef GDB}
  34. {$ifdef delphi}
  35. sysutils,
  36. {$else}
  37. strings,
  38. {$endif}
  39. gdb,
  40. {$endif GDB}
  41. cginfo,cgbase,pass_2,
  42. cpuinfo,cpubase,aasmbase,aasmtai,aasmcpu,
  43. nmem,nld,ncnv,
  44. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu,cg64f32,cgcpu,cpupi;
  45. function tppccallnode.pass_1 : tnode;
  46. begin
  47. result:=inherited pass_1;
  48. if assigned(result) then
  49. exit;
  50. if procdefinition is tprocdef then
  51. begin
  52. if tprocdef(procdefinition).parast.datasize>tppcprocinfo(procinfo).maxpushedparasize then
  53. tppcprocinfo(procinfo).maxpushedparasize:=tprocdef(procdefinition).parast.datasize
  54. end
  55. else
  56. begin
  57. {!!!!}
  58. end;
  59. end;
  60. procedure tppccallnode.load_framepointer;
  61. begin
  62. { if we call a nested function in a method, we must }
  63. { push also SELF! }
  64. { THAT'S NOT TRUE, we have to load ESI via frame pointer }
  65. { access }
  66. {
  67. begin
  68. loadesi:=false;
  69. emit_reg(A_PUSH,S_L,R_ESI);
  70. end;
  71. }
  72. {
  73. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  74. begin
  75. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  76. cg.a_param_ref(exprasmlist,OS_ADDR,href,-1);
  77. end
  78. { this is only true if the difference is one !!
  79. but it cannot be more !! }
  80. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  81. begin
  82. cg.a_param_reg(exprasmlist,OS_ADDR,procinfo^.framepointer,-1);
  83. end
  84. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  85. begin
  86. hregister:=rg.getregisterint(exprasmlist);
  87. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  88. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  89. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  90. begin
  91. {we should get the correct frame_pointer_offset at each level
  92. how can we do this !!! }
  93. reference_reset_base(href,hregister,procinfo^.framepointer_offset);
  94. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  95. end;
  96. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,-1);
  97. rg.ungetregisterint(exprasmlist,hregister);
  98. end
  99. else
  100. internalerror(2002081303);
  101. }
  102. end;
  103. begin
  104. ccallnode:=tppccallnode;
  105. end.
  106. {
  107. $Log$
  108. Revision 1.2 2002-08-17 09:23:49 florian
  109. * first part of procinfo rewrite
  110. Revision 1.1 2002/08/13 21:40:59 florian
  111. * more fixes for ppc calling conventions
  112. }