2
0

nppcmat.pas 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. Generate PowerPC assembler for math nodes
  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 nppcmat;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. node,nmat, ncgmat;
  22. type
  23. tppcmoddivnode = class(tmoddivnode)
  24. function pass_1: tnode;override;
  25. procedure pass_generate_code;override;
  26. end;
  27. tppcshlshrnode = class(tshlshrnode)
  28. procedure pass_generate_code;override;
  29. { everything will be handled in pass_2 }
  30. function first_shlshr64bitint: tnode; override;
  31. end;
  32. tppcunaryminusnode = class(tunaryminusnode)
  33. procedure pass_generate_code;override;
  34. end;
  35. tppcnotnode = class(tcgnotnode)
  36. procedure pass_generate_code;override;
  37. end;
  38. implementation
  39. uses
  40. globtype,systems,constexp,
  41. cutils,verbose,globals,
  42. symconst,symdef,
  43. aasmbase,aasmcpu,aasmtai,aasmdata,
  44. defutil,
  45. cgbase,cgutils,cgobj,hlcgobj,pass_2,
  46. ncon,procinfo,
  47. cpubase,
  48. ncgutil,cgcpu;
  49. {*****************************************************************************
  50. TPPCMODDIVNODE
  51. *****************************************************************************}
  52. function tppcmoddivnode.pass_1: tnode;
  53. begin
  54. result := inherited pass_1;
  55. if not assigned(result) then
  56. include(current_procinfo.flags,pi_do_call);
  57. end;
  58. procedure tppcmoddivnode.pass_generate_code;
  59. const
  60. { signed overflow }
  61. divops: array[boolean, boolean] of tasmop =
  62. ((A_DIVWU,A_DIVWU_),(A_DIVW,A_DIVWO_));
  63. zerocond: tasmcond = (dirhint: DH_Plus; simple: true; cond:C_NE; cr: RS_CR1);
  64. var
  65. power : longint;
  66. op : tasmop;
  67. numerator,
  68. divider,
  69. resultreg : tregister;
  70. size : Tcgsize;
  71. hl : tasmlabel;
  72. done: boolean;
  73. procedure genOrdConstNodeDiv;
  74. const
  75. negops : array[boolean] of tasmop = (A_NEG, A_NEGO);
  76. var
  77. divreg : tregister;
  78. begin
  79. if (tordconstnode(right).value = 0) then begin
  80. internalerror(2005061701);
  81. end else if (tordconstnode(right).value = 1) then begin
  82. cg.a_load_reg_reg(current_asmdata.CurrAsmList, OS_INT, OS_INT, numerator, resultreg);
  83. end else if (tordconstnode(right).value = int64(-1)) then begin
  84. // note: only in the signed case possible..., may overflow
  85. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(negops[cs_check_overflow in current_settings.localswitches], resultreg, numerator));
  86. end else if (ispowerof2(tordconstnode(right).value, power)) then begin
  87. if (is_signed(right.resultdef)) then begin
  88. { From "The PowerPC Compiler Writer's Guide", pg. 52ff }
  89. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, power,
  90. numerator, resultreg);
  91. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_ADDZE, resultreg, resultreg));
  92. end else begin
  93. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SHR, OS_INT, power, numerator, resultreg)
  94. end;
  95. end else begin
  96. cg.g_div_const_reg_reg(current_asmdata.CurrAsmList,def_cgsize(resultdef),
  97. tordconstnode(right).value.svalue,numerator,resultreg);
  98. end;
  99. done := true;
  100. end;
  101. procedure genOrdConstNodeMod;
  102. var
  103. modreg, maskreg, tempreg : tregister;
  104. begin
  105. if (tordconstnode(right).value = 0) then begin
  106. internalerror(2005061702);
  107. end else if (abs(tordconstnode(right).value.svalue) = 1) then begin
  108. // x mod +/-1 is always zero
  109. cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, 0, resultreg);
  110. end else if (ispowerof2(tordconstnode(right).value, power)) then begin
  111. if (is_signed(right.resultdef)) then begin
  112. tempreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  113. maskreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  114. modreg := cg.getintregister(current_asmdata.CurrAsmList, OS_INT);
  115. cg.a_load_const_reg(current_asmdata.CurrAsmList, OS_INT, abs(tordconstnode(right).value.svalue)-1, modreg);
  116. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_SAR, OS_INT, 31, numerator, maskreg);
  117. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, numerator, modreg, tempreg);
  118. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_ANDC, maskreg, maskreg, modreg));
  119. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC, modreg, tempreg, 0));
  120. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_SUBFE, modreg, modreg, modreg));
  121. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, modreg, maskreg, maskreg);
  122. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_OR, OS_INT, maskreg, tempreg, resultreg);
  123. end else begin
  124. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_AND, OS_INT, tordconstnode(right).value.svalue-1, numerator, resultreg);
  125. end;
  126. end else begin
  127. genOrdConstNodeDiv();
  128. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList, OP_MUL, OS_INT, tordconstnode(right).value.svalue, resultreg, resultreg);
  129. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList, OP_SUB, OS_INT, resultreg, numerator, resultreg);
  130. end;
  131. end;
  132. begin
  133. secondpass(left);
  134. secondpass(right);
  135. location_copy(location,left.location);
  136. { put numerator in register }
  137. size:=def_cgsize(left.resultdef);
  138. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,
  139. left.resultdef,left.resultdef,true);
  140. location_copy(location,left.location);
  141. numerator := location.register;
  142. resultreg := location.register;
  143. if (location.loc = LOC_CREGISTER) then begin
  144. location.loc := LOC_REGISTER;
  145. location.register := cg.getintregister(current_asmdata.CurrAsmList,size);
  146. resultreg := location.register;
  147. end else if (nodetype = modn) or (right.nodetype = ordconstn) then begin
  148. // for a modulus op, and for const nodes we need the result register
  149. // to be an extra register
  150. resultreg := cg.getintregister(current_asmdata.CurrAsmList,size);
  151. end;
  152. done := false;
  153. if (right.nodetype = ordconstn) then begin
  154. if (nodetype = divn) then
  155. genOrdConstNodeDiv
  156. else
  157. genOrdConstNodeMod;
  158. done := true;
  159. end;
  160. if (not done) then begin
  161. { load divider in a register if necessary }
  162. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,
  163. right.resultdef,right.resultdef,true);
  164. if (right.nodetype <> ordconstn) then
  165. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_CMPWI,NR_CR1,
  166. right.location.register,0));
  167. divider := right.location.register;
  168. { needs overflow checking, (-maxlongint-1) div (-1) overflows! }
  169. op := divops[is_signed(right.resultdef),
  170. cs_check_overflow in current_settings.localswitches];
  171. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(op,resultreg,numerator,
  172. divider));
  173. if (nodetype = modn) then
  174. begin
  175. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_MULLW,resultreg,
  176. divider,resultreg));
  177. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_SUB,location.register,
  178. numerator,resultreg));
  179. resultreg := location.register;
  180. end;
  181. end;
  182. { set result location }
  183. location.loc:=LOC_REGISTER;
  184. location.register:=resultreg;
  185. if right.nodetype <> ordconstn then
  186. begin
  187. current_asmdata.getjumplabel(hl);
  188. current_asmdata.CurrAsmList.concat(taicpu.op_cond_sym(A_BC,zerocond,hl));
  189. cg.a_call_name(current_asmdata.CurrAsmList,'FPC_DIVBYZERO',false);
  190. cg.a_label(current_asmdata.CurrAsmList,hl);
  191. end;
  192. { unsigned division/module can only overflow in case of division by zero }
  193. { (but checking this overflow flag is more convoluted than performing a }
  194. { simple comparison with 0) }
  195. if is_signed(right.resultdef) then
  196. cg.g_overflowcheck(current_asmdata.CurrAsmList,location,resultdef);
  197. end;
  198. {*****************************************************************************
  199. TPPCSHLRSHRNODE
  200. *****************************************************************************}
  201. function tppcshlshrnode.first_shlshr64bitint: tnode;
  202. begin
  203. result := nil;
  204. end;
  205. procedure tppcshlshrnode.pass_generate_code;
  206. var
  207. resultreg, hregister1,hregister2,
  208. hreg64hi,hreg64lo : tregister;
  209. op : topcg;
  210. asmop1, asmop2: tasmop;
  211. shiftval: aint;
  212. begin
  213. secondpass(left);
  214. secondpass(right);
  215. if is_64bitint(left.resultdef) then
  216. begin
  217. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,
  218. left.resultdef,left.resultdef,true);
  219. location_copy(location,left.location);
  220. hreg64hi := location.register64.reghi;
  221. hreg64lo := location.register64.reglo;
  222. if (location.loc = LOC_CREGISTER) then
  223. begin
  224. location.loc := LOC_REGISTER;
  225. location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  226. location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  227. end;
  228. if (right.nodetype = ordconstn) then
  229. begin
  230. shiftval := tordconstnode(right).value.svalue;
  231. shiftval := shiftval and 63;
  232. {
  233. I think the statements below is much more correct instead of the hack above,
  234. but then we fail tshlshr.pp :/
  235. if shiftval > 63 then
  236. begin
  237. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reglo);
  238. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reglo);
  239. end
  240. else }
  241. if shiftval = 0 then
  242. begin
  243. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.register64.reghi,location.register64.reghi);
  244. cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,left.location.register64.reglo,location.register64.reglo);
  245. end
  246. else if shiftval > 31 then
  247. begin
  248. if nodetype = shln then
  249. begin
  250. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHL,OS_32,
  251. shiftval and 31,hreg64lo,location.register64.reghi);
  252. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reglo);
  253. end
  254. else
  255. begin
  256. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,OP_SHR,OS_32,
  257. shiftval and 31,hreg64hi,location.register64.reglo);
  258. cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reghi);
  259. end;
  260. end
  261. else
  262. begin
  263. if nodetype = shln then
  264. begin
  265. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  266. A_RLWINM,location.register64.reghi,hreg64hi,shiftval,
  267. 0,31-shiftval));
  268. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  269. A_RLWIMI,location.register64.reghi,hreg64lo,shiftval,
  270. 32-shiftval,31));
  271. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  272. A_RLWINM,location.register64.reglo,hreg64lo,shiftval,
  273. 0,31-shiftval));
  274. end
  275. else
  276. begin
  277. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  278. A_RLWINM,location.register64.reglo,hreg64lo,32-shiftval,
  279. shiftval,31));
  280. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  281. A_RLWIMI,location.register64.reglo,hreg64hi,32-shiftval,
  282. 0,shiftval-1));
  283. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const_const_const(
  284. A_RLWINM,location.register64.reghi,hreg64hi,32-shiftval,
  285. shiftval,31));
  286. end;
  287. end;
  288. end
  289. else
  290. { no constant shiftcount }
  291. begin
  292. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,s32inttype,true);
  293. hregister1 := right.location.register;
  294. if nodetype = shln then
  295. begin
  296. asmop1 := A_SLW;
  297. asmop2 := A_SRW;
  298. end
  299. else
  300. begin
  301. asmop1 := A_SRW;
  302. asmop2 := A_SLW;
  303. resultreg := hreg64hi;
  304. hreg64hi := hreg64lo;
  305. hreg64lo := resultreg;
  306. resultreg := location.register64.reghi;
  307. location.register64.reghi := location.register64.reglo;
  308. location.register64.reglo := resultreg;
  309. end;
  310. cg.getcpuregister(current_asmdata.CurrAsmList,NR_R0);
  311. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC,
  312. NR_R0,hregister1,32));
  313. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(asmop1,
  314. location.register64.reghi,hreg64hi,hregister1));
  315. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(asmop2,
  316. NR_R0,hreg64lo,NR_R0));
  317. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_OR,
  318. location.register64.reghi,location.register64.reghi,NR_R0));
  319. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBI,
  320. NR_R0,hregister1,32));
  321. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(asmop1,
  322. NR_R0,hreg64lo,NR_R0));
  323. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(A_OR,
  324. location.register64.reghi,location.register64.reghi,NR_R0));
  325. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg(asmop1,
  326. location.register64.reglo,hreg64lo,hregister1));
  327. cg.ungetcpuregister(current_asmdata.CurrAsmList,NR_R0);
  328. if nodetype = shrn then
  329. begin
  330. resultreg := location.register64.reghi;
  331. location.register64.reghi := location.register64.reglo;
  332. location.register64.reglo := resultreg;
  333. end;
  334. end
  335. end
  336. else
  337. begin
  338. { load left operators in a register }
  339. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  340. location_copy(location,left.location);
  341. resultreg := location.register;
  342. hregister1 := location.register;
  343. location.loc := LOC_REGISTER;
  344. resultreg := cg.getintregister(current_asmdata.CurrAsmList,location.size);
  345. location.register := resultreg;
  346. { determine operator }
  347. if nodetype=shln then
  348. op:=OP_SHL
  349. else
  350. op:=OP_SHR;
  351. { shifting by a constant directly coded: }
  352. if (right.nodetype=ordconstn) then
  353. cg.a_op_const_reg_reg(current_asmdata.CurrAsmList,op,location.size,
  354. tordconstnode(right).value.svalue and 31,hregister1,resultreg)
  355. else
  356. begin
  357. { load shift count in a register if necessary }
  358. hlcg.location_force_reg(current_asmdata.CurrAsmList,right.location,right.resultdef,right.resultdef,true);
  359. hregister2 := right.location.register;
  360. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,op,location.size,hregister2,
  361. hregister1,resultreg);
  362. end;
  363. end;
  364. end;
  365. {*****************************************************************************
  366. TPPCUNARYMINUSNODE
  367. *****************************************************************************}
  368. procedure tppcunaryminusnode.pass_generate_code;
  369. var
  370. src1: tregister;
  371. op: tasmop;
  372. begin
  373. src1:=NR_NO;
  374. secondpass(left);
  375. if is_64bit(left.resultdef) then
  376. begin
  377. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  378. location_copy(location,left.location);
  379. if (location.loc = LOC_CREGISTER) then
  380. begin
  381. location.register64.reglo := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  382. location.register64.reghi := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  383. location.loc := LOC_REGISTER;
  384. end;
  385. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_const(A_SUBFIC,
  386. location.register64.reglo,left.location.register64.reglo,0));
  387. if not(cs_check_overflow in current_settings.localswitches) then
  388. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SUBFZE,
  389. location.register64.reghi,left.location.register64.reghi))
  390. else
  391. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_SUBFZEO_,
  392. location.register64.reghi,left.location.register64.reghi));
  393. end
  394. else
  395. begin
  396. if left.location.loc in [LOC_SUBSETREG,LOC_CSUBSETREG,LOC_SUBSETREF,LOC_CSUBSETREF] then
  397. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  398. location_copy(location,left.location);
  399. location.loc:=LOC_REGISTER;
  400. case left.location.loc of
  401. LOC_FPUREGISTER, LOC_REGISTER:
  402. begin
  403. src1 := left.location.register;
  404. location.register := src1;
  405. end;
  406. LOC_CFPUREGISTER, LOC_CREGISTER:
  407. begin
  408. src1 := left.location.register;
  409. if left.location.loc = LOC_CREGISTER then
  410. location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT)
  411. else
  412. location.register := cg.getfpuregister(current_asmdata.CurrAsmList,location.size);
  413. end;
  414. LOC_REFERENCE,LOC_CREFERENCE:
  415. begin
  416. if (left.resultdef.typ=floatdef) then
  417. begin
  418. src1 := cg.getfpuregister(current_asmdata.CurrAsmList,def_cgsize(left.resultdef));
  419. location.register := src1;
  420. cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,
  421. left.location.size,left.location.size,
  422. left.location.reference,src1);
  423. end
  424. else
  425. begin
  426. src1 := cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  427. location.register:= src1;
  428. cg.a_load_ref_reg(current_asmdata.CurrAsmList,OS_32,OS_32,
  429. left.location.reference,src1);
  430. end;
  431. end;
  432. end;
  433. { choose appropriate operand }
  434. if left.resultdef.typ <> floatdef then
  435. begin
  436. if not(cs_check_overflow in current_settings.localswitches) then
  437. op := A_NEG
  438. else
  439. op := A_NEGO_;
  440. location.loc := LOC_REGISTER;
  441. end
  442. else
  443. begin
  444. op := A_FNEG;
  445. location.loc := LOC_FPUREGISTER;
  446. end;
  447. { emit operation }
  448. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(op,location.register,src1));
  449. end;
  450. { Here was a problem... }
  451. { Operand to be negated always }
  452. { seems to be converted to signed }
  453. { 32-bit before doing neg!! }
  454. { So this is useless... }
  455. { that's not true: -2^31 gives an overflow error if it is negated (FK) }
  456. cg.g_overflowcheck(current_asmdata.CurrAsmList,location,resultdef);
  457. end;
  458. {*****************************************************************************
  459. TPPCNOTNODE
  460. *****************************************************************************}
  461. procedure tppcnotnode.pass_generate_code;
  462. var
  463. tmpreg: tregister;
  464. begin
  465. if is_boolean(resultdef) then
  466. begin
  467. if not handle_locjump then
  468. begin
  469. secondpass(left);
  470. case left.location.loc of
  471. LOC_FLAGS :
  472. begin
  473. location_copy(location,left.location);
  474. inverse_flags(location.resflags);
  475. end;
  476. LOC_REGISTER, LOC_CREGISTER,
  477. LOC_REFERENCE, LOC_CREFERENCE,
  478. LOC_SUBSETREG, LOC_CSUBSETREG,
  479. LOC_SUBSETREF, LOC_CSUBSETREF:
  480. begin
  481. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  482. tmpreg:=left.location.register;
  483. {$ifndef cpu64bitalu}
  484. { 64 bit pascal booleans have their truth value stored in
  485. the lower 32 bits; with cbools, it can be anywhere }
  486. if (left.location.size in [OS_64,OS_S64]) and
  487. not is_pasbool(left.resultdef) then
  488. begin
  489. tmpreg:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
  490. cg.a_op_reg_reg_reg(current_asmdata.CurrAsmList,OP_OR,OS_32,left.location.register64.reglo,left.location.register64.reghi,tmpreg);
  491. end;
  492. {$endif not cpu64bitalu}
  493. current_asmdata.CurrAsmList.concat(taicpu.op_reg_const(A_CMPWI,tmpreg,0));
  494. location_reset(location,LOC_FLAGS,OS_NO);
  495. location.resflags.cr:=RS_CR0;
  496. location.resflags.flag:=F_EQ;
  497. end;
  498. else
  499. internalerror(2003042401);
  500. end;
  501. end;
  502. end
  503. else if is_64bitint(left.resultdef) then
  504. begin
  505. secondpass(left);
  506. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,false);
  507. location_copy(location,left.location);
  508. { perform the NOT operation }
  509. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_NOT,location.register64.reghi,
  510. location.register64.reghi));
  511. current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg(A_NOT,location.register64.reglo,
  512. location.register64.reglo));
  513. end
  514. else
  515. begin
  516. secondpass(left);
  517. hlcg.location_force_reg(current_asmdata.CurrAsmList,left.location,left.resultdef,left.resultdef,true);
  518. location_copy(location,left.location);
  519. location.loc := LOC_REGISTER;
  520. location.register := cg.getintregister(current_asmdata.CurrAsmList,OS_INT);
  521. { perform the NOT operation }
  522. cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NOT,def_cgsize(resultdef),left.location.register,
  523. location.register);
  524. end;
  525. end;
  526. begin
  527. cmoddivnode:=tppcmoddivnode;
  528. cshlshrnode:=tppcshlshrnode;
  529. cunaryminusnode:=tppcunaryminusnode;
  530. cnotnode:=tppcnotnode;
  531. end.