narmmat.pas 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate ARM assembler for math 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 narmmat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,nmat,ncgmat;
  22. type
  23. tarmmoddivnode = class(tmoddivnode)
  24. function first_moddivint: tnode;override;
  25. procedure pass_generate_code;override;
  26. end;
  27. tarmnotnode = class(tcgnotnode)
  28. procedure second_boolean;override;
  29. end;
  30. tarmunaryminusnode = class(tcgunaryminusnode)
  31. function pass_1: tnode; override;
  32. procedure second_float;override;
  33. end;
  34. tarmshlshrnode = class(tcgshlshrnode)
  35. procedure second_64bit;override;
  36. function first_shlshr64bitint: tnode; override;
  37. end;
  38. implementation
  39. uses
  40. globtype,
  41. cutils,verbose,globals,constexp,
  42. aasmbase,aasmcpu,aasmtai,aasmdata,
  43. defutil,
  44. symtype,symconst,symtable,
  45. cgbase,cgobj,hlcgobj,cgutils,
  46. pass_2,procinfo,
  47. ncon,ncnv,ncal,
  48. cpubase,cpuinfo,
  49. ncgutil,
  50. nadd,pass_1,symdef;
  51. {*****************************************************************************
  52. TARMMODDIVNODE
  53. *****************************************************************************}
  54. function tarmmoddivnode.first_moddivint: tnode;
  55. var
  56. power : longint;
  57. begin
  58. if (right.nodetype=ordconstn) and
  59. (nodetype=divn) and
  60. (ispowerof2(tordconstnode(right).value,power) or
  61. (tordconstnode(right).value=1) or
  62. (tordconstnode(right).value=int64(-1))
  63. ) and
  64. not(is_64bitint(resultdef)) then
  65. result:=nil
  66. else if (current_settings.cputype in [cpu_armv7m,cpu_armv7em]) and
  67. (nodetype=divn) and
  68. not(is_64bitint(resultdef)) then
  69. result:=nil
  70. else if (current_settings.cputype in [cpu_armv7m,cpu_armv7em]) and
  71. (nodetype=modn) and
  72. not(is_64bitint(resultdef)) then
  73. begin
  74. if (right.nodetype=ordconstn) and
  75. ispowerof2(tordconstnode(right).value,power) and
  76. (tordconstnode(right).value<=256) and
  77. (tordconstnode(right).value>0) then
  78. result:=caddnode.create(andn,left,cordconstnode.create(tordconstnode(right).value-1,sinttype,false))
  79. else
  80. begin
  81. result:=caddnode.create(subn,left,caddnode.create(muln,right.getcopy, cmoddivnode.Create(divn,left.getcopy,right.getcopy)));
  82. right:=nil;
  83. end;
  84. left:=nil;
  85. end
  86. else
  87. result:=inherited first_moddivint;
  88. end;
  89. procedure tarmmoddivnode.pass_generate_code;
  90. var
  91. power : longint;
  92. numerator,
  93. helper1,
  94. helper2,
  95. resultreg : tregister;
  96. size : Tcgsize;
  97. so : tshifterop;
  98. procedure genOrdConstNodeDiv;
  99. begin
  100. if tordconstnode(right).value=0 then
  101. internalerror(2005061701)
  102. else if tordconstnode(right).value=1 then
  103. cg.a_load_reg_reg(current_asmdata.CurrAsmList, OS_INT, OS_INT, numerator, resultreg)
  104. else if (tordconstnode(right).value = int64(-1)) then
  105. begin
  106. // note: only in the signed case possible..., may overflow
  107. if cs_check_overflow in current_settings.localswitches then
  108. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  109. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_MVN,
  110. resultreg,numerator),toppostfix(ord(cs_check_overflow in current_settings.localswitches)*ord(PF_S))));
  111. end
  112. else if ispowerof2(tordconstnode(right).value,power) then
  113. begin
  114. if (is_signed(right.resultdef)) then
  115. begin
  116. helper1:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  117. helper2:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  118. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,OS_INT,31,numerator,helper1);
  119. if current_settings.cputype in cpu_thumb then
  120. begin
  121. cg.a_op_const_reg(current_asmdata.CurrAsmList,OP_SAR,OS_INT,32-power,helper1);
  122. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_ADD,helper2,numerator,helper1));
  123. end
  124. else
  125. begin
  126. shifterop_reset(so);
  127. so.shiftmode:=SM_LSR;
  128. so.shiftimm:=32-power;
  129. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_shifterop(A_ADD,helper2,numerator,helper1,so));
  130. end;
  131. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SAR,OS_INT,power,helper2,resultreg);
  132. end
  133. else
  134. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,OS_INT,power,numerator,resultreg)
  135. end;
  136. end;
  137. {
  138. procedure genOrdConstNodeMod;
  139. var
  140. modreg, maskreg, tempreg : tregister;
  141. begin
  142. if (tordconstnode(right).value = 0) then begin
  143. internalerror(2005061702);
  144. end
  145. else if (abs(tordconstnode(right).value.svalue) = 1) then
  146. begin
  147. // x mod +/-1 is always zero
  148. cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 0, resultreg);
  149. end
  150. else if (ispowerof2(tordconstnode(right).value, power)) then
  151. begin
  152. if (is_signed(right.resultdef)) then begin
  153. tempreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  154. maskreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  155. modreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  156. cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, abs(tordconstnode(right).value.svalue)-1, modreg);
  157. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, 31, numerator, maskreg);
  158. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, numerator, modreg, tempreg);
  159. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_ANDC, maskreg, maskreg, modreg));
  160. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC, modreg, tempreg, 0));
  161. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_SUBFE, modreg, modreg, modreg));
  162. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, modreg, maskreg, maskreg);
  163. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_INT, maskreg, tempreg, resultreg);
  164. end else begin
  165. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, tordconstnode(right).value.svalue-1, numerator, resultreg);
  166. end;
  167. end else begin
  168. genOrdConstNodeDiv();
  169. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_MUL, OS_INT, tordconstnode(right).value.svalue, resultreg, resultreg);
  170. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_SUB, OS_INT, resultreg, numerator, resultreg);
  171. end;
  172. end;
  173. }
  174. begin
  175. secondpass(left);
  176. secondpass(right);
  177. if (current_settings.cputype in [cpu_armv7m,cpu_armv7em]) and
  178. (nodetype=divn) and
  179. not(is_64bitint(resultdef)) then
  180. begin
  181. size:=def_cgsize(left.resultdef);
  182. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  183. location_copy(location,left.location);
  184. location.loc := LOC_REGISTER;
  185. location.register := cg.getintregister(current_asmdata.CurrAsmList,size);
  186. resultreg:=location.register;
  187. if (right.nodetype=ordconstn) and
  188. ((tordconstnode(right).value=1) or
  189. (tordconstnode(right).value=int64(-1)) or
  190. (tordconstnode(right).value=0) or
  191. ispowerof2(tordconstnode(right).value,power)) then
  192. begin
  193. numerator:=left.location.register;
  194. genOrdConstNodeDiv;
  195. end
  196. else
  197. begin
  198. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,left.resultdef,true);
  199. if is_signed(left.resultdef) or
  200. is_signed(right.resultdef) then
  201. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_IDIV,OS_INT,right.location.register,left.location.register,location.register)
  202. else
  203. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_DIV,OS_INT,right.location.register,left.location.register,location.register);
  204. end;
  205. end
  206. else
  207. begin
  208. location_copy(location,left.location);
  209. { put numerator in register }
  210. size:=def_cgsize(left.resultdef);
  211. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,
  212. left.resultdef,left.resultdef,true);
  213. location_copy(location,left.location);
  214. numerator:=location.register;
  215. resultreg:=location.register;
  216. if location.loc=LOC_CREGISTER then
  217. begin
  218. location.loc := LOC_REGISTER;
  219. location.register := cg.getintregister(current_asmdata.CurrAsmList,size);
  220. resultreg:=location.register;
  221. end
  222. else if (nodetype=modn) or (right.nodetype=ordconstn) then
  223. begin
  224. // for a modulus op, and for const nodes we need the result register
  225. // to be an extra register
  226. resultreg:=cg.getintregister(current_asmdata.CurrAsmList,size);
  227. end;
  228. if right.nodetype=ordconstn then
  229. begin
  230. if nodetype=divn then
  231. genOrdConstNodeDiv
  232. else
  233. // genOrdConstNodeMod;
  234. end;
  235. location.register:=resultreg;
  236. end;
  237. { unsigned division/module can only overflow in case of division by zero }
  238. { (but checking this overflow flag is more convoluted than performing a }
  239. { simple comparison with 0) }
  240. if is_signed(right.resultdef) then
  241. cg.g_overflowcheck(current_asmdata.CurrAsmList,location,resultdef);
  242. end;
  243. {*****************************************************************************
  244. TARMNOTNODE
  245. *****************************************************************************}
  246. procedure tarmnotnode.second_boolean;
  247. var
  248. hl : tasmlabel;
  249. begin
  250. { if the location is LOC_JUMP, we do the secondpass after the
  251. labels are allocated
  252. }
  253. if left.expectloc=LOC_JUMP then
  254. begin
  255. hl:=current_procinfo.CurrTrueLabel;
  256. current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
  257. current_procinfo.CurrFalseLabel:=hl;
  258. secondpass(left);
  259. if left.location.loc<>LOC_JUMP then
  260. internalerror(2012081305);
  261. maketojumpbool(current_asmdata.CurrAsmList,left,lr_load_regvars);
  262. hl:=current_procinfo.CurrTrueLabel;
  263. current_procinfo.CurrTrueLabel:=current_procinfo.CurrFalseLabel;
  264. current_procinfo.CurrFalseLabel:=hl;
  265. location.loc:=LOC_JUMP;
  266. end
  267. else
  268. begin
  269. secondpass(left);
  270. case left.location.loc of
  271. LOC_FLAGS :
  272. begin
  273. location_copy(location,left.location);
  274. inverse_flags(location.resflags);
  275. end;
  276. LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE,
  277. LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF :
  278. begin
  279. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  280. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  281. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,0));
  282. location_reset(location,LOC_FLAGS,OS_NO);
  283. location.resflags:=F_EQ;
  284. end;
  285. else
  286. internalerror(2003042401);
  287. end;
  288. end;
  289. end;
  290. {*****************************************************************************
  291. TARMUNARYMINUSNODE
  292. *****************************************************************************}
  293. function tarmunaryminusnode.pass_1: tnode;
  294. var
  295. procname: string[31];
  296. fdef : tdef;
  297. begin
  298. if (current_settings.fputype<>fpu_fpv4_s16) or
  299. (tfloatdef(resultdef).floattype=s32real) then
  300. exit(inherited pass_1);
  301. result:=nil;
  302. firstpass(left);
  303. if codegenerror then
  304. exit;
  305. if (left.resultdef.typ=floatdef) then
  306. begin
  307. case tfloatdef(resultdef).floattype of
  308. s64real:
  309. begin
  310. procname:='float64_sub';
  311. fdef:=search_system_type('FLOAT64').typedef;
  312. end;
  313. else
  314. internalerror(2005082801);
  315. end;
  316. result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
  317. ctypeconvnode.create_internal(left,fDef),
  318. ccallparanode.create(ctypeconvnode.create_internal(crealconstnode.create(0,resultdef),fdef),nil))),resultdef);
  319. left:=nil;
  320. end
  321. else
  322. begin
  323. if (left.resultdef.typ=floatdef) then
  324. expectloc:=LOC_FPUREGISTER
  325. else if (left.resultdef.typ=orddef) then
  326. expectloc:=LOC_REGISTER;
  327. end;
  328. end;
  329. procedure tarmunaryminusnode.second_float;
  330. var
  331. op: tasmop;
  332. begin
  333. secondpass(left);
  334. case current_settings.fputype of
  335. fpu_fpa,
  336. fpu_fpa10,
  337. fpu_fpa11:
  338. begin
  339. location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
  340. location:=left.location;
  341. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_const(A_RSF,
  342. location.register,left.location.register,0),
  343. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  344. end;
  345. fpu_vfpv2,
  346. fpu_vfpv3,
  347. fpu_vfpv3_d16:
  348. begin
  349. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  350. location:=left.location;
  351. if (left.location.loc=LOC_CMMREGISTER) then
  352. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  353. if (location.size=OS_F32) then
  354. op:=A_FNEGS
  355. else
  356. op:=A_FNEGD;
  357. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  358. location.register,left.location.register));
  359. end;
  360. fpu_fpv4_s16:
  361. begin
  362. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  363. location:=left.location;
  364. if (left.location.loc=LOC_CMMREGISTER) then
  365. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  366. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_VNEG,
  367. location.register,left.location.register), PF_F32));
  368. end
  369. else
  370. internalerror(2009112602);
  371. end;
  372. end;
  373. function tarmshlshrnode.first_shlshr64bitint: tnode;
  374. begin
  375. if (current_settings.cputype in cpu_thumb+cpu_thumb2) then
  376. result:=inherited
  377. else
  378. result := nil;
  379. end;
  380. procedure tarmshlshrnode.second_64bit;
  381. var
  382. hreg64hi,hreg64lo,shiftreg:Tregister;
  383. v : TConstExprInt;
  384. l1,l2,l3:Tasmlabel;
  385. so: tshifterop;
  386. procedure emit_instr(p: tai);
  387. begin
  388. current_asmdata.CurrAsmList.concat(p);
  389. end;
  390. {Reg1 gets shifted and moved into reg2, and is set to zero afterwards}
  391. procedure shift_more_than_32(reg1, reg2: TRegister; shiftval: Byte ; sm: TShiftMode);
  392. begin
  393. shifterop_reset(so); so.shiftimm:=shiftval - 32; so.shiftmode:=sm;
  394. emit_instr(taicpu.op_reg_reg_shifterop(A_MOV, reg2, reg1, so));
  395. emit_instr(taicpu.op_reg_const(A_MOV, reg1, 0));
  396. end;
  397. procedure shift_less_than_32(reg1, reg2: TRegister; shiftval: Byte; shiftright: boolean);
  398. begin
  399. shifterop_reset(so); so.shiftimm:=shiftval;
  400. if shiftright then so.shiftmode:=SM_LSR else so.shiftmode:=SM_LSL;
  401. emit_instr(taicpu.op_reg_reg_shifterop(A_MOV, reg1, reg1, so));
  402. if shiftright then so.shiftmode:=SM_LSL else so.shiftmode:=SM_LSR;
  403. so.shiftimm:=32-shiftval;
  404. emit_instr(taicpu.op_reg_reg_reg_shifterop(A_ORR, reg1, reg1, reg2, so));
  405. if shiftright then so.shiftmode:=SM_LSR else so.shiftmode:=SM_LSL;
  406. so.shiftimm:=shiftval;
  407. emit_instr(taicpu.op_reg_reg_shifterop(A_MOV, reg2, reg2, so));
  408. end;
  409. procedure shift_by_variable(reg1, reg2, shiftval: TRegister; shiftright: boolean);
  410. var
  411. shiftval2:TRegister;
  412. begin
  413. shifterop_reset(so);
  414. shiftval2:=cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  415. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  416. {Do we shift more than 32 bits?}
  417. emit_instr(setoppostfix(taicpu.op_reg_reg_const(A_RSB, shiftval2, shiftval, 32), PF_S));
  418. {This part cares for 32 bits and more}
  419. emit_instr(setcondition(taicpu.op_reg_reg_const(A_SUB, shiftval2, shiftval, 32), C_MI));
  420. if shiftright then so.shiftmode:=SM_LSR else so.shiftmode:=SM_LSL;
  421. so.rs:=shiftval2;
  422. emit_instr(setcondition(taicpu.op_reg_reg_shifterop(A_MOV, reg2, reg1, so), C_MI));
  423. {Less than 32 bits}
  424. so.rs:=shiftval;
  425. emit_instr(setcondition(taicpu.op_reg_reg_shifterop(A_MOV, reg2, reg2, so), C_PL));
  426. if shiftright then so.shiftmode:=SM_LSL else so.shiftmode:=SM_LSR;
  427. so.rs:=shiftval2;
  428. emit_instr(setcondition(taicpu.op_reg_reg_reg_shifterop(A_ORR, reg2, reg2, reg1, so), C_PL));
  429. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  430. {Final adjustments}
  431. if shiftright then so.shiftmode:=SM_LSR else so.shiftmode:=SM_LSL;
  432. so.rs:=shiftval;
  433. emit_instr(taicpu.op_reg_reg_shifterop(A_MOV, reg1, reg1, so));
  434. end;
  435. begin
  436. if (current_settings.cputype in cpu_thumb+cpu_thumb2) then
  437. begin
  438. inherited;
  439. exit;
  440. end;
  441. location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
  442. { load left operator in a register }
  443. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,resultdef,false);
  444. hreg64hi:=left.location.register64.reghi;
  445. hreg64lo:=left.location.register64.reglo;
  446. location.register64.reghi:=hreg64hi;
  447. location.register64.reglo:=hreg64lo;
  448. { shifting by a constant directly coded: }
  449. if (right.nodetype=ordconstn) then
  450. begin
  451. v:=Tordconstnode(right).value and 63;
  452. {Single bit shift}
  453. if v = 1 then
  454. if nodetype=shln then
  455. begin
  456. {Shift left by one by 2 simple 32bit additions}
  457. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  458. emit_instr(setoppostfix(taicpu.op_reg_reg_reg(A_ADD, hreg64lo, hreg64lo, hreg64lo), PF_S));
  459. emit_instr(taicpu.op_reg_reg_reg(A_ADC, hreg64hi, hreg64hi, hreg64hi));
  460. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  461. end
  462. else
  463. begin
  464. {Shift right by first shifting hi by one and then using RRX (rotate right extended), which rotates through the carry}
  465. shifterop_reset(so); so.shiftmode:=SM_LSR; so.shiftimm:=1;
  466. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  467. emit_instr(setoppostfix(taicpu.op_reg_reg_shifterop(A_MOV, hreg64hi, hreg64hi, so), PF_S));
  468. so.shiftmode:=SM_RRX; so.shiftimm:=0; {RRX does NOT have a shift amount}
  469. emit_instr(taicpu.op_reg_reg_shifterop(A_MOV, hreg64lo, hreg64lo, so));
  470. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  471. end
  472. {A 32bit shift just replaces a register and clears the other}
  473. else if v = 32 then
  474. begin
  475. if nodetype=shln then
  476. emit_instr(taicpu.op_reg_const(A_MOV, hreg64hi, 0))
  477. else
  478. emit_instr(taicpu.op_reg_const(A_MOV, hreg64lo, 0));
  479. location.register64.reghi:=hreg64lo;
  480. location.register64.reglo:=hreg64hi;
  481. end
  482. {Shift LESS than 32}
  483. else if (v < 32) and (v > 1) then
  484. if nodetype=shln then
  485. shift_less_than_32(hreg64hi, hreg64lo, v.uvalue, false)
  486. else
  487. shift_less_than_32(hreg64lo, hreg64hi, v.uvalue, true)
  488. {More than 32}
  489. else if v > 32 then
  490. if nodetype=shln then
  491. shift_more_than_32(hreg64lo, hreg64hi, v.uvalue, SM_LSL)
  492. else
  493. shift_more_than_32(hreg64hi, hreg64lo, v.uvalue, SM_LSR);
  494. end
  495. else
  496. begin
  497. { force right operators in a register }
  498. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,resultdef,false);
  499. if nodetype = shln then
  500. shift_by_variable(hreg64lo,hreg64hi,right.location.register, false)
  501. else
  502. shift_by_variable(hreg64hi,hreg64lo,right.location.register, true);
  503. end;
  504. end;
  505. begin
  506. cmoddivnode:=tarmmoddivnode;
  507. cnotnode:=tarmnotnode;
  508. cunaryminusnode:=tarmunaryminusnode;
  509. cshlshrnode:=tarmshlshrnode;
  510. end.