narmadd.pas 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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)) or
  308. ((current_settings.cputype in cpu_thumb) and not(is_thumb_imm(right.location.value))) then
  309. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  310. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  311. case nodetype of
  312. equaln,
  313. unequaln:
  314. begin
  315. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  316. if right.location.loc = LOC_CONSTANT then
  317. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  318. else
  319. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  320. if nodetype = equaln then
  321. location.resflags:=F_EQ
  322. else
  323. location.resflags:=F_NE;
  324. end;
  325. lten,
  326. gten:
  327. begin
  328. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  329. if right.location.loc = LOC_CONSTANT then
  330. begin
  331. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_AND,tmpreg,left.location.register,right.location.value));
  332. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  333. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,tmpreg,right.location.value));
  334. end
  335. else
  336. begin
  337. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
  338. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  339. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
  340. end;
  341. location.resflags:=F_EQ;
  342. end;
  343. else
  344. internalerror(2004012401);
  345. end;
  346. end;
  347. procedure tarmaddnode.second_cmp64bit;
  348. var
  349. unsigned : boolean;
  350. oldnodetype : tnodetype;
  351. dummyreg : tregister;
  352. l: tasmlabel;
  353. begin
  354. unsigned:=not(is_signed(left.resultdef)) or
  355. not(is_signed(right.resultdef));
  356. pass_left_right;
  357. if (nodetype in [equaln,unequaln]) and
  358. (left.nodetype=ordconstn) and (tordconstnode(left).value=0) then
  359. begin
  360. location_reset(location,LOC_FLAGS,OS_NO);
  361. location.resflags:=getresflags(unsigned);
  362. if not(right.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  363. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  364. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  365. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  366. if current_settings.cputype in cpu_thumb then
  367. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,right.location.register64.reglo,right.location.register64.reghi,dummyreg)
  368. else
  369. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,right.location.register64.reglo,right.location.register64.reghi),PF_S));
  370. end
  371. else if (nodetype in [equaln,unequaln]) and
  372. (right.nodetype=ordconstn) and (tordconstnode(right).value=0) then
  373. begin
  374. location_reset(location,LOC_FLAGS,OS_NO);
  375. location.resflags:=getresflags(unsigned);
  376. if not(left.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  377. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  378. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  379. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  380. if current_settings.cputype in cpu_thumb then
  381. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,dummyreg)
  382. else
  383. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,left.location.register64.reglo,left.location.register64.reghi),PF_S));
  384. end
  385. else
  386. begin
  387. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  388. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  389. { operation requiring proper N, Z and C flags ? }
  390. if unsigned or (nodetype in [equaln,unequaln]) then
  391. begin
  392. location_reset(location,LOC_FLAGS,OS_NO);
  393. location.resflags:=getresflags(unsigned);
  394. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  395. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  396. if current_settings.cputype in (cpu_thumb+cpu_thumb2) then
  397. begin
  398. current_asmdata.getjumplabel(l);
  399. cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,l);
  400. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  401. cg.a_label(current_asmdata.CurrAsmList,l);
  402. end
  403. else
  404. current_asmdata.CurrAsmList.concat(setcondition(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo),C_EQ));
  405. end
  406. else
  407. { operation requiring proper N, Z and V flags ? }
  408. begin
  409. location_reset(location,LOC_JUMP,OS_NO);
  410. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  411. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  412. { the jump the sequence is a little bit hairy }
  413. case nodetype of
  414. ltn,gtn:
  415. begin
  416. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrTrueLabel);
  417. { cheat a little bit for the negative test }
  418. toggleflag(nf_swapped);
  419. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrFalseLabel);
  420. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  421. toggleflag(nf_swapped);
  422. end;
  423. lten,gten:
  424. begin
  425. oldnodetype:=nodetype;
  426. if nodetype=lten then
  427. nodetype:=ltn
  428. else
  429. nodetype:=gtn;
  430. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
  431. { cheat for the negative test }
  432. if nodetype=ltn then
  433. nodetype:=gtn
  434. else
  435. nodetype:=ltn;
  436. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
  437. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  438. nodetype:=oldnodetype;
  439. end;
  440. end;
  441. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  442. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  443. { the comparisaion of the low dword have to be
  444. always unsigned! }
  445. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
  446. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  447. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  448. end;
  449. end;
  450. end;
  451. function tarmaddnode.pass_1 : tnode;
  452. var
  453. unsigned : boolean;
  454. begin
  455. result:=inherited pass_1;
  456. if not(assigned(result)) then
  457. begin
  458. unsigned:=not(is_signed(left.resultdef)) or
  459. not(is_signed(right.resultdef));
  460. if is_64bit(left.resultdef) and
  461. ((nodetype in [equaln,unequaln]) or
  462. (unsigned and (nodetype in [ltn,lten,gtn,gten]))
  463. ) then
  464. expectloc:=LOC_FLAGS;
  465. end;
  466. end;
  467. function tarmaddnode.first_addfloat: tnode;
  468. var
  469. procname: string[31];
  470. { do we need to reverse the result ? }
  471. notnode : boolean;
  472. fdef : tdef;
  473. begin
  474. result := nil;
  475. notnode := false;
  476. if current_settings.fputype = fpu_fpv4_s16 then
  477. begin
  478. case tfloatdef(left.resultdef).floattype of
  479. s32real:
  480. begin
  481. result:=nil;
  482. notnode:=false;
  483. end;
  484. s64real:
  485. begin
  486. fdef:=search_system_type('FLOAT64').typedef;
  487. procname:='float64';
  488. case nodetype of
  489. addn:
  490. procname:=procname+'_add';
  491. muln:
  492. procname:=procname+'_mul';
  493. subn:
  494. procname:=procname+'_sub';
  495. slashn:
  496. procname:=procname+'_div';
  497. ltn:
  498. procname:=procname+'_lt';
  499. lten:
  500. procname:=procname+'_le';
  501. gtn:
  502. begin
  503. procname:=procname+'_le';
  504. notnode:=true;
  505. end;
  506. gten:
  507. begin
  508. procname:=procname+'_lt';
  509. notnode:=true;
  510. end;
  511. equaln:
  512. procname:=procname+'_eq';
  513. unequaln:
  514. begin
  515. procname:=procname+'_eq';
  516. notnode:=true;
  517. end;
  518. else
  519. CGMessage3(type_e_operator_not_supported_for_types,node2opstr(nodetype),left.resultdef.typename,right.resultdef.typename);
  520. end;
  521. if nodetype in [ltn,lten,gtn,gten,equaln,unequaln] then
  522. resultdef:=pasbool8type;
  523. result:=ctypeconvnode.create_internal(ccallnode.createintern(procname,ccallparanode.create(
  524. ctypeconvnode.create_internal(right,fdef),
  525. ccallparanode.create(
  526. ctypeconvnode.create_internal(left,fdef),nil))),resultdef);
  527. left:=nil;
  528. right:=nil;
  529. { do we need to reverse the result }
  530. if notnode then
  531. result:=cnotnode.create(result);
  532. end;
  533. end;
  534. end
  535. else
  536. result:=inherited first_addfloat;
  537. end;
  538. procedure tarmaddnode.second_cmpordinal;
  539. var
  540. unsigned : boolean;
  541. tmpreg : tregister;
  542. b : byte;
  543. begin
  544. pass_left_right;
  545. force_reg_left_right(true,true);
  546. unsigned:=not(is_signed(left.resultdef)) or
  547. not(is_signed(right.resultdef));
  548. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  549. if right.location.loc = LOC_CONSTANT then
  550. begin
  551. if (not(current_settings.cputype in cpu_thumb) and is_shifter_const(right.location.value,b)) or
  552. ((current_settings.cputype in cpu_thumb) and is_thumb_imm(right.location.value)) then
  553. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  554. else
  555. begin
  556. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  557. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_INT,
  558. right.location.value,tmpreg);
  559. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,tmpreg));
  560. end;
  561. end
  562. else
  563. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  564. location_reset(location,LOC_FLAGS,OS_NO);
  565. location.resflags:=getresflags(unsigned);
  566. end;
  567. begin
  568. caddnode:=tarmaddnode;
  569. end.