nwasmld.pas 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {
  2. Copyright (c) 1998-2022 by Florian Klaempfl and Nikolay Nikolov
  3. Generate WebAssembly code for load nodes
  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. unit nwasmld;
  17. {$i fpcdefs.inc}
  18. interface
  19. uses
  20. nld,ncgld,
  21. symsym;
  22. type
  23. { twasmloadnode }
  24. twasmloadnode = class(tcgloadnode)
  25. protected
  26. procedure generate_threadvar_access(gvs: tstaticvarsym); override;
  27. end;
  28. implementation
  29. uses
  30. globtype,globals,
  31. aasmbase,aasmdata,
  32. cgbase,cgutils,
  33. symconst;
  34. { twasmloadnode }
  35. procedure twasmloadnode.generate_threadvar_access(gvs: tstaticvarsym);
  36. begin
  37. if ts_wasm_threads in current_settings.targetswitches then
  38. begin
  39. if not(vo_is_weak_external in gvs.varoptions) then
  40. reference_reset_symbol(location.reference,current_asmdata.RefAsmSymbol(gvs.mangledname,AT_TLS,use_indirect_symbol(gvs)),0,location.reference.alignment,[])
  41. else
  42. reference_reset_symbol(location.reference,current_asmdata.WeakRefAsmSymbol(gvs.mangledname,AT_TLS),0,location.reference.alignment,[]);
  43. location.reference.refaddr:=addr_got_tls;
  44. end
  45. else
  46. inherited generate_threadvar_access(gvs);
  47. end;
  48. begin
  49. cloadnode:=twasmloadnode;
  50. end.