nppccal.pas 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 push_framepointer;override;
  27. end;
  28. implementation
  29. uses
  30. globtype,systems,
  31. cutils,verbose,globals,
  32. symconst,symbase,symsym,symtable,defutil,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.push_framepointer;
  61. var
  62. href : treference;
  63. hregister1,hregister2 : tregister;
  64. i : longint;
  65. begin
  66. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  67. begin
  68. { pass the same framepointer as the current procedure got }
  69. hregister2.enum:=R_INTREGISTER;
  70. hregister2.number:=NR_R11;
  71. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,procinfo.framepointer,hregister2);
  72. { it must be adjusted! }
  73. end
  74. { this is only true if the difference is one !!
  75. but it cannot be more !! }
  76. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  77. begin
  78. // cg.a_param_reg(exprasmlist,OS_ADDR,procinfo.framepointer,paramanager.getframepointerloc(procinfo.procdef));
  79. end
  80. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  81. begin
  82. hregister1:=rg.getregisterint(exprasmlist,OS_ADDR);
  83. reference_reset_base(href,procinfo.framepointer,procinfo.framepointer_offset);
  84. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
  85. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  86. begin
  87. {we should get the correct frame_pointer_offset at each level
  88. how can we do this !!! }
  89. reference_reset_base(href,hregister2,procinfo.framepointer_offset);
  90. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister1);
  91. end;
  92. hregister2.enum:=R_11;
  93. cg.a_load_reg_reg(exprasmlist,OS_ADDR,OS_ADDR,hregister1,hregister2);
  94. rg.ungetregisterint(exprasmlist,hregister1);
  95. end
  96. else
  97. internalerror(2002081303);
  98. end;
  99. begin
  100. ccallnode:=tppccallnode;
  101. end.
  102. {
  103. $Log$
  104. Revision 1.6 2003-04-23 12:35:35 florian
  105. * fixed several issues with powerpc
  106. + applied a patch from Jonas for nested function calls (PowerPC only)
  107. * ...
  108. Revision 1.5 2003/04/04 15:38:56 peter
  109. * moved generic code from n386cal to ncgcal, i386 now also
  110. uses the generic ncgcal
  111. Revision 1.4 2002/12/05 14:28:12 florian
  112. * some variant <-> dyn. array stuff
  113. Revision 1.3 2002/11/25 17:43:28 peter
  114. * splitted defbase in defutil,symutil,defcmp
  115. * merged isconvertable and is_equal into compare_defs(_ext)
  116. * made operator search faster by walking the list only once
  117. Revision 1.2 2002/08/17 09:23:49 florian
  118. * first part of procinfo rewrite
  119. Revision 1.1 2002/08/13 21:40:59 florian
  120. * more fixes for ppc calling conventions
  121. }