narmld.pas 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. href: treference;
  45. hregister : tregister;
  46. handled: boolean;
  47. l : TAsmLabel;
  48. begin
  49. handled:=false;
  50. if tf_section_threadvars in target_info.flags then
  51. begin
  52. if target_info.system in [system_arm_linux] then
  53. begin
  54. if not(pi_uses_threadvar in current_procinfo.flags) then
  55. internalerror(2012012101);
  56. current_asmdata.getjumplabel(l);
  57. reference_reset_symbol(href,current_asmdata.RefAsmSymbol(gvs.mangledname,AT_DATA),-8,sizeof(AInt),[]);
  58. href.refaddr:=addr_gottpoff;
  59. href.relsymbol:=l;
  60. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  61. cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,href,hregister);
  62. cg.a_label(current_asmdata.CurrAsmList,l);
  63. reference_reset(href,0,[]);
  64. href.base:=NR_PC;
  65. href.index:=hregister;
  66. hregister:=cg.getaddressregister(current_asmdata.CurrAsmList);
  67. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,href,hregister);
  68. location.reference.base:=current_procinfo.tlsoffset;
  69. location.reference.index:=hregister;
  70. handled:=true;
  71. end;
  72. end;
  73. if not handled then
  74. inherited;
  75. end;
  76. begin
  77. cloadnode:=tarmloadnode;
  78. end.