narmadd.pas 25 KB

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