nppccal.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 extra_call_code;override;
  26. procedure do_syscall;override;
  27. end;
  28. implementation
  29. uses
  30. globtype,systems,
  31. cutils,verbose,globals,
  32. symconst,symbase,symsym,symtable,defutil,paramgr,parabase,
  33. {$ifdef GDB}
  34. {$ifdef delphi}
  35. sysutils,
  36. {$else}
  37. strings,
  38. {$endif}
  39. gdb,
  40. {$endif GDB}
  41. cgbase,pass_2,
  42. cpuinfo,cpubase,aasmbase,aasmtai,aasmcpu,
  43. nmem,nld,ncnv,
  44. ncgutil,cgutils,cgobj,tgobj,regvars,rgobj,rgcpu,
  45. cg64f32,cgcpu,cpupi,procinfo;
  46. procedure tppccallnode.extra_call_code;
  47. begin
  48. if assigned(varargsparas) then
  49. begin
  50. if va_uses_float_reg in varargsparas.varargsinfo then
  51. exprasmlist.concat(taicpu.op_const_const_const(A_CREQV,6,6,6))
  52. else
  53. exprasmlist.concat(taicpu.op_const_const_const(A_CRXOR,6,6,6));
  54. end;
  55. end;
  56. procedure tppccallnode.do_syscall;
  57. var
  58. tmpref: treference;
  59. begin
  60. case target_info.system of
  61. system_powerpc_morphos:
  62. begin
  63. cg.getexplicitregister(exprasmlist,NR_R0);
  64. cg.getexplicitregister(exprasmlist,NR_R3);
  65. { store call offset into R3 }
  66. exprasmlist.concat(taicpu.op_reg_const(A_LI,NR_R3,-tprocdef(procdefinition).extnumber));
  67. { prepare LR, and call function }
  68. reference_reset_base(tmpref,NR_R2,100); { 100 ($64) is EmulDirectCallOS offset }
  69. exprasmlist.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,tmpref));
  70. exprasmlist.concat(taicpu.op_reg(A_MTLR,NR_R0));
  71. exprasmlist.concat(taicpu.op_none(A_BLRL));
  72. cg.ungetregister(exprasmlist,NR_R0);
  73. cg.ungetregister(exprasmlist,NR_R3);
  74. end;
  75. else
  76. internalerror(2004042901);
  77. end;
  78. end;
  79. begin
  80. ccallnode:=tppccallnode;
  81. end.
  82. {
  83. $Log$
  84. Revision 1.28 2004-09-21 17:25:13 peter
  85. * paraloc branch merged
  86. Revision 1.27.4.1 2004/09/18 20:21:08 jonas
  87. * fixed ppc, but still needs fix in tgobj
  88. Revision 1.27 2004/06/20 08:55:32 florian
  89. * logs truncated
  90. Revision 1.26 2004/04/29 22:18:37 karoly
  91. * removed some unneeded parts of do_syscall
  92. Revision 1.25 2004/04/29 14:36:42 karoly
  93. * little cleanup of the previous commit
  94. Revision 1.24 2004/04/29 14:01:23 karoly
  95. + first implementation of PowerPC/MorphOS do_syscall
  96. }