cgcpu.pas 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202
  1. {
  2. $Id$
  3. Copyright (c) 1998-2000 by Florian Klaempfl
  4. This unit implements the code generator 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 cgcpu;
  19. {$i defines.inc}
  20. interface
  21. uses
  22. cgbase,cgobj,aasm,cpuasm,cpubase,cpuinfo,cg64f32;
  23. type
  24. tcgppc = class(tcg64f32)
  25. { passing parameters, per default the parameter is pushed }
  26. { nr gives the number of the parameter (enumerated from }
  27. { left to right), this allows to move the parameter to }
  28. { register, if the cpu supports register calling }
  29. { conventions }
  30. procedure a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);override;
  31. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);override;
  32. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);override;
  33. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);override;
  34. procedure a_call_name(list : taasmoutput;const s : string;
  35. offset : longint);override;
  36. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister); override;
  37. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
  38. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  39. size: tcgsize; a: aword; src, dst: tregister); override;
  40. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  41. size: tcgsize; src1, src2, dst: tregister); override;
  42. { move instructions }
  43. procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);override;
  44. procedure a_load_reg_ref(list : taasmoutput; size: tcgsize; reg : tregister;const ref : treference);override;
  45. procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const Ref : treference;reg : tregister);override;
  46. procedure a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);override;
  47. procedure a_load_sym_ofs_reg(list: taasmoutput; const sym: tasmsymbol; ofs: longint; reg: tregister); override;
  48. { comparison operations }
  49. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  50. l : tasmlabel);override;
  51. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
  52. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel); override;
  53. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
  54. procedure g_flags2reg(list: taasmoutput; const f: TResFlags; reg: TRegister); override;
  55. procedure g_stackframe_entry_sysv(list : taasmoutput;localsize : longint);
  56. procedure g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  57. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
  58. procedure g_restore_frame_pointer(list : taasmoutput);override;
  59. procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
  60. procedure a_loadaddress_ref_reg(list : taasmoutput;const ref2 : treference;r : tregister);override;
  61. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
  62. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  63. { that's the case, we can use rlwinm to do an AND operation }
  64. function get_rlwi_const(a: longint; var l1, l2: longint): boolean;
  65. private
  66. procedure g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
  67. procedure g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  68. { Make sure ref is a valid reference for the PowerPC and sets the }
  69. { base to the value of the index if (base = R_NO). }
  70. procedure fixref(list: taasmoutput; var ref: treference);
  71. { contains the common code of a_load_reg_ref and a_load_ref_reg }
  72. procedure a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  73. ref: treference);
  74. { creates the correct branch instruction for a given combination }
  75. { of asmcondflags and destination addressing mode }
  76. procedure a_jmp(list: taasmoutput; op: tasmop;
  77. c: tasmcondflag; crval: longint; l: tasmlabel);
  78. end;
  79. const
  80. {
  81. TOpCG2AsmOp: Array[topcg] of TAsmOp = (A_ADD,A_AND,A_DIVWU,
  82. A_DIVW,A_MULLW, A_MULLW, A_NEG,A_NOT,A_OR,
  83. A_SRAW,A_SLW,A_SRW,A_SUB,A_XOR);
  84. }
  85. TOpCG2AsmOpConstLo: Array[topcg] of TAsmOp = (A_ADDI,A_ANDI_,A_DIVWU,
  86. A_DIVW,A_MULLW, A_MULLW, A_NONE,A_NONE,A_ORI,
  87. A_SRAWI,A_SLWI,A_SRWI,A_SUBI,A_XORI);
  88. TOpCG2AsmOpConstHi: Array[topcg] of TAsmOp = (A_ADDIS,A_ANDIS_,
  89. A_DIVWU,A_DIVW, A_MULLW,A_MULLW,A_NONE,A_NONE,
  90. A_ORIS,A_NONE, A_NONE,A_NONE,A_SUBIS,A_XORIS);
  91. TOpCmp2AsmCond: Array[topcmp] of TAsmCondFlag = (C_NONE,C_EQ,C_GT,
  92. C_LT,C_GE,C_LE,C_NE,C_LE,C_NG,C_GE,C_NL);
  93. LoadInstr: Array[OS_8..OS_S32,boolean, boolean] of TAsmOp =
  94. { indexed? updating?}
  95. (((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  96. ((A_LHZ,A_LHZU),(A_LHZX,A_LHZUX)),
  97. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)),
  98. { 64bit stuff should be handled separately }
  99. ((A_NONE,A_NONE),(A_NONE,A_NONE)),
  100. { there's no load-byte-with-sign-extend :( }
  101. ((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  102. ((A_LHA,A_LHAU),(A_LHAX,A_LHAUX)),
  103. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)));
  104. StoreInstr: Array[OS_8..OS_32,boolean, boolean] of TAsmOp =
  105. { indexed? updating?}
  106. (((A_STB,A_STBU),(A_STBX,A_STBUX)),
  107. ((A_STH,A_STHU),(A_STHX,A_STHUX)),
  108. ((A_STW,A_STWU),(A_STWX,A_STWUX)));
  109. implementation
  110. uses
  111. globtype,globals,verbose,systems,cutils, tgcpu;
  112. { parameter passing... Still needs extra support from the processor }
  113. { independent code generator }
  114. procedure tcgppc.a_param_reg(list : taasmoutput;size : tcgsize;r : tregister;nr : longint);
  115. var
  116. ref: treference;
  117. begin
  118. {$ifdef para_sizes_known}
  119. if (nr <= max_param_regs_int) then
  120. a_load_reg_reg(list,size,r,param_regs_int[nr])
  121. else
  122. begin
  123. reset_reference(ref);
  124. ref.base := stack_pointer;
  125. ref.offset := LinkageAreaSize+para_size_till_now;
  126. a_load_reg_ref(list,size,reg,ref);
  127. end;
  128. {$endif para_sizes_known}
  129. end;
  130. procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aword;nr : longint);
  131. var
  132. ref: treference;
  133. begin
  134. {$ifdef para_sizes_known}
  135. if (nr <= max_param_regs_int) then
  136. a_load_const_reg(list,size,a,param_regs_int[nr])
  137. else
  138. begin
  139. reset_reference(ref);
  140. ref.base := stack_pointer;
  141. ref.offset := LinkageAreaSize+para_size_till_now;
  142. a_load_const_ref(list,size,a,ref);
  143. end;
  144. {$endif para_sizes_known}
  145. end;
  146. procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;nr : longint);
  147. var
  148. ref: treference;
  149. tmpreg: tregister;
  150. begin
  151. {$ifdef para_sizes_known}
  152. if (nr <= max_param_regs_int) then
  153. a_load_ref_reg(list,size,r,param_regs_int[nr])
  154. else
  155. begin
  156. reset_reference(ref);
  157. ref.base := stack_pointer;
  158. ref.offset := LinkageAreaSize+para_size_till_now;
  159. tmpreg := get_scratch_reg(list);
  160. a_load_ref_reg(list,size,r,tmpreg);
  161. a_load_reg_ref(list,size,tmpreg,ref);
  162. free_scratch_reg(list,tmpreg);
  163. end;
  164. {$endif para_sizes_known}
  165. end;
  166. procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;nr : longint);
  167. var
  168. ref: treference;
  169. tmpreg: tregister;
  170. begin
  171. {$ifdef para_sizes_known}
  172. if (nr <= max_param_regs_int) then
  173. a_loadaddress_ref_reg(list,size,r,param_regs_int[nr])
  174. else
  175. begin
  176. reset_reference(ref);
  177. ref.base := stack_pointer;
  178. ref.offset := LinkageAreaSize+para_size_till_now;
  179. tmpreg := get_scratch_reg(list);
  180. a_loadaddress_ref_reg(list,size,r,tmpreg);
  181. a_load_reg_ref(list,size,tmpreg,ref);
  182. free_scratch_reg(list,tmpreg);
  183. end;
  184. {$endif para_sizes_known}
  185. end;
  186. { calling a code fragment by name }
  187. procedure tcgppc.a_call_name(list : taasmoutput;const s : string;
  188. offset : longint);
  189. begin
  190. { save our RTOC register value. Only necessary when doing pointer based }
  191. { calls or cross TOC calls, but currently done always }
  192. list.concat(taicpu.op_reg_ref(A_STW,R_RTOC,
  193. new_reference(stack_pointer,LA_RTOC)));
  194. list.concat(taicpu.op_sym(A_BL,newasmsymbol(s)));
  195. list.concat(taicpu.op_reg_ref(A_LWZ,R_RTOC,
  196. new_reference(stack_pointer,LA_RTOC)));
  197. end;
  198. {********************** load instructions ********************}
  199. procedure tcgppc.a_load_const_reg(list : taasmoutput; size: TCGSize; a : aword; reg : TRegister);
  200. begin
  201. if (a and $ffff) <> 0 Then
  202. begin
  203. list.concat(taicpu.op_reg_const(A_LI,reg,a and $ffff));
  204. if (longint(a) < low(smallint)) or
  205. (longint(a) > high(smallint)) then
  206. list.concat(taicpu.op_reg_const(A_ADDIS,reg,
  207. (a shr 16)+ord(smallint(a and $ffff) < 0)))
  208. end
  209. else
  210. list.concat(taicpu.op_reg_const(A_LIS,reg,a shr 16));
  211. end;
  212. procedure tcgppc.a_load_reg_ref(list : taasmoutput; size: TCGSize; reg : tregister;const ref : treference);
  213. var
  214. op: TAsmOp;
  215. ref2: TReference;
  216. begin
  217. ref2 := ref;
  218. FixRef(list,ref2);
  219. if size in [OS_S8..OS_S16] then
  220. { storing is the same for signed and unsigned values }
  221. size := tcgsize(ord(size)-(ord(OS_S8)-ord(OS_8)));
  222. { 64 bit stuff should be handled separately }
  223. if size in [OS_64,OS_S64] then
  224. internalerror(200109236);
  225. op := storeinstr[size,ref2.index<>R_NO,false];
  226. a_load_store(list,op,reg,ref2);
  227. End;
  228. procedure tcgppc.a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref: treference;reg : tregister);
  229. var
  230. op: tasmop;
  231. tmpreg: tregister;
  232. ref2, tmpref: treference;
  233. begin
  234. if ref.is_immediate then
  235. a_load_const_reg(list,size,ref.offset,reg)
  236. else
  237. begin
  238. ref2 := ref;
  239. fixref(list,ref2);
  240. op := loadinstr[size,ref2.index<>R_NO,false];
  241. a_load_store(list,op,reg,ref2);
  242. { sign extend shortint if necessary, since there is no }
  243. { load instruction that does that automatically (JM) }
  244. if size = OS_S8 then
  245. list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
  246. end;
  247. end;
  248. procedure tcgppc.a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);
  249. begin
  250. list.concat(taicpu.op_reg_reg(A_MR,reg2,reg1));
  251. end;
  252. procedure tcgppc.a_load_sym_ofs_reg(list: taasmoutput; const sym: tasmsymbol; ofs: longint; reg: tregister);
  253. begin
  254. { can't use op_sym_ofs_reg because sym+ofs can be > 32767!! }
  255. internalerror(200112293);
  256. end;
  257. procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister);
  258. var
  259. scratch_register: TRegister;
  260. begin
  261. case op of
  262. OP_DIV, OP_IDIV, OP_IMUL, OP_MUL, OP_ADD, OP_AND, OP_OR, OP_SUB,
  263. OP_XOR:
  264. a_op_const_reg_reg(list,op,OS_32,a,reg,reg);
  265. OP_SHL,OP_SHR,OP_SAR:
  266. begin
  267. if (a and 31) <> 0 then
  268. list.concat(taicpu.op_reg_reg_const(
  269. TOpCG2AsmOpConstLo[op],reg,reg,a and 31));
  270. if (a shr 5) <> 0 then
  271. internalError(68991);
  272. end
  273. else internalError(68992);
  274. end;
  275. end;
  276. procedure tcgppc.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
  277. begin
  278. a_op_reg_reg_reg(list,op,OS_32,src,dst,dst);
  279. end;
  280. procedure tcgppc.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  281. size: tcgsize; a: aword; src, dst: tregister);
  282. var
  283. l1,l2: longint;
  284. var
  285. oplo, ophi: tasmop;
  286. scratchreg: tregister;
  287. useReg: boolean;
  288. begin
  289. ophi := TOpCG2AsmOpConstHi[op];
  290. oplo := TOpCG2AsmOpConstLo[op];
  291. { constants in a PPC instruction are always interpreted as signed }
  292. { 16bit values, so if the value is between low(smallint) and }
  293. { high(smallint), it's easy }
  294. if (op in [OP_ADD,OP_SUB,OP_AND,OP_OR,OP_XOR]) then
  295. begin
  296. if (longint(a) >= low(smallint)) and
  297. (longint(a) <= high(smallint)) then
  298. begin
  299. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,a));
  300. exit;
  301. end;
  302. { all basic constant instructions also have a shifted form that }
  303. { works only on the highest 16bits, so if low(a) is 0, we can }
  304. { use that one }
  305. if (lo(a) = 0) then
  306. begin
  307. list.concat(taicpu.op_reg_reg_const(ophi,dst,src,hi(a)));
  308. exit;
  309. end;
  310. end;
  311. { otherwise, the instructions we can generate depend on the }
  312. { operation }
  313. useReg := false;
  314. case op of
  315. OP_DIV, OP_IDIV, OP_IMUL, OP_MUL:
  316. if (Op = OP_IMUL) and (longint(a) >= -32768) and
  317. (longint(a) <= 32767) then
  318. list.concat(taicpu.op_reg_reg_const(A_MULLI,dst,src,a))
  319. else
  320. usereg := true;
  321. OP_ADD,OP_SUB:
  322. begin
  323. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,low(a)));
  324. list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,
  325. high(a) + ord(smallint(a) < 0)));
  326. end;
  327. OP_OR:
  328. { try to use rlwimi }
  329. if get_rlwi_const(a,l1,l2) then
  330. begin
  331. if src <> dst then
  332. list.concat(taicpu.op_reg_reg(A_MR,dst,src));
  333. scratchreg := get_scratch_reg(list);
  334. list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
  335. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
  336. scratchreg,0,l1,l2));
  337. free_scratch_reg(list,scratchreg);
  338. end
  339. else
  340. useReg := true;
  341. OP_AND:
  342. { try to use rlwinm }
  343. if get_rlwi_const(a,l1,l2) then
  344. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,dst,
  345. src,0,l1,l2))
  346. else
  347. useReg := true;
  348. OP_XOR:
  349. useReg := true;
  350. OP_SHL,OP_SHR,OP_SAR:
  351. begin
  352. if (a and 31) <> 0 Then
  353. list.concat(taicpu.op_reg_reg_const(
  354. TOpCG2AsmOpConstLo[Op],dst,src,a and 31));
  355. if (a shr 5) <> 0 then
  356. internalError(68991);
  357. end
  358. else
  359. internalerror(200109091);
  360. end;
  361. { if all else failed, load the constant in a register and then }
  362. { perform the operation }
  363. if useReg then
  364. begin
  365. scratchreg := get_scratch_reg(list);
  366. a_load_const_reg(list,OS_32,a,scratchreg);
  367. a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
  368. free_scratch_reg(list,scratchreg);
  369. end;
  370. end;
  371. procedure tcgppc.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  372. size: tcgsize; src1, src2, dst: tregister);
  373. const
  374. op_reg_reg_opcg2asmop: array[TOpCG] of tasmop =
  375. (A_ADD,A_AND,A_DIVWU,A_DIVW,A_MULLW,A_MULLW,A_NEG,A_NOT,A_OR,
  376. A_SRAW,A_SLW,A_SRW,A_SUB,A_XOR);
  377. begin
  378. case op of
  379. OP_NEG,OP_NOT:
  380. list.concat(taicpu.op_reg_reg(op_reg_reg_opcg2asmop[op],dst,dst));
  381. else
  382. list.concat(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1));
  383. end;
  384. end;
  385. {*************** compare instructructions ****************}
  386. procedure tcgppc.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  387. l : tasmlabel);
  388. var
  389. p: taicpu;
  390. scratch_register: TRegister;
  391. signed: boolean;
  392. begin
  393. signed := cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE];
  394. if signed then
  395. if (longint(a) >= low(smallint)) and (longint(a) <= high(smallint)) Then
  396. list.concat(taicpu.op_reg_reg_const(A_CMPI,R_CR0,reg,a))
  397. else
  398. begin
  399. scratch_register := get_scratch_reg(list);
  400. a_load_const_reg(list,OS_32,a,scratch_register);
  401. list.concat(taicpu.op_reg_reg_reg(A_CMP,R_CR0,reg,scratch_register));
  402. free_scratch_reg(list,scratch_register);
  403. end
  404. else
  405. if (a <= $ffff) then
  406. list.concat(taicpu.op_reg_reg_const(A_CMPLI,R_CR0,reg,a))
  407. else
  408. begin
  409. scratch_register := get_scratch_reg(list);
  410. a_load_const_reg(list,OS_32,a,scratch_register);
  411. list.concat(taicpu.op_reg_reg_reg(A_CMPL,R_CR0,reg,scratch_register));
  412. free_scratch_reg(list,scratch_register);
  413. end;
  414. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  415. end;
  416. procedure tcgppc.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;
  417. reg1,reg2 : tregister;l : tasmlabel);
  418. var
  419. p: taicpu;
  420. op: tasmop;
  421. begin
  422. if cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE] then
  423. op := A_CMP
  424. else op := A_CMPL;
  425. list.concat(taicpu.op_reg_reg_reg(op,R_CR0,reg1,reg2));
  426. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  427. end;
  428. procedure tcgppc.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  429. begin
  430. a_jmp(list,A_BC,TOpCmp2AsmCond[cond],0,l);
  431. end;
  432. procedure tcgppc.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
  433. var
  434. c: tasmcond;
  435. begin
  436. c := flags_to_cond(f);
  437. a_jmp(list,A_BC,c.cond,ord(c.cr)-ord(R_CR0),l);
  438. end;
  439. procedure tcgppc.g_flags2reg(list: taasmoutput; const f: TResFlags; reg: TRegister);
  440. var
  441. testbit: byte;
  442. bitvalue: boolean;
  443. begin
  444. { get the bit to extract from the conditional register + its }
  445. { requested value (0 or 1) }
  446. testbit := (ord(f.cr) * 4);
  447. case f.flag of
  448. F_EQ,F_NE:
  449. bitvalue := f.flag = F_EQ;
  450. F_LT,F_GE:
  451. begin
  452. inc(testbit);
  453. bitvalue := f.flag = F_LT;
  454. end;
  455. F_GT,F_LE:
  456. begin
  457. inc(testbit,2);
  458. bitvalue := f.flag = F_GT;
  459. end;
  460. else
  461. internalerror(200112261);
  462. end;
  463. { load the conditional register in the destination reg }
  464. list.concat(taicpu.op_reg(A_MFCR,reg));
  465. { we will move the bit that has to be tested to bit 31 -> rotate }
  466. { left by bitpos+1 (remember, this is big-endian!) }
  467. testbit := (testbit + 1) and 31;
  468. { extract bit }
  469. list.concat(taicpu.op_reg_reg_const_const_const(
  470. A_RLWINM,reg,reg,testbit,31,31));
  471. { if we need the inverse, xor with 1 }
  472. if not bitvalue then
  473. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  474. end;
  475. (*
  476. procedure tcgppc.g_cond2reg(list: taasmoutput; const f: TAsmCond; reg: TRegister);
  477. var
  478. testbit: byte;
  479. bitvalue: boolean;
  480. begin
  481. { get the bit to extract from the conditional register + its }
  482. { requested value (0 or 1) }
  483. case f.simple of
  484. false:
  485. begin
  486. { we don't generate this in the compiler }
  487. internalerror(200109062);
  488. end;
  489. true:
  490. case f.cond of
  491. C_None:
  492. internalerror(200109063);
  493. C_LT..C_NU:
  494. begin
  495. testbit := (ord(f.cr) - ord(R_CR0))*4;
  496. inc(testbit,AsmCondFlag2BI[f.cond]);
  497. bitvalue := AsmCondFlagTF[f.cond];
  498. end;
  499. C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
  500. begin
  501. testbit := f.crbit
  502. bitvalue := AsmCondFlagTF[f.cond];
  503. end;
  504. else
  505. internalerror(200109064);
  506. end;
  507. end;
  508. { load the conditional register in the destination reg }
  509. list.concat(taicpu.op_reg_reg(A_MFCR,reg));
  510. { we will move the bit that has to be tested to bit 31 -> rotate }
  511. { left by bitpos+1 (remember, this is big-endian!) }
  512. if bitpos <> 31 then
  513. inc(bitpos)
  514. else
  515. bitpos := 0;
  516. { extract bit }
  517. list.concat(taicpu.op_reg_reg_const_const_const(
  518. A_RLWINM,reg,reg,bitpos,31,31));
  519. { if we need the inverse, xor with 1 }
  520. if not bitvalue then
  521. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  522. end;
  523. *)
  524. { *********** entry/exit code and address loading ************ }
  525. procedure tcgppc.g_stackframe_entry(list : taasmoutput;localsize : longint);
  526. begin
  527. case target_info.target of
  528. target_powerpc_macos:
  529. g_stackframe_entry_mac(list,localsize);
  530. target_powerpc_linux:
  531. g_stackframe_entry_sysv(list,localsize)
  532. else
  533. internalerror(2204001);
  534. end;
  535. end;
  536. procedure tcgppc.g_stackframe_entry_sysv(list : taasmoutput;localsize : longint);
  537. { generated the entry code of a procedure/function. Note: localsize is the }
  538. { sum of the size necessary for local variables and the maximum possible }
  539. { combined size of ALL the parameters of a procedure called by the current }
  540. { one }
  541. var regcounter: TRegister;
  542. begin
  543. if (localsize mod 8) <> 0 then internalerror(58991);
  544. { CR and LR only have to be saved in case they are modified by the current }
  545. { procedure, but currently this isn't checked, so save them always }
  546. { following is the entry code as described in "Altivec Programming }
  547. { Interface Manual", bar the saving of AltiVec registers }
  548. a_reg_alloc(list,stack_pointer);
  549. a_reg_alloc(list,R_0);
  550. { allocate registers containing reg parameters }
  551. for regcounter := R_3 to R_10 do
  552. a_reg_alloc(list,regcounter);
  553. { save return address... }
  554. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_LR));
  555. { ... in caller's frame }
  556. list.concat(taicpu.op_reg_ref(A_STW,R_0,new_reference(STACK_POINTER,4)));
  557. a_reg_dealloc(list,R_0);
  558. a_reg_alloc(list,R_11);
  559. { save end of fpr save area }
  560. list.concat(taicpu.op_reg_reg_const(A_ORI,R_11,STACK_POINTER,0));
  561. a_reg_alloc(list,R_12);
  562. { 0 or 8 based on SP alignment }
  563. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  564. R_12,STACK_POINTER,0,28,28));
  565. { add in stack length }
  566. list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
  567. -localsize));
  568. { establish new alignment }
  569. list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER,STACK_POINTER,R_12));
  570. a_reg_dealloc(list,R_12);
  571. { save floating-point registers }
  572. { !!! has to be optimized: only save registers that are used }
  573. list.concat(taicpu.op_sym_ofs(A_BL,newasmsymbol('_savefpr_14'),0));
  574. { compute end of gpr save area }
  575. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,-144));
  576. { save gprs and fetch GOT pointer }
  577. { !!! has to be optimized: only save registers that are used }
  578. list.concat(taicpu.op_sym_ofs(A_BL,newasmsymbol('_savegpr_14_go'),0));
  579. a_reg_alloc(list,R_31);
  580. { place GOT ptr in r31 }
  581. list.concat(taicpu.op_reg_reg(A_MFSPR,R_31,R_LR));
  582. { save the CR if necessary ( !!! always done currently ) }
  583. { still need to find out where this has to be done for SystemV
  584. a_reg_alloc(list,R_0);
  585. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR);
  586. list.concat(taicpu.op_reg_ref(A_STW,scratch_register,
  587. new_reference(stack_pointer,LA_CR)));
  588. a_reg_dealloc(list,R_0); }
  589. { save pointer to incoming arguments }
  590. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_30,R_11,144));
  591. { now comes the AltiVec context save, not yet implemented !!! }
  592. end;
  593. procedure tcgppc.g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  594. { generated the entry code of a procedure/function. Note: localsize is the }
  595. { sum of the size necessary for local variables and the maximum possible }
  596. { combined size of ALL the parameters of a procedure called by the current }
  597. { one }
  598. var regcounter: TRegister;
  599. begin
  600. if (localsize mod 8) <> 0 then internalerror(58991);
  601. { CR and LR only have to be saved in case they are modified by the current }
  602. { procedure, but currently this isn't checked, so save them always }
  603. { following is the entry code as described in "Altivec Programming }
  604. { Interface Manual", bar the saving of AltiVec registers }
  605. a_reg_alloc(list,STACK_POINTER);
  606. a_reg_alloc(list,R_0);
  607. { allocate registers containing reg parameters }
  608. for regcounter := R_3 to R_10 do
  609. a_reg_alloc(list,regcounter);
  610. { save return address... }
  611. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_LR));
  612. { ... in caller's frame }
  613. list.concat(taicpu.op_reg_ref(A_STW,R_0,new_reference(STACK_POINTER,8)));
  614. a_reg_dealloc(list,R_0);
  615. { save floating-point registers }
  616. { !!! has to be optimized: only save registers that are used }
  617. list.concat(taicpu.op_sym_ofs(A_BL,newasmsymbol('_savef14'),0));
  618. { save gprs in gpr save area }
  619. { !!! has to be optimized: only save registers that are used }
  620. list.concat(taicpu.op_reg_ref(A_STMW,R_13,new_reference(STACK_POINTER,-220)));
  621. { save the CR if necessary ( !!! always done currently ) }
  622. a_reg_alloc(list,R_0);
  623. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR));
  624. list.concat(taicpu.op_reg_ref(A_STW,R_0,
  625. new_reference(stack_pointer,LA_CR)));
  626. a_reg_dealloc(list,R_0);
  627. { save pointer to incoming arguments }
  628. list.concat(taicpu.op_reg_reg_const(A_ORI,R_31,STACK_POINTER,0));
  629. a_reg_alloc(list,R_12);
  630. { 0 or 8 based on SP alignment }
  631. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  632. R_12,STACK_POINTER,0,28,28));
  633. { add in stack length }
  634. list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
  635. -localsize));
  636. { establish new alignment }
  637. list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER,STACK_POINTER,R_12));
  638. a_reg_dealloc(list,R_12);
  639. { now comes the AltiVec context save, not yet implemented !!! }
  640. end;
  641. procedure tcgppc.g_restore_frame_pointer(list : taasmoutput);
  642. begin
  643. { no frame pointer on the PowerPC (maybe there is one in the SystemV ABI?)}
  644. end;
  645. procedure tcgppc.g_return_from_proc(list : taasmoutput;parasize : aword);
  646. begin
  647. case target_info.target of
  648. target_powerpc_macos:
  649. g_return_from_proc_mac(list,parasize);
  650. target_powerpc_linux:
  651. g_return_from_proc_sysv(list,parasize)
  652. else
  653. internalerror(2204001);
  654. end;
  655. end;
  656. procedure tcgppc.a_loadaddress_ref_reg(list : taasmoutput;const ref2 : treference;r : tregister);
  657. var tmpreg: tregister;
  658. ref, tmpref: treference;
  659. begin
  660. ref := ref2;
  661. FixRef(list,ref);
  662. if assigned(ref.symbol) then
  663. { add the symbol's value to the base of the reference, and if the }
  664. { reference doesn't have a base, create one }
  665. begin
  666. tmpreg := get_scratch_reg(list);
  667. reset_reference(tmpref);
  668. tmpref.symbol := ref.symbol;
  669. tmpref.symaddr := refs_ha;
  670. tmpref.is_immediate := true;
  671. if ref.base <> R_NO then
  672. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
  673. ref.base,newreference(tmpref)))
  674. else
  675. list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,
  676. newreference(tmpref)));
  677. ref.base := tmpreg;
  678. ref.symaddr := refs_l;
  679. { can be folded with one of the next instructions by the }
  680. { optimizer probably }
  681. list.concat(taicpu.op_reg_reg_ref(A_ADDI,tmpreg,tmpreg,
  682. newreference(tmpref)));
  683. end;
  684. if ref.offset <> 0 Then
  685. if ref.base <> R_NO then
  686. a_op_const_reg_reg(list,OP_ADD,OS_32,ref.offset,ref.base,r)
  687. { FixRef makes sure that "(ref.index <> R_NO) and (ref.offset <> 0)" never}
  688. { occurs, so now only ref.offset has to be loaded }
  689. else a_load_const_reg(list, OS_32, ref.offset, r)
  690. else
  691. if ref.index <> R_NO Then
  692. list.concat(taicpu.op_reg_reg_reg(A_ADD,r,ref.base,ref.index))
  693. else
  694. if r <> ref.base then
  695. list.concat(taicpu.op_reg_reg(A_MR,r,ref.base));
  696. if assigned(ref.symbol) then
  697. free_scratch_reg(list,tmpreg);
  698. end;
  699. { ************* concatcopy ************ }
  700. procedure tcgppc.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
  701. var
  702. t: taicpu;
  703. countreg, tempreg: TRegister;
  704. src, dst: TReference;
  705. lab: tasmlabel;
  706. count, count2: aword;
  707. begin
  708. { make sure source and dest are valid }
  709. src := source;
  710. fixref(list,src);
  711. dst := dest;
  712. fixref(list,dst);
  713. reset_reference(src);
  714. reset_reference(dst);
  715. { load the address of source into src.base }
  716. src.base := get_scratch_reg(list);
  717. if loadref then
  718. a_load_ref_reg(list,OS_32,source,src.base)
  719. else a_loadaddress_ref_reg(list,source,src.base);
  720. if delsource then
  721. del_reference(source);
  722. { load the address of dest into dst.base }
  723. dst.base := get_scratch_reg(list);
  724. a_loadaddress_ref_reg(list,dest,dst.base);
  725. count := len div 4;
  726. if count > 3 then
  727. { generate a loop }
  728. begin
  729. { the offsets are zero after the a_loadaddress_ref_reg and just }
  730. { have to be set to 4. I put an Inc there so debugging may be }
  731. { easier (should offset be different from zero here, it will be }
  732. { easy to notice in the genreated assembler }
  733. Inc(dst.offset,4);
  734. Inc(src.offset,4);
  735. list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
  736. list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
  737. countreg := get_scratch_reg(list);
  738. a_load_const_reg(list,OS_32,count-1,countreg);
  739. { explicitely allocate R_0 since it can be used safely here }
  740. { (for holding date that's being copied) }
  741. tempreg := R_0;
  742. a_reg_alloc(list,R_0);
  743. getlabel(lab);
  744. a_label(list, lab);
  745. list.concat(taicpu.op_reg_ref(A_LWZU,tempreg,
  746. newreference(src)));
  747. list.concat(taicpu.op_reg_reg_const(A_CMPI,R_CR0,countreg,0));
  748. list.concat(taicpu.op_reg_ref(A_STWU,tempreg,newreference(dst)));
  749. list.concat(taicpu.op_reg_reg_const(A_SUBI,countreg,countreg,1));
  750. a_jmp(list,A_BC,C_NE,0,lab);
  751. free_scratch_reg(list,countreg);
  752. end
  753. else
  754. { unrolled loop }
  755. begin
  756. tempreg := get_scratch_reg(list);
  757. for count2 := 1 to count do
  758. begin
  759. a_load_ref_reg(list,OS_32,src,tempreg);
  760. a_load_reg_ref(list,OS_32,tempreg,dst);
  761. inc(src.offset,4);
  762. inc(dst.offset,4);
  763. end
  764. end;
  765. { copy the leftovers }
  766. if (len and 2) <> 0 then
  767. begin
  768. a_load_ref_reg(list,OS_16,src,tempreg);
  769. a_load_reg_ref(list,OS_16,tempreg,dst);
  770. inc(src.offset,2);
  771. inc(dst.offset,2);
  772. end;
  773. if (len and 1) <> 0 then
  774. begin
  775. a_load_ref_reg(list,OS_8,src,tempreg);
  776. a_load_reg_ref(list,OS_8,tempreg,dst);
  777. end;
  778. a_reg_dealloc(list,tempreg);
  779. free_scratch_reg(list,src.base);
  780. free_scratch_reg(list,dst.base);
  781. end;
  782. {***************** This is private property, keep out! :) *****************}
  783. procedure tcgppc.g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
  784. var
  785. regcounter: TRegister;
  786. begin
  787. { release parameter registers }
  788. for regcounter := R_3 to R_10 do
  789. a_reg_dealloc(list,regcounter);
  790. { AltiVec context restore, not yet implemented !!! }
  791. { address of gpr save area to r11 }
  792. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_31,-144));
  793. { restore gprs }
  794. list.concat(taicpu.op_sym_ofs(A_BL,newasmsymbol('_restgpr_14'),0));
  795. { address of fpr save area to r11 }
  796. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,144));
  797. { restore fprs and return }
  798. list.concat(taicpu.op_sym_ofs(A_BL,newasmsymbol('_restfpr_14_x'),0));
  799. end;
  800. procedure tcgppc.g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  801. var
  802. regcounter: TRegister;
  803. begin
  804. { release parameter registers }
  805. for regcounter := R_3 to R_10 do
  806. a_reg_dealloc(list,regcounter);
  807. { AltiVec context restore, not yet implemented !!! }
  808. { restore SP }
  809. list.concat(taicpu.op_reg_reg_const(A_ORI,STACK_POINTER,R_31,0));
  810. { restore gprs }
  811. list.concat(taicpu.op_reg_ref(A_LMW,R_13,new_reference(STACK_POINTER,-220)));
  812. { restore return address ... }
  813. list.concat(taicpu.op_reg_ref(A_LWZ,R_0,new_reference(STACK_POINTER,8)));
  814. { ... and return from _restf14 }
  815. list.concat(taicpu.op_sym_ofs(A_B,newasmsymbol('_restf14'),0));
  816. end;
  817. procedure tcgppc.fixref(list: taasmoutput; var ref: treference);
  818. begin
  819. If (ref.base <> R_NO) then
  820. begin
  821. if (ref.index <> R_NO) and
  822. ((ref.offset <> 0) or assigned(ref.symbol)) then
  823. begin
  824. if not assigned(ref.symbol) and
  825. (cardinal(ref.offset-low(smallint)) <=
  826. high(smallint)-low(smallint)) then
  827. begin
  828. list.concat(taicpu.op_reg_reg_const(
  829. A_ADDI,ref.base,ref.base,ref.offset));
  830. ref.offset := 0;
  831. end
  832. else
  833. begin
  834. list.concat(taicpu.op_reg_reg_reg(
  835. A_ADD,ref.base,ref.base,ref.index));
  836. ref.index := R_NO;
  837. end;
  838. end
  839. end
  840. else
  841. begin
  842. ref.base := ref.index;
  843. ref.index := R_NO
  844. end
  845. end;
  846. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  847. { that's the case, we can use rlwinm to do an AND operation }
  848. function tcgppc.get_rlwi_const(a: longint; var l1, l2: longint): boolean;
  849. var
  850. temp, testbit: longint;
  851. compare: boolean;
  852. begin
  853. get_rlwi_const := false;
  854. { start with the lowest bit }
  855. testbit := 1;
  856. { check its value }
  857. compare := boolean(a and testbit);
  858. { find out how long the run of bits with this value is }
  859. { (it's impossible that all bits are 1 or 0, because in that case }
  860. { this function wouldn't have been called) }
  861. l1 := 31;
  862. while (((a and testbit) <> 0) = compare) do
  863. begin
  864. testbit := testbit shl 1;
  865. dec(l1);
  866. end;
  867. { check the length of the run of bits that comes next }
  868. compare := not compare;
  869. l2 := l1;
  870. while (((a and testbit) <> 0) = compare) and
  871. (l2 >= 0) do
  872. begin
  873. testbit := testbit shl 1;
  874. dec(l2);
  875. end;
  876. { and finally the check whether the rest of the bits all have the }
  877. { same value }
  878. compare := not compare;
  879. temp := l2;
  880. if temp >= 0 then
  881. if (a shr (31-temp)) <> ((-ord(compare)) shr (31-temp)) then
  882. exit;
  883. { we have done "not(not(compare))", so compare is back to its }
  884. { initial value. If the lowest bit was 0, a is of the form }
  885. { 00..11..00 and we need "rlwinm reg,reg,0,l2+1,l1", (+1 }
  886. { because l2 now contains the position of the last zero of the }
  887. { first run instead of that of the first 1) so switch l1 and l2 }
  888. { in that case (we will generate "rlwinm reg,reg,0,l1,l2") }
  889. if not compare then
  890. begin
  891. temp := l1;
  892. l1 := l2+1;
  893. l2 := temp;
  894. end
  895. else
  896. { otherwise, l1 currently contains the position of the last }
  897. { zero instead of that of the first 1 of the second run -> +1 }
  898. inc(l1);
  899. { the following is the same as "if l1 = -1 then l1 := 31;" }
  900. l1 := l1 and 31;
  901. l2 := l2 and 31;
  902. get_rlwi_const := true;
  903. end;
  904. procedure tcgppc.a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  905. ref: treference);
  906. var
  907. tmpreg: tregister;
  908. tmpref: treference;
  909. begin
  910. if assigned(ref.symbol) then
  911. begin
  912. tmpreg := get_scratch_reg(list);
  913. reset_reference(tmpref);
  914. tmpref.symbol := ref.symbol;
  915. tmpref.symaddr := refs_ha;
  916. tmpref.is_immediate := true;
  917. if ref.base <> R_NO then
  918. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
  919. ref.base,newreference(tmpref)))
  920. else
  921. list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,
  922. newreference(tmpref)));
  923. ref.base := tmpreg;
  924. ref.symaddr := refs_l;
  925. end;
  926. list.concat(taicpu.op_reg_ref(op,reg,newreference(ref)));
  927. if assigned(ref.symbol) then
  928. free_scratch_reg(list,tmpreg);
  929. end;
  930. procedure tcgppc.a_jmp(list: taasmoutput; op: tasmop; c: tasmcondflag;
  931. crval: longint; l: tasmlabel);
  932. var
  933. p: taicpu;
  934. begin
  935. p := taicpu.op_sym(op,newasmsymbol(l.name));
  936. create_cond_norm(c,crval,p.condition);
  937. p.is_jmp := true;
  938. list.concat(p)
  939. end;
  940. begin
  941. cg := tcgppc.create;
  942. end.
  943. {
  944. $Log$
  945. Revision 1.11 2002-01-02 14:53:04 jonas
  946. * fixed small bug in a_jmp_flags
  947. Revision 1.10 2001/12/30 17:24:48 jonas
  948. * range checking is now processor independent (part in cgobj, part in cg64f32) and should work correctly again (it needed some changes after the changes of the low and high of tordef's to int64) * maketojumpbool() is now processor independent (in ncgutil) * getregister32 is now called getregisterint
  949. Revision 1.9 2001/12/29 15:28:58 jonas
  950. * powerpc/cgcpu.pas compiles :)
  951. * several powerpc-related fixes
  952. * cpuasm unit is now based on common tainst unit
  953. + nppcmat unit for powerpc (almost complete)
  954. Revision 1.8 2001/10/28 14:16:49 jonas
  955. * small fixes
  956. Revision 1.7 2001/09/29 21:33:30 jonas
  957. * small optimization
  958. Revision 1.6 2001/09/28 20:40:05 jonas
  959. * several additions, almost complete (only some problems with resflags left)
  960. Revision 1.5 2001/09/16 10:33:21 jonas
  961. * some fixes to operations with constants
  962. Revision 1.3 2001/09/06 15:25:55 jonas
  963. * changed type of tcg from object to class -> abstract methods are now
  964. a lot cleaner :)
  965. + more updates: load_*_loc methods, op_*_* methods, g_flags2reg method
  966. (if possible with generic implementation and necessary ppc
  967. implementations)
  968. * worked a bit further on cgflw, now working on exitnode
  969. Revision 1.2 2001/09/05 20:21:03 jonas
  970. * new cgflow based on n386flw with all nodes until forn "translated"
  971. + a_cmp_loc_*_label methods for tcg
  972. + base implementatino for a_cmp_ref_*_label methods
  973. * small bugfixes to powerpc cg
  974. Revision 1.1 2001/08/26 13:31:04 florian
  975. * some cg reorganisation
  976. * some PPC updates
  977. Revision 1.2 2001/08/26 13:29:33 florian
  978. * some cg reorganisation
  979. * some PPC updates
  980. Revision 1.1 2000/07/13 06:30:12 michael
  981. + Initial import
  982. Revision 1.12 2000/04/22 14:25:04 jonas
  983. * aasm.pas: pai_align instead of pai_align_abstract if cpu <> i386
  984. + systems.pas: info for macos/ppc
  985. * new/cgobj.pas: compiles again without newst define
  986. * new/powerpc/cgcpu: generate different entry/exit code depending on
  987. whether target_os is MacOs or Linux
  988. Revision 1.11 2000/01/07 01:14:57 peter
  989. * updated copyright to 2000
  990. Revision 1.10 1999/12/24 22:48:10 jonas
  991. * compiles again
  992. Revision 1.9 1999/11/05 07:05:56 jonas
  993. + a_jmp_cond()
  994. Revision 1.8 1999/10/24 09:22:18 jonas
  995. + entry/exitcode for SystemV (Linux) and AIX/Mac from the Altivec
  996. PIM (no AltiVec support yet though)
  997. * small fix to the a_cmp_* methods
  998. Revision 1.7 1999/10/20 12:23:24 jonas
  999. * fixed a_loadaddress_ref_reg (mentioned as ToDo in rev. 1.5)
  1000. * small bugfix in a_load_store
  1001. Revision 1.6 1999/09/15 20:35:47 florian
  1002. * small fix to operator overloading when in MMX mode
  1003. + the compiler uses now fldz and fld1 if possible
  1004. + some fixes to floating point registers
  1005. + some math. functions (arctan, ln, sin, cos, sqrt, sqr, pi) are now inlined
  1006. * .... ???
  1007. Revision 1.5 1999/09/03 13:14:11 jonas
  1008. + implemented some parameter passing methods, but they require
  1009. some more helper routines
  1010. * fix for loading symbol addresses (still needs to be done in a_loadaddress)
  1011. * several changes to the way conditional branches are handled
  1012. Revision 1.4 1999/08/26 14:53:41 jonas
  1013. * first implementation of concatcopy (requires 4 scratch regs)
  1014. Revision 1.3 1999/08/25 12:00:23 jonas
  1015. * changed pai386, paippc and paiapha (same for tai*) to paicpu (taicpu)
  1016. Revision 1.2 1999/08/18 17:05:57 florian
  1017. + implemented initilizing of data for the new code generator
  1018. so it should compile now simple programs
  1019. Revision 1.1 1999/08/06 16:41:11 jonas
  1020. * PowerPC compiles again, several routines implemented in cgcpu.pas
  1021. * added constant to cpubase of alpha and powerpc for maximum
  1022. number of operands
  1023. }