cgcpu.pas 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements the code generator for the Risc-V32
  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 cgcpu;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. globtype,symtype,symdef,
  22. cgbase,cgobj,cgrv,
  23. aasmbase,aasmcpu,aasmtai,aasmdata,
  24. cpubase,cpuinfo,cgutils,cg64f32,rgcpu,
  25. parabase;
  26. type
  27. tcgrv32 = class(tcgrv)
  28. procedure init_register_allocators;override;
  29. procedure done_register_allocators;override;
  30. { move instructions }
  31. procedure a_load_reg_reg(list : TAsmList; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
  32. { 32x32 to 64 bit multiplication }
  33. procedure a_mul_reg_reg_pair(list: TAsmList;size: tcgsize; src1,src2,dstlo,dsthi: tregister); override;
  34. procedure g_concatcopy(list : TAsmList;const source,dest : treference;len : tcgint);override;
  35. procedure g_overflowcheck(list: TAsmList; const Loc: tlocation; def: tdef); override;
  36. end;
  37. tcg64frv = class(tcg64f32)
  38. procedure a_op64_reg_reg(list : TAsmList;op:TOpCG;size : tcgsize;regsrc,regdst : tregister64);override;
  39. procedure a_op64_const_reg(list : TAsmList;op:TOpCG;size : tcgsize;value : int64;reg : tregister64);override;
  40. procedure a_op64_const_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;value : int64;regsrc,regdst : tregister64);override;
  41. procedure a_op64_reg_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;regsrc1,regsrc2,regdst : tregister64);override;
  42. end;
  43. procedure create_codegen;
  44. implementation
  45. uses
  46. symtable,
  47. globals,verbose,systems,cutils,
  48. symconst,symsym,fmodule,
  49. rgobj,tgobj,cpupi,procinfo,paramgr;
  50. {$undef AVOID_OVERFLOW}
  51. {$ifopt Q+}
  52. {$define AVOID_OVERFLOW}
  53. const
  54. max_12_bit = 1 shl 12;
  55. {$endif}
  56. { Range check must be disabled explicitly as conversions between signed and unsigned
  57. 32-bit values are done without explicit typecasts }
  58. {$R-}
  59. procedure tcgrv32.init_register_allocators;
  60. begin
  61. inherited init_register_allocators;
  62. if CPURV_HAS_16REGISTERS in cpu_capabilities[current_settings.cputype] then
  63. rg[R_INTREGISTER]:=trgintcpu.create(R_INTREGISTER,R_SUBWHOLE,
  64. [RS_X10,RS_X11,RS_X12,RS_X13,RS_X14,RS_X15,
  65. RS_X5,RS_X6,RS_X7,
  66. RS_X3,RS_X4,
  67. RS_X9],first_int_imreg,[])
  68. else
  69. rg[R_INTREGISTER]:=trgintcpu.create(R_INTREGISTER,R_SUBWHOLE,
  70. [RS_X10,RS_X11,RS_X12,RS_X13,RS_X14,RS_X15,RS_X16,RS_X17,
  71. RS_X31,RS_X30,RS_X29,RS_X28,
  72. RS_X5,RS_X6,RS_X7,
  73. RS_X3,RS_X4,
  74. RS_X9,RS_X27,RS_X26,RS_X25,RS_X24,RS_X23,RS_X22,
  75. RS_X21,RS_X20,RS_X19,RS_X18],first_int_imreg,[]);
  76. rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
  77. [RS_F10,RS_F11,RS_F12,RS_F13,RS_F14,RS_F15,RS_F16,RS_F17,
  78. RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,
  79. RS_F28,RS_F29,RS_F30,RS_F31,
  80. RS_F8,RS_F9,
  81. RS_F27,
  82. RS_F26,RS_F25,RS_F24,RS_F23,RS_F22,RS_F21,RS_F20,RS_F19,RS_F18],first_fpu_imreg,[]);
  83. end;
  84. procedure tcgrv32.done_register_allocators;
  85. begin
  86. rg[R_INTREGISTER].free;
  87. rg[R_FPUREGISTER].free;
  88. inherited done_register_allocators;
  89. end;
  90. procedure tcgrv32.a_load_reg_reg(list : TAsmList;fromsize, tosize : tcgsize;reg1,reg2 : tregister);
  91. var
  92. ai: taicpu;
  93. begin
  94. {$ifdef EXTDEBUG}
  95. list.concat(tai_comment.Create(strpnew('Move '+tcgsize2str(fromsize)+'->'+tcgsize2str(tosize))));
  96. {$endif EXTDEBUG}
  97. if (tosize=OS_S32) and (fromsize=OS_32) then
  98. begin
  99. ai:=taicpu.op_reg_reg_const(A_ADDI,reg2,reg1,0);
  100. list.concat(ai);
  101. rg[R_INTREGISTER].add_move_instruction(ai);
  102. end
  103. else if (tcgsize2unsigned[tosize]=OS_32) and (fromsize=OS_8) then
  104. list.Concat(taicpu.op_reg_reg_const(A_ANDI,reg2,reg1,$FF))
  105. else if (tosize=OS_8) and (fromsize<>OS_8) then
  106. list.Concat(taicpu.op_reg_reg_const(A_ANDI,reg2,reg1,$FF))
  107. else if (CPURV_HAS_ZBB in cpu_capabilities[current_settings.cputype]) and (tcgsize2unsigned[tosize]=OS_32) and (fromsize=OS_S16) then
  108. list.Concat(taicpu.op_reg_reg(A_SEXT_H,reg2,reg1))
  109. else if (CPURV_HAS_ZBB in cpu_capabilities[current_settings.cputype]) and (tosize=OS_S16) and (tcgsize2unsigned[fromsize]=OS_32) then
  110. list.Concat(taicpu.op_reg_reg(A_SEXT_H,reg2,reg1))
  111. else if (CPURV_HAS_ZBB in cpu_capabilities[current_settings.cputype]) and (tcgsize2unsigned[tosize]=OS_64) and (fromsize=OS_16) then
  112. list.Concat(taicpu.op_reg_reg(A_ZEXT_H,reg2,reg1))
  113. else if (CPURV_HAS_ZBB in cpu_capabilities[current_settings.cputype]) and (tosize=OS_16) and (fromsize<>OS_16) then
  114. list.Concat(taicpu.op_reg_reg(A_ZEXT_H,reg2,reg1))
  115. else if (tcgsize2size[fromsize] > tcgsize2size[tosize]) or
  116. ((tcgsize2size[fromsize] = tcgsize2size[tosize]) and (fromsize <> tosize)) or
  117. { do we need to mask out the sign when loading from smaller signed to larger unsigned type? }
  118. ((tcgsize2unsigned[fromsize]<>fromsize) and ((tcgsize2unsigned[tosize]=tosize)) and
  119. (tcgsize2size[fromsize] < tcgsize2size[tosize]) and (tcgsize2size[tosize] <> sizeof(pint)) ) then
  120. begin
  121. if tcgsize2size[fromsize]<tcgsize2size[tosize] then
  122. begin
  123. list.Concat(taicpu.op_reg_reg_const(A_SLLI,reg2,reg1,8*(4-tcgsize2size[fromsize])));
  124. if tcgsize2unsigned[fromsize]<>fromsize then
  125. list.Concat(taicpu.op_reg_reg_const(A_SRAI,reg2,reg2,8*(tcgsize2size[tosize]-tcgsize2size[fromsize])))
  126. else
  127. list.Concat(taicpu.op_reg_reg_const(A_SRLI,reg2,reg2,8*(tcgsize2size[tosize]-tcgsize2size[fromsize])));
  128. end
  129. else
  130. list.Concat(taicpu.op_reg_reg_const(A_SLLI,reg2,reg1,8*(4-tcgsize2size[tosize])));
  131. if tcgsize2unsigned[tosize]=tosize then
  132. list.Concat(taicpu.op_reg_reg_const(A_SRLI,reg2,reg2,8*(4-tcgsize2size[tosize])))
  133. else
  134. list.Concat(taicpu.op_reg_reg_const(A_SRAI,reg2,reg2,8*(4-tcgsize2size[tosize])));
  135. end
  136. else
  137. begin
  138. ai:=taicpu.op_reg_reg_const(A_ADDI,reg2,reg1,0);
  139. list.concat(ai);
  140. rg[R_INTREGISTER].add_move_instruction(ai);
  141. end;
  142. end;
  143. procedure tcgrv32.a_mul_reg_reg_pair(list: TAsmList;size: tcgsize; src1,src2,dstlo,dsthi: tregister);
  144. var
  145. op: tasmop;
  146. begin
  147. case size of
  148. OS_INT: op:=A_MULHU;
  149. OS_SINT: op:=A_MULH;
  150. else
  151. InternalError(2014061501);
  152. end;
  153. if (dsthi<>NR_NO) then
  154. list.concat(taicpu.op_reg_reg_reg(op,dsthi,src1,src2));
  155. { low word is always unsigned }
  156. if (dstlo<>NR_NO) then
  157. list.concat(taicpu.op_reg_reg_reg(A_MUL,dstlo,src1,src2));
  158. end;
  159. procedure tcgrv32.g_concatcopy(list : TAsmList;const source,dest : treference;len : tcgint);
  160. var
  161. tmpreg1, hreg, countreg: TRegister;
  162. src, dst, src2, dst2: TReference;
  163. lab: tasmlabel;
  164. Count, count2: aint;
  165. function reference_is_reusable(const ref: treference): boolean;
  166. begin
  167. result:=(ref.base<>NR_NO) and (ref.index=NR_NO) and
  168. (ref.symbol=nil) and
  169. is_imm12(ref.offset);
  170. end;
  171. begin
  172. src2:=source;
  173. fixref(list,src2);
  174. dst2:=dest;
  175. fixref(list,dst2);
  176. if len > high(longint) then
  177. internalerror(2002072704);
  178. { A call (to FPC_MOVE) requires the outgoing parameter area to be properly
  179. allocated on stack. This can only be done before tmipsprocinfo.set_first_temp_offset,
  180. i.e. before secondpass. Other internal procedures request correct stack frame
  181. by setting pi_do_call during firstpass, but for this particular one it is impossible.
  182. Therefore, if the current procedure is a leaf one, we have to leave it that way. }
  183. { anybody wants to determine a good value here :)? }
  184. if (len > 100) and
  185. assigned(current_procinfo) and
  186. (pi_do_call in current_procinfo.flags) then
  187. g_concatcopy_move(list, src2, dst2, len)
  188. else
  189. begin
  190. Count := len div 4;
  191. if (count<=4) and reference_is_reusable(src2) then
  192. src:=src2
  193. else
  194. begin
  195. reference_reset(src,sizeof(aint),[]);
  196. { load the address of src2 into src.base }
  197. src.base := GetAddressRegister(list);
  198. a_loadaddr_ref_reg(list, src2, src.base);
  199. end;
  200. if (count<=4) and reference_is_reusable(dst2) then
  201. dst:=dst2
  202. else
  203. begin
  204. reference_reset(dst,sizeof(aint),[]);
  205. { load the address of dst2 into dst.base }
  206. dst.base := GetAddressRegister(list);
  207. a_loadaddr_ref_reg(list, dst2, dst.base);
  208. end;
  209. { generate a loop }
  210. if Count > 4 then
  211. begin
  212. countreg := GetIntRegister(list, OS_INT);
  213. tmpreg1 := GetIntRegister(list, OS_INT);
  214. a_load_const_reg(list, OS_INT, Count, countreg);
  215. current_asmdata.getjumplabel(lab);
  216. a_label(list, lab);
  217. list.concat(taicpu.op_reg_ref(A_LW, tmpreg1, src));
  218. list.concat(taicpu.op_reg_ref(A_SW, tmpreg1, dst));
  219. list.concat(taicpu.op_reg_reg_const(A_ADDI, src.base, src.base, 4));
  220. list.concat(taicpu.op_reg_reg_const(A_ADDI, dst.base, dst.base, 4));
  221. list.concat(taicpu.op_reg_reg_const(A_ADDI, countreg, countreg, -1));
  222. a_cmp_reg_reg_label(list,OS_INT,OC_GT,NR_X0,countreg,lab);
  223. len := len mod 4;
  224. end;
  225. { unrolled loop }
  226. Count := len div 4;
  227. if Count > 0 then
  228. begin
  229. tmpreg1 := GetIntRegister(list, OS_INT);
  230. for count2 := 1 to Count do
  231. begin
  232. list.concat(taicpu.op_reg_ref(A_LW, tmpreg1, src));
  233. list.concat(taicpu.op_reg_ref(A_SW, tmpreg1, dst));
  234. Inc(src.offset, 4);
  235. Inc(dst.offset, 4);
  236. end;
  237. len := len mod 4;
  238. end;
  239. if (len and 4) <> 0 then
  240. begin
  241. hreg := GetIntRegister(list, OS_INT);
  242. a_load_ref_reg(list, OS_32, OS_32, src, hreg);
  243. a_load_reg_ref(list, OS_32, OS_32, hreg, dst);
  244. Inc(src.offset, 4);
  245. Inc(dst.offset, 4);
  246. end;
  247. { copy the leftovers }
  248. if (len and 2) <> 0 then
  249. begin
  250. hreg := GetIntRegister(list, OS_INT);
  251. a_load_ref_reg(list, OS_16, OS_16, src, hreg);
  252. a_load_reg_ref(list, OS_16, OS_16, hreg, dst);
  253. Inc(src.offset, 2);
  254. Inc(dst.offset, 2);
  255. end;
  256. if (len and 1) <> 0 then
  257. begin
  258. hreg := GetIntRegister(list, OS_INT);
  259. a_load_ref_reg(list, OS_8, OS_8, src, hreg);
  260. a_load_reg_ref(list, OS_8, OS_8, hreg, dst);
  261. end;
  262. end;
  263. end;
  264. procedure tcgrv32.g_overflowcheck(list: TAsmList; const Loc: tlocation; def: tdef);
  265. begin
  266. end;
  267. procedure tcg64frv.a_op64_reg_reg(list : TAsmList;op:TOpCG;size : tcgsize;regsrc,regdst : tregister64);
  268. var
  269. tmpreg1: TRegister;
  270. begin
  271. case op of
  272. OP_NOT:
  273. begin
  274. cg.a_op_reg_reg(list,OP_NOT,OS_32,regsrc.reglo,regdst.reglo);
  275. cg.a_op_reg_reg(list,OP_NOT,OS_32,regsrc.reghi,regdst.reghi);
  276. end;
  277. OP_NEG:
  278. begin
  279. tmpreg1 := cg.GetIntRegister(list, OS_INT);
  280. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reglo, NR_X0, regsrc.reglo));
  281. list.concat(taicpu.op_reg_reg_reg(A_SLTU, tmpreg1, NR_X0, regdst.reglo));
  282. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reghi, NR_X0, regsrc.reghi));
  283. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reghi, regdst.reghi, tmpreg1));
  284. end;
  285. else
  286. a_op64_reg_reg_reg(list,op,size,regsrc,regdst,regdst);
  287. end;
  288. end;
  289. procedure tcg64frv.a_op64_const_reg(list : TAsmList;op:TOpCG;size : tcgsize;value : int64;reg : tregister64);
  290. begin
  291. a_op64_const_reg_reg(list,op,size,value,reg,reg);
  292. end;
  293. procedure tcg64frv.a_op64_reg_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;regsrc1,regsrc2,regdst : tregister64);
  294. var
  295. signed: Boolean;
  296. tmplo, carry, tmphi, hreg: TRegister;
  297. begin
  298. case op of
  299. OP_AND,OP_OR,OP_XOR:
  300. begin
  301. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reglo,regsrc2.reglo,regdst.reglo);
  302. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reghi,regsrc2.reghi,regdst.reghi);
  303. end;
  304. OP_ADD:
  305. begin
  306. signed:=(size in [OS_S64]);
  307. tmplo := cg.GetIntRegister(list,OS_S32);
  308. carry := cg.GetIntRegister(list,OS_S32);
  309. // destreg.reglo could be regsrc1.reglo or regsrc2.reglo
  310. list.concat(taicpu.op_reg_reg_reg(A_ADD, tmplo, regsrc2.reglo, regsrc1.reglo));
  311. list.concat(taicpu.op_reg_reg_reg(A_SLTU, carry, tmplo, regsrc2.reglo));
  312. cg.a_load_reg_reg(list,OS_INT,OS_INT,tmplo,regdst.reglo);
  313. if signed then
  314. begin
  315. list.concat(taicpu.op_reg_reg_reg(A_ADD, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
  316. list.concat(taicpu.op_reg_reg_reg(A_ADD, regdst.reghi, regdst.reghi, carry));
  317. end
  318. else
  319. begin
  320. tmphi:=cg.GetIntRegister(list,OS_INT);
  321. hreg:=cg.GetIntRegister(list,OS_INT);
  322. cg.a_load_const_reg(list,OS_INT,$80000000,hreg);
  323. // first add carry to one of the addends
  324. list.concat(taicpu.op_reg_reg_reg(A_ADD, tmphi, regsrc2.reghi, carry));
  325. list.concat(taicpu.op_reg_reg_reg(A_SLTU, carry, tmphi, regsrc2.reghi));
  326. list.concat(taicpu.op_reg_reg_reg(A_SUB, carry, hreg, carry));
  327. // then add another addend
  328. list.concat(taicpu.op_reg_reg_reg(A_ADD, regdst.reghi, tmphi, regsrc1.reghi));
  329. end;
  330. end;
  331. OP_SUB:
  332. begin
  333. signed:=(size in [OS_S64]);
  334. tmplo := cg.GetIntRegister(list,OS_S32);
  335. carry := cg.GetIntRegister(list,OS_S32);
  336. // destreg.reglo could be regsrc1.reglo or regsrc2.reglo
  337. list.concat(taicpu.op_reg_reg_reg(A_SUB, tmplo, regsrc2.reglo, regsrc1.reglo));
  338. list.concat(taicpu.op_reg_reg_reg(A_SLTU, carry, regsrc2.reglo,tmplo));
  339. cg.a_load_reg_reg(list,OS_INT,OS_INT,tmplo,regdst.reglo);
  340. if signed then
  341. begin
  342. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reghi, regsrc2.reghi, regsrc1.reghi));
  343. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reghi, regdst.reghi, carry));
  344. end
  345. else
  346. begin
  347. tmphi:=cg.GetIntRegister(list,OS_INT);
  348. hreg:=cg.GetIntRegister(list,OS_INT);
  349. cg.a_load_const_reg(list,OS_INT,$80000000,hreg);
  350. // first subtract the carry...
  351. list.concat(taicpu.op_reg_reg_reg(A_SUB, tmphi, regsrc2.reghi, carry));
  352. list.concat(taicpu.op_reg_reg_reg(A_SLTU, carry, regsrc2.reghi, tmphi));
  353. list.concat(taicpu.op_reg_reg_reg(A_SUB, carry, hreg, carry));
  354. // ...then the subtrahend
  355. list.concat(taicpu.op_reg_reg_reg(A_SUB, regdst.reghi, tmphi, regsrc1.reghi));
  356. end;
  357. end;
  358. else
  359. internalerror(2002072801);
  360. end;
  361. end;
  362. procedure tcg64frv.a_op64_const_reg_reg(list: TAsmList;op:TOpCG;size : tcgsize;value : int64;regsrc,regdst : tregister64);
  363. var
  364. tmplo,carry: TRegister;
  365. hisize: tcgsize;
  366. begin
  367. carry:=NR_NO;
  368. if (size in [OS_S64]) then
  369. hisize:=OS_S32
  370. else
  371. hisize:=OS_32;
  372. case op of
  373. OP_AND,OP_OR,OP_XOR:
  374. begin
  375. cg.a_op_const_reg_reg(list,op,OS_32,aint(lo(value)),regsrc.reglo,regdst.reglo);
  376. cg.a_op_const_reg_reg(list,op,OS_32,aint(hi(value)),regsrc.reghi,regdst.reghi);
  377. end;
  378. OP_ADD:
  379. begin
  380. if lo(value)<>0 then
  381. begin
  382. tmplo:=cg.GetIntRegister(list,OS_32);
  383. carry:=cg.GetIntRegister(list,OS_32);
  384. if is_imm12(aint(lo(value))) then
  385. list.concat(taicpu.op_reg_reg_const(A_ADDI,tmplo,regsrc.reglo,aint(lo(value))))
  386. else
  387. begin
  388. cg.a_load_const_reg(list,OS_INT,aint(lo(value)),tmplo);
  389. list.concat(taicpu.op_reg_reg_reg(A_ADD,tmplo,tmplo,regsrc.reglo))
  390. end;
  391. list.concat(taicpu.op_reg_reg_reg(A_SLTU,carry,tmplo,regsrc.reglo));
  392. cg.a_load_reg_reg(list,OS_32,OS_32,tmplo,regdst.reglo);
  393. end
  394. else
  395. cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo);
  396. { With overflow checking and unsigned args, this generates slighly suboptimal code
  397. ($80000000 constant loaded twice). Other cases are fine. Getting it perfect does not
  398. look worth the effort. }
  399. cg.a_op_const_reg_reg(list,OP_ADD,hisize,aint(hi(value)),regsrc.reghi,regdst.reghi);
  400. if carry<>NR_NO then
  401. cg.a_op_reg_reg_reg(list,OP_ADD,hisize,carry,regdst.reghi,regdst.reghi);
  402. end;
  403. OP_SUB:
  404. begin
  405. carry:=NR_NO;
  406. if lo(value)<>0 then
  407. begin
  408. tmplo:=cg.GetIntRegister(list,OS_32);
  409. carry:=cg.GetIntRegister(list,OS_32);
  410. if {$ifdef AVOID_OVERFLOW} (abs(value) <= max_12_bit) and {$endif} is_imm12(-aint(lo(value))) then
  411. list.concat(taicpu.op_reg_reg_const(A_ADDI,tmplo,regsrc.reglo,-aint(lo(value))))
  412. else
  413. begin
  414. cg.a_load_const_reg(list,OS_INT,aint(lo(value)),tmplo);
  415. list.concat(taicpu.op_reg_reg_reg(A_SUB,tmplo,regsrc.reglo,tmplo))
  416. end;
  417. list.concat(taicpu.op_reg_reg_reg(A_SLTU,carry,regsrc.reglo,tmplo));
  418. cg.a_load_reg_reg(list,OS_32,OS_32,tmplo,regdst.reglo);
  419. end
  420. else
  421. cg.a_load_reg_reg(list,OS_32,OS_32,regsrc.reglo,regdst.reglo);
  422. cg.a_op_const_reg_reg(list,OP_SUB,hisize,aint(hi(value)),regsrc.reghi,regdst.reghi);
  423. if carry<>NR_NO then
  424. cg.a_op_reg_reg_reg(list,OP_SUB,hisize,carry,regdst.reghi,regdst.reghi);
  425. end;
  426. else
  427. InternalError(2013050301);
  428. end;
  429. end;
  430. procedure create_codegen;
  431. begin
  432. cg := tcgrv32.create;
  433. cg64 :=tcg64frv.create;
  434. end;
  435. end.