123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481 |
- {
- $Id$
- Copyright (c) 1998-2002 by Florian Klaempfl
- This unit implements the code generator for the PowerPC
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- ****************************************************************************
- }
- unit cgcpu;
- {$i fpcdefs.inc}
- interface
- uses
- globtype,symtype,
- cgbase,cgobj,
- aasmbase,aasmcpu,aasmtai,
- cpubase,cpuinfo,node,cg64f32,rgcpu,
- parabase;
- type
- tcgppc = class(tcg)
- procedure init_register_allocators;override;
- procedure done_register_allocators;override;
- procedure ungetreference(list:Taasmoutput;const r:Treference);override;
- { passing parameters, per default the parameter is pushed }
- { nr gives the number of the parameter (enumerated from }
- { left to right), this allows to move the parameter to }
- { register, if the cpu supports register calling }
- { conventions }
- procedure a_param_const(list : taasmoutput;size : tcgsize;a : aint;const paraloc : tcgpara);override;
- procedure a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const paraloc : tcgpara);override;
- procedure a_paramaddr_ref(list : taasmoutput;const r : treference;const paraloc : tcgpara);override;
- procedure a_call_name(list : taasmoutput;const s : string);override;
- procedure a_call_reg(list : taasmoutput;reg: tregister); override;
- procedure a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister); override;
- procedure a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister); override;
- procedure a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
- size: tcgsize; a: aint; src, dst: tregister); override;
- procedure a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
- size: tcgsize; src1, src2, dst: tregister); override;
- { move instructions }
- procedure a_load_const_reg(list : taasmoutput; size: tcgsize; a : aint;reg : tregister);override;
- procedure a_load_reg_ref(list : taasmoutput; fromsize, tosize: tcgsize; reg : tregister;const ref : treference);override;
- procedure a_load_ref_reg(list : taasmoutput; fromsize, tosize : tcgsize;const Ref : treference;reg : tregister);override;
- procedure a_load_reg_reg(list : taasmoutput; fromsize, tosize : tcgsize;reg1,reg2 : tregister);override;
- { fpu move instructions }
- procedure a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister); override;
- procedure a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister); override;
- procedure a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference); override;
- { comparison operations }
- procedure a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
- l : tasmlabel);override;
- procedure a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;reg1,reg2 : tregister;l : tasmlabel); override;
- procedure a_jmp_name(list : taasmoutput;const s : string); override;
- procedure a_jmp_always(list : taasmoutput;l: tasmlabel); override;
- procedure a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel); override;
- procedure g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister); override;
- procedure g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);override;
- procedure g_proc_exit(list : taasmoutput;parasize : longint;nostackframe:boolean); override;
- procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);override;
- procedure g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint; delsource,loadref : boolean);override;
- procedure g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef); override;
- { find out whether a is of the form 11..00..11b or 00..11...00. If }
- { that's the case, we can use rlwinm to do an AND operation }
- function get_rlwi_const(a: aint; var l1, l2: longint): boolean;
- procedure g_save_standard_registers(list:Taasmoutput);override;
- procedure g_restore_standard_registers(list:Taasmoutput);override;
- procedure g_save_all_registers(list : taasmoutput);override;
- procedure g_restore_all_registers(list : taasmoutput;const funcretparaloc:tcgpara);override;
- procedure a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
- private
- (* NOT IN USE: *)
- procedure g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
- (* NOT IN USE: *)
- procedure g_return_from_proc_mac(list : taasmoutput;parasize : aint);
- { Make sure ref is a valid reference for the PowerPC and sets the }
- { base to the value of the index if (base = R_NO). }
- { Returns true if the reference contained a base, index and an }
- { offset or symbol, in which case the base will have been changed }
- { to a tempreg (which has to be freed by the caller) containing }
- { the sum of part of the original reference }
- function fixref(list: taasmoutput; var ref: treference): boolean;
- { returns whether a reference can be used immediately in a powerpc }
- { instruction }
- function issimpleref(const ref: treference): boolean;
- { contains the common code of a_load_reg_ref and a_load_ref_reg }
- procedure a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
- ref: treference);
- { creates the correct branch instruction for a given combination }
- { of asmcondflags and destination addressing mode }
- procedure a_jmp(list: taasmoutput; op: tasmop;
- c: tasmcondflag; crval: longint; l: tasmlabel);
- function save_regs(list : taasmoutput):longint;
- procedure restore_regs(list : taasmoutput);
- function get_darwin_call_stub(const s: string): tasmsymbol;
- end;
- tcg64fppc = class(tcg64f32)
- procedure a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);override;
- procedure a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);override;
- procedure a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64;regsrc,regdst : tregister64);override;
- procedure a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);override;
- end;
- const
- TOpCG2AsmOpConstLo: Array[topcg] of TAsmOp = (A_NONE,A_ADDI,A_ANDI_,A_DIVWU,
- A_DIVW,A_MULLW, A_MULLW, A_NONE,A_NONE,A_ORI,
- A_SRAWI,A_SLWI,A_SRWI,A_SUBI,A_XORI);
- TOpCG2AsmOpConstHi: Array[topcg] of TAsmOp = (A_NONE,A_ADDIS,A_ANDIS_,
- A_DIVWU,A_DIVW, A_MULLW,A_MULLW,A_NONE,A_NONE,
- A_ORIS,A_NONE, A_NONE,A_NONE,A_SUBIS,A_XORIS);
- TOpCmp2AsmCond: Array[topcmp] of TAsmCondFlag = (C_NONE,C_EQ,C_GT,
- C_LT,C_GE,C_LE,C_NE,C_LE,C_LT,C_GE,C_GT);
- implementation
- uses
- globals,verbose,systems,cutils,
- symconst,symdef,symsym,
- rgobj,tgobj,cpupi,procinfo,paramgr,
- cgutils;
- procedure tcgppc.init_register_allocators;
- begin
- inherited init_register_allocators;
- if target_info.system=system_powerpc_darwin then
- begin
- if pi_needs_got in current_procinfo.flags then
- begin
- current_procinfo.got:=NR_R31;
- rg[R_INTREGISTER]:=trgcpu.create(R_INTREGISTER,R_SUBWHOLE,
- [RS_R3,RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,
- RS_R9,RS_R10,RS_R11,RS_R12,RS_R30,RS_R29,
- RS_R28,RS_R27,RS_R26,RS_R25,RS_R24,RS_R23,RS_R22,
- RS_R21,RS_R20,RS_R19,RS_R18,RS_R17,RS_R16,RS_R15,
- RS_R14,RS_R13],first_int_imreg,[]);
- end
- else
- rg[R_INTREGISTER]:=trgcpu.create(R_INTREGISTER,R_SUBWHOLE,
- [RS_R3,RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,
- RS_R9,RS_R10,RS_R11,RS_R12,RS_R31,RS_R30,RS_R29,
- RS_R28,RS_R27,RS_R26,RS_R25,RS_R24,RS_R23,RS_R22,
- RS_R21,RS_R20,RS_R19,RS_R18,RS_R17,RS_R16,RS_R15,
- RS_R14,RS_R13],first_int_imreg,[]);
- end
- else
- rg[R_INTREGISTER]:=trgcpu.create(R_INTREGISTER,R_SUBWHOLE,
- [RS_R3,RS_R4,RS_R5,RS_R6,RS_R7,RS_R8,
- RS_R9,RS_R10,RS_R11,RS_R12,RS_R31,RS_R30,RS_R29,
- RS_R28,RS_R27,RS_R26,RS_R25,RS_R24,RS_R23,RS_R22,
- RS_R21,RS_R20,RS_R19,RS_R18,RS_R17,RS_R16,RS_R15,
- RS_R14,RS_R13],first_int_imreg,[]);
- case target_info.abi of
- abi_powerpc_aix:
- rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
- [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,RS_F9,
- RS_F10,RS_F11,RS_F12,RS_F13,RS_F31,RS_F30,RS_F29,RS_F28,RS_F27,
- RS_F26,RS_F25,RS_F24,RS_F23,RS_F22,RS_F21,RS_F20,RS_F19,RS_F18,
- RS_F17,RS_F16,RS_F15,RS_F14],first_fpu_imreg,[]);
- abi_powerpc_sysv:
- rg[R_FPUREGISTER]:=trgcpu.create(R_FPUREGISTER,R_SUBNONE,
- [RS_F0,RS_F1,RS_F2,RS_F3,RS_F4,RS_F5,RS_F6,RS_F7,RS_F8,RS_F9,
- RS_F31,RS_F30,RS_F29,RS_F28,RS_F27,RS_F26,RS_F25,RS_F24,RS_F23,
- RS_F22,RS_F21,RS_F20,RS_F19,RS_F18,RS_F17,RS_F16,RS_F15,RS_F14,
- RS_F13,RS_F12,RS_F11,RS_F10],first_fpu_imreg,[]);
- else
- internalerror(2003122903);
- end;
- {$warning FIX ME}
- rg[R_MMREGISTER]:=trgcpu.create(R_MMREGISTER,R_SUBNONE,
- [RS_M0,RS_M1,RS_M2],first_mm_imreg,[]);
- end;
- procedure tcgppc.done_register_allocators;
- begin
- rg[R_INTREGISTER].free;
- rg[R_FPUREGISTER].free;
- rg[R_MMREGISTER].free;
- inherited done_register_allocators;
- end;
- procedure tcgppc.ungetreference(list:Taasmoutput;const r:Treference);
- begin
- if r.base<>NR_NO then
- ungetregister(list,r.base);
- if r.index<>NR_NO then
- ungetregister(list,r.index);
- end;
- procedure tcgppc.a_param_const(list : taasmoutput;size : tcgsize;a : aint;const paraloc : tcgpara);
- var
- ref: treference;
- begin
- paraloc.check_simple_location;
- case paraloc.location^.loc of
- LOC_REGISTER,LOC_CREGISTER:
- a_load_const_reg(list,size,a,paraloc.location^.register);
- LOC_REFERENCE:
- begin
- reference_reset(ref);
- ref.base:=paraloc.location^.reference.index;
- ref.offset:=paraloc.location^.reference.offset;
- a_load_const_ref(list,size,a,ref);
- end;
- else
- internalerror(2002081101);
- end;
- end;
- procedure tcgppc.a_param_ref(list : taasmoutput;size : tcgsize;const r : treference;const paraloc : tcgpara);
- var
- ref: treference;
- tmpreg: tregister;
- begin
- paraloc.check_simple_location;
- case paraloc.location^.loc of
- LOC_REGISTER,LOC_CREGISTER:
- a_load_ref_reg(list,size,size,r,paraloc.location^.register);
- LOC_REFERENCE:
- begin
- reference_reset(ref);
- ref.base:=paraloc.location^.reference.index;
- ref.offset:=paraloc.location^.reference.offset;
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_ref_reg(list,size,size,r,tmpreg);
- a_load_reg_ref(list,size,size,tmpreg,ref);
- rg[R_INTREGISTER].ungetregister(list,tmpreg);
- end;
- LOC_FPUREGISTER,LOC_CFPUREGISTER:
- case size of
- OS_F32, OS_F64:
- a_loadfpu_ref_reg(list,size,r,paraloc.location^.register);
- else
- internalerror(2002072801);
- end;
- else
- internalerror(2002081103);
- end;
- end;
- procedure tcgppc.a_paramaddr_ref(list : taasmoutput;const r : treference;const paraloc : tcgpara);
- var
- ref: treference;
- tmpreg: tregister;
- begin
- paraloc.check_simple_location;
- case paraloc.location^.loc of
- LOC_REGISTER,LOC_CREGISTER:
- a_loadaddr_ref_reg(list,r,paraloc.location^.register);
- LOC_REFERENCE:
- begin
- reference_reset(ref);
- ref.base := paraloc.location^.reference.index;
- ref.offset := paraloc.location^.reference.offset;
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_loadaddr_ref_reg(list,r,tmpreg);
- a_load_reg_ref(list,OS_ADDR,OS_ADDR,tmpreg,ref);
- rg[R_INTREGISTER].ungetregister(list,tmpreg);
- end;
- else
- internalerror(2002080701);
- end;
- end;
- function tcgppc.get_darwin_call_stub(const s: string): tasmsymbol;
- var
- stubname: string;
- href: treference;
- l1: tasmsymbol;
- begin
- { function declared in the current unit? }
- result := objectlibrary.getasmsymbol(s);
- if not(assigned(result)) then
- begin
- stubname := 'L'+s+'$stub';
- result := objectlibrary.getasmsymbol(stubname);
- end;
- if assigned(result) then
- exit;
- if not(assigned(importssection)) then
- importssection:=TAAsmoutput.create;
- importsSection.concat(Tai_section.Create(sec_data,'',0));
- importsSection.concat(Tai_direct.create(strpnew('.section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16')));
- importsSection.concat(Tai_align.Create(4));
- result := objectlibrary.newasmsymbol(stubname,AB_EXTERNAL,AT_FUNCTION);
- importsSection.concat(Tai_symbol.Create(result,0));
- importsSection.concat(Tai_direct.create(strpnew((#9+'.indirect_symbol ')+s)));
- l1 := objectlibrary.newasmsymbol('L'+s+'$lazy_ptr',AB_EXTERNAL,AT_FUNCTION);
- reference_reset_symbol(href,l1,0);
- {$ifdef powerpc}
- href.refaddr := addr_hi;
- importsSection.concat(taicpu.op_reg_ref(A_LIS,NR_R11,href));
- href.refaddr := addr_lo;
- href.base := NR_R11;
- importsSection.concat(taicpu.op_reg_ref(A_LWZU,NR_R12,href));
- importsSection.concat(taicpu.op_reg(A_MTCTR,NR_R12));
- importsSection.concat(taicpu.op_none(A_BCTR));
- {$else powerpc}
- internalerror(2004010502);
- {$endif powerpc}
- importsSection.concat(Tai_section.Create(sec_data,'',0));
- importsSection.concat(Tai_direct.create(strpnew('.lazy_symbol_pointer')));
- importsSection.concat(Tai_symbol.Create(l1,0));
- importsSection.concat(Tai_direct.create(strpnew((#9+'.indirect_symbol ')+s)));
- importsSection.concat(tai_const.createname(strpnew('dyld_stub_binding_helper'),AT_FUNCTION,0));
- end;
- { calling a procedure by name }
- procedure tcgppc.a_call_name(list : taasmoutput;const s : string);
- var
- href : treference;
- begin
- { MacOS: The linker on MacOS (PPCLink) inserts a call to glue code,
- if it is a cross-TOC call. If so, it also replaces the NOP
- with some restore code.}
- if (target_info.system <> system_powerpc_darwin) then
- begin
- list.concat(taicpu.op_sym(A_BL,objectlibrary.newasmsymbol(s,AB_EXTERNAL,AT_FUNCTION)));
- if target_info.system=system_powerpc_macos then
- list.concat(taicpu.op_none(A_NOP));
- end
- else
- begin
- list.concat(taicpu.op_sym(A_BL,get_darwin_call_stub(s)));
- end;
- if not(pi_do_call in current_procinfo.flags) then
- internalerror(2003060703);
- end;
- { calling a procedure by address }
- procedure tcgppc.a_call_reg(list : taasmoutput;reg: tregister);
- var
- tmpreg : tregister;
- tmpref : treference;
- begin
- if target_info.system=system_powerpc_macos then
- begin
- {Generate instruction to load the procedure address from
- the transition vector.}
- //TODO: Support cross-TOC calls.
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- reference_reset(tmpref);
- tmpref.offset := 0;
- //tmpref.symaddr := refs_full;
- tmpref.base:= reg;
- list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
- list.concat(taicpu.op_reg(A_MTCTR,tmpreg));
- rg[R_INTREGISTER].ungetregister(list,tmpreg);
- end
- else
- list.concat(taicpu.op_reg(A_MTCTR,reg));
- list.concat(taicpu.op_none(A_BCTRL));
- //if target_info.system=system_powerpc_macos then
- // //NOP is not needed here.
- // list.concat(taicpu.op_none(A_NOP));
- if not(pi_do_call in current_procinfo.flags) then
- internalerror(2003060704);
- //list.concat(tai_comment.create(strpnew('***** a_call_reg')));
- end;
- {********************** load instructions ********************}
- procedure tcgppc.a_load_const_reg(list : taasmoutput; size: TCGSize; a : aint; reg : TRegister);
- begin
- if not(size in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
- internalerror(2002090902);
- if (a >= low(smallint)) and
- (a <= high(smallint)) then
- list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a)))
- else if ((a and $ffff) <> 0) then
- begin
- list.concat(taicpu.op_reg_const(A_LI,reg,smallint(a and $ffff)));
- if ((a shr 16) <> 0) or
- (smallint(a and $ffff) < 0) then
- list.concat(taicpu.op_reg_reg_const(A_ADDIS,reg,reg,
- smallint((a shr 16)+ord(smallint(a and $ffff) < 0))))
- end
- else
- list.concat(taicpu.op_reg_const(A_LIS,reg,smallint(a shr 16)));
- end;
- procedure tcgppc.a_load_reg_ref(list : taasmoutput; fromsize, tosize: TCGSize; reg : tregister;const ref : treference);
- const
- StoreInstr: Array[OS_8..OS_32,boolean, boolean] of TAsmOp =
- { indexed? updating?}
- (((A_STB,A_STBU),(A_STBX,A_STBUX)),
- ((A_STH,A_STHU),(A_STHX,A_STHUX)),
- ((A_STW,A_STWU),(A_STWX,A_STWUX)));
- var
- op: TAsmOp;
- ref2: TReference;
- freereg: boolean;
- begin
- ref2 := ref;
- freereg := fixref(list,ref2);
- if tosize in [OS_S8..OS_S16] then
- { storing is the same for signed and unsigned values }
- tosize := tcgsize(ord(tosize)-(ord(OS_S8)-ord(OS_8)));
- { 64 bit stuff should be handled separately }
- if tosize in [OS_64,OS_S64] then
- internalerror(200109236);
- op := storeinstr[tcgsize2unsigned[tosize],ref2.index<>NR_NO,false];
- a_load_store(list,op,reg,ref2);
- if freereg then
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- End;
- procedure tcgppc.a_load_ref_reg(list : taasmoutput; fromsize,tosize : tcgsize;const ref: treference;reg : tregister);
- const
- LoadInstr: Array[OS_8..OS_S32,boolean, boolean] of TAsmOp =
- { indexed? updating?}
- (((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
- ((A_LHZ,A_LHZU),(A_LHZX,A_LHZUX)),
- ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)),
- { 64bit stuff should be handled separately }
- ((A_NONE,A_NONE),(A_NONE,A_NONE)),
- { 128bit stuff too }
- ((A_NONE,A_NONE),(A_NONE,A_NONE)),
- { there's no load-byte-with-sign-extend :( }
- ((A_LBZ,A_LBZU),(A_LBZX,A_LBZUX)),
- ((A_LHA,A_LHAU),(A_LHAX,A_LHAUX)),
- ((A_LWZ,A_LWZU),(A_LWZX,A_LWZUX)));
- var
- op: tasmop;
- tmpreg: tregister;
- ref2, tmpref: treference;
- freereg: boolean;
- begin
- { TODO: optimize/take into consideration fromsize/tosize. Will }
- { probably only matter for OS_S8 loads though }
- if not(fromsize in [OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32]) then
- internalerror(2002090902);
- ref2 := ref;
- freereg := fixref(list,ref2);
- { the caller is expected to have adjusted the reference already }
- { in this case }
- if (TCGSize2Size[fromsize] >= TCGSize2Size[tosize]) then
- fromsize := tosize;
- op := loadinstr[fromsize,ref2.index<>NR_NO,false];
- a_load_store(list,op,reg,ref2);
- if freereg then
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- { sign extend shortint if necessary, since there is no }
- { load instruction that does that automatically (JM) }
- if fromsize = OS_S8 then
- list.concat(taicpu.op_reg_reg(A_EXTSB,reg,reg));
- end;
- procedure tcgppc.a_load_reg_reg(list : taasmoutput;fromsize, tosize : tcgsize;reg1,reg2 : tregister);
- var
- instr: taicpu;
- begin
- case tosize of
- OS_8:
- instr := taicpu.op_reg_reg_const_const_const(A_RLWINM,
- reg2,reg1,0,31-8+1,31);
- OS_S8:
- instr := taicpu.op_reg_reg(A_EXTSB,reg2,reg1);
- OS_16:
- instr := taicpu.op_reg_reg_const_const_const(A_RLWINM,
- reg2,reg1,0,31-16+1,31);
- OS_S16:
- instr := taicpu.op_reg_reg(A_EXTSH,reg2,reg1);
- OS_32,OS_S32:
- instr := taicpu.op_reg_reg(A_MR,reg2,reg1);
- else internalerror(2002090901);
- end;
- list.concat(instr);
- rg[R_INTREGISTER].add_move_instruction(instr);
- end;
- procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; reg1, reg2: tregister);
- var
- instr: taicpu;
- begin
- instr := taicpu.op_reg_reg(A_FMR,reg2,reg1);
- list.concat(instr);
- rg[R_FPUREGISTER].add_move_instruction(instr);
- end;
- procedure tcgppc.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; const ref: treference; reg: tregister);
- const
- FpuLoadInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
- { indexed? updating?}
- (((A_LFS,A_LFSU),(A_LFSX,A_LFSUX)),
- ((A_LFD,A_LFDU),(A_LFDX,A_LFDUX)));
- var
- op: tasmop;
- ref2: treference;
- freereg: boolean;
- begin
- { several functions call this procedure with OS_32 or OS_64 }
- { so this makes life easier (FK) }
- case size of
- OS_32,OS_F32:
- size:=OS_F32;
- OS_64,OS_F64,OS_C64:
- size:=OS_F64;
- else
- internalerror(200201121);
- end;
- ref2 := ref;
- freereg := fixref(list,ref2);
- op := fpuloadinstr[size,ref2.index <> NR_NO,false];
- a_load_store(list,op,reg,ref2);
- if freereg then
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- end;
- procedure tcgppc.a_loadfpu_reg_ref(list: taasmoutput; size: tcgsize; reg: tregister; const ref: treference);
- const
- FpuStoreInstr: Array[OS_F32..OS_F64,boolean, boolean] of TAsmOp =
- { indexed? updating?}
- (((A_STFS,A_STFSU),(A_STFSX,A_STFSUX)),
- ((A_STFD,A_STFDU),(A_STFDX,A_STFDUX)));
- var
- op: tasmop;
- ref2: treference;
- freereg: boolean;
- begin
- if not(size in [OS_F32,OS_F64]) then
- internalerror(200201122);
- ref2 := ref;
- freereg := fixref(list,ref2);
- op := fpustoreinstr[size,ref2.index <> NR_NO,false];
- a_load_store(list,op,reg,ref2);
- if freereg then
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- end;
- procedure tcgppc.a_op_const_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; a: aint; reg: TRegister);
- begin
- a_op_const_reg_reg(list,op,size,a,reg,reg);
- end;
- procedure tcgppc.a_op_reg_reg(list : taasmoutput; Op: TOpCG; size: TCGSize; src, dst: TRegister);
- begin
- a_op_reg_reg_reg(list,op,size,src,dst,dst);
- end;
- procedure tcgppc.a_op_const_reg_reg(list: taasmoutput; op: TOpCg;
- size: tcgsize; a: aint; src, dst: tregister);
- var
- l1,l2: longint;
- oplo, ophi: tasmop;
- scratchreg: tregister;
- useReg, gotrlwi: boolean;
- procedure do_lo_hi;
- begin
- list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
- list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,word(a shr 16)));
- end;
- begin
- if op = OP_SUB then
- begin
- a_op_const_reg_reg(list,OP_ADD,size,-a,src,dst);
- exit;
- end;
- ophi := TOpCG2AsmOpConstHi[op];
- oplo := TOpCG2AsmOpConstLo[op];
- gotrlwi := get_rlwi_const(a,l1,l2);
- if (op in [OP_AND,OP_OR,OP_XOR]) then
- begin
- if (a = 0) then
- begin
- if op = OP_AND then
- list.concat(taicpu.op_reg_const(A_LI,dst,0))
- else
- a_load_reg_reg(list,size,size,src,dst);
- exit;
- end
- else if (a = -1) then
- begin
- case op of
- OP_OR:
- list.concat(taicpu.op_reg_const(A_LI,dst,-1));
- OP_XOR:
- list.concat(taicpu.op_reg_reg(A_NOT,dst,src));
- OP_AND:
- a_load_reg_reg(list,size,size,src,dst);
- end;
- exit;
- end
- else if (aword(a) <= high(word)) and
- ((op <> OP_AND) or
- not gotrlwi) then
- begin
- list.concat(taicpu.op_reg_reg_const(oplo,dst,src,word(a)));
- exit;
- end;
- { all basic constant instructions also have a shifted form that }
- { works only on the highest 16bits, so if lo(a) is 0, we can }
- { use that one }
- if (word(a) = 0) and
- (not(op = OP_AND) or
- not gotrlwi) then
- begin
- list.concat(taicpu.op_reg_reg_const(ophi,dst,src,word(a shr 16)));
- exit;
- end;
- end
- else if (op = OP_ADD) then
- if a = 0 then
- begin
- a_load_reg_reg(list,size,size,src,dst);
- exit
- end
- else if (a >= low(smallint)) and
- (a <= high(smallint)) then
- begin
- list.concat(taicpu.op_reg_reg_const(A_ADDI,dst,src,smallint(a)));
- exit;
- end;
- { otherwise, the instructions we can generate depend on the }
- { operation }
- useReg := false;
- case op of
- OP_DIV,OP_IDIV:
- if (a = 0) then
- internalerror(200208103)
- else if (a = 1) then
- begin
- a_load_reg_reg(list,OS_INT,OS_INT,src,dst);
- exit
- end
- else if ispowerof2(a,l1) then
- begin
- case op of
- OP_DIV:
- list.concat(taicpu.op_reg_reg_const(A_SRWI,dst,src,l1));
- OP_IDIV:
- begin
- list.concat(taicpu.op_reg_reg_const(A_SRAWI,dst,src,l1));
- list.concat(taicpu.op_reg_reg(A_ADDZE,dst,dst));
- end;
- end;
- exit;
- end
- else
- usereg := true;
- OP_IMUL, OP_MUL:
- if (a = 0) then
- begin
- list.concat(taicpu.op_reg_const(A_LI,dst,0));
- exit
- end
- else if (a = 1) then
- begin
- a_load_reg_reg(list,OS_INT,OS_INT,src,dst);
- exit
- end
- else if ispowerof2(a,l1) then
- list.concat(taicpu.op_reg_reg_const(A_SLWI,dst,src,l1))
- else if (longint(a) >= low(smallint)) and
- (longint(a) <= high(smallint)) then
- list.concat(taicpu.op_reg_reg_const(A_MULLI,dst,src,smallint(a)))
- else
- usereg := true;
- OP_ADD:
- begin
- list.concat(taicpu.op_reg_reg_const(oplo,dst,src,smallint(a)));
- list.concat(taicpu.op_reg_reg_const(ophi,dst,dst,
- smallint((a shr 16) + ord(smallint(a) < 0))));
- end;
- OP_OR:
- { try to use rlwimi }
- if gotrlwi and
- (src = dst) then
- begin
- scratchreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- list.concat(taicpu.op_reg_const(A_LI,scratchreg,-1));
- list.concat(taicpu.op_reg_reg_const_const_const(A_RLWIMI,dst,
- scratchreg,0,l1,l2));
- rg[R_INTREGISTER].ungetregister(list,scratchreg);
- end
- else
- do_lo_hi;
- OP_AND:
- { try to use rlwinm }
- if gotrlwi then
- list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,dst,
- src,0,l1,l2))
- else
- useReg := true;
- OP_XOR:
- do_lo_hi;
- OP_SHL,OP_SHR,OP_SAR:
- begin
- if (a and 31) <> 0 Then
- list.concat(taicpu.op_reg_reg_const(
- TOpCG2AsmOpConstLo[Op],dst,src,a and 31))
- else
- a_load_reg_reg(list,size,size,src,dst);
- if (a shr 5) <> 0 then
- internalError(68991);
- end
- else
- internalerror(200109091);
- end;
- { if all else failed, load the constant in a register and then }
- { perform the operation }
- if useReg then
- begin
- scratchreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_const_reg(list,OS_32,a,scratchreg);
- a_op_reg_reg_reg(list,op,OS_32,scratchreg,src,dst);
- rg[R_INTREGISTER].ungetregister(list,scratchreg);
- end;
- end;
- procedure tcgppc.a_op_reg_reg_reg(list: taasmoutput; op: TOpCg;
- size: tcgsize; src1, src2, dst: tregister);
- const
- op_reg_reg_opcg2asmop: array[TOpCG] of tasmop =
- (A_NONE,A_ADD,A_AND,A_DIVWU,A_DIVW,A_MULLW,A_MULLW,A_NEG,A_NOT,A_OR,
- A_SRAW,A_SLW,A_SRW,A_SUB,A_XOR);
- begin
- case op of
- OP_NEG,OP_NOT:
- begin
- list.concat(taicpu.op_reg_reg(op_reg_reg_opcg2asmop[op],dst,src1));
- if (op = OP_NOT) and
- not(size in [OS_32,OS_S32]) then
- { zero/sign extend result again }
- a_load_reg_reg(list,OS_32,size,dst,dst);
- end;
- else
- list.concat(taicpu.op_reg_reg_reg(op_reg_reg_opcg2asmop[op],dst,src2,src1));
- end;
- end;
- {*************** compare instructructions ****************}
- procedure tcgppc.a_cmp_const_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;a : aint;reg : tregister;
- l : tasmlabel);
- var
- p: taicpu;
- scratch_register: TRegister;
- signed: boolean;
- begin
- signed := cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE];
- { in the following case, we generate more efficient code when }
- { signed is true }
- if (cmp_op in [OC_EQ,OC_NE]) and
- (aword(a) > $ffff) then
- signed := true;
- if signed then
- if (a >= low(smallint)) and (a <= high(smallint)) Then
- list.concat(taicpu.op_reg_reg_const(A_CMPWI,NR_CR0,reg,a))
- else
- begin
- scratch_register := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_const_reg(list,OS_32,a,scratch_register);
- list.concat(taicpu.op_reg_reg_reg(A_CMPW,NR_CR0,reg,scratch_register));
- rg[R_INTREGISTER].ungetregister(list,scratch_register);
- end
- else
- if (aword(a) <= $ffff) then
- list.concat(taicpu.op_reg_reg_const(A_CMPLWI,NR_CR0,reg,aword(a)))
- else
- begin
- scratch_register := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_const_reg(list,OS_32,a,scratch_register);
- list.concat(taicpu.op_reg_reg_reg(A_CMPLW,NR_CR0,reg,scratch_register));
- rg[R_INTREGISTER].ungetregister(list,scratch_register);
- end;
- a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
- end;
- procedure tcgppc.a_cmp_reg_reg_label(list : taasmoutput;size : tcgsize;cmp_op : topcmp;
- reg1,reg2 : tregister;l : tasmlabel);
- var
- p: taicpu;
- op: tasmop;
- begin
- if cmp_op in [OC_GT,OC_LT,OC_GTE,OC_LTE] then
- op := A_CMPW
- else
- op := A_CMPLW;
- list.concat(taicpu.op_reg_reg_reg(op,NR_CR0,reg2,reg1));
- a_jmp(list,A_BC,TOpCmp2AsmCond[cmp_op],0,l);
- end;
- procedure tcgppc.g_save_standard_registers(list:Taasmoutput);
- begin
- {$warning FIX ME}
- end;
- procedure tcgppc.g_restore_standard_registers(list:Taasmoutput);
- begin
- {$warning FIX ME}
- end;
- procedure tcgppc.g_save_all_registers(list : taasmoutput);
- begin
- {$warning FIX ME}
- end;
- procedure tcgppc.g_restore_all_registers(list : taasmoutput;const funcretparaloc:tcgpara);
- begin
- {$warning FIX ME}
- end;
- procedure tcgppc.a_jmp_cond(list : taasmoutput;cond : TOpCmp;l: tasmlabel);
- begin
- a_jmp(list,A_BC,TOpCmp2AsmCond[cond],0,l);
- end;
- procedure tcgppc.a_jmp_name(list : taasmoutput;const s : string);
- var
- p : taicpu;
- begin
- p := taicpu.op_sym(A_B,objectlibrary.newasmsymbol(s,AB_EXTERNAL,AT_FUNCTION));
- p.is_jmp := true;
- list.concat(p)
- end;
- procedure tcgppc.a_jmp_always(list : taasmoutput;l: tasmlabel);
- begin
- a_jmp(list,A_B,C_None,0,l);
- end;
- procedure tcgppc.a_jmp_flags(list : taasmoutput;const f : TResFlags;l: tasmlabel);
- var
- c: tasmcond;
- begin
- c := flags_to_cond(f);
- a_jmp(list,A_BC,c.cond,c.cr-RS_CR0,l);
- end;
- procedure tcgppc.g_flags2reg(list: taasmoutput; size: TCgSize; const f: TResFlags; reg: TRegister);
- var
- testbit: byte;
- bitvalue: boolean;
- begin
- { get the bit to extract from the conditional register + its }
- { requested value (0 or 1) }
- testbit := ((f.cr-RS_CR0) * 4);
- case f.flag of
- F_EQ,F_NE:
- begin
- inc(testbit,2);
- bitvalue := f.flag = F_EQ;
- end;
- F_LT,F_GE:
- begin
- bitvalue := f.flag = F_LT;
- end;
- F_GT,F_LE:
- begin
- inc(testbit);
- bitvalue := f.flag = F_GT;
- end;
- else
- internalerror(200112261);
- end;
- { load the conditional register in the destination reg }
- list.concat(taicpu.op_reg(A_MFCR,reg));
- { we will move the bit that has to be tested to bit 0 by rotating }
- { left }
- testbit := (testbit + 1) and 31;
- { extract bit }
- list.concat(taicpu.op_reg_reg_const_const_const(
- A_RLWINM,reg,reg,testbit,31,31));
- { if we need the inverse, xor with 1 }
- if not bitvalue then
- list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
- end;
- (*
- procedure tcgppc.g_cond2reg(list: taasmoutput; const f: TAsmCond; reg: TRegister);
- var
- testbit: byte;
- bitvalue: boolean;
- begin
- { get the bit to extract from the conditional register + its }
- { requested value (0 or 1) }
- case f.simple of
- false:
- begin
- { we don't generate this in the compiler }
- internalerror(200109062);
- end;
- true:
- case f.cond of
- C_None:
- internalerror(200109063);
- C_LT..C_NU:
- begin
- testbit := (ord(f.cr) - ord(R_CR0))*4;
- inc(testbit,AsmCondFlag2BI[f.cond]);
- bitvalue := AsmCondFlagTF[f.cond];
- end;
- C_T,C_F,C_DNZT,C_DNZF,C_DZT,C_DZF:
- begin
- testbit := f.crbit
- bitvalue := AsmCondFlagTF[f.cond];
- end;
- else
- internalerror(200109064);
- end;
- end;
- { load the conditional register in the destination reg }
- list.concat(taicpu.op_reg_reg(A_MFCR,reg));
- { we will move the bit that has to be tested to bit 31 -> rotate }
- { left by bitpos+1 (remember, this is big-endian!) }
- if bitpos <> 31 then
- inc(bitpos)
- else
- bitpos := 0;
- { extract bit }
- list.concat(taicpu.op_reg_reg_const_const_const(
- A_RLWINM,reg,reg,bitpos,31,31));
- { if we need the inverse, xor with 1 }
- if not bitvalue then
- list.concat(taicpu.op_reg_reg_const(A_XORI,reg,reg,1));
- end;
- *)
- { *********** entry/exit code and address loading ************ }
- procedure tcgppc.g_proc_entry(list : taasmoutput;localsize : longint;nostackframe:boolean);
- { generated the entry code of a procedure/function. Note: localsize is the }
- { sum of the size necessary for local variables and the maximum possible }
- { combined size of ALL the parameters of a procedure called by the current }
- { one. }
- { This procedure may be called before, as well as after g_return_from_proc }
- { is called. NOTE registers are not to be allocated through the register }
- { allocator here, because the register colouring has already occured !! }
- var regcounter,firstregfpu,firstreggpr: TSuperRegister;
- href,href2 : treference;
- usesfpr,usesgpr,gotgot : boolean;
- parastart : aint;
- l : tasmlabel;
- regcounter2, firstfpureg: Tsuperregister;
- hp: tparaitem;
- cond : tasmcond;
- instr : taicpu;
- size: tcgsize;
- begin
- { CR and LR only have to be saved in case they are modified by the current }
- { procedure, but currently this isn't checked, so save them always }
- { following is the entry code as described in "Altivec Programming }
- { Interface Manual", bar the saving of AltiVec registers }
- a_reg_alloc(list,NR_STACK_POINTER_REG);
- a_reg_alloc(list,NR_R0);
- if current_procinfo.procdef.parast.symtablelevel>1 then
- a_reg_alloc(list,NR_R11);
- usesfpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
- case target_info.abi of
- abi_powerpc_aix:
- firstfpureg := RS_F14;
- abi_powerpc_sysv:
- firstfpureg := RS_F9;
- else
- internalerror(2003122903);
- end;
- for regcounter:=firstfpureg to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- usesfpr:= true;
- firstregfpu:=regcounter;
- break;
- end;
- end;
- usesgpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- firstreggpr:=regcounter2;
- break;
- end;
- end;
- { save link register? }
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- if (pi_do_call in current_procinfo.flags) then
- begin
- { save return address... }
- list.concat(taicpu.op_reg(A_MFLR,NR_R0));
- { ... in caller's frame }
- case target_info.abi of
- abi_powerpc_aix:
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX);
- abi_powerpc_sysv:
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
- end;
- list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
- a_reg_dealloc(list,NR_R0);
- end;
- { save the CR if necessary in callers frame. }
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- if target_info.abi = abi_powerpc_aix then
- if false then { Not needed at the moment. }
- begin
- a_reg_alloc(list,NR_R0);
- list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_CR));
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
- list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
- a_reg_dealloc(list,NR_R0);
- end;
- { !!! always allocate space for all registers for now !!! }
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- { if usesfpr or usesgpr then }
- begin
- a_reg_alloc(list,NR_R12);
- { save end of fpr save area }
- list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
- end;
- if (localsize <> 0) then
- begin
- if (localsize <= high(smallint)) then
- begin
- reference_reset_base(href,NR_STACK_POINTER_REG,-localsize);
- a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
- end
- else
- begin
- reference_reset_base(href,NR_STACK_POINTER_REG,0);
- { can't use getregisterint here, the register colouring }
- { is already done when we get here }
- href.index := NR_R11;
- a_reg_alloc(list,href.index);
- a_load_const_reg(list,OS_S32,-localsize,href.index);
- a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
- a_reg_dealloc(list,href.index);
- end;
- end;
- { no GOT pointer loaded yet }
- gotgot:=false;
- if usesfpr then
- begin
- { save floating-point registers
- if (cs_create_pic in aktmoduleswitches) and not(usesgpr) then
- begin
- a_call_name(objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+'_g',AB_EXTERNAL,AT_FUNCTION));
- gotgot:=true;
- end
- else
- a_call_name(objectlibrary.newasmsymbol('_savefpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14),AB_EXTERNAL,AT_FUNCTION));
- }
- reference_reset_base(href,NR_R12,-8);
- for regcounter:=firstregfpu to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- a_loadfpu_reg_ref(list,OS_F64,newreg(R_FPUREGISTER,regcounter,R_SUBNONE),href);
- dec(href.offset,8);
- end;
- end;
- { compute end of gpr save area }
- a_op_const_reg(list,OP_ADD,OS_ADDR,href.offset+8,NR_R12);
- end;
- { save gprs and fetch GOT pointer }
- if usesgpr then
- begin
- {
- if cs_create_pic in aktmoduleswitches then
- begin
- a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14)+'_g',AB_EXTERNAL,AT_FUNCTION));
- gotgot:=true;
- end
- else
- a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14),AB_EXTERNAL,AT_FUNCTION))
- }
- reference_reset_base(href,NR_R12,-4);
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- a_load_reg_ref(list,OS_INT,OS_INT,newreg(R_INTREGISTER,regcounter2,R_SUBNONE),href);
- dec(href.offset,4);
- end;
- end;
- {
- r.enum:=R_INTREGISTER;
- r.:=;
- reference_reset_base(href,NR_R12,-((NR_R31-firstreggpr) shr 8+1)*4);
- list.concat(taicpu.op_reg_ref(A_STMW,firstreggpr,href));
- }
- end;
- if assigned(current_procinfo.procdef.parast) then
- begin
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- begin
- { copy memory parameters to local parast }
- hp:=tparaitem(current_procinfo.procdef.para.first);
- while assigned(hp) do
- begin
- if (hp.paraloc[calleeside].location^.loc in [LOC_REFERENCE,LOC_CREFERENCE]) then
- begin
- if assigned(hp.paraloc[callerside].location^.next) then
- internalerror(2004091210);
- case tvarsym(hp.parasym).localloc.loc of
- LOC_REFERENCE:
- begin
- reference_reset_base(href,tvarsym(hp.parasym).localloc.reference.base,tvarsym(hp.parasym).localloc.reference.offset);
- reference_reset_base(href2,NR_R12,hp.paraloc[callerside].location^.reference.offset);
- { we can't use functions here which allocate registers (FK)
- cg.a_load_ref_ref(list,hp.paraloc[calleeside].size,hp.paraloc[calleeside].size,href2,href);
- }
- case hp.paraloc[calleeside].size of
- OS_F32:
- size := OS_32;
- OS_64,OS_S64:
- size := OS_F64;
- else
- size := hp.paraloc[calleeside].size;
- end;
- case size of
- OS_8,OS_S8,OS_16,OS_S16,OS_32,OS_S32:
- begin
- cg.a_load_ref_reg(list,size,size,href2,NR_R0);
- cg.a_load_reg_ref(list,size,size,NR_R0,href);
- end;
- OS_F64:
- begin
- cg.a_loadfpu_ref_reg(list,size,href2,NR_F0);
- cg.a_loadfpu_reg_ref(list,size,NR_F0,href);
- end;
- else
- internalerror(2004070910);
- end;
- end;
- LOC_CREGISTER:
- begin
- reference_reset_base(href2,NR_R12,hp.paraloc[callerside].location^.reference.offset);
- cg.a_load_ref_reg(list,hp.paraloc[calleeside].size,hp.paraloc[calleeside].size,href2,tvarsym(hp.parasym).localloc.register);
- end;
- LOC_CFPUREGISTER:
- begin
- reference_reset_base(href2,NR_R12,hp.paraloc[callerside].location^.reference.offset);
- cg.a_loadfpu_ref_reg(list,hp.paraloc[calleeside].size,href2,tvarsym(hp.parasym).localloc.register);
- end;
- else
- internalerror(2004070911);
- end;
- end;
- hp := tparaitem(hp.next);
- end;
- end;
- end;
- if usesfpr or usesgpr then
- a_reg_dealloc(list,NR_R12);
- { if we didn't get the GOT pointer till now, we've to calculate it now }
- if not(gotgot) and (pi_needs_got in current_procinfo.flags) then
- case target_info.system of
- system_powerpc_darwin:
- begin
- list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_LR));
- fillchar(cond,sizeof(cond),0);
- cond.simple:=false;
- cond.bo:=20;
- cond.bi:=31;
- instr:=taicpu.op_sym(A_BCL,current_procinfo.gotlabel);
- instr.setcondition(cond);
- list.concat(instr);
- a_label(list,current_procinfo.gotlabel);
- list.concat(taicpu.op_reg_reg(A_MFSPR,current_procinfo.got,NR_LR));
- list.concat(taicpu.op_reg_reg(A_MTSPR,NR_LR,NR_R0));
- end;
- else
- begin
- a_reg_alloc(list,NR_R31);
- { place GOT ptr in r31 }
- list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R31,NR_LR));
- end;
- end;
- { save the CR if necessary ( !!! always done currently ) }
- { still need to find out where this has to be done for SystemV
- a_reg_alloc(list,R_0);
- list.concat(taicpu.op_reg_reg(A_MFSPR,R_0,R_CR);
- list.concat(taicpu.op_reg_ref(A_STW,scratch_register,
- new_reference(STACK_POINTER_REG,LA_CR)));
- a_reg_dealloc(list,R_0); }
- { now comes the AltiVec context save, not yet implemented !!! }
- end;
- procedure tcgppc.g_proc_exit(list : taasmoutput;parasize : longint;nostackframe:boolean);
- { This procedure may be called before, as well as after g_stackframe_entry }
- { is called. NOTE registers are not to be allocated through the register }
- { allocator here, because the register colouring has already occured !! }
- var
- regcounter,firstregfpu,firstreggpr: TsuperRegister;
- href : treference;
- usesfpr,usesgpr,genret : boolean;
- regcounter2, firstfpureg:Tsuperregister;
- localsize: aint;
- begin
- { AltiVec context restore, not yet implemented !!! }
- usesfpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- begin
- { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
- case target_info.abi of
- abi_powerpc_aix:
- firstfpureg := RS_F14;
- abi_powerpc_sysv:
- firstfpureg := RS_F9;
- else
- internalerror(2003122903);
- end;
- for regcounter:=firstfpureg to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- usesfpr:=true;
- firstregfpu:=regcounter;
- break;
- end;
- end;
- end;
- usesgpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- firstreggpr:=regcounter2;
- break;
- end;
- end;
- localsize:= tppcprocinfo(current_procinfo).calc_stackframe_size;
- { no return (blr) generated yet }
- genret:=true;
- if usesgpr or usesfpr then
- begin
- { address of gpr save area to r11 }
- { (register allocator is no longer valid at this time and an add of 0 }
- { is translated into a move, which is then registered with the register }
- { allocator, causing a crash }
- if (localsize <> 0) then
- a_op_const_reg_reg(list,OP_ADD,OS_ADDR,localsize,NR_STACK_POINTER_REG,NR_R12)
- else
- list.concat(taicpu.op_reg_reg(A_MR,NR_R12,NR_STACK_POINTER_REG));
- if usesfpr then
- begin
- reference_reset_base(href,NR_R12,-8);
- for regcounter := firstregfpu to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- a_loadfpu_ref_reg(list,OS_F64,href,newreg(R_FPUREGISTER,regcounter,R_SUBNONE));
- dec(href.offset,8);
- end;
- end;
- inc(href.offset,4);
- end
- else
- reference_reset_base(href,NR_R12,-4);
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- a_load_ref_reg(list,OS_INT,OS_INT,href,newreg(R_INTREGISTER,regcounter2,R_SUBNONE));
- dec(href.offset,4);
- end;
- end;
- (*
- reference_reset_base(href,r2,-((NR_R31-ord(firstreggpr)) shr 8+1)*4);
- list.concat(taicpu.op_reg_ref(A_LMW,firstreggpr,href));
- *)
- end;
- (*
- { restore fprs and return }
- if usesfpr then
- begin
- { address of fpr save area to r11 }
- r:=NR_R12;
- list.concat(taicpu.op_reg_reg_const(A_ADDI,r,r,(ord(R_F31)-ord(firstregfpu.enum)+1)*8));
- {
- if (pi_do_call in current_procinfo.flags) then
- a_call_name(objectlibrary.newasmsymbol('_restfpr_'+tostr(ord(firstregfpu)-ord(R_F14)+14)+
- '_x',AB_EXTERNAL,AT_FUNCTION))
- else
- { leaf node => lr haven't to be restored }
- a_call_name('_restfpr_'+tostr(ord(firstregfpu.enum)-ord(R_F14)+14)+
- '_l');
- genret:=false;
- }
- end;
- *)
- { if we didn't generate the return code, we've to do it now }
- if genret then
- begin
- { adjust r1 }
- { (register allocator is no longer valid at this time and an add of 0 }
- { is translated into a move, which is then registered with the register }
- { allocator, causing a crash }
- if (localsize <> 0) then
- a_op_const_reg(list,OP_ADD,OS_ADDR,localsize,NR_R1);
- { load link register? }
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- begin
- if (pi_do_call in current_procinfo.flags) then
- begin
- case target_info.abi of
- abi_powerpc_aix:
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_AIX);
- abi_powerpc_sysv:
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_LR_SYSV);
- end;
- list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
- list.concat(taicpu.op_reg(A_MTLR,NR_R0));
- end;
- { restore the CR if necessary from callers frame}
- if target_info.abi = abi_powerpc_aix then
- if false then { Not needed at the moment. }
- begin
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
- list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
- list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_CR));
- a_reg_dealloc(list,NR_R0);
- end;
- end;
- list.concat(taicpu.op_none(A_BLR));
- end;
- end;
- function tcgppc.save_regs(list : taasmoutput):longint;
- {Generates code which saves used non-volatile registers in
- the save area right below the address the stackpointer point to.
- Returns the actual used save area size.}
- var regcounter,firstregfpu,firstreggpr: TSuperRegister;
- usesfpr,usesgpr: boolean;
- href : treference;
- offset: aint;
- regcounter2, firstfpureg: Tsuperregister;
- begin
- usesfpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- begin
- { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
- case target_info.abi of
- abi_powerpc_aix:
- firstfpureg := RS_F14;
- abi_powerpc_sysv:
- firstfpureg := RS_F9;
- else
- internalerror(2003122903);
- end;
- for regcounter:=firstfpureg to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- usesfpr:=true;
- firstregfpu:=regcounter;
- break;
- end;
- end;
- end;
- usesgpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- firstreggpr:=regcounter2;
- break;
- end;
- end;
- offset:= 0;
- { save floating-point registers }
- if usesfpr then
- for regcounter := firstregfpu to RS_F31 do
- begin
- offset:= offset - 8;
- reference_reset_base(href, NR_STACK_POINTER_REG, offset);
- list.concat(taicpu.op_reg_ref(A_STFD, tregister(regcounter), href));
- end;
- (* Optimiztion in the future: a_call_name(list,'_savefXX'); *)
- { save gprs in gpr save area }
- if usesgpr then
- if firstreggpr < RS_R30 then
- begin
- offset:= offset - 4 * (RS_R31 - firstreggpr + 1);
- reference_reset_base(href,NR_STACK_POINTER_REG,offset);
- list.concat(taicpu.op_reg_ref(A_STMW,tregister(firstreggpr),href));
- {STMW stores multiple registers}
- end
- else
- begin
- for regcounter := firstreggpr to RS_R31 do
- begin
- offset:= offset - 4;
- reference_reset_base(href, NR_STACK_POINTER_REG, offset);
- list.concat(taicpu.op_reg_ref(A_STW, newreg(R_INTREGISTER,regcounter,R_SUBWHOLE), href));
- end;
- end;
- { now comes the AltiVec context save, not yet implemented !!! }
- save_regs:= -offset;
- end;
- procedure tcgppc.restore_regs(list : taasmoutput);
- {Generates code which restores used non-volatile registers from
- the save area right below the address the stackpointer point to.}
- var regcounter,firstregfpu,firstreggpr: TSuperRegister;
- usesfpr,usesgpr: boolean;
- href : treference;
- offset: integer;
- regcounter2, firstfpureg: Tsuperregister;
- begin
- usesfpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- begin
- { FIXME: has to be R_F14 instad of R_F8 for SYSV-64bit }
- case target_info.abi of
- abi_powerpc_aix:
- firstfpureg := RS_F14;
- abi_powerpc_sysv:
- firstfpureg := RS_F9;
- else
- internalerror(2003122903);
- end;
- for regcounter:=firstfpureg to RS_F31 do
- begin
- if regcounter in rg[R_FPUREGISTER].used_in_proc then
- begin
- usesfpr:=true;
- firstregfpu:=regcounter;
- break;
- end;
- end;
- end;
- usesgpr:=false;
- if not (po_assembler in current_procinfo.procdef.procoptions) then
- for regcounter2:=RS_R13 to RS_R31 do
- begin
- if regcounter2 in rg[R_INTREGISTER].used_in_proc then
- begin
- usesgpr:=true;
- firstreggpr:=regcounter2;
- break;
- end;
- end;
- offset:= 0;
- { restore fp registers }
- if usesfpr then
- for regcounter := firstregfpu to RS_F31 do
- begin
- offset:= offset - 8;
- reference_reset_base(href, NR_STACK_POINTER_REG, offset);
- list.concat(taicpu.op_reg_ref(A_LFD, newreg(R_FPUREGISTER,regcounter,R_SUBWHOLE), href));
- end;
- (* Optimiztion in the future: a_call_name(list,'_restfXX'); *)
- { restore gprs }
- if usesgpr then
- if firstreggpr < RS_R30 then
- begin
- offset:= offset - 4 * (RS_R31 - firstreggpr + 1);
- reference_reset_base(href,NR_STACK_POINTER_REG,offset); //-220
- list.concat(taicpu.op_reg_ref(A_LMW,tregister(firstreggpr),href));
- {LMW loads multiple registers}
- end
- else
- begin
- for regcounter := firstreggpr to RS_R31 do
- begin
- offset:= offset - 4;
- reference_reset_base(href, NR_STACK_POINTER_REG, offset);
- list.concat(taicpu.op_reg_ref(A_LWZ, newreg(R_INTREGISTER,regcounter,R_SUBWHOLE), href));
- end;
- end;
- { now comes the AltiVec context restore, not yet implemented !!! }
- end;
- procedure tcgppc.g_stackframe_entry_mac(list : taasmoutput;localsize : longint);
- (* NOT IN USE *)
- { generated the entry code of a procedure/function. Note: localsize is the }
- { sum of the size necessary for local variables and the maximum possible }
- { combined size of ALL the parameters of a procedure called by the current }
- { one }
- const
- macosLinkageAreaSize = 24;
- var regcounter: TRegister;
- href : treference;
- registerSaveAreaSize : longint;
- begin
- if (localsize mod 8) <> 0 then
- internalerror(58991);
- { CR and LR only have to be saved in case they are modified by the current }
- { procedure, but currently this isn't checked, so save them always }
- { following is the entry code as described in "Altivec Programming }
- { Interface Manual", bar the saving of AltiVec registers }
- a_reg_alloc(list,NR_STACK_POINTER_REG);
- a_reg_alloc(list,NR_R0);
- { save return address in callers frame}
- list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_LR));
- { ... in caller's frame }
- reference_reset_base(href,NR_STACK_POINTER_REG,8);
- list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
- a_reg_dealloc(list,NR_R0);
- { save non-volatile registers in callers frame}
- registerSaveAreaSize:= save_regs(list);
- { save the CR if necessary in callers frame ( !!! always done currently ) }
- a_reg_alloc(list,NR_R0);
- list.concat(taicpu.op_reg_reg(A_MFSPR,NR_R0,NR_CR));
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
- list.concat(taicpu.op_reg_ref(A_STW,NR_R0,href));
- a_reg_dealloc(list,NR_R0);
- (*
- { save pointer to incoming arguments }
- list.concat(taicpu.op_reg_reg_const(A_ORI,R_31,STACK_POINTER_REG,0));
- *)
- (*
- a_reg_alloc(list,R_12);
- { 0 or 8 based on SP alignment }
- list.concat(taicpu.op_reg_reg_const_const_const(A_RLWINM,
- R_12,STACK_POINTER_REG,0,28,28));
- { add in stack length }
- list.concat(taicpu.op_reg_reg_const(A_SUBFIC,R_12,R_12,
- -localsize));
- { establish new alignment }
- list.concat(taicpu.op_reg_reg_reg(A_STWUX,STACK_POINTER_REG,STACK_POINTER_REG,R_12));
- a_reg_dealloc(list,R_12);
- *)
- { allocate stack frame }
- localsize:= align(localsize + macosLinkageAreaSize + registerSaveAreaSize, 16);
- inc(localsize,tg.lasttemp);
- localsize:=align(localsize,16);
- //tppcprocinfo(current_procinfo).localsize:=localsize;
- if (localsize <> 0) then
- begin
- if (localsize <= high(smallint)) then
- begin
- reference_reset_base(href,NR_STACK_POINTER_REG,-localsize);
- a_load_store(list,A_STWU,NR_STACK_POINTER_REG,href);
- end
- else
- begin
- reference_reset_base(href,NR_STACK_POINTER_REG,0);
- href.index := NR_R11;
- a_reg_alloc(list,href.index);
- a_load_const_reg(list,OS_S32,-localsize,href.index);
- a_load_store(list,A_STWUX,NR_STACK_POINTER_REG,href);
- a_reg_dealloc(list,href.index);
- end;
- end;
- end;
- procedure tcgppc.g_return_from_proc_mac(list : taasmoutput;parasize : aint);
- (* NOT IN USE *)
- var
- href : treference;
- begin
- a_reg_alloc(list,NR_R0);
- { restore stack pointer }
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_SP);
- list.concat(taicpu.op_reg_ref(A_LWZ,NR_STACK_POINTER_REG,href));
- (*
- list.concat(taicpu.op_reg_reg_const(A_ORI,NR_STACK_POINTER_REG,R_31,0));
- *)
- { restore the CR if necessary from callers frame
- ( !!! always done currently ) }
- reference_reset_base(href,NR_STACK_POINTER_REG,LA_CR_AIX);
- list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
- list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_CR));
- a_reg_dealloc(list,NR_R0);
- (*
- { restore return address from callers frame }
- reference_reset_base(href,STACK_POINTER_REG,8);
- list.concat(taicpu.op_reg_ref(A_LWZ,R_0,href));
- *)
- { restore non-volatile registers from callers frame }
- restore_regs(list);
- (*
- { return to caller }
- list.concat(taicpu.op_reg_reg(A_MTSPR,R_0,R_LR));
- list.concat(taicpu.op_none(A_BLR));
- *)
- { restore return address from callers frame }
- reference_reset_base(href,NR_STACK_POINTER_REG,8);
- list.concat(taicpu.op_reg_ref(A_LWZ,NR_R0,href));
- { return to caller }
- list.concat(taicpu.op_reg_reg(A_MTSPR,NR_R0,NR_LR));
- list.concat(taicpu.op_none(A_BLR));
- end;
- procedure tcgppc.a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);
- var
- ref2, tmpref: treference;
- freereg: boolean;
- tmpreg:Tregister;
- begin
- ref2 := ref;
- freereg := fixref(list,ref2);
- if assigned(ref2.symbol) then
- begin
- if target_info.system = system_powerpc_macos then
- begin
- if macos_direct_globals then
- begin
- reference_reset(tmpref);
- tmpref.offset := ref2.offset;
- tmpref.symbol := ref2.symbol;
- tmpref.base := NR_NO;
- list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,NR_RTOC,tmpref));
- end
- else
- begin
- reference_reset(tmpref);
- tmpref.symbol := ref2.symbol;
- tmpref.offset := 0;
- tmpref.base := NR_RTOC;
- list.concat(taicpu.op_reg_ref(A_LWZ,r,tmpref));
- if ref2.offset <> 0 then
- begin
- reference_reset(tmpref);
- tmpref.offset := ref2.offset;
- tmpref.base:= r;
- list.concat(taicpu.op_reg_ref(A_LA,r,tmpref));
- end;
- end;
- if ref2.base <> NR_NO then
- list.concat(taicpu.op_reg_reg_reg(A_ADD,r,r,ref2.base));
- //list.concat(tai_comment.create(strpnew('*** a_loadaddr_ref_reg')));
- end
- else
- begin
- { add the symbol's value to the base of the reference, and if the }
- { reference doesn't have a base, create one }
- reference_reset(tmpref);
- tmpref.offset := ref2.offset;
- tmpref.symbol := ref2.symbol;
- tmpref.relsymbol := ref2.relsymbol;
- tmpref.refaddr := addr_hi;
- if ref2.base<> NR_NO then
- begin
- list.concat(taicpu.op_reg_reg_ref(A_ADDIS,r,
- ref2.base,tmpref));
- if freereg then
- begin
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- freereg := false;
- end;
- end
- else
- list.concat(taicpu.op_reg_ref(A_LIS,r,tmpref));
- tmpref.base := NR_NO;
- tmpref.refaddr := addr_lo;
- { can be folded with one of the next instructions by the }
- { optimizer probably }
- list.concat(taicpu.op_reg_reg_ref(A_ADDI,r,r,tmpref));
- end
- end
- else if ref2.offset <> 0 Then
- if ref2.base <> NR_NO then
- a_op_const_reg_reg(list,OP_ADD,OS_32,ref2.offset,ref2.base,r)
- { FixRef makes sure that "(ref.index <> R_NO) and (ref.offset <> 0)" never}
- { occurs, so now only ref.offset has to be loaded }
- else
- a_load_const_reg(list,OS_32,ref2.offset,r)
- else if ref.index <> NR_NO Then
- list.concat(taicpu.op_reg_reg_reg(A_ADD,r,ref2.base,ref2.index))
- else if (ref2.base <> NR_NO) and
- (r <> ref2.base) then
- a_load_reg_reg(list,OS_ADDR,OS_ADDR,ref2.base,r)
- else
- list.concat(taicpu.op_reg_const(A_LI,r,0));
- if freereg then
- rg[R_INTREGISTER].ungetregister(list,ref2.base);
- end;
- { ************* concatcopy ************ }
- {$ifndef ppc603}
- const
- maxmoveunit = 8;
- {$else ppc603}
- const
- maxmoveunit = 4;
- {$endif ppc603}
- procedure tcgppc.g_concatcopy(list : taasmoutput;const source,dest : treference;len : aint; delsource,loadref : boolean);
- var
- countreg: TRegister;
- src, dst: TReference;
- lab: tasmlabel;
- count, count2: aint;
- orgsrc, orgdst: boolean;
- size: tcgsize;
- begin
- {$ifdef extdebug}
- if len > high(longint) then
- internalerror(2002072704);
- {$endif extdebug}
- { make sure short loads are handled as optimally as possible }
- if not loadref then
- if (len <= maxmoveunit) and
- (byte(len) in [1,2,4,8]) then
- begin
- if len < 8 then
- begin
- size := int_cgsize(len);
- a_load_ref_ref(list,size,size,source,dest);
- if delsource then
- begin
- reference_release(list,source);
- tg.ungetiftemp(list,source);
- end;
- end
- else
- begin
- a_reg_alloc(list,NR_F0);
- a_loadfpu_ref_reg(list,OS_F64,source,NR_F0);
- if delsource then
- begin
- reference_release(list,source);
- tg.ungetiftemp(list,source);
- end;
- a_loadfpu_reg_ref(list,OS_F64,NR_F0,dest);
- a_reg_dealloc(list,NR_F0);
- end;
- exit;
- end;
- count := len div maxmoveunit;
- reference_reset(src);
- reference_reset(dst);
- { load the address of source into src.base }
- if loadref then
- begin
- src.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_ref_reg(list,OS_32,OS_32,source,src.base);
- orgsrc := false;
- end
- else if (count > 4) or
- not issimpleref(source) or
- ((source.index <> NR_NO) and
- ((source.offset + longint(len)) > high(smallint))) then
- begin
- src.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_loadaddr_ref_reg(list,source,src.base);
- orgsrc := false;
- end
- else
- begin
- src := source;
- orgsrc := true;
- end;
- if not orgsrc and delsource then
- reference_release(list,source);
- { load the address of dest into dst.base }
- if (count > 4) or
- not issimpleref(dest) or
- ((dest.index <> NR_NO) and
- ((dest.offset + longint(len)) > high(smallint))) then
- begin
- dst.base := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_loadaddr_ref_reg(list,dest,dst.base);
- orgdst := false;
- end
- else
- begin
- dst := dest;
- orgdst := true;
- end;
- {$ifndef ppc603}
- if count > 4 then
- { generate a loop }
- begin
- { the offsets are zero after the a_loadaddress_ref_reg and just }
- { have to be set to 8. I put an Inc there so debugging may be }
- { easier (should offset be different from zero here, it will be }
- { easy to notice in the generated assembler }
- inc(dst.offset,8);
- inc(src.offset,8);
- list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,8));
- list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,8));
- countreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_const_reg(list,OS_32,count,countreg);
- { explicitely allocate R_0 since it can be used safely here }
- { (for holding date that's being copied) }
- a_reg_alloc(list,NR_F0);
- objectlibrary.getlabel(lab);
- a_label(list, lab);
- list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
- list.concat(taicpu.op_reg_ref(A_LFDU,NR_F0,src));
- list.concat(taicpu.op_reg_ref(A_STFDU,NR_F0,dst));
- a_jmp(list,A_BC,C_NE,0,lab);
- rg[R_INTREGISTER].ungetregister(list,countreg);
- a_reg_dealloc(list,NR_F0);
- len := len mod 8;
- end;
- count := len div 8;
- if count > 0 then
- { unrolled loop }
- begin
- a_reg_alloc(list,NR_F0);
- for count2 := 1 to count do
- begin
- a_loadfpu_ref_reg(list,OS_F64,src,NR_F0);
- a_loadfpu_reg_ref(list,OS_F64,NR_F0,dst);
- inc(src.offset,8);
- inc(dst.offset,8);
- end;
- a_reg_dealloc(list,NR_F0);
- len := len mod 8;
- end;
- if (len and 4) <> 0 then
- begin
- a_reg_alloc(list,NR_R0);
- a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
- a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
- inc(src.offset,4);
- inc(dst.offset,4);
- a_reg_dealloc(list,NR_R0);
- end;
- {$else not ppc603}
- if count > 4 then
- { generate a loop }
- begin
- { the offsets are zero after the a_loadaddress_ref_reg and just }
- { have to be set to 4. I put an Inc there so debugging may be }
- { easier (should offset be different from zero here, it will be }
- { easy to notice in the generated assembler }
- inc(dst.offset,4);
- inc(src.offset,4);
- list.concat(taicpu.op_reg_reg_const(A_SUBI,src.base,src.base,4));
- list.concat(taicpu.op_reg_reg_const(A_SUBI,dst.base,dst.base,4));
- countreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load_const_reg(list,OS_32,count,countreg);
- { explicitely allocate R_0 since it can be used safely here }
- { (for holding date that's being copied) }
- a_reg_alloc(list,NR_R0);
- objectlibrary.getlabel(lab);
- a_label(list, lab);
- list.concat(taicpu.op_reg_reg_const(A_SUBIC_,countreg,countreg,1));
- list.concat(taicpu.op_reg_ref(A_LWZU,NR_R0,src));
- list.concat(taicpu.op_reg_ref(A_STWU,NR_R0,dst));
- a_jmp(list,A_BC,C_NE,0,lab);
- rg[R_INTREGISTER].ungetregister(list,countreg);
- a_reg_dealloc(list,NR_R0);
- len := len mod 4;
- end;
- count := len div 4;
- if count > 0 then
- { unrolled loop }
- begin
- a_reg_alloc(list,NR_R0);
- for count2 := 1 to count do
- begin
- a_load_ref_reg(list,OS_32,OS_32,src,NR_R0);
- a_load_reg_ref(list,OS_32,OS_32,NR_R0,dst);
- inc(src.offset,4);
- inc(dst.offset,4);
- end;
- a_reg_dealloc(list,NR_R0);
- len := len mod 4;
- end;
- {$endif not ppc603}
- { copy the leftovers }
- if (len and 2) <> 0 then
- begin
- a_reg_alloc(list,NR_R0);
- a_load_ref_reg(list,OS_16,OS_16,src,NR_R0);
- a_load_reg_ref(list,OS_16,OS_16,NR_R0,dst);
- inc(src.offset,2);
- inc(dst.offset,2);
- a_reg_dealloc(list,NR_R0);
- end;
- if (len and 1) <> 0 then
- begin
- a_reg_alloc(list,NR_R0);
- a_load_ref_reg(list,OS_8,OS_8,src,NR_R0);
- a_load_reg_ref(list,OS_8,OS_8,NR_R0,dst);
- a_reg_dealloc(list,NR_R0);
- end;
- if orgsrc then
- begin
- if delsource then
- reference_release(list,source);
- end
- else
- rg[R_INTREGISTER].ungetregister(list,src.base);
- if not orgdst then
- rg[R_INTREGISTER].ungetregister(list,dst.base);
- if delsource then
- tg.ungetiftemp(list,source);
- end;
- procedure tcgppc.g_overflowcheck(list: taasmoutput; const l: tlocation; def: tdef);
- var
- hl : tasmlabel;
- begin
- if not(cs_check_overflow in aktlocalswitches) then
- exit;
- objectlibrary.getlabel(hl);
- if not ((def.deftype=pointerdef) or
- ((def.deftype=orddef) and
- (torddef(def).typ in [u64bit,u16bit,u32bit,u8bit,uchar,
- bool8bit,bool16bit,bool32bit]))) then
- begin
- list.concat(taicpu.op_reg(A_MCRXR,NR_CR7));
- a_jmp(list,A_BC,C_NO,7,hl)
- end
- else
- a_jmp_cond(list,OC_AE,hl);
- a_call_name(list,'FPC_OVERFLOW');
- a_label(list,hl);
- end;
- {***************** This is private property, keep out! :) *****************}
- function tcgppc.issimpleref(const ref: treference): boolean;
- begin
- if (ref.base = NR_NO) and
- (ref.index <> NR_NO) then
- internalerror(200208101);
- result :=
- not(assigned(ref.symbol)) and
- (((ref.index = NR_NO) and
- (ref.offset >= low(smallint)) and
- (ref.offset <= high(smallint))) or
- ((ref.index <> NR_NO) and
- (ref.offset = 0)));
- end;
- function tcgppc.fixref(list: taasmoutput; var ref: treference): boolean;
- var
- tmpreg: tregister;
- orgindex: tregister;
- begin
- result := false;
- if (ref.base = NR_NO) then
- begin
- ref.base := ref.index;
- ref.base := NR_NO;
- end;
- if (ref.base <> NR_NO) then
- begin
- if (ref.index <> NR_NO) and
- ((ref.offset <> 0) or assigned(ref.symbol)) then
- begin
- result := true;
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- list.concat(taicpu.op_reg_reg_reg(
- A_ADD,tmpreg,ref.base,ref.index));
- ref.index := NR_NO;
- ref.base := tmpreg;
- end
- end
- else
- if ref.index <> NR_NO then
- internalerror(200208102);
- end;
- { find out whether a is of the form 11..00..11b or 00..11...00. If }
- { that's the case, we can use rlwinm to do an AND operation }
- function tcgppc.get_rlwi_const(a: aint; var l1, l2: longint): boolean;
- var
- temp : longint;
- testbit : aint;
- compare: boolean;
- begin
- get_rlwi_const := false;
- if (a = 0) or (a = -1) then
- exit;
- { start with the lowest bit }
- testbit := 1;
- { check its value }
- compare := boolean(a and testbit);
- { find out how long the run of bits with this value is }
- { (it's impossible that all bits are 1 or 0, because in that case }
- { this function wouldn't have been called) }
- l1 := 31;
- while (((a and testbit) <> 0) = compare) do
- begin
- testbit := testbit shl 1;
- dec(l1);
- end;
- { check the length of the run of bits that comes next }
- compare := not compare;
- l2 := l1;
- while (((a and testbit) <> 0) = compare) and
- (l2 >= 0) do
- begin
- testbit := testbit shl 1;
- dec(l2);
- end;
- { and finally the check whether the rest of the bits all have the }
- { same value }
- compare := not compare;
- temp := l2;
- if temp >= 0 then
- if (a shr (31-temp)) <> ((-ord(compare)) shr (31-temp)) then
- exit;
- { we have done "not(not(compare))", so compare is back to its }
- { initial value. If the lowest bit was 0, a is of the form }
- { 00..11..00 and we need "rlwinm reg,reg,0,l2+1,l1", (+1 }
- { because l2 now contains the position of the last zero of the }
- { first run instead of that of the first 1) so switch l1 and l2 }
- { in that case (we will generate "rlwinm reg,reg,0,l1,l2") }
- if not compare then
- begin
- temp := l1;
- l1 := l2+1;
- l2 := temp;
- end
- else
- { otherwise, l1 currently contains the position of the last }
- { zero instead of that of the first 1 of the second run -> +1 }
- inc(l1);
- { the following is the same as "if l1 = -1 then l1 := 31;" }
- l1 := l1 and 31;
- l2 := l2 and 31;
- get_rlwi_const := true;
- end;
- procedure tcgppc.a_load_store(list:taasmoutput;op: tasmop;reg:tregister;
- ref: treference);
- var
- tmpreg: tregister;
- tmpref: treference;
- largeOffset: Boolean;
- begin
- tmpreg := NR_NO;
- if target_info.system = system_powerpc_macos then
- begin
- largeOffset:= (cardinal(ref.offset-low(smallint)) >
- high(smallint)-low(smallint));
- if assigned(ref.symbol) then
- begin {Load symbol's value}
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- reference_reset(tmpref);
- tmpref.symbol := ref.symbol;
- tmpref.base := NR_RTOC;
- if macos_direct_globals then
- list.concat(taicpu.op_reg_ref(A_LA,tmpreg,tmpref))
- else
- list.concat(taicpu.op_reg_ref(A_LWZ,tmpreg,tmpref));
- end;
- if largeOffset then
- begin {Add hi part of offset}
- reference_reset(tmpref);
- if Smallint(Lo(ref.offset)) < 0 then
- tmpref.offset := Hi(ref.offset) + 1 {Compensate when lo part is negative}
- else
- tmpref.offset := Hi(ref.offset);
- if (tmpreg <> NR_NO) then
- list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg, tmpreg,tmpref))
- else
- begin
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,tmpref));
- end;
- end;
- if (tmpreg <> NR_NO) then
- begin
- {Add content of base register}
- if ref.base <> NR_NO then
- list.concat(taicpu.op_reg_reg_reg(A_ADD,tmpreg,
- ref.base,tmpreg));
- {Make ref ready to be used by op}
- ref.symbol:= nil;
- ref.base:= tmpreg;
- if largeOffset then
- ref.offset := Smallint(Lo(ref.offset));
- list.concat(taicpu.op_reg_ref(op,reg,ref));
- //list.concat(tai_comment.create(strpnew('*** a_load_store indirect global')));
- end
- else
- list.concat(taicpu.op_reg_ref(op,reg,ref));
- end
- else {if target_info.system <> system_powerpc_macos}
- begin
- if assigned(ref.symbol) or
- (cardinal(ref.offset-low(smallint)) >
- high(smallint)-low(smallint)) then
- begin
- tmpreg := rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- reference_reset(tmpref);
- tmpref.symbol := ref.symbol;
- tmpref.relsymbol := ref.relsymbol;
- tmpref.offset := ref.offset;
- tmpref.refaddr := addr_hi;
- if ref.base <> NR_NO then
- list.concat(taicpu.op_reg_reg_ref(A_ADDIS,tmpreg,
- ref.base,tmpref))
- else
- list.concat(taicpu.op_reg_ref(A_LIS,tmpreg,tmpref));
- ref.base := tmpreg;
- ref.refaddr := addr_lo;
- list.concat(taicpu.op_reg_ref(op,reg,ref));
- end
- else
- list.concat(taicpu.op_reg_ref(op,reg,ref));
- end;
- if (tmpreg <> NR_NO) then
- rg[R_INTREGISTER].ungetregister(list,tmpreg);
- end;
- procedure tcgppc.a_jmp(list: taasmoutput; op: tasmop; c: tasmcondflag;
- crval: longint; l: tasmlabel);
- var
- p: taicpu;
- begin
- p := taicpu.op_sym(op,objectlibrary.newasmsymbol(l.name,AB_EXTERNAL,AT_FUNCTION));
- if op <> A_B then
- create_cond_norm(c,crval,p.condition);
- p.is_jmp := true;
- list.concat(p)
- end;
- procedure tcg64fppc.a_op64_reg_reg(list : taasmoutput;op:TOpCG;regsrc,regdst : tregister64);
- begin
- a_op64_reg_reg_reg(list,op,regsrc,regdst,regdst);
- end;
- procedure tcg64fppc.a_op64_const_reg(list : taasmoutput;op:TOpCG;value : int64;reg : tregister64);
- begin
- a_op64_const_reg_reg(list,op,value,reg,reg);
- end;
- procedure tcg64fppc.a_op64_reg_reg_reg(list: taasmoutput;op:TOpCG;regsrc1,regsrc2,regdst : tregister64);
- begin
- case op of
- OP_AND,OP_OR,OP_XOR:
- begin
- cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reglo,regsrc2.reglo,regdst.reglo);
- cg.a_op_reg_reg_reg(list,op,OS_32,regsrc1.reghi,regsrc2.reghi,regdst.reghi);
- end;
- OP_ADD:
- begin
- list.concat(taicpu.op_reg_reg_reg(A_ADDC,regdst.reglo,regsrc1.reglo,regsrc2.reglo));
- list.concat(taicpu.op_reg_reg_reg(A_ADDE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
- end;
- OP_SUB:
- begin
- list.concat(taicpu.op_reg_reg_reg(A_SUBC,regdst.reglo,regsrc2.reglo,regsrc1.reglo));
- list.concat(taicpu.op_reg_reg_reg(A_SUBFE,regdst.reghi,regsrc1.reghi,regsrc2.reghi));
- end;
- else
- internalerror(2002072801);
- end;
- end;
- procedure tcg64fppc.a_op64_const_reg_reg(list: taasmoutput;op:TOpCG;value : int64;regsrc,regdst : tregister64);
- const
- ops: array[boolean,1..3] of tasmop = ((A_ADDIC,A_ADDC,A_ADDZE),
- (A_SUBIC,A_SUBC,A_ADDME));
- var
- tmpreg: tregister;
- tmpreg64: tregister64;
- issub: boolean;
- begin
- case op of
- OP_AND,OP_OR,OP_XOR:
- begin
- cg.a_op_const_reg_reg(list,op,OS_32,aint(value),regsrc.reglo,regdst.reglo);
- cg.a_op_const_reg_reg(list,op,OS_32,aint(value shr 32),regsrc.reghi,
- regdst.reghi);
- end;
- OP_ADD, OP_SUB:
- begin
- if (value < 0) then
- begin
- if op = OP_ADD then
- op := OP_SUB
- else
- op := OP_ADD;
- value := -value;
- end;
- if (longint(value) <> 0) then
- begin
- issub := op = OP_SUB;
- if (value > 0) and
- (value-ord(issub) <= 32767) then
- begin
- list.concat(taicpu.op_reg_reg_const(ops[issub,1],
- regdst.reglo,regsrc.reglo,longint(value)));
- list.concat(taicpu.op_reg_reg(ops[issub,3],
- regdst.reghi,regsrc.reghi));
- end
- else if ((value shr 32) = 0) then
- begin
- tmpreg := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- cg.a_load_const_reg(list,OS_32,cardinal(value),tmpreg);
- list.concat(taicpu.op_reg_reg_reg(ops[issub,2],
- regdst.reglo,regsrc.reglo,tmpreg));
- tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg);
- list.concat(taicpu.op_reg_reg(ops[issub,3],
- regdst.reghi,regsrc.reghi));
- end
- else
- begin
- tmpreg64.reglo := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- tmpreg64.reghi := tcgppc(cg).rg[R_INTREGISTER].getregister(list,R_SUBWHOLE);
- a_load64_const_reg(list,value,tmpreg64);
- a_op64_reg_reg_reg(list,op,tmpreg64,regsrc,regdst);
- tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg64.reglo);
- tcgppc(cg).rg[R_INTREGISTER].ungetregister(list,tmpreg64.reghi);
- end
- end
- else
- begin
- cg.a_load_reg_reg(list,OS_INT,OS_INT,regsrc.reglo,regdst.reglo);
- cg.a_op_const_reg_reg(list,op,OS_32,aint(value shr 32),regsrc.reghi,
- regdst.reghi);
- end;
- end;
- else
- internalerror(2002072802);
- end;
- end;
- begin
- cg := tcgppc.create;
- cg64 :=tcg64fppc.create;
- end.
- {
- $Log$
- Revision 1.177 2004-09-21 17:25:12 peter
- * paraloc branch merged
- Revision 1.176.4.2 2004/09/18 20:21:08 jonas
- * fixed ppc, but still needs fix in tgobj
- Revision 1.176.4.1 2004/09/10 11:10:08 florian
- * first part of ppc fixes
- Revision 1.176 2004/07/17 14:48:20 jonas
- * fixed op_const_reg_reg for (OP_ADD,0,reg1,reg2)
- Revision 1.175 2004/07/09 21:45:24 jonas
- * fixed passing of fpu paras on the stack
- * fixed number of fpu parameters passed in registers
- * skip corresponding integer registers when using an fpu register for a
- parameter under the AIX abi
- Revision 1.174 2004/07/01 18:00:00 jonas
- * fixed several errors due to aword -> aint change
- Revision 1.173 2004/06/20 08:55:32 florian
- * logs truncated
- Revision 1.172 2004/06/17 16:55:46 peter
- * powerpc compiles again
- Revision 1.171 2004/06/02 17:18:10 jonas
- * parameters passed on the stack now also work as register variables
- Revision 1.170 2004/05/31 18:08:41 jonas
- * changed calling of external procedures to be the same as under gcc
- (don't worry about all the generated stubs, they're optimized away
- by the linker)
- -> side effect: no need anymore to use special declarations for
- external C functions under Darwin compared to other platforms
- (it's still necessary for variables though)
- Revision 1.169 2004/04/04 17:50:36 olle
- * macos: fixed large offsets in references
- Revision 1.168 2004/03/06 21:37:45 florian
- * fixed ppc compilation
- }
|