123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250 |
- rscid = "$Header$"
- #define UNTESTED
- EM_WSIZE=2
- EM_PSIZE=2
- EM_BSIZE=4
- SL=4
- FORMAT = "0%lo"
- TIMEFACTOR = 1/300
- illins = "Illegal"
- PROPERTIES
- GENREG /* All PDP registers */
- REG /* Normal registers (allocatable) */
- ODDREG /* All odd registers (allocatable) */
- REGPAIR(4) /* Register pairs for division */
- FLTREG(4) /* Floating point registers, single precision */
- DBLREG(8) /* Same, double precision */
- GENFREG(4) /* generic floating point */
- GENDREG(8) /* generic floating point */
- FLTREGPAIR(8) /* register pair for modf */
- DBLREGPAIR(16) /* same, double precision */
- LOCALBASE /* Guess what */
- STACKPOINTER
- PROGRAMCOUNTER
- REGISTERS
- r0 : GENREG,REG.
- r2 : GENREG,REG regvar.
- r4 : GENREG,REG regvar.
- r1,r3 : GENREG,REG,ODDREG.
- r01("r0")=r0+r1 : REGPAIR.
- fr0("r0"),fr1("r1"),fr2("r2"),fr3("r3") : GENFREG,FLTREG.
- dr0("r0")=fr0,dr1("r1")=fr1,dr2("r2")=fr2,dr3("r3")=fr3 : GENDREG,DBLREG.
- fr01("r0")=fr0+fr1,fr23("r2")=fr2+fr3 : FLTREGPAIR.
- dr01("r0")=dr0+dr1,dr23("r2")=dr2+dr3 : DBLREGPAIR.
- lb("r5") : GENREG,LOCALBASE.
- sp : GENREG,STACKPOINTER.
- pc : GENREG,PROGRAMCOUNTER.
- TOKENS
- const2 = { INT num; } 2 "$" num .
- LOCAL = { INT ind; INT size; } 2 ind "(r5)" .
- ILOCAL = { INT ind; } 2 "*" ind "(r5)" .
- DLOCAL = { INT ind; INT size; } 4 ind "(r5)" .
- addr_local = { INT ind; } 2 .
- addr_external = { ADDR off; } 2 "$" off.
- regdef2 = { GENREG reg; } 2 "*" reg.
- regind2 = { GENREG reg; ADDR off; } 2 off "(" reg ")" .
- reginddef2 = { GENREG reg; ADDR off; } 2 "*" off "(" reg ")" .
- regconst2 = { GENREG reg; ADDR off; } 2 .
- relative2 = { ADDR off; } 2 off .
- reldef2 = { ADDR off; } 2 "*" off.
- regdef1 = { GENREG reg; } 2 "*" reg.
- regind1 = { GENREG reg; ADDR off; } 2 off "(" reg ")" .
- reginddef1 = { GENREG reg; ADDR off; } 2 "*" off "(" reg ")" .
- relative1 = { ADDR off; } 2 off.
- reldef1 = { ADDR off; } 2 "*" off.
- autodec = { GENREG reg; } 2 "-(" reg ")".
- autoinc = { GENREG reg; } 2 "(" reg ")+".
- ftoint = { GENFREG reg; } 2 .
- ftolong = { GENFREG reg; } 4 .
- regind4 = { GENREG reg; ADDR off; } 4 off "(" reg ")".
- reginddef4 = { GENREG reg; ADDR off; } 4 "*" off "(" reg ")".
- relative4 = { ADDR off; } 4 off.
- reldef4 = { ADDR off; } 4 "*" off.
- regdef4 = { GENREG reg; } 4 "*" reg.
- regind8 = { GENREG reg; ADDR off; } 8 off "(" reg ")".
- reginddef8 = { GENREG reg; ADDR off; } 8 "*" off "(" reg ")".
- relative8 = { ADDR off; } 8 off.
- reldef8 = { ADDR off; } 8 "*" off.
- regdef8 = { GENREG reg; } 8 "*" reg.
- label = { ADDR off; } 2 off.
- SETS
- src2 = GENREG + regdef2 + regind2 + reginddef2 + relative2 +
- reldef2 + addr_external + const2 + LOCAL + ILOCAL +
- autodec + autoinc .
- dst2 = src2 - ( const2 + addr_external ) .
- xsrc2 = src2 + ftoint .
- src1 = regdef1 + regind1 + reginddef1 + relative1 + reldef1 .
- dst1 = src1 .
- src1or2 = src1 + src2 .
- src4 = relative4 + regdef4 + DLOCAL + regind4 .
- dst4 = src4 .
- long4 = src4 + REGPAIR .
- longf4 = src4 + reldef4 + reginddef4 + FLTREG .
- f4src = longf4 + autoinc + autodec .
- f4dst = f4src .
- long8 = relative8 + regdef8 + regind8 + DBLREG .
- double8 = long8 + reldef8 + reginddef8 .
- freg = FLTREG + DBLREG .
- fsrc = FLTREG + double8 + autoinc + autodec .
- fdst = fsrc .
- indexed2 = regind2 + reginddef2 .
- indexed4 = regind4 .
- indexed8 = regind8 .
- indexed = indexed2 + indexed4 + indexed8 .
- regdeferred = regdef2 + regdef4 + regdef8 .
- indordef = indexed + regdeferred .
- locals = LOCAL + DLOCAL .
- variable2 = relative2 + reldef2 .
- variable4 = relative4 .
- variable8 = relative8 .
- variable = variable2 + variable4 + variable8 .
- regs = REG + REGPAIR + FLTREG + DBLREG .
- noconst2 = src2 - const2 - addr_external .
- allexeptcon = ALL - ( regs + const2 + addr_local + addr_external ) .
- externals = relative1 + relative2 + relative4 + relative8 .
- posextern = variable + regdeferred + indexed + externals .
- diradr2 = regconst2 + addr_external .
- INSTRUCTIONS
- /* default cost */
- cost(2,450)
- /* Normal instructions */
- adc dst2:rw:cc .
- add src2:ro,dst2:rw:cc .
- ash src2:ro,REG:rw:cc .
- ashc src2:ro,REGPAIR+ODDREG:rw kills :cc .
- asl dst2:rw:cc .
- asr dst2:rw:cc .
- bxx "syntax error" label . /* generic branch used only as bxx* */
- bcc label .
- bcs label .
- beq label .
- bge label .
- bgt label .
- bhi label .
- bhis "bcc" label .
- bic src2:ro,dst2:rw:cc .
- bis src2:ro,dst2:rw:cc .
- bisb src1or2:ro,REG:rw kills :cc .
- bit src2:ro,src2:ro kills :cc.
- ble label .
- blo "bcs" label .
- blos label .
- blt label .
- bmi label .
- bne label .
- bpl label .
- br label .
- bvc label .
- bvs label .
- clr dst2:wo:cc .
- clrb dst1:wo kills :cc .
- cmp src2:ro,src2:ro kills :cc .
- cmpb src1or2:ro,src1or2:ro kills :cc .
- com dst2:rw:cc .
- dec dst2:rw:cc .
- div src2:ro,REG:rw kills :cc .
- inc dst2:rw:cc .
- jbr label .
- jeq label .
- jne label .
- jxx "syntax error" label .
- jmp dst2+label kills :cc r0 r1 r3.
- jsr GENREG:rw,dst2+label kills :cc r0 r1 r3.
- mov src2:ro,dst2:wo:cc .
- movb src1or2:ro,dst1+REG:wo kills :cc .
- mul src2:ro,ODDREG:rw:cc .
- neg dst2:rw:cc .
- rol dst2:rw:cc .
- ror dst2:rw:cc .
- rts GENREG:rw .
- sbc dst2:rw:cc .
- sob REG:rw,label .
- sub src2:ro,dst2:rw:cc .
- sxt dst2:wo .
- tst src2:ro:cc .
- xor REG:ro,dst2:rw:cc .
- /* floating point instructions */
- cfcc .
- setf .
- setd .
- seti .
- setl .
- clrf fdst.
- negf fdst .
- absf fdst .
- tstf fsrc .
- movf fsrc,freg .
- movf freg,fdst .
- movif src2,freg .
- movif src4,freg .
- movfi freg,dst2 .
- movfi freg,dst4 .
- movof f4src,freg .
- movfo freg,f4dst .
- movie src2,freg .
- movei freg,dst2 .
- addf fsrc,freg .
- subf fsrc,freg .
- mulf fsrc,freg .
- divf fsrc,freg .
- cmpf fsrc,freg .
- modf fsrc,FLTREGPAIR+DBLREGPAIR .
- ldfps src2 .
- stfps dst2 .
- stst dst2 .
- /* weirdo instructions */
- mfpt kills r0 .
- MOVES
- from const2 %num==0 to dst2
- gen clr %2
- from src2 to dst2
- gen mov %1,%2
- from FLTREG to longf4-FLTREG
- gen movfo %1,%2
- from longf4-FLTREG to FLTREG
- gen movof %1,%2
- from FLTREG to FLTREG
- gen movf %1,%2
- from DBLREG to double8
- gen movf %1,%2
- from double8 to DBLREG
- gen movf %1,%2
- from const2 %num==0 to src1
- gen clrb %2
- from src1or2 to src1
- gen movb %1,%2
- from ftoint to dst2
- gen movfi %1.reg,%2
- TESTS
- to test src2
- gen tst %1
- STACKINGRULES
- from const2 %num==0 to STACK
- gen clr {autodec,sp}
- from src2 to STACK
- gen mov %1,{autodec,sp}
- from regconst2 to STACK
- gen mov %1.reg,{autodec,sp}
- add {addr_external, %1.off},{regdef2,sp}
- from addr_local to STACK
- gen mov lb,{autodec,sp}
- add {const2, %1.ind},{regdef2,sp}
- from DBLREG to STACK
- gen movf %1,{autodec,sp}
- from FLTREG to STACK
- gen movfo %1,{autodec,sp}
- from REGPAIR to STACK
- gen mov %1.2,{autodec,sp}
- mov %1.1,{autodec,sp}
- from regind4 to STACK
- gen mov {regind2, %1.reg, 2+%1.off},{autodec,sp}
- mov {regind2, %1.reg, %1.off},{autodec,sp}
- from relative4 to STACK
- gen mov {relative2, 2+%1.off},{autodec,sp}
- mov {relative2, %1.off},{autodec,sp}
- from regdef4 to STACK
- gen mov {regind2, %1.reg, 2},{autodec,sp}
- mov {regdef2, %1.reg },{autodec,sp}
- from regind8 to STACK
- uses REG
- gen move %1.reg,%a
- add {addr_external, 8+%1.off},%a
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- from regind8 to STACK
- gen mov {regind2, %1.reg, 6+%1.off},{autodec,sp}
- mov {regind2, %1.reg, 4+%1.off},{autodec,sp}
- mov {regind2, %1.reg, 2+%1.off},{autodec,sp}
- mov {regind2, %1.reg, %1.off},{autodec,sp}
- from relative8 to STACK
- uses REG
- gen mov {addr_external, 8+%1.off},%a
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- mov {autodec, %a},{autodec,sp}
- from relative8 to STACK
- gen mov {relative2, 6+%1.off},{autodec,sp}
- mov {relative2, 4+%1.off},{autodec,sp}
- mov {relative2, 2+%1.off},{autodec,sp}
- mov {relative2, %1.off},{autodec,sp}
- from regdef8 to STACK
- gen mov {regind2, %1.reg, 6},{autodec,sp}
- mov {regind2, %1.reg, 4},{autodec,sp}
- mov {regind2, %1.reg, 2},{autodec,sp}
- mov {regdef2, %1.reg },{autodec,sp}
- from DLOCAL to STACK
- gen mov {LOCAL, 2+%1.ind, 2},{autodec,sp}
- mov {LOCAL, %1.ind, 2},{autodec,sp}
- from src1 to STACK
- gen clr {autodec,sp}
- movb %1,{regdef1,sp}
- from ftoint to STACK
- gen movfi %1.reg,{autodec,sp}
- from ftolong to STACK
- gen setl.
- movfi %1.reg,{autodec,sp}
- seti.
- COERCIONS
- from STACK
- uses REG
- gen mov {autoinc,sp},%a yields %a
- from STACK
- uses REG
- gen mov {autoinc,sp},%a yields {regconst2, %a, 0}
- from STACK
- uses FLTREG
- gen movof {autoinc,sp},%a yields %a
- from STACK
- uses DBLREG
- gen movf {autoinc,sp},%a yields %a
- from STACK
- uses REGPAIR
- gen mov {autoinc,sp},%a.1
- mov {autoinc,sp},%a.2 yields %a
- from LOCAL yields {regind2,lb,%1.ind}
- from DLOCAL yields {regind4,lb,%1.ind}
- from regconst2
- uses reusing %1,REG=%1.reg
- gen add {addr_external, %1.off},%a yields %a
- from addr_local
- uses REG
- gen mov lb,%a
- add {const2, %1.ind},%a yields %a
- from REG yields {regconst2, %1, 0}
- from xsrc2
- uses reusing %1, REG=%1 yields %a
- from xsrc2
- uses reusing %1, REG=%1 yields {regconst2, %a, 0}
- from longf4
- uses FLTREG
- gen move %1,%a yields %a
- from double8
- uses DBLREG
- gen move %1,%a yields %a
- from src1
- uses REG={const2,0}
- gen bisb %1,%a yields %a
- from REGPAIR yields %1.2 %1.1
- from regind4 yields {regind2,%1.reg,2+%1.off}
- {regind2,%1.reg,%1.off}
- from relative4 yields {relative2,2+%1.off}
- {relative2,%1.off}
- from regdef4 yields {regind2,%1.reg,2}
- {regdef2,%1.reg}
- from DLOCAL yields {LOCAL, %1.ind+2, 2}
- {LOCAL, %1.ind, 2}
- /********************************
- * from double8 to long4 *
- ********************************/
- from regind8 yields {regind4,%1.reg,4+%1.off}
- {regind4,%1.reg,%1.off}
- from relative8 yields {relative4,4+%1.off}
- {relative4,%1.off}
- from regdef8 yields {regind4,%1.reg,4}
- {regdef4,%1.reg}
- PATTERNS
- /********************************************************
- * Group 1 : load instructions. *
- * *
- * For most load instructions no code is generated. *
- * Action : put something on the fake-stack. *
- ********************************************************/
- pat loc yields {const2, $1}
- pat ldc yields {const2, loww($1)}
- {const2, highw($1)}
- pat lol yields {LOCAL, $1,2}
- pat loe yields {relative2, $1}
- pat lil yields {ILOCAL, $1}
- pat lof
- with REG yields {regind2,%1,$1}
- with exact regconst2 yields {regind2,%1.reg,$1+%1.off}
- with exact addr_external yields {relative2,$1+%1.off}
- with exact addr_local yields {LOCAL, %1.ind + $1,2}
- pat lal yields {addr_local, $1}
- pat lae yields {addr_external, $1}
- pat lpb leaving adp SL
- pat lxl $1==0 yields lb
- pat lxl $1==1 yields {LOCAL ,SL,2}
- pat lxl $1==2
- uses REG={LOCAL, SL, 2} yields {regind2,%a, SL}
- pat lxl $1==3
- uses REG={LOCAL, SL, 2}
- gen move {regind2,%a, SL},%a yields {regind2,%a, SL}
- pat lxl $1>3
- uses REG={LOCAL, SL, 2},
- REG={const2,$1-1}
- gen 1:
- move {regind2,%a, SL},%a
- sob %b,{label,1b} yields %a
- pat lxa $1==0 yields {addr_local, SL}
- pat lxa $1==1
- uses REG={LOCAL, SL, 2 } yields {regconst2, %a, SL }
- pat lxa $1==2
- uses REG={LOCAL, SL, 2 }
- gen move {regind2, %a, SL }, %a yields {regconst2, %a, SL }
- pat lxa $1==3
- uses REG={LOCAL, SL, 2 }
- gen move {regind2, %a, SL }, %a
- move {regind2, %a, SL }, %a yields {regconst2, %a, SL }
- pat lxa $1 > 3
- uses REG={LOCAL, SL, 2},
- REG={const2,$1-1}
- gen 1:
- move {regind2,%a, SL},%a
- sob %b,{label,1b} yields {regconst2, %a, SL }
- pat dch leaving loi 2
- pat loi $1==2
- with REG yields {regdef2, %1}
- with exact regconst2 yields {regind2, %1.reg, %1.off}
- with exact relative2 yields {reldef2, %1.off}
- with exact regind2 yields {reginddef2, %1.reg, %1.off}
- with exact regdef2 yields {reginddef2, %1.reg, 0}
- with exact addr_local yields {LOCAL, %1.ind,2}
- with exact addr_external yields {relative2, %1.off}
- with exact LOCAL yields {reginddef2, lb, %1.ind}
- pat loi $1==1
- with REG yields {regdef1, %1}
- with exact regconst2 yields {regind1, %1.reg, %1.off}
- with exact addr_external yields {relative1, %1.off}
- with exact addr_local yields {regind1, lb, %1.ind}
- with exact relative2 yields {reldef1, %1.off}
- with exact regind2 yields {reginddef1, %1.reg, %1.off}
- with exact regdef2 yields {reginddef1, %1.reg, 0}
- with exact LOCAL yields {reginddef1, lb, %1.ind}
- pat loi $1==4
- with REG yields {regdef4, %1}
- with exact regconst2 yields {regind4, %1.reg, %1.off}
- with exact addr_local yields {DLOCAL,%1.ind,4}
- with exact addr_external yields {relative4, %1.off}
- pat loi $1==8
- with REG yields {regdef8, %1}
- with exact regconst2 yields {regind8, %1.reg, %1.off}
- with exact addr_local yields {regind8, lb , %1.ind}
- with exact addr_external yields {relative8, %1.off}
- pat loi
- with exact addr_local
- kills ALL
- uses REG={const2,$1/2}, REG
- gen move lb,%b
- add {const2,%1.ind+$1},%b
- 1:
- mov {autodec,%b},{autodec,sp}
- sob %a,{label,1b}
- with exact addr_external
- kills ALL
- uses REG={const2,$1/2}, REG
- gen mov {addr_external,%1.off+$1},%b
- 1:
- mov {autodec,%b},{autodec,sp}
- sob %a,{label,1b}
- with REG
- kills ALL
- uses REG={const2,$1}
- gen add %a,%1
- asr %a
- 1:
- mov {autodec,%1},{autodec,sp}
- sob %a,{label,1b}
- pat ldl yields {DLOCAL, $1,4}
- pat lde yields {relative4, $1}
- pat ldf
- with regconst2 yields {regind4,%1.reg,$1+%1.off}
- with exact addr_external yields {relative4, $1+%1.off}
- with exact addr_local yields {DLOCAL, %1.ind+$1,4}
- pat lpi yields {addr_external, $1}
- /****************************************************************
- * Group 2 : Store instructions. *
- * *
- * These instructions are likely to ruin the fake-stack. *
- * We don't expect many items on the fake-stack anyway *
- * because we seem to have evaluated an expression just now. *
- ****************************************************************/
- pat stl with xsrc2
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen move %1,{LOCAL,$1,2}
- pat ste with xsrc2
- kills posextern
- gen move %1, {relative2, $1 }
- pat sil with xsrc2
- kills allexeptcon
- gen move %1, {reginddef2,lb,$1}
- pat stf
- with regconst2 xsrc2
- kills allexeptcon
- gen move %2,{regind2,%1.reg,$1+%1.off}
- with addr_external xsrc2
- kills allexeptcon
- gen move %2,{relative2,$1+%1.off}
- pat sti $1==2
- with REG xsrc2
- kills allexeptcon
- gen move%2,{regdef2,%1}
- with regconst2 xsrc2
- kills allexeptcon
- gen move%2,{regind2,%1.reg,%1.off}
- with addr_external xsrc2
- kills allexeptcon
- gen move %2,{relative2,%1.off}
- with addr_local xsrc2
- kills allexeptcon
- gen move %2,{LOCAL, %1.ind, 2}
- with relative2 xsrc2
- kills allexeptcon
- gen move %2,{reldef2,%1.off}
- with regind2 xsrc2
- kills allexeptcon
- gen move %2,{reginddef2,%1.reg,%1.off}
- pat sti $1==1
- with REG src1or2
- kills allexeptcon
- gen move %2,{regdef1,%1}
- with exact regconst2 src1or2
- kills allexeptcon
- gen move %2,{regind1,%1.reg,%1.off}
- with exact addr_external src1or2
- kills allexeptcon
- gen move %2,{relative1,%1.off}
- with exact addr_local src1or2
- kills allexeptcon
- gen move %2,{regind1, lb, %1.ind}
- with exact relative2 src1or2
- kills allexeptcon
- gen move %2,{reldef1,%1.off}
- with exact regind2 src1or2
- kills allexeptcon
- gen move %2,{reginddef1,%1.reg,%1.off}
- pat sti $1==4
- with exact REG FLTREG
- kills allexeptcon
- gen movfo %2,{regdef4,%1}
- with exact regind2 FLTREG
- kills allexeptcon
- gen movfo %2,{reginddef4,%1.reg,%1.off}
- with exact relative2 FLTREG
- kills allexeptcon
- gen movfo %2,{reldef4,%1.off}
- with exact REG ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{regdef2,%1}
- seti.
- with exact regind2 ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{reginddef2,%1.reg,%1.off}
- seti.
- with exact relative2 ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{reldef2,%1.off}
- seti.
- with exact regconst2 FLTREG
- kills allexeptcon
- gen movfo %2,{regind4,%1.reg,%1.off}
- with exact regconst2 ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{regind2,%1.reg,%1.off}
- seti.
- with exact addr_local FLTREG
- kills allexeptcon
- gen movfo %2,{DLOCAL,%1.ind,4}
- with exact addr_local ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{DLOCAL,%1.ind,4}
- seti.
- with exact addr_external FLTREG
- kills allexeptcon
- gen movfo %2,{relative4,%1.off}
- with exact addr_external ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{relative2,%1.off}
- seti.
- with REG src2 src2
- kills allexeptcon
- gen move %2,{regdef2,%1}
- move %3,{regind2,%1,2}
- with REG
- kills ALL
- gen mov {autoinc,sp},{autoinc,%1}
- mov {autoinc,sp},{regdef2,%1}
- pat sti $1==8
- with exact REG DBLREG
- kills allexeptcon
- gen movf %2,{regdef8,%1}
- with exact regind2 DBLREG
- kills allexeptcon
- gen movf %2,{reginddef8,%1.reg,%1.off}
- with exact relative2 DBLREG
- kills allexeptcon
- gen movf %2,{reldef8,%1.off}
- with exact regconst2 DBLREG
- kills allexeptcon
- gen movf %2,{regind8,%1.reg,%1.off}
- with exact addr_local DBLREG
- kills allexeptcon
- gen movf %2,{regind8, lb, %1.ind}
- with exact addr_external DBLREG
- kills allexeptcon
- gen movf %2,{relative8, %1.off}
- with REG regind8
- kills allexeptcon
- gen mov {regind2,%2.reg,%2.off },{autoinc,%1}
- mov {regind2,%2.reg,%2.off+2},{autoinc,%1}
- mov {regind2,%2.reg,%2.off+4},{autoinc,%1}
- mov {regind2,%2.reg,%2.off+6},{regdef2,%1}
- with REG relative8
- kills allexeptcon
- uses REG={addr_external,%2.off}
- gen mov {autoinc,%a},{autoinc,%1}
- mov {autoinc,%a},{autoinc,%1}
- mov {autoinc,%a},{autoinc,%1}
- mov {regdef2,%a},{regdef2,%1}
- with REG
- kills ALL
- gen mov {autoinc,sp},{autoinc,%1}
- mov {autoinc,sp},{autoinc,%1}
- mov {autoinc,sp},{autoinc,%1}
- mov {autoinc,sp},{regdef2,%1}
- pat sti
- with REG
- kills ALL
- uses REG={const2,$1/2}
- gen 1:
- mov {autoinc,sp},{autoinc,%1}
- sob %a,{label,1b}
- pat lal sti $2>2 && $2<=8
- with exact xsrc2
- yields %1
- leaving stl $1 lal $1+2 sti $2-2
- with
- yields {addr_local,$1}
- leaving sti $2
- pat sdl
- with exact FLTREG
- kills indordef, locals %ind <= $1+2 && %ind+%size > $1
- gen move %1,{DLOCAL,$1,4}
- with exact ftolong
- kills indordef, locals %ind <= $1+2 && %ind+%size > $1
- gen setl.
- movfi %1.reg,{DLOCAL,$1,4}
- seti.
- with src2 src2
- kills indordef, locals %ind <= $1+2 && %ind+%size > $1
- gen move %1,{LOCAL,$1,2}
- move %2,{LOCAL,$1+2,2}
- pat sde
- with exact FLTREG
- kills posextern
- gen move %1,{relative4,$1}
- with exact ftolong
- kills posextern
- gen setl.
- movfi %1.reg,{relative4,$1}
- seti.
- with src2 src2
- kills posextern
- gen move %1, {relative2, $1 }
- move %2, {relative2, $1+2}
- pat sdf
- with exact regconst2 FLTREG
- kills allexeptcon
- gen move %2,{regind4,%1.reg,$1+%1.off}
- with exact regconst2 ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{regind4,%1.reg,$1+%1.off}
- seti.
- with exact addr_external FLTREG
- kills allexeptcon
- gen move %2,{relative4,$1+%1.off}
- with exact addr_external ftolong
- kills allexeptcon
- gen setl.
- movfi %2.reg,{relative4, $1+%1.off}
- seti.
- with regconst2 src2 src2
- kills allexeptcon
- gen move %2,{regind2,%1.reg,$1+%1.off}
- move %3,{regind2,%1.reg,$1+2+%1.off}
- with addr_external src2 src2
- kills allexeptcon
- gen move %2,{relative2,$1+%1.off}
- move %3,{relative2,$1+2+%1.off}
- /****************************************************************
- * Group 3 : Integer arithmetic. *
- * *
- * Implemented (sometimes with the use of subroutines) : *
- * all 2 and 4 byte arithmetic. *
- ****************************************************************/
- pat adi $1==2
- with exact REG const2 yields {regconst2,%1,%2.num}
- with exact REG addr_external yields {regconst2,%1,%2.off}
- with exact REG addr_local
- gen add lb,%1 yields {regconst2,%1,%2.ind}
- with exact REG addr_local
- uses REG
- gen mov lb,%a
- add %1,%a yields {regconst2,%a,%2.ind}
- with exact REG regconst2
- gen add %2.reg,%1 yields {regconst2,%1,%2.off}
- with exact src2-REG const2+addr_external+addr_local
- uses reusing %1,REG=%1 yields %2 %a
- leaving adi 2
- with exact regconst2 const2 yields {regconst2,%1.reg,%2.num+%1.off}
- with exact regconst2 addr_external yields {regconst2,%1.reg,%2.off+%1.off}
- with exact regconst2 addr_local
- gen add lb,%1.reg yields {regconst2,%1.reg,%2.ind+%1.off}
- with exact regconst2 regconst2
- gen add %2.reg,%1.reg yields {regconst2,%1.reg,%2.off+%1.off}
- with exact regconst2 noconst2
- gen add %2,%1.reg yields %1
- with exact REG noconst2
- gen add %2,%1 yields %1
- with exact src2 regconst2
- gen add %1,%2.reg yields %2
- with exact regconst2 src2
- gen add %2,%1.reg yields %1
- with src2 REG
- gen add %1,%2 yields %2
- pat adi $1==4
- with REG REG src2 src2
- gen add %4,%2
- adc %1
- add %3,%1 yields %2 %1
- with REG REG src2 STACK
- gen add {autoinc,sp},%2
- adc %1
- add %3,%1 yields %2 %1
- with REG REG STACK
- gen add {autoinc,sp},%1
- add {autoinc,sp},%2
- adc %1 yields %2 %1
- with src2 src2 REG REG
- gen add %2,%4
- adc %3
- add %1,%3 yields %4 %3
- pat sbi $1==2
- with src2 REG
- gen sub %1,%2 yields %2
- with exact REG src2-REG
- gen sub %2,%1
- neg %1 yields %1
- pat sbi $1==4
- with src2-REG src2-REG REG REG
- gen sub %2,%4
- sbc %3
- sub %1,%3 yields %4 %3
- with src2 src2 STACK
- gen sub %2,{regind2,sp,2}
- sbc {regdef2,sp}
- sub %1,{regdef2,sp}
- pat mli $1==2
- with ODDREG src2
- gen mul %2,%1 yields %1
- with src2 ODDREG
- gen mul %1,%2 yields %2
- pat mli $1==4
- kills ALL
- gen jsr pc,{label, "mli4~"} yields r1 r0
- pat dvi $1==2
- with src2 src2
- uses reusing %2,REGPAIR
- gen mov %2,%a.2
- sxt %a.1
- div %1,%a.1 yields %a.1
- with src2 src2 STACK
- gen mov %1,{autodec,sp}
- mov %2,r1
- sxt r0
- div {autoinc,sp},r0 yields r0
- pat dvi $1==4
- kills ALL
- gen jsr pc,{label, "dvi4~"} yields r1 r0
- pat rmi $1==2
- with src2 src2
- uses reusing %2,REGPAIR
- gen mov %2,%a.2
- sxt %a.1
- div %1,%a.1 yields %a.2
- with src2 src2 STACK
- gen mov %1,{autodec,sp}
- mov %2,r1
- sxt r0
- div {autoinc,sp},r0 yields r1
- pat rmi $1==4
- kills ALL
- gen jsr pc,{label, "rmi4~"} yields r1 r0
- pat ngi $1==2
- with REG
- gen neg %1 yields %1
- pat ngi $1==4
- with REG REG
- gen neg %1
- neg %2
- sbc %1 yields %2 %1
- pat loc sli $1==1 && $2==2
- with REG
- gen asl %1 yields %1
- pat sli $1==2
- with src2 REG
- gen ash %1,%2 yields %2
- pat sli $1==4
- with src2 REGPAIR
- gen ashc %1,%2 yields %2
- pat loc sri $1==1 && $2==2
- with REG
- gen asr %1 yields %1
- pat loc sri $2==2
- with REG
- gen ash {const2,0-$1},%1 yields %1
- pat sri $1==2
- with REG REG
- gen neg %1
- ash %1,%2 yields %2
- pat loc sri $2==4
- with REGPAIR
- gen ashc {const2,0-$1},%1 yields %1
- pat sri $1==4
- with REG REGPAIR
- gen neg %1
- ashc %1,%2 yields %2
- /************************************************
- * Group 4 : unsigned arithmetic *
- * *
- * adu = adi *
- * sbu = sbi *
- * slu = sli *
- * *
- * Supported : 2- and 4 byte arithmetic. *
- ************************************************/
- pat adu leaving adi $1
- pat sbu leaving sbi $1
- pat mlu $1==2 leaving mli 2
- pat mlu $1==4
- kills ALL
- gen jsr pc,{label, "mlu4~"} yields r1 r0
- pat dvu $1==2
- kills ALL
- gen jsr pc,{label, "dvu2~"} yields r0
- pat dvu $1==4
- kills ALL
- gen jsr pc,{label, "dvu4~"} yields r1 r0
- pat rmu $1==2
- kills ALL
- gen jsr pc,{label, "rmu2~"} yields r1
- pat rmu $1==4
- kills ALL
- gen jsr pc,{label, "rmu4~"} yields r1 r0
- pat slu leaving sli $1
- pat sru $1==2
- with REG xsrc2
- uses reusing %2,REGPAIR
- gen move %2,%a.2
- move {const2,0},%a.1
- neg %1
- ashc %1,%a yields %a.2
- pat loc sru $2==2
- with xsrc2
- uses reusing %1,REGPAIR
- gen move %1,%a.2
- move {const2,0},%a.1
- ashc {const2,0-$1},%a yields %a.2
- pat sru $1==4
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "sru~"}
- /************************************************
- * Group 5 : Floating point arithmetic *
- * *
- * Supported : 4- and 8 byte arithmetic. *
- ************************************************/
- pat adf $1==4
- with FLTREG FLTREG
- gen addf %1,%2 yields %2
- with FLTREG FLTREG
- gen addf %2,%1 yields %1
- pat adf $1==8
- with double8 DBLREG
- gen addf %1,%2 yields %2
- with DBLREG double8
- gen addf %2,%1 yields %1
- pat sbf $1==4
- with FLTREG FLTREG
- gen subf %1,%2 yields %2
- pat sbf $1==8
- with double8 DBLREG
- gen subf %1,%2 yields %2
- pat mlf $1==4
- with FLTREG FLTREG
- gen mulf %1,%2 yields %2
- with FLTREG FLTREG
- gen mulf %2,%1 yields %1
- pat mlf $1==8
- with double8 DBLREG
- gen mulf %1,%2 yields %2
- with DBLREG double8
- gen mulf %2,%1 yields %1
- pat dvf $1==4
- with FLTREG FLTREG
- gen divf %1,%2 yields %2
- pat dvf $1==8
- with double8 DBLREG
- gen divf %1,%2 yields %2
- pat ngf $1==4
- with FLTREG
- gen negf %1 yields %1
- pat ngf $1==8
- with DBLREG
- gen negf %1 yields %1
- pat fif $1==4
- with longf4 FLTREG
- uses FLTREGPAIR
- gen move %1,%a.1
- modf %2,%a yields %a.1 %a.2
- pat fif $1==8
- with double8 double8
- uses DBLREGPAIR
- gen move %1,%a.1
- modf %2,%a yields %a.1 %a.2
- pat fef $1==4
- with FLTREG
- uses REG
- gen movei %1,%a
- movie {const2,0},%1 yields %1 %a
- pat fef $1==8
- with DBLREG
- uses REG
- gen movei %1,%a
- movie {const2,0},%1 yields %1 %a
- /****************************************
- * Group 6 : pointer arithmetic. *
- * *
- * Pointers have size 2 bytes. *
- ****************************************/
- pat adp
- with REG yields {regconst2, %1, $1}
- with exact regconst2 yields {regconst2, %1.reg, $1+%1.off}
- with exact addr_external yields {addr_external, $1+%1.off}
- with exact addr_local yields {addr_local,%1.ind+$1}
- pat ads $1==2 leaving adi 2
- pat sbs $1==2 leaving sbi $1
- /****************************************
- * Group 7 : increment/decrement/zero *
- ****************************************/
- pat inc
- with REG
- gen inc %1 yields %1
- pat inl
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen inc {LOCAL,$1,2}
- pat ine
- kills posextern
- gen inc {relative2, $1}
- pat dec
- with REG
- gen dec %1 yields %1
- pat del
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen dec {LOCAL, $1, 2}
- pat dee
- kills posextern
- gen dec {relative2, $1}
- pat lol loc sbi stl $1==$4 && $3==2
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen sub {const2,$2},{LOCAL,$1,2}
- pat lol ngi stl $1==$3 && $2==2
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen neg {LOCAL, $1, 2}
- pat lil ngi sil $1==$3 && $2==2
- kills allexeptcon
- gen neg {ILOCAL, $1}
- pat lil inc sil $1==$3
- kills allexeptcon
- gen inc {ILOCAL, $1}
- pat lol adi stl $2==2 && $1==$3
- with src2
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen add %1,{LOCAL, $1, 2}
- pat lol adp stl $1==$3 && $2==1
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen inc {LOCAL, $1, 2}
- pat lol adp stl $1==$3
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen add {const2, $2},{LOCAL, $1, 2}
- pat loe adi ste $2==2 && $1==$3
- with src2
- kills posextern
- gen add %1,{relative2, $1}
- pat loe adp ste $1==$3
- kills posextern
- gen add {const2, $2},{relative2, $1}
- pat lol ior stl $2==2 && $1==$3
- with src2
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen bis %1,{LOCAL, $1, 2}
- pat loe ior ste $2==2 && $1==$3
- with src2
- kills posextern
- gen bis %1,{relative2, $1}
- pat lol and stl $2==2 && $1==$3
- with REG
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen com %1
- bic %1,{LOCAL, $1, 2}
- pat loe and ste $2==2 && $1==$3
- with REG
- kills posextern
- gen com %1
- bic %1,{relative2, $1}
- pat loc lol and stl $3==2 && $2==$4
- kills indordef, locals %ind <= $2 && %ind+%size > $2
- gen bic {const2, ~$1},{LOCAL, $2, 2}
- pat loc loe and ste $3==2 && $2==$4
- kills posextern
- gen bic {const2, ~$1},{relative2, $2}
- pat zrl
- kills indordef, locals %ind <= $1 && %ind+%size > $1
- gen clr {LOCAL, $1, 2}
- pat zre
- kills posextern
- gen clr {relative2, $1}
- pat zrf $1==4
- uses FLTREG
- gen clrf %a yields %a
- pat zrf $1==8
- uses DBLREG
- gen clrf %a yields %a
- pat zer $1==2 yields {const2, 0}
- pat zer $1==4 yields {const2,0} {const2,0}
- pat zer $1==6 yields {const2,0} {const2,0} {const2,0}
- pat zer $1==8 yields {const2,0} {const2,0}
- {const2,0} {const2,0}
- pat zer defined($1)
- with STACK
- gen move {const2,$1/2},r0
- 1:
- clr {autodec,sp}
- sob r0,{label, 1b}
- /****************************************
- * Group 8 : Convert instructions *
- ****************************************/
- pat cii
- kills ALL
- gen jsr pc,{label, "cii~"}
- pat cfi leaving cfu
- pat ciu leaving cuu
- pat cui leaving cuu
- pat cfu
- kills ALL
- gen jsr pc,{label, "cfi~"}
- pat cif
- kills ALL
- gen jsr pc,{label, "cif~"}
- pat cuf
- kills ALL
- gen jsr pc,{label, "cuf~"}
- pat cff
- kills ALL
- gen jsr pc,{label, "cff~"}
- pat cuu
- kills ALL
- gen jsr pc,{label, "cuu~"}
- pat loc loc cii $1==1 && $2==2
- with src1or2
- uses reusing %1,REG
- gen movb %1,%a yields %a
- pat loc loc cii $1==1 && $2==4
- with src1or2
- uses reusing %1,REG,REG
- gen movb %1,%a
- sxt %b yields %a %b
- pat loc loc cii $1==2 && $2==4
- with src2
- uses reusing %1,REG,REG
- gen move %1,%a
- test %a
- sxt %b yields %a %b
- pat loc loc loc cii $1>=0 && $2==2 && $3==4 leaving loc $1 loc 0
- pat loc loc loc cii $1< 0 && $2==2 && $3==4 leaving loc $1 loc 0-1
- pat loc loc cii $1==4 && $2==2
- with src2
- pat loc loc cuu $1==2 && $2==4 leaving loc 0
- pat loc loc cuu $1==4 && $2==2
- with src2
- pat loc loc cfu $1==4
- with FLTREG yields {ftolong,%1}
- leaving loc 4 loc $2 cuu
- pat loc loc cfu $1==8
- with DBLREG yields {ftolong,%1.1}
- leaving loc 4 loc $2 cuu
- pat loc loc cfi $1==4 && $2==2
- with FLTREG yields {ftoint,%1}
- pat loc loc cfi $1==4 && $2==4
- with FLTREG yields {ftolong,%1}
- pat loc loc cfi $1==8 && $2==2
- with DBLREG yields {ftoint,%1.1}
- pat loc loc cfi $1==8 && $2==4
- with DBLREG yields {ftolong,%1.1}
- pat loc loc cif $1==2 && $2==4
- with src2
- uses FLTREG
- gen movif %1,%a yields %a
- pat loc loc cif $1==2 && $2==8
- with src2
- uses DBLREG
- gen movif %1,%a yields %a
- pat loc loc cif $1==4 && $2==4
- with exact long4-REGPAIR
- uses FLTREG
- gen setl.
- movif %1,%a
- seti. yields %a
- with STACK
- uses FLTREG
- gen setl.
- movif {autoinc,sp},%a
- seti. yields %a
- pat loc loc cif $1==4 && $2==8
- with exact long4-REGPAIR
- uses DBLREG
- gen setl.
- movif %1,%a
- seti. yields %a
- with STACK
- uses DBLREG
- gen setl.
- movif {autoinc,sp},%a
- seti. yields %a
- pat loc loc cuf $1==2 && $2==4
- with STACK
- uses FLTREG
- gen clr {autodec,sp}
- setl.
- movif {autoinc,sp},%a
- seti. yields %a
- pat loc loc cuf $1==2 && $2==8
- with STACK
- uses DBLREG
- gen clr {autodec,sp}
- setl.
- movif {autoinc,sp},%a
- seti. yields %a
- pat loc loc cuf $1==4 leaving loc $1 loc $2 cif
- pat loc loc cff $1==4 && $2==8
- with longf4 - FLTREG
- uses DBLREG
- gen movof %1,%a yields %a
- with FLTREG
- uses DBLREG
- gen move %1,%a.1 yields %a
- pat loc loc cff $1==8 && $2==4
- with DBLREG yields %1.1
- /****************************************
- * Group 9 : Logical instructions *
- ****************************************/
- pat and $1==2
- with const2 REG
- gen bic {const2,~%1.num},%2 yields %2
- with REG const2
- gen bic {const2,~%2.num},%1 yields %1
- with REG REG
- gen com %1
- bic %1,%2 yields %2
- pat and defined($1)
- kills ALL
- gen move {const2,$1}, r0
- jsr pc,{label, "and~"}
- pat ior $1==2
- with REG src2
- gen bis %2,%1 yields %1
- with src2 REG
- gen bis %1,%2 yields %2
- pat ior $1==8
- with exact src2 src2 src2 src2 STACK
- gen bis %1,{regdef2,sp}
- bis %2,{regind2,sp,2}
- bis %3,{regind2,sp,4}
- bis %4,{regind2,sp,6}
- with STACK
- uses REG={const2,$1}
- gen add sp,%a
- bis {autoinc,sp},{autoinc,%a}
- bis {autoinc,sp},{autoinc,%a}
- bis {autoinc,sp},{autoinc,%a}
- bis {autoinc,sp},{autoinc,%a}
- pat ior defined($1)
- with STACK
- uses REG={const2,$1},REG={const2,$1/2}
- gen add sp,%a
- 1:
- bis {autoinc,sp},{autoinc,%a}
- sob %b,{label,1b}
- pat xor $1==2
- with REG REG
- gen xor %1,%2 yields %2
- with REG REG
- gen xor %2,%1 yields %1
- pat xor defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "xor~"}
- pat com $1==2
- with REG
- gen com %1 yields %1
- pat com defined($1)
- with STACK
- uses REG={const2,$1/2},REG
- gen mov sp,%b
- 1:
- com {autoinc,%b}
- sob %a,{label,1b}
- pat rol $1==2
- with const2 ODDREG
- gen ashc {const2,%1.num-16},%2 yields %2
- with REG ODDREG
- gen sub {const2,16},%1
- ashc %1,%2 yields %2
- pat rol defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "rol~"}
- pat ror $1==2
- with const2 ODDREG
- gen ashc {const2,0-%1.num},%2 yields %2
- with REG ODDREG
- gen neg %1
- ashc %1,%2 yields %2
- pat ror defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "ror~"}
- pat com and $1==2 && $2==2
- with src2 REG
- gen bic %1,%2 yields %2
- pat com and $1==$2
- with STACK
- uses REG={const2,$1},REG
- gen mov sp,%b
- add %a,%b
- asr %a
- 1:
- bic {autoinc,sp},{autoinc,%b}
- sob %a,{label,1b}
- /********************************
- * Group 10 : Set instructions *
- ********************************/
- pat inn $1==2
- with REG REG
- gen neg %1
- ash %1,%2
- bic {const2,0177776},%2 yields %2
- pat loc inn $2==2 && $1==0
- with REG
- gen bic {const2,0177776},%1 yields %1
- pat loc inn $2==2 && $1==1
- with REG
- gen asr %1
- bic {const2,0177776},%1 yields %1
- pat loc inn $2==2
- with REG
- gen ash {const2,0-$1},%1
- bic {const2,0177776},%1 yields %1
- pat loc inn zeq $2==2 yields {const2, 1<<$1}
- leaving and 2 zeq $3
- pat inn zeq $1==2
- with src2
- uses REG={const2,1}
- gen ash %1,%a yields %a
- leaving and 2 zeq $2
- pat loc inn zne $2==2 yields {const2, 1<<$1}
- leaving and 2 zne $3
- pat inn zne $1==2
- with src2
- uses REG={const2,1}
- gen ash %1,%a yields %a
- leaving and 2 zne $2
- pat inn defined($1)
- with src2
- kills ALL
- gen move %1,r1
- move {const2,$1},r0
- jsr pc,{label, "inn~"} yields r0
- pat set $1==2
- with REG
- uses REG={const2,1}
- gen ash %1,%a yields %a
- pat set defined($1)
- with src2
- kills ALL
- gen move %1,r1
- move {const2,$1},r0
- jsr pc,{label, "set~"}
- /****************************************
- * Group 11 : Array instructions *
- ****************************************/
- pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)==0 leaving adi 2
- pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)!=0 leaving adi 2 adp 0-rom($1,1)
- pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)==0
- with REG
- gen asl %1 yields %1 leaving adi 2
- pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)!=0
- with REG
- gen asl %1 yields {regconst2,%1,(0-2)*rom($1,1)}
- leaving adi 2
- pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)==0
- with REG
- gen ash {const2,2},%1 yields %1 leaving adi 2
- pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)!=0
- with REG
- gen ash {const2,2},%1 yields {regconst2,%1,(0-4)*rom($1,1)}
- leaving adi 2
- pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)==0
- with REG
- gen ash {const2,3},%1 yields %1
- leaving adi 2
- pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)!=0
- with REG
- gen ash {const2,3},%1 yields {regconst2,%1,(0-8)*rom($1,1)}
- leaving adi 2
- pat lae aar $2==2 && rom($1,1)==0
- with ODDREG
- gen mul {const2,rom($1,3)},%1 yields %1 leaving adi 2
- pat lae aar $2==2 && defined(rom($1,1))
- with ODDREG
- gen mul {const2,rom($1,3)},%1 yields {regconst2,%1,(0-rom($1,3))*rom($1,1)}
- leaving adi 2
- pat aar $1==2
- kills ALL
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- jsr pc,{label, "aar~"}
- pat lae sar defined(rom($1,3)) leaving lae $1 aar $2 sti rom($1,3)
- pat lae lar defined(rom($1,3)) leaving lae $1 aar $2 loi rom($1,3)
- pat sar $1==2
- kills ALL
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- jsr pc,{label, "sar~"}
- pat lar $1==2
- kills ALL
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- jsr pc,{label, "lar~"}
- #ifdef UNTESTED
- pat aar !defined($1)
- kills ALL
- gen jsr pc,{label, "iaar~"}
- pat sar !defined($1)
- kills ALL
- gen jsr pc,{label, "isar~"}
- pat lar !defined($1)
- kills ALL
- gen jsr pc,{label, "ilar~"}
- #endif
- /****************************************
- * group 12 : Compare instructions *
- ****************************************/
- pat cmi $1==2
- with src2 src2
- uses REG = {const2,0}
- gen cmp %1,%2
- beq {label,2f}
- bgt {label,1f}
- inc %a
- br {label,2f}
- 1:
- dec %a
- 2: yields %a
- pat cmi $1==4
- kills ALL
- gen jsr pc,{label, "cmi4~"} yields r0
- pat cmf defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "cmf~"} yields r0
- pat cmu $1==2 leaving cmp
- pat cmu $1==4
- kills ALL
- gen jsr pc,{label, "cmu4~"} yields r0
- pat cmu defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "cmu~"} yields r0
- pat cms $1==2 leaving cmi $1
- pat cms defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "cms~"} yields r0
- pat cms !defined($1)
- with src2
- kills ALL
- gen move %1,r0
- jsr pc,{label, "cms~"} yields r0
- pat cmp
- with src2 src2
- uses REG = {const2,0}
- gen cmp %1,%2
- beq {label,2f}
- bhi {label,1f}
- inc %a
- br {label,2f}
- 1:
- dec %a
- 2: yields %a
- proc txxand
- with src2 REG
- gen test %1
- bxx* {label,1f}
- clr %2
- 1: yields %2
- proc txxior
- with src2 REG
- gen test %1
- bxx* {label,1f}
- bis {const2,1},%2
- 1: yields %2
- proc txx
- with src2
- uses REG={const2,0}
- gen test %1
- bxx* {label,1f}
- inc %a
- 1: yields %a
- pat tlt and $2==2 call txxand("blt")
- pat tle and $2==2 call txxand("ble")
- pat teq and $2==2 call txxand("beq")
- pat tne and $2==2 call txxand("bne")
- pat tgt and $2==2 call txxand("bgt")
- pat tge and $2==2 call txxand("bge")
- pat tlt ior $2==2 call txxior("bge")
- pat tle ior $2==2 call txxior("bgt")
- pat teq ior $2==2 call txxior("bne")
- pat tne ior $2==2 call txxior("beq")
- pat tgt ior $2==2 call txxior("ble")
- pat tge ior $2==2 call txxior("blt")
- pat tlt call txx("bge")
- pat tle call txx("bgt")
- pat teq call txx("bne")
- pat tne call txx("beq")
- pat tgt call txx("ble")
- pat tge call txx("blt")
- proc andtxx
- with src2 src2
- uses REG={const2,0}
- gen bit %1,%2
- bxx* {label,1f}
- inc %a
- 1: yields %a
- pat and tne $1==2 call andtxx("beq")
- pat and teq $1==2 call andtxx("bne")
- proc cmitxxand
- with src2 src2 REG
- gen cmp %2,%1
- bxx* {label,1f}
- clr %3
- 1: yields %3
- proc cmitxxior
- with src2 src2 REG
- gen cmp %2,%1
- bxx* {label,1f}
- bis {const2,1},%3
- 1: yields %3
- proc cmitxx
- with src2 src2
- uses REG={const2,0}
- gen cmp %2,%1
- bxx* {label,1f}
- inc %a
- 1: yields %a
- pat cmi tlt and $1==2 && $3==2 call cmitxxand("blt")
- pat cmi tle and $1==2 && $3==2 call cmitxxand("ble")
- pat cmi teq and $1==2 && $3==2 call cmitxxand("beq")
- pat cmi tne and $1==2 && $3==2 call cmitxxand("bne")
- pat cmi tgt and $1==2 && $3==2 call cmitxxand("bgt")
- pat cmi tge and $1==2 && $3==2 call cmitxxand("bge")
- pat cmi tlt ior $1==2 && $3==2 call cmitxxior("bge")
- pat cmi tle ior $1==2 && $3==2 call cmitxxior("bgt")
- pat cmi teq ior $1==2 && $3==2 call cmitxxior("bne")
- pat cmi tne ior $1==2 && $3==2 call cmitxxior("beq")
- pat cmi tgt ior $1==2 && $3==2 call cmitxxior("ble")
- pat cmi tge ior $1==2 && $3==2 call cmitxxior("blt")
- pat cmi tlt $1==2 call cmitxx("bge")
- pat cmi tle $1==2 call cmitxx("bgt")
- pat cmi teq $1==2 call cmitxx("bne")
- pat cmi tne $1==2 call cmitxx("beq")
- pat cmi tgt $1==2 call cmitxx("ble")
- pat cmi tge $1==2 call cmitxx("blt")
- pat loc cmi teq and $1>=0 && $1<=127 && $2==2 && $4==2
- with exact src1 REG
- gen cmpb %1,{const2,$1}
- beq {label,1f}
- clr %2
- 1: yields %2
- with yields {const2, $1}
- leaving cmi 2 teq and 2
- pat loc cmi teq ior $1>=0 && $1<=127 && $2==2 && $4==2
- with exact src1 REG
- gen cmpb %1,{const2,$1}
- bne {label,1f}
- bis {const2,1},%2
- 1: yields %2
- with yields {const2, $1}
- leaving cmi 2 teq ior 2
- pat loc cmi teq $1>=0 && $1<=127 && $2==2
- with exact src1
- uses REG={const2,0}
- gen cmpb %1,{const2,$1}
- bne {label,1f}
- inc %a
- 1: yields %a
- with yields {const2, $1}
- leaving cmi 2 teq
- pat loc cmi tne and $1>=0 && $1<=127 && $2==2 && $4==2
- with exact src1 REG
- gen cmpb %1,{const2,$1}
- bne {label,1f}
- clr %2
- 1: yields %2
- with yields {const2, $1}
- leaving cmi 2 tne and 2
- pat loc cmi tne ior $1>=0 && $1<=127 && $2==2 && $4==2
- with exact src1 REG
- gen cmpb %1,{const2,$1}
- beq {label,1f}
- bis {const2,1},%2
- 1: yields %2
- with yields {const2, $1}
- leaving cmi 2 tne ior 2
- pat loc cmi tne $1>=0 && $1<=127 && $2==2
- with exact src1
- uses REG={const2,0}
- gen cmpb %1,{const2,$1}
- beq {label,1f}
- inc %a
- 1: yields %a
- with yields {const2, $1}
- leaving cmi 2 tne
- proc cmptxx
- with src2 src2
- uses REG={const2,0}
- gen cmp %2,%1
- bxx* {label,1f}
- inc %a
- 1: yields %a
- pat cmp tlt call cmptxx("bhis")
- pat cmp tle call cmptxx("bhi")
- pat cmp teq call cmptxx("bne")
- pat cmp tne call cmptxx("beq")
- pat cmp tgt call cmptxx("blos")
- pat cmp tge call cmptxx("blo")
- proc cmf4txx
- with FLTREG FLTREG
- uses REG={const2,0}
- gen cmpf %2,%1
- cfcc.
- bxx* {label,1f}
- inc %a
- 1: yields %a
- pat cmf tlt $1==4 call cmf4txx("bge")
- pat cmf tle $1==4 call cmf4txx("bgt")
- pat cmf teq $1==4 call cmf4txx("bne")
- pat cmf tne $1==4 call cmf4txx("beq")
- pat cmf tgt $1==4 call cmf4txx("ble")
- pat cmf tge $1==4 call cmf4txx("blt")
- proc cmf8txx
- with DBLREG double8
- uses REG={const2,0}
- gen cmpf %2,%1
- cfcc.
- bxx[1] {label,1f}
- inc %a
- 1: yields %a
- with double8 DBLREG
- uses REG={const2,0}
- gen cmpf %1,%2
- cfcc.
- bxx[2] {label,1f}
- inc %a
- 1: yields %a
- pat cmf tlt $1==8 call cmf8txx("bge","ble")
- pat cmf tle $1==8 call cmf8txx("bgt","blt")
- pat cmf teq $1==8 call cmf8txx("bne","bne")
- pat cmf tne $1==8 call cmf8txx("beq","beq")
- pat cmf tgt $1==8 call cmf8txx("ble","bge")
- pat cmf tge $1==8 call cmf8txx("blt","bgt")
- /****************************************
- * Group 13 : Branch instructions *
- ****************************************/
- pat bra
- with STACK
- gen jbr {label, $1}
- proc bxx example beq
- with src2 src2 STACK
- gen cmp %2,%1
- jxx* {label, $1}
- pat blt call bxx("jlt")
- pat ble call bxx("jle")
- pat beq call bxx("jeq")
- pat bne call bxx("jne")
- pat bgt call bxx("jgt")
- pat bge call bxx("jge")
- pat loc beq $1>=0 && $1<=127
- with exact src1 STACK
- gen cmpb %1,{const2,$1}
- jeq {label, $2}
- with yields {const2, $1}
- leaving beq $2
- pat loc bne $1>=0 && $1<=127
- with exact src1 STACK
- gen cmpb %1,{const2,$1}
- jne {label, $2}
- with yields {const2, $1}
- leaving bne $2
- proc zxx example zeq
- with src2 STACK
- gen test %1
- jxx* {label, $1}
- pat zlt call zxx("jlt")
- pat zle call zxx("jle")
- pat zeq call zxx("jeq")
- pat zne call zxx("jne")
- pat zgt call zxx("jgt")
- pat zge call zxx("jge")
- proc cmpzxx example cmp zeq
- with src2 src2 STACK
- gen cmp %2,%1
- jxx* {label, $2}
- pat cmp zlt call cmpzxx("jlo")
- pat cmp zle call cmpzxx("jlos")
- pat cmp zeq call cmpzxx("jeq")
- pat cmp zne call cmpzxx("jne")
- pat cmp zgt call cmpzxx("jhi")
- pat cmp zge call cmpzxx("jhis")
- proc cmf4zxx example cmf zeq
- with FLTREG FLTREG STACK
- gen cmpf %2,%1
- cfcc.
- jxx* {label, $2}
- pat cmf zlt $1==4 call cmf4zxx("jlt")
- pat cmf zle $1==4 call cmf4zxx("jle")
- pat cmf zeq $1==4 call cmf4zxx("jeq")
- pat cmf zne $1==4 call cmf4zxx("jne")
- pat cmf zgt $1==4 call cmf4zxx("jgt")
- pat cmf zge $1==4 call cmf4zxx("jge")
- proc cmf8zxx example cmf zeq
- with DBLREG double8 STACK
- gen cmpf %2,%1
- cfcc.
- jxx[1] {label, $2}
- with double8 DBLREG STACK
- gen cmpf %1,%2
- cfcc.
- jxx[2] {label, $2}
- pat cmf zlt $1==8 call cmf8zxx("jlt","jgt")
- pat cmf zle $1==8 call cmf8zxx("jle","jge")
- pat cmf zeq $1==8 call cmf8zxx("jeq","jeq")
- pat cmf zne $1==8 call cmf8zxx("jne","jne")
- pat cmf zgt $1==8 call cmf8zxx("jgt","jlt")
- pat cmf zge $1==8 call cmf8zxx("jge","jle")
- proc andzen example and zeq
- with src2 src2 STACK
- gen bit %1,%2
- jxx* {label, $2}
- pat and zeq $1==2 call andzen("jeq")
- pat and zne $1==2 call andzen("jne")
- /************************************************
- * group 14 : Procedure call instructions *
- ************************************************/
- pat cal
- kills ALL
- gen jsr pc,{label, $1}
- pat cai
- with REG
- kills ALL
- gen jsr pc,{regdef2,%1}
- pat lfr $1==2 yields r0
- pat lfr $1==4 yields r1 r0
- pat lfr $1==8 yields {relative8,"retar"}
- pat lfr
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "lfr~"}
- pat lfr ret $1==$2 leaving ret 0
- pat ret $1==0
- with STACK
- gen mov lb,sp
- mov {autoinc, sp},lb
- rts pc
- pat ret $1==2
- with src2 STACK
- gen move %1,r0
- mov lb,sp
- mov {autoinc, sp},lb
- rts pc
- pat ret $1==4
- with STACK
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- mov lb,sp
- mov {autoinc, sp},lb
- rts pc
- pat ret $1==8 yields {addr_external, "retar"}
- leaving sti 8 ret 0
- pat ret
- kills ALL
- gen move {const2,$1},r0
- jmp {label,"ret~"}
- /************************************************
- * Group 15 : Miscellaneous instructions *
- ************************************************/
- pat asp $1==2
- with STACK
- gen tst {autoinc,sp}
- pat asp $1==4
- with STACK
- gen cmp {autoinc,sp},{autoinc,sp}
- pat asp $1==0-2
- with STACK
- gen tst {autodec,sp}
- pat asp
- with STACK
- gen add {const2,$1},sp
- pat ass $1==2
- with STACK
- gen add {autoinc,sp},sp
- pat blm $1==4
- with REG REG
- gen mov {autoinc,%2},{autoinc,%1}
- mov {regdef2,%2},{regdef2,%1}
- pat blm $1==6
- with REG REG
- gen mov {autoinc,%2},{autoinc,%1}
- mov {autoinc,%2},{autoinc,%1}
- mov {regdef2,%2},{regdef2,%1}
- pat blm $1==8
- with REG REG
- gen mov {autoinc,%2},{autoinc,%1}
- mov {autoinc,%2},{autoinc,%1}
- mov {autoinc,%2},{autoinc,%1}
- mov {regdef2,%2},{regdef2,%1}
- pat blm
- with REG REG
- uses REG={const2,$1/2}
- gen 1:
- mov {autoinc,%2},{autoinc,%1}
- sob %a,{label,1b}
- pat bls $1==2
- with REG REG REG
- gen
- asr %1
- beq {label,1f}
- 2:
- mov {autoinc,%3},{autoinc,%2}
- sob %1,{label,2b}
- 1:
- pat lae csa $2==2
- with src2
- kills ALL
- gen move %1,r1
- move {addr_external,$1},r0
- jmp {label, "csa~"}
- pat csa $1==2
- kills ALL
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- jmp {label, "csa~"}
- pat lae csb $2==2
- with src2
- kills ALL
- gen move %1,r1
- move {addr_external,$1},r0
- jmp {label, "csb~"}
- pat csb $1==2
- kills ALL
- gen mov {autoinc,sp},r0
- mov {autoinc,sp},r1
- jmp {label, "csb~"}
- pat dup $1==2
- with REG yields %1 %1
- pat dup $1==4
- with exact long4 yields %1 %1
- with src2 src2 yields %2 %1 %2 %1
- pat dup $1==8
- with exact long8 yields %1 %1
- with STACK
- kills ALL
- gen move {const2, $1}, r0
- jsr pc,{label, "dup~"}
- pat dup
- kills ALL
- gen move {const2, $1}, r0
- jsr pc,{label, "dup~"}
- pat dus $1==2
- with src2
- kills ALL
- gen move %1,r0
- jsr pc,{label, "dup~"}
- pat gto
- kills ALL
- gen mov {addr_external, $1},{autodec,sp}
- jmp {label, "gto~"}
- pat fil
- gen mov {addr_external, $1},{relative2, "hol0"+4}
- pat lim yields { relative2, "trpim~"}
- pat lin
- gen mov {const2,$1},{relative2, "hol0"}
- pat lni
- gen inc {relative2, "hol0"}
- pat lor $1==0 yields lb
- pat lor $1==1
- with STACK
- uses REG
- gen mov sp,%a yields %a
- pat lor $1==2 yields {relative2,"reghp~"}
- pat mon
- kills ALL
- gen jsr pc,{label, "mon~"}
- pat nop
- kills ALL
- #ifdef DEBUG
- gen jsr pc,{label, "nop~"}
- #endif
- pat rck $1==2
- with src2
- pat rtt leaving ret 0
- pat sig
- with src2
- uses REG
- gen move {relative2,"trppc~"},%a
- mov %1,{relative2,"trppc~"} yields %a
- pat sim
- kills ALL
- gen jsr pc,{label, "sim~"}
- pat str $1==0
- with src2
- kills ALL
- gen mov %1,lb
- pat str $1==1
- with src2
- kills ALL
- gen mov %1,sp
- pat str $1==2
- kills ALL
- gen jsr pc,{label, "strhp~"}
- pat trp
- kills ALL
- gen jsr pc,{label, "trp~"}
- pat exg $1==2
- with src2 src2 yields %1 %2
- pat exg defined($1)
- kills ALL
- gen move {const2,$1},r0
- jsr pc,{label, "exg~"}
- pat lol lal sti $1==$2 && $3==1 /* throw away funny C-proc-prolog */
- pat los
- gen jmp {label, illins}
- pat sts
- gen jmp {label, illins}
- pat inn
- gen jmp {label, illins}
- pat set
- gen jmp {label, illins}
|