ncpucall.pas 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. {*****************************************************************************}
  2. { File : ncpucall.pas }
  3. { Author : Mazen NEIFER }
  4. { Project : Free Pascal Compiler (FPC) }
  5. { Creation date : 2002\26\26 }
  6. { Last modification date : 2002\07\01 }
  7. { Licence : GPL }
  8. { Bug report : [email protected] }
  9. {*****************************************************************************}
  10. {
  11. $Id$
  12. Copyright (c) 1998-2002 by Florian Klaempfl
  13. Generate SPARC assembler for in call nodes
  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 bymethodpointer
  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 ncpucall;
  27. {$INCLUDE fpcdefs.inc}
  28. interface
  29. uses
  30. symdef,node,ncal,ncgcal;
  31. type
  32. TSparccallnode = class(tcgcallnode)
  33. function pass_1 : tnode;override;
  34. procedure load_framepointer;override;
  35. end;
  36. implementation
  37. uses
  38. globtype,systems,
  39. cutils,verbose,globals,
  40. symconst,symbase,symsym,symtable,defbase,paramgr,
  41. {$ifdef GDB}
  42. {$ifdef delphi}
  43. sysutils,
  44. {$else}
  45. strings,
  46. {$endif}
  47. gdb,
  48. {$endif GDB}
  49. cginfo,cgbase,pass_2,
  50. cpuinfo,cpubase,aasmbase,aasmtai,aasmcpu,
  51. nmem,nld,ncnv,
  52. ncgutil,cgobj,tgobj,regvars,rgobj,rgcpu,cg64f32,cgcpu,cpupi;
  53. function TSparccallnode.pass_1 : tnode;
  54. begin
  55. result:=inherited pass_1;
  56. if assigned(result) then
  57. exit;
  58. if procdefinition is tprocdef then
  59. begin
  60. if tprocdef(procdefinition).parast.datasize>TSparcprocinfo(procinfo).maxpushedparasize then
  61. TSparcprocinfo(procinfo).maxpushedparasize:=tprocdef(procdefinition).parast.datasize
  62. end
  63. else
  64. begin
  65. {!!!!}
  66. end;
  67. end;
  68. procedure TSparccallnode.load_framepointer;
  69. begin
  70. { if we call a nested function in a method, we must }
  71. { push also SELF! }
  72. { THAT'S NOT TRUE, we have to load ESI via frame pointer }
  73. { access }
  74. {
  75. begin
  76. loadesi:=false;
  77. emit_reg(A_PUSH,S_L,R_ESI);
  78. end;
  79. }
  80. {
  81. if lexlevel=(tprocdef(procdefinition).parast.symtablelevel) then
  82. begin
  83. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  84. cg.a_param_ref(exprasmlist,OS_ADDR,href,-1);
  85. end
  86. { this is only true if the difference is one !!
  87. but it cannot be more !! }
  88. else if (lexlevel=(tprocdef(procdefinition).parast.symtablelevel)-1) then
  89. begin
  90. cg.a_param_reg(exprasmlist,OS_ADDR,procinfo^.framepointer,-1);
  91. end
  92. else if (lexlevel>(tprocdef(procdefinition).parast.symtablelevel)) then
  93. begin
  94. hregister:=rg.getregisterint(exprasmlist);
  95. reference_reset_base(href,procinfo^.framepointer,procinfo^.framepointer_offset);
  96. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  97. for i:=(tprocdef(procdefinition).parast.symtablelevel) to lexlevel-1 do
  98. begin
  99. {we should get the correct frame_pointer_offset at each level
  100. how can we do this !!! }
  101. reference_reset_base(href,hregister,procinfo^.framepointer_offset);
  102. cg.a_load_ref_reg(exprasmlist,OS_ADDR,href,hregister);
  103. end;
  104. cg.a_param_reg(exprasmlist,OS_ADDR,hregister,-1);
  105. rg.ungetregisterint(exprasmlist,hregister);
  106. end
  107. else
  108. internalerror(2002081303);
  109. }
  110. end;
  111. begin
  112. ccallnode:=TSparccallnode;
  113. end.
  114. {
  115. $Log$
  116. Revision 1.2 2002-08-30 13:16:23 mazen
  117. *call parameter handling is now based on the new param manager
  118. Revision 1.2 2002/08/17 09:23:49 florian
  119. * first part of procinfo rewrite
  120. Revision 1.1 2002/08/13 21:40:59 florian
  121. * more fixes for ppc calling conventions
  122. }