cgcpu.pas 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772
  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. symtype,
  23. cgbase,cgobj,
  24. aasmbase,aasmcpu,aasmtai,
  25. cpubase,cpuinfo,node,cg64f32,rgcpu;
  26. type
  27. tcgppc = class(tcg)
  28. procedure init_register_allocators;override;
  29. procedure done_register_allocators;override;
  30. procedure ungetreference(list:Taasmoutput;const r:Treference);override;
  31. { passing parameters, per default the parameter is pushed }
  32. { nr gives the number of the parameter (enumerated from }
  33. { left to right), this allows to move the parameter to }
  34. { register, if the cpu supports register calling }
  35. { conventions }
  36. procedure a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);override;
  37. procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);override;
  38. procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);override;
  39. procedure a_call_name(list : taasmoutput;const s : string);override;
  40. procedure a_call_reg(list : taasmoutput;reg: tregister); override;
  41. procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister); override;
  42. procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
  43. procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  44. size: tcgsize; a: aword; src, dst: tregister); override;
  45. procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  46. size: tcgsize; src1, src2, dst: tregister); override;
  47. { move instructions }
  48. procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aword;reg : tregister);override;
  49. procedure a_load_reg_ref(list : taasmoutput; fromsize, tosize: tcgsize; reg : tregister;const ref : treference);override;
  50. procedure a_load_ref_reg(list : taasmoutput; fromsize, tosize : tcgsize;const Ref : treference;reg : tregister);override;
  51. procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
  52. { fpu move instructions }
  53. procedure a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister); override;
  54. procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
  55. procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
  56. { comparison operations }
  57. procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  58. l : tasmlabel);override;
  59. procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
  60. procedure a_jmp_always(list : taasmoutput;l: tasmlabel); override;
  61. procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
  62. procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
  63. procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
  64. procedure g_return_from_proc(list : taasmoutput;parasize : aword); override;
  65. procedure g_restore_frame_pointer(list : taasmoutput);override;
  66. procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
  67. procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);override;
  68. procedure g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef); override;
  69. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  70. { that's the case, we can use rlwinm to do an AND operation }
  71. function get_rlwi_const(a: aword; var l1, l2: longint): boolean;
  72. procedure g_save_standard_registers(list:Taasmoutput);override;
  73. procedure g_restore_standard_registers(list:Taasmoutput);override;
  74. procedure g_save_all_registers(list : taasmoutput);override;
  75. procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);override;
  76. procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  77. private
  78. (* NOT IN USE: *)
  79. procedure g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  80. (* NOT IN USE: *)
  81. procedure g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  82. { Make sure ref is a valid reference for the PowerPC and sets the }
  83. { base to the value of the index if (base = R_NO). }
  84. { Returns true if the reference contained a base, index and an }
  85. { offset or symbol, in which case the base will have been changed }
  86. { to a tempreg (which has to be freed by the caller) containing }
  87. { the sum of part of the original reference }
  88. function fixref(list: taasmoutput; var ref: treference): boolean;
  89. { returns whether a reference can be used immediately in a powerpc }
  90. { instruction }
  91. function issimpleref(const ref: treference): boolean;
  92. { contains the common code of a_load_reg_ref and a_load_ref_reg }
  93. procedure a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  94. ref: treference);
  95. { creates the correct branch instruction for a given combination }
  96. { of asmcondflags and destination addressing mode }
  97. procedure a_jmp(list: taasmoutput; op: tasmop;
  98. c: tasmcondflag; crval: longint; l: tasmlabel);
  99. function save_regs(list : taasmoutput):longint;
  100. procedure restore_regs(list : taasmoutput);
  101. end;
  102. tcg64fppc = class(tcg64f32)
  103. procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
  104. procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);override;
  105. procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);override;
  106. procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);override;
  107. end;
  108. const
  109. TOpCG2AsmOpConstLo: Array[topcg] of TAsmOp = (A_NONE,A_ADDI,A_ANDI_,A_DIVWU,
  110. A_DIVW,A_MULLW, A_MULLW, A_NONE,A_NONE,A_ORI,
  111. A_SRAWI,A_SLWI,A_SRWI,A_SUBI,A_XORI);
  112. TOpCG2AsmOpConstHi: Array[topcg] of TAsmOp = (A_NONE,A_ADDIS,A_ANDIS_,
  113. A_DIVWU,A_DIVW, A_MULLW,A_MULLW,A_NONE,A_NONE,
  114. A_ORIS,A_NONE, A_NONE,A_NONE,A_SUBIS,A_XORIS);
  115. TOpCmp2AsmCond: Array[topcmp] of TAsmCondFlag = (C_NONE,C_EQ,C_GT,
  116. C_LT,C_GE,C_LE,C_NE,C_LE,C_LT,C_GE,C_GT);
  117. implementation
  118. uses
  119. globtype,globals,verbose,systems,cutils,
  120. symconst,symdef,symsym,
  121. rgobj,tgobj,cpupi,procinfo,paramgr;
  122. procedure tcgppc.init_register_allocators;
  123. begin
  124. inherited init_register_allocators;
  125. rg[R_INTREGISTER]:=trgcpu.create(R_INTREGISTER,R_SUBWHOLE,
  126. [RS_R3,RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,
  127. RS_R9,RS_R10,RS_R11,RS_R12,RS_R31,RS_R30,RS_R29,
  128. RS_R28,RS_R27,RS_R26,RS_R25,RS_R24,RS_R23,RS_R22,
  129. RS_R21,RS_R20,RS_R19,RS_R18,RS_R17,RS_R16,RS_R15,
  130. RS_R14,RS_R13],first_int_imreg,[]);
  131. case target_info.abi of
  132. abi_powerpc_aix:
  133. rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
  134. [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,RS_F9,
  135. RS_F10,RS_F11,RS_F12,RS_F13,RS_F31,RS_F30,RS_F29,RS_F28,RS_F27,
  136. RS_F26,RS_F25,RS_F24,RS_F23,RS_F22,RS_F21,RS_F20,RS_F19,RS_F18,
  137. RS_F17,RS_F16,RS_F15,RS_F14],first_fpu_imreg,[]);
  138. abi_powerpc_sysv:
  139. rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
  140. [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,RS_F9,
  141. RS_F31,RS_F30,RS_F29,RS_F28,RS_F27,RS_F26,RS_F25,RS_F24,RS_F23,
  142. RS_F22,RS_F21,RS_F20,RS_F19,RS_F18,RS_F17,RS_F16,RS_F15,RS_F14,
  143. RS_F13,RS_F12,RS_F11,RS_F10],first_fpu_imreg,[]);
  144. else
  145. internalerror(2003122903);
  146. end;
  147. {$warning FIX ME}
  148. rg[R_MMREGISTER]:=trgcpu.create(R_MMREGISTER,R_SUBNONE,
  149. [RS_M0,RS_M1,RS_M2],first_mm_imreg,[]);
  150. end;
  151. procedure tcgppc.done_register_allocators;
  152. begin
  153. rg[R_INTREGISTER].free;
  154. rg[R_FPUREGISTER].free;
  155. rg[R_MMREGISTER].free;
  156. inherited done_register_allocators;
  157. end;
  158. procedure tcgppc.ungetreference(list:Taasmoutput;const r:Treference);
  159. begin
  160. if r.base<>NR_NO then
  161. ungetregister(list,r.base);
  162. if r.index<>NR_NO then
  163. ungetregister(list,r.index);
  164. end;
  165. procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aword;const locpara : tparalocation);
  166. var
  167. ref: treference;
  168. begin
  169. case locpara.loc of
  170. LOC_REGISTER,LOC_CREGISTER:
  171. a_load_const_reg(list,size,a,locpara.register);
  172. LOC_REFERENCE:
  173. begin
  174. reference_reset(ref);
  175. ref.base:=locpara.reference.index;
  176. ref.offset:=locpara.reference.offset;
  177. a_load_const_ref(list,size,a,ref);
  178. end;
  179. else
  180. internalerror(2002081101);
  181. end;
  182. end;
  183. procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const locpara : tparalocation);
  184. var
  185. ref: treference;
  186. tmpreg: tregister;
  187. begin
  188. case locpara.loc of
  189. LOC_REGISTER,LOC_CREGISTER:
  190. a_load_ref_reg(list,size,size,r,locpara.register);
  191. LOC_REFERENCE:
  192. begin
  193. reference_reset(ref);
  194. ref.base:=locpara.reference.index;
  195. ref.offset:=locpara.reference.offset;
  196. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  197. a_load_ref_reg(list,size,size,r,tmpreg);
  198. a_load_reg_ref(list,size,size,tmpreg,ref);
  199. rg[R_INTREGISTER].ungetregister(list,tmpreg);
  200. end;
  201. LOC_FPUREGISTER,LOC_CFPUREGISTER:
  202. case size of
  203. OS_F32, OS_F64:
  204. a_loadfpu_ref_reg(list,size,r,locpara.register);
  205. else
  206. internalerror(2002072801);
  207. end;
  208. else
  209. internalerror(2002081103);
  210. end;
  211. end;
  212. procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const locpara : tparalocation);
  213. var
  214. ref: treference;
  215. tmpreg: tregister;
  216. begin
  217. case locpara.loc of
  218. LOC_REGISTER,LOC_CREGISTER:
  219. a_loadaddr_ref_reg(list,r,locpara.register);
  220. LOC_REFERENCE:
  221. begin
  222. reference_reset(ref);
  223. ref.base := locpara.reference.index;
  224. ref.offset := locpara.reference.offset;
  225. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  226. a_loadaddr_ref_reg(list,r,tmpreg);
  227. a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
  228. rg[R_INTREGISTER].ungetregister(list,tmpreg);
  229. end;
  230. else
  231. internalerror(2002080701);
  232. end;
  233. end;
  234. { calling a procedure by name }
  235. procedure tcgppc.a_call_name(list : taasmoutput;const s : string);
  236. var
  237. href : treference;
  238. begin
  239. { MacOS: The linker on MacOS (PPCLink) inserts a call to glue code,
  240. if it is a cross-TOC call. If so, it also replaces the NOP
  241. with some restore code.}
  242. list.concat(taicpu.op_sym(A_BL,objectlibrary.newasmsymbol(s)));
  243. if target_info.system=system_powerpc_macos then
  244. list.concat(taicpu.op_none(A_NOP));
  245. if not(pi_do_call in current_procinfo.flags) then
  246. internalerror(2003060703);
  247. end;
  248. { calling a procedure by address }
  249. procedure tcgppc.a_call_reg(list : taasmoutput;reg: tregister);
  250. var
  251. tmpreg : tregister;
  252. tmpref : treference;
  253. begin
  254. if target_info.system=system_powerpc_macos then
  255. begin
  256. {Generate instruction to load the procedure address from
  257. the transition vector.}
  258. //TODO: Support cross-TOC calls.
  259. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  260. reference_reset(tmpref);
  261. tmpref.offset := 0;
  262. //tmpref.symaddr := refs_full;
  263. tmpref.base:= reg;
  264. list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
  265. list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
  266. rg[R_INTREGISTER].ungetregister(list,tmpreg);
  267. end
  268. else
  269. list.concat(taicpu.op_reg(A_MTCTR,reg));
  270. list.concat(taicpu.op_none(A_BCTRL));
  271. //if target_info.system=system_powerpc_macos then
  272. // //NOP is not needed here.
  273. // list.concat(taicpu.op_none(A_NOP));
  274. if not(pi_do_call in current_procinfo.flags) then
  275. internalerror(2003060704);
  276. //list.concat(tai_comment.create(strpnew('***** a_call_reg')));
  277. end;
  278. {********************** load instructions ********************}
  279. procedure tcgppc.a_load_const_reg(list : taasmoutput; size: TCGSize; a : aword; reg : TRegister);
  280. begin
  281. if not(size in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
  282. internalerror(2002090902);
  283. if (longint(a) >= low(smallint)) and
  284. (longint(a) <= high(smallint)) then
  285. list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a)))
  286. else if ((a and $ffff) <> 0) then
  287. begin
  288. list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a and $ffff)));
  289. if ((a shr 16) <> 0) or
  290. (smallint(a and $ffff) < 0) then
  291. list.concat(taicpu.op_reg_reg_const(A_ADDIS,reg,reg,
  292. smallint((a shr 16)+ord(smallint(a and $ffff) < 0))))
  293. end
  294. else
  295. list.concat(taicpu.op_reg_const(A_LIS,reg,smallint(a shr 16)));
  296. end;
  297. procedure tcgppc.a_load_reg_ref(list : taasmoutput; fromsize, tosize: TCGSize; reg : tregister;const ref : treference);
  298. const
  299. StoreInstr: Array[OS_8..OS_32,boolean, boolean] of TAsmOp =
  300. { indexed? updating?}
  301. (((A_STB,A_STBU),(A_STBX,A_STBUX)),
  302. ((A_STH,A_STHU),(A_STHX,A_STHUX)),
  303. ((A_STW,A_STWU),(A_STWX,A_STWUX)));
  304. var
  305. op: TAsmOp;
  306. ref2: TReference;
  307. freereg: boolean;
  308. begin
  309. ref2 := ref;
  310. freereg := fixref(list,ref2);
  311. if tosize in [OS_S8..OS_S16] then
  312. { storing is the same for signed and unsigned values }
  313. tosize := tcgsize(ord(tosize)-(ord(OS_S8)-ord(OS_8)));
  314. { 64 bit stuff should be handled separately }
  315. if tosize in [OS_64,OS_S64] then
  316. internalerror(200109236);
  317. op := storeinstr[tcgsize2unsigned[tosize],ref2.index<>NR_NO,false];
  318. a_load_store(list,op,reg,ref2);
  319. if freereg then
  320. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  321. End;
  322. procedure tcgppc.a_load_ref_reg(list : taasmoutput; fromsize,tosize : tcgsize;const ref: treference;reg : tregister);
  323. const
  324. LoadInstr: Array[OS_8..OS_S32,boolean, boolean] of TAsmOp =
  325. { indexed? updating?}
  326. (((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  327. ((A_LHZ,A_LHZU),(A_LHZX,A_LHZUX)),
  328. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)),
  329. { 64bit stuff should be handled separately }
  330. ((A_NONE,A_NONE),(A_NONE,A_NONE)),
  331. { there's no load-byte-with-sign-extend :( }
  332. ((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
  333. ((A_LHA,A_LHAU),(A_LHAX,A_LHAUX)),
  334. ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)));
  335. var
  336. op: tasmop;
  337. tmpreg: tregister;
  338. ref2, tmpref: treference;
  339. freereg: boolean;
  340. begin
  341. { TODO: optimize/take into consideration fromsize/tosize. Will }
  342. { probably only matter for OS_S8 loads though }
  343. if not(fromsize in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
  344. internalerror(2002090902);
  345. ref2 := ref;
  346. freereg := fixref(list,ref2);
  347. { the caller is expected to have adjusted the reference already }
  348. { in this case }
  349. if (TCGSize2Size[fromsize] >= TCGSize2Size[tosize]) then
  350. fromsize := tosize;
  351. op := loadinstr[fromsize,ref2.index<>NR_NO,false];
  352. a_load_store(list,op,reg,ref2);
  353. if freereg then
  354. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  355. { sign extend shortint if necessary, since there is no }
  356. { load instruction that does that automatically (JM) }
  357. if fromsize = OS_S8 then
  358. list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
  359. end;
  360. procedure tcgppc.a_load_reg_reg(list : taasmoutput;fromsize, tosize : tcgsize;reg1,reg2 : tregister);
  361. var
  362. instr: taicpu;
  363. begin
  364. case tosize of
  365. OS_8:
  366. instr := taicpu.op_reg_reg_const_const_const(A_RLWINM,
  367. reg2,reg1,0,31-8+1,31);
  368. OS_S8:
  369. instr := taicpu.op_reg_reg(A_EXTSB,reg2,reg1);
  370. OS_16:
  371. instr := taicpu.op_reg_reg_const_const_const(A_RLWINM,
  372. reg2,reg1,0,31-16+1,31);
  373. OS_S16:
  374. instr := taicpu.op_reg_reg(A_EXTSH,reg2,reg1);
  375. OS_32,OS_S32:
  376. instr := taicpu.op_reg_reg(A_MR,reg2,reg1);
  377. else internalerror(2002090901);
  378. end;
  379. list.concat(instr);
  380. rg[R_INTREGISTER].add_move_instruction(instr);
  381. end;
  382. procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister);
  383. begin
  384. list.concat(taicpu.op_reg_reg(A_FMR,reg2,reg1));
  385. end;
  386. procedure tcgppc.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister);
  387. const
  388. FpuLoadInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
  389. { indexed? updating?}
  390. (((A_LFS,A_LFSU),(A_LFSX,A_LFSUX)),
  391. ((A_LFD,A_LFDU),(A_LFDX,A_LFDUX)));
  392. var
  393. op: tasmop;
  394. ref2: treference;
  395. freereg: boolean;
  396. begin
  397. { several functions call this procedure with OS_32 or OS_64 }
  398. { so this makes life easier (FK) }
  399. case size of
  400. OS_32,OS_F32:
  401. size:=OS_F32;
  402. OS_64,OS_F64,OS_C64:
  403. size:=OS_F64;
  404. else
  405. internalerror(200201121);
  406. end;
  407. ref2 := ref;
  408. freereg := fixref(list,ref2);
  409. op := fpuloadinstr[size,ref2.index <> NR_NO,false];
  410. a_load_store(list,op,reg,ref2);
  411. if freereg then
  412. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  413. end;
  414. procedure tcgppc.a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference);
  415. const
  416. FpuStoreInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
  417. { indexed? updating?}
  418. (((A_STFS,A_STFSU),(A_STFSX,A_STFSUX)),
  419. ((A_STFD,A_STFDU),(A_STFDX,A_STFDUX)));
  420. var
  421. op: tasmop;
  422. ref2: treference;
  423. freereg: boolean;
  424. begin
  425. if not(size in [OS_F32,OS_F64]) then
  426. internalerror(200201122);
  427. ref2 := ref;
  428. freereg := fixref(list,ref2);
  429. op := fpustoreinstr[size,ref2.index <> NR_NO,false];
  430. a_load_store(list,op,reg,ref2);
  431. if freereg then
  432. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  433. end;
  434. procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: AWord; reg: TRegister);
  435. begin
  436. a_op_const_reg_reg(list,op,size,a,reg,reg);
  437. end;
  438. procedure tcgppc.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
  439. begin
  440. a_op_reg_reg_reg(list,op,size,src,dst,dst);
  441. end;
  442. procedure tcgppc.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
  443. size: tcgsize; a: aword; src, dst: tregister);
  444. var
  445. l1,l2: longint;
  446. oplo, ophi: tasmop;
  447. scratchreg: tregister;
  448. useReg, gotrlwi: boolean;
  449. procedure do_lo_hi;
  450. begin
  451. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
  452. list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,word(a shr 16)));
  453. end;
  454. begin
  455. if op = OP_SUB then
  456. begin
  457. {$ifopt q+}
  458. {$q-}
  459. {$define overflowon}
  460. {$endif}
  461. a_op_const_reg_reg(list,OP_ADD,size,aword(-longint(a)),src,dst);
  462. {$ifdef overflowon}
  463. {$q+}
  464. {$undef overflowon}
  465. {$endif}
  466. exit;
  467. end;
  468. ophi := TOpCG2AsmOpConstHi[op];
  469. oplo := TOpCG2AsmOpConstLo[op];
  470. gotrlwi := get_rlwi_const(a,l1,l2);
  471. if (op in [OP_AND,OP_OR,OP_XOR]) then
  472. begin
  473. if (a = 0) then
  474. begin
  475. if op = OP_AND then
  476. list.concat(taicpu.op_reg_const(A_LI,dst,0))
  477. else
  478. a_load_reg_reg(list,size,size,src,dst);
  479. exit;
  480. end
  481. else if (a = high(aword)) then
  482. begin
  483. case op of
  484. OP_OR:
  485. list.concat(taicpu.op_reg_const(A_LI,dst,-1));
  486. OP_XOR:
  487. list.concat(taicpu.op_reg_reg(A_NOT,dst,src));
  488. OP_AND:
  489. a_load_reg_reg(list,size,size,src,dst);
  490. end;
  491. exit;
  492. end
  493. else if (a <= high(word)) and
  494. ((op <> OP_AND) or
  495. not gotrlwi) then
  496. begin
  497. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
  498. exit;
  499. end;
  500. { all basic constant instructions also have a shifted form that }
  501. { works only on the highest 16bits, so if lo(a) is 0, we can }
  502. { use that one }
  503. if (word(a) = 0) and
  504. (not(op = OP_AND) or
  505. not gotrlwi) then
  506. begin
  507. list.concat(taicpu.op_reg_reg_const(ophi,dst,src,word(a shr 16)));
  508. exit;
  509. end;
  510. end
  511. else if (op = OP_ADD) then
  512. if a = 0 then
  513. exit
  514. else if (longint(a) >= low(smallint)) and
  515. (longint(a) <= high(smallint)) then
  516. begin
  517. list.concat(taicpu.op_reg_reg_const(A_ADDI,dst,src,smallint(a)));
  518. exit;
  519. end;
  520. { otherwise, the instructions we can generate depend on the }
  521. { operation }
  522. useReg := false;
  523. case op of
  524. OP_DIV,OP_IDIV:
  525. if (a = 0) then
  526. internalerror(200208103)
  527. else if (a = 1) then
  528. begin
  529. a_load_reg_reg(list,OS_INT,OS_INT,src,dst);
  530. exit
  531. end
  532. else if ispowerof2(a,l1) then
  533. begin
  534. case op of
  535. OP_DIV:
  536. list.concat(taicpu.op_reg_reg_const(A_SRWI,dst,src,l1));
  537. OP_IDIV:
  538. begin
  539. list.concat(taicpu.op_reg_reg_const(A_SRAWI,dst,src,l1));
  540. list.concat(taicpu.op_reg_reg(A_ADDZE,dst,dst));
  541. end;
  542. end;
  543. exit;
  544. end
  545. else
  546. usereg := true;
  547. OP_IMUL, OP_MUL:
  548. if (a = 0) then
  549. begin
  550. list.concat(taicpu.op_reg_const(A_LI,dst,0));
  551. exit
  552. end
  553. else if (a = 1) then
  554. begin
  555. a_load_reg_reg(list,OS_INT,OS_INT,src,dst);
  556. exit
  557. end
  558. else if ispowerof2(a,l1) then
  559. list.concat(taicpu.op_reg_reg_const(A_SLWI,dst,src,l1))
  560. else if (longint(a) >= low(smallint)) and
  561. (longint(a) <= high(smallint)) then
  562. list.concat(taicpu.op_reg_reg_const(A_MULLI,dst,src,smallint(a)))
  563. else
  564. usereg := true;
  565. OP_ADD:
  566. begin
  567. list.concat(taicpu.op_reg_reg_const(oplo,dst,src,smallint(a)));
  568. list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,
  569. smallint((a shr 16) + ord(smallint(a) < 0))));
  570. end;
  571. OP_OR:
  572. { try to use rlwimi }
  573. if gotrlwi and
  574. (src = dst) then
  575. begin
  576. scratchreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  577. list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
  578. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
  579. scratchreg,0,l1,l2));
  580. rg[R_INTREGISTER].ungetregister(list,scratchreg);
  581. end
  582. else
  583. do_lo_hi;
  584. OP_AND:
  585. { try to use rlwinm }
  586. if gotrlwi then
  587. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,dst,
  588. src,0,l1,l2))
  589. else
  590. useReg := true;
  591. OP_XOR:
  592. do_lo_hi;
  593. OP_SHL,OP_SHR,OP_SAR:
  594. begin
  595. if (a and 31) <> 0 Then
  596. list.concat(taicpu.op_reg_reg_const(
  597. TOpCG2AsmOpConstLo[Op],dst,src,a and 31))
  598. else
  599. a_load_reg_reg(list,size,size,src,dst);
  600. if (a shr 5) <> 0 then
  601. internalError(68991);
  602. end
  603. else
  604. internalerror(200109091);
  605. end;
  606. { if all else failed, load the constant in a register and then }
  607. { perform the operation }
  608. if useReg then
  609. begin
  610. scratchreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  611. a_load_const_reg(list,OS_32,a,scratchreg);
  612. a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
  613. rg[R_INTREGISTER].ungetregister(list,scratchreg);
  614. end;
  615. end;
  616. procedure tcgppc.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
  617. size: tcgsize; src1, src2, dst: tregister);
  618. const
  619. op_reg_reg_opcg2asmop: array[TOpCG] of tasmop =
  620. (A_NONE,A_ADD,A_AND,A_DIVWU,A_DIVW,A_MULLW,A_MULLW,A_NEG,A_NOT,A_OR,
  621. A_SRAW,A_SLW,A_SRW,A_SUB,A_XOR);
  622. begin
  623. case op of
  624. OP_NEG,OP_NOT:
  625. begin
  626. list.concat(taicpu.op_reg_reg(op_reg_reg_opcg2asmop[op],dst,src1));
  627. if (op = OP_NOT) and
  628. not(size in [OS_32,OS_S32]) then
  629. { zero/sign extend result again }
  630. a_load_reg_reg(list,OS_32,size,dst,dst);
  631. end;
  632. else
  633. list.concat(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1));
  634. end;
  635. end;
  636. {*************** compare instructructions ****************}
  637. procedure tcgppc.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aword;reg : tregister;
  638. l : tasmlabel);
  639. var
  640. p: taicpu;
  641. scratch_register: TRegister;
  642. signed: boolean;
  643. begin
  644. signed := cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE];
  645. { in the following case, we generate more efficient code when }
  646. { signed is true }
  647. if (cmp_op in [OC_EQ,OC_NE]) and
  648. (a > $ffff) then
  649. signed := true;
  650. if signed then
  651. if (longint(a) >= low(smallint)) and (longint(a) <= high(smallint)) Then
  652. list.concat(taicpu.op_reg_reg_const(A_CMPWI,NR_CR0,reg,longint(a)))
  653. else
  654. begin
  655. scratch_register := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  656. a_load_const_reg(list,OS_32,a,scratch_register);
  657. list.concat(taicpu.op_reg_reg_reg(A_CMPW,NR_CR0,reg,scratch_register));
  658. rg[R_INTREGISTER].ungetregister(list,scratch_register);
  659. end
  660. else
  661. if (a <= $ffff) then
  662. list.concat(taicpu.op_reg_reg_const(A_CMPLWI,NR_CR0,reg,a))
  663. else
  664. begin
  665. scratch_register := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  666. a_load_const_reg(list,OS_32,a,scratch_register);
  667. list.concat(taicpu.op_reg_reg_reg(A_CMPLW,NR_CR0,reg,scratch_register));
  668. rg[R_INTREGISTER].ungetregister(list,scratch_register);
  669. end;
  670. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  671. end;
  672. procedure tcgppc.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;
  673. reg1,reg2 : tregister;l : tasmlabel);
  674. var
  675. p: taicpu;
  676. op: tasmop;
  677. begin
  678. if cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE] then
  679. op := A_CMPW
  680. else
  681. op := A_CMPLW;
  682. list.concat(taicpu.op_reg_reg_reg(op,NR_CR0,reg2,reg1));
  683. a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
  684. end;
  685. procedure tcgppc.g_save_standard_registers(list:Taasmoutput);
  686. begin
  687. {$warning FIX ME}
  688. end;
  689. procedure tcgppc.g_restore_standard_registers(list:Taasmoutput);
  690. begin
  691. {$warning FIX ME}
  692. end;
  693. procedure tcgppc.g_save_all_registers(list : taasmoutput);
  694. begin
  695. {$warning FIX ME}
  696. end;
  697. procedure tcgppc.g_restore_all_registers(list : taasmoutput;const funcretparaloc:tparalocation);
  698. begin
  699. {$warning FIX ME}
  700. end;
  701. procedure tcgppc.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
  702. begin
  703. a_jmp(list,A_BC,TOpCmp2AsmCond[cond],0,l);
  704. end;
  705. procedure tcgppc.a_jmp_always(list : taasmoutput;l: tasmlabel);
  706. begin
  707. a_jmp(list,A_B,C_None,0,l);
  708. end;
  709. procedure tcgppc.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
  710. var
  711. c: tasmcond;
  712. begin
  713. c := flags_to_cond(f);
  714. a_jmp(list,A_BC,c.cond,c.cr-RS_CR0,l);
  715. end;
  716. procedure tcgppc.g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister);
  717. var
  718. testbit: byte;
  719. bitvalue: boolean;
  720. begin
  721. { get the bit to extract from the conditional register + its }
  722. { requested value (0 or 1) }
  723. testbit := ((f.cr-RS_CR0) * 4);
  724. case f.flag of
  725. F_EQ,F_NE:
  726. begin
  727. inc(testbit,2);
  728. bitvalue := f.flag = F_EQ;
  729. end;
  730. F_LT,F_GE:
  731. begin
  732. bitvalue := f.flag = F_LT;
  733. end;
  734. F_GT,F_LE:
  735. begin
  736. inc(testbit);
  737. bitvalue := f.flag = F_GT;
  738. end;
  739. else
  740. internalerror(200112261);
  741. end;
  742. { load the conditional register in the destination reg }
  743. list.concat(taicpu.op_reg(A_MFCR,reg));
  744. { we will move the bit that has to be tested to bit 0 by rotating }
  745. { left }
  746. testbit := (testbit + 1) and 31;
  747. { extract bit }
  748. list.concat(taicpu.op_reg_reg_const_const_const(
  749. A_RLWINM,reg,reg,testbit,31,31));
  750. { if we need the inverse, xor with 1 }
  751. if not bitvalue then
  752. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  753. end;
  754. (*
  755. procedure tcgppc.g_cond2reg(list: taasmoutput; const f: TAsmCond; reg: TRegister);
  756. var
  757. testbit: byte;
  758. bitvalue: boolean;
  759. begin
  760. { get the bit to extract from the conditional register + its }
  761. { requested value (0 or 1) }
  762. case f.simple of
  763. false:
  764. begin
  765. { we don't generate this in the compiler }
  766. internalerror(200109062);
  767. end;
  768. true:
  769. case f.cond of
  770. C_None:
  771. internalerror(200109063);
  772. C_LT..C_NU:
  773. begin
  774. testbit := (ord(f.cr) - ord(R_CR0))*4;
  775. inc(testbit,AsmCondFlag2BI[f.cond]);
  776. bitvalue := AsmCondFlagTF[f.cond];
  777. end;
  778. C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
  779. begin
  780. testbit := f.crbit
  781. bitvalue := AsmCondFlagTF[f.cond];
  782. end;
  783. else
  784. internalerror(200109064);
  785. end;
  786. end;
  787. { load the conditional register in the destination reg }
  788. list.concat(taicpu.op_reg_reg(A_MFCR,reg));
  789. { we will move the bit that has to be tested to bit 31 -> rotate }
  790. { left by bitpos+1 (remember, this is big-endian!) }
  791. if bitpos <> 31 then
  792. inc(bitpos)
  793. else
  794. bitpos := 0;
  795. { extract bit }
  796. list.concat(taicpu.op_reg_reg_const_const_const(
  797. A_RLWINM,reg,reg,bitpos,31,31));
  798. { if we need the inverse, xor with 1 }
  799. if not bitvalue then
  800. list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
  801. end;
  802. *)
  803. { *********** entry/exit code and address loading ************ }
  804. procedure tcgppc.g_stackframe_entry(list : taasmoutput;localsize : longint);
  805. { generated the entry code of a procedure/function. Note: localsize is the }
  806. { sum of the size necessary for local variables and the maximum possible }
  807. { combined size of ALL the parameters of a procedure called by the current }
  808. { one. }
  809. { This procedure may be called before, as well as after
  810. g_return_from_proc is called.}
  811. var regcounter,firstregfpu,firstreggpr: TSuperRegister;
  812. href,href2 : treference;
  813. usesfpr,usesgpr,gotgot : boolean;
  814. parastart : aword;
  815. // r,r2,rsp:Tregister;
  816. regcounter2, firstfpureg: Tsuperregister;
  817. hp: tparaitem;
  818. begin
  819. { CR and LR only have to be saved in case they are modified by the current }
  820. { procedure, but currently this isn't checked, so save them always }
  821. { following is the entry code as described in "Altivec Programming }
  822. { Interface Manual", bar the saving of AltiVec registers }
  823. a_reg_alloc(list,NR_STACK_POINTER_REG);
  824. a_reg_alloc(list,NR_R0);
  825. if current_procinfo.procdef.parast.symtablelevel>1 then
  826. a_reg_alloc(list,NR_R11);
  827. usesfpr:=false;
  828. if not (po_assembler in current_procinfo.procdef.procoptions) then
  829. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  830. case target_info.abi of
  831. abi_powerpc_aix:
  832. firstfpureg := RS_F14;
  833. abi_powerpc_sysv:
  834. firstfpureg := RS_F9;
  835. else
  836. internalerror(2003122903);
  837. end;
  838. for regcounter:=firstfpureg to RS_F31 do
  839. begin
  840. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  841. begin
  842. usesfpr:= true;
  843. firstregfpu:=regcounter;
  844. break;
  845. end;
  846. end;
  847. usesgpr:=false;
  848. if not (po_assembler in current_procinfo.procdef.procoptions) then
  849. for regcounter2:=RS_R13 to RS_R31 do
  850. begin
  851. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  852. begin
  853. usesgpr:=true;
  854. firstreggpr:=regcounter2;
  855. break;
  856. end;
  857. end;
  858. { save link register? }
  859. if not (po_assembler in current_procinfo.procdef.procoptions) then
  860. if (pi_do_call in current_procinfo.flags) then
  861. begin
  862. { save return address... }
  863. list.concat(taicpu.op_reg(A_MFLR,NR_R0));
  864. { ... in caller's frame }
  865. case target_info.abi of
  866. abi_powerpc_aix:
  867. reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX);
  868. abi_powerpc_sysv:
  869. reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
  870. end;
  871. list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
  872. a_reg_dealloc(list,NR_R0);
  873. end;
  874. { save the CR if necessary in callers frame. }
  875. if not (po_assembler in current_procinfo.procdef.procoptions) then
  876. if target_info.abi = abi_powerpc_aix then
  877. if false then { Not needed at the moment. }
  878. begin
  879. a_reg_alloc(list,NR_R0);
  880. list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_CR));
  881. reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
  882. list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
  883. a_reg_dealloc(list,NR_R0);
  884. end;
  885. { !!! always allocate space for all registers for now !!! }
  886. if not (po_assembler in current_procinfo.procdef.procoptions) then
  887. { if usesfpr or usesgpr then }
  888. begin
  889. a_reg_alloc(list,NR_R12);
  890. { save end of fpr save area }
  891. list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
  892. end;
  893. if (localsize <> 0) then
  894. begin
  895. if (localsize <= high(smallint)) then
  896. begin
  897. reference_reset_base(href,NR_STACK_POINTER_REG,-localsize);
  898. a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
  899. end
  900. else
  901. begin
  902. reference_reset_base(href,NR_STACK_POINTER_REG,0);
  903. { can't use getregisterint here, the register colouring }
  904. { is already done when we get here }
  905. href.index := NR_R11;
  906. a_reg_alloc(list,href.index);
  907. a_load_const_reg(list,OS_S32,-localsize,href.index);
  908. a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
  909. a_reg_dealloc(list,href.index);
  910. end;
  911. end;
  912. { no GOT pointer loaded yet }
  913. gotgot:=false;
  914. if usesfpr then
  915. begin
  916. { save floating-point registers
  917. if (cs_create_pic in aktmoduleswitches) and not(usesgpr) then
  918. begin
  919. a_call_name(objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+'_g');
  920. gotgot:=true;
  921. end
  922. else
  923. a_call_name(objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14));
  924. }
  925. reference_reset_base(href,NR_R12,-8);
  926. for regcounter:=firstregfpu to RS_F31 do
  927. begin
  928. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  929. begin
  930. a_loadfpu_reg_ref(list,OS_F64,newreg(R_FPUREGISTER,regcounter,R_SUBNONE),href);
  931. dec(href.offset,8);
  932. end;
  933. end;
  934. { compute end of gpr save area }
  935. a_op_const_reg(list,OP_ADD,OS_ADDR,aword(href.offset+8),NR_R12);
  936. end;
  937. { save gprs and fetch GOT pointer }
  938. if usesgpr then
  939. begin
  940. {
  941. if cs_create_pic in aktmoduleswitches then
  942. begin
  943. a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14)+'_g');
  944. gotgot:=true;
  945. end
  946. else
  947. a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14))
  948. }
  949. reference_reset_base(href,NR_R12,-4);
  950. for regcounter2:=RS_R13 to RS_R31 do
  951. begin
  952. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  953. begin
  954. usesgpr:=true;
  955. a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href);
  956. dec(href.offset,4);
  957. end;
  958. end;
  959. {
  960. r.enum:=R_INTREGISTER;
  961. r.:=;
  962. reference_reset_base(href,NR_R12,-((NR_R31-firstreggpr) shr 8+1)*4);
  963. list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
  964. }
  965. end;
  966. if assigned(current_procinfo.procdef.parast) then
  967. begin
  968. if not (po_assembler in current_procinfo.procdef.procoptions) then
  969. begin
  970. { copy memory parameters to local parast }
  971. hp:=tparaitem(current_procinfo.procdef.para.first);
  972. while assigned(hp) do
  973. begin
  974. if (hp.paraloc[calleeside].loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
  975. begin
  976. if tvarsym(hp.parasym).localloc.loc<>LOC_REFERENCE then
  977. internalerror(200310011);
  978. reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.index,tvarsym(hp.parasym).localloc.reference.offset);
  979. reference_reset_base(href2,NR_R12,hp.paraloc[callerside].reference.offset);
  980. { we can't use functions here which allocate registers (FK)
  981. cg.a_load_ref_ref(list,hp.paraloc[calleeside].size,hp.paraloc[calleeside].size,href2,href);
  982. }
  983. cg.a_load_ref_reg(list,hp.paraloc[calleeside].size,hp.paraloc[calleeside].size,href2,NR_R0);
  984. cg.a_load_reg_ref(list,hp.paraloc[calleeside].size,hp.paraloc[calleeside].size,NR_R0,href);
  985. end
  986. {$ifdef dummy}
  987. else if (hp.calleeparaloc.loc in [LOC_REGISTER,LOC_CREGISTER]) then
  988. begin
  989. rg.getexplicitregisterint(list,hp.calleeparaloc.register);
  990. end
  991. {$endif dummy}
  992. ;
  993. hp := tparaitem(hp.next);
  994. end;
  995. end;
  996. end;
  997. if usesfpr or usesgpr then
  998. a_reg_dealloc(list,NR_R12);
  999. { PIC code support, }
  1000. if cs_create_pic in aktmoduleswitches then
  1001. begin
  1002. { if we didn't get the GOT pointer till now, we've to calculate it now }
  1003. if not(gotgot) then
  1004. begin
  1005. {!!!!!!!!!!!!!}
  1006. end;
  1007. a_reg_alloc(list,NR_R31);
  1008. { place GOT ptr in r31 }
  1009. list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R31,NR_LR));
  1010. end;
  1011. { save the CR if necessary ( !!! always done currently ) }
  1012. { still need to find out where this has to be done for SystemV
  1013. a_reg_alloc(list,R_0);
  1014. list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR);
  1015. list.concat(taicpu.op_reg_ref(A_STW,scratch_register,
  1016. new_reference(STACK_POINTER_REG,LA_CR)));
  1017. a_reg_dealloc(list,R_0); }
  1018. { now comes the AltiVec context save, not yet implemented !!! }
  1019. { if we're in a nested procedure, we've to save R11 }
  1020. if current_procinfo.procdef.parast.symtablelevel>2 then
  1021. begin
  1022. reference_reset_base(href,NR_STACK_POINTER_REG,PARENT_FRAMEPOINTER_OFFSET);
  1023. list.concat(taicpu.op_reg_ref(A_STW,NR_R11,href));
  1024. end;
  1025. end;
  1026. procedure tcgppc.g_return_from_proc(list : taasmoutput;parasize : aword);
  1027. { This procedure may be called before, as well as after
  1028. g_stackframe_entry is called.}
  1029. var
  1030. regcounter,firstregfpu,firstreggpr: TsuperRegister;
  1031. href : treference;
  1032. usesfpr,usesgpr,genret : boolean;
  1033. regcounter2, firstfpureg:Tsuperregister;
  1034. localsize: aword;
  1035. begin
  1036. { AltiVec context restore, not yet implemented !!! }
  1037. usesfpr:=false;
  1038. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1039. begin
  1040. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  1041. case target_info.abi of
  1042. abi_powerpc_aix:
  1043. firstfpureg := RS_F14;
  1044. abi_powerpc_sysv:
  1045. firstfpureg := RS_F9;
  1046. else
  1047. internalerror(2003122903);
  1048. end;
  1049. for regcounter:=firstfpureg to RS_F31 do
  1050. begin
  1051. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  1052. begin
  1053. usesfpr:=true;
  1054. firstregfpu:=regcounter;
  1055. break;
  1056. end;
  1057. end;
  1058. end;
  1059. usesgpr:=false;
  1060. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1061. for regcounter2:=RS_R13 to RS_R31 do
  1062. begin
  1063. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  1064. begin
  1065. usesgpr:=true;
  1066. firstreggpr:=regcounter2;
  1067. break;
  1068. end;
  1069. end;
  1070. localsize:= tppcprocinfo(current_procinfo).calc_stackframe_size;
  1071. { no return (blr) generated yet }
  1072. genret:=true;
  1073. if usesgpr or usesfpr then
  1074. begin
  1075. { address of gpr save area to r11 }
  1076. a_op_const_reg_reg(list,OP_ADD,OS_ADDR,localsize,NR_STACK_POINTER_REG,NR_R12);
  1077. if usesfpr then
  1078. begin
  1079. reference_reset_base(href,NR_R12,-8);
  1080. for regcounter := firstregfpu to RS_F31 do
  1081. begin
  1082. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  1083. begin
  1084. a_loadfpu_ref_reg(list,OS_F64,href,newreg(R_FPUREGISTER,regcounter,R_SUBNONE));
  1085. dec(href.offset,8);
  1086. end;
  1087. end;
  1088. inc(href.offset,4);
  1089. end
  1090. else
  1091. reference_reset_base(href,NR_R12,-4);
  1092. for regcounter2:=RS_R13 to RS_R31 do
  1093. begin
  1094. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  1095. begin
  1096. usesgpr:=true;
  1097. a_load_ref_reg(list,OS_INT,OS_INT,href,newreg(R_INTREGISTER,regcounter2,R_SUBNONE));
  1098. dec(href.offset,4);
  1099. end;
  1100. end;
  1101. (*
  1102. reference_reset_base(href,r2,-((NR_R31-ord(firstreggpr)) shr 8+1)*4);
  1103. list.concat(taicpu.op_reg_ref(A_LMW,firstreggpr,href));
  1104. *)
  1105. end;
  1106. (*
  1107. { restore fprs and return }
  1108. if usesfpr then
  1109. begin
  1110. { address of fpr save area to r11 }
  1111. r:=NR_R12;
  1112. list.concat(taicpu.op_reg_reg_const(A_ADDI,r,r,(ord(R_F31)-ord(firstregfpu.enum)+1)*8));
  1113. {
  1114. if (pi_do_call in current_procinfo.flags) then
  1115. a_call_name(objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
  1116. '_x')
  1117. else
  1118. { leaf node => lr haven't to be restored }
  1119. a_call_name('_restfpr_'+tostr(ord(firstregfpu.enum)-ord(R_F14)+14)+
  1120. '_l');
  1121. genret:=false;
  1122. }
  1123. end;
  1124. *)
  1125. { if we didn't generate the return code, we've to do it now }
  1126. if genret then
  1127. begin
  1128. { adjust r1 }
  1129. a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,NR_R1);
  1130. { load link register? }
  1131. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1132. begin
  1133. if (pi_do_call in current_procinfo.flags) then
  1134. begin
  1135. case target_info.abi of
  1136. abi_powerpc_aix:
  1137. reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX);
  1138. abi_powerpc_sysv:
  1139. reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
  1140. end;
  1141. list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
  1142. list.concat(taicpu.op_reg(A_MTLR,NR_R0));
  1143. end;
  1144. { restore the CR if necessary from callers frame}
  1145. if target_info.abi = abi_powerpc_aix then
  1146. if false then { Not needed at the moment. }
  1147. begin
  1148. reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
  1149. list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
  1150. list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_CR));
  1151. a_reg_dealloc(list,NR_R0);
  1152. end;
  1153. end;
  1154. list.concat(taicpu.op_none(A_BLR));
  1155. end;
  1156. end;
  1157. function tcgppc.save_regs(list : taasmoutput):longint;
  1158. {Generates code which saves used non-volatile registers in
  1159. the save area right below the address the stackpointer point to.
  1160. Returns the actual used save area size.}
  1161. var regcounter,firstregfpu,firstreggpr: TSuperRegister;
  1162. usesfpr,usesgpr: boolean;
  1163. href : treference;
  1164. offset: integer;
  1165. regcounter2, firstfpureg: Tsuperregister;
  1166. begin
  1167. usesfpr:=false;
  1168. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1169. begin
  1170. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  1171. case target_info.abi of
  1172. abi_powerpc_aix:
  1173. firstfpureg := RS_F14;
  1174. abi_powerpc_sysv:
  1175. firstfpureg := RS_F9;
  1176. else
  1177. internalerror(2003122903);
  1178. end;
  1179. for regcounter:=firstfpureg to RS_F31 do
  1180. begin
  1181. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  1182. begin
  1183. usesfpr:=true;
  1184. firstregfpu:=regcounter;
  1185. break;
  1186. end;
  1187. end;
  1188. end;
  1189. usesgpr:=false;
  1190. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1191. for regcounter2:=RS_R13 to RS_R31 do
  1192. begin
  1193. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  1194. begin
  1195. usesgpr:=true;
  1196. firstreggpr:=regcounter2;
  1197. break;
  1198. end;
  1199. end;
  1200. offset:= 0;
  1201. { save floating-point registers }
  1202. if usesfpr then
  1203. for regcounter := firstregfpu to RS_F31 do
  1204. begin
  1205. offset:= offset - 8;
  1206. reference_reset_base(href, NR_STACK_POINTER_REG, offset);
  1207. list.concat(taicpu.op_reg_ref(A_STFD, tregister(regcounter), href));
  1208. end;
  1209. (* Optimiztion in the future: a_call_name(list,'_savefXX'); *)
  1210. { save gprs in gpr save area }
  1211. if usesgpr then
  1212. if firstreggpr < RS_R30 then
  1213. begin
  1214. offset:= offset - 4 * (RS_R31 - firstreggpr + 1);
  1215. reference_reset_base(href,NR_STACK_POINTER_REG,offset);
  1216. list.concat(taicpu.op_reg_ref(A_STMW,tregister(firstreggpr),href));
  1217. {STMW stores multiple registers}
  1218. end
  1219. else
  1220. begin
  1221. for regcounter := firstreggpr to RS_R31 do
  1222. begin
  1223. offset:= offset - 4;
  1224. reference_reset_base(href, NR_STACK_POINTER_REG, offset);
  1225. list.concat(taicpu.op_reg_ref(A_STW, newreg(R_INTREGISTER,regcounter,R_SUBWHOLE), href));
  1226. end;
  1227. end;
  1228. { now comes the AltiVec context save, not yet implemented !!! }
  1229. save_regs:= -offset;
  1230. end;
  1231. procedure tcgppc.restore_regs(list : taasmoutput);
  1232. {Generates code which restores used non-volatile registers from
  1233. the save area right below the address the stackpointer point to.}
  1234. var regcounter,firstregfpu,firstreggpr: TSuperRegister;
  1235. usesfpr,usesgpr: boolean;
  1236. href : treference;
  1237. offset: integer;
  1238. regcounter2, firstfpureg: Tsuperregister;
  1239. begin
  1240. usesfpr:=false;
  1241. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1242. begin
  1243. { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
  1244. case target_info.abi of
  1245. abi_powerpc_aix:
  1246. firstfpureg := RS_F14;
  1247. abi_powerpc_sysv:
  1248. firstfpureg := RS_F9;
  1249. else
  1250. internalerror(2003122903);
  1251. end;
  1252. for regcounter:=firstfpureg to RS_F31 do
  1253. begin
  1254. if regcounter in rg[R_FPUREGISTER].used_in_proc then
  1255. begin
  1256. usesfpr:=true;
  1257. firstregfpu:=regcounter;
  1258. break;
  1259. end;
  1260. end;
  1261. end;
  1262. usesgpr:=false;
  1263. if not (po_assembler in current_procinfo.procdef.procoptions) then
  1264. for regcounter2:=RS_R13 to RS_R31 do
  1265. begin
  1266. if regcounter2 in rg[R_INTREGISTER].used_in_proc then
  1267. begin
  1268. usesgpr:=true;
  1269. firstreggpr:=regcounter2;
  1270. break;
  1271. end;
  1272. end;
  1273. offset:= 0;
  1274. { restore fp registers }
  1275. if usesfpr then
  1276. for regcounter := firstregfpu to RS_F31 do
  1277. begin
  1278. offset:= offset - 8;
  1279. reference_reset_base(href, NR_STACK_POINTER_REG, offset);
  1280. list.concat(taicpu.op_reg_ref(A_LFD, newreg(R_FPUREGISTER,regcounter,R_SUBWHOLE), href));
  1281. end;
  1282. (* Optimiztion in the future: a_call_name(list,'_restfXX'); *)
  1283. { restore gprs }
  1284. if usesgpr then
  1285. if firstreggpr < RS_R30 then
  1286. begin
  1287. offset:= offset - 4 * (RS_R31 - firstreggpr + 1);
  1288. reference_reset_base(href,NR_STACK_POINTER_REG,offset); //-220
  1289. list.concat(taicpu.op_reg_ref(A_LMW,tregister(firstreggpr),href));
  1290. {LMW loads multiple registers}
  1291. end
  1292. else
  1293. begin
  1294. for regcounter := firstreggpr to RS_R31 do
  1295. begin
  1296. offset:= offset - 4;
  1297. reference_reset_base(href, NR_STACK_POINTER_REG, offset);
  1298. list.concat(taicpu.op_reg_ref(A_LWZ, newreg(R_INTREGISTER,regcounter,R_SUBWHOLE), href));
  1299. end;
  1300. end;
  1301. { now comes the AltiVec context restore, not yet implemented !!! }
  1302. end;
  1303. procedure tcgppc.g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
  1304. (* NOT IN USE *)
  1305. { generated the entry code of a procedure/function. Note: localsize is the }
  1306. { sum of the size necessary for local variables and the maximum possible }
  1307. { combined size of ALL the parameters of a procedure called by the current }
  1308. { one }
  1309. const
  1310. macosLinkageAreaSize = 24;
  1311. var regcounter: TRegister;
  1312. href : treference;
  1313. registerSaveAreaSize : longint;
  1314. begin
  1315. if (localsize mod 8) <> 0 then
  1316. internalerror(58991);
  1317. { CR and LR only have to be saved in case they are modified by the current }
  1318. { procedure, but currently this isn't checked, so save them always }
  1319. { following is the entry code as described in "Altivec Programming }
  1320. { Interface Manual", bar the saving of AltiVec registers }
  1321. a_reg_alloc(list,NR_STACK_POINTER_REG);
  1322. a_reg_alloc(list,NR_R0);
  1323. { save return address in callers frame}
  1324. list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_LR));
  1325. { ... in caller's frame }
  1326. reference_reset_base(href,NR_STACK_POINTER_REG,8);
  1327. list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
  1328. a_reg_dealloc(list,NR_R0);
  1329. { save non-volatile registers in callers frame}
  1330. registerSaveAreaSize:= save_regs(list);
  1331. { save the CR if necessary in callers frame ( !!! always done currently ) }
  1332. a_reg_alloc(list,NR_R0);
  1333. list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_CR));
  1334. reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
  1335. list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
  1336. a_reg_dealloc(list,NR_R0);
  1337. (*
  1338. { save pointer to incoming arguments }
  1339. list.concat(taicpu.op_reg_reg_const(A_ORI,R_31,STACK_POINTER_REG,0));
  1340. *)
  1341. (*
  1342. a_reg_alloc(list,R_12);
  1343. { 0 or 8 based on SP alignment }
  1344. list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
  1345. R_12,STACK_POINTER_REG,0,28,28));
  1346. { add in stack length }
  1347. list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
  1348. -localsize));
  1349. { establish new alignment }
  1350. list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER_REG,STACK_POINTER_REG,R_12));
  1351. a_reg_dealloc(list,R_12);
  1352. *)
  1353. { allocate stack frame }
  1354. localsize:= align(localsize + macosLinkageAreaSize + registerSaveAreaSize, 16);
  1355. inc(localsize,tg.lasttemp);
  1356. localsize:=align(localsize,16);
  1357. //tppcprocinfo(current_procinfo).localsize:=localsize;
  1358. if (localsize <> 0) then
  1359. begin
  1360. if (localsize <= high(smallint)) then
  1361. begin
  1362. reference_reset_base(href,NR_STACK_POINTER_REG,-localsize);
  1363. a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
  1364. end
  1365. else
  1366. begin
  1367. reference_reset_base(href,NR_STACK_POINTER_REG,0);
  1368. href.index := NR_R11;
  1369. a_reg_alloc(list,href.index);
  1370. a_load_const_reg(list,OS_S32,-localsize,href.index);
  1371. a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
  1372. a_reg_dealloc(list,href.index);
  1373. end;
  1374. end;
  1375. end;
  1376. procedure tcgppc.g_return_from_proc_mac(list : taasmoutput;parasize : aword);
  1377. (* NOT IN USE *)
  1378. var
  1379. href : treference;
  1380. begin
  1381. a_reg_alloc(list,NR_R0);
  1382. { restore stack pointer }
  1383. reference_reset_base(href,NR_STACK_POINTER_REG,LA_SP);
  1384. list.concat(taicpu.op_reg_ref(A_LWZ,NR_STACK_POINTER_REG,href));
  1385. (*
  1386. list.concat(taicpu.op_reg_reg_const(A_ORI,NR_STACK_POINTER_REG,R_31,0));
  1387. *)
  1388. { restore the CR if necessary from callers frame
  1389. ( !!! always done currently ) }
  1390. reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
  1391. list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
  1392. list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_CR));
  1393. a_reg_dealloc(list,NR_R0);
  1394. (*
  1395. { restore return address from callers frame }
  1396. reference_reset_base(href,STACK_POINTER_REG,8);
  1397. list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
  1398. *)
  1399. { restore non-volatile registers from callers frame }
  1400. restore_regs(list);
  1401. (*
  1402. { return to caller }
  1403. list.concat(taicpu.op_reg_reg(A_MTSPR,R_0,R_LR));
  1404. list.concat(taicpu.op_none(A_BLR));
  1405. *)
  1406. { restore return address from callers frame }
  1407. reference_reset_base(href,NR_STACK_POINTER_REG,8);
  1408. list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
  1409. { return to caller }
  1410. list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_LR));
  1411. list.concat(taicpu.op_none(A_BLR));
  1412. end;
  1413. procedure tcgppc.g_restore_frame_pointer(list : taasmoutput);
  1414. begin
  1415. { no frame pointer on the PowerPC (maybe there is one in the SystemV ABI?)}
  1416. end;
  1417. procedure tcgppc.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
  1418. var
  1419. ref2, tmpref: treference;
  1420. freereg: boolean;
  1421. tmpreg:Tregister;
  1422. begin
  1423. ref2 := ref;
  1424. freereg := fixref(list,ref2);
  1425. if assigned(ref2.symbol) then
  1426. begin
  1427. if target_info.system = system_powerpc_macos then
  1428. begin
  1429. if macos_direct_globals then
  1430. begin
  1431. reference_reset(tmpref);
  1432. tmpref.offset := ref2.offset;
  1433. tmpref.symbol := ref2.symbol;
  1434. tmpref.base := NR_NO;
  1435. list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,NR_RTOC,tmpref));
  1436. end
  1437. else
  1438. begin
  1439. reference_reset(tmpref);
  1440. tmpref.symbol := ref2.symbol;
  1441. tmpref.offset := 0;
  1442. tmpref.base := NR_RTOC;
  1443. list.concat(taicpu.op_reg_ref(A_LWZ,r,tmpref));
  1444. if ref2.offset <> 0 then
  1445. begin
  1446. reference_reset(tmpref);
  1447. tmpref.offset := ref2.offset;
  1448. tmpref.base:= r;
  1449. list.concat(taicpu.op_reg_ref(A_LA,r,tmpref));
  1450. end;
  1451. end;
  1452. if ref2.base <> NR_NO then
  1453. list.concat(taicpu.op_reg_reg_reg(A_ADD,r,r,ref2.base));
  1454. //list.concat(tai_comment.create(strpnew('*** a_loadaddr_ref_reg')));
  1455. end
  1456. else
  1457. begin
  1458. { add the symbol's value to the base of the reference, and if the }
  1459. { reference doesn't have a base, create one }
  1460. reference_reset(tmpref);
  1461. tmpref.offset := ref2.offset;
  1462. tmpref.symbol := ref2.symbol;
  1463. tmpref.symaddr := refs_ha;
  1464. if ref2.base<> NR_NO then
  1465. begin
  1466. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,r,
  1467. ref2.base,tmpref));
  1468. if freereg then
  1469. begin
  1470. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  1471. freereg := false;
  1472. end;
  1473. end
  1474. else
  1475. list.concat(taicpu.op_reg_ref(A_LIS,r,tmpref));
  1476. tmpref.base := NR_NO;
  1477. tmpref.symaddr := refs_l;
  1478. { can be folded with one of the next instructions by the }
  1479. { optimizer probably }
  1480. list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,r,tmpref));
  1481. end
  1482. end
  1483. else if ref2.offset <> 0 Then
  1484. if ref2.base <> NR_NO then
  1485. a_op_const_reg_reg(list,OP_ADD,OS_32,aword(ref2.offset),ref2.base,r)
  1486. { FixRef makes sure that "(ref.index <> R_NO) and (ref.offset <> 0)" never}
  1487. { occurs, so now only ref.offset has to be loaded }
  1488. else
  1489. a_load_const_reg(list,OS_32,ref2.offset,r)
  1490. else if ref.index <> NR_NO Then
  1491. list.concat(taicpu.op_reg_reg_reg(A_ADD,r,ref2.base,ref2.index))
  1492. else if (ref2.base <> NR_NO) and
  1493. (r <> ref2.base) then
  1494. list.concat(taicpu.op_reg_reg(A_MR,r,ref2.base))
  1495. else
  1496. list.concat(taicpu.op_reg_const(A_LI,r,0));
  1497. if freereg then
  1498. rg[R_INTREGISTER].ungetregister(list,ref2.base);
  1499. end;
  1500. { ************* concatcopy ************ }
  1501. {$ifndef ppc603}
  1502. const
  1503. maxmoveunit = 8;
  1504. {$else ppc603}
  1505. const
  1506. maxmoveunit = 4;
  1507. {$endif ppc603}
  1508. procedure tcgppc.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aword; delsource,loadref : boolean);
  1509. var
  1510. countreg: TRegister;
  1511. src, dst: TReference;
  1512. lab: tasmlabel;
  1513. count, count2: aword;
  1514. orgsrc, orgdst: boolean;
  1515. size: tcgsize;
  1516. begin
  1517. {$ifdef extdebug}
  1518. if len > high(longint) then
  1519. internalerror(2002072704);
  1520. {$endif extdebug}
  1521. { make sure short loads are handled as optimally as possible }
  1522. if not loadref then
  1523. if (len <= maxmoveunit) and
  1524. (byte(len) in [1,2,4,8]) then
  1525. begin
  1526. if len < 8 then
  1527. begin
  1528. size := int_cgsize(len);
  1529. a_load_ref_ref(list,size,size,source,dest);
  1530. if delsource then
  1531. begin
  1532. reference_release(list,source);
  1533. tg.ungetiftemp(list,source);
  1534. end;
  1535. end
  1536. else
  1537. begin
  1538. a_reg_alloc(list,NR_F0);
  1539. a_loadfpu_ref_reg(list,OS_F64,source,NR_F0);
  1540. if delsource then
  1541. begin
  1542. reference_release(list,source);
  1543. tg.ungetiftemp(list,source);
  1544. end;
  1545. a_loadfpu_reg_ref(list,OS_F64,NR_F0,dest);
  1546. a_reg_dealloc(list,NR_F0);
  1547. end;
  1548. exit;
  1549. end;
  1550. count := len div maxmoveunit;
  1551. reference_reset(src);
  1552. reference_reset(dst);
  1553. { load the address of source into src.base }
  1554. if loadref then
  1555. begin
  1556. src.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1557. a_load_ref_reg(list,OS_32,OS_32,source,src.base);
  1558. orgsrc := false;
  1559. end
  1560. else if (count > 4) or
  1561. not issimpleref(source) or
  1562. ((source.index <> NR_NO) and
  1563. ((source.offset + longint(len)) > high(smallint))) then
  1564. begin
  1565. src.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1566. a_loadaddr_ref_reg(list,source,src.base);
  1567. orgsrc := false;
  1568. end
  1569. else
  1570. begin
  1571. src := source;
  1572. orgsrc := true;
  1573. end;
  1574. if not orgsrc and delsource then
  1575. reference_release(list,source);
  1576. { load the address of dest into dst.base }
  1577. if (count > 4) or
  1578. not issimpleref(dest) or
  1579. ((dest.index <> NR_NO) and
  1580. ((dest.offset + longint(len)) > high(smallint))) then
  1581. begin
  1582. dst.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1583. a_loadaddr_ref_reg(list,dest,dst.base);
  1584. orgdst := false;
  1585. end
  1586. else
  1587. begin
  1588. dst := dest;
  1589. orgdst := true;
  1590. end;
  1591. {$ifndef ppc603}
  1592. if count > 4 then
  1593. { generate a loop }
  1594. begin
  1595. { the offsets are zero after the a_loadaddress_ref_reg and just }
  1596. { have to be set to 8. I put an Inc there so debugging may be }
  1597. { easier (should offset be different from zero here, it will be }
  1598. { easy to notice in the generated assembler }
  1599. inc(dst.offset,8);
  1600. inc(src.offset,8);
  1601. list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
  1602. list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
  1603. countreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1604. a_load_const_reg(list,OS_32,count,countreg);
  1605. { explicitely allocate R_0 since it can be used safely here }
  1606. { (for holding date that's being copied) }
  1607. a_reg_alloc(list,NR_F0);
  1608. objectlibrary.getlabel(lab);
  1609. a_label(list, lab);
  1610. list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
  1611. list.concat(taicpu.op_reg_ref(A_LFDU,NR_F0,src));
  1612. list.concat(taicpu.op_reg_ref(A_STFDU,NR_F0,dst));
  1613. a_jmp(list,A_BC,C_NE,0,lab);
  1614. rg[R_INTREGISTER].ungetregister(list,countreg);
  1615. a_reg_dealloc(list,NR_F0);
  1616. len := len mod 8;
  1617. end;
  1618. count := len div 8;
  1619. if count > 0 then
  1620. { unrolled loop }
  1621. begin
  1622. a_reg_alloc(list,NR_F0);
  1623. for count2 := 1 to count do
  1624. begin
  1625. a_loadfpu_ref_reg(list,OS_F64,src,NR_F0);
  1626. a_loadfpu_reg_ref(list,OS_F64,NR_F0,dst);
  1627. inc(src.offset,8);
  1628. inc(dst.offset,8);
  1629. end;
  1630. a_reg_dealloc(list,NR_F0);
  1631. len := len mod 8;
  1632. end;
  1633. if (len and 4) <> 0 then
  1634. begin
  1635. a_reg_alloc(list,NR_R0);
  1636. a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
  1637. a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
  1638. inc(src.offset,4);
  1639. inc(dst.offset,4);
  1640. a_reg_dealloc(list,NR_R0);
  1641. end;
  1642. {$else not ppc603}
  1643. if count > 4 then
  1644. { generate a loop }
  1645. begin
  1646. { the offsets are zero after the a_loadaddress_ref_reg and just }
  1647. { have to be set to 4. I put an Inc there so debugging may be }
  1648. { easier (should offset be different from zero here, it will be }
  1649. { easy to notice in the generated assembler }
  1650. inc(dst.offset,4);
  1651. inc(src.offset,4);
  1652. list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
  1653. list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
  1654. countreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1655. a_load_const_reg(list,OS_32,count,countreg);
  1656. { explicitely allocate R_0 since it can be used safely here }
  1657. { (for holding date that's being copied) }
  1658. a_reg_alloc(list,NR_R0);
  1659. objectlibrary.getlabel(lab);
  1660. a_label(list, lab);
  1661. list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
  1662. list.concat(taicpu.op_reg_ref(A_LWZU,NR_R0,src));
  1663. list.concat(taicpu.op_reg_ref(A_STWU,NR_R0,dst));
  1664. a_jmp(list,A_BC,C_NE,0,lab);
  1665. rg[R_INTREGISTER].ungetregister(list,countreg);
  1666. a_reg_dealloc(list,NR_R0);
  1667. len := len mod 4;
  1668. end;
  1669. count := len div 4;
  1670. if count > 0 then
  1671. { unrolled loop }
  1672. begin
  1673. a_reg_alloc(list,NR_R0);
  1674. for count2 := 1 to count do
  1675. begin
  1676. a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
  1677. a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
  1678. inc(src.offset,4);
  1679. inc(dst.offset,4);
  1680. end;
  1681. a_reg_dealloc(list,NR_R0);
  1682. len := len mod 4;
  1683. end;
  1684. {$endif not ppc603}
  1685. { copy the leftovers }
  1686. if (len and 2) <> 0 then
  1687. begin
  1688. a_reg_alloc(list,NR_R0);
  1689. a_load_ref_reg(list,OS_16,OS_16,src,NR_R0);
  1690. a_load_reg_ref(list,OS_16,OS_16,NR_R0,dst);
  1691. inc(src.offset,2);
  1692. inc(dst.offset,2);
  1693. a_reg_dealloc(list,NR_R0);
  1694. end;
  1695. if (len and 1) <> 0 then
  1696. begin
  1697. a_reg_alloc(list,NR_R0);
  1698. a_load_ref_reg(list,OS_8,OS_8,src,NR_R0);
  1699. a_load_reg_ref(list,OS_8,OS_8,NR_R0,dst);
  1700. a_reg_dealloc(list,NR_R0);
  1701. end;
  1702. if orgsrc then
  1703. begin
  1704. if delsource then
  1705. reference_release(list,source);
  1706. end
  1707. else
  1708. rg[R_INTREGISTER].ungetregister(list,src.base);
  1709. if not orgdst then
  1710. rg[R_INTREGISTER].ungetregister(list,dst.base);
  1711. if delsource then
  1712. tg.ungetiftemp(list,source);
  1713. end;
  1714. procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
  1715. var
  1716. hl : tasmlabel;
  1717. begin
  1718. if not(cs_check_overflow in aktlocalswitches) then
  1719. exit;
  1720. objectlibrary.getlabel(hl);
  1721. if not ((def.deftype=pointerdef) or
  1722. ((def.deftype=orddef) and
  1723. (torddef(def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
  1724. bool8bit,bool16bit,bool32bit]))) then
  1725. begin
  1726. list.concat(taicpu.op_reg(A_MCRXR,NR_CR7));
  1727. a_jmp(list,A_BC,C_NO,7,hl)
  1728. end
  1729. else
  1730. a_jmp_cond(list,OC_AE,hl);
  1731. a_call_name(list,'FPC_OVERFLOW');
  1732. a_label(list,hl);
  1733. end;
  1734. {***************** This is private property, keep out! :) *****************}
  1735. function tcgppc.issimpleref(const ref: treference): boolean;
  1736. begin
  1737. if (ref.base = NR_NO) and
  1738. (ref.index <> NR_NO) then
  1739. internalerror(200208101);
  1740. result :=
  1741. not(assigned(ref.symbol)) and
  1742. (((ref.index = NR_NO) and
  1743. (ref.offset >= low(smallint)) and
  1744. (ref.offset <= high(smallint))) or
  1745. ((ref.index <> NR_NO) and
  1746. (ref.offset = 0)));
  1747. end;
  1748. function tcgppc.fixref(list: taasmoutput; var ref: treference): boolean;
  1749. var
  1750. tmpreg: tregister;
  1751. orgindex: tregister;
  1752. begin
  1753. result := false;
  1754. if (ref.base = NR_NO) then
  1755. begin
  1756. ref.base := ref.index;
  1757. ref.base := NR_NO;
  1758. end;
  1759. if (ref.base <> NR_NO) then
  1760. begin
  1761. if (ref.index <> NR_NO) and
  1762. ((ref.offset <> 0) or assigned(ref.symbol)) then
  1763. begin
  1764. result := true;
  1765. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1766. list.concat(taicpu.op_reg_reg_reg(
  1767. A_ADD,tmpreg,ref.base,ref.index));
  1768. ref.index := NR_NO;
  1769. ref.base := tmpreg;
  1770. end
  1771. end
  1772. else
  1773. if ref.index <> NR_NO then
  1774. internalerror(200208102);
  1775. end;
  1776. { find out whether a is of the form 11..00..11b or 00..11...00. If }
  1777. { that's the case, we can use rlwinm to do an AND operation }
  1778. function tcgppc.get_rlwi_const(a: aword; var l1, l2: longint): boolean;
  1779. var
  1780. temp : longint;
  1781. testbit : aword;
  1782. compare: boolean;
  1783. begin
  1784. get_rlwi_const := false;
  1785. if (a = 0) or (a = $ffffffff) then
  1786. exit;
  1787. { start with the lowest bit }
  1788. testbit := 1;
  1789. { check its value }
  1790. compare := boolean(a and testbit);
  1791. { find out how long the run of bits with this value is }
  1792. { (it's impossible that all bits are 1 or 0, because in that case }
  1793. { this function wouldn't have been called) }
  1794. l1 := 31;
  1795. while (((a and testbit) <> 0) = compare) do
  1796. begin
  1797. testbit := testbit shl 1;
  1798. dec(l1);
  1799. end;
  1800. { check the length of the run of bits that comes next }
  1801. compare := not compare;
  1802. l2 := l1;
  1803. while (((a and testbit) <> 0) = compare) and
  1804. (l2 >= 0) do
  1805. begin
  1806. testbit := testbit shl 1;
  1807. dec(l2);
  1808. end;
  1809. { and finally the check whether the rest of the bits all have the }
  1810. { same value }
  1811. compare := not compare;
  1812. temp := l2;
  1813. if temp >= 0 then
  1814. if (a shr (31-temp)) <> ((-ord(compare)) shr (31-temp)) then
  1815. exit;
  1816. { we have done "not(not(compare))", so compare is back to its }
  1817. { initial value. If the lowest bit was 0, a is of the form }
  1818. { 00..11..00 and we need "rlwinm reg,reg,0,l2+1,l1", (+1 }
  1819. { because l2 now contains the position of the last zero of the }
  1820. { first run instead of that of the first 1) so switch l1 and l2 }
  1821. { in that case (we will generate "rlwinm reg,reg,0,l1,l2") }
  1822. if not compare then
  1823. begin
  1824. temp := l1;
  1825. l1 := l2+1;
  1826. l2 := temp;
  1827. end
  1828. else
  1829. { otherwise, l1 currently contains the position of the last }
  1830. { zero instead of that of the first 1 of the second run -> +1 }
  1831. inc(l1);
  1832. { the following is the same as "if l1 = -1 then l1 := 31;" }
  1833. l1 := l1 and 31;
  1834. l2 := l2 and 31;
  1835. get_rlwi_const := true;
  1836. end;
  1837. procedure tcgppc.a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
  1838. ref: treference);
  1839. var
  1840. tmpreg: tregister;
  1841. tmpregUsed: Boolean;
  1842. tmpref: treference;
  1843. largeOffset: Boolean;
  1844. begin
  1845. tmpreg := NR_NO;
  1846. if target_info.system = system_powerpc_macos then
  1847. begin
  1848. largeOffset:= (cardinal(ref.offset-low(smallint)) >
  1849. high(smallint)-low(smallint));
  1850. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1851. tmpregUsed:= false;
  1852. if assigned(ref.symbol) then
  1853. begin //Load symbol's value
  1854. reference_reset(tmpref);
  1855. tmpref.symbol := ref.symbol;
  1856. tmpref.base := NR_RTOC;
  1857. if macos_direct_globals then
  1858. list.concat(taicpu.op_reg_ref(A_LA,tmpreg,tmpref))
  1859. else
  1860. list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
  1861. tmpregUsed:= true;
  1862. end;
  1863. if largeOffset then
  1864. begin //Add hi part of offset
  1865. reference_reset(tmpref);
  1866. tmpref.offset := Hi(ref.offset);
  1867. if tmpregUsed then
  1868. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
  1869. tmpreg,tmpref))
  1870. else
  1871. list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,tmpref));
  1872. tmpregUsed:= true;
  1873. end;
  1874. if tmpregUsed then
  1875. begin
  1876. //Add content of base register
  1877. if ref.base <> NR_NO then
  1878. list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,
  1879. ref.base,tmpreg));
  1880. //Make ref ready to be used by op
  1881. ref.symbol:= nil;
  1882. ref.base:= tmpreg;
  1883. if largeOffset then
  1884. ref.offset := Lo(ref.offset);
  1885. list.concat(taicpu.op_reg_ref(op,reg,ref));
  1886. //list.concat(tai_comment.create(strpnew('*** a_load_store indirect global')));
  1887. end
  1888. else
  1889. list.concat(taicpu.op_reg_ref(op,reg,ref));
  1890. end
  1891. else {if target_info.system <> system_powerpc_macos}
  1892. begin
  1893. if assigned(ref.symbol) or
  1894. (cardinal(ref.offset-low(smallint)) >
  1895. high(smallint)-low(smallint)) then
  1896. begin
  1897. tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1898. reference_reset(tmpref);
  1899. tmpref.symbol := ref.symbol;
  1900. tmpref.offset := ref.offset;
  1901. tmpref.symaddr := refs_ha;
  1902. if ref.base <> NR_NO then
  1903. list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
  1904. ref.base,tmpref))
  1905. else
  1906. list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,tmpref));
  1907. ref.base := tmpreg;
  1908. ref.symaddr := refs_l;
  1909. list.concat(taicpu.op_reg_ref(op,reg,ref));
  1910. end
  1911. else
  1912. list.concat(taicpu.op_reg_ref(op,reg,ref));
  1913. end;
  1914. if (tmpreg <> NR_NO) then
  1915. rg[R_INTREGISTER].ungetregister(list,tmpreg);
  1916. end;
  1917. procedure tcgppc.a_jmp(list: taasmoutput; op: tasmop; c: tasmcondflag;
  1918. crval: longint; l: tasmlabel);
  1919. var
  1920. p: taicpu;
  1921. begin
  1922. p := taicpu.op_sym(op,objectlibrary.newasmsymbol(l.name));
  1923. if op <> A_B then
  1924. create_cond_norm(c,crval,p.condition);
  1925. p.is_jmp := true;
  1926. list.concat(p)
  1927. end;
  1928. procedure tcg64fppc.a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);
  1929. begin
  1930. a_op64_reg_reg_reg(list,op,regsrc,regdst,regdst);
  1931. end;
  1932. procedure tcg64fppc.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : qword;reg : tregister64);
  1933. begin
  1934. a_op64_const_reg_reg(list,op,value,reg,reg);
  1935. end;
  1936. procedure tcg64fppc.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
  1937. begin
  1938. case op of
  1939. OP_AND,OP_OR,OP_XOR:
  1940. begin
  1941. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reglo,regsrc2.reglo,regdst.reglo);
  1942. cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reghi,regsrc2.reghi,regdst.reghi);
  1943. end;
  1944. OP_ADD:
  1945. begin
  1946. list.concat(taicpu.op_reg_reg_reg(A_ADDC,regdst.reglo,regsrc1.reglo,regsrc2.reglo));
  1947. list.concat(taicpu.op_reg_reg_reg(A_ADDE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
  1948. end;
  1949. OP_SUB:
  1950. begin
  1951. list.concat(taicpu.op_reg_reg_reg(A_SUBC,regdst.reglo,regsrc2.reglo,regsrc1.reglo));
  1952. list.concat(taicpu.op_reg_reg_reg(A_SUBFE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
  1953. end;
  1954. else
  1955. internalerror(2002072801);
  1956. end;
  1957. end;
  1958. procedure tcg64fppc.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : qword;regsrc,regdst : tregister64);
  1959. const
  1960. ops: array[boolean,1..3] of tasmop = ((A_ADDIC,A_ADDC,A_ADDZE),
  1961. (A_SUBIC,A_SUBC,A_ADDME));
  1962. var
  1963. tmpreg: tregister;
  1964. tmpreg64: tregister64;
  1965. issub: boolean;
  1966. begin
  1967. case op of
  1968. OP_AND,OP_OR,OP_XOR:
  1969. begin
  1970. cg.a_op_const_reg_reg(list,op,OS_32,aword(value),regsrc.reglo,regdst.reglo);
  1971. cg.a_op_const_reg_reg(list,op,OS_32,aword(value shr 32),regsrc.reghi,
  1972. regdst.reghi);
  1973. end;
  1974. OP_ADD, OP_SUB:
  1975. begin
  1976. if (int64(value) < 0) then
  1977. begin
  1978. if op = OP_ADD then
  1979. op := OP_SUB
  1980. else
  1981. op := OP_ADD;
  1982. int64(value) := -int64(value);
  1983. end;
  1984. if (longint(value) <> 0) then
  1985. begin
  1986. issub := op = OP_SUB;
  1987. if (int64(value) > 0) and
  1988. (int64(value)-ord(issub) <= 32767) then
  1989. begin
  1990. list.concat(taicpu.op_reg_reg_const(ops[issub,1],
  1991. regdst.reglo,regsrc.reglo,longint(value)));
  1992. list.concat(taicpu.op_reg_reg(ops[issub,3],
  1993. regdst.reghi,regsrc.reghi));
  1994. end
  1995. else if ((value shr 32) = 0) then
  1996. begin
  1997. tmpreg := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  1998. cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
  1999. list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
  2000. regdst.reglo,regsrc.reglo,tmpreg));
  2001. tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg);
  2002. list.concat(taicpu.op_reg_reg(ops[issub,3],
  2003. regdst.reghi,regsrc.reghi));
  2004. end
  2005. else
  2006. begin
  2007. tmpreg64.reglo := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  2008. tmpreg64.reghi := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
  2009. a_load64_const_reg(list,value,tmpreg64);
  2010. a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
  2011. tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg64.reglo);
  2012. tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg64.reghi);
  2013. end
  2014. end
  2015. else
  2016. begin
  2017. cg.a_load_reg_reg(list,OS_INT,OS_INT,regsrc.reglo,regdst.reglo);
  2018. cg.a_op_const_reg_reg(list,op,OS_32,aword(value shr 32),regsrc.reghi,
  2019. regdst.reghi);
  2020. end;
  2021. end;
  2022. else
  2023. internalerror(2002072802);
  2024. end;
  2025. end;
  2026. begin
  2027. cg := tcgppc.create;
  2028. cg64 :=tcg64fppc.create;
  2029. end.
  2030. {
  2031. $Log$
  2032. Revision 1.158 2004-02-04 22:01:13 peter
  2033. * first try to get cpupara working for x86_64
  2034. Revision 1.157 2004/02/03 19:49:24 jonas
  2035. - removed mov "reg, reg" optimizations, as they are removed by the
  2036. register allocator and may be necessary to indicate a register may not
  2037. be reused before some point
  2038. Revision 1.156 2004/01/25 16:36:34 jonas
  2039. - removed double construction of fpu register allocator
  2040. Revision 1.155 2004/01/12 22:11:38 peter
  2041. * use localalign info for alignment for locals and temps
  2042. * sparc fpu flags branching added
  2043. * moved powerpc copy_valye_openarray to generic
  2044. Revision 1.154 2003/12/29 14:17:50 jonas
  2045. * fixed saving/restoring of volatile fpu registers under sysv
  2046. + better provisions for abi differences regarding fpu registers that have
  2047. to be saved
  2048. Revision 1.153 2003/12/29 11:13:53 jonas
  2049. * fixed tb0350 (support loading address of reference containing the
  2050. address 0)
  2051. Revision 1.152 2003/12/28 23:49:30 jonas
  2052. * fixed tnotnode for < 32 bit quantities
  2053. Revision 1.151 2003/12/28 19:22:27 florian
  2054. * handling of open array value parameters fixed
  2055. Revision 1.150 2003/12/26 14:02:30 peter
  2056. * sparc updates
  2057. * use registertype in spill_register
  2058. Revision 1.149 2003/12/18 01:03:52 florian
  2059. + register allocators are set to nil now after they are freed
  2060. Revision 1.148 2003/12/16 21:49:47 florian
  2061. * fixed ppc compilation
  2062. Revision 1.147 2003/12/15 21:37:09 jonas
  2063. * fixed compilation and simplified fixref, so it never has to reallocate
  2064. already freed registers anymore
  2065. Revision 1.146 2003/12/12 17:16:18 peter
  2066. * rg[tregistertype] added in tcg
  2067. Revision 1.145 2003/12/10 00:09:57 karoly
  2068. * fixed compilation with -dppc603
  2069. Revision 1.144 2003/12/09 20:39:43 jonas
  2070. * forgot call to cg.g_overflowcheck() in nppcadd
  2071. * fixed overflow flag definition
  2072. * fixed cg.g_overflowcheck() for signed numbers (jump over call to
  2073. FPC_OVERFLOW if *no* overflow instead of if overflow :)
  2074. Revision 1.143 2003/12/07 21:59:21 florian
  2075. * a_load_ref_ref isn't allowed to be used in g_stackframe_entry
  2076. Revision 1.142 2003/12/06 22:13:53 jonas
  2077. * another fix to a_load_ref_reg()
  2078. + implemented uses_registers() method
  2079. Revision 1.141 2003/12/05 22:53:28 jonas
  2080. * fixed load_ref_reg for source > dest size
  2081. Revision 1.140 2003/12/04 20:37:02 jonas
  2082. * fixed some int<->boolean type conversion issues
  2083. Revision 1.139 2003/11/30 11:32:12 jonas
  2084. * fixded fixref() regarding the reallocation of already freed registers
  2085. used in references
  2086. Revision 1.138 2003/11/30 10:16:05 jonas
  2087. * fixed fpu regallocator initialisation
  2088. Revision 1.137 2003/11/21 16:29:26 florian
  2089. * fixed reading of reg. sets in the arm assembler reader
  2090. Revision 1.136 2003/11/02 17:19:33 florian
  2091. + copying of open array value parameters to the heap implemented
  2092. Revision 1.135 2003/11/02 15:20:06 jonas
  2093. * fixed releasing of references (ppc also has a base and an index, not
  2094. just a base)
  2095. Revision 1.134 2003/10/19 01:34:30 florian
  2096. * some ppc stuff fixed
  2097. * memory leak fixed
  2098. Revision 1.133 2003/10/17 15:25:18 florian
  2099. * fixed more ppc stuff
  2100. Revision 1.132 2003/10/17 15:08:34 peter
  2101. * commented out more obsolete constants
  2102. Revision 1.131 2003/10/17 14:52:07 peter
  2103. * fixed ppc build
  2104. Revision 1.130 2003/10/17 01:22:08 florian
  2105. * compilation of the powerpc compiler fixed
  2106. Revision 1.129 2003/10/13 01:58:04 florian
  2107. * some ideas for mm support implemented
  2108. Revision 1.128 2003/10/11 16:06:42 florian
  2109. * fixed some MMX<->SSE
  2110. * started to fix ppc, needs an overhaul
  2111. + stabs info improve for spilling, not sure if it works correctly/completly
  2112. - MMX_SUPPORT removed from Makefile.fpc
  2113. Revision 1.127 2003/10/01 20:34:49 peter
  2114. * procinfo unit contains tprocinfo
  2115. * cginfo renamed to cgbase
  2116. * moved cgmessage to verbose
  2117. * fixed ppc and sparc compiles
  2118. Revision 1.126 2003/09/14 16:37:20 jonas
  2119. * fixed some ppc problems
  2120. Revision 1.125 2003/09/03 21:04:14 peter
  2121. * some fixes for ppc
  2122. Revision 1.124 2003/09/03 19:35:24 peter
  2123. * powerpc compiles again
  2124. Revision 1.123 2003/09/03 15:55:01 peter
  2125. * NEWRA branch merged
  2126. Revision 1.122.2.1 2003/08/31 21:08:16 peter
  2127. * first batch of sparc fixes
  2128. Revision 1.122 2003/08/18 21:27:00 jonas
  2129. * some newra optimizations (eliminate lots of moves between registers)
  2130. Revision 1.121 2003/08/18 11:50:55 olle
  2131. + cleaning up in proc entry and exit, now calc_stack_frame always is used.
  2132. Revision 1.120 2003/08/17 16:59:20 jonas
  2133. * fixed regvars so they work with newra (at least for ppc)
  2134. * fixed some volatile register bugs
  2135. + -dnotranslation option for -dnewra, which causes the registers not to
  2136. be translated from virtual to normal registers. Requires support in
  2137. the assembler writer as well, which is only implemented in aggas/
  2138. agppcgas currently
  2139. Revision 1.119 2003/08/11 21:18:20 peter
  2140. * start of sparc support for newra
  2141. Revision 1.118 2003/08/08 15:50:45 olle
  2142. * merged macos entry/exit code generation into the general one.
  2143. Revision 1.117 2002/10/01 05:24:28 olle
  2144. * made a_load_store more robust and to accept large offsets and cleaned up code
  2145. Revision 1.116 2003/07/23 11:02:23 jonas
  2146. * don't use rg.getregisterint() anymore in g_stackframe_entry_*, because
  2147. the register colouring has already occurred then, use a hard-coded
  2148. register instead
  2149. Revision 1.115 2003/07/20 20:39:20 jonas
  2150. * fixed newra bug due to the fact that we sometimes need a temp reg
  2151. when loading/storing to memory (base+index+offset is not possible)
  2152. and because a reference is often freed before it is last used, this
  2153. temp register was soemtimes the same as one of the reference regs
  2154. Revision 1.114 2003/07/20 16:15:58 jonas
  2155. * fixed bug in g_concatcopy with -dnewra
  2156. Revision 1.113 2003/07/06 20:25:03 jonas
  2157. * fixed ppc compiler
  2158. Revision 1.112 2003/07/05 20:11:42 jonas
  2159. * create_paraloc_info() is now called separately for the caller and
  2160. callee info
  2161. * fixed ppc cycle
  2162. Revision 1.111 2003/07/02 22:18:04 peter
  2163. * paraloc splitted in callerparaloc,calleeparaloc
  2164. * sparc calling convention updates
  2165. Revision 1.110 2003/06/18 10:12:36 olle
  2166. * macos: fixes of loading-code
  2167. Revision 1.109 2003/06/14 22:32:43 jonas
  2168. * ppc compiles with -dnewra, haven't tried to compile anything with it
  2169. yet though
  2170. Revision 1.108 2003/06/13 21:19:31 peter
  2171. * current_procdef removed, use current_procinfo.procdef instead
  2172. Revision 1.107 2003/06/09 14:54:26 jonas
  2173. * (de)allocation of registers for parameters is now performed properly
  2174. (and checked on the ppc)
  2175. - removed obsolete allocation of all parameter registers at the start
  2176. of a procedure (and deallocation at the end)
  2177. Revision 1.106 2003/06/08 18:19:27 jonas
  2178. - removed duplicate identifier
  2179. Revision 1.105 2003/06/07 18:57:04 jonas
  2180. + added freeintparaloc
  2181. * ppc get/freeintparaloc now check whether the parameter regs are
  2182. properly allocated/deallocated (and get an extra list para)
  2183. * ppc a_call_* now internalerrors if pi_do_call is not yet set
  2184. * fixed lot of missing pi_do_call's
  2185. Revision 1.104 2003/06/04 11:58:58 jonas
  2186. * calculate localsize also in g_return_from_proc since it's now called
  2187. before g_stackframe_entry (still have to fix macos)
  2188. * compilation fixes (cycle doesn't work yet though)
  2189. Revision 1.103 2003/06/01 21:38:06 peter
  2190. * getregisterfpu size parameter added
  2191. * op_const_reg size parameter added
  2192. * sparc updates
  2193. Revision 1.102 2003/06/01 13:42:18 jonas
  2194. * fix for bug in fixref that Peter found during the Sparc conversion
  2195. Revision 1.101 2003/05/30 18:52:10 jonas
  2196. * fixed bug with intregvars
  2197. * locapara.loc can also be LOC_CFPUREGISTER -> also fixed
  2198. rcgppc.a_param_ref, which previously got bogus size values
  2199. Revision 1.100 2003/05/29 21:17:27 jonas
  2200. * compile with -dppc603 to not use unaligned float loads in move() and
  2201. g_concatcopy, because the 603 and 604 take an exception for those
  2202. (and netbsd doesn't even handle those in the kernel). There are
  2203. still some of those left that could cause problems though (e.g.
  2204. in the set helpers)
  2205. Revision 1.99 2003/05/29 10:06:09 jonas
  2206. * also free temps in g_concatcopy if delsource is true
  2207. Revision 1.98 2003/05/28 23:58:18 jonas
  2208. * added missing initialization of rg.usedintin,byproc
  2209. * ppc now also saves/restores used fpu registers
  2210. * ncgcal doesn't add used registers to usedby/inproc anymore, except for
  2211. i386
  2212. Revision 1.97 2003/05/28 23:18:31 florian
  2213. * started to fix and clean up the sparc port
  2214. Revision 1.96 2003/05/24 11:59:42 jonas
  2215. * fixed integer typeconversion problems
  2216. Revision 1.95 2003/05/23 18:51:26 jonas
  2217. * fixed support for nested procedures and more parameters than those
  2218. which fit in registers (untested/probably not working: calling a
  2219. nested procedure from a deeper nested procedure)
  2220. Revision 1.94 2003/05/20 23:54:00 florian
  2221. + basic darwin support added
  2222. Revision 1.93 2003/05/15 22:14:42 florian
  2223. * fixed last commit, changing lastsaveintreg to r31 caused some strange problems
  2224. Revision 1.92 2003/05/15 21:37:00 florian
  2225. * sysv entry code saves r13 now as well
  2226. Revision 1.91 2003/05/15 19:39:09 florian
  2227. * fixed ppc compiler which was broken by Peter's changes
  2228. Revision 1.90 2003/05/12 18:43:50 jonas
  2229. * fixed g_concatcopy
  2230. Revision 1.89 2003/05/11 20:59:23 jonas
  2231. * fixed bug with large offsets in entrycode
  2232. Revision 1.88 2003/05/11 11:45:08 jonas
  2233. * fixed shifts
  2234. Revision 1.87 2003/05/11 11:07:33 jonas
  2235. * fixed optimizations in a_op_const_reg_reg()
  2236. Revision 1.86 2003/04/27 11:21:36 peter
  2237. * aktprocdef renamed to current_procinfo.procdef
  2238. * procinfo renamed to current_procinfo
  2239. * procinfo will now be stored in current_module so it can be
  2240. cleaned up properly
  2241. * gen_main_procsym changed to create_main_proc and release_main_proc
  2242. to also generate a tprocinfo structure
  2243. * fixed unit implicit initfinal
  2244. Revision 1.85 2003/04/26 22:56:11 jonas
  2245. * fix to a_op64_const_reg_reg
  2246. Revision 1.84 2003/04/26 16:08:41 jonas
  2247. * fixed g_flags2reg
  2248. Revision 1.83 2003/04/26 15:25:29 florian
  2249. * fixed cmp_reg_reg_reg, cmp operands were emitted in the wrong order
  2250. Revision 1.82 2003/04/25 20:55:34 florian
  2251. * stack frame calculations are now completly done using the code generator
  2252. routines instead of generating directly assembler so also large stack frames
  2253. are handle properly
  2254. Revision 1.81 2003/04/24 11:24:00 florian
  2255. * fixed several issues with nested procedures
  2256. Revision 1.80 2003/04/23 22:18:01 peter
  2257. * fixes to get rtl compiled
  2258. Revision 1.79 2003/04/23 12:35:35 florian
  2259. * fixed several issues with powerpc
  2260. + applied a patch from Jonas for nested function calls (PowerPC only)
  2261. * ...
  2262. Revision 1.78 2003/04/16 09:26:55 jonas
  2263. * assembler procedures now again get a stackframe if they have local
  2264. variables. No space is reserved for a function result however.
  2265. Also, the register parameters aren't automatically saved on the stack
  2266. anymore in assembler procedures.
  2267. Revision 1.77 2003/04/06 16:39:11 jonas
  2268. * don't generate entry/exit code for assembler procedures
  2269. Revision 1.76 2003/03/22 18:01:13 jonas
  2270. * fixed linux entry/exit code generation
  2271. Revision 1.75 2003/03/19 14:26:26 jonas
  2272. * fixed R_TOC bugs introduced by new register allocator conversion
  2273. Revision 1.74 2003/03/13 22:57:45 olle
  2274. * change in a_loadaddr_ref_reg
  2275. Revision 1.73 2003/03/12 22:43:38 jonas
  2276. * more powerpc and generic fixes related to the new register allocator
  2277. Revision 1.72 2003/03/11 21:46:24 jonas
  2278. * lots of new regallocator fixes, both in generic and ppc-specific code
  2279. (ppc compiler still can't compile the linux system unit though)
  2280. Revision 1.71 2003/02/19 22:00:16 daniel
  2281. * Code generator converted to new register notation
  2282. - Horribily outdated todo.txt removed
  2283. Revision 1.70 2003/01/13 17:17:50 olle
  2284. * changed global var access, TOC now contain pointers to globals
  2285. * fixed handling of function pointers
  2286. Revision 1.69 2003/01/09 22:00:53 florian
  2287. * fixed some PowerPC issues
  2288. Revision 1.68 2003/01/08 18:43:58 daniel
  2289. * Tregister changed into a record
  2290. Revision 1.67 2002/12/15 19:22:01 florian
  2291. * fixed some crashes and a rte 201
  2292. Revision 1.66 2002/11/28 10:55:16 olle
  2293. * macos: changing code gen for references to globals
  2294. Revision 1.65 2002/11/07 15:50:23 jonas
  2295. * fixed bctr(l) problems
  2296. Revision 1.64 2002/11/04 18:24:19 olle
  2297. * macos: globals are located in TOC and relative r2, instead of absolute
  2298. Revision 1.63 2002/10/28 22:24:28 olle
  2299. * macos entry/exit: only used registers are saved
  2300. - macos entry/exit: stackptr not saved in r31 anymore
  2301. * macos entry/exit: misc fixes
  2302. Revision 1.62 2002/10/19 23:51:48 olle
  2303. * macos stack frame size computing updated
  2304. + macos epilogue: control register now restored
  2305. * macos prologue and epilogue: fp reg now saved and restored
  2306. Revision 1.61 2002/10/19 12:50:36 olle
  2307. * reorganized prologue and epilogue routines
  2308. Revision 1.60 2002/10/02 21:49:51 florian
  2309. * all A_BL instructions replaced by calls to a_call_name
  2310. Revision 1.59 2002/10/02 13:24:58 jonas
  2311. * changed a_call_* so that no superfluous code is generated anymore
  2312. Revision 1.58 2002/09/17 18:54:06 jonas
  2313. * a_load_reg_reg() now has two size parameters: source and dest. This
  2314. allows some optimizations on architectures that don't encode the
  2315. register size in the register name.
  2316. Revision 1.57 2002/09/10 21:22:25 jonas
  2317. + added some internal errors
  2318. * fixed bug in sysv exit code
  2319. Revision 1.56 2002/09/08 20:11:56 jonas
  2320. * fixed TOpCmp2AsmCond array (some unsigned equivalents were wrong)
  2321. Revision 1.55 2002/09/08 13:03:26 jonas
  2322. * several large offset-related fixes
  2323. Revision 1.54 2002/09/07 17:54:58 florian
  2324. * first part of PowerPC fixes
  2325. Revision 1.53 2002/09/07 15:25:14 peter
  2326. * old logs removed and tabs fixed
  2327. Revision 1.52 2002/09/02 10:14:51 jonas
  2328. + a_call_reg()
  2329. * small fix in a_call_ref()
  2330. Revision 1.51 2002/09/02 06:09:02 jonas
  2331. * fixed range error
  2332. Revision 1.50 2002/09/01 21:04:49 florian
  2333. * several powerpc related stuff fixed
  2334. Revision 1.49 2002/09/01 12:09:27 peter
  2335. + a_call_reg, a_call_loc added
  2336. * removed exprasmlist references
  2337. Revision 1.48 2002/08/31 21:38:02 jonas
  2338. * fixed a_call_ref (it should load ctr, not lr)
  2339. Revision 1.47 2002/08/31 21:30:45 florian
  2340. * fixed several problems caused by Jonas' commit :)
  2341. Revision 1.46 2002/08/31 19:25:50 jonas
  2342. + implemented a_call_ref()
  2343. Revision 1.45 2002/08/18 22:16:14 florian
  2344. + the ppc gas assembler writer adds now registers aliases
  2345. to the assembler file
  2346. Revision 1.44 2002/08/17 18:23:53 florian
  2347. * some assembler writer bugs fixed
  2348. Revision 1.43 2002/08/17 09:23:49 florian
  2349. * first part of procinfo rewrite
  2350. Revision 1.42 2002/08/16 14:24:59 carl
  2351. * issameref() to test if two references are the same (then emit no opcodes)
  2352. + ret_in_reg to replace ret_in_acc
  2353. (fix some register allocation bugs at the same time)
  2354. + save_std_register now has an extra parameter which is the
  2355. usedinproc registers
  2356. Revision 1.41 2002/08/15 08:13:54 carl
  2357. - a_load_sym_ofs_reg removed
  2358. * loadvmt now calls loadaddr_ref_reg instead
  2359. Revision 1.40 2002/08/11 14:32:32 peter
  2360. * renamed current_library to objectlibrary
  2361. Revision 1.39 2002/08/11 13:24:18 peter
  2362. * saving of asmsymbols in ppu supported
  2363. * asmsymbollist global is removed and moved into a new class
  2364. tasmlibrarydata that will hold the info of a .a file which
  2365. corresponds with a single module. Added librarydata to tmodule
  2366. to keep the library info stored for the module. In the future the
  2367. objectfiles will also be stored to the tasmlibrarydata class
  2368. * all getlabel/newasmsymbol and friends are moved to the new class
  2369. Revision 1.38 2002/08/11 11:39:31 jonas
  2370. + powerpc-specific genlinearlist
  2371. Revision 1.37 2002/08/10 17:15:31 jonas
  2372. * various fixes and optimizations
  2373. Revision 1.36 2002/08/06 20:55:23 florian
  2374. * first part of ppc calling conventions fix
  2375. Revision 1.35 2002/08/06 07:12:05 jonas
  2376. * fixed bug in g_flags2reg()
  2377. * and yet more constant operation fixes :)
  2378. Revision 1.34 2002/08/05 08:58:53 jonas
  2379. * fixed compilation problems
  2380. Revision 1.33 2002/08/04 12:57:55 jonas
  2381. * more misc. fixes, mostly constant-related
  2382. }