cgcpu.pas 101 KB

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