12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718 |
- /* lfr ret should little endian */
- #define const13(x) ((x) > -4096 && (x) < 4096)
- #define NULL 0
- #include "mach_em.h"
- define(`RETH_LD',`reg_o1')
- define(`RETL_LD',`reg_o0')
- define(`RETH_ST',`reg_i1')
- define(`RETL_ST',`reg_i0')
- define(`LIN_NO',`%g6')
- define(`FIL_NAM',`%g7')
- define(`BP_OFFSET',`'WINDOWSIZE)
- define(`'`EM_BSIZE',EM_BSIZE)
- define(STACK_CLICK,4)
- #if RESOLV_debug
- define(Comment0)
- define(Comment)
- define(Comment2)
- #else
- define(Comment0,; `'`)' ; `'`/* */'" ! $1" ; code_combiner`'`(' )
- define(Comment, ; `'`)' ; `'`/* */'" ! $1 $2" ; code_combiner`'`(' )
- define(Comment2,; `'`)' ; `'`/* */'" ! $1 $2 $3" ; code_combiner`'`(' )
- #endif
- define(MAX_INT, 0x7fffffff)
- define(E_EM_CUF, 100)
- define(E_EM_CFF, 101)
- define(E_EM_CFI, 102)
- define(E_EM_CFU, 103)
- #define MAX_UNROLL 16
- #undef FAST_LIN_LNI_FIL
- define( narg4,
- C_$1_narg ==>
- ` {
- reg_t a;
- int n;
-
- Comment0( $1_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- C_$1 (n);
- }
- else
- {
- a= pop_reg();
- force_alloc_output();
- "cmp $a, 4";
- "be 1f";
- "set EILLINS, $reg_o0";
- "call trp";
- "nop";
- "1:";
- free_reg(a);
- free_output();
- C_$1 (4);
- }
- }.
- '
- )
- /******************************************************************************/
- /* */
- /* Group 1 : Load instructions */
- /* */
- /******************************************************************************/
- /* %fp : frame pointer
- * %sp : stack pointer
- * RETH_XX: High part of return value
- * RETL_XX: Low part of return value
- * LIN_NO : lin_no
- * FIL_NAM: Fil_nam
- */
- C_loc ==>
- Comment( loc , $1 );
- push_const($1).
- C_lol ==>
- Comment( lol , $1 );
- {
- reg_t S1;
- if (S1 = find_local($1, NULL)) {
- soft_alloc_reg(S1);
- push_reg(S1);
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(4);
- C_los(EM_WSIZE);
- }
- }.
- C_loe.. ==>
- Comment2( loe.. , $1, $2 );
- {
- #ifdef FAST_LIN_LNI_FIL
- if ((int*)($1) == (int*)"hol0")
- if ($2 == 0)
- push_reg(reg_lin);
- else if ($2 == 4)
- push_reg(reg_fil);
- else
- arg_error("loe.. hol0+", $2);
- else {
- #endif
- push_ext($1);
- inc_tos($2);
- push_const(4);
- C_los(EM_WSIZE);
- #ifdef FAST_LIN_LNI_FIL
- }
- #endif
- }
- .
- C_lil ==>
- Comment( lil , $1 );
- {
- reg_t S1;
- reg_t S2;
- if (S1 = find_local($1, NULL)) {
- S2 = alloc_reg();
- "ld [$S1], $S2";
- push_reg(S2);
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(4);
- C_los(EM_WSIZE);
- push_const(4);
- C_los(EM_WSIZE);
- }
- }.
- C_lof ==>
- Comment( lof , $1 );
- inc_tos($1);
- push_const(4);
- C_los(EM_WSIZE).
- C_lal ==>
- Comment( lal , $1 );
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1).
- C_lae.. ==>
- Comment2( lae.. , $1, $2 );
- push_ext($1);
- inc_tos($2).
- C_lxl
- $1 == 0 ==>
- Comment( lxl , $1 );
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb).
- $1 == 1 ==>
- Comment( lxl , $1 );
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos(EM_BSIZE);
- push_const(4);
- C_los(EM_WSIZE).
- default ==>
- Comment( lxl , $1 );
- {
- reg_t a;
- reg_t b;
- reg_t c;
- const_str_t n_str;
- a = alloc_reg();
- b = alloc_reg();
- c = alloc_reg();
- sprint(n_str, "%d", $1);
- "set $n_str, $a";
- "mov $reg_lb, $b";
- "1: ld [$b + EM_BSIZE], $c";
- "deccc $a";
- "bnz 1b";
- "mov $c, $b";
- push_reg(b);
- free_reg(a);
- free_reg(c);
- }.
- C_lxa ==>
- C_lxl($1);
- inc_tos(EM_BSIZE).
- C_loi
- ( $1 == 1 ) ||
- ( $1 == 2 ) ||
- ( $1 % 4 == 0 ) ==>
- Comment( loi , $1 );
- push_const($1);
- C_los(EM_WSIZE).
- default ==>
- arg_error( "loi", $1).
- C_los
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- int i;
- char *LD;
- arith size;
- const_str_t n;
- const_str_t size_str;
- Comment( los, $1);
- if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL) {
- size = pop_const(size_str);
- if (size <= 4) {
- switch (size) {
- case 1: LD = "ldub"; break;
- case 2: LD = "lduh"; break;
- case 4: LD = "ld"; break;
- default: arg_error("C_los", size);
- }
- b = alloc_reg();
- if (type_of_tos() & T_reg2)
- {
- a= pop_reg_reg(&c);
- "$LD [$a+$c], $b";
- free_reg(a);
- free_reg(c);
- }
- else
- {
- a = pop_reg_c13(n);
- "$LD [$a+$n], $b";
- free_reg(a);
- }
- push_reg(b);
- } else if (size <= MAX_UNROLL) { /* SUB-OPTIMAL */
- inc_tos(size-4);
- for (i = 0; i < size; i += 4) {
- b = alloc_reg();
- if (type_of_tos() & T_reg2)
- {
- a= pop_reg_reg(&c);
- "ld [$a+$c], $b";
- push_reg(b);
- push_reg(a);
- inc_tos_reg(c);
- }
- else
- {
- a = pop_reg_c13(n);
- "ld [$a+$n], $b";
- push_reg(b);
- if (n[0] == '-' || isdigit(n[0]))
- {
- push_reg(a);
- inc_tos(atoi(n));
- }
- else
- {
- b= alloc_reg();
- "add $a, $n, $b";
- push_reg(b);
- free_reg(a);
- }
- }
- inc_tos(-4);
- }
- pop_nop(1);
- } else
- arg_error ("loi", size);
- }
- else {
- a = alloc_reg(); /* count */
- pop_reg_as(a);
- b = pop_reg(); /* addr */
- c = alloc_reg();
- flush_cache();
- "sub $reg_sp, $a, $reg_sp" /* HACK */
- "1: deccc 4, $a"
- "ld [$b+$a], $c"
- "bnz 1b"
- "st $c, [$reg_sp+$a]" /* delay */
- free_reg(a);
- free_reg(b);
- free_reg(c);
- }
- }.
- default ==>
- arg_error("C_los", $1).
- narg4(los)
- C_ldl ==>
- Comment( ldl , $1 );
- {
- reg_t S1;
- reg_t S2;
- if (S1 = find_local($1, &S2)) {
- soft_alloc_reg(S1);
- soft_alloc_reg(S2);
- push_double_reg(S1);
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(8);
- C_los(EM_WSIZE);
- }
- }.
- C_lde.. ==>
- Comment2( lde.. , $1, $2 );
- push_ext($1);
- inc_tos($2);
- push_const(8);
- C_los(EM_WSIZE).
- C_ldf ==>
- Comment( ldf , $1 );
- inc_tos($1);
- push_const(8);
- C_los(EM_WSIZE).
- C_lpi ==>
- Comment( lpi , $1 );
- push_ext($1).
- /******************************************************************************/
- /* */
- /* Group 2 : Store instructions */
- /* */
- /******************************************************************************/
- C_stl ==>
- Comment( stl , $1 );
- {
- reg_t S1;
- if ((S1 = find_local($1, NULL))) {
- pop_reg_as(S1);
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(4);
- C_sts(EM_WSIZE);
- }
- }.
- C_ste.. ==>
- Comment2( ste.. , $1, $2 );
- push_ext($1);
- inc_tos($2);
- push_const(4);
- C_sts(EM_WSIZE).
- C_sil ==>
- Comment( sil , $1 );
- {
- reg_t S1;
- reg_t S2;
- if (S1 = find_local($1, NULL)) {
- S2 = pop_reg();
- "st $S2, [$S1]";
- free_reg(S2);
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(4);
- C_los(EM_WSIZE);
- push_const(4);
- C_sts(EM_WSIZE);
- }
- }.
- C_stf ==>
- Comment( stf , $1 );
- inc_tos($1);
- push_const(4);
- C_sts(EM_WSIZE).
- C_sti
- ( $1 == 1) ||
- ( $1 == 2) ||
- ( $1 % 4 == 0 ) ==>
- Comment( sti, $1 );
- push_const($1);
- C_sts(EM_WSIZE).
- default ==>
- arg_error( "sti", $1).
- C_sts
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- arith size;
- const_str_t n;
- const_str_t size_str;
- int i;
- char *ST;
- Comment( sts, $1);
- if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL) {
- size = pop_const(size_str);
- if (size <= 4) {
- switch (size) {
- case 1: ST = "stb"; break;
- case 2: ST = "sth"; break;
- case 4: ST = "st"; break;
- default: arg_error("C_sti", size);
- }
- c= NULL;
- if (type_of_tos() & T_reg2)
- a= pop_reg_reg(&c);
- else
- a = pop_reg_c13(n);
- if (type_of_tos() == T_float) {
- b= pop_float();
- if (size < 4) {
- "st $b,[%fp+64]";
- free_reg(b);
- b= alloc_reg();
- "ld [%fp+64],$b";
- }
- }
- else
- b = pop_reg();
- if (c)
- {
- "$ST $b, [$a+$c]";
- free_reg(c);
- }
- else
- "$ST $b, [$a+$n]";
- free_reg(a);
- free_reg(b);
- } else if (size <= MAX_UNROLL) {
- for (i = 0; i < size; i+=4) {
- c= NULL;
- if (type_of_tos() & T_reg2)
- a= pop_reg_reg(&c);
- else
- a = pop_reg_c13(n);
- if (type_of_tos() == T_float)
- b= pop_float();
- else
- b = pop_reg();
- if (c)
- "st $b, [$a+$c]";
- else
- "st $b, [$a+$n]";
- free_reg(b);
- if (c)
- {
- push_reg(a);
- inc_tos_reg(c);
- }
- else if (n[0] == '-' || isdigit(n[0]))
- {
- push_reg(a);
- inc_tos(atoi(n));
- }
- else
- {
- b= alloc_reg();
- "add $a, $n, $b";
- push_reg(b);
- free_reg(a);
- }
- inc_tos(4);
- }
- pop_nop(1);
- } else
- arg_error ("sti", size);
- }
- else {
- force_alloc_output();
- d = pop_reg(); /* size */
- a = pop_reg(); /* address */
- flush_cache();
- b = alloc_reg();
- c = alloc_reg();
- "cmp $d, 4";
- "bg,a 8f";
- "andcc $d, 3, %g0"; /* delay slot */
- "be,a 4f";
- "ld [$reg_sp], $b"; /* delay slot */
- "cmp $d, 1";
- "be,a 1f";
- "ld [$reg_sp], $b"; /* delay slot */
- "bl 0f";
- "cmp $d, 2";
- "be 2f";
- "ld [$reg_sp], $b"; /* delay slot */
- "3: set EILLINS, %o0";
- "call trp";
- "nop";
- "b 0f";
- "nop";
- "1:";
- "inc STACK_CLICK, $reg_sp";
- "b 0f";
- "stb $b, [$a]"; /* delay slot */
- "2:";
- "inc STACK_CLICK, $reg_sp";
- "b 0f";
- "sth $b, [$a]"; /* delay slot */
- "4:";
- "inc STACK_CLICK, $reg_sp";
- "b 0f";
- "st $b, [$a]"; /* delay slot */
- "8:";
- "bne 3b";
- "nop";
- "mov $d, $b";
- "9: deccc 4, $b";
- "ld [$reg_sp+$b], $c";
- "bnz 9b";
- "st $c, [$a+$b]"; /* delay slot */
- "add $reg_sp, $d, $reg_sp" /* HACK */
- "0:"
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_output();
- }
- }.
- default ==>
- arg_error( "sts", $1).
- narg4(sts)
- C_sdl ==>
- Comment( sdl , $1 );
- {
- reg_t S1;
- reg_t S2;
- S1 = find_local($1, NULL);
- if (S1)
- pop_double_reg_as(S1);
- else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- push_const(8);
- C_sts(EM_WSIZE);
- }
- }.
- C_sde.. ==>
- Comment2( sde.. , $1, $2 );
- push_ext($1);
- inc_tos($2);
- push_const(8);
- C_sts(EM_WSIZE).
- C_sdf ==>
- Comment( sdf , $1 );
- inc_tos($1);
- push_const(8);
- C_sts(EM_WSIZE).
- /******************************************************************************/
- /* */
- /* Group 3 : Integer arithmetic */
- /* */
- /******************************************************************************/
- C_adi
- $1 == 4 ==>
- Comment( adi , $1 );
- if ((type_of_tos()) == T_cst) {
- arith n;
- n = pop_const(NULL);
- inc_tos(n);
- } else {
- reg_t a;
- reg_t b;
- reg_t c;
- a = pop_reg();
- inc_tos_reg(a);
- }.
- default ==>
- arg_error( "adi", $1).
- narg4(adi)
- C_sbi
- $1 == 4 ==>
- Comment( sbi , $1 );
- if ((type_of_tos()) == T_cst) {
- arith n;
- n = pop_const(NULL);
- inc_tos(-n);
- } else {
- reg_t a;
- reg_t b;
- reg_t c;
- a = pop_reg();
- b = pop_reg();
- c = alloc_reg();
- "sub $b, $a, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }.
- default ==>
- arg_error( "sbi", $1).
- narg4(sbi)
- C_mli
- $1 == 4 ==>
- {
- unsigned int n0;
- unsigned int n1;
- reg_t orig;
- reg_t a;
- reg_t b;
- reg_t c;
- unsigned int n;
- const_str_t n_str;
- Comment( mli , $1 );
- if (type_of_tos() == T_cst) {
- n = pop_const(NULL);
- orig = pop_reg();
- c = reg_g0;
- while (n) {
- for (n0 = 0; !(n & 1); n>>=1)
- ++n0;
- for (n1 = 0; n & 1; n>>=1)
- ++n1;
- if (n0) {
- a = alloc_reg();
- sprint(n_str, "%d", n0);
- "sll $orig, $n_str, $a";
- free_reg(orig);
- orig = a;
- }
- if (n1 == 1) {
- if (c == reg_g0) {
- soft_alloc_reg(orig);
- c = orig;
- } else {
- a = alloc_reg();
- "add $c, $orig, $a";
- free_reg(c);
- c = a;
- }
- n <<= n1;
- } else {
- a = alloc_reg();
- sprint(n_str, "%d", n1);
- "sll $orig, $n_str, $a";
- b = alloc_reg();
- "sub $a, $orig, $b";
- free_reg(orig);
- orig = a;
- if (c == reg_g0)
- c = b;
- else {
- a = alloc_reg();
- "add $c, $b, $a";
- free_reg(b);
- free_reg(c);
- c = a;
- }
- }
- }
- push_reg(c);
- free_reg(orig);
- } else {
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- "call mli4";
- "nop" /* delay */
- free_output();
- forced_alloc_reg(reg_o0);
- push_reg(reg_o0);
- }
- }.
- default ==>
- arg_error( "mli", $1).
- narg4(mli)
- C_dvi
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- int n;
- int n_exp;
- const_str_t n_exp_str;
- Comment( dvi , $1 );
- #if MATH_DIVIDE
- if (type_of_tos() == T_cst &&
- power_of_2(top_const(), &n_exp))
- {
- sprint (n_exp_str, "%d", n_exp);
- n= pop_const(NULL);
- a= pop_reg();
- b= alloc_reg();
- "sra $a, $n_exp_str, $b";
- free_reg(a);
- push_reg(b);
- }
- else
- #endif
- {
- force_alloc_output();
- pop_reg_as(reg_o1); /* denominator */
- pop_reg_as(reg_o0); /* numerator */
- #if MATH_DIVIDE
- "call mathdvi4";
- #else
- "call dvi4";
- #endif
- "nop"
- free_output();
- forced_alloc_reg(reg_o0);
- push_reg(reg_o0);
- }
- }.
- default ==>
- arg_error( "dvi", $1).
- narg4(dvi)
- C_rmi
- $1 == 4 ==>
- Comment( rmi , $1 );
- {
- force_alloc_output();
- pop_reg_as(reg_o1); /* denominator */
- pop_reg_as(reg_o0); /* numerator */
- #if MATH_DIVIDE
- "call mathdvi4";
- #else
- "call dvi4";
- #endif
- "nop"
- free_output();
- forced_alloc_reg(reg_o1);
- push_reg(reg_o1);
- }.
- default ==>
- arg_error( "rmi", $1).
- narg4(rmi)
- C_ngi
- $1 == 4 ==>
- Comment( ngi , $1 );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b = alloc_reg();
- "sub %g0, $a, $b";
- push_reg(b);
- free_reg(a);
- }.
- default ==>
- arg_error( "ngi", $1).
- narg4(ngi)
- C_sli
- $1 == 4 ==>
- Comment( sli , $1 );
- {
- reg_t a;
- reg_t b;
- reg_t c;
- b = alloc_reg();
- if ((type_of_tos() == T_cst) &&
- (const13(top_const()))) {
- const_str_t n;
- pop_const(n);
- a = pop_reg();
- "sll $a, $n, $b";
- } else {
- c = pop_reg();
- a = pop_reg();
- "sll $a, $c, $b";
- free_reg(c);
- }
- free_reg(a);
- push_reg(b);
- }.
- default ==>
- arg_error( "sli", $1).
- narg4(sli)
- C_sri
- $1 == 4 ==>
- Comment( sri , $1 );
- {
- reg_t a;
- reg_t b;
- reg_t c;
- b = alloc_reg();
- if ((type_of_tos() == T_cst) &&
- (const13(top_const()))) {
- const_str_t n;
- pop_const(n);
- a = pop_reg();
- "sra $a, $n, $b";
- } else {
- c = pop_reg();
- a = pop_reg();
- "sra $a, $c, $b";
- free_reg(c);
- }
- free_reg(a);
- push_reg(b);
- }.
- default ==>
- arg_error( "sri", $1).
- narg4(sri)
- /******************************************************************************/
- /* */
- /* Group 4 : Unsigned arithmetic */
- /* */
- /******************************************************************************/
- C_adu ==>
- Comment( adu , $1 );
- C_adi( w).
- narg4(adu)
- C_sbu ==>
- Comment( sbu , $1 );
- C_sbi( w).
- narg4(sbu)
- C_mlu
- $1 == 4 ==>
- Comment( mlu , $1 );
- C_mli($1).
- /*
- {
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- "call mlu4";
- "nop"
- free_output();
- forced_alloc_reg(reg_o0);
- push_reg(reg_o0);
- }.
- */
- default ==>
- arg_error( "mlu", $1).
- narg4(mlu)
- C_dvu
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- unsigned n;
- int n_exp;
- const_str_t n_exp_str;
- Comment( dvu , $1 );
- if (type_of_tos() == T_cst &&
- uns_power_of_2(top_const(), &n_exp))
- {
- sprint (n_exp_str, "%d", n_exp);
- n= pop_const(NULL);
- a= pop_reg();
- b= alloc_reg();
- "srl $a, $n_exp_str, $b";
- free_reg(a);
- push_reg(b);
- }
- else
- {
- force_alloc_output();
- pop_reg_as(reg_o1); /* denominator */
- pop_reg_as(reg_o0); /* numerator */
- "call dvu4";
- "nop"
- free_output();
- forced_alloc_reg(reg_o0);
- push_reg(reg_o0);
- }
- }.
- default ==>
- arg_error( "dvu", $1).
- narg4(dvu)
- C_rmu
- $1 == 4 ==>
- Comment( rmu , $1 );
- {
- force_alloc_output();
- pop_reg_as(reg_o1);
- pop_reg_as(reg_o0);
- "call dvu4";
- "nop"
- free_output();
- forced_alloc_reg(reg_o1);
- push_reg(reg_o1);
- }.
- default ==>
- arg_error( "rmu", $1).
- narg4(rmu)
- C_slu ==>
- Comment( slu , $1 );
- C_sli($1).
- narg4(slu)
- C_sru
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- Comment( sru , $1 );
- b = alloc_reg();
- if ((type_of_tos() == T_cst) &&
- (const13(top_const()))) {
- const_str_t n;
- pop_const(n);
- a = pop_reg();
- "srl $a, $n, $b";
- } else {
- c = pop_reg();
- a = pop_reg();
- "srl $a, $c, $b";
- free_reg(c);
- }
- free_reg(a);
- push_reg(b);
- }.
- default ==>
- arg_error( "sru", $1).
- narg4(sru)
- /******************************************************************************/
- /* */
- /* Group 5 : Floating point arithmetic */
- /* */
- /******************************************************************************/
- C_adf ==>
- {
- Comment( adf, $1);
- push_const($1);
- C_adf_narg();
- }.
- C_adf_narg ==>
- {
- reg_t f1;
- reg_t f2;
- reg_t f3;
- int n;
- Comment0( adf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_WSIZE)
- {
- f1= pop_float();
- f2= pop_float();
- f3= alloc_float();
- "fadds $f2, $f1, $f3";
- free_reg(f1);
- free_reg(f2);
- push_reg(f3);
- }
- else if (n == EM_DSIZE)
- {
- f1= pop_double(NULL);
- f2= pop_double(NULL);
- f3= alloc_double(NULL);
- "faddd $f1, $f2, $f3";
- free_double_reg(f1);
- free_double_reg(f2);
- push_double_reg(f3);
- }
- else
- arg_error ("unimp adf", n);
- }
- else
- not_implemented ("adf_narg");
- }.
- C_sbf ==>
- {
- Comment( sbf, $1);
- push_const($1);
- C_sbf_narg();
- }.
- C_sbf_narg ==>
- {
- reg_t f1;
- reg_t f2;
- reg_t f3;
- int n;
- Comment0( sbf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_WSIZE)
- {
- f1= pop_float();
- f2= pop_float();
- f3= alloc_float();
- "fsubs $f2, $f1, $f3";
- free_reg(f1);
- free_reg(f2);
- push_reg(f3);
- }
- else if (n == EM_DSIZE)
- {
- f1= pop_double(NULL);
- f2= pop_double(NULL);
- f3= alloc_double(NULL);
- "fsubd $f2, $f1, $f3";
- free_double_reg(f1);
- free_double_reg(f2);
- push_double_reg(f3);
- }
- else
- arg_error ("unimp sbf", n);
- }
- else
- not_implemented ("sbf_narg");
- }.
- C_mlf ==>
- {
- Comment( mlf, $1);
- push_const($1);
- C_mlf_narg();
- }.
- C_mlf_narg ==>
- {
- reg_t f1;
- reg_t f2;
- reg_t f3;
- int n;
- Comment0( mlf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_WSIZE)
- {
- f1= pop_float();
- f2= pop_float();
- f3= alloc_float();
- "fmuls $f2, $f1, $f3";
- free_reg(f1);
- free_reg(f2);
- push_reg(f3);
- }
- else if (n == EM_DSIZE)
- {
- f1= pop_double(NULL);
- f2= pop_double(NULL);
- f3= alloc_double(NULL);
- "fmuld $f2, $f1, $f3";
- free_double_reg(f1);
- free_double_reg(f2);
- push_double_reg(f3);
- }
- else
- arg_error ("unimp mlf", n);
- }
- else
- not_implemented ("mlf_narg");
- }.
- C_dvf ==>
- {
- Comment( dvf, $1);
- push_const($1);
- C_dvf_narg();
- }.
- C_dvf_narg ==>
- {
- reg_t f1;
- reg_t f2;
- reg_t f3;
- int n;
- Comment0( dvf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_WSIZE)
- {
- f1= pop_float();
- f2= pop_float();
- f3= alloc_float();
- "fdivs $f2, $f1, $f3";
- free_reg(f1);
- free_reg(f2);
- push_reg(f3);
- }
- else if (n == EM_DSIZE)
- {
- f1= pop_double(NULL);
- f2= pop_double(NULL);
- f3= alloc_double(NULL);
- "fdivd $f2, $f1, $f3";
- free_double_reg(f1);
- free_double_reg(f2);
- push_double_reg(f3);
- }
- else
- arg_error ("unimp dvf", n);
- }
- else
- not_implemented ("dvf_narg");
- }.
- C_ngf ==>
- {
- Comment( ngf, $1);
- push_const($1);
- C_ngf_narg();
- }.
- C_ngf_narg ==>
- {
- reg_t f1;
- reg_t f2;
- int n;
- Comment0( ngf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_WSIZE || n == EM_DSIZE)
- {
- f1= pop_float();
- f2= alloc_float();
- "fnegs $f1, $f2";
- free_reg(f1);
- push_reg(f2);
- }
- else
- arg_error ("unimp ngf", n);
- }
- else
- not_implemented ("ngf_narg");
- }.
- C_fif ==>
- Comment( fif, $1);
- push_const($1);
- C_fif_narg().
- C_fif_narg ==>
- {
- int n;
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- Comment0( fif_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n==4)
- {
- "! unimplemented fif 4";
- "st %g0, [%g0]"; /* unimp */
- }
- else if (n==8)
- {
- flush_cache();
- "call fif8";
- "nop";
- }
- else
- arg_error ("fif", n);
- }
- else
- {
- a= alloc_reg();
- flush_cache();
- force_alloc_output();
- b= alloc_reg();
- c= alloc_reg();
- d= pop_reg();
- "cmp 8, $d";
- "be 8f";
- "nop";
- "cmp 4, $d";
- "bne 0f";
- "nop";
- "4:";
- "! unimplemented fif 4";
- "st %g0, [%g0]";
- "b 1f";
- "0:";
- "set EILLINS, $reg_o0";
- "call trp";
- "nop";
- "b 1f";
- "8:";
- "call fif8";
- "nop";
- "1:";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_output();
- }
- }.
- C_fef ==>
- Comment( fef, $1);
- push_const($1);
- C_fef_narg().
- C_fef_narg ==>
- {
- int n;
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- Comment0( fef_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n==4)
- {
- "! unimplemented fef 4";
- "st %g0, [%g0]"; /* unimp */
- }
- else if (n==8)
- {
- flush_cache();
- "call fef8";
- "nop";
- }
- else
- arg_error ("fef", n);
- }
- else
- {
- a= alloc_reg();
- flush_cache();
- force_alloc_output();
- b= alloc_reg();
- c= alloc_reg();
- d= pop_reg();
- "cmp 8, $d";
- "be 8f";
- "nop";
- "cmp 4, $d";
- "bne 0f";
- "nop";
- "4:";
- "! unimplemented fef 4";
- "st %g0, [%g0]";
- "b 1f";
- "0:";
- "set EILLINS, $reg_o0";
- "call trp";
- "nop";
- "b 1f";
- "8:";
- "call fef8";
- "nop";
- "1:";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_output();
- }
- }.
- /******************************************************************************/
- /* */
- /* Group 6 : Pointer arithmetic */
- /* */
- /******************************************************************************/
- C_adp ==>
- Comment( adp , $1 );
- inc_tos($1).
- C_ads
- $1 == 4 ==>
- Comment( ads , $1 );
- if ((type_of_tos()) == T_cst) {
- arith n;
- n = pop_const(NULL);
- inc_tos(n);
- } else {
- reg_t a;
- reg_t b;
- reg_t c;
- a = pop_reg();
- inc_tos_reg(a);
- }.
- default ==>
- arg_error( "ads", $1).
- narg4(ads)
- C_sbs
- $1 == 4 ==>
- Comment( sbs , $1 );
- if ((type_of_tos()) == T_cst) {
- arith n;
- n = pop_const(NULL);
- inc_tos(-n);
- } else {
- reg_t a;
- reg_t b;
- reg_t c;
- a = pop_reg();
- b = pop_reg();
- c = alloc_reg();
- "sub $b, $a, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }.
- default ==>
- arg_error( "sbs", $1).
- narg4(sbs)
- /******************************************************************************/
- /* */
- /* Group 7 : Increment/decrement/zero */
- /* */
- /******************************************************************************/
- C_inc ==>
- Comment0( inc );
- inc_tos(1).
- C_inl ==>
- Comment( inl , $1 );
- {
- reg_t S1;
- if (S1 = find_local($1, NULL)) {
- change_reg(S1);
- "inc 1, $S1";
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- C_loi(4);
- C_inc();
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- C_sti(4);
- }
- }.
- C_ine.. ==>
- {
- char *ename;
- const_str_t evalue;
- reg_t a;
- reg_t b;
- Comment2( ine.. , $1, $2 );
- a= alloc_reg();
- b= alloc_reg();
- ename= $1;
- sprint(evalue, "%d", $2);
- "sethi %hi($ename+$evalue), $a";
- "ld [$a+%lo($ename+$evalue)], $b";
- "inc $b";
- "st $b, [$a+%lo($ename+$evalue)]"
- free_reg(a);
- free_reg(b);
- }.
- C_dec ==>
- Comment0( dec );
- inc_tos(-1).
- C_del ==>
- Comment( del , $1 );
- {
- reg_t S1;
- if (S1 = find_local($1, NULL)) {
- change_reg(S1);
- "dec 1, $S1";
- } else {
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- C_loi(4);
- C_dec();
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- C_sti(4);
- }
- }.
- C_dee.. ==>
- {
- char *ename;
- const_str_t evalue;
- reg_t a;
- reg_t b;
- Comment2( dee.. , $1, $2 );
- a= alloc_reg();
- b= alloc_reg();
- ename= $1;
- sprint(evalue, "%d", $2);
- "sethi %hi($ename+$evalue), $a";
- "ld [$a+%lo($ename+$evalue)], $b";
- "dec $b";
- "st $b, [$a+%lo($ename+$evalue)]"
- free_reg(a);
- free_reg(b);
- }.
- C_zrl ==>
- Comment( zrl , $1 );
- {
- reg_t S1;
- if (S1 = find_local($1, NULL)) {
- change_reg(S1);
- "mov 0, $S1";
- } else {
- push_const(0);
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos($1);
- C_sti(4);
- }
- }.
- C_zre.. ==>
- {
- char *ename;
- const_str_t evalue;
- reg_t a;
- Comment2( zre.. , $1, $2 );
- a= alloc_reg();
- ename= $1;
- sprint(evalue, "%d", $2);
- "sethi %hi($ename+$evalue), $a";
- "st %g0, [$a+%lo($ename+$evalue)]"
- free_reg(a);
- }.
- C_zrf ==>
- Comment( zrf , $1 );
- push_const($1);
- C_zrf_narg().
- C_zrf_narg ==>
- Comment0( zrf_narg );
- C_zer_narg().
- C_zer ==>
- Comment( zer, $1);
- push_const($1);
- C_zer_narg().
- C_zer_narg ==>
- {
- reg_t a;
- int n;
- const_str_t n_str;
- Comment0( zer_narg);
- if (type_of_tos() == T_cst && top_const() <= 8)
- {
- n= pop_const(n_str);
- if (n == 4)
- push_const(0);
- else if (n == 8)
- {
- push_const(0);
- push_const(0);
- }
- else
- arg_error ("zer", n);
- }
- else
- {
- a= alloc_reg();
- pop_reg_as(a);
- flush_cache();
- "sub $reg_sp, $a, $reg_sp";
- "1:"
- "deccc 4, $a"; /* hack */
- "st %g0, [$reg_sp+$a]";
- "bne 1b";
- "nop";
- free_reg(a);
- }
- }.
- /******************************************************************************/
- /* */
- /* Group 8 : Convert */
- /* */
- /******************************************************************************/
- /* cii, ciu, cuu, cui are assumed to be called with legal arguments only */
- C_cii ==>
- {
- reg_t a; /* target obj size */
- reg_t b; /* src obj size */
- int n1; /* target obj size */
- int n2; /* src obj size */
- const_str_t n1_str;
- Comment0( cii );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- pop_reg_as(a);
- b= pop_reg();
- }
- else
- {
- n1= pop_const(n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- a = pop_reg();
- if (n1 > EM_WSIZE)
- arg_error ("unimp cii", n1);
- if (n2 > EM_WSIZE)
- arg_error ("unimp cii", n2);
- if (n2 < EM_WSIZE) {
- b = alloc_reg();
- if (n2 == 1)
- {
- "sll $a, 24, $b";
- "sra $b, 24, $b";
- }
- else if (n2 == 2)
- {
- "sll $a, 16, $b";
- "sra $b, 16, $b";
- }
- free_reg(a);
- push_reg(b);
- }
- else
- push_reg(a);
- } else {
- flush_cache();
- "cmp $a, $b";
- "ble 4f";
- "nop"; /* delay slot */
- "cmp $b, 1";
- "bne 2f";
- "nop"; /* delay slot */
- "1:";
- "b 3f";
- "ldsb [$reg_sp+3], $a"; /* delay slot */
- "2:"
- "ldsh [$reg_sp+2], $a";
- "3:";
- "st $a, [$reg_sp]";
- "4:";
- free_reg(a);
- free_reg(b);
- }
- }.
- C_cuu ==>
- Comment0( cuu );
- pop_nop(2).
- C_ciu ==>
- Comment0( ciu );
- pop_nop(2).
- C_cui ==>
- Comment0( cui );
- pop_nop(2).
- C_cfi ==>
- {
- reg_t a; /* target (int) size */
- reg_t b; /* src (float) size */
- reg_t s1;
- reg_t s2;
- reg_t d1;
- reg_t d2;
- int n1; /* target (int) size */
- int n2; /* src (float) size */
- const_str_t n1_str;
- Comment0( cfi );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= pop_reg();
- b= pop_reg();
- }
- else
- {
- n1= pop_const (n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- if (n1 != EM_WSIZE)
- arg_error ("unimp cfi", n1);
- if (n2 == EM_WSIZE)
- {
- s1= pop_float();
- d1= alloc_float();
- "fstoi $s1, $d1";
- free_reg(s1);
- push_reg(d1);
- }
- else if (n2 == EM_DSIZE)
- {
- s1= pop_double(NULL);
- d1= alloc_float();
- "fdtoi $s1, $d1";
- free_double_reg(s1);
- push_reg(d1);
- }
- else
- arg_error ("unimp cfi", n2);
- }
- else
- {
- d1= alloc_float();
- flush_cache();
- force_alloc_output();
- "cmp $a, 4";
- "bne 0f";
- "nop";
- "cmp $b, 4";
- "be 4f";
- "nop";
- "cmp $b, 8";
- "bne 0f";
- "nop";
- "8:";
- "ld [$reg_sp], %f0";
- "ld [$reg_sp+STACK_CLICK], %f1";
- "fdtoi %f0, $d1";
- "b 1f";
- "inc 2*STACK_CLICK, $reg_sp"; /* delay slot */
- "4:";
- "ld [$reg_sp+2*STACK_CLICK], %f0";
- "fstoi %f0, $d1";
- "b 1f";
- "inc STACK_CLICK, $reg_sp"; /* delay slot */
- "0:";
- "set E_EM_CFI, %o0";
- "call trp";
- "nop";
- "1:";
- free_reg(a);
- free_reg(b);
- push_reg(d1);
- free_output();
- }
- }.
- C_cfu ==>
- {
- reg_t a; /* target (int) size */
- reg_t b; /* src (float) size */
- int n1; /* target (int) size */
- int n2; /* src (float) size */
- const_str_t n1_str;
- Comment0( cfu );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= pop_reg();
- b= pop_reg();
- }
- else
- {
- n1= pop_const (n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- if (n1 != EM_WSIZE)
- arg_error ("unimp cfu", n1);
- force_alloc_output();
- flush_cache();
- if (n2 == EM_WSIZE)
- {
- "call cfu4";
- "nop";
- }
- else if (n2 == EM_DSIZE)
- {
- "call cfu8";
- "nop";
- }
- else
- arg_error ("unimp cfu", n2);
- soft_alloc_reg(reg_o0);
- free_output();
- push_reg(reg_o0);
- }
- else
- {
- flush_cache();
- force_alloc_output();
- "cmp $a, 4";
- "bne 0f";
- "nop";
- "cmp $b, 4";
- "be 4f";
- "nop";
- "cmp $b, 8";
- "bne 0f";
- "nop";
- "8:";
- "call cfu8";
- "nop";
- "b 1f";
- "4:";
- "call cfu4";
- "nop";
- "b 1f";
- "0:";
- "set E_EM_CFU, %o0";
- "call trp";
- "nop";
- "1:";
- free_reg(a);
- free_reg(b);
- soft_alloc_reg(reg_o0);
- free_output();
- push_reg(reg_o0);
- }
- }.
- C_cff ==>
- {
- reg_t a; /* target (int) size */
- reg_t b; /* src (float) size */
- int n1; /* target (int) size */
- int n2; /* src (float) size */
- const_str_t n1_str;
- Comment0( cff );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= pop_reg();
- b= pop_reg();
- }
- else
- {
- n1= pop_const (n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- if (n1 == EM_WSIZE)
- {
- if (n2 == EM_DSIZE)
- {
- a= pop_double(NULL);
- b= alloc_float();
- "fdtos $a, $b";
- free_double_reg(a);
- push_reg(b);
- } else if (n2 != EM_WSIZE)
- arg_error ("unimp cff", n2);
- }
- else if (n1 == EM_DSIZE)
- {
- if (n2 == EM_WSIZE)
- {
- a= pop_float();
- b= alloc_double(NULL);
- "fstod $a, $b";
- free_reg(a);
- push_double_reg(b);
- } else if (n2 != EM_DSIZE)
- arg_error ("unimp cff", n2);
- }
- else
- arg_error ("unimp cff", n1);
- }
- else
- {
- flush_cache();
- force_alloc_output();
- "cmp $b, $a";
- "be 1f";
- "nop"; /* delay slot */
- "cmp $b, 4";
- "be 4f";
- "nop";
- "cmp $b, 8";
- "be 8f";
- "nop";
- "0:"
- "set E_EM_CFF, %o0";
- "call trp";
- "nop";
- "4:";
- "cmp $a, 8";
- "bne 0b";
- "nop";
- "ld [$reg_sp], %f0";
- "fstod %f0, %f2";
- "dec STACK_CLICK, $reg_sp";
- "st %f2, [$reg_sp]";
- "st %f3, [$reg_sp+STACK_CLICK]";
- "b 1f";
- "nop";
- "8:";
- "cmp $a, 4";
- "bne 0b";
- "nop";
- "ld [$reg_sp], %f0";
- "ld [$reg_sp+STACK_CLICK], %f1";
- "fdtos %f0, %f2";
- "inc STACK_CLICK, $reg_sp";
- "st %f2, [$reg_sp]";
- "1:";
- free_reg(a);
- free_reg(b);
- free_output();
- }
- }.
- C_cif ==>
- {
- reg_t a; /* target (float) size */
- reg_t b; /* src (int) size */
- int n1; /* target (float) size */
- int n2; /* src (int) size */
- reg_t r1;
- reg_t f1;
- const_str_t n1_str;
- Comment0( cif );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= pop_reg();
- b= pop_reg();
- }
- else
- {
- n1= pop_const (n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- if (n2 != EM_WSIZE)
- arg_error ("unimp cif", n2);
- else
- {
- if (n1 == EM_WSIZE)
- {
- r1= pop_float();
- f1= alloc_float();
- "fitos $r1, $f1";
- free_reg(r1);
- push_reg(f1);
- }
- else if (n1 == EM_DSIZE)
- {
- r1= pop_float();
- f1= alloc_double(NULL);
- "fitod $r1, $f1";
- free_reg(r1);
- push_double_reg(f1);
- }
- else
- arg_error ("unimp cif", n1);
- }
- }
- else
- {
- flush_cache();
- force_alloc_output();
- "cmp $a, 4";
- "be 4f";
- "nop"; /* delay slot */
- "cmp $a, 8";
- "be 8f";
- "nop"; /* delay slot */
- "1:"
- "set E_EM_CUF, %o0";
- "call trp";
- "nop";
- "4:";
- "cmp $b, 4";
- "bne 1b";
- "nop"; /* delay slot */
- "ld [$reg_sp], %f0";
- "fitos %f0, %f1";
- "b 0f";
- "st %f1, [$reg_sp]"; /* delay slot */
- "8:";
- "dec STACK_CLICK, $reg_sp";
- "cmp $b, 4";
- "bne 1b";
- "nop"; /* delay slot */
- "ld [$reg_sp+STACK_CLICK], %f0";
- "fitod %f0, %f2";
- "st %f2, [$reg_sp]";
- "b 0f";
- "st %f3, [$reg_sp+STACK_CLICK]"; /* delay slot */
- "0:";
- free_reg(a);
- free_reg(b);
- free_output();
- }
- }.
- C_cuf ==>
- {
- reg_t a; /* target (float) size */
- reg_t b; /* src (int) size */
- reg_t c;
- reg_t fs1;
- reg_t fs2;
- reg_t fd1;
- reg_t fd2;
- int n1; /* target (float) size */
- int n2; /* src (int) size */
- const_str_t n1_str;
- Comment0( cuf );
- a= NULL;
- b= NULL;
- if (type_of_tos() != T_cst)
- {
- a= pop_reg();
- b= pop_reg();
- }
- else
- {
- n1= pop_const (n1_str);
- if (type_of_tos() != T_cst)
- {
- a= alloc_reg();
- "set $n1_str, $a";
- b= pop_reg();
- }
- else
- n2= pop_const(NULL);
- }
- if (!a)
- {
- if (n2 != EM_WSIZE)
- arg_error ("unimp cuf", n2);
- else
- {
- if (n1 == EM_WSIZE)
- {
- fs1= pop_float();
- fs2= alloc_float();
- a= alloc_reg();
- "fitos $fs1, $fs2";
- "sethi %hi(Fs0), $a";
- "ld [$a+%lo(Fs0)], $fs1";
- "fcmpes $fs2, $fs1";
- "nop";
- "fbge 0f";
- "nop";
- "sethi %hi(Fs80000000), $a";
- "ld [$a+%lo(Fs80000000)], $fs1";
- "fadds $fs1, $fs2, $fs2";
- "0:";
- push_reg(fs2);
- free_reg(fs1);
- free_reg(a);
- }
- else if (n1 == EM_DSIZE)
- {
- fs1= pop_float();
- fd1= alloc_double(NULL);
- fd2= alloc_double(NULL);
- a= alloc_reg();
- "fitod $fs1, $fd2";
- "sethi %hi(Fd0), $a";
- "ldd [$a+%lo(Fd0)], $fd1";
- "fcmped $fd2, $fd1";
- "nop";
- "fbge 0f";
- "nop";
- "sethi %hi(Fd80000000), $a";
- "ldd [$a+%lo(Fd80000000)], $fd1";
- "faddd $fd1, $fd2, $fd2";
- "0:";
- free_reg(fs1);
- free_double_reg(fd1);
- push_double_reg(fd2);
- free_reg(a);
- }
- else
- arg_error ("unimp cuf", n1);
- }
- }
- else
- {
- #if 0
- flush_cache();
- "cmp $a, 4";
- "be 4f";
- "nop"; /* delay slot */
- "cmp $a, 8";
- "be 8f";
- "nop"; /* delay slot */
- "1:"
- "set E_EM_CUF, %o0";
- "set fatal, %g1";
- "jmp %g1";
- "nop";
- "4:";
- "cmp $b, 4";
- "bne 1b";
- "nop"; /* delay slot */
- "ld [$reg_sp], $c";
- "tst $c";
- "bl 5f";
- "nop"; /* delay slot */
- "ld [$reg_sp], %f0";
- "fitos %f0, %f1";
- "b 0f";
- "st %f1, [$reg_sp]"; /* delay slot */
- "5:";
- "set MAX_INT, $b";
- "sub $c, $b, $a";
- "st $a, [$reg_sp]";
- "ld [$reg_sp], %f0";
- "st $b, [$reg_sp]";
- "ld [$reg_sp], %f1";
- "fitos %f0, %f2";
- "fitos %f1, %f3";
- "fadds %f2, %f3, %f0";
- "b 0f";
- "st %f0, [$reg_sp]"; /* delay slot */
- "8:";
- "dec STACK_CLICK, $reg_sp";
- "cmp $b, 4";
- "bne 1b";
- "nop"; /* delay slot */
- "ld [$reg_sp+STACK_CLICK], $c";
- "tst $c";
- "bl 9f";
- "nop"; /* delay slot */
- "ld [$reg_sp+STACK_CLICK], %f0";
- "fitod %f0, %f2";
- "st %f2, [$reg_sp]";
- "b 0f";
- "st %f3, [$reg_sp+STACK_CLICK]"; /* delay slot */
- "9:";
- "set MAX_INT, $b";
- "sub $c, $b, $a";
- "st $a, [$reg_sp+STACK_CLICK]";
- "ld [$reg_sp+STACK_CLICK], %f0";
- "st $b, [$reg_sp+STACK_CLICK]";
- "ld [$reg_sp+STACK_CLICK], %f1";
- "fitod %f0, %f2";
- "fitod %f1, %f4";
- "fadds %f2, %f4, %f0";
- "st %f0, [$reg_sp]";
- "b 0f";
- "st %f1, [$reg_sp+STACK_CLICK]"; /* delay slot */
- "0:";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- #else
- not_implemented ("cuf");
- #endif
- }
- }.
- /******************************************************************************/
- /* */
- /* Group 9 : Logical */
- /* */
- /******************************************************************************/
- C_and ==>
- Comment( and, $1);
- push_const($1);
- C_and_narg().
- C_and_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- reg_t f;
- const_str_t a_cst_str;
- const_str_t b_cst_str;
- const_str_t c_cst_str;
- const_str_t d_cst_str;
- int n;
- const_str_t n_str;
- Comment0( and_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(n_str);
- if (n == EM_WSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (!a && !b)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- c= alloc_reg();
- if (a)
- if (b)
- "and $a, $b, $c";
- else
- "and $a, $b_cst_str, $c";
- else
- "and $b, $a_cst_str, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- else if (n == EM_DSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- c= NULL;
- pop_const (c_cst_str);
- }
- else
- c= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- d= NULL;
- pop_const (d_cst_str);
- }
- else
- d= pop_reg();
- if (!b && !d)
- {
- b= alloc_reg();
- "mov $b_cst_str, $b";
- }
- e= alloc_reg();
- if (b)
- if (d)
- "and $b, $d, $e";
- else
- "and $b, $d_cst_str, $e";
- else
- "and $d, $b_cst_str, $e";
- free_reg(b);
- free_reg(d);
- push_reg(e);
- if (!a && !c)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- e= alloc_reg();
- if (a)
- if (c)
- "and $a, $c, $e";
- else
- "and $a, $c_cst_str, $e";
- else
- "and $c, $a_cst_str, $e";
- free_reg(a);
- free_reg(c);
- push_reg(e);
- }
- else if (!(n % EM_WSIZE))
- {
- a= alloc_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "set $n_str, $a";
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "and $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
- }
- else
- arg_error ("unimp and", n);
- }
- else
- {
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "and $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
-
- }
- }.
- C_ior ==>
- Comment( ior, $1);
- push_const($1);
- C_ior_narg().
- C_ior_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- reg_t f;
- const_str_t a_cst_str;
- const_str_t b_cst_str;
- const_str_t c_cst_str;
- const_str_t d_cst_str;
- int n;
- const_str_t n_str;
- Comment0( ior_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(n_str);
- if (n == EM_WSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (!a && !b)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- c= alloc_reg();
- if (a)
- if (b)
- "or $a, $b, $c";
- else
- "or $a, $b_cst_str, $c";
- else
- "or $b, $a_cst_str, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- else if (n == EM_DSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- c= NULL;
- pop_const (c_cst_str);
- }
- else
- c= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- d= NULL;
- pop_const (d_cst_str);
- }
- else
- d= pop_reg();
- if (!b && !d)
- {
- b= alloc_reg();
- "mov $b_cst_str, $b";
- }
- e= alloc_reg();
- if (b)
- if (d)
- "or $b, $d, $e";
- else
- "or $b, $d_cst_str, $e";
- else
- "or $d, $b_cst_str, $e";
- free_reg(b);
- free_reg(d);
- push_reg(e);
- if (!a && !c)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- e= alloc_reg();
- if (a)
- if (c)
- "or $a, $c, $e";
- else
- "or $a, $c_cst_str, $e";
- else
- "or $c, $a_cst_str, $e";
- free_reg(a);
- free_reg(c);
- push_reg(e);
- }
- else if (!(n % EM_WSIZE))
- {
- a= alloc_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "set $n_str, $a";
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "or $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
- }
- else
- arg_error ("unimp ior", n);
- }
- else
- {
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "or $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
- }
- }.
- C_xor ==>
- Comment( xor, $1);
- push_const($1);
- C_xor_narg().
- C_xor_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- reg_t f;
- const_str_t a_cst_str;
- const_str_t b_cst_str;
- const_str_t c_cst_str;
- const_str_t d_cst_str;
- int n;
- const_str_t n_str;
- Comment0( xor_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(n_str);
- if (n == EM_WSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (!a && !b)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- c= alloc_reg();
- if (a)
- if (b)
- "xor $a, $b, $c";
- else
- "xor $a, $b_cst_str, $c";
- else
- "xor $b, $a_cst_str, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- else if (n == EM_DSIZE)
- {
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- a= NULL;
- pop_const (a_cst_str);
- }
- else
- a= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- b= NULL;
- pop_const (b_cst_str);
- }
- else
- b= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- c= NULL;
- pop_const (c_cst_str);
- }
- else
- c= pop_reg();
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- d= NULL;
- pop_const (d_cst_str);
- }
- else
- d= pop_reg();
- if (!b && !d)
- {
- b= alloc_reg();
- "mov $b_cst_str, $b";
- }
- e= alloc_reg();
- if (b)
- if (d)
- "xor $b, $d, $e";
- else
- "xor $b, $d_cst_str, $e";
- else
- "xor $d, $b_cst_str, $e";
- free_reg(b);
- free_reg(d);
- push_reg(e);
- if (!a && !c)
- {
- a= alloc_reg();
- "mov $a_cst_str, $a";
- }
- e= alloc_reg();
- if (a)
- if (c)
- "xor $a, $c, $e";
- else
- "xor $a, $c_cst_str, $e";
- else
- "xor $c, $a_cst_str, $e";
- free_reg(a);
- free_reg(c);
- push_reg(e);
- }
- else if (!(n % EM_WSIZE))
- {
- a= alloc_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "set $n_str, $a";
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "xor $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
- }
- else
- arg_error ("unimp xor", n);
- }
- else
- {
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- e= alloc_reg();
- f= alloc_reg();
- flush_cache();
- "add $reg_sp, $a, $b";
- "mov $a, $c";
- "1:";
- "deccc 4, $c";
- "ld [$reg_sp+$c], $d";
- "ld [$b+$c], $e";
- "xor $d, $e, $f";
- "bnz 1b";
- "st $f, [$b+$c]"; /* delay slot */
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- free_reg(f);
- }
- }.
- C_com ==>
- Comment( com, $1);
- push_const($1);
- C_com_narg().
- C_com_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int n;
- int i;
- const_str_t i_str;
- Comment0( com_narg );
- if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
- {
- n= pop_const(NULL);
- if (n == 4)
- {
- a= pop_reg();
- b= alloc_reg();
- "not $a, $b";
- free_reg(a);
- push_reg(b);
- }
- else if (n == 8)
- {
- a= pop_reg();
- b= pop_reg();
- c= alloc_reg();
- d= alloc_reg();
- "not $a, $c";
- "not $b, $d";
- push_reg(d);
- push_reg(c);
- free_reg(b);
- free_reg(a);
- }
- else if (n>0 && !(n % 4))
- {
- flush_cache();
- a= alloc_reg();
- b= alloc_reg();
- for (i= 0; i< n; i += 4)
- {
- sprint(i_str, "%d", i);
- "ld [$reg_sp+$i_str], $a";
- "not $a, $b";
- "st $b, [$reg_sp+$i_str]";
- }
- free_reg(b);
- free_reg(a);
- }
- else
- arg_error ("com", n);
- }
- else
- {
- a= alloc_reg();
- pop_reg_as(a);
- b= alloc_reg();
- c= alloc_reg();
- flush_cache();
- "1:";
- "deccc 4, $a";
- "ld [$reg_sp+$a], $b";
- "not $a, $c";
- "bnz 1b";
- "st $c, [$reg_sp+$a]";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- }
- }.
- C_rol
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int n;
- const_str_t n_str;
- Comment( rol, $1);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n<0)
- arg_error("rol 4:", n);
- else
- {
- n= n % 32;
- if (n)
- {
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- sprint(n_str, "%d", n);
- "sll $a, $n_str, $b";
- sprint(n_str, "%d", 32-n);
- "srl $a, $n_str, $c";
- "or $b, $c, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- }
- }
- else
- {
- a= pop_reg();
- b= pop_reg();
- c= alloc_reg();
- d= alloc_reg();
- "and $a, 31, $c";
- "mov 32, $d";
- "sub $d, $c, $d";
- "sll $b, $c, $c";
- "srl $b, $d, $d";
- "or $c, $d, $d";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- push_ref(d);
- }
- }.
- default ==>
- arg_error( "rol", $1).
- narg4(rol)
- C_ror
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int n;
- const_str_t n_str;
- Comment( ror, $1);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n<0)
- arg_error("ror 4:", n);
- else
- {
- n= n % 32;
- if (n)
- {
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- sprint(n_str, "%d", n);
- "srl $a, $n_str, $b";
- sprint(n_str, "%d", 32-n);
- "sll $a, $n_str, $c";
- "or $b, $c, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- }
- }
- else
- {
- a= pop_reg();
- b= pop_reg();
- c= alloc_reg();
- d= alloc_reg();
- "and $a, 31, $c";
- "mov 32, $d";
- "sub $d, $c, $d";
- "srl $b, $c, $c";
- "sll $b, $d, $d";
- "or $c, $d, $d";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- push_reg(d);
- }
- }.
- default ==>
- arg_error( "ror", $1).
- narg4(ror)
- /******************************************************************************/
- /* */
- /* Group 10 : Sets */
- /* */
- /******************************************************************************/
- C_inn ==>
- Comment( inn, $1);
- push_const($1);
- C_inn_narg().
- C_inn_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int i;
- int n;
- const_str_t i_str;
- const_str_t n_str;
- Comment0(inn_narg);
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- n= pop_const(n_str);
- if (n == EM_WSIZE)
- {
- if (type_of_tos() == T_cst)
- {
- i= pop_const (i_str);
- if (i >= n*8)
- push_const(0);
- else
- {
- a= pop_reg();
- b= alloc_reg();
- "srl $a, $i_str, $b";
- "and $b, 1, $b";
- free_reg(a);
- push_reg(b);
- }
- }
- else
- {
- a= pop_reg();
- b= pop_reg();
- c= alloc_reg();
- "srl $b, $a, $c";
- "and $c, 1, $c";
- push_reg(c);
- free_reg(b);
- free_reg(a);
- }
- }
- else if (n == 2*EM_WSIZE)
- {
- if (type_of_tos() == T_cst)
- {
- i= pop_const (i_str);
- if (i >= n*8)
- push_const(0);
- else
- {
- if (i>= EM_WSIZE*8)
- {
- i -= EM_WSIZE*8;
- pop_nop(1);
- a= pop_reg();
- }
- else
- {
- a= pop_reg();
- pop_nop(1);
- }
- b= alloc_reg();
- c= alloc_reg();
- "srl $a, $i_str, $b";
- "and $b, 1, $c";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- }
- else
- {
- a= pop_reg();
- flush_cache();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- flush_cache();
- "andn $a, 31, $b";
- "and $a, 31, $c";
- "srl $b, 3, $d";
- "ld [$reg_sp+$d], $b";
- "inc $n_str, $reg_sp";
- "srl $b, $c, $d";
- "and $d, 1, $b";
- free_reg(a);
- push_reg(b);
- free_reg(c);
- free_reg(d);
- }
- }
- else if (n % EM_WSIZE)
- arg_error ("inn", n);
- else
- {
- a= pop_reg();
- flush_cache();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- flush_cache();
- "andn $a, 31, $b";
- "and $a, 31, $c";
- "srl $b, 3, $d";
- "ld [$reg_sp+$d], $b";
- "inc $n_str, $reg_sp";
- "srl $b, $c, $d";
- "and $d, 1, $b";
- free_reg(a);
- push_reg(b);
- free_reg(c);
- free_reg(d);
- }
- }
- else
- not_implemented ("inn_narg");
- }.
- C_set ==> Comment( set, $1);
- push_const($1);
- C_set_narg().
- C_set_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int n;
- const_str_t n_str;
- Comment0( set_narg );
- if (type_of_tos() == T_cst) {
- n = pop_const(n_str);
- if (n == EM_WSIZE) {
- b = alloc_reg();
- c = alloc_reg();
- a = pop_reg();
- "set 1, $c";
- "sll $c, $a, $b";
- free_reg(a);
- free_reg(c);
- push_reg(b);
- } else {
- a= alloc_reg();
- b= pop_reg();
- c= alloc_reg();
- d= alloc_reg();
- flush_cache();
- sprint(n_str, "%d", n);
- "set $n_str, $a";
- "sub $reg_sp, $a, $reg_sp";
- "1:";
- "deccc 4, $a";
- "bnz 1b";
- "st %g0, [$reg_sp+$a]"; /* HACK delay */
- "andn $b, 31, $c";
- "and $b, 31, $d";
- "srl $c, 3, $c";
- "set 1, $a";
- "sll $a, $d, $d";
- "st $d, [$reg_sp+$c]";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- }
- } else {
- a= alloc_reg();
- pop_reg_as(a);
- b= pop_reg();
- flush_cache();
- c= alloc_reg();
- d= alloc_reg();
- "sub $reg_sp, $a, $reg_sp";
- "1:";
- "deccc 4, $a";
- "bnz 1b";
- "st %g0, [$reg_sp+$a]"; /* HACK delay */
- "andn $b, 31, $c";
- "and $b, 31, $d";
- "srl $c, 3, $c";
- "set 1, $a";
- "sll $a, $d, $d";
- "st $d, [$reg_sp+$c]";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- }
- }.
- /******************************************************************************/
- /* */
- /* Group 11 : Array */
- /* */
- /******************************************************************************/
- C_lar
- ($1 == 4) ==>
- Comment(lar, $1);
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- pop_reg_as(reg_o2);
- flush_cache();
- "call lar";
- "nop";
- free_output().
- default ==>
- arg_error ("arg error lar", $1).
- narg4(lar)
- C_sar
- ($1 == 4) ==>
- Comment( sar , $1 );
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- pop_reg_as(reg_o2);
- flush_cache();
- "call sar";
- "nop"
- free_output().
- default ==>
- arg_error ("arg error sar", $1).
- narg4(sar)
- C_aar
- ($1 == 4) ==>
- Comment(aar, $1);
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- pop_reg_as(reg_o2);
- flush_cache();
- "call aar";
- "nop";
- soft_alloc_reg(reg_o0);
- free_output();
- push_reg(reg_o0).
- default ==>
- arg_error ("arg error aar", $1).
- narg4(aar)
- /******************************************************************************/
- /* */
- /* Group 12 : Compare */
- /* */
- /******************************************************************************/
- C_cmi
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- const_str_t d;
- Comment( cmi, $1 );
- if (type_of_tos() == T_cst && const13(top_const()))
- {
- pop_const(d);
- a= pop_reg();
- b= alloc_reg();
- "cmp $a, $d";
- "be,a 1f";
- "mov 0, $b"; /* delay slot */
- "bg,a 1f";
- "mov 1, $b"; /* delay slot */
- "mov -1, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }
- else
- {
- a= pop_reg();
- b= NULL;
- c= alloc_reg();
- if (type_of_tos() == T_cst)
- {
- pop_const(d);
- "cmp $a, $d";
- }
- else
- {
- b= pop_reg();
- "cmp $a, $b";
- }
- "be,a 1f";
- "mov 0, $c"; /* delay slot */
- "bg,a 1f";
- "mov -1, $c"; /* delay slot */
- "mov 1, $c";
- "1:";
- free_reg(a);
- if (b)
- free_reg(b);
- push_reg(c);
- }
- }.
- default ==>
- arg_error ("unimp cmi", $1).
- narg4(cmi)
- C_cmu ==>
- Comment( cmu, $1 );
- push_const($1);
- C_cmu_narg().
- C_cmu_narg ==>
- {
- int n;
- reg_t a;
- reg_t b;
- reg_t c;
- const_str_t d;
- Comment0( cmu_narg );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n != EM_WSIZE)
- arg_error ("unimp cmu", n);
- else
- {
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- {
- pop_const(d);
- a= pop_reg();
- b= alloc_reg();
- "cmp $a, $d";
- "be,a 1f";
- "mov 0, $b"; /* delay slot */
- "bgu,a 1f";
- "mov 1, $b"; /* delay slot */
- "mov -1, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }
- else
- {
- a= pop_reg();
- b= NULL;
- c= alloc_reg();
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- {
- pop_const(d);
- "cmp $a, $d";
- }
- else
- {
- b= pop_reg();
- "cmp $a, $b";
- }
- "be,a 1f";
- "mov 0, $c"; /* delay slot */
- "bgu,a 1f";
- "mov -1, $c"; /* delay slot */
- "mov 1, $c";
- "1:";
- free_reg(a);
- if (b)
- free_reg(b);
- push_reg(c);
- }
- }
- }
- else
- not_implemented ("cmu_narg");
- }.
- C_cms ==>
- Comment( cms, $1 );
- push_const($1);
- C_cms_narg().
- C_cms_narg ==>
- {
- int n;
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- const_str_t b_str;
- const_str_t n_str;
- Comment0( cms_narg );
- if (type_of_tos() == T_cst && top_const() <= EM_WSIZE)
- {
- n= pop_const(n_str);
- if (n == EM_WSIZE)
- {
- b= NULL;
- c= alloc_reg();
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- {
- pop_const(b_str);
- a= pop_reg();
- "cmp $a, $b_str";
- }
- else
- {
- a= pop_reg();
- b= pop_reg();
- "cmp $a, $b";
- }
- "be,a 1f";
- "mov 0, $c";
- "mov 1, $c";
- "1:";
- free_reg(a);
- if (b)
- free_reg(b);
- push_reg(c);
- }
- else if (n % EM_WSIZE)
- arg_error ("unimp cms", n);
- }
- else
- {
- a= pop_reg();
- flush_cache();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- "add $reg_sp, $a, $b";
- "dec 4, $b";
- "1:";
- "ld [$b], $c";
- "ld [$b+$a], $d";
- "cmp $d, $c";
- "bne,a 2f";
- "mov 1, $b"; /* delay slot */
- "cmp $b, $reg_sp";
- "bg 1b";
- "dec 4, $b"; /* delay slot */
- "mov 0, $b";
- "2:";
- "add $reg_sp, $a, $reg_sp";
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- push_reg(b);
- free_reg(c);
- free_reg(d);
- }
- }.
- C_cmp ==>
- Comment0( cmp );
- C_cmu( (arith)4).
- C_tlt ==>
- Comment0( tlt );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b= alloc_reg();
- " tst $a";
- " bl,a 1f";
- " mov 1, $b"; /* delay slot */
- " set 0, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_tle ==>
- Comment0( tle );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b= alloc_reg();
- "tst $a";
- "ble,a 1f";
- "mov 1, $b"; /* delay slot */
- "set 0, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_tge ==>
- Comment0( tge );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b = alloc_reg();
- " tst $a";
- " bge,a 1f";
- " mov 1, $b"; /* delay slot */
- " set 0, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_tgt ==>
- Comment0( tgt );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b = alloc_reg();
- " tst $a";
- " bg,a 1f";
- " mov 1, $b"; /* delay slot */
- " set 0, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_tne ==>
- Comment0( tne );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b = alloc_reg();
- " tst $a";
- " bne,a 1f";
- " mov 1, $b"; /* delay slot */
- " set 0, $b"; /* sup optimal */
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_teq ==>
- Comment0( teq );
- {
- reg_t a;
- reg_t b;
- a = pop_reg();
- b = alloc_reg();
- " tst $a";
- " be,a 1f";
- " mov 1, $b"; /* delay slot */
- " set 0, $b";
- "1:";
- free_reg(a);
- push_reg(b);
- }.
- C_cmf ==>
- Comment( cmf, $1);
- push_const($1);
- C_cmf_narg().
- C_cmf_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- int n;
- Comment0( cmf_narg);
- if (type_of_tos() == T_cst)
- {
- n= pop_const(NULL);
- if (n == EM_FSIZE)
- {
- a= pop_float();
- b= pop_float();
- c= alloc_reg();
- "fcmpes $b, $a";
- "nop";
- "fbe,a 1f";
- "mov 0, $c";
- "fbl,a 1f";
- "mov -1, $c";
- "mov 1, $c";
- "1:";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }
- else if (n == EM_DSIZE)
- {
- a= pop_double(NULL);
- b= pop_double(NULL);
- c= alloc_reg();
- "fcmped $b, $a";
- "nop";
- "fbe,a 1f";
- "mov 0, $c";
- "fbl,a 1f";
- "mov -1, $c";
- "mov 1, $c";
- "1:";
- free_double_reg(a);
- free_double_reg(b);
- push_reg(c);
- }
- else
- arg_error ("cmf", n);
- }
- else
- not_implemented ("cmf_narg");
- }.
- /******************************************************************************/
- /* */
- /* Group 13 : Branch */
- /* */
- /******************************************************************************/
- C_bra ==>
- Comment( bra , $1 );
- {
- char *lbl;
- flush_cache();
- lbl = $1;
- "b $lbl";
- "nop"; /* delay slot */
- }.
- C_bge ==>
- Comment( bge , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "bge $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_bne ==>
- Comment( bne , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "bne $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_beq ==>
- Comment( beq , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "beq $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_ble ==>
- Comment( ble , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "ble $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_blt ==>
- Comment( blt , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "bl $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_bgt ==>
- Comment( bgt , $1 );
- {
- char *lbl = $1;
- reg_t a;
- reg_t b;
- const_str_t n_str;
- a= NULL;
- if (type_of_tos() == T_cst &&
- const13(top_const()))
- pop_const(n_str);
- else
- a = pop_reg();
- b = pop_reg();
- flush_cache();
- if (a)
- "cmp $b, $a";
- else
- "cmp $b, $n_str";
- "bg $lbl";
- "nop" /* delay slot */
- free_reg(a);
- free_reg(b);
- }.
- C_zlt ==>
- Comment( zlt , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "bl $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- C_zle ==>
- Comment( zle , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "ble $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- C_zeq ==>
- Comment( zeq , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "be $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- C_zne ==>
- Comment( zne , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "bne $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- C_zge ==>
- Comment( zge , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "bge $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- C_zgt ==>
- Comment( zgt , $1 );
- {
- char *lbl = $1;
- reg_t a;
- a = pop_reg();
- flush_cache();
- "tst $a";
- "bg $lbl";
- "nop"; /* delay slot */
- free_reg(a);
- }
- .
- /******************************************************************************/
- /* */
- /* Group 14 : Procedure call instructions */
- /* */
- /******************************************************************************/
- C_cai ==>
- Comment0( cai );
- {
- reg_t a;
- a= pop_reg();
- flush_cache();
- "call $a";
- "nop"; /* delay slot */
- free_reg(a);
- }.
- C_cal ==>
- Comment( cal , $1 );
- {
- char *lbl = $1;
- flush_cache();
- "call $lbl";
- "nop"; /* delay slot */
- }.
- C_lfr
- $1 == 4 ==>
- {
- Comment( lfr , $1 );
- forced_alloc_reg(RETL_LD);
- push_reg(RETL_LD);
- }.
- $1 == 8 ==>
- {
- Comment( lfr , $1 );
- forced_alloc_reg(RETL_LD);
- forced_alloc_reg(RETH_LD);
- push_reg(RETH_LD);
- push_reg(RETL_LD);
- }.
- default ==>
- arg_error( "lfr", $1).
- C_ret
- $1 == 0 ==>
- {
- Comment( ret , $1 );
- load_float_regs();
- if (debug)
- free_all_reg_vars();
- "restore";
- "retl";
- "add %sp, $reg_gap, %sp";
- if (debug)
- alloc_all_reg_vars();
- }.
- $1 == 4 ==>
- {
- Comment( ret , $1 );
- soft_alloc_reg(RETL_ST);
- pop_reg_as(RETL_ST);
- free_reg(RETL_ST);
- load_float_regs();
- if (debug)
- free_all_reg_vars();
- "restore";
- "retl";
- "add %sp, $reg_gap, %sp";
- if (debug)
- alloc_all_reg_vars();
- }.
- $1 == 8 ==>
- {
- Comment( ret , $1 );
- soft_alloc_reg(RETL_ST);
- soft_alloc_reg(RETH_ST);
- pop_reg_as(RETL_ST);
- pop_reg_as(RETH_ST);
- free_reg(RETL_ST);
- free_reg(RETH_ST);
- load_float_regs();
- if (debug)
- free_all_reg_vars();
- "restore";
- "retl";
- "add %sp, $reg_gap, %sp";
- if (debug)
- alloc_all_reg_vars();
- }.
- default ==>
- arg_error( "ret", $1).
- /******************************************************************************/
- /* */
- /* Group 15 : Miscellaneous instructions */
- /* */
- /******************************************************************************/
- C_asp ==>
- Comment( asp , $1 );
- push_const($1);
- C_ass(EM_WSIZE).
- C_ass
- $1 == 4 ==>
- {
- int n;
- const_str_t n_str;
- reg_t a;
- if (type_of_tos() == T_cst)
- {
- n= pop_const(n_str);
- if (n % EM_WSIZE)
- arg_error ("asp", n);
- else
- if (n>=0)
- pop_nop (n/4);
- else
- {
- flush_cache();
- if (const13(n))
- "inc $n_str, $reg_sp";
- else
- {
- a= alloc_reg();
- "set $n_str, $a"
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- }
- }
- }
- else
- {
- a= pop_reg();
- flush_cache();
- "add $reg_sp, $a, $reg_sp";
- free_reg(a);
- }
- }.
- default ==>
- arg_error( "ass", $1).
- narg4(ass)
- C_blm ==>
- Comment( blm, $1);
- push_const($1);
- C_bls (EM_WSIZE).
- C_bls
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- reg_t e;
- reg_t ao_reg;
- reg_t bo_reg;
- int n;
- int i;
- const_str_t n_str;
- const_str_t ac_str;
- const_str_t bc_str;
-
- Comment( bls , $1 );
- if (type_of_tos() == T_cst)
- {
- n= pop_const(n_str);
- if (n % EM_WSIZE)
- arg_error ("blm", n);
- else if (n <= MAX_UNROLL)
- {
- c= alloc_reg();
- for (i=0; i<n; i += EM_WSIZE)
- {
- if (type_of_tos() & T_reg2) /* dest */
- a= pop_reg_reg (&ao_reg);
- else
- {
- ao_reg= NULL;
- a= pop_reg_c13(ac_str);
- }
- if (type_of_tos() & T_reg2) /* src */
- b= pop_reg_reg (&bo_reg);
- else
- {
- bo_reg= NULL;
- b= pop_reg_c13(bc_str);
- }
- if (bo_reg)
- "ld [$b+$bo_reg], $c";
- else
- "ld [$b+$bc_str], $c";
- if (ao_reg)
- "st $c, [$a+$ao_reg]";
- else
- "st $c, [$a+$ac_str]";
- if (bo_reg)
- {
- push_reg(b);
- inc_tos_reg(bo_reg);
- }
- else if (bc_str[0] == '-' ||
- isdigit(bc_str[0]))
- {
- push_reg(b);
- inc_tos(atoi(bc_str));
- }
- else
- {
- "add $b, $bc_str, $c";
- push_reg(c);
- free_reg(b);
- c= alloc_reg();
- }
- inc_tos(4);
- if (ao_reg)
- {
- push_reg(a);
- inc_tos_reg(ao_reg);
- }
- else if (ac_str[0] == '-' ||
- isdigit(ac_str[0]))
- {
- push_reg(a);
- inc_tos(atoi(ac_str));
- }
- else
- {
- "add $a, $ac_str, $c";
- push_reg(c);
- free_reg(a);
- c= alloc_reg();
- }
- inc_tos(4);
- }
- pop_nop(2);
- free_reg(c);
- }
- else
- {
- a= pop_reg(); /* dest */
- b= pop_reg(); /* src */
- c= alloc_reg();
- d= alloc_reg();
- e = alloc_reg();
- "set $n_str-4, $c";
- "set -4, $e";
- "1:";
- "inc 4, $e";
- "ld [$b+$e], $d";
- "cmp $e,$c";
- "bnz 1b";
- "st $d, [$a+$e]";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- }
- }
- else
- {
- c= alloc_reg(); /* size */
- pop_reg_as(c);
- a= pop_reg(); /* dest */
- b= pop_reg(); /* src */
- d= alloc_reg();
- e= alloc_reg();
- "ba 2f";
- "clr $e";
- "1:";
- "st $d, [$a+$e]";
- "inc 4, $e";
- "2:";
- "cmp $e, $c"
- "bnz 1b";
- "ld [$b+$e], $d";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- free_reg(e);
- }
- }.
- default ==>
- arg_error( "bls", $1).
- narg4(bls)
- C_csa
- $1 == 4 ==>
- Comment( csa , $1 );
- {
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- flush_cache();
- free_output();
- "set csa, $reg_tmp";
- "jmp $reg_tmp";
- "nop";
- }.
- default ==>
- arg_error( "csa", $1).
- narg4(csa)
- C_csb
- $1 == 4 ==>
- Comment( csb , $1 );
- {
- force_alloc_output();
- pop_reg_as(reg_o0);
- pop_reg_as(reg_o1);
- flush_cache();
- free_output();
- "set csb, $reg_tmp";
- "jmp $reg_tmp";
- "nop";
- }.
- default ==>
- arg_error( "csb", $1).
- narg4(csb)
- C_dch ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- Comment0( dch );
- a= pop_reg(); /* some LB */
- b= alloc_reg();
- c= alloc_reg();
- "ta 3"; /* flush register windows */
- "add $a, 7, $b";
- "andn $b, 7, $c"; /* and it's %fp */
- "ld [$c+4], $b"; /* the previous LB */
- free_reg(a);
- push_reg(b);
- free_reg(c);
- }.
- C_dup ==>
- Comment( dup, $1);
- push_const($1);
- C_dus(EM_WSIZE).
- C_dus
- $1 == 4 ==>
- {
- int n;
- int i;
- const_str_t n_str;
- const_str_t i_str;
- reg_t a;
- reg_t b;
- reg_t c;
- Comment( dus, $1);
- if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
- {
- n= pop_const(n_str);
- if (n == 4 || n == 8 || n<=32)
- dup_tos(n/4);
- else if (n<0 || n % 4)
- arg_error ("dup", n);
- else
- {
- flush_cache();
- a= alloc_reg();
- "sub $reg_sp, $n_str, $reg_sp";
- for (i=0; i<n; i += 4)
- {
- sprint(i_str, "%d", i);
- "ld [$reg_sp+$i_str+$n_str], $a";
- "st $a, [$reg_sp+$i_str]";
- }
- free_reg(a);
- }
- }
- else
- {
- a= pop_reg();
- flush_cache();
- b= alloc_reg();
- c= alloc_reg();
- "mov $a, $b";
- "1:";
- "dec STACK_CLICK, $reg_sp";
- "ld [$reg_sp+ $a], $c";
- "deccc 4, $b";
- "bne 1b";
- "st $c, [$reg_sp+ $a]"; /* delay slot */
- free_reg(a);
- free_reg(b);
- free_reg(c);
- }
- }.
- default ==>
- arg_error( "dus", $1).
- narg4(dus)
- C_exg ==>
- Comment( exg, $1 );
- push_const($1);
- C_exg_narg().
- C_exg_narg ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- int n;
- int i;
- const_str_t i_str;
- const_str_t in_str;
- Comment0( exg_narg );
- if (type_of_tos() == T_cst && top_const() <= MAX_UNROLL)
- {
- n= pop_const(NULL);
- if (n==4)
- {
- a= pop_reg();
- b= pop_reg();
- push_reg(a);
- push_reg(b);
- }
- else if (n==8)
- {
- a= pop_reg();
- b= pop_reg();
- c= pop_reg();
- d= pop_reg();
- push_reg(b);
- push_reg(a);
- push_reg(d);
- push_reg(c);
- }
- else if (n>0 && !(n % 4))
- {
- a= alloc_reg();
- b= alloc_reg();
- flush_cache();
- for (i=0; i<n; i += 4)
- {
- sprint(i_str, "%d", i);
- sprint(in_str, "%d", i+n);
- "ld [$reg_sp+$i_str], $a";
- "ld [$reg_sp+$in_str], $b";
- "st $b, [$reg_sp+$i_str]";
- "st $a, [$reg_sp+$in_str]";
- }
- free_reg(a);
- free_reg(b);
- }
- else
- arg_error ("exg", n);
- }
- else
- {
- a= pop_reg();
- flush_cache();
- b= alloc_reg();
- c= alloc_reg();
- d= alloc_reg();
- "add $reg_sp, $a, $b";
- "1:";
- "dec 4, $b";
- "cmp $reg_sp, $b";
- "ld [$b], $c";
- "ld [$b+$a], $d";
- "st $d, [$b]";
- "bne 1b";
- "st $c, [$b+$a]"; /* delay slot */
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- }
- }.
- C_fil.. ==>
- Comment2( fil , $1 , $2);
- #ifdef FAST_LIN_LNI_FIL
- {
- char *lbl = $1;
- int n = $2;
- "set $lbl+$n, $reg_fil"
- }.
- #else
- push_ext($1);
- inc_tos($2);
- push_ext("filn");
- push_const(4);
- C_sts(EM_WSIZE).
- #endif
- C_gto.. ==>
- {
- char *ext;
- reg_t a;
- reg_t b;
- reg_t c;
- reg_t d;
- Comment2( gto , $1 , $2 );
- flush_cache();
- a= reg_g1;
- b= reg_g2;
- c= reg_g3;
- d= reg_g5;
- forced_alloc_reg(a);
- forced_alloc_reg(b);
- forced_alloc_reg(c);
- forced_alloc_reg(d);
- ext= $1;
- push_ext(ext);
- inc_tos($2);
- pop_reg_as(a);
- "ld [$a+8], $b";
- "mov $reg_o0, $c";
- "mov $reg_o1, $d";
- "1:";
- "cmp $b, $reg_lb";
- "bne,a 1b";
- "restore";
- "ld [$a+4], $reg_sp";
- "ld [$a], $b";
- "mov $c, $reg_o0";
- "jmp $b";
- "mov $d, $reg_o1"; /* delay slot */
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_reg(d);
- }.
- C_lim ==>
- Comment0( lim );
- push_ext("trpim");
- C_loi(4).
- C_lin ==>
- Comment( lin , $1 );
- #ifdef FAST_LIN_LNI_FIL
- {
- const_str_t n_str;
- sprint(n_str, "%d", $1);
- "set $n_str, $reg_fil";
- }.
- #else
- push_const($1);
- push_ext("lino");
- push_const(4);
- C_sts(EM_WSIZE).
- #endif
- C_lni ==>
- #ifdef FAST_LIN_LNI_FIL
- Comment0( lni );
- "inc $reg_fil".
- #else
- {
- reg_t a;
- reg_t b;
- Comment0( lni );
- a = alloc_reg();
- b = alloc_reg();
- "sethi %hi(lino), $a";
- "ld [$a+%lo(lino)], $b";
- "inc $b";
- "st $b, [$a+%lo(lino)]"
- free_reg(a);
- free_reg(b);
- }.
- #endif
- C_lor
- $1 == 0 ==>
- Comment( lor , $1 );
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb).
- $1 == 1 ==>
- {
- reg_t a;
- Comment( lor , $1 );
- a= alloc_reg();
- flush_cache();
- "mov $reg_sp, $a";
- push_reg(a);
- }.
- $1 == 2 ==>
- Comment( lor , $1 );
- {
- reg_t a;
- reg_t b;
- a= alloc_reg();
- b= alloc_reg();
- "set reghp, $a";
- "ld [$a], $b";
- push_reg(b);
- free_reg(a);
- }.
- default ==>
- arg_error( "lor", $1).
- C_lpb ==>
- Comment0( lpb );
- C_adp( (arith)EM_BSIZE).
- C_mon ==>
- Comment0( mon );
- force_alloc_output();
- pop_reg_as(reg_o0);
- "call mon";
- "nop";
- free_output().
- C_nop ==>
- Comment0( nop );
- flush_cache();
- .
- C_rck
- $1 == 4 ==>
- {
- reg_t a;
- reg_t b;
- reg_t c;
- Comment( rck , $1 );
- force_alloc_output();
- a= pop_reg();
- b= pop_reg();
- soft_alloc_reg(b);
- push_reg(b);
- c= alloc_reg();
- "ld [$a], $c";
- "cmp $b, $c";
- "bl 1f";
- "ld [$a+4], $c";
- "cmp $b, $c";
- "ble 2f";
- "nop";
- "1:";
- "set ERANGE, $reg_o0";
- "call trp";
- "nop";
- "2:";
- free_reg(a);
- free_reg(b);
- free_reg(c);
- free_output();
- }.
- default ==>
- arg_error( "rck", $1).
- narg4(rck)
- C_rtt ==>
- Comment0( rtt );
- C_ret( (arith)0).
- C_sig ==>
- Comment0( sig );
- {
- reg_t a;
- reg_t b;
- reg_t c;
- a= pop_reg();
- b= alloc_reg();
- c= alloc_reg();
- "set trppc, $b";
- "ld [$b], $c";
- "st $a, [$b]";
- free_reg(a);
- free_reg(b);
- push_reg(c);
- }.
- C_sim ==>
- Comment0( sim );
- {
- reg_t a;
- reg_t b;
- a= pop_reg();
- b= alloc_reg();
- "set trpim, $b";
- "st $a, [$b]";
- free_reg(a);
- free_reg(b);
- }.
- C_str
- $1 == 0 ==>
- Comment( str , $1 );
- flush_cache();
- "ld [$reg_sp], $reg_lb";
- "add $reg_lb, 4, %fp";
- "and %fp, -8, %fp";
- "inc STACK_CLICK, $reg_sp"
- .
- $1 == 1 ==>
- {
- Comment( str , $1 );
- flush_cache();
- "ld [$reg_sp], $reg_sp";
- }.
- $1 == 2 ==>
- {
- Comment( str , $1 );
- force_alloc_output();
- pop_reg_as(reg_o0);
- "call strhp";
- "nop";
- free_output();
- }.
- default ==>
- arg_error( "str", $1).
- C_trp ==>
- Comment0( trp );
- force_alloc_output();
- pop_reg_as(reg_o0);
- flush_cache();
- "call trp";
- "nop";
- free_output().
- /*****************************************************************************/
- ..icon
- $2 == 1 ==>
- Comment( ..icon , $1 );
- gen1( (ONE_BYTE) atoi( $1)).
- $2 == 2 ==>
- Comment( ..icon , $1 );
- gen2( (TWO_BYTES) atoi( $1)).
- $2 == 4 ==>
- Comment( ..icon , $1 );
- gen4( (FOUR_BYTES) atol( $1)).
- default ==>
- arg_error( "icon", $2).
- ..ucon
- $2 == 1 ==>
- Comment( ..ucon , $1 );
- gen1( (ONE_BYTE) atoi( $1)).
- $2 == 2 ==>
- Comment( ..ucon , $1 );
- gen2( (TWO_BYTES) atoi( $1)).
- $2 == 4 ==>
- Comment( ..ucon , $1 );
- gen4( (FOUR_BYTES) atol( $1)).
- default ==>
- arg_error( "icon", $2).
- ..fcon ==>
- Comment( ..fcon , $1 );
- con_float($1, $2).
- /*****************************************************************************/
- C_prolog ==>
- Comment0( prolog );
- init_cache();
- "sub $reg_sp, (EM_BSIZE-4), %g1";
- "and %g1, -8, %sp";
- "mov $reg_sp, %g1";
- "save %sp, $reg_gap, %sp";
- "st %g0, [%sp+BP_OFFSET]";
- "sub %g1, EM_BSIZE, $reg_lb";
- init_reg_man();
- forced_alloc_reg(reg_sp);
- forced_alloc_reg(reg_lb);
- forced_alloc_reg(reg_gap);
- #ifdef FAST_LIN_LNI_FIL
- reg_lin = alloc_reg();
- reg_fil = alloc_reg();
- #endif
- .
- C_jump ==>
- {
- char *l;
- Comment( jump , $1 );
- l= $1;
- "b $l";
- "nop"; /* delay slot */
- }.
- C_locals ==>
- {
- Comment( locals , $1 );
- soft_alloc_reg(reg_lb);
- push_reg(reg_lb);
- inc_tos(-($1));
- pop_reg_as(reg_sp);
- }.
|