narmmem.pas 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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,cpubase,nmem,ncgmem;
  23. type
  24. tarmvecnode = class(tcgvecnode)
  25. procedure update_reference_reg_mul(maybe_const_reg: tregister; l: aint);override;
  26. end;
  27. implementation
  28. uses
  29. cutils,verbose,globals,aasmdata,aasmcpu,cgobj,
  30. cpuinfo;
  31. {*****************************************************************************
  32. TARMVECNODE
  33. *****************************************************************************}
  34. procedure tarmvecnode.update_reference_reg_mul(maybe_const_reg:tregister;l:aint);
  35. var
  36. hreg: tregister;
  37. hl : longint;
  38. begin
  39. if ((location.reference.base=NR_NO) and (location.reference.index=NR_NO)) or
  40. (current_settings.cputype in cpu_thumb) or
  41. { simple constant? }
  42. (l=1) or ispowerof2(l,hl) or ispowerof2(l+1,hl) or ispowerof2(l-1,hl) then
  43. inherited update_reference_reg_mul(maybe_const_reg,l)
  44. else if (location.reference.base<>NR_NO) then
  45. begin
  46. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  47. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,l,hreg);
  48. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_reg(A_MLA,hreg,maybe_const_reg,hreg,location.reference.base));
  49. location.reference.base:=hreg;
  50. { update alignment }
  51. if (location.reference.alignment=0) then
  52. internalerror(2012052202);
  53. location.reference.alignment:=newalignment(location.reference.alignment,l);
  54. end
  55. else if (location.reference.index<>NR_NO) then
  56. begin
  57. hreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
  58. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,l,hreg);
  59. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_reg(A_MLA,hreg,maybe_const_reg,hreg,location.reference.index));
  60. location.reference.base:=hreg;
  61. location.reference.index:=NR_NO;
  62. { update alignment }
  63. if (location.reference.alignment=0) then
  64. internalerror(2012052203);
  65. location.reference.alignment:=newalignment(location.reference.alignment,l);
  66. end
  67. else
  68. internalerror(2012052201);
  69. end;
  70. begin
  71. cvecnode:=tarmvecnode;
  72. end.