cgcpu.pas 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 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 fpcdefs.inc}
  20. interface
  21. uses
  22. cgbase,cgobj,
  23. aasmbase,aasmcpu,aasmtai,
  24. cpubase,cpuinfo,node,cg64f32,cginfo;
  25. type
  26. tcgppc = class(tcg)
  27. { passing parameters, per default the parameter is pushed }
  28. { nr gives the number of the parameter (enumerated from }
  29. { left to right), this allows to move the parameter to }
  30. { register, if the cpu supports register calling }
  31. { conventions }
  32. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);override;
  33. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
  34. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
  35. procedure a_call_name(list : taasmoutput;const s : string);override;
  36. procedure a_call_ref(list : taasmoutput;const ref : treference);override;
  37. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister); override;
  38. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
  39. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  40. size: tcgsize; a: aword; src, dst: tregister); override;
  41. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  42. size: tcgsize; src1, src2, dst: tregister); override;
  43. { move instructions }
  44. procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);override;
  45. procedure a_load_reg_ref(list : taasmoutput; size: tcgsize; reg : tregister;const ref : treference);override;
  46. procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const Ref : treference;reg : tregister);override;
  47. procedure a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);override;
  48. procedure a_load_sym_ofs_reg(list: taasmoutput; const sym: tasmsymbol; ofs: longint; reg: tregister); override;
  49. { fpu move instructions }
  50. procedure a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister); override;
  51. procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
  52. procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
  53. { comparison operations }
  54. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  55. l : tasmlabel);override;
  56. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
  57. procedure a_jmp_always(list : taasmoutput;l: tasmlabel); override;
  58. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
  59. procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
  60. procedure g_stackframe_entry_sysv(list : taasmoutput;localsize : longint);
  61. procedure g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  62. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
  63. procedure g_restore_frame_pointer(list : taasmoutput);override;
  64. procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
  65. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
  66. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
  67. procedure g_overflowcheck(list: taasmoutput; const p: tnode); override;
  68. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  69. { that's the case, we can use rlwinm to do an AND operation }
  70. function get_rlwi_const(a: longint; var l1, l2: longint): boolean;
  71. procedure g_save_standard_registers(list : taasmoutput);override;
  72. procedure g_restore_standard_registers(list : taasmoutput);override;
  73. procedure g_save_all_registers(list : taasmoutput);override;
  74. procedure g_restore_all_registers(list : taasmoutput;selfused,accused,acchiused:boolean);override;
  75. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  76. private
  77. procedure g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
  78. procedure g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  79. { Make sure ref is a valid reference for the PowerPC and sets the }
  80. { base to the value of the index if (base = R_NO). }
  81. { Returns true if the reference contained a base, index and an }
  82. { offset or symbol, in which case the base will have been changed }
  83. { to a tempreg (which has to be freed by the caller) containing }
  84. { the sum of part of the original reference }
  85. function fixref(list: taasmoutput; var ref: treference): boolean;
  86. { returns whether a reference can be used immediately in a powerpc }
  87. { instruction }
  88. function issimpleref(const ref: treference): boolean;
  89. { contains the common code of a_load_reg_ref and a_load_ref_reg }
  90. procedure a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  91. ref: treference);
  92. { creates the correct branch instruction for a given combination }
  93. { of asmcondflags and destination addressing mode }
  94. procedure a_jmp(list: taasmoutput; op: tasmop;
  95. c: tasmcondflag; crval: longint; l: tasmlabel);
  96. end;
  97. tcg64fppc = class(tcg64f32)
  98. procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
  99. procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);override;
  100. procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);override;
  101. procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);override;
  102. end;
  103. const
  104. TOpCG2AsmOpConstLo: Array[topcg] of TAsmOp = (A_NONE,A_ADDI,A_ANDI_,A_DIVWU,
  105. A_DIVW,A_MULLW, A_MULLW, A_NONE,A_NONE,A_ORI,
  106. A_SRAWI,A_SLWI,A_SRWI,A_SUBI,A_XORI);
  107. TOpCG2AsmOpConstHi: Array[topcg] of TAsmOp = (A_NONE,A_ADDIS,A_ANDIS_,
  108. A_DIVWU,A_DIVW, A_MULLW,A_MULLW,A_NONE,A_NONE,
  109. A_ORIS,A_NONE, A_NONE,A_NONE,A_SUBIS,A_XORIS);
  110. TOpCmp2AsmCond: Array[topcmp] of TAsmCondFlag = (C_NONE,C_EQ,C_GT,
  111. C_LT,C_GE,C_LE,C_NE,C_LE,C_NG,C_GE,C_NL);
  112. implementation
  113. uses
  114. globtype,globals,verbose,systems,cutils,symconst,symdef,rgobj;
  115. { parameter passing... Still needs extra support from the processor }
  116. { independent code generator }
  117. procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
  118. var
  119. ref: treference;
  120. begin
  121. case locpara.loc of
  122. LOC_REGISTER,LOC_CREGISTER:
  123. a_load_const_reg(list,size,a,locpara.register);
  124. LOC_REFERENCE:
  125. begin
  126. reference_reset(ref);
  127. ref.base:=locpara.reference.index;
  128. ref.offset:=locpara.reference.offset;
  129. a_load_const_ref(list,size,a,ref);
  130. end;
  131. else
  132. internalerror(2002081101);
  133. end;
  134. if locpara.sp_fixup<>0 then
  135. internalerror(2002081102);
  136. end;
  137. procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
  138. var
  139. ref: treference;
  140. tmpreg: tregister;
  141. begin
  142. case locpara.loc of
  143. LOC_REGISTER,LOC_CREGISTER:
  144. a_load_ref_reg(list,size,r,locpara.register);
  145. LOC_REFERENCE:
  146. begin
  147. reference_reset(ref);
  148. ref.base:=locpara.reference.index;
  149. ref.offset:=locpara.reference.offset;
  150. tmpreg := get_scratch_reg_int(list);
  151. a_load_ref_reg(list,size,r,tmpreg);
  152. a_load_reg_ref(list,size,tmpreg,ref);
  153. free_scratch_reg(list,tmpreg);
  154. end;
  155. LOC_FPUREGISTER,LOC_CFPUREGISTER:
  156. case size of
  157. OS_32:
  158. a_loadfpu_ref_reg(list,OS_F32,r,locpara.register);
  159. OS_64:
  160. a_loadfpu_ref_reg(list,OS_F64,r,locpara.register);
  161. else
  162. internalerror(2002072801);
  163. end;
  164. else
  165. internalerror(2002081103);
  166. end;
  167. if locpara.sp_fixup<>0 then
  168. internalerror(2002081104);
  169. end;
  170. procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
  171. var
  172. ref: treference;
  173. tmpreg: tregister;
  174. begin
  175. case locpara.loc of
  176. LOC_REGISTER,LOC_CREGISTER:
  177. a_loadaddr_ref_reg(list,r,locpara.register);
  178. LOC_REFERENCE:
  179. begin
  180. reference_reset(ref);
  181. ref.base := locpara.reference.index;
  182. ref.offset := locpara.reference.offset;
  183. tmpreg := get_scratch_reg_address(list);
  184. a_loadaddr_ref_reg(list,r,tmpreg);
  185. a_load_reg_ref(list,OS_ADDR,tmpreg,ref);
  186. free_scratch_reg(list,tmpreg);
  187. end;
  188. else
  189. internalerror(2002080701);
  190. end;
  191. end;
  192. { calling a code fragment by name }
  193. procedure tcgppc.a_call_name(list : taasmoutput;const s : string);
  194. var
  195. href : treference;
  196. begin
  197. { save our RTOC register value. Only necessary when doing pointer based }
  198. { calls or cross TOC calls, but currently done always }
  199. reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
  200. list.concat(taicpu.op_reg_ref(A_STW,R_TOC,href));
  201. list.concat(taicpu.op_sym(A_BL,objectlibrary.newasmsymbol(s)));
  202. reference_reset_base(href,STACK_POINTER_REG,LA_RTOC);
  203. list.concat(taicpu.op_reg_ref(A_LWZ,R_TOC,href));
  204. procinfo^.flags:=procinfo^.flags or pi_do_call;
  205. end;
  206. { calling a code fragment through a reference }
  207. procedure tcgppc.a_call_ref(list : taasmoutput;const ref : treference);
  208. begin
  209. {$warning FIX ME}
  210. procinfo^.flags:=procinfo^.flags or pi_do_call;
  211. end;
  212. {********************** load instructions ********************}
  213. procedure tcgppc.a_load_const_reg(list : taasmoutput; size: TCGSize; a : aword; reg : TRegister);
  214. begin
  215. if (longint(a) >= low(smallint)) and
  216. (longint(a) <= high(smallint)) then
  217. list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a)))
  218. else if ((a and $ffff) <> 0) then
  219. begin
  220. list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a and $ffff)));
  221. if ((a shr 16) <> 0) or
  222. (smallint(a and $ffff) < 0) then
  223. list.concat(taicpu.op_reg_const(A_ADDIS,reg,
  224. smallint((a shr 16)+ord(smallint(a and $ffff) < 0))))
  225. end
  226. else
  227. list.concat(taicpu.op_reg_const(A_LIS,reg,smallint(a shr 16)));
  228. end;
  229. procedure tcgppc.a_load_reg_ref(list : taasmoutput; size: TCGSize; reg : tregister;const ref : treference);
  230. const
  231. StoreInstr: Array[OS_8..OS_32,boolean, boolean] of TAsmOp =
  232. { indexed? updating?}
  233. (((A_STB,A_STBU),(A_STBX,A_STBUX)),
  234. ((A_STH,A_STHU),(A_STHX,A_STHUX)),
  235. ((A_STW,A_STWU),(A_STWX,A_STWUX)));
  236. var
  237. op: TAsmOp;
  238. ref2: TReference;
  239. freereg: boolean;
  240. begin
  241. ref2 := ref;
  242. freereg := fixref(list,ref2);
  243. if size in [OS_S8..OS_S16] then
  244. { storing is the same for signed and unsigned values }
  245. size := tcgsize(ord(size)-(ord(OS_S8)-ord(OS_8)));
  246. { 64 bit stuff should be handled separately }
  247. if size in [OS_64,OS_S64] then
  248. internalerror(200109236);
  249. op := storeinstr[tcgsize2unsigned[size],ref2.index<>R_NO,false];
  250. a_load_store(list,op,reg,ref2);
  251. if freereg then
  252. cg.free_scratch_reg(list,ref2.base);
  253. End;
  254. procedure tcgppc.a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref: treference;reg : tregister);
  255. const
  256. LoadInstr: Array[OS_8..OS_S32,boolean, boolean] of TAsmOp =
  257. { indexed? updating?}
  258. (((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  259. ((A_LHZ,A_LHZU),(A_LHZX,A_LHZUX)),
  260. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)),
  261. { 64bit stuff should be handled separately }
  262. ((A_NONE,A_NONE),(A_NONE,A_NONE)),
  263. { there's no load-byte-with-sign-extend :( }
  264. ((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  265. ((A_LHA,A_LHAU),(A_LHAX,A_LHAUX)),
  266. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)));
  267. var
  268. op: tasmop;
  269. tmpreg: tregister;
  270. ref2, tmpref: treference;
  271. freereg: boolean;
  272. begin
  273. ref2 := ref;
  274. freereg := fixref(list,ref2);
  275. op := loadinstr[size,ref2.index<>R_NO,false];
  276. a_load_store(list,op,reg,ref2);
  277. if freereg then
  278. free_scratch_reg(list,ref2.base);
  279. { sign extend shortint if necessary, since there is no }
  280. { load instruction that does that automatically (JM) }
  281. if size = OS_S8 then
  282. list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
  283. end;
  284. procedure tcgppc.a_load_reg_reg(list : taasmoutput;size : tcgsize;reg1,reg2 : tregister);
  285. begin
  286. if (reg1 <> reg2) or
  287. not(size in [OS_32,OS_S32]) then
  288. begin
  289. case size of
  290. OS_8:
  291. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  292. reg2,reg1,0,31-8+1,31));
  293. OS_S8:
  294. list.concat(taicpu.op_reg_reg(A_EXTSB,reg2,reg1));
  295. OS_16:
  296. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  297. reg2,reg1,0,31-16+1,31));
  298. OS_S16:
  299. list.concat(taicpu.op_reg_reg(A_EXTSH,reg2,reg1));
  300. OS_32,OS_S32:
  301. list.concat(taicpu.op_reg_reg(A_MR,reg2,reg1));
  302. end;
  303. end;
  304. end;
  305. procedure tcgppc.a_load_sym_ofs_reg(list: taasmoutput; const sym: tasmsymbol; ofs: longint; reg: tregister);
  306. begin
  307. { can't use op_sym_ofs_reg because sym+ofs can be > 32767!! }
  308. internalerror(200112293);
  309. end;
  310. procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; reg1, reg2: tregister);
  311. begin
  312. list.concat(taicpu.op_reg_reg(A_FMR,reg2,reg1));
  313. end;
  314. procedure tcgppc.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister);
  315. const
  316. FpuLoadInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
  317. { indexed? updating?}
  318. (((A_LFS,A_LFSU),(A_LFSX,A_LFSUX)),
  319. ((A_LFD,A_LFDU),(A_LFDX,A_LFDUX)));
  320. var
  321. op: tasmop;
  322. ref2: treference;
  323. freereg: boolean;
  324. begin
  325. { several functions call this procedure with OS_32 or OS_64 }
  326. { so this makes life easier (FK) }
  327. case size of
  328. OS_32,OS_F32:
  329. size:=OS_F32;
  330. OS_64,OS_F64:
  331. size:=OS_F64;
  332. else
  333. internalerror(200201121);
  334. end;
  335. ref2 := ref;
  336. freereg := fixref(list,ref2);
  337. op := fpuloadinstr[size,ref2.index <> R_NO,false];
  338. a_load_store(list,op,reg,ref2);
  339. if freereg then
  340. cg.free_scratch_reg(list,ref2.base);
  341. end;
  342. procedure tcgppc.a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference);
  343. const
  344. FpuStoreInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
  345. { indexed? updating?}
  346. (((A_STFS,A_STFSU),(A_STFSX,A_STFSUX)),
  347. ((A_STFD,A_STFDU),(A_STFDX,A_STFDUX)));
  348. var
  349. op: tasmop;
  350. ref2: treference;
  351. freereg: boolean;
  352. begin
  353. if not(size in [OS_F32,OS_F64]) then
  354. internalerror(200201122);
  355. ref2 := ref;
  356. freereg := fixref(list,ref2);
  357. op := fpustoreinstr[size,ref2.index <> R_NO,false];
  358. a_load_store(list,op,reg,ref2);
  359. if freereg then
  360. cg.free_scratch_reg(list,ref2.base);
  361. end;
  362. procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; a: AWord; reg: TRegister);
  363. var
  364. scratch_register: TRegister;
  365. begin
  366. a_op_const_reg_reg(list,op,OS_32,a,reg,reg);
  367. end;
  368. procedure tcgppc.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
  369. begin
  370. a_op_reg_reg_reg(list,op,OS_32,src,dst,dst);
  371. end;
  372. procedure tcgppc.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  373. size: tcgsize; a: aword; src, dst: tregister);
  374. var
  375. l1,l2: longint;
  376. oplo, ophi: tasmop;
  377. scratchreg: tregister;
  378. useReg, gotrlwi: boolean;
  379. procedure do_lo_hi;
  380. begin
  381. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
  382. list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,word(a shr 16)));
  383. end;
  384. begin
  385. if op = OP_SUB then
  386. begin
  387. {$ifopt q+}
  388. {$q-}
  389. {$define overflowon}
  390. {$endif}
  391. a_op_const_reg_reg(list,OP_ADD,size,aword(-a),src,dst);
  392. {$ifdef overflowon}
  393. {$q+}
  394. {$undef overflowon}
  395. {$endif}
  396. exit;
  397. end;
  398. ophi := TOpCG2AsmOpConstHi[op];
  399. oplo := TOpCG2AsmOpConstLo[op];
  400. gotrlwi := get_rlwi_const(a,l1,l2);
  401. if (op in [OP_AND,OP_OR,OP_XOR]) then
  402. begin
  403. if (a = 0) then
  404. begin
  405. if op = OP_AND then
  406. list.concat(taicpu.op_reg_const(A_LI,dst,0));
  407. exit;
  408. end
  409. else if (a = high(aword)) then
  410. begin
  411. case op of
  412. OP_OR:
  413. list.concat(taicpu.op_reg_const(A_LI,dst,-1));
  414. OP_XOR:
  415. list.concat(taicpu.op_reg_reg(A_NOT,dst,src));
  416. end;
  417. exit;
  418. end
  419. else if (a <= high(word)) and
  420. ((op <> OP_AND) or
  421. not gotrlwi) then
  422. begin
  423. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
  424. exit;
  425. end;
  426. { all basic constant instructions also have a shifted form that }
  427. { works only on the highest 16bits, so if lo(a) is 0, we can }
  428. { use that one }
  429. if (word(a) = 0) and
  430. (not(op = OP_AND) or
  431. not gotrlwi) then
  432. begin
  433. list.concat(taicpu.op_reg_reg_const(ophi,dst,src,word(a shr 16)));
  434. exit;
  435. end;
  436. end
  437. else if (op = OP_ADD) then
  438. if a = 0 then
  439. exit
  440. else if (longint(a) >= low(smallint)) and
  441. (longint(a) <= high(smallint)) then
  442. begin
  443. list.concat(taicpu.op_reg_reg_const(A_ADDI,dst,src,smallint(a)));
  444. exit;
  445. end;
  446. { otherwise, the instructions we can generate depend on the }
  447. { operation }
  448. useReg := false;
  449. case op of
  450. OP_DIV,OP_IDIV:
  451. if (a = 0) then
  452. internalerror(200208103)
  453. else if (a = 1) then
  454. begin
  455. a_load_reg_reg(list,OS_INT,src,dst);
  456. exit
  457. end
  458. else if ispowerof2(a,l1) then
  459. begin
  460. case op of
  461. OP_DIV:
  462. list.concat(taicpu.op_reg_reg_const(A_SRWI,dst,src,l1));
  463. OP_IDIV:
  464. begin
  465. list.concat(taicpu.op_reg_reg_const(A_SRAWI,dst,src,l1));
  466. list.concat(taicpu.op_reg_reg(A_ADDZE,dst,dst));
  467. end;
  468. end;
  469. exit;
  470. end
  471. else
  472. usereg := true;
  473. OP_IMUL, OP_MUL:
  474. if (a = 0) then
  475. begin
  476. list.concat(taicpu.op_reg_const(A_LI,dst,0));
  477. exit
  478. end
  479. else if (a = 1) then
  480. begin
  481. a_load_reg_reg(list,OS_INT,src,dst);
  482. exit
  483. end
  484. else if ispowerof2(a,l1) then
  485. list.concat(taicpu.op_reg_reg_const(A_SLWI,dst,src,l1))
  486. else if (longint(a) >= low(smallint)) and
  487. (longint(a) <= high(smallint)) then
  488. list.concat(taicpu.op_reg_reg_const(A_MULLI,dst,src,smallint(a)))
  489. else
  490. usereg := true;
  491. OP_ADD:
  492. begin
  493. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,smallint(a)));
  494. list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,
  495. smallint((a shr 16) + ord(smallint(a) < 0))));
  496. end;
  497. OP_OR:
  498. { try to use rlwimi }
  499. if gotrlwi and
  500. (src = dst) then
  501. begin
  502. scratchreg := get_scratch_reg_int(list);
  503. list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
  504. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
  505. scratchreg,0,l1,l2));
  506. free_scratch_reg(list,scratchreg);
  507. end
  508. else
  509. do_lo_hi;
  510. OP_AND:
  511. { try to use rlwinm }
  512. if gotrlwi then
  513. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,dst,
  514. src,0,l1,l2))
  515. else
  516. useReg := true;
  517. OP_XOR:
  518. do_lo_hi;
  519. OP_SHL,OP_SHR,OP_SAR:
  520. begin
  521. if (a and 31) <> 0 Then
  522. list.concat(taicpu.op_reg_reg_const(
  523. TOpCG2AsmOpConstLo[Op],dst,src,a and 31));
  524. if (a shr 5) <> 0 then
  525. internalError(68991);
  526. end
  527. else
  528. internalerror(200109091);
  529. end;
  530. { if all else failed, load the constant in a register and then }
  531. { perform the operation }
  532. if useReg then
  533. begin
  534. scratchreg := get_scratch_reg_int(list);
  535. a_load_const_reg(list,OS_32,a,scratchreg);
  536. a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
  537. free_scratch_reg(list,scratchreg);
  538. end;
  539. end;
  540. procedure tcgppc.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  541. size: tcgsize; src1, src2, dst: tregister);
  542. const
  543. op_reg_reg_opcg2asmop: array[TOpCG] of tasmop =
  544. (A_NONE,A_ADD,A_AND,A_DIVWU,A_DIVW,A_MULLW,A_MULLW,A_NEG,A_NOT,A_OR,
  545. A_SRAW,A_SLW,A_SRW,A_SUB,A_XOR);
  546. begin
  547. case op of
  548. OP_NEG,OP_NOT:
  549. list.concat(taicpu.op_reg_reg(op_reg_reg_opcg2asmop[op],dst,dst));
  550. else
  551. list.concat(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1));
  552. end;
  553. end;
  554. {*************** compare instructructions ****************}
  555. procedure tcgppc.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  556. l : tasmlabel);
  557. var
  558. p: taicpu;
  559. scratch_register: TRegister;
  560. signed: boolean;
  561. begin
  562. signed := cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE];
  563. { in the following case, we generate more efficient code when }
  564. { signed is true }
  565. if (cmp_op in [OC_EQ,OC_NE]) and
  566. (a > $ffff) then
  567. signed := true;
  568. if signed then
  569. if (longint(a) >= low(smallint)) and (longint(a) <= high(smallint)) Then
  570. list.concat(taicpu.op_reg_reg_const(A_CMPWI,R_CR0,reg,longint(a)))
  571. else
  572. begin
  573. scratch_register := get_scratch_reg_int(list);
  574. a_load_const_reg(list,OS_32,a,scratch_register);
  575. list.concat(taicpu.op_reg_reg_reg(A_CMPW,R_CR0,reg,scratch_register));
  576. free_scratch_reg(list,scratch_register);
  577. end
  578. else
  579. if (a <= $ffff) then
  580. list.concat(taicpu.op_reg_reg_const(A_CMPLWI,R_CR0,reg,a))
  581. else
  582. begin
  583. scratch_register := get_scratch_reg_int(list);
  584. a_load_const_reg(list,OS_32,a,scratch_register);
  585. list.concat(taicpu.op_reg_reg_reg(A_CMPLW,R_CR0,reg,scratch_register));
  586. free_scratch_reg(list,scratch_register);
  587. end;
  588. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  589. end;
  590. procedure tcgppc.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;
  591. reg1,reg2 : tregister;l : tasmlabel);
  592. var
  593. p: taicpu;
  594. op: tasmop;
  595. begin
  596. if cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE] then
  597. op := A_CMPW
  598. else op := A_CMPLW;
  599. list.concat(taicpu.op_reg_reg_reg(op,R_CR0,reg1,reg2));
  600. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  601. end;
  602. procedure tcgppc.g_save_standard_registers(list : taasmoutput);
  603. begin
  604. {$warning FIX ME}
  605. end;
  606. procedure tcgppc.g_restore_standard_registers(list : taasmoutput);
  607. begin
  608. {$warning FIX ME}
  609. end;
  610. procedure tcgppc.g_save_all_registers(list : taasmoutput);
  611. begin
  612. {$warning FIX ME}
  613. end;
  614. procedure tcgppc.g_restore_all_registers(list : taasmoutput;selfused,accused,acchiused:boolean);
  615. begin
  616. {$warning FIX ME}
  617. end;
  618. procedure tcgppc.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  619. begin
  620. a_jmp(list,A_BC,TOpCmp2AsmCond[cond],0,l);
  621. end;
  622. procedure tcgppc.a_jmp_always(list : taasmoutput;l: tasmlabel);
  623. begin
  624. a_jmp(list,A_B,C_None,0,l);
  625. end;
  626. procedure tcgppc.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
  627. var
  628. c: tasmcond;
  629. begin
  630. c := flags_to_cond(f);
  631. a_jmp(list,A_BC,c.cond,ord(c.cr)-ord(R_CR0),l);
  632. end;
  633. procedure tcgppc.g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister);
  634. var
  635. testbit: byte;
  636. bitvalue: boolean;
  637. begin
  638. { get the bit to extract from the conditional register + its }
  639. { requested value (0 or 1) }
  640. testbit := ((ord(f.cr)-ord(R_CR0)) * 4);
  641. case f.flag of
  642. F_EQ,F_NE:
  643. bitvalue := f.flag = F_EQ;
  644. F_LT,F_GE:
  645. begin
  646. inc(testbit);
  647. bitvalue := f.flag = F_LT;
  648. end;
  649. F_GT,F_LE:
  650. begin
  651. inc(testbit,2);
  652. bitvalue := f.flag = F_GT;
  653. end;
  654. else
  655. internalerror(200112261);
  656. end;
  657. { load the conditional register in the destination reg }
  658. list.concat(taicpu.op_reg(A_MFCR,reg));
  659. { we will move the bit that has to be tested to bit 0 by rotating }
  660. { left }
  661. testbit := (32 - testbit) and 31;
  662. { extract bit }
  663. list.concat(taicpu.op_reg_reg_const_const_const(
  664. A_RLWINM,reg,reg,testbit,31,31));
  665. { if we need the inverse, xor with 1 }
  666. if not bitvalue then
  667. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  668. end;
  669. (*
  670. procedure tcgppc.g_cond2reg(list: taasmoutput; const f: TAsmCond; reg: TRegister);
  671. var
  672. testbit: byte;
  673. bitvalue: boolean;
  674. begin
  675. { get the bit to extract from the conditional register + its }
  676. { requested value (0 or 1) }
  677. case f.simple of
  678. false:
  679. begin
  680. { we don't generate this in the compiler }
  681. internalerror(200109062);
  682. end;
  683. true:
  684. case f.cond of
  685. C_None:
  686. internalerror(200109063);
  687. C_LT..C_NU:
  688. begin
  689. testbit := (ord(f.cr) - ord(R_CR0))*4;
  690. inc(testbit,AsmCondFlag2BI[f.cond]);
  691. bitvalue := AsmCondFlagTF[f.cond];
  692. end;
  693. C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
  694. begin
  695. testbit := f.crbit
  696. bitvalue := AsmCondFlagTF[f.cond];
  697. end;
  698. else
  699. internalerror(200109064);
  700. end;
  701. end;
  702. { load the conditional register in the destination reg }
  703. list.concat(taicpu.op_reg_reg(A_MFCR,reg));
  704. { we will move the bit that has to be tested to bit 31 -> rotate }
  705. { left by bitpos+1 (remember, this is big-endian!) }
  706. if bitpos <> 31 then
  707. inc(bitpos)
  708. else
  709. bitpos := 0;
  710. { extract bit }
  711. list.concat(taicpu.op_reg_reg_const_const_const(
  712. A_RLWINM,reg,reg,bitpos,31,31));
  713. { if we need the inverse, xor with 1 }
  714. if not bitvalue then
  715. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  716. end;
  717. *)
  718. { *********** entry/exit code and address loading ************ }
  719. procedure tcgppc.g_stackframe_entry(list : taasmoutput;localsize : longint);
  720. begin
  721. case target_info.system of
  722. system_powerpc_macos:
  723. g_stackframe_entry_mac(list,localsize);
  724. system_powerpc_linux:
  725. g_stackframe_entry_sysv(list,localsize)
  726. else
  727. internalerror(2204001);
  728. end;
  729. end;
  730. procedure tcgppc.g_stackframe_entry_sysv(list : taasmoutput;localsize : longint);
  731. { generated the entry code of a procedure/function. Note: localsize is the }
  732. { sum of the size necessary for local variables and the maximum possible }
  733. { combined size of ALL the parameters of a procedure called by the current }
  734. { one }
  735. var regcounter,firstregfpu,firstreggpr : TRegister;
  736. href : treference;
  737. usesfpr,usesgpr,gotgot : boolean;
  738. parastart : aword;
  739. begin
  740. { CR and LR only have to be saved in case they are modified by the current }
  741. { procedure, but currently this isn't checked, so save them always }
  742. { following is the entry code as described in "Altivec Programming }
  743. { Interface Manual", bar the saving of AltiVec registers }
  744. a_reg_alloc(list,STACK_POINTER_REG);
  745. a_reg_alloc(list,R_0);
  746. { allocate registers containing reg parameters }
  747. for regcounter := R_3 to R_10 do
  748. a_reg_alloc(list,regcounter);
  749. usesfpr:=false;
  750. for regcounter:=R_F14 to R_F31 do
  751. if regcounter in rg.usedbyproc then
  752. begin
  753. usesfpr:=true;
  754. firstregfpu:=regcounter;
  755. break;
  756. end;
  757. usesgpr:=false;
  758. for regcounter:=R_14 to R_31 do
  759. if regcounter in rg.usedbyproc then
  760. begin
  761. usesgpr:=true;
  762. firstreggpr:=regcounter;
  763. break;
  764. end;
  765. { save link register? }
  766. if (procinfo^.flags and pi_do_call)<>0 then
  767. begin
  768. { save return address... }
  769. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_LR));
  770. { ... in caller's rframe }
  771. reference_reset_base(href,STACK_POINTER_REG,4);
  772. list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
  773. a_reg_dealloc(list,R_0);
  774. end;
  775. if usesfpr or usesgpr then
  776. begin
  777. a_reg_alloc(list,R_11);
  778. { save end of fpr save area }
  779. list.concat(taicpu.op_reg_reg_const(A_ORI,R_11,STACK_POINTER_REG,0));
  780. end;
  781. { calculate the size of the locals }
  782. if usesgpr then
  783. inc(localsize,(ord(R_31)-ord(firstreggpr)+1)*4);
  784. if usesfpr then
  785. inc(localsize,(ord(R_F31)-ord(firstregfpu)+1)*8);
  786. { align to 16 bytes }
  787. if (localsize mod 16)<>0 then
  788. localsize:=(localsize and $fffffff0)+16;
  789. parastart:=localsize;
  790. inc(localsize,procinfo^.maxpushedparasize);
  791. { align to 16 bytes }
  792. if (localsize mod 16)<>0 then
  793. localsize:=(localsize and $fffffff0)+16;
  794. procinfo^.procdef.localst.address_fixup:=localsize-parastart;
  795. procinfo^.localsize:=localsize;
  796. reference_reset_base(href,R_1,-localsize);
  797. list.concat(taicpu.op_reg_ref(A_STWU,R_1,href));
  798. { no GOT pointer loaded yet }
  799. gotgot:=false;
  800. if usesfpr then
  801. begin
  802. { save floating-point registers }
  803. if (cs_create_pic in aktmoduleswitches) and not(usesgpr) then
  804. begin
  805. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+'_g'),0));
  806. gotgot:=true;
  807. end
  808. else
  809. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)),0));
  810. { compute end of gpr save area }
  811. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,-(ord(R_F31)-ord(firstregfpu)+1)*8));
  812. end;
  813. { save gprs and fetch GOT pointer }
  814. if usesgpr then
  815. begin
  816. {
  817. if cs_create_pic in aktmoduleswitches then
  818. begin
  819. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14)+'_g'),0));
  820. gotgot:=true;
  821. end
  822. else
  823. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14)),0))
  824. }
  825. reference_reset_base(href,R_11,-(ord(R_31)-ord(firstreggpr)+1)*4);
  826. list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
  827. end;
  828. if usesfpr or usesgpr then
  829. a_reg_dealloc(list,R_11);
  830. { PIC code support, }
  831. if cs_create_pic in aktmoduleswitches then
  832. begin
  833. { if we didn't get the GOT pointer till now, we've to calculate it now }
  834. if not(gotgot) then
  835. begin
  836. {!!!!!!!!!!!!!}
  837. end;
  838. a_reg_alloc(list,R_31);
  839. { place GOT ptr in r31 }
  840. list.concat(taicpu.op_reg_reg(A_MFSPR,R_31,R_LR));
  841. end;
  842. { save the CR if necessary ( !!! always done currently ) }
  843. { still need to find out where this has to be done for SystemV
  844. a_reg_alloc(list,R_0);
  845. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR);
  846. list.concat(taicpu.op_reg_ref(A_STW,scratch_register,
  847. new_reference(STACK_POINTER_REG,LA_CR)));
  848. a_reg_dealloc(list,R_0); }
  849. { now comes the AltiVec context save, not yet implemented !!! }
  850. end;
  851. procedure tcgppc.g_return_from_proc_sysv(list : taasmoutput;parasize : aword);
  852. var
  853. regcounter,firstregfpu,firstreggpr : TRegister;
  854. href : treference;
  855. usesfpr,usesgpr,genret : boolean;
  856. begin
  857. { release parameter registers }
  858. for regcounter := R_3 to R_10 do
  859. a_reg_dealloc(list,regcounter);
  860. { AltiVec context restore, not yet implemented !!! }
  861. usesfpr:=false;
  862. for regcounter:=R_F14 to R_F31 do
  863. if regcounter in rg.usedbyproc then
  864. begin
  865. usesfpr:=true;
  866. firstregfpu:=regcounter;
  867. break;
  868. end;
  869. usesgpr:=false;
  870. for regcounter:=R_14 to R_30 do
  871. if regcounter in rg.usedbyproc then
  872. begin
  873. usesgpr:=true;
  874. firstreggpr:=regcounter;
  875. break;
  876. end;
  877. { no return (blr) generated yet }
  878. genret:=true;
  879. if usesgpr then
  880. begin
  881. { address of gpr save area to r11 }
  882. if usesfpr then
  883. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_1,procinfo^.localsize-(ord(R_F31)-ord(firstregfpu)+1)*8))
  884. else
  885. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_1,procinfo^.localsize));
  886. { restore gprs }
  887. { at least for now we use LMW }
  888. {
  889. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_restgpr_14'),0));
  890. }
  891. reference_reset_base(href,R_11,-(ord(R_31)-ord(firstreggpr)+1)*4);
  892. list.concat(taicpu.op_reg_ref(A_LMW,firstreggpr,href));
  893. end;
  894. { restore fprs and return }
  895. if usesfpr then
  896. begin
  897. { address of fpr save area to r11 }
  898. list.concat(taicpu.op_reg_reg_const(A_ADDI,R_11,R_11,(ord(R_F31)-ord(firstregfpu)+1)*8));
  899. if (procinfo^.flags and pi_do_call)<>0 then
  900. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
  901. '_x'),0))
  902. else
  903. { leaf node => lr haven't to be restored }
  904. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
  905. '_l'),0));
  906. genret:=false;
  907. end;
  908. { if we didn't generate the return code, we've to do it now }
  909. if genret then
  910. begin
  911. { adjust r1 }
  912. reference_reset_base(href,R_1,procinfo^.localsize);
  913. list.concat(taicpu.op_reg_ref(A_STWU,R_1,href));
  914. { load link register? }
  915. if (procinfo^.flags and pi_do_call)<>0 then
  916. begin
  917. reference_reset_base(href,STACK_POINTER_REG,4);
  918. list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
  919. list.concat(taicpu.op_reg_reg(A_MTSPR,R_LR,R_0));
  920. end;
  921. list.concat(taicpu.op_none(A_BLR));
  922. end;
  923. end;
  924. procedure tcgppc.g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  925. { generated the entry code of a procedure/function. Note: localsize is the }
  926. { sum of the size necessary for local variables and the maximum possible }
  927. { combined size of ALL the parameters of a procedure called by the current }
  928. { one }
  929. var regcounter: TRegister;
  930. href : treference;
  931. begin
  932. if (localsize mod 8) <> 0 then internalerror(58991);
  933. { CR and LR only have to be saved in case they are modified by the current }
  934. { procedure, but currently this isn't checked, so save them always }
  935. { following is the entry code as described in "Altivec Programming }
  936. { Interface Manual", bar the saving of AltiVec registers }
  937. a_reg_alloc(list,STACK_POINTER_REG);
  938. a_reg_alloc(list,R_0);
  939. { allocate registers containing reg parameters }
  940. for regcounter := R_3 to R_10 do
  941. a_reg_alloc(list,regcounter);
  942. { save return address... }
  943. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_LR));
  944. { ... in caller's frame }
  945. reference_reset_base(href,STACK_POINTER_REG,8);
  946. list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
  947. a_reg_dealloc(list,R_0);
  948. { save floating-point registers }
  949. { !!! has to be optimized: only save registers that are used }
  950. list.concat(taicpu.op_sym_ofs(A_BL,objectlibrary.newasmsymbol('_savef14'),0));
  951. { save gprs in gpr save area }
  952. { !!! has to be optimized: only save registers that are used }
  953. reference_reset_base(href,STACK_POINTER_REG,-220);
  954. list.concat(taicpu.op_reg_ref(A_STMW,R_13,href));
  955. { save the CR if necessary ( !!! always done currently ) }
  956. a_reg_alloc(list,R_0);
  957. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR));
  958. reference_reset_base(href,stack_pointer_reg,LA_CR);
  959. list.concat(taicpu.op_reg_ref(A_STW,R_0,href));
  960. a_reg_dealloc(list,R_0);
  961. { save pointer to incoming arguments }
  962. list.concat(taicpu.op_reg_reg_const(A_ORI,R_31,STACK_POINTER_REG,0));
  963. a_reg_alloc(list,R_12);
  964. { 0 or 8 based on SP alignment }
  965. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  966. R_12,STACK_POINTER_REG,0,28,28));
  967. { add in stack length }
  968. list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
  969. -localsize));
  970. { establish new alignment }
  971. list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER_REG,STACK_POINTER_REG,R_12));
  972. a_reg_dealloc(list,R_12);
  973. { now comes the AltiVec context save, not yet implemented !!! }
  974. end;
  975. procedure tcgppc.g_restore_frame_pointer(list : taasmoutput);
  976. begin
  977. { no frame pointer on the PowerPC (maybe there is one in the SystemV ABI?)}
  978. end;
  979. procedure tcgppc.g_return_from_proc(list : taasmoutput;parasize : aword);
  980. begin
  981. case target_info.system of
  982. system_powerpc_macos:
  983. g_return_from_proc_mac(list,parasize);
  984. system_powerpc_linux:
  985. g_return_from_proc_sysv(list,parasize)
  986. else
  987. internalerror(2204001);
  988. end;
  989. end;
  990. procedure tcgppc.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
  991. var
  992. ref2, tmpref: treference;
  993. freereg: boolean;
  994. begin
  995. ref2 := ref;
  996. freereg := fixref(list,ref2);
  997. if assigned(ref2.symbol) then
  998. { add the symbol's value to the base of the reference, and if the }
  999. { reference doesn't have a base, create one }
  1000. begin
  1001. reference_reset(tmpref);
  1002. tmpref.offset := ref2.offset;
  1003. tmpref.symbol := ref2.symbol;
  1004. tmpref.symaddr := refs_ha;
  1005. if ref2.base <> R_NO then
  1006. begin
  1007. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,r,
  1008. ref2.base,tmpref));
  1009. if freereg then
  1010. begin
  1011. cg.free_scratch_reg(list,ref2.base);
  1012. freereg := false;
  1013. end;
  1014. end
  1015. else
  1016. list.concat(taicpu.op_reg_ref(A_LIS,r,tmpref));
  1017. tmpref.base := R_NO;
  1018. tmpref.symaddr := refs_l;
  1019. { can be folded with one of the next instructions by the }
  1020. { optimizer probably }
  1021. list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,r,tmpref));
  1022. end
  1023. else if ref2.offset <> 0 Then
  1024. if ref2.base <> R_NO then
  1025. a_op_const_reg_reg(list,OP_ADD,OS_32,ref2.offset,ref2.base,r)
  1026. { FixRef makes sure that "(ref.index <> R_NO) and (ref.offset <> 0)" never}
  1027. { occurs, so now only ref.offset has to be loaded }
  1028. else a_load_const_reg(list,OS_32,ref2.offset,r)
  1029. else if ref.index <> R_NO Then
  1030. list.concat(taicpu.op_reg_reg_reg(A_ADD,r,ref2.base,ref2.index))
  1031. else if (ref2.base <> R_NO) and
  1032. (r <> ref2.base) then
  1033. list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base));
  1034. if freereg then
  1035. cg.free_scratch_reg(list,ref2.base);
  1036. end;
  1037. { ************* concatcopy ************ }
  1038. procedure tcgppc.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
  1039. var
  1040. countreg: TRegister;
  1041. src, dst: TReference;
  1042. lab: tasmlabel;
  1043. count, count2: aword;
  1044. orgsrc, orgdst: boolean;
  1045. begin
  1046. {$ifdef extdebug}
  1047. if len > high(longint) then
  1048. internalerror(2002072704);
  1049. {$endif extdebug}
  1050. { make sure short loads are handled as optimally as possible }
  1051. if not loadref then
  1052. if (len <= 8) and
  1053. (byte(len) in [1,2,4,8]) then
  1054. begin
  1055. if len < 8 then
  1056. begin
  1057. a_load_ref_ref(list,int_cgsize(len),source,dest);
  1058. if delsource then
  1059. reference_release(exprasmlist,source);
  1060. end
  1061. else
  1062. begin
  1063. a_reg_alloc(list,R_F0);
  1064. a_loadfpu_ref_reg(list,OS_F64,source,R_F0);
  1065. if delsource then
  1066. reference_release(exprasmlist,source);
  1067. a_loadfpu_reg_ref(list,OS_F64,R_F0,dest);
  1068. a_reg_dealloc(list,R_F0);
  1069. end;
  1070. exit;
  1071. end;
  1072. reference_reset(src);
  1073. reference_reset(dst);
  1074. { load the address of source into src.base }
  1075. if loadref then
  1076. begin
  1077. src.base := get_scratch_reg_address(list);
  1078. a_load_ref_reg(list,OS_32,source,src.base);
  1079. orgsrc := false;
  1080. end
  1081. else if not issimpleref(source) or
  1082. ((source.index <> R_NO) and
  1083. ((source.offset + longint(len)) > high(smallint))) then
  1084. begin
  1085. src.base := get_scratch_reg_address(list);
  1086. a_loadaddr_ref_reg(list,source,src.base);
  1087. orgsrc := false;
  1088. end
  1089. else
  1090. begin
  1091. src := source;
  1092. orgsrc := true;
  1093. end;
  1094. if not orgsrc and delsource then
  1095. reference_release(exprasmlist,source);
  1096. { load the address of dest into dst.base }
  1097. if not issimpleref(dest) or
  1098. ((dest.index <> R_NO) and
  1099. ((dest.offset + longint(len)) > high(smallint))) then
  1100. begin
  1101. dst.base := get_scratch_reg_address(list);
  1102. a_loadaddr_ref_reg(list,dest,dst.base);
  1103. orgdst := false;
  1104. end
  1105. else
  1106. begin
  1107. dst := dest;
  1108. orgdst := true;
  1109. end;
  1110. count := len div 8;
  1111. if count > 4 then
  1112. { generate a loop }
  1113. begin
  1114. { the offsets are zero after the a_loadaddress_ref_reg and just }
  1115. { have to be set to 8. I put an Inc there so debugging may be }
  1116. { easier (should offset be different from zero here, it will be }
  1117. { easy to notice in the generated assembler }
  1118. inc(dst.offset,8);
  1119. inc(src.offset,8);
  1120. list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
  1121. list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
  1122. countreg := get_scratch_reg_int(list);
  1123. a_load_const_reg(list,OS_32,count,countreg);
  1124. { explicitely allocate R_0 since it can be used safely here }
  1125. { (for holding date that's being copied) }
  1126. a_reg_alloc(list,R_F0);
  1127. objectlibrary.getlabel(lab);
  1128. a_label(list, lab);
  1129. list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
  1130. list.concat(taicpu.op_reg_ref(A_LFDU,R_F0,src));
  1131. list.concat(taicpu.op_reg_ref(A_STFDU,R_F0,dst));
  1132. a_jmp(list,A_BC,C_NE,0,lab);
  1133. free_scratch_reg(list,countreg);
  1134. a_reg_dealloc(list,R_F0);
  1135. len := len mod 8;
  1136. end;
  1137. count := len div 8;
  1138. if count > 0 then
  1139. { unrolled loop }
  1140. begin
  1141. a_reg_alloc(list,R_F0);
  1142. for count2 := 1 to count do
  1143. begin
  1144. a_loadfpu_ref_reg(list,OS_F64,src,R_F0);
  1145. a_loadfpu_reg_ref(list,OS_F64,R_F0,dst);
  1146. inc(src.offset,8);
  1147. inc(dst.offset,8);
  1148. end;
  1149. a_reg_dealloc(list,R_F0);
  1150. len := len mod 8;
  1151. end;
  1152. if (len and 4) <> 0 then
  1153. begin
  1154. a_reg_alloc(list,R_0);
  1155. a_load_ref_reg(list,OS_32,src,R_0);
  1156. a_load_reg_ref(list,OS_32,R_0,dst);
  1157. inc(src.offset,4);
  1158. inc(dst.offset,4);
  1159. a_reg_dealloc(list,R_0);
  1160. end;
  1161. { copy the leftovers }
  1162. if (len and 2) <> 0 then
  1163. begin
  1164. a_reg_alloc(list,R_0);
  1165. a_load_ref_reg(list,OS_16,src,R_0);
  1166. a_load_reg_ref(list,OS_16,R_0,dst);
  1167. inc(src.offset,2);
  1168. inc(dst.offset,2);
  1169. a_reg_dealloc(list,R_0);
  1170. end;
  1171. if (len and 1) <> 0 then
  1172. begin
  1173. a_reg_alloc(list,R_0);
  1174. a_load_ref_reg(list,OS_8,src,R_0);
  1175. a_load_reg_ref(list,OS_8,R_0,dst);
  1176. a_reg_dealloc(list,R_0);
  1177. end;
  1178. if orgsrc then
  1179. begin
  1180. if delsource then
  1181. reference_release(exprasmlist,source);
  1182. end
  1183. else
  1184. free_scratch_reg(list,src.base);
  1185. if not orgdst then
  1186. free_scratch_reg(list,dst.base);
  1187. end;
  1188. procedure tcgppc.g_overflowcheck(list: taasmoutput; const p: tnode);
  1189. var
  1190. hl : tasmlabel;
  1191. begin
  1192. if not(cs_check_overflow in aktlocalswitches) then
  1193. exit;
  1194. objectlibrary.getlabel(hl);
  1195. if not ((p.resulttype.def.deftype=pointerdef) or
  1196. ((p.resulttype.def.deftype=orddef) and
  1197. (torddef(p.resulttype.def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
  1198. bool8bit,bool16bit,bool32bit]))) then
  1199. begin
  1200. list.concat(taicpu.op_reg(A_MCRXR,R_CR7));
  1201. a_jmp(list,A_BC,C_OV,7,hl)
  1202. end
  1203. else
  1204. a_jmp_cond(list,OC_AE,hl);
  1205. a_call_name(list,'FPC_OVERFLOW');
  1206. a_label(list,hl);
  1207. end;
  1208. {***************** This is private property, keep out! :) *****************}
  1209. procedure tcgppc.g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  1210. var
  1211. regcounter: TRegister;
  1212. href : treference;
  1213. begin
  1214. { release parameter registers }
  1215. for regcounter := R_3 to R_10 do
  1216. a_reg_dealloc(list,regcounter);
  1217. { AltiVec context restore, not yet implemented !!! }
  1218. { restore SP }
  1219. list.concat(taicpu.op_reg_reg_const(A_ORI,STACK_POINTER_REG,R_31,0));
  1220. { restore gprs }
  1221. reference_reset_base(href,STACK_POINTER_REG,-220);
  1222. list.concat(taicpu.op_reg_ref(A_LMW,R_13,href));
  1223. { restore return address ... }
  1224. reference_reset_base(href,STACK_POINTER_REG,8);
  1225. list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
  1226. { ... and return from _restf14 }
  1227. list.concat(taicpu.op_sym_ofs(A_B,objectlibrary.newasmsymbol('_restf14'),0));
  1228. end;
  1229. function tcgppc.issimpleref(const ref: treference): boolean;
  1230. begin
  1231. if (ref.base = R_NO) and
  1232. (ref.index <> R_NO) then
  1233. internalerror(200208101);
  1234. result :=
  1235. not(assigned(ref.symbol)) and
  1236. (((ref.index = R_NO) and
  1237. (ref.offset >= low(smallint)) and
  1238. (ref.offset <= high(smallint))) or
  1239. ((ref.index <> R_NO) and
  1240. (ref.offset = 0)));
  1241. end;
  1242. function tcgppc.fixref(list: taasmoutput; var ref: treference): boolean;
  1243. var
  1244. tmpreg: tregister;
  1245. begin
  1246. result := false;
  1247. if (ref.base <> R_NO) then
  1248. begin
  1249. if (ref.index <> R_NO) and
  1250. ((ref.offset <> 0) or assigned(ref.symbol)) then
  1251. begin
  1252. result := true;
  1253. tmpreg := cg.get_scratch_reg_int(list);
  1254. if not assigned(ref.symbol) and
  1255. (cardinal(ref.offset-low(smallint)) <=
  1256. high(smallint)-low(smallint)) then
  1257. begin
  1258. list.concat(taicpu.op_reg_reg_const(
  1259. A_ADDI,tmpreg,ref.base,ref.offset));
  1260. ref.offset := 0;
  1261. end
  1262. else
  1263. begin
  1264. list.concat(taicpu.op_reg_reg_reg(
  1265. A_ADD,tmpreg,ref.base,ref.index));
  1266. ref.index := R_NO;
  1267. end;
  1268. ref.base := tmpreg;
  1269. end
  1270. end
  1271. else
  1272. if ref.index <> R_NO then
  1273. internalerror(200208102);
  1274. end;
  1275. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  1276. { that's the case, we can use rlwinm to do an AND operation }
  1277. function tcgppc.get_rlwi_const(a: longint; var l1, l2: longint): boolean;
  1278. var
  1279. temp, testbit: longint;
  1280. compare: boolean;
  1281. begin
  1282. get_rlwi_const := false;
  1283. if (a = 0) or (a = $ffffffff) then
  1284. exit;
  1285. { start with the lowest bit }
  1286. testbit := 1;
  1287. { check its value }
  1288. compare := boolean(a and testbit);
  1289. { find out how long the run of bits with this value is }
  1290. { (it's impossible that all bits are 1 or 0, because in that case }
  1291. { this function wouldn't have been called) }
  1292. l1 := 31;
  1293. while (((a and testbit) <> 0) = compare) do
  1294. begin
  1295. testbit := testbit shl 1;
  1296. dec(l1);
  1297. end;
  1298. { check the length of the run of bits that comes next }
  1299. compare := not compare;
  1300. l2 := l1;
  1301. while (((a and testbit) <> 0) = compare) and
  1302. (l2 >= 0) do
  1303. begin
  1304. testbit := testbit shl 1;
  1305. dec(l2);
  1306. end;
  1307. { and finally the check whether the rest of the bits all have the }
  1308. { same value }
  1309. compare := not compare;
  1310. temp := l2;
  1311. if temp >= 0 then
  1312. if (a shr (31-temp)) <> ((-ord(compare)) shr (31-temp)) then
  1313. exit;
  1314. { we have done "not(not(compare))", so compare is back to its }
  1315. { initial value. If the lowest bit was 0, a is of the form }
  1316. { 00..11..00 and we need "rlwinm reg,reg,0,l2+1,l1", (+1 }
  1317. { because l2 now contains the position of the last zero of the }
  1318. { first run instead of that of the first 1) so switch l1 and l2 }
  1319. { in that case (we will generate "rlwinm reg,reg,0,l1,l2") }
  1320. if not compare then
  1321. begin
  1322. temp := l1;
  1323. l1 := l2+1;
  1324. l2 := temp;
  1325. end
  1326. else
  1327. { otherwise, l1 currently contains the position of the last }
  1328. { zero instead of that of the first 1 of the second run -> +1 }
  1329. inc(l1);
  1330. { the following is the same as "if l1 = -1 then l1 := 31;" }
  1331. l1 := l1 and 31;
  1332. l2 := l2 and 31;
  1333. get_rlwi_const := true;
  1334. end;
  1335. procedure tcgppc.a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  1336. ref: treference);
  1337. var
  1338. tmpreg: tregister;
  1339. tmpref: treference;
  1340. begin
  1341. if assigned(ref.symbol) then
  1342. begin
  1343. tmpreg := get_scratch_reg_address(list);
  1344. reference_reset(tmpref);
  1345. tmpref.symbol := ref.symbol;
  1346. tmpref.symaddr := refs_ha;
  1347. if ref.base <> R_NO then
  1348. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
  1349. ref.base,tmpref))
  1350. else
  1351. list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,tmpref));
  1352. ref.base := tmpreg;
  1353. ref.symaddr := refs_l;
  1354. end;
  1355. list.concat(taicpu.op_reg_ref(op,reg,ref));
  1356. if assigned(ref.symbol) then
  1357. free_scratch_reg(list,tmpreg);
  1358. end;
  1359. procedure tcgppc.a_jmp(list: taasmoutput; op: tasmop; c: tasmcondflag;
  1360. crval: longint; l: tasmlabel);
  1361. var
  1362. p: taicpu;
  1363. begin
  1364. p := taicpu.op_sym(op,objectlibrary.newasmsymbol(l.name));
  1365. if op <> A_B then
  1366. create_cond_norm(c,crval,p.condition);
  1367. p.is_jmp := true;
  1368. list.concat(p)
  1369. end;
  1370. procedure tcg64fppc.a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);
  1371. begin
  1372. a_op64_reg_reg_reg(list,op,regsrc,regdst,regdst);
  1373. end;
  1374. procedure tcg64fppc.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);
  1375. begin
  1376. a_op64_const_reg_reg(list,op,value,reg,reg);
  1377. end;
  1378. procedure tcg64fppc.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
  1379. begin
  1380. case op of
  1381. OP_AND,OP_OR,OP_XOR:
  1382. begin
  1383. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reglo,regsrc2.reglo,regdst.reglo);
  1384. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reghi,regsrc2.reghi,regdst.reghi);
  1385. end;
  1386. OP_ADD:
  1387. begin
  1388. list.concat(taicpu.op_reg_reg_reg(A_ADDC,regdst.reglo,regsrc1.reglo,regsrc2.reglo));
  1389. list.concat(taicpu.op_reg_reg_reg(A_ADDE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
  1390. end;
  1391. OP_SUB:
  1392. begin
  1393. list.concat(taicpu.op_reg_reg_reg(A_SUBC,regdst.reglo,regsrc2.reglo,regsrc1.reglo));
  1394. list.concat(taicpu.op_reg_reg_reg(A_SUBFE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
  1395. end;
  1396. else
  1397. internalerror(2002072801);
  1398. end;
  1399. end;
  1400. procedure tcg64fppc.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);
  1401. const
  1402. ops: array[boolean,1..3] of tasmop = ((A_ADDIC,A_ADDC,A_ADDZE),
  1403. (A_SUBIC,A_SUBC,A_ADDME));
  1404. var
  1405. tmpreg: tregister;
  1406. tmpreg64: tregister64;
  1407. issub: boolean;
  1408. begin
  1409. case op of
  1410. OP_AND,OP_OR,OP_XOR:
  1411. begin
  1412. cg.a_op_const_reg_reg(list,op,OS_32,cardinal(value),regsrc.reglo,regdst.reglo);
  1413. cg.a_op_const_reg_reg(list,op,OS_32,value shr 32,regsrc.reghi,
  1414. regdst.reghi);
  1415. end;
  1416. OP_ADD, OP_SUB:
  1417. begin
  1418. if (longint(value) <> 0) then
  1419. begin
  1420. issub := op = OP_SUB;
  1421. if (longint(value)-ord(issub) >= -32768) and
  1422. (longint(value)-ord(issub) <= 32767) then
  1423. begin
  1424. list.concat(taicpu.op_reg_reg_const(ops[issub,1],
  1425. regdst.reglo,regsrc.reglo,longint(value)));
  1426. list.concat(taicpu.op_reg_reg(ops[issub,3],
  1427. regdst.reghi,regsrc.reghi));
  1428. end
  1429. else if ((value shr 32) = 0) then
  1430. begin
  1431. tmpreg := cg.get_scratch_reg_int(list);
  1432. cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
  1433. list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
  1434. regdst.reglo,regsrc.reglo,tmpreg));
  1435. cg.free_scratch_reg(list,tmpreg);
  1436. list.concat(taicpu.op_reg_reg(ops[issub,3],
  1437. regdst.reghi,regsrc.reghi));
  1438. end
  1439. else
  1440. begin
  1441. tmpreg64.reglo := cg.get_scratch_reg_int(list);
  1442. tmpreg64.reghi := cg.get_scratch_reg_int(list);
  1443. a_load64_const_reg(list,value,tmpreg64);
  1444. a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
  1445. cg.free_scratch_reg(list,tmpreg64.reghi);
  1446. cg.free_scratch_reg(list,tmpreg64.reglo);
  1447. end
  1448. end
  1449. else
  1450. begin
  1451. cg.a_load_reg_reg(list,OS_INT,regsrc.reglo,regdst.reglo);
  1452. cg.a_op_const_reg_reg(list,op,OS_32,value shr 32,regsrc.reghi,
  1453. regdst.reghi);
  1454. end;
  1455. end;
  1456. else
  1457. internalerror(2002072802);
  1458. end;
  1459. end;
  1460. begin
  1461. cg := tcgppc.create;
  1462. cg64 :=tcg64fppc.create;
  1463. end.
  1464. {
  1465. $Log$
  1466. Revision 1.40 2002-08-11 14:32:32 peter
  1467. * renamed current_library to objectlibrary
  1468. Revision 1.39 2002/08/11 13:24:18 peter
  1469. * saving of asmsymbols in ppu supported
  1470. * asmsymbollist global is removed and moved into a new class
  1471. tasmlibrarydata that will hold the info of a .a file which
  1472. corresponds with a single module. Added librarydata to tmodule
  1473. to keep the library info stored for the module. In the future the
  1474. objectfiles will also be stored to the tasmlibrarydata class
  1475. * all getlabel/newasmsymbol and friends are moved to the new class
  1476. Revision 1.38 2002/08/11 11:39:31 jonas
  1477. + powerpc-specific genlinearlist
  1478. Revision 1.37 2002/08/10 17:15:31 jonas
  1479. * various fixes and optimizations
  1480. Revision 1.36 2002/08/06 20:55:23 florian
  1481. * first part of ppc calling conventions fix
  1482. Revision 1.35 2002/08/06 07:12:05 jonas
  1483. * fixed bug in g_flags2reg()
  1484. * and yet more constant operation fixes :)
  1485. Revision 1.34 2002/08/05 08:58:53 jonas
  1486. * fixed compilation problems
  1487. Revision 1.33 2002/08/04 12:57:55 jonas
  1488. * more misc. fixes, mostly constant-related
  1489. Revision 1.32 2002/08/02 11:10:42 jonas
  1490. * some misc constant fixes
  1491. Revision 1.31 2002/07/30 20:50:44 florian
  1492. * the code generator knows now if parameters are in registers
  1493. Revision 1.30 2002/07/29 21:23:44 florian
  1494. * more fixes for the ppc
  1495. + wrappers for the tcnvnode.first_* stuff introduced
  1496. Revision 1.29 2002/07/28 21:38:30 florian
  1497. - removed debug code which was commited by accident
  1498. Revision 1.28 2002/07/28 21:34:31 florian
  1499. * more powerpc fixes
  1500. + dummy tcgvecnode
  1501. Revision 1.27 2002/07/28 16:01:59 jonas
  1502. + tcg64fppc.a_op64_const_reg_reg() and tcg64fppc.a_op64_reg_reg_reg()
  1503. * several fixes, most notably in a_load_reg_reg(): it didn't do any
  1504. conversion from smaller to larger sizes or vice versa
  1505. * some small optimizations
  1506. Revision 1.26 2002/07/27 19:59:29 jonas
  1507. * fixed a_loadaddr_ref_reg()
  1508. * fixed g_flags2reg()
  1509. * optimized g_concatcopy()
  1510. Revision 1.25 2002/07/26 21:15:45 florian
  1511. * rewrote the system handling
  1512. Revision 1.24 2002/07/21 17:00:23 jonas
  1513. * make sure we use rlwi* when possible instead of andi.
  1514. Revision 1.23 2002/07/11 14:41:34 florian
  1515. * start of the new generic parameter handling
  1516. Revision 1.22 2002/07/11 07:38:28 jonas
  1517. + tcg64fpc implementation (only a_op64_reg_reg and a_op64_const_reg for
  1518. now)
  1519. * fixed and improved tcgppc.a_load_const_reg
  1520. * improved tcgppc.a_op_const_reg, tcgppc.a_cmp_const_reg_label
  1521. * A_CMP* -> A_CMPW* (this means that 32bit compares should be done)
  1522. Revision 1.21 2002/07/09 19:45:01 jonas
  1523. * unarynminus and shlshr node fixed for 32bit and smaller ordinals
  1524. * small fixes in the assembler writer
  1525. * changed scratch registers, because they were used by the linker (r11
  1526. and r12) and by the abi under linux (r31)
  1527. Revision 1.20 2002/07/07 09:44:31 florian
  1528. * powerpc target fixed, very simple units can be compiled
  1529. Revision 1.19 2002/05/20 13:30:41 carl
  1530. * bugfix of hdisponen (base must be set, not index)
  1531. * more portability fixes
  1532. Revision 1.18 2002/05/18 13:34:26 peter
  1533. * readded missing revisions
  1534. Revision 1.17 2002/05/16 19:46:53 carl
  1535. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1536. + try to fix temp allocation (still in ifdef)
  1537. + generic constructor calls
  1538. + start of tassembler / tmodulebase class cleanup
  1539. Revision 1.14 2002/05/13 19:52:46 peter
  1540. * a ppcppc can be build again
  1541. Revision 1.13 2002/04/20 21:41:51 carl
  1542. * renamed some constants
  1543. Revision 1.12 2002/04/06 18:13:01 jonas
  1544. * several powerpc-related additions and fixes
  1545. Revision 1.11 2002/01/02 14:53:04 jonas
  1546. * fixed small bug in a_jmp_flags
  1547. }