narmld.pas 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. {
  2. Copyright (c) 1998-2018 by Florian Klaempfl
  3. Generate arm assembler 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. }
  17. unit narmld;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. symsym,
  23. node,ncgld,pass_1,aasmbase;
  24. type
  25. tarmloadnode = class(tcgloadnode)
  26. procedure generate_threadvar_access(gvs : tstaticvarsym); override;
  27. end;
  28. implementation
  29. uses
  30. globals,verbose,
  31. cgbase,cgobj,cgutils,
  32. aasmdata,
  33. systems,
  34. symcpu,symdef,
  35. nld,
  36. cpubase,
  37. parabase,
  38. procinfo;
  39. {*****************************************************************************
  40. TARMLOADNODE
  41. *****************************************************************************}
  42. procedure tarmloadnode.generate_threadvar_access(gvs: tstaticvarsym);
  43. var
  44. paraloc1 : tcgpara;
  45. pd: tprocdef;
  46. href: treference;
  47. hregister : tregister;
  48. handled: boolean;
  49. l : TAsmLabel;
  50. begin
  51. handled:=false;
  52. if tf_section_threadvars in target_info.flags then
  53. begin
  54. if target_info.system in [system_arm_linux] then
  55. begin
  56. if not(pi_uses_threadvar in current_procinfo.flags) then
  57. internalerror(2012012101);
  58. current_asmdata.getjumplabel(l);
  59. reference_reset_symbol(href,current_asmdata.RefAsmSymbol(gvs.mangledname,AT_DATA),-8,sizeof(AInt),[]);
  60. href.refaddr:=addr_gottpoff;
  61. href.relsymbol:=l;
  62. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  63. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,hregister);
  64. cg.a_label(current_asmdata.CurrAsmList,l);
  65. reference_reset(href,0,[]);
  66. href.base:=NR_PC;
  67. href.index:=hregister;
  68. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  69. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,hregister);
  70. location.reference.base:=current_procinfo.tlsoffset;
  71. location.reference.index:=hregister;
  72. handled:=true;
  73. end;
  74. end;
  75. if not handled then
  76. inherited;
  77. end;
  78. begin
  79. cloadnode:=tarmloadnode;
  80. end.