cpubase.pas 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. {
  2. $Id$
  3. Copyright (c) 1999 by Florian Klaempfl
  4. Contains the base types for the PowerPC
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit cpubase;
  19. interface
  20. {$ifdef TP}
  21. {$L-,Y-}
  22. {$endif}
  23. uses
  24. strings,cobjects,aasm,cpuinfo;
  25. const
  26. { Size of the instruction table converted by nasmconv.pas }
  27. instabentries = 1103;
  28. maxinfolen = 7;
  29. { By default we want everything }
  30. {$define ATTOP}
  31. {$define ATTREG}
  32. {$define INTELOP}
  33. {$define ITTABLE}
  34. { For TP we can't use asmdebug due the table sizes }
  35. {$ifndef TP}
  36. {$define ASMDEBUG}
  37. {$endif}
  38. { We Don't need the intel style opcodes if we don't have a intel }
  39. { reader or generator }
  40. {$undef INTELOP}
  41. { We Don't need the AT&T style opcodes if we don't have a AT&T
  42. reader or generator }
  43. {$ifdef NORA386ATT}
  44. {$ifdef NOAG386ATT}
  45. {$undef ATTOP}
  46. {$ifdef NOAG386DIR}
  47. {$undef ATTREG}
  48. {$endif}
  49. {$endif}
  50. {$endif}
  51. type
  52. TAsmOp=(A_None,
  53. { normal opcodes }
  54. a_add, a_add_, a_addo, a_addo_, a_addc, a_addc_, a_addco, a_addco_,
  55. a_adde, a_adde_, a_addeo, a_addeo_, a_addi, a_addic, a_addic_, a_addis,
  56. a_addme, a_addme_, a_addmeo, a_addmeo_, a_addze, a_addze_, a_addzeo,
  57. a_addzeo_, a_and, a_and_, a_andc, a_andc_, a_andi_, a_andis_, a_b,
  58. a_ba, a_bl, a_bla, a_bc, a_bca, a_bcl, a_bcla, a_bcctr, a_bcctrl, a_bclr,
  59. a_bclrl, a_cmp, a_cmpi, a_cmpl, a_cmpli, a_cntlzw, a_cntlzw_, a_crand,
  60. a_crandc, a_creqv, a_crnand, a_crnor, a_cror, a_crorc, a_crxor, a_dcba,
  61. a_dcbf, a_dcbi, a_dcbst, a_dcbt, a_divw, a_divw_, a_divwo, a_divwo_,
  62. a_divwu, a_divwu_, a_divwuo, a_divwuo_, a_eciwx, a_ecowx, a_eieio, a_eqv,
  63. a_eqv_, a_extsb, a_extsb_, a_extsh, a_extsh_, a_fabs, a_fabs_, a_fadd,
  64. a_fadd_, a_fadds, a_fadds_, a_fcompo, a_fcmpu, a_fctiw, a_fctw_, a_fctwz,
  65. a_fctwz_, a_fdiv, a_fdiv_, a_fdivs, a_fdivs_, a_fmadd, a_fmadd_, a_fmadds,
  66. a_fmadds_, a_fmr, a_fmsub, a_fmsub_, a_fmsubs, a_fmsubs_, a_fmul, a_fmul_,
  67. a_fmuls, a_fmuls_, a_fnabs, a_fnabs_, a_fneg, a_fneg_, a_fnmadd,
  68. a_fnmadd_, a_fnmadds, a_fnmadds_, a_fnmsub, a_fnmsub_, a_fnmsubs,
  69. a_fnmsubs_, a_fres, a_fres_, a_frsp, a_frsp_, a_frsqrte, a_frsqrte_,
  70. a_fsel, a_fsel_, a_fsqrt, a_fsqrt_, a_fsqrts, a_fsqrts_, a_fsub, a_fsub_,
  71. a_fsubs, a_fsubs_, a_icbi, a_isync, a_lbz, a_lbzu, a_lbzux, a_lbzx,
  72. a_lfd, a_lfdu, a_lfdux, a_lfdx, a_lfs, a_lfsu, a_lfsux, a_lfsx, a_lha,
  73. a_lhau, a_lhaux, a_lhax, a_hbrx, a_lhz, a_lhzu, a_lhzux, a_lhzx, a_lmw,
  74. a_lswi, a_lswx, a_lwarx, a_lwbrx, a_lwz, a_lwzu, a_lwzux, a_lwzx, a_mcrf,
  75. a_mcrfs, a_lcrxe, a_mfcr, a_mffs, a_maffs_, a_mfmsr, a_mfspr, a_mfsr,
  76. a_mfsrin, a_mftb, a_mtfcrf, a_a_mtfd0, a_mtfsb1, a_mtfsf, a_mtfsf_,
  77. a_mtfsfi, a_mtfsfi_, a_mtmsr, a_mtspr, a_mtsr, a_mtsrin, a_mulhw,
  78. a_mulhw_, a_mulhwu, a_mulhwu_, a_mulli, a_mullw, a_mullw_, a_mullwo,
  79. a_mullwo_, a_nand, a_nand_, a_neg, a_neg_, a_nego, a_nego_, a_nor, a_nor_,
  80. a_or, a_or_, a_orc, a_orc_, a_ori, a_oris, a_rfi, a_rlwimi, a_rlwimi_,
  81. a_rlwinm, a_tlwinm_, a_rlwnm, a_sc, a_slw, a_slw_, a_sraw, a_sraw_,
  82. a_srawi, a_srawi_,a_srw, a_srw_, a_stb, a_stbu, a_stbux, a_stbx, a_stfd,
  83. a_stfdu, a_stfdux, a_stfdx, a_stfiwx, a_stfs, a_stfsu, a_stfsux, a_stfsx,
  84. a_sth, a_sthbrx, a_sthu, a_sthux, a_sthx, a_stmw, a_stswi, a_stswx, a_stw,
  85. a_stwbrx, a_stwx_, a_stwu, a_stwux, a_stwx, a_subf, a_subf_, a_subfo,
  86. a_subfo_, a_subfc, a_subfc_, a_subfco, a_subfco_, a_subfe, a_subfe_,
  87. a_subfeo, a_subfeo_, a_subfic, a_subfme, a_subfme_, a_subfmeo, a_subfmeo_,
  88. a_subfze, a_subfze_, a_subfzeo, a_subfzeo_, a_sync, a_tlbia, a_tlbie,
  89. a_tlbsync, a_tw, a_twi, a_xor, a_xor_, a_xori, a_xoris,
  90. { simplified mnemonics }
  91. a_subi, a_subis, a_subic, a_subic_, a_sub, a_sub_, a_subo, a_subo_,
  92. a_subc, a_subc_, a_subco, _subco_, a_cmpwi, a_cmpw, a_cmplwi, a_cmplw,
  93. a_extlwi, a_extlwi_, a_extrwi, a_extrwi_, a_inslwi, a_inslwi_, a_insrwi,
  94. a_insrwi_, a_rotlwi, a_rotlwi_, a_rotlw, a_rotlw_, a_slwi, a_slwi_,
  95. a_srwi, a_srwi_, a_clrlwi, a_clrlwi_, a_clrrwi, a_clrrwi_, a_clrslwi,
  96. a_clrslwi_, a_blr, a_bctr, a_blrl, a_bctrl, a_crset, a_crclr, a_crmove,
  97. a_crnot, a_mt {move to special prupose reg}, a_mf {move from special purpose reg},
  98. nop, a_li, a_lis, a_la, a_mr, a_not, a_mtcr);
  99. op2strtable=array[tasmop] of string[8];
  100. const
  101. firstop = low(tasmop);
  102. lastop = high(tasmop);
  103. {*****************************************************************************
  104. Registers
  105. *****************************************************************************}
  106. type
  107. tregister = (R_NO,
  108. R_0,R_1,R_2,R_3,R_4,R_5,R_6,R_7,R_8,R_9,R_10,R_11,R_12,R_13,R_14,R_15,R_16,
  109. R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,R_26,R_27,R_28,R_29,R_30,R_31,
  110. R_F0,R_F1,R_F2,R_F3,R_F4,R_F5,R_F6,R_F7,R_F8,R_F9,R_F10,R_F11,R_F12,
  111. R_F13,R_F14,R_F15,R_F16,R_F17, R_F18,R_F19,R_F20,R_F21,R_F22, R_F23,R_F24,
  112. R_F25,R_F26,R_F27,R_F28,R_F29,R_F30,R_F31,
  113. R_M0,R_M1,R_M2,R_M3,R_M4,R_M5,R_M6,R_M7,R_M8,R_M9,R_M10,R_M11,R_M12,
  114. R_M13,R_M14,R_M15,R_M16,R_M17,R_M18,R_M19,R_M20,R_M21,R_M22, R_M23,R_M24,
  115. R_M25,R_M26,R_M27,R_M28,R_M29,R_M30,R_M31,
  116. R_CR,R_CR0,R_CR1,R_CR2,R_CR3,R_CR4,R_CR5,R_CR6,R_CR7,
  117. R_XER,R_LR,R_CTR,R_FPSCR
  118. );
  119. tregisterset = set of tregister;
  120. reg2strtable = array[tregister] of string[5];
  121. Const
  122. R_SPR1 = R_XER;
  123. R_SPR8 = R_LR;
  124. R_SPR9 = R_CTR;
  125. R_TOC = R_2;
  126. { CR0 = 0;
  127. CR1 = 4;
  128. CR2 = 8;
  129. CR3 = 12;
  130. CR4 = 16;
  131. CR5 = 20;
  132. CR6 = 24;
  133. CR7 = 28;
  134. LT = 0;
  135. GT = 1;
  136. EQ = 2;
  137. SO = 3;
  138. FX = 4;
  139. FEX = 5;
  140. VX = 6;
  141. OX = 7;}
  142. firstreg = low(tregister);
  143. lastreg = high(tregister);
  144. att_reg2str : reg2strtable = ('',
  145. '0','1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16',
  146. '17','18','19','20','21','22','23','24','25','26','27','28','29','30','31',
  147. 'F0','F1','F2','F3','F4','F5','F6','F7', 'F8','F9','F10','F11','F12',
  148. 'F13','F14','F15','F16','F17', 'F18','F19','F20','F21','F22', 'F23','F24',
  149. 'F25','F26','F27','F28','F29','F30','F31',
  150. 'M0','M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12',
  151. 'M13','M14','M15','M16','M17','M18','M19','M20','M21','M22', 'M23','M24',
  152. 'M25','M26','M27','M28','M29','M30','M31',
  153. 'CR','CR0','CR1','CR2','CR3','CR4','CR5','CR6','CR7',
  154. 'XER','LR','CTR','FPSCR'
  155. );
  156. mot_reg2str : reg2strtable = ('',
  157. 'r0','r1','r2','r3','r4','r5','r6','r7','r8','r9','r10','r11','r12','r13',
  158. 'r14','r15','r16','r17','r18','r19','r20','r21','r22','r23','r24','r25',
  159. 'r26','r27','r28','r29','r30','r31',
  160. 'F0','F1','F2','F3','F4','F5','F6','F7', 'F8','F9','F10','F11','F12',
  161. 'F13','F14','F15','F16','F17', 'F18','F19','F20','F21','F22', 'F23','F24',
  162. 'F25','F26','F27','F28','F29','F30','F31',
  163. 'M0','M1','M2','M3','M4','M5','M6','M7','M8','M9','M10','M11','M12',
  164. 'M13','M14','M15','M16','M17','M18','M19','M20','M21','M22', 'M23','M24',
  165. 'M25','M26','M27','M28','M29','M30','M31',
  166. 'CR','CR0','CR1','CR2','CR3','CR4','CR5','CR6','CR7',
  167. 'XER','LR','CTR','FPSCR'
  168. );
  169. {*****************************************************************************
  170. Conditions
  171. *****************************************************************************}
  172. type
  173. {$ifndef tp}
  174. {$minenumsize 1}
  175. {$endif tp}
  176. TAsmCondFlags = (CF_None { unconditional junps },
  177. { conditions when not using ctr decrement etc }
  178. CF_LT,CF_LE,CF_EQ,CF_GE,CF_GT,CF_NL,CF_NE,CF_NG,CF_SO,CF_NS,CF_UN,CF_NU,
  179. { conditions when using ctr decrement etc }
  180. CF_T,CF_F,CF_DNZ,CF_DNZT,CF_DNZF,CF_DZ,CF_DZT,CF_DZF);
  181. {$ifndef tp}
  182. {$minenumsize default}
  183. {$endif tp}
  184. TAsmCond = packed record
  185. case simple: boolean of
  186. false: (BO, BI: byte);
  187. true: (
  188. case cond: TAsmCondFlags of
  189. CF_None: ();
  190. { specifies in which part of the cr the bit has to be }
  191. { tested for blt,bgt,beq etc. }
  192. CF_LT,CF_LE,CF_EQ,CF_GE,CF_GT,CF_NL,CF_NE,CF_NG,CF_SO,
  193. CF_NS,CF_UN,CF_NU: (cr: R_CR0..R_CR7);
  194. { specifies the bit to test for bt,bf,bdz etc. }
  195. CF_T,CF_F,CF_DNZ,CF_DNZT,CF_DNZF,CF_DZ,CF_DZT,CF_DZF:
  196. (crbit: byte)
  197. );
  198. end;
  199. const
  200. { AsmCondFlag2BO: Array[TAsmCondFlags] of Byte =
  201. (0,12,4,12,4,12,4,4,4,12,4,12,4,
  202. );
  203. AsmCondFlag2BI: Array[TAsmCondFlags] of Byte =
  204. (0,0,1,2,0,1,0,2,1,3,3,3,3);}
  205. AsmCondFlag2Str: Array[tasmcondflags] of string[2] = ({cf_none}'',
  206. { conditions when not using ctr decrement etc}
  207. 'lt','le','eq','ge','gt','nl','ne','ng','so','ns','un','nu',
  208. 't','f','dnz','dzt','dnzf','dz','dzt','dzf');
  209. const
  210. CondAsmOps=3;
  211. CondAsmOp:array[0..CondAsmOps-1] of TasmOp=(
  212. A_BC, A_TW, A_TWI
  213. );
  214. {*****************************************************************************
  215. Flags
  216. *****************************************************************************}
  217. type
  218. TResFlags = (F_LT,F_GT,F_EQ,F_SO,F_FX,F_FEX,F_VX,F_OX);
  219. (*
  220. const
  221. { arrays for boolean location conversions }
  222. flag_2_cond : array[TResFlags] of TAsmCond =
  223. (C_E,C_NE,C_G,C_L,C_GE,C_LE,C_C,C_NC,C_A,C_AE,C_B,C_BE);
  224. *)
  225. {*****************************************************************************
  226. Reference
  227. *****************************************************************************}
  228. type
  229. trefoptions=(ref_none,ref_parafixup,ref_localfixup);
  230. { since we have only 16 offsets, we need to be able to specify the high }
  231. { and low 16 bits of the address of a symbol }
  232. trefsymaddr = (refs_full,refs_ha,_refs_l);
  233. { immediate/reference record }
  234. preference = ^treference;
  235. treference = packed record
  236. is_immediate: boolean; { is this used as reference or immediate }
  237. base, index : tregister;
  238. offset : longint;
  239. symbol : pasmsymbol;
  240. symaddr : trefsymaddr;
  241. offsetfixup : longint;
  242. options : trefoptions;
  243. end;
  244. const symaddr2str: array[trefsymaddr] of string[3] = ('','@ha','@l');
  245. {*****************************************************************************
  246. Operand
  247. *****************************************************************************}
  248. type
  249. toptype=(top_none,top_reg,top_ref,top_const,top_symbol,top_bool);
  250. toper=record
  251. ot : longint;
  252. case typ : toptype of
  253. top_none : ();
  254. top_reg : (reg:tregister);
  255. top_ref : (ref:preference);
  256. top_const : (val:aword);
  257. top_symbol : (sym:pasmsymbol;symofs:longint);
  258. top_bool : (b: boolean);
  259. end;
  260. {*****************************************************************************
  261. Generic Location
  262. *****************************************************************************}
  263. type
  264. TLoc=(
  265. LOC_INVALID, { added for tracking problems}
  266. LOC_REGISTER, { in a processor register }
  267. LOC_CREGISTER, { Constant register which shouldn't be modified }
  268. LOC_FPUREGISTER, { FPU register }
  269. LOC_CFPUREGISTER,{ Constant FPU register which shouldn't be modified }
  270. LOC_MMREGISTER, { multimedia register }
  271. LOC_CMMREGISTER, { Constant multimedia reg which shouldn't be modified }
  272. LOC_MEM, { in memory }
  273. LOC_REFERENCE, { like LOC_MEM, but lvalue }
  274. LOC_JUMP, { boolean results only, jump to false or true label }
  275. LOC_FLAGS { boolean results only, flags are set }
  276. );
  277. plocation = ^tlocation;
  278. tlocation = packed record
  279. case loc : tloc of
  280. LOC_MEM,LOC_REFERENCE : (reference : treference);
  281. LOC_FPUREGISTER, LOC_CFPUREGISTER, LOC_MMREGISTER, LOC_CMMREGISTER,
  282. LOC_REGISTER,LOC_CREGISTER : (
  283. case longint of
  284. 1 : (registerlow,registerhigh : tregister);
  285. { overlay a registerlow }
  286. 2 : (register : tregister);
  287. );
  288. LOC_JUMP : ();
  289. LOC_FLAGS : (resflags : tresflags);
  290. LOC_INVALID : ();
  291. { segment in reference at the same place as in loc_register }
  292. end;
  293. {*****************************************************************************
  294. Constants
  295. *****************************************************************************}
  296. const
  297. availabletempregsint = [R_11..R_30];
  298. availabletempregsfpu = [R_F14..R_F31];
  299. availabletempregsmm = [R_M0..R_M31];
  300. c_countusableregsint = 21;
  301. c_countusableregsfpu = 32;
  302. c_countusableregsmm = 32;
  303. max_operands = 5;
  304. maxvarregs = 18;
  305. varregs : Array [1..maxvarregs] of Tregister =
  306. (R_13,R_14,R_15,R_16,R_17,R_18,R_19,R_20,R_21,R_22,R_23,R_24,R_25,
  307. R_26,R_27,R_28,R_29,R_30);
  308. max_param_regs_int = 8;
  309. param_regs_int: Array[1..max_param_regs_int] of tregister =
  310. (R_3,R_4,R_5,R_6,R_7,R_8,R_9,R_10);
  311. max_param_regs_fpu = 13;
  312. param_regs_fpu: Array[1..max_param_regs_fpu] of tregister =
  313. (R_F1,R_F2,R_F3,R_F4,R_F5,R_F6,R_F7,R_F8,R_F9,R_F10,R_F11,R_F12,R_F13);
  314. intregs = [R_0..R_31];
  315. fpuregs = [R_F0..R_F31];
  316. mmregs = [R_M0..R_M31];
  317. cpuflags = [];
  318. registers_saved_on_cdecl = [R_13..R_29];
  319. { generic register names }
  320. stack_pointer = R_1;
  321. R_RTOC = R_2;
  322. frame_pointer = R_NO;
  323. self_pointer = R_9;
  324. accumulator = R_3;
  325. vmt_offset_reg = R_0;
  326. max_scratch_regs = 3;
  327. scratch_regs: Array[1..max_scratch_regs] of TRegister = (R_0,R_30,R_31);
  328. (* cpuflags : set of tcpuflags = []; *)
  329. { sizes }
  330. pointersize = 4;
  331. extended_size = 8;
  332. LinkageAreaSize = 24;
  333. { offset in the linkage area for the saved stack pointer }
  334. LA_SP = 0;
  335. { offset in the linkage area for the saved conditional register}
  336. LA_CR = 4;
  337. { offset in the linkage area for the saved link register}
  338. LA_LR = 8;
  339. { offset in the linkage area for the saved RTOC register}
  340. LA_RTOC = 20;
  341. {*****************************************************************************
  342. Helpers
  343. *****************************************************************************}
  344. { resets all values of ref to defaults }
  345. procedure reset_reference(var ref : treference);
  346. { set mostly used values of a new reference }
  347. function new_reference(base : tregister;offset : longint) : preference;
  348. function newreference(const r : treference) : preference;
  349. procedure disposereference(var r : preference);
  350. function reg2str(r : tregister) : string;
  351. function is_calljmp(o:tasmop):boolean;
  352. function inverse_cond(c: TAsmCond): TAsmCond;
  353. function create_cond_imm(BO,BI:byte): TAsmCond;
  354. function create_cond_norm(cond: TAsmCondFlags; cr: byte): TasmCond;
  355. {*****************************************************************************
  356. Init/Done
  357. *****************************************************************************}
  358. procedure InitCpu;
  359. procedure DoneCpu;
  360. implementation
  361. {$ifdef heaptrc}
  362. uses
  363. ppheap;
  364. {$endif heaptrc}
  365. {*****************************************************************************
  366. Helpers
  367. *****************************************************************************}
  368. function reg2str(r : tregister) : string;
  369. begin
  370. reg2str:=mot_reg2str[r];
  371. end;
  372. function is_calljmp(o:tasmop):boolean;
  373. begin
  374. is_calljmp:=false;
  375. case o of
  376. A_B,A_BA,A_BL,A_BLA,A_BC,A_BCA,A_BCL,A_BCLA,A_BCCTR,A_BCCTRL,A_BCLR,
  377. A_BCLRL,A_TW,A_TWI: is_calljmp:=true;
  378. end;
  379. end;
  380. procedure disposereference(var r : preference);
  381. begin
  382. dispose(r);
  383. r:=nil;
  384. end;
  385. function newreference(const r : treference) : preference;
  386. var
  387. p : preference;
  388. begin
  389. new(p);
  390. p^:=r;
  391. newreference:=p;
  392. end;
  393. procedure reset_reference(var ref : treference);
  394. begin
  395. FillChar(ref,sizeof(treference),0)
  396. end;
  397. function new_reference(base : tregister;offset : longint) : preference;
  398. var
  399. r : preference;
  400. begin
  401. new(r);
  402. FillChar(r^,sizeof(treference),0);
  403. r^.base:=base;
  404. r^.offset:=offset;
  405. new_reference:=r;
  406. end;
  407. function inverse_cond(c: TAsmCond): TAsmCond;
  408. const
  409. inv_condflags:array[TAsmCondFlags] of TAsmCondFlags=(CF_None,
  410. CF_GE,CF_GT,CF_NE,CF_LT,CF_LE,CF_LT,CF_EQ,CF_GT,CF_NS,CF_SO,CF_NU,CF_UN,
  411. CF_F,CF_T,CF_DNZ,CF_DNZF,CF_DNZT,CF_DZ,CF_DZF,CF_DZT);
  412. begin
  413. c.cond := inv_condflags[c.cond];
  414. inverse_cond := c;
  415. end;
  416. function create_cond_imm(BO,BI:byte): TAsmCond;
  417. var c: tasmcond;
  418. begin
  419. c.simple := false;
  420. c.bo := bo;
  421. c.bi := bi;
  422. create_cond_imm := c
  423. end;
  424. function create_cond_norm(cond: TAsmCondFlags; cr: byte): TasmCond;
  425. const cr2reg: array[0..7] of tregister =
  426. (R_CR0,R_CR1,R_CR2,R_CR3,R_CR4,R_CR5,R_CR6,R_CR7);
  427. var c: tasmcond;
  428. begin
  429. c.simple := true;
  430. c.cond := cond;
  431. case cond of
  432. CF_NONE:;
  433. CF_T..CF_DZF: c.crbit := cr
  434. else c.cr := cr2reg[cr];
  435. end;
  436. create_cond_norm := c;
  437. end;
  438. {*****************************************************************************
  439. Init/Done
  440. *****************************************************************************}
  441. procedure InitCpu;
  442. begin
  443. end;
  444. procedure DoneCpu;
  445. begin
  446. end;
  447. end.
  448. {
  449. $Log$
  450. Revision 1.6 1999-09-03 13:11:59 jonas
  451. * several changes to the way conditional branches are handled\n * some typos fixed
  452. Revision 1.5 1999/08/23 23:27:54 pierre
  453. + dummy InitCpu/DoneCpu
  454. Revision 1.4 1999/08/06 16:41:12 jonas
  455. * PowerPC compiles again, several routines implemented in cgcpu.pas
  456. * added constant to cpubase of alpha and powerpc for maximum
  457. number of operands
  458. Revision 1.3 1999/08/05 14:58:18 florian
  459. * some fixes for the floating point registers
  460. * more things for the new code generator
  461. Revision 1.2 1999/08/04 12:59:25 jonas
  462. * all tokes now start with an underscore
  463. * PowerPC compiles!!
  464. Revision 1.1 1999/08/03 23:37:53 jonas
  465. + initial implementation for PowerPC based on the Alpha stuff
  466. }