narmadd.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. {
  2. Copyright (c) 2000-2002 by Florian Klaempfl
  3. Code generation for add nodes on the ARM
  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 narmadd;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,ncgadd,cpubase;
  22. type
  23. tarmaddnode = class(tcgaddnode)
  24. private
  25. function GetResFlags(unsigned:Boolean):TResFlags;
  26. public
  27. function pass_1 : tnode;override;
  28. protected
  29. function first_addfloat: tnode; override;
  30. procedure second_addfloat;override;
  31. procedure second_cmpfloat;override;
  32. procedure second_cmpordinal;override;
  33. procedure second_cmpsmallset;override;
  34. procedure second_cmp64bit;override;
  35. end;
  36. implementation
  37. uses
  38. globtype,verbose,globals,
  39. constexp,symdef,symtable,symtype,
  40. aasmbase,aasmdata,aasmcpu,defutil,htypechk,
  41. cgbase,cgutils,
  42. cpuinfo,pass_1,procinfo,
  43. ncon,nadd,ncnv,ncal,nmat,
  44. ncgutil,cgobj,
  45. hlcgobj
  46. ;
  47. {*****************************************************************************
  48. TSparcAddNode
  49. *****************************************************************************}
  50. function tarmaddnode.GetResFlags(unsigned:Boolean):TResFlags;
  51. begin
  52. case NodeType of
  53. equaln:
  54. GetResFlags:=F_EQ;
  55. unequaln:
  56. GetResFlags:=F_NE;
  57. else
  58. if not(unsigned) then
  59. begin
  60. if nf_swapped in flags then
  61. case NodeType of
  62. ltn:
  63. GetResFlags:=F_GT;
  64. lten:
  65. GetResFlags:=F_GE;
  66. gtn:
  67. GetResFlags:=F_LT;
  68. gten:
  69. GetResFlags:=F_LE;
  70. end
  71. else
  72. case NodeType of
  73. ltn:
  74. GetResFlags:=F_LT;
  75. lten:
  76. GetResFlags:=F_LE;
  77. gtn:
  78. GetResFlags:=F_GT;
  79. gten:
  80. GetResFlags:=F_GE;
  81. end;
  82. end
  83. else
  84. begin
  85. if nf_swapped in Flags then
  86. case NodeType of
  87. ltn:
  88. GetResFlags:=F_HI;
  89. lten:
  90. GetResFlags:=F_CS;
  91. gtn:
  92. GetResFlags:=F_CC;
  93. gten:
  94. GetResFlags:=F_LS;
  95. end
  96. else
  97. case NodeType of
  98. ltn:
  99. GetResFlags:=F_CC;
  100. lten:
  101. GetResFlags:=F_LS;
  102. gtn:
  103. GetResFlags:=F_HI;
  104. gten:
  105. GetResFlags:=F_CS;
  106. end;
  107. end;
  108. end;
  109. end;
  110. procedure tarmaddnode.second_addfloat;
  111. var
  112. op : TAsmOp;
  113. singleprec: boolean;
  114. begin
  115. pass_left_right;
  116. if (nf_swapped in flags) then
  117. swapleftright;
  118. case current_settings.fputype of
  119. fpu_fpa,
  120. fpu_fpa10,
  121. fpu_fpa11:
  122. begin
  123. { force fpureg as location, left right doesn't matter
  124. as both will be in a fpureg }
  125. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  126. location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
  127. location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
  128. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  129. case nodetype of
  130. addn :
  131. op:=A_ADF;
  132. muln :
  133. op:=A_MUF;
  134. subn :
  135. op:=A_SUF;
  136. slashn :
  137. op:=A_DVF;
  138. else
  139. internalerror(200308313);
  140. end;
  141. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(op,
  142. location.register,left.location.register,right.location.register),
  143. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  144. end;
  145. fpu_vfpv2,
  146. fpu_vfpv3,
  147. fpu_vfpv3_d16:
  148. begin
  149. { force mmreg as location, left right doesn't matter
  150. as both will be in a fpureg }
  151. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  152. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  153. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  154. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  155. singleprec:=tfloatdef(left.resultdef).floattype=s32real;
  156. case nodetype of
  157. addn :
  158. if singleprec then
  159. op:=A_FADDS
  160. else
  161. op:=A_FADDD;
  162. muln :
  163. if singleprec then
  164. op:=A_FMULS
  165. else
  166. op:=A_FMULD;
  167. subn :
  168. if singleprec then
  169. op:=A_FSUBS
  170. else
  171. op:=A_FSUBD;
  172. slashn :
  173. if singleprec then
  174. op:=A_FDIVS
  175. else
  176. op:=A_FDIVD;
  177. else
  178. internalerror(2009111401);
  179. end;
  180. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
  181. location.register,left.location.register,right.location.register));
  182. end;
  183. fpu_fpv4_s16:
  184. begin
  185. { force mmreg as location, left right doesn't matter
  186. as both will be in a fpureg }
  187. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  188. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  189. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  190. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  191. case nodetype of
  192. addn :
  193. op:=A_VADD;
  194. muln :
  195. op:=A_VMUL;
  196. subn :
  197. op:=A_VSUB;
  198. slashn :
  199. op:=A_VDIV;
  200. else
  201. internalerror(2009111401);
  202. end;
  203. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(op, location.register,left.location.register,right.location.register), PF_F32));
  204. end;
  205. fpu_soft:
  206. { this case should be handled already by pass1 }
  207. internalerror(200308252);
  208. else
  209. internalerror(200308251);
  210. end;
  211. end;
  212. procedure tarmaddnode.second_cmpfloat;
  213. var
  214. op: TAsmOp;
  215. begin
  216. pass_left_right;
  217. if (nf_swapped in flags) then
  218. swapleftright;
  219. location_reset(location,LOC_FLAGS,OS_NO);
  220. location.resflags:=getresflags(true);
  221. case current_settings.fputype of
  222. fpu_fpa,
  223. fpu_fpa10,
  224. fpu_fpa11:
  225. begin
  226. { force fpureg as location, left right doesn't matter
  227. as both will be in a fpureg }
  228. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  229. location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
  230. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  231. if nodetype in [equaln,unequaln] then
  232. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMF,
  233. left.location.register,right.location.register),
  234. cgsize2fpuoppostfix[def_cgsize(resultdef)]))
  235. else
  236. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMFE,
  237. left.location.register,right.location.register),
  238. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  239. end;
  240. fpu_vfpv2,
  241. fpu_vfpv3,
  242. fpu_vfpv3_d16:
  243. begin
  244. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  245. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  246. if (tfloatdef(left.resultdef).floattype=s32real) then
  247. if nodetype in [equaln,unequaln] then
  248. op:=A_FCMPS
  249. else
  250. op:=A_FCMPES
  251. else if nodetype in [equaln,unequaln] then
  252. op:=A_FCMPD
  253. else
  254. op:=A_FCMPED;
  255. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  256. left.location.register,right.location.register));
  257. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  258. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_FMSTAT));
  259. end;
  260. fpu_fpv4_s16:
  261. begin
  262. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  263. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  264. if nodetype in [equaln,unequaln] then
  265. op:=A_VCMP
  266. else
  267. op:=A_VCMPE;
  268. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  269. left.location.register,right.location.register));
  270. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  271. current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg(A_VMRS, NR_APSR_nzcv, NR_FPSCR));
  272. end;
  273. fpu_soft:
  274. { this case should be handled already by pass1 }
  275. internalerror(2009112404);
  276. end;
  277. location_reset(location,LOC_FLAGS,OS_NO);
  278. location.resflags:=getresflags(false);
  279. end;
  280. procedure tarmaddnode.second_cmpsmallset;
  281. var
  282. tmpreg : tregister;
  283. b: byte;
  284. begin
  285. pass_left_right;
  286. location_reset(location,LOC_FLAGS,OS_NO);
  287. if (not(nf_swapped in flags) and
  288. (nodetype = lten)) or
  289. ((nf_swapped in flags) and
  290. (nodetype = gten)) then
  291. swapleftright;
  292. (* Try to keep right as a constant *)
  293. if (right.location.loc <> LOC_CONSTANT) or
  294. not(is_shifter_const(right.location.value, b)) or
  295. ((current_settings.cputype in cpu_thumb) and not(is_thumb_imm(right.location.value))) then
  296. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  297. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  298. case nodetype of
  299. equaln,
  300. unequaln:
  301. begin
  302. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  303. if right.location.loc = LOC_CONSTANT then
  304. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  305. else
  306. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  307. if nodetype = equaln then
  308. location.resflags:=F_EQ
  309. else
  310. location.resflags:=F_NE;
  311. end;
  312. lten,
  313. gten:
  314. begin
  315. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  316. if right.location.loc = LOC_CONSTANT then
  317. begin
  318. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_AND,tmpreg,left.location.register,right.location.value));
  319. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  320. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,tmpreg,right.location.value));
  321. end
  322. else
  323. begin
  324. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
  325. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  326. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
  327. end;
  328. location.resflags:=F_EQ;
  329. end;
  330. else
  331. internalerror(2004012401);
  332. end;
  333. end;
  334. procedure tarmaddnode.second_cmp64bit;
  335. var
  336. unsigned : boolean;
  337. oldnodetype : tnodetype;
  338. dummyreg : tregister;
  339. l: tasmlabel;
  340. begin
  341. unsigned:=not(is_signed(left.resultdef)) or
  342. not(is_signed(right.resultdef));
  343. pass_left_right;
  344. if (nodetype in [equaln,unequaln]) and
  345. (left.nodetype=ordconstn) and (tordconstnode(left).value=0) then
  346. begin
  347. location_reset(location,LOC_FLAGS,OS_NO);
  348. location.resflags:=getresflags(unsigned);
  349. if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  350. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  351. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  352. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  353. if current_settings.cputype in cpu_thumb then
  354. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,right.location.register64.reglo,right.location.register64.reghi,dummyreg)
  355. else
  356. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,right.location.register64.reglo,right.location.register64.reghi),PF_S));
  357. end
  358. else if (nodetype in [equaln,unequaln]) and
  359. (right.nodetype=ordconstn) and (tordconstnode(right).value=0) then
  360. begin
  361. location_reset(location,LOC_FLAGS,OS_NO);
  362. location.resflags:=getresflags(unsigned);
  363. if not(left.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  364. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  365. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  366. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  367. if current_settings.cputype in cpu_thumb then
  368. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,dummyreg)
  369. else
  370. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,left.location.register64.reglo,left.location.register64.reghi),PF_S));
  371. end
  372. else
  373. begin
  374. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  375. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  376. { operation requiring proper N, Z and C flags ? }
  377. if unsigned or (nodetype in [equaln,unequaln]) then
  378. begin
  379. location_reset(location,LOC_FLAGS,OS_NO);
  380. location.resflags:=getresflags(unsigned);
  381. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  382. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  383. if current_settings.cputype in (cpu_thumb+cpu_thumb2) then
  384. begin
  385. current_asmdata.getjumplabel(l);
  386. cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,l);
  387. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  388. cg.a_label(current_asmdata.CurrAsmList,l);
  389. end
  390. else
  391. current_asmdata.CurrAsmList.concat(setcondition(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo),C_EQ));
  392. end
  393. else
  394. { operation requiring proper N, Z and V flags ? }
  395. begin
  396. location_reset(location,LOC_JUMP,OS_NO);
  397. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  398. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  399. { the jump the sequence is a little bit hairy }
  400. case nodetype of
  401. ltn,gtn:
  402. begin
  403. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrTrueLabel);
  404. { cheat a little bit for the negative test }
  405. toggleflag(nf_swapped);
  406. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrFalseLabel);
  407. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  408. toggleflag(nf_swapped);
  409. end;
  410. lten,gten:
  411. begin
  412. oldnodetype:=nodetype;
  413. if nodetype=lten then
  414. nodetype:=ltn
  415. else
  416. nodetype:=gtn;
  417. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
  418. { cheat for the negative test }
  419. if nodetype=ltn then
  420. nodetype:=gtn
  421. else
  422. nodetype:=ltn;
  423. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
  424. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  425. nodetype:=oldnodetype;
  426. end;
  427. end;
  428. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  429. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  430. { the comparisaion of the low dword have to be
  431. always unsigned! }
  432. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
  433. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  434. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  435. end;
  436. end;
  437. end;
  438. function tarmaddnode.pass_1 : tnode;
  439. var
  440. unsigned : boolean;
  441. begin
  442. result:=inherited pass_1;
  443. if not(assigned(result)) then
  444. begin
  445. unsigned:=not(is_signed(left.resultdef)) or
  446. not(is_signed(right.resultdef));
  447. if is_64bit(left.resultdef) and
  448. ((nodetype in [equaln,unequaln]) or
  449. (unsigned and (nodetype in [ltn,lten,gtn,gten]))
  450. ) then
  451. expectloc:=LOC_FLAGS;
  452. end;
  453. end;
  454. function tarmaddnode.first_addfloat: tnode;
  455. var
  456. procname: string[31];
  457. { do we need to reverse the result ? }
  458. notnode : boolean;
  459. fdef : tdef;
  460. begin
  461. result := nil;
  462. notnode := false;
  463. if current_settings.fputype = fpu_fpv4_s16 then
  464. begin
  465. case tfloatdef(left.resultdef).floattype of
  466. s32real:
  467. begin
  468. result:=nil;
  469. notnode:=false;
  470. end;
  471. s64real:
  472. begin
  473. fdef:=search_system_type('FLOAT64').typedef;
  474. procname:='float64';
  475. case nodetype of
  476. addn:
  477. procname:=procname+'_add';
  478. muln:
  479. procname:=procname+'_mul';
  480. subn:
  481. procname:=procname+'_sub';
  482. slashn:
  483. procname:=procname+'_div';
  484. ltn:
  485. procname:=procname+'_lt';
  486. lten:
  487. procname:=procname+'_le';
  488. gtn:
  489. begin
  490. procname:=procname+'_le';
  491. notnode:=true;
  492. end;
  493. gten:
  494. begin
  495. procname:=procname+'_lt';
  496. notnode:=true;
  497. end;
  498. equaln:
  499. procname:=procname+'_eq';
  500. unequaln:
  501. begin
  502. procname:=procname+'_eq';
  503. notnode:=true;
  504. end;
  505. else
  506. CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),left.resultdef.typename,right.resultdef.typename);
  507. end;
  508. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  509. resultdef:=pasbool8type;
  510. result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
  511. ctypeconvnode.create_internal(right,fdef),
  512. ccallparanode.create(
  513. ctypeconvnode.create_internal(left,fdef),nil))),resultdef);
  514. left:=nil;
  515. right:=nil;
  516. { do we need to reverse the result }
  517. if notnode then
  518. result:=cnotnode.create(result);
  519. end;
  520. end;
  521. end
  522. else
  523. result:=inherited first_addfloat;
  524. end;
  525. procedure tarmaddnode.second_cmpordinal;
  526. var
  527. unsigned : boolean;
  528. tmpreg : tregister;
  529. b : byte;
  530. begin
  531. pass_left_right;
  532. force_reg_left_right(true,true);
  533. unsigned:=not(is_signed(left.resultdef)) or
  534. not(is_signed(right.resultdef));
  535. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  536. if right.location.loc = LOC_CONSTANT then
  537. begin
  538. if (not(current_settings.cputype in cpu_thumb) and is_shifter_const(right.location.value,b)) or
  539. ((current_settings.cputype in cpu_thumb) and is_thumb_imm(right.location.value)) then
  540. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  541. else
  542. begin
  543. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  544. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,
  545. right.location.value,tmpreg);
  546. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,tmpreg));
  547. end;
  548. end
  549. else
  550. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  551. location_reset(location,LOC_FLAGS,OS_NO);
  552. location.resflags:=getresflags(unsigned);
  553. end;
  554. begin
  555. caddnode:=tarmaddnode;
  556. end.