narmadd.pas 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  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,(left.location.loc<>LOC_CFPUREGISTER));
  127. location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
  128. if left.location.loc<>LOC_CFPUREGISTER then
  129. location.register:=left.location.register
  130. else
  131. location.register:=right.location.register;
  132. case nodetype of
  133. addn :
  134. op:=A_ADF;
  135. muln :
  136. op:=A_MUF;
  137. subn :
  138. op:=A_SUF;
  139. slashn :
  140. op:=A_DVF;
  141. else
  142. internalerror(200308313);
  143. end;
  144. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(op,
  145. location.register,left.location.register,right.location.register),
  146. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  147. end;
  148. fpu_vfpv2,
  149. fpu_vfpv3,
  150. fpu_vfpv3_d16:
  151. begin
  152. { force mmreg as location, left right doesn't matter
  153. as both will be in a fpureg }
  154. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  155. location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,true);
  156. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  157. if left.location.loc<>LOC_CMMREGISTER then
  158. location.register:=left.location.register
  159. else if right.location.loc<>LOC_CMMREGISTER then
  160. location.register:=right.location.register
  161. else
  162. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  163. singleprec:=tfloatdef(left.resultdef).floattype=s32real;
  164. case nodetype of
  165. addn :
  166. if singleprec then
  167. op:=A_FADDS
  168. else
  169. op:=A_FADDD;
  170. muln :
  171. if singleprec then
  172. op:=A_FMULS
  173. else
  174. op:=A_FMULD;
  175. subn :
  176. if singleprec then
  177. op:=A_FSUBS
  178. else
  179. op:=A_FSUBD;
  180. slashn :
  181. if singleprec then
  182. op:=A_FDIVS
  183. else
  184. op:=A_FDIVD;
  185. else
  186. internalerror(2009111401);
  187. end;
  188. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
  189. location.register,left.location.register,right.location.register));
  190. end;
  191. fpu_fpv4_s16:
  192. begin
  193. { force mmreg as location, left right doesn't matter
  194. as both will be in a fpureg }
  195. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  196. location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,true);
  197. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  198. if left.location.loc<>LOC_CMMREGISTER then
  199. location.register:=left.location.register
  200. else if right.location.loc<>LOC_CMMREGISTER then
  201. location.register:=right.location.register
  202. else
  203. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  204. case nodetype of
  205. addn :
  206. op:=A_VADD;
  207. muln :
  208. op:=A_VMUL;
  209. subn :
  210. op:=A_VSUB;
  211. slashn :
  212. op:=A_VDIV;
  213. else
  214. internalerror(2009111401);
  215. end;
  216. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(op, location.register,left.location.register,right.location.register), PF_F32));
  217. end;
  218. fpu_soft:
  219. { this case should be handled already by pass1 }
  220. internalerror(200308252);
  221. else
  222. internalerror(200308251);
  223. end;
  224. end;
  225. procedure tarmaddnode.second_cmpfloat;
  226. var
  227. op: TAsmOp;
  228. begin
  229. pass_left_right;
  230. if (nf_swapped in flags) then
  231. swapleftright;
  232. location_reset(location,LOC_FLAGS,OS_NO);
  233. location.resflags:=getresflags(true);
  234. case current_settings.fputype of
  235. fpu_fpa,
  236. fpu_fpa10,
  237. fpu_fpa11:
  238. begin
  239. { force fpureg as location, left right doesn't matter
  240. as both will be in a fpureg }
  241. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  242. location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
  243. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  244. if nodetype in [equaln,unequaln] then
  245. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMF,
  246. left.location.register,right.location.register),
  247. cgsize2fpuoppostfix[def_cgsize(resultdef)]))
  248. else
  249. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMFE,
  250. left.location.register,right.location.register),
  251. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  252. end;
  253. fpu_vfpv2,
  254. fpu_vfpv3,
  255. fpu_vfpv3_d16:
  256. begin
  257. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  258. location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,true);
  259. if (tfloatdef(left.resultdef).floattype=s32real) then
  260. if nodetype in [equaln,unequaln] then
  261. op:=A_FCMPS
  262. else
  263. op:=A_FCMPES
  264. else if nodetype in [equaln,unequaln] then
  265. op:=A_FCMPD
  266. else
  267. op:=A_FCMPED;
  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_none(A_FMSTAT));
  272. end;
  273. fpu_fpv4_s16:
  274. begin
  275. location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,true);
  276. location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,true);
  277. if nodetype in [equaln,unequaln] then
  278. op:=A_VCMP
  279. else
  280. op:=A_VCMPE;
  281. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  282. left.location.register,right.location.register));
  283. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  284. current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg(A_VMRS, NR_APSR_nzcv, NR_FPSCR));
  285. end;
  286. fpu_soft:
  287. { this case should be handled already by pass1 }
  288. internalerror(2009112404);
  289. end;
  290. location_reset(location,LOC_FLAGS,OS_NO);
  291. location.resflags:=getresflags(false);
  292. end;
  293. procedure tarmaddnode.second_cmpsmallset;
  294. var
  295. tmpreg : tregister;
  296. b: byte;
  297. begin
  298. pass_left_right;
  299. location_reset(location,LOC_FLAGS,OS_NO);
  300. if (not(nf_swapped in flags) and
  301. (nodetype = lten)) or
  302. ((nf_swapped in flags) and
  303. (nodetype = gten)) then
  304. swapleftright;
  305. (* Try to keep right as a constant *)
  306. if (right.location.loc <> LOC_CONSTANT) or
  307. not(is_shifter_const(right.location.value, b)) then
  308. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  309. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  310. case nodetype of
  311. equaln,
  312. unequaln:
  313. begin
  314. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  315. if right.location.loc = LOC_CONSTANT then
  316. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  317. else
  318. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  319. if nodetype = equaln then
  320. location.resflags:=F_EQ
  321. else
  322. location.resflags:=F_NE;
  323. end;
  324. lten,
  325. gten:
  326. begin
  327. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  328. if right.location.loc = LOC_CONSTANT then
  329. begin
  330. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_AND,tmpreg,left.location.register,right.location.value));
  331. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  332. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,tmpreg,right.location.value));
  333. end
  334. else
  335. begin
  336. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
  337. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  338. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
  339. end;
  340. location.resflags:=F_EQ;
  341. end;
  342. else
  343. internalerror(2004012401);
  344. end;
  345. end;
  346. procedure tarmaddnode.second_cmp64bit;
  347. var
  348. unsigned : boolean;
  349. oldnodetype : tnodetype;
  350. dummyreg : tregister;
  351. l: tasmlabel;
  352. begin
  353. unsigned:=not(is_signed(left.resultdef)) or
  354. not(is_signed(right.resultdef));
  355. pass_left_right;
  356. if (nodetype in [equaln,unequaln]) and
  357. (left.nodetype=ordconstn) and (tordconstnode(left).value=0) then
  358. begin
  359. location_reset(location,LOC_FLAGS,OS_NO);
  360. location.resflags:=getresflags(unsigned);
  361. if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  362. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  363. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  364. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  365. if current_settings.cputype in cpu_thumb then
  366. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,right.location.register64.reglo,right.location.register64.reghi,dummyreg)
  367. else
  368. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,right.location.register64.reglo,right.location.register64.reghi),PF_S));
  369. end
  370. else if (nodetype in [equaln,unequaln]) and
  371. (right.nodetype=ordconstn) and (tordconstnode(right).value=0) then
  372. begin
  373. location_reset(location,LOC_FLAGS,OS_NO);
  374. location.resflags:=getresflags(unsigned);
  375. if not(left.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  376. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  377. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  378. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  379. if current_settings.cputype in cpu_thumb then
  380. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,dummyreg)
  381. else
  382. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,left.location.register64.reglo,left.location.register64.reghi),PF_S));
  383. end
  384. else
  385. begin
  386. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  387. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  388. { operation requiring proper N, Z and C flags ? }
  389. if unsigned or (nodetype in [equaln,unequaln]) then
  390. begin
  391. location_reset(location,LOC_FLAGS,OS_NO);
  392. location.resflags:=getresflags(unsigned);
  393. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  394. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  395. if current_settings.cputype in (cpu_thumb+cpu_thumb2) then
  396. begin
  397. current_asmdata.getjumplabel(l);
  398. cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,l);
  399. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  400. cg.a_label(current_asmdata.CurrAsmList,l);
  401. end
  402. else
  403. current_asmdata.CurrAsmList.concat(setcondition(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo),C_EQ));
  404. end
  405. else
  406. { operation requiring proper N, Z and V flags ? }
  407. begin
  408. location_reset(location,LOC_JUMP,OS_NO);
  409. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  410. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  411. { the jump the sequence is a little bit hairy }
  412. case nodetype of
  413. ltn,gtn:
  414. begin
  415. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrTrueLabel);
  416. { cheat a little bit for the negative test }
  417. toggleflag(nf_swapped);
  418. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrFalseLabel);
  419. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  420. toggleflag(nf_swapped);
  421. end;
  422. lten,gten:
  423. begin
  424. oldnodetype:=nodetype;
  425. if nodetype=lten then
  426. nodetype:=ltn
  427. else
  428. nodetype:=gtn;
  429. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
  430. { cheat for the negative test }
  431. if nodetype=ltn then
  432. nodetype:=gtn
  433. else
  434. nodetype:=ltn;
  435. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
  436. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  437. nodetype:=oldnodetype;
  438. end;
  439. end;
  440. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  441. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  442. { the comparisaion of the low dword have to be
  443. always unsigned! }
  444. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
  445. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  446. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  447. end;
  448. end;
  449. end;
  450. function tarmaddnode.pass_1 : tnode;
  451. var
  452. unsigned : boolean;
  453. begin
  454. result:=inherited pass_1;
  455. if not(assigned(result)) then
  456. begin
  457. unsigned:=not(is_signed(left.resultdef)) or
  458. not(is_signed(right.resultdef));
  459. if is_64bit(left.resultdef) and
  460. ((nodetype in [equaln,unequaln]) or
  461. (unsigned and (nodetype in [ltn,lten,gtn,gten]))
  462. ) then
  463. expectloc:=LOC_FLAGS;
  464. end;
  465. end;
  466. function tarmaddnode.first_addfloat: tnode;
  467. var
  468. procname: string[31];
  469. { do we need to reverse the result ? }
  470. notnode : boolean;
  471. fdef : tdef;
  472. begin
  473. result := nil;
  474. notnode := false;
  475. if current_settings.fputype = fpu_fpv4_s16 then
  476. begin
  477. case tfloatdef(left.resultdef).floattype of
  478. s32real:
  479. begin
  480. result:=nil;
  481. notnode:=false;
  482. end;
  483. s64real:
  484. begin
  485. fdef:=search_system_type('FLOAT64').typedef;
  486. procname:='float64';
  487. case nodetype of
  488. addn:
  489. procname:=procname+'_add';
  490. muln:
  491. procname:=procname+'_mul';
  492. subn:
  493. procname:=procname+'_sub';
  494. slashn:
  495. procname:=procname+'_div';
  496. ltn:
  497. procname:=procname+'_lt';
  498. lten:
  499. procname:=procname+'_le';
  500. gtn:
  501. begin
  502. procname:=procname+'_le';
  503. notnode:=true;
  504. end;
  505. gten:
  506. begin
  507. procname:=procname+'_lt';
  508. notnode:=true;
  509. end;
  510. equaln:
  511. procname:=procname+'_eq';
  512. unequaln:
  513. begin
  514. procname:=procname+'_eq';
  515. notnode:=true;
  516. end;
  517. else
  518. CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),left.resultdef.typename,right.resultdef.typename);
  519. end;
  520. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  521. resultdef:=pasbool8type;
  522. result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
  523. ctypeconvnode.create_internal(right,fdef),
  524. ccallparanode.create(
  525. ctypeconvnode.create_internal(left,fdef),nil))),resultdef);
  526. left:=nil;
  527. right:=nil;
  528. { do we need to reverse the result }
  529. if notnode then
  530. result:=cnotnode.create(result);
  531. end;
  532. end;
  533. end
  534. else
  535. result:=inherited first_addfloat;
  536. end;
  537. procedure tarmaddnode.second_cmpordinal;
  538. var
  539. unsigned : boolean;
  540. tmpreg : tregister;
  541. b : byte;
  542. begin
  543. pass_left_right;
  544. force_reg_left_right(true,true);
  545. unsigned:=not(is_signed(left.resultdef)) or
  546. not(is_signed(right.resultdef));
  547. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  548. if right.location.loc = LOC_CONSTANT then
  549. begin
  550. if (not(current_settings.cputype in cpu_thumb) and is_shifter_const(right.location.value,b)) or
  551. ((current_settings.cputype in cpu_thumb) and is_thumb_imm(right.location.value)) then
  552. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  553. else
  554. begin
  555. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  556. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,
  557. right.location.value,tmpreg);
  558. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,tmpreg));
  559. end;
  560. end
  561. else
  562. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  563. location_reset(location,LOC_FLAGS,OS_NO);
  564. location.resflags:=getresflags(unsigned);
  565. end;
  566. begin
  567. caddnode:=tarmaddnode;
  568. end.