narmadd.pas 25 KB

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