nllvmutil.pas 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. {
  2. Copyright (c) 20011 by Jonas Maebe
  3. LLVM version of some node tree helper routines
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit nllvmutil;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. aasmdata,ngenutil,
  23. symtype,symconst,symsym,symdef;
  24. type
  25. tllvmnodeutils = class(tnodeutils)
  26. strict protected
  27. class procedure insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint; varalign: shortint); override;
  28. public
  29. class procedure InsertResourceInfo(ResourcesUsed : boolean); override;
  30. class procedure InsertObjectInfo; override;
  31. end;
  32. implementation
  33. uses
  34. verbose,cutils,globals,fmodule,systems,
  35. aasmbase,aasmtai,cpubase,llvmbase,aasmllvm,
  36. symbase,symtable,defutil,
  37. llvmtype;
  38. class procedure tllvmnodeutils.insertbsssym(list: tasmlist; sym: tstaticvarsym; size: asizeint; varalign: shortint);
  39. var
  40. asmsym: tasmsymbol;
  41. field1, field2: tsym;
  42. begin
  43. if sym.globalasmsym then
  44. asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_GLOBAL,AT_DATA)
  45. else
  46. asmsym:=current_asmdata.DefineAsmSymbol(sym.mangledname,AB_LOCAL,AT_DATA);
  47. if not(vo_is_thread_var in sym.varoptions) then
  48. list.concat(taillvmdecl.createdef(asmsym,sym.vardef,nil,sec_data,varalign))
  49. else if tf_section_threadvars in target_info.flags then
  50. list.concat(taillvmdecl.createtls(asmsym,sym.vardef,varalign))
  51. else
  52. list.concat(taillvmdecl.createdef(asmsym,
  53. get_threadvar_record(sym.vardef,field1,field2),
  54. nil,sec_data,varalign));
  55. end;
  56. class procedure tllvmnodeutils.InsertResourceInfo(ResourcesUsed: boolean);
  57. begin
  58. { not supported }
  59. end;
  60. class procedure tllvmnodeutils.InsertObjectInfo;
  61. begin
  62. inherited;
  63. { add "type xx = .." statements for all used recorddefs }
  64. with TLLVMTypeInfo.Create do
  65. begin
  66. inserttypeinfo;
  67. free;
  68. end;
  69. end;
  70. begin
  71. cnodeutils:=tllvmnodeutils;
  72. end.