nx64obj.pas 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Kovacs Attila Zoltan
  4. Generate i386 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 nx64obj;
  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. tx8664classheader=class(tclassheader)
  33. protected
  34. procedure cgintfwrapper(asmlist: TAAsmoutput; procdef: tprocdef; const labelname: string; ioffset: longint);override;
  35. end;
  36. procedure tx8664classheader.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_RDI,0);
  68. cg.a_load_ref_reg(asmlist,OS_ADDR,OS_ADDR,href,NR_RAX);
  69. { jmp *vmtoffs(%eax) ; method offs }
  70. reference_reset_base(href,NR_RAX,procdef._class.vmtmethodoffset(procdef.extnumber));
  71. asmlist.concat(taicpu.op_ref_reg(A_MOV,S_Q,href,NR_RAX));
  72. asmlist.concat(taicpu.op_reg(A_JMP,S_Q,NR_RAX));
  73. end
  74. else
  75. asmlist.concat(taicpu.op_sym(A_JMP,S_NO,objectlibrary.newasmsymbol(procdef.mangledname,AB_EXTERNAL,AT_FUNCTION)));
  76. exprasmList.concat(Tai_symbol_end.Createname(labelname));
  77. exprasmlist:=oldexprasmlist;
  78. end;
  79. initialization
  80. cclassheader:=tx8664classheader;
  81. end.
  82. {
  83. $Log$
  84. Revision 1.2 2004-06-16 20:07:11 florian
  85. * dwarf branch merged
  86. Revision 1.1.2.3 2004/05/10 21:28:35 peter
  87. * section_smartlink enabled for gas under linux
  88. Revision 1.1.2.2 2004/04/29 21:54:29 florian
  89. * interface wrappers fixed
  90. Revision 1.1.2.1 2004/04/22 21:14:34 peter
  91. * nx64obj added, untested
  92. }