narmadd.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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. function use_generic_mul32to64: boolean; override;
  29. protected
  30. function first_addfloat: tnode; override;
  31. procedure second_addordinal;override;
  32. procedure second_addfloat;override;
  33. procedure second_cmpfloat;override;
  34. procedure second_cmpordinal;override;
  35. procedure second_cmpsmallset;override;
  36. procedure second_cmp64bit;override;
  37. procedure second_add64bit;override;
  38. end;
  39. implementation
  40. uses
  41. globtype,verbose,globals,systems,
  42. constexp,symdef,symtable,symtype,symconst,
  43. aasmbase,aasmdata,aasmcpu,
  44. defutil,htypechk,cgbase,cgutils,
  45. cpuinfo,pass_1,pass_2,procinfo,
  46. ncon,nadd,ncnv,ncal,nmat,
  47. ncgutil,cgobj,cgcpu,
  48. hlcgobj
  49. ;
  50. {*****************************************************************************
  51. TSparcAddNode
  52. *****************************************************************************}
  53. function tarmaddnode.GetResFlags(unsigned:Boolean):TResFlags;
  54. begin
  55. case NodeType of
  56. equaln:
  57. GetResFlags:=F_EQ;
  58. unequaln:
  59. GetResFlags:=F_NE;
  60. else
  61. if not(unsigned) then
  62. begin
  63. if nf_swapped in flags then
  64. case NodeType of
  65. ltn:
  66. GetResFlags:=F_GT;
  67. lten:
  68. GetResFlags:=F_GE;
  69. gtn:
  70. GetResFlags:=F_LT;
  71. gten:
  72. GetResFlags:=F_LE;
  73. end
  74. else
  75. case NodeType of
  76. ltn:
  77. GetResFlags:=F_LT;
  78. lten:
  79. GetResFlags:=F_LE;
  80. gtn:
  81. GetResFlags:=F_GT;
  82. gten:
  83. GetResFlags:=F_GE;
  84. end;
  85. end
  86. else
  87. begin
  88. if nf_swapped in Flags then
  89. case NodeType of
  90. ltn:
  91. GetResFlags:=F_HI;
  92. lten:
  93. GetResFlags:=F_CS;
  94. gtn:
  95. GetResFlags:=F_CC;
  96. gten:
  97. GetResFlags:=F_LS;
  98. end
  99. else
  100. case NodeType of
  101. ltn:
  102. GetResFlags:=F_CC;
  103. lten:
  104. GetResFlags:=F_LS;
  105. gtn:
  106. GetResFlags:=F_HI;
  107. gten:
  108. GetResFlags:=F_CS;
  109. end;
  110. end;
  111. end;
  112. end;
  113. procedure tarmaddnode.second_addfloat;
  114. var
  115. op : TAsmOp;
  116. singleprec: boolean;
  117. begin
  118. pass_left_right;
  119. if (nf_swapped in flags) then
  120. swapleftright;
  121. case current_settings.fputype of
  122. fpu_fpa,
  123. fpu_fpa10,
  124. fpu_fpa11:
  125. begin
  126. { force fpureg as location, left right doesn't matter
  127. as both will be in a fpureg }
  128. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  129. location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
  130. location_reset(location,LOC_FPUREGISTER,def_cgsize(resultdef));
  131. location.register:=cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  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. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  155. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  156. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  157. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  158. singleprec:=tfloatdef(left.resultdef).floattype=s32real;
  159. case nodetype of
  160. addn :
  161. if singleprec then
  162. op:=A_FADDS
  163. else
  164. op:=A_FADDD;
  165. muln :
  166. if singleprec then
  167. op:=A_FMULS
  168. else
  169. op:=A_FMULD;
  170. subn :
  171. if singleprec then
  172. op:=A_FSUBS
  173. else
  174. op:=A_FSUBD;
  175. slashn :
  176. if singleprec then
  177. op:=A_FDIVS
  178. else
  179. op:=A_FDIVD;
  180. else
  181. internalerror(2009111401);
  182. end;
  183. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,
  184. location.register,left.location.register,right.location.register));
  185. end;
  186. fpu_fpv4_s16:
  187. begin
  188. { force mmreg as location, left right doesn't matter
  189. as both will be in a fpureg }
  190. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  191. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  192. location_reset(location,LOC_MMREGISTER,def_cgsize(resultdef));
  193. location.register:=cg.getmmregister(current_asmdata.CurrAsmList,location.size);
  194. case nodetype of
  195. addn :
  196. op:=A_VADD;
  197. muln :
  198. op:=A_VMUL;
  199. subn :
  200. op:=A_VSUB;
  201. slashn :
  202. op:=A_VDIV;
  203. else
  204. internalerror(2009111401);
  205. end;
  206. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(op, location.register,left.location.register,right.location.register), PF_F32));
  207. end;
  208. fpu_soft:
  209. { this case should be handled already by pass1 }
  210. internalerror(200308252);
  211. else
  212. internalerror(200308251);
  213. end;
  214. end;
  215. procedure tarmaddnode.second_cmpfloat;
  216. var
  217. op: TAsmOp;
  218. begin
  219. pass_left_right;
  220. if (nf_swapped in flags) then
  221. swapleftright;
  222. location_reset(location,LOC_FLAGS,OS_NO);
  223. location.resflags:=getresflags(true);
  224. case current_settings.fputype of
  225. fpu_fpa,
  226. fpu_fpa10,
  227. fpu_fpa11:
  228. begin
  229. { force fpureg as location, left right doesn't matter
  230. as both will be in a fpureg }
  231. location_force_fpureg(current_asmdata.CurrAsmList,left.location,true);
  232. location_force_fpureg(current_asmdata.CurrAsmList,right.location,true);
  233. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  234. if nodetype in [equaln,unequaln] then
  235. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMF,
  236. left.location.register,right.location.register),
  237. cgsize2fpuoppostfix[def_cgsize(resultdef)]))
  238. else
  239. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_CMFE,
  240. left.location.register,right.location.register),
  241. cgsize2fpuoppostfix[def_cgsize(resultdef)]));
  242. end;
  243. fpu_vfpv2,
  244. fpu_vfpv3,
  245. fpu_vfpv3_d16:
  246. begin
  247. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  248. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  249. if (tfloatdef(left.resultdef).floattype=s32real) then
  250. if nodetype in [equaln,unequaln] then
  251. op:=A_FCMPS
  252. else
  253. op:=A_FCMPES
  254. else if nodetype in [equaln,unequaln] then
  255. op:=A_FCMPD
  256. else
  257. op:=A_FCMPED;
  258. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  259. left.location.register,right.location.register));
  260. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  261. current_asmdata.CurrAsmList.concat(taicpu.op_none(A_FMSTAT));
  262. end;
  263. fpu_fpv4_s16:
  264. begin
  265. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,left.location,left.resultdef,true);
  266. hlcg.location_force_mmregscalar(current_asmdata.CurrAsmList,right.location,right.resultdef,true);
  267. if nodetype in [equaln,unequaln] then
  268. op:=A_VCMP
  269. else
  270. op:=A_VCMPE;
  271. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,
  272. left.location.register,right.location.register));
  273. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  274. current_asmdata.CurrAsmList.Concat(taicpu.op_reg_reg(A_VMRS, NR_APSR_nzcv, NR_FPSCR));
  275. end;
  276. fpu_soft:
  277. { this case should be handled already by pass1 }
  278. internalerror(2009112404);
  279. end;
  280. location_reset(location,LOC_FLAGS,OS_NO);
  281. location.resflags:=getresflags(false);
  282. end;
  283. procedure tarmaddnode.second_cmpsmallset;
  284. var
  285. tmpreg : tregister;
  286. b: byte;
  287. begin
  288. pass_left_right;
  289. location_reset(location,LOC_FLAGS,OS_NO);
  290. if (not(nf_swapped in flags) and
  291. (nodetype = lten)) or
  292. ((nf_swapped in flags) and
  293. (nodetype = gten)) then
  294. swapleftright;
  295. (* Try to keep right as a constant *)
  296. if (right.location.loc <> LOC_CONSTANT) or
  297. not(is_shifter_const(right.location.value, b)) or
  298. ((GenerateThumbCode) and not(is_thumb_imm(right.location.value))) then
  299. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  300. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  301. case nodetype of
  302. equaln,
  303. unequaln:
  304. begin
  305. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  306. if right.location.loc = LOC_CONSTANT then
  307. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,left.location.register,right.location.value))
  308. else
  309. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register,right.location.register));
  310. if nodetype = equaln then
  311. location.resflags:=F_EQ
  312. else
  313. location.resflags:=F_NE;
  314. end;
  315. lten,
  316. gten:
  317. begin
  318. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  319. if right.location.loc = LOC_CONSTANT then
  320. begin
  321. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_AND,tmpreg,left.location.register,right.location.value));
  322. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  323. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMP,tmpreg,right.location.value));
  324. end
  325. else
  326. begin
  327. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_AND,tmpreg,left.location.register,right.location.register));
  328. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  329. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,tmpreg,right.location.register));
  330. end;
  331. location.resflags:=F_EQ;
  332. end;
  333. else
  334. internalerror(2004012401);
  335. end;
  336. end;
  337. procedure tarmaddnode.second_cmp64bit;
  338. var
  339. unsigned : boolean;
  340. oldnodetype : tnodetype;
  341. dummyreg : tregister;
  342. l: tasmlabel;
  343. begin
  344. unsigned:=not(is_signed(left.resultdef)) or
  345. not(is_signed(right.resultdef));
  346. pass_left_right;
  347. { pass_left_right moves possible consts to the right, the only
  348. remaining case with left consts (currency) can take this path too (KB) }
  349. if (nodetype in [equaln,unequaln]) and
  350. (right.nodetype=ordconstn) and (tordconstnode(right).value=0) then
  351. begin
  352. location_reset(location,LOC_FLAGS,OS_NO);
  353. location.resflags:=getresflags(unsigned);
  354. if not(left.location.loc in [LOC_CREGISTER,LOC_REGISTER]) then
  355. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  356. dummyreg:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
  357. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  358. if GenerateThumbCode then
  359. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,dummyreg)
  360. else
  361. current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg_reg(A_ORR,dummyreg,left.location.register64.reglo,left.location.register64.reghi),PF_S));
  362. end
  363. else
  364. begin
  365. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  366. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  367. { operation requiring proper N, Z and C flags ? }
  368. if unsigned or (nodetype in [equaln,unequaln]) then
  369. begin
  370. location_reset(location,LOC_FLAGS,OS_NO);
  371. location.resflags:=getresflags(unsigned);
  372. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  373. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  374. if GenerateThumbCode or GenerateThumb2Code then
  375. begin
  376. current_asmdata.getjumplabel(l);
  377. cg.a_jmp_flags(current_asmdata.CurrAsmList,F_NE,l);
  378. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  379. cg.a_label(current_asmdata.CurrAsmList,l);
  380. end
  381. else
  382. current_asmdata.CurrAsmList.concat(setcondition(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo),C_EQ));
  383. end
  384. else
  385. { operation requiring proper N, Z and V flags ? }
  386. begin
  387. location_reset(location,LOC_JUMP,OS_NO);
  388. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  389. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reghi,right.location.register64.reghi));
  390. { the jump the sequence is a little bit hairy }
  391. case nodetype of
  392. ltn,gtn:
  393. begin
  394. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrTrueLabel);
  395. { cheat a little bit for the negative test }
  396. toggleflag(nf_swapped);
  397. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(false),current_procinfo.CurrFalseLabel);
  398. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  399. toggleflag(nf_swapped);
  400. end;
  401. lten,gten:
  402. begin
  403. oldnodetype:=nodetype;
  404. if nodetype=lten then
  405. nodetype:=ltn
  406. else
  407. nodetype:=gtn;
  408. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrTrueLabel);
  409. { cheat for the negative test }
  410. if nodetype=ltn then
  411. nodetype:=gtn
  412. else
  413. nodetype:=ltn;
  414. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(unsigned),current_procinfo.CurrFalseLabel);
  415. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  416. nodetype:=oldnodetype;
  417. end;
  418. end;
  419. cg.a_reg_alloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  420. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_CMP,left.location.register64.reglo,right.location.register64.reglo));
  421. { the comparisaion of the low dword have to be
  422. always unsigned! }
  423. cg.a_jmp_flags(current_asmdata.CurrAsmList,getresflags(true),current_procinfo.CurrTrueLabel);
  424. cg.a_jmp_always(current_asmdata.CurrAsmList,current_procinfo.CurrFalseLabel);
  425. cg.a_reg_dealloc(current_asmdata.CurrAsmList,NR_DEFAULTFLAGS);
  426. end;
  427. end;
  428. end;
  429. procedure tarmaddnode.second_add64bit;
  430. var
  431. asmList : TAsmList;
  432. ll,rl,res : TRegister64;
  433. tmpreg: TRegister;
  434. begin
  435. if (nodetype in [muln]) then
  436. begin
  437. asmList := current_asmdata.CurrAsmList;
  438. pass_left_right;
  439. force_reg_left_right(true, false);
  440. set_result_location_reg;
  441. { shortcuts to register64s }
  442. ll:=left.location.register64;
  443. rl:=right.location.register64;
  444. res:=location.register64;
  445. tmpreg := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  446. asmList.concat(taicpu.op_reg_reg_reg(A_MUL,tmpreg,ll.reglo,rl.reghi));
  447. asmList.concat(taicpu.op_reg_reg_reg_reg(A_UMULL,res.reglo,res.reghi,rl.reglo,ll.reglo));
  448. tbasecgarm(cg).safe_mla(asmList,tmpreg,rl.reglo,ll.reghi,tmpreg);
  449. asmList.concat(taicpu.op_reg_reg_reg(A_ADD,res.reghi,tmpreg,res.reghi));
  450. end
  451. else
  452. inherited second_add64bit;
  453. end;
  454. function tarmaddnode.pass_1 : tnode;
  455. var
  456. unsigned : boolean;
  457. begin
  458. { prepare for MUL64 inlining }
  459. if (not(cs_check_overflow in current_settings.localswitches)) and
  460. (nodetype in [muln]) and
  461. (is_64bitint(left.resultdef)) and
  462. not(GenerateThumbCode) and
  463. (CPUARM_HAS_UMULL in cpu_capabilities[current_settings.cputype]) 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. const
  584. multops: array[boolean] of TAsmOp = (A_SMULL, A_UMULL);
  585. procedure tarmaddnode.second_addordinal;
  586. var
  587. unsigned: boolean;
  588. begin
  589. if (nodetype=muln) and
  590. is_64bit(resultdef) and
  591. not(GenerateThumbCode) and
  592. (CPUARM_HAS_UMULL in cpu_capabilities[current_settings.cputype]) then
  593. begin
  594. pass_left_right;
  595. force_reg_left_right(true, false);
  596. set_result_location_reg;
  597. unsigned:=not(is_signed(left.resultdef)) or
  598. not(is_signed(right.resultdef));
  599. current_asmdata.CurrAsmList.Concat(
  600. taicpu.op_reg_reg_reg_reg(multops[unsigned], location.register64.reglo, location.register64.reghi,
  601. left.location.register,right.location.register));
  602. end
  603. else
  604. inherited second_addordinal;
  605. end;
  606. function tarmaddnode.use_generic_mul32to64: boolean;
  607. begin
  608. result:=GenerateThumbCode or not(CPUARM_HAS_UMULL in cpu_capabilities[current_settings.cputype]);
  609. end;
  610. begin
  611. caddnode:=tarmaddnode;
  612. end.