/compiler/arm/narmmem.pas

https://github.com/slibre/freepascal · Pascal · 85 lines · 47 code · 10 blank · 28 comment · 7 complexity · 224f99ce6a1e949dd36c8cc24896c442 MD5 · raw file

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