2
0

ncpuobj.pas 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. {
  2. $Id$
  3. Copyright (c) 1998-2004 by Kovacs Attila Zoltan and Florian Klaempfl
  4. Generate sparc assembly wrapper code interface implementor objects
  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 by
  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 ncpuobj;
  19. {$i fpcdefs.inc}
  20. interface
  21. implementation
  22. uses
  23. systems,
  24. verbose,globals,globtype,
  25. aasmbase,aasmtai,aasmcpu,
  26. symconst,symdef,
  27. fmodule,
  28. nobj,
  29. cpuinfo,cpubase,
  30. cgutils,cgobj;
  31. type
  32. tsparcclassheader=class(tclassheader)
  33. protected
  34. procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);override;
  35. end;
  36. procedure tsparcclassheader.cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);
  37. var
  38. oldexprasmlist: TAAsmoutput;
  39. make_global : boolean;
  40. href : treference;
  41. begin
  42. if procdef.proctypeoption<>potype_none then
  43. Internalerror(200006137);
  44. if not assigned(procdef._class) or
  45. (procdef.procoptions*[po_classmethod, po_staticmethod,
  46. po_methodpointer, po_interrupt, po_iocheck]<>[]) then
  47. Internalerror(200006138);
  48. if procdef.owner.symtabletype<>objectsymtable then
  49. Internalerror(200109191);
  50. make_global:=false;
  51. if (not current_module.is_unit) or
  52. (procdef.owner.defowner.owner.symtabletype=globalsymtable) then
  53. make_global:=true;
  54. oldexprasmlist:=exprasmlist;
  55. exprasmlist:=asmlist;
  56. if make_global then
  57. exprasmList.concat(Tai_symbol.Createname_global(labelname,AT_FUNCTION,0))
  58. else
  59. exprasmList.concat(Tai_symbol.Createname(labelname,AT_FUNCTION,0));
  60. { set param1 interface to self }
  61. adjustselfvalue(procdef,ioffset);
  62. if po_virtualmethod in procdef.procoptions then
  63. begin
  64. if (procdef.extnumber=$ffff) then
  65. Internalerror(200006139);
  66. { mov 0(%rdi),%rax ; load vmt}
  67. reference_reset_base(href,NR_O0,0);
  68. cg.a_load_ref_reg(asmlist,OS_ADDR,OS_ADDR,href,NR_L0);
  69. { jmp *vmtoffs(%eax) ; method offs }
  70. reference_reset_base(href,NR_L0,procdef._class.vmtmethodoffset(procdef.extnumber));
  71. asmlist.concat(taicpu.op_ref_reg(A_LD,href,NR_L1));
  72. asmlist.concat(taicpu.op_reg(A_JMP,NR_L1));
  73. end
  74. else
  75. asmlist.concat(taicpu.op_sym(A_BA,objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  76. { Delay slot }
  77. asmlist.Concat(TAiCpu.Op_none(A_NOP));
  78. exprasmList.concat(Tai_symbol_end.Createname(labelname));
  79. exprasmlist:=oldexprasmlist;
  80. end;
  81. initialization
  82. cclassheader:=tsparcclassheader;
  83. end.
  84. {
  85. $Log$
  86. Revision 1.2 2004-06-16 20:07:11 florian
  87. * dwarf branch merged
  88. Revision 1.1.2.4 2004/05/14 16:17:25 florian
  89. * the interface wrappers are called before save, so they must use o0 for self
  90. Revision 1.1.2.3 2004/05/13 20:58:47 florian
  91. * fixed register addressed jumps in interface wrappers
  92. Revision 1.1.2.2 2004/05/13 20:10:38 florian
  93. * released variant and interface support
  94. Revision 1.1.2.1 2004/05/13 19:41:10 florian
  95. + ncpuobj added
  96. }