narmmat.pas 23 KB

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