narmmem.pas 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. {
  2. Copyright (c) 2012 by Florian Klaempfl
  3. Generate arm assembler for in memory related 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 narmmem;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,
  22. cgbase,cpuinfo,cpubase,
  23. node,nmem,ncgmem;
  24. type
  25. tarmvecnode = class(tcgvecnode)
  26. procedure update_reference_reg_mul(maybe_const_reg: tregister; l: aint);override;
  27. end;
  28. implementation
  29. uses
  30. systems,
  31. cutils,verbose,
  32. symdef,paramgr,
  33. aasmtai,aasmdata,aasmcpu,
  34. nld,ncon,nadd,
  35. cgutils,cgobj;
  36. {*****************************************************************************
  37. TARMVECNODE
  38. *****************************************************************************}
  39. procedure tarmvecnode.update_reference_reg_mul(maybe_const_reg:tregister;l:aint);
  40. var
  41. hreg: tregister;
  42. hl : longint;
  43. begin
  44. if ((location.reference.base=NR_NO) and (location.reference.index=NR_NO)) or
  45. { simple constant? }
  46. (l=1) or ispowerof2(l,hl) or ispowerof2(l+1,hl) or ispowerof2(l-1,hl) then
  47. inherited update_reference_reg_mul(maybe_const_reg,l)
  48. else if (location.reference.base<>NR_NO) then
  49. begin
  50. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  51. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,l,hreg);
  52. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_reg(A_MLA,hreg,maybe_const_reg,hreg,location.reference.base));
  53. location.reference.base:=hreg;
  54. { update alignment }
  55. if (location.reference.alignment=0) then
  56. internalerror(2012052202);
  57. location.reference.alignment:=newalignment(location.reference.alignment,l);
  58. end
  59. else if (location.reference.index<>NR_NO) then
  60. begin
  61. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  62. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,l,hreg);
  63. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_reg(A_MLA,hreg,maybe_const_reg,hreg,location.reference.index));
  64. location.reference.base:=hreg;
  65. location.reference.index:=NR_NO;
  66. { update alignment }
  67. if (location.reference.alignment=0) then
  68. internalerror(2012052203);
  69. location.reference.alignment:=newalignment(location.reference.alignment,l);
  70. end
  71. else
  72. internalerror(2012052201);
  73. end;
  74. begin
  75. cvecnode:=tarmvecnode;
  76. end.