nppccal.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. procedure load_framepointer;override;
  26. end;
  27. implementation
  28. uses
  29. globtype,systems,
  30. cutils,verbose,globals,
  31. symconst,symbase,symsym,symtable,defbase,paramgr,
  32. {$ifdef GDB}
  33. {$ifdef delphi}
  34. sysutils,
  35. {$else}
  36. strings,
  37. {$endif}
  38. gdb,
  39. {$endif GDB}
  40. cginfo,cgbase,pass_2,
  41. cpuinfo,cpubase,aasmbase,aasmtai,aasmcpu,
  42. nmem,nld,ncnv,
  43. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu,cg64f32,cgcpu;
  44. procedure tppccallnode.load_framepointer;
  45. begin
  46. { if we call a nested function in a method, we must }
  47. { push also SELF! }
  48. { THAT'S NOT TRUE, we have to load ESI via frame pointer }
  49. { access }
  50. {
  51. begin
  52. loadesi:=false;
  53. emit_reg(A_PUSH,S_L,R_ESI);
  54. end;
  55. }
  56. {
  57. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  58. begin
  59. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  60. cg.a_param_ref(exprasmlist,OS_ADDR,href,-1);
  61. end
  62. { this is only true if the difference is one !!
  63. but it cannot be more !! }
  64. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  65. begin
  66. cg.a_param_reg(exprasmlist,OS_ADDR,procinfo^.framepointer,-1);
  67. end
  68. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  69. begin
  70. hregister:=rg.getregisterint(exprasmlist);
  71. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  72. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  73. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  74. begin
  75. {we should get the correct frame_pointer_offset at each level
  76. how can we do this !!! }
  77. reference_reset_base(href,hregister,procinfo^.framepointer_offset);
  78. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  79. end;
  80. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,-1);
  81. rg.ungetregisterint(exprasmlist,hregister);
  82. end
  83. else
  84. internalerror(2002081303);
  85. }
  86. end;
  87. begin
  88. ccallnode:=tppccallnode;
  89. end.
  90. {
  91. $Log$
  92. Revision 1.1 2002-08-13 21:40:59 florian
  93. * more fixes for ppc calling conventions
  94. }