/compiler/arm/narmmem.pas
Pascal | 85 lines | 47 code | 10 blank | 28 comment | 7 complexity | 224f99ce6a1e949dd36c8cc24896c442 MD5 | raw file
Possible License(s): LGPL-2.0, LGPL-2.1, LGPL-3.0
1{ 2 Copyright (c) 2012 by Florian Klaempfl 3 4 Generate arm assembler for in memory related nodes 5 6 This program is free software; you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation; either version 2 of the License, or 9 (at your option) any later version. 10 11 This program is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with this program; if not, write to the Free Software 18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 20 **************************************************************************** 21} 22unit narmmem; 23 24{$i fpcdefs.inc} 25 26interface 27 28 uses 29 globtype, 30 cgbase,cpubase,nmem,ncgmem; 31 32 type 33 tarmvecnode = class(tcgvecnode) 34 procedure update_reference_reg_mul(maybe_const_reg: tregister; l: aint);override; 35 end; 36 37implementation 38 39 uses 40 cutils,verbose,aasmdata,aasmcpu,cgobj; 41 42{***************************************************************************** 43 TARMVECNODE 44*****************************************************************************} 45 46 procedure tarmvecnode.update_reference_reg_mul(maybe_const_reg:tregister;l:aint); 47 var 48 hreg: tregister; 49 hl : longint; 50 begin 51 if ((location.reference.base=NR_NO) and (location.reference.index=NR_NO)) or 52 { simple constant? } 53 (l=1) or ispowerof2(l,hl) or ispowerof2(l+1,hl) or ispowerof2(l-1,hl) then 54 inherited update_reference_reg_mul(maybe_const_reg,l) 55 else if (location.reference.base<>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.base)); 60 location.reference.base:=hreg; 61 { update alignment } 62 if (location.reference.alignment=0) then 63 internalerror(2012052202); 64 location.reference.alignment:=newalignment(location.reference.alignment,l); 65 end 66 else if (location.reference.index<>NR_NO) then 67 begin 68 hreg:=cg.getaddressregister(current_asmdata.CurrAsmList); 69 cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_ADDR,l,hreg); 70 current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_reg(A_MLA,hreg,maybe_const_reg,hreg,location.reference.index)); 71 location.reference.base:=hreg; 72 location.reference.index:=NR_NO; 73 { update alignment } 74 if (location.reference.alignment=0) then 75 internalerror(2012052203); 76 location.reference.alignment:=newalignment(location.reference.alignment,l); 77 end 78 else 79 internalerror(2012052201); 80 end; 81 82 83begin 84 cvecnode:=tarmvecnode; 85end.