table 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. rscid = "$Id$"
  6. /*
  7. * Back end tables for Intel 8086, 80286
  8. *
  9. * Author : Ed Keizer
  10. *
  11. * Adapted to ncg format by BMT Mosseveld, EM v Mulligen, M de Rooy, E tulp,
  12. * and R Vendelmans (practical work course compiler construction).
  13. *
  14. * New format table much corrected: Ceriel Jacobs
  15. * Added register variables: Ceriel Jacobs
  16. * Adapted to use floating point library: Ceriel Jacobs
  17. *
  18. * wordsize = 2 bytes, pointersize = 2 bytes.
  19. *
  20. * Register bp is used as LB, sp is used for SP.
  21. * Some global variables are used:
  22. * - .reghp : the heap pointer
  23. * - .ignmask : trap ignore mask
  24. * - .trppc : address of user defined trap handler
  25. *
  26. */
  27. SL = 4
  28. SSL = "4"
  29. EM_WSIZE = 2
  30. EM_PSIZE = 2
  31. EM_BSIZE = 4
  32. SIZEFACTOR = 5/1
  33. #define EXACT exact
  34. #define REGVARS
  35. /*****************************************************************/
  36. PROPERTIES
  37. /*****************************************************************/
  38. REG1
  39. ACC1
  40. AREG
  41. SHIFT_CREG
  42. REG
  43. GENREG
  44. ACC
  45. BREG
  46. BXREG
  47. ADDREG
  48. CXREG
  49. DXREG
  50. IREG
  51. #ifdef REGVARS
  52. RADDREG
  53. #endif
  54. /*****************************************************************/
  55. REGISTERS
  56. /*****************************************************************/
  57. al : REG1 , ACC1 .
  58. ah,bl,bh,ch,dl,dh : REG1 .
  59. cl : REG1 , SHIFT_CREG .
  60. ax = al + ah : REG , GENREG , ACC .
  61. bx = bl + bh : REG , GENREG , BXREG , ADDREG , AREG .
  62. cx = cl + ch : REG , GENREG , CXREG , SHIFT_CREG.
  63. dx = dl + dh : REG , GENREG , DXREG .
  64. #ifndef REGVARS
  65. si : REG , IREG , AREG , ADDREG .
  66. di : REG , IREG , AREG , ADDREG .
  67. #else
  68. si : AREG , RADDREG , IREG regvar(reg_any) .
  69. di : AREG , RADDREG , IREG regvar(reg_any) .
  70. #endif
  71. bp : AREG .
  72. sp : BREG .
  73. /*****************************************************************/
  74. TOKENS
  75. /*****************************************************************/
  76. ANYCON = { INT val; } 2 cost(2,2) val .
  77. CONSTR = { ADDR off; } 2 cost(2,2) off .
  78. ADDR_EXTERN = { ADDR off; } 2 cost(2,2) off .
  79. EXTERN1 = { ADDR off; } 2 cost(2,12) "(" off ")" .
  80. EXTERN2 = { ADDR off; } 2 cost(2,12) "(" off ")" .
  81. ADDR_LOCAL = { INT ind; } 2 cost(1,9) ind "(bp)" .
  82. LOCAL = { INT ind; INT size; } 2 cost(1,15) ind "(bp)" .
  83. LOCAL1 = { INT ind; INT size; } 2 cost(1,15) ind "(bp)" .
  84. Rreg_off = { AREG reg; ADDR off;} 2 cost(1,9) off "(" reg ")" .
  85. Rbpreg_off = { AREG reg; INT ind;} 2 cost(1,11) ind "(bp)" "(" reg ")" .
  86. Xreg_off = { AREG reg; ADDR off;} 2 cost(1,9) off "(" reg ")" .
  87. ind_reg2 = { AREG reg;} 2 cost(0,11) "(" reg ")" .
  88. ind_regoff2 = { AREG reg; ADDR off;} 2 cost(1,15) off "(" reg ")" .
  89. ind_bpregoff2 = { AREG reg; INT ind;} 2 cost(1,18) ind "(bp)" "(" reg ")" .
  90. ind_reg1 = { AREG reg;} 2 cost(0,11) "(" reg ")" .
  91. ind_regoff1 = { AREG reg; ADDR off;} 2 cost(1,15) off "(" reg ")" .
  92. ind_bpregoff1 = { AREG reg; INT ind;} 2 cost(1,18) ind "(bp)" "(" reg ")" .
  93. label = { ADDR off;} 2 off .
  94. /*****************************************************************/
  95. SETS
  96. /*****************************************************************/
  97. /* Mode refering to a word in memory */
  98. memory2 = EXTERN2 + ind_reg2 + ind_regoff2 + ind_bpregoff2 +
  99. LOCAL .
  100. memory1 = EXTERN1 + ind_reg1 + ind_regoff1 + ind_bpregoff1 +
  101. LOCAL1 .
  102. const = ANYCON + ADDR_EXTERN + CONSTR .
  103. register = REG + AREG
  104. #ifdef REGVARS
  105. + IREG
  106. #endif
  107. .
  108. addreg = ADDREG
  109. #ifdef REGVARS
  110. + RADDREG
  111. #endif
  112. .
  113. anyreg = register + BREG .
  114. rm = anyreg + memory2 .
  115. rmnoacc = IREG + BXREG + CXREG + memory2 .
  116. rmorconst = const + rm .
  117. regorconst = const + anyreg .
  118. #ifdef REGVARS
  119. /* Needed because there is a shortage of ADDREG-registers.
  120. This is the main penalty for having register variables.
  121. */
  122. regorconstnoaddr = const + IREG + ACC + CXREG + DXREG .
  123. #else
  124. regorconstnoaddr = regorconst .
  125. #endif
  126. dest = register + memory2 .
  127. rm1 = REG1 + memory1 .
  128. rmorconst1 = const + rm1 .
  129. regorconst12 = REG1 + GENREG + const .
  130. dest1 = REG1 + memory1 .
  131. rm12 = rm1 + memory2 .
  132. /* Modes used to indicate tokens to be removed from the fakestack */
  133. reg_indexed = ind_reg2 + ind_regoff2 + ind_reg1 + ind_regoff1 .
  134. lb_indexed = ind_bpregoff2 + ind_bpregoff1 .
  135. indexed = reg_indexed + lb_indexed .
  136. externals = EXTERN2 + EXTERN1 .
  137. locals = LOCAL + LOCAL1 .
  138. all_locals = locals + lb_indexed .
  139. indirects = externals + reg_indexed .
  140. referals = indirects + locals .
  141. /* Miscellaneous */
  142. reg_off = Xreg_off + Rreg_off .
  143. bpreg_off = Rbpreg_off .
  144. halfindir = reg_off + bpreg_off + ADDR_LOCAL .
  145. some_off = halfindir + ADDR_EXTERN + addreg .
  146. a_word = rmorconst + rm1 + halfindir .
  147. no_reg_off = rmorconst + rm1 + ADDR_LOCAL .
  148. /*****************************************************************/
  149. INSTRUCTIONS
  150. /*****************************************************************/
  151. cost(1,3)
  152. adc rm:rw:cc, regorconst:ro.
  153. adc anyreg:rw:cc, rmorconst:ro.
  154. #ifdef REGVARS
  155. add LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  156. #endif
  157. add anyreg:rw:cc, rmorconst:ro.
  158. add rm:rw:cc, regorconst:ro.
  159. #ifdef REGVARS
  160. axx "syntax error" LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  161. #endif
  162. axx "syntax error" anyreg:rw:cc, rmorconst:ro.
  163. axx "syntax error" rm:rw:cc, regorconst:ro.
  164. #ifdef REGVARS
  165. and LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  166. #endif
  167. and rm:rw:cc, regorconst:ro.
  168. and anyreg:rw:cc, rmorconst:ro.
  169. cbw kills ah cost(1,2).
  170. cmp rm:ro, regorconst:ro kills :cc.
  171. cmp anyreg:ro, rmorconst:ro kills :cc.
  172. cmpb rm1:ro, REG1+const:ro kills :cc.
  173. cmpb REG1:ro, rm1:ro kills :cc.
  174. cwd kills dx cost(1,5).
  175. dec rm:rw:cc cost(1,2).
  176. div rm:ro kills:cc ax dx cost(1,150).
  177. idiv rm:ro kills:cc ax dx cost(1,170).
  178. inc rm:rw:cc cost(1,2).
  179. ja label cost(1,4).
  180. jae label cost(1,4).
  181. jb label cost(1,4).
  182. jbe label cost(1,4).
  183. jcxz label cost(1,5).
  184. je label cost(1,4).
  185. jg label cost(1,4).
  186. jge label cost(1,4).
  187. jl label cost(1,4).
  188. jle label cost(1,4).
  189. jne label cost(1,4).
  190. jmp label cost(1,7).
  191. joehoe "call" label+rm cost(1,8).
  192. jxx "syntax error" label.
  193. lea anyreg:wo, halfindir:ro cost(1,2).
  194. lea LOCAL:wo, halfindir:ro cost(1,2). /* only for register variables, UNSAFE!!! */
  195. loop label kills cx cost(1,5).
  196. #ifdef REGVARS
  197. mov LOCAL:wo, memory2:ro cost(1,2). /* only for register variables, UNSAFE!!! */
  198. #endif
  199. mov a_word:wo, regorconst:ro cost(1,2).
  200. mov anyreg:wo, rmorconst:ro cost(1,2).
  201. movb rm1:wo, regorconst12:ro cost(1,2).
  202. movb REG1:wo, rm1:ro cost(1,2).
  203. mul rmorconst:ro kills :cc ax dx cost(1,124).
  204. neg rmorconst:rw:cc.
  205. nop .
  206. not rmorconst:rw.
  207. ORB "orb" REG1:ro, REG1:ro:cc. /* use ORB for tests */
  208. OR "or" anyreg:ro, anyreg:ro:cc. /* Use OR for tests */
  209. #ifdef REGVARS
  210. or LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  211. #endif
  212. or rm:rw:cc, regorconst:ro.
  213. or anyreg:rw:cc, rmorconst:ro.
  214. pop rmorconst:wo cost(1,8).
  215. push rmorconst:ro cost(1,10).
  216. rcl rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  217. rcr rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  218. ret cost(1,8).
  219. rol rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  220. ror rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  221. sal rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  222. sar rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  223. sbb rm:rw:cc, regorconst:ro.
  224. sbb anyreg:rw:cc, rmorconst:ro.
  225. shl rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  226. shr rm:rw, ANYCON+SHIFT_CREG:ro kills:cc.
  227. sxx rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  228. #ifdef REGVARS
  229. sub LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  230. #endif
  231. sub rm:rw:cc, regorconst:ro.
  232. sub anyreg:rw:cc, rmorconst+halfindir:ro.
  233. check "test" rm:ro, regorconst:ro kills :cc.
  234. check "test" anyreg:ro, rmorconst:ro kills :cc.
  235. testb "testb" rm12:ro, regorconst:ro kills :cc.
  236. testb "testb" REG1:ro, rmorconst:ro kills :cc.
  237. testb "testb" ACC1:ro, const:ro kills :cc.
  238. uxx "syntax error" rm:rw:cc cost(1,2).
  239. xchg rm:rw, anyreg:rw.
  240. xchg anyreg:rw, rm:rw.
  241. xor rm:rw:cc, regorconst:ro.
  242. xor anyreg:rw:cc, rmorconst:ro.
  243. xorb rm1:rw:cc, regorconst12:ro.
  244. xorb anyreg:rw:cc, rm1:ro.
  245. killreg "! kill" anyreg:wo cost(0,0).
  246. killcc "! kill cc" kills:cc cost(0,0).
  247. data ".sect .data".
  248. word ".data2" const:ro.
  249. text ".sect .text".
  250. /*****************************************************************/
  251. MOVES
  252. /*****************************************************************/
  253. #ifdef REGVARS
  254. from memory2 to LOCAL /* unsafe !!! */
  255. gen mov %2,%1
  256. from halfindir to LOCAL /* unsafe !!! */
  257. gen lea %2,%1
  258. #endif
  259. from rm to register
  260. gen mov %2,%1
  261. from anyreg to dest
  262. gen mov %2,%1
  263. from halfindir to register+AREG
  264. gen lea %2,%1
  265. from rm1 to REG1
  266. gen movb %2,%1
  267. from GENREG to rm1
  268. gen movb %2,%1.1
  269. from ANYCON %val==0 to register
  270. gen xor %2,%2
  271. from ANYCON %val==0 to REG1
  272. gen xorb %2,%2
  273. from const to dest
  274. gen mov %2,%1
  275. from const+REG1 to rm1
  276. gen movb %2,%1
  277. /*****************************************************************/
  278. TESTS
  279. /*****************************************************************/
  280. to test anyreg
  281. gen OR %1,%1
  282. to test memory2
  283. gen cmp %1, {ANYCON,0}
  284. to test REG1
  285. gen ORB %1,%1
  286. to test memory1
  287. gen cmpb %1, {ANYCON,0}
  288. /*****************************************************************/
  289. STACKINGRULES
  290. /*****************************************************************/
  291. from anyreg to STACK
  292. gen push %1
  293. from memory2 to STACK
  294. gen push %1
  295. from const to STACK
  296. uses REG
  297. gen move %1,%a
  298. push %a
  299. from const to STACK
  300. gen data.
  301. 1:
  302. word %1
  303. text.
  304. push {EXTERN2,"1b"}
  305. from rm1 to STACK
  306. uses GENREG
  307. gen move {ANYCON,0},%a
  308. move %1,%a.1
  309. push %a
  310. from rm1 to STACK
  311. gen push ax
  312. push bx
  313. move %1,al
  314. xorb ah,ah
  315. mov bx,sp
  316. xchg {ind_regoff2,bx,2},ax
  317. pop bx
  318. from Xreg_off to STACK
  319. gen add %1.reg,{CONSTR,%1.off}
  320. push %1.reg
  321. from ADDR_LOCAL %ind==0 to STACK
  322. gen
  323. push bp
  324. from halfindir to STACK
  325. uses REG
  326. gen move %1,%a
  327. push %a
  328. from halfindir to STACK
  329. gen push ax
  330. push bx
  331. lea ax,%1
  332. mov bx,sp
  333. xchg {ind_regoff2,bx,2},ax
  334. pop bx
  335. /*****************************************************************/
  336. COERCIONS
  337. /*****************************************************************/
  338. /***************************
  339. * From source to register *
  340. ***************************/
  341. from rmorconst
  342. uses reusing %1,REG=%1 yields %a
  343. from Xreg_off
  344. gen add %1.reg,{CONSTR,%1.off} yields %1.reg
  345. from halfindir
  346. uses reusing %1,ADDREG
  347. gen move %1,%a yields %a
  348. from halfindir
  349. uses reusing %1,REG
  350. gen move %1,%a yields %a
  351. /************************
  352. * From source to token *
  353. ************************/
  354. from ANYCON yields {ADDR_EXTERN,%1.val}
  355. /****************
  356. * From source1 *
  357. ****************/
  358. from rm1
  359. uses reusing %1,REG1=%1 yields %a
  360. from rm1
  361. uses reusing %1,GENREG
  362. gen move %1,%a.1
  363. xorb %a.2,%a.2 yields %a
  364. from ACC1
  365. uses reusing %1,ACC
  366. gen xorb %a.2,%a.2 yields %a
  367. /************************
  368. * From STACK coercions *
  369. ************************/
  370. from STACK
  371. uses REG
  372. gen pop %a yields %a
  373. /*****************************************************************/
  374. PATTERNS
  375. /*****************************************************************/
  376. /******************************************************************
  377. * Group 1 : Load Instructions *
  378. ******************************************************************/
  379. pat loc yields {ANYCON,$1}
  380. pat ldc loww($1)==0 && highw($1)==0
  381. uses REG = {ANYCON, 0} yields %a %a
  382. pat ldc yields {ANYCON,highw($1)}
  383. {ANYCON,loww($1)}
  384. pat lol yields {LOCAL,$1,2}
  385. pat stl lol $1==$2
  386. #ifdef REGVARS
  387. && inreg($1) <= 0
  388. #endif
  389. leaving dup 2 stl $1
  390. pat stl lol lof $1==$2
  391. #ifdef REGVARS
  392. && inreg($1) <= 0
  393. #endif
  394. with AREG yields %1 %1
  395. leaving stl $1 lof $3
  396. pat stl lol loi $1==$2
  397. #ifdef REGVARS
  398. && inreg($1) <= 0
  399. #endif
  400. with AREG yields %1 %1
  401. leaving stl $1 loi $3
  402. pat sdl ldl $1==$2 leaving dup 4 sdl $1
  403. #ifdef REGVARS
  404. pat lol dup stl $2==2 && inreg($1) <= 0 && inreg($3) > 0
  405. kills regvar($3)
  406. gen move {LOCAL,$1,2}, {LOCAL,$3,2}
  407. yields {LOCAL,$3,2}
  408. #endif
  409. pat loe yields {EXTERN2,$1}
  410. pat ste loe $1==$2 leaving dup 2 ste $1
  411. pat ste loe lof $1==$2
  412. with AREG yields %1 %1
  413. leaving ste $1 lof $3
  414. pat ste loe loi $1==$2
  415. with AREG yields %1 %1
  416. leaving ste $1 loi $3
  417. pat sde lde $1==$2 leaving dup 4 sde $1
  418. #ifdef REGVARS
  419. pat loe dup stl $2==2 && inreg($3) > 0
  420. kills regvar($3)
  421. gen move {EXTERN2,$1}, {LOCAL,$3,2}
  422. yields {LOCAL,$3,2}
  423. #endif
  424. #ifdef REGVARS
  425. pat lil inreg($1) > 0 yields {ind_reg2, regvar($1)}
  426. #endif
  427. pat lil
  428. uses ADDREG={LOCAL,$1,2} yields {ind_reg2,%a}
  429. pat lil dup stl $2==2 leaving lil $1 stl $3 lol $3
  430. pat sil lil $1==$2 leaving dup 2 sil $1
  431. pat lof
  432. with exact reg_off yields {ind_regoff2,%1.reg,%1.off+$1}
  433. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+$1}
  434. with exact ADDR_EXTERN yields {EXTERN2,%1.off+$1}
  435. with exact ADDR_LOCAL yields {LOCAL,%1.ind + $1,2}
  436. with addreg yields {ind_regoff2,%1,$1}
  437. pat lal yields {ADDR_LOCAL,$1}
  438. pat lae yields {ADDR_EXTERN,$1}
  439. pat lpb leaving adp SL
  440. pat lxl $1==0 yields {ADDR_LOCAL,0}
  441. pat lxl $1==1 yields {LOCAL,SL,2}
  442. pat lxl $1==2
  443. uses ADDREG={LOCAL,SL,2} yields {ind_regoff2,%a,SSL}
  444. pat lxl $1>2
  445. uses ADDREG={LOCAL,SL,2},
  446. CXREG={ANYCON,$1-1}
  447. gen 1:
  448. mov %a,{ind_regoff2,%a,4}
  449. loop {label,1b} yields %a
  450. pat lxa $1==0 yields {ADDR_LOCAL,SL}
  451. pat lxa $1==1
  452. uses ADDREG={LOCAL,SL,2} yields {Xreg_off,%a,SSL}
  453. pat lxa $1==2
  454. uses ADDREG={LOCAL,SL,2}
  455. gen move {ind_regoff2,%a,SSL},%a yields {Xreg_off,%a,SSL}
  456. pat lxa $1>2
  457. uses ADDREG={LOCAL,SL,2},
  458. CXREG={ANYCON,$1-1}
  459. gen 1:
  460. mov %a,{ind_regoff2,%a,4}
  461. loop {label,1b} yields {Xreg_off,%a,SSL}
  462. pat dch leaving loi 2
  463. pat loi $1==2
  464. with addreg yields {ind_reg2,%1}
  465. with exact reg_off yields {ind_regoff2,%1.reg,%1.off}
  466. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind}
  467. with exact ADDR_EXTERN yields {EXTERN2,%1.off}
  468. with exact ADDR_LOCAL yields {LOCAL,%1.ind,2}
  469. pat loi $1==1
  470. with addreg yields {ind_reg1,%1}
  471. with exact reg_off yields {ind_regoff1,%1.reg,%1.off}
  472. with exact bpreg_off yields {ind_bpregoff1,%1.reg,%1.ind}
  473. with exact ADDR_EXTERN yields {EXTERN1,%1.off}
  474. with exact ADDR_LOCAL yields {LOCAL1,%1.ind,1}
  475. pat loi $1==4
  476. with addreg yields {ind_regoff2,%1,2}
  477. {ind_reg2,%1}
  478. with exact reg_off yields {ind_regoff2,%1.reg,%1.off+2}
  479. {ind_regoff2,%1.reg,%1.off}
  480. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+2}
  481. {ind_bpregoff2,%1.reg,%1.ind}
  482. with exact ADDR_LOCAL yields {LOCAL,%1.ind+2,2}
  483. {LOCAL,%1.ind,2}
  484. with exact ADDR_EXTERN yields {EXTERN2,%1.off + 2}
  485. {EXTERN2,%1.off}
  486. pat loi $1>4
  487. with BXREG
  488. kills ALL
  489. gen mov cx,{ANYCON,$1}
  490. joehoe {label,".loi"}
  491. pat los $1==2
  492. with CXREG BXREG
  493. kills ALL
  494. gen joehoe {label,".los"}
  495. pat ldl yields {LOCAL,$1+2,2}
  496. {LOCAL,$1,2}
  497. pat lde yields {EXTERN2,$1 + 2}
  498. {EXTERN2,$1}
  499. pat ldf
  500. with exact reg_off yields {ind_regoff2,%1.reg,
  501. %1.off + 2 + $1}
  502. {ind_regoff2,%1.reg,
  503. %1.off + $1}
  504. with addreg yields {ind_regoff2,%1,$1+2}
  505. {ind_regoff2,%1,$1}
  506. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+2+$1}
  507. {ind_bpregoff2,%1.reg,%1.ind+$1}
  508. with exact ADDR_EXTERN yields {EXTERN2,%1.off+2+$1}
  509. {EXTERN2,%1.off+$1}
  510. with exact ADDR_LOCAL yields {LOCAL,%1.ind + $1 + 2,2}
  511. {LOCAL,%1.ind + $1,2}
  512. pat lpi yields {ADDR_EXTERN,$1}
  513. /* this code sequence is generated by the C-compiler to tackle
  514. char parameters, on the 8086 it reduces to nil */
  515. pat lol lal sti $1==$2 && $3<=2
  516. /*******************************************************************
  517. * Group 2 : Store Instructions *
  518. *******************************************************************/
  519. #ifdef REGVARS
  520. pat stl inreg($1)==reg_any
  521. with rmorconst
  522. kills regvar($1)
  523. gen move %1, {LOCAL,$1,2}
  524. with halfindir
  525. kills regvar($1)
  526. gen move %1, {LOCAL,$1,2}
  527. with exact STACK
  528. kills regvar($1)
  529. gen pop {LOCAL, $1, 2}
  530. #endif
  531. pat stl
  532. with regorconst
  533. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  534. gen move %1,{LOCAL,$1,2}
  535. with exact STACK
  536. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  537. gen pop {LOCAL,$1,2}
  538. pat ste
  539. with regorconst
  540. kills indirects
  541. gen move %1,{EXTERN2,$1}
  542. with exact STACK
  543. kills indirects
  544. gen pop {EXTERN2,$1}
  545. #ifdef REGVARS
  546. pat sil inreg($1)==reg_any
  547. with regorconst
  548. kills referals
  549. gen move %1,{ind_reg2,regvar($1)}
  550. with exact STACK
  551. kills referals
  552. gen pop {ind_reg2,regvar($1)}
  553. #endif
  554. pat sil
  555. with regorconstnoaddr
  556. kills referals
  557. uses ADDREG={LOCAL,$1,2}
  558. gen move %1,{ind_reg2,%a}
  559. killreg %a
  560. with exact STACK
  561. kills referals
  562. uses ADDREG={LOCAL,$1,2}
  563. gen pop {ind_reg2,%a}
  564. killreg %a
  565. pat stf
  566. with addreg regorconst
  567. kills referals
  568. gen move %2,{ind_regoff2,%1,$1}
  569. with exact addreg STACK
  570. kills referals
  571. gen pop {ind_regoff2, %1,$1}
  572. with reg_off regorconst
  573. kills referals
  574. gen move %2,{ind_regoff2,%1.reg,%1.off+$1}
  575. with exact reg_off STACK
  576. kills referals
  577. gen pop {ind_regoff2,%1.reg,$1+%1.off}
  578. with exact bpreg_off STACK
  579. kills all_locals, indexed
  580. gen pop {ind_bpregoff2,%1.reg,$1+%1.ind}
  581. with ADDR_LOCAL regorconst
  582. kills indexed,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+2
  583. gen move %2,{LOCAL,%1.ind+$1,2}
  584. with exact ADDR_LOCAL STACK
  585. kills indexed,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+2
  586. gen pop {LOCAL,%1.ind+$1,2}
  587. with bpreg_off regorconst
  588. kills all_locals,indexed
  589. gen move %2,{ind_bpregoff2,%1.reg,%1.ind+$1}
  590. with ADDR_EXTERN regorconst
  591. kills indirects
  592. gen move %2,{EXTERN2,%1.off+$1}
  593. with exact ADDR_EXTERN STACK
  594. kills indirects
  595. gen pop {EXTERN2,%1.off+$1}
  596. pat sti $1==2
  597. with addreg regorconst
  598. kills referals
  599. gen move %2,{ind_reg2,%1}
  600. with exact addreg STACK
  601. kills referals
  602. gen pop {ind_reg2,%1}
  603. with reg_off regorconst
  604. kills referals
  605. gen move %2,{ind_regoff2,%1.reg,%1.off}
  606. with exact reg_off STACK
  607. kills referals
  608. gen pop {ind_regoff2,%1.reg,%1.off}
  609. with bpreg_off regorconst
  610. kills all_locals,indexed
  611. gen move %2,{ind_bpregoff2,%1.reg,%1.ind}
  612. with exact bpreg_off STACK
  613. kills all_locals,indexed
  614. gen pop {ind_bpregoff2,%1.reg,%1.ind}
  615. with ADDR_EXTERN regorconst
  616. kills indirects
  617. gen move %2,{EXTERN2,%1.off}
  618. with exact ADDR_EXTERN STACK
  619. kills indirects
  620. gen pop {EXTERN2,%1.off}
  621. with ADDR_LOCAL regorconst
  622. kills indexed,locals %ind+%size > %1.ind && %ind < %1.ind+2
  623. gen move %2,{LOCAL,%1.ind,2}
  624. with exact ADDR_LOCAL STACK
  625. kills indexed,locals %ind+%size > %1.ind && %ind < %1.ind+2
  626. gen pop {LOCAL,%1.ind,2}
  627. pat sti $1==1
  628. with addreg regorconst12
  629. kills referals
  630. gen move %2,{ind_reg1,%1}
  631. with reg_off regorconst12
  632. kills referals
  633. gen move %2,{ind_regoff1,%1.reg,%1.off}
  634. with bpreg_off regorconst12
  635. kills all_locals,indexed
  636. gen move %2,{ind_bpregoff1,%1.reg,%1.ind}
  637. with ADDR_EXTERN regorconst12
  638. kills indirects
  639. gen move %2,{EXTERN1,%1.off}
  640. with ADDR_LOCAL regorconst12
  641. kills indexed,locals %ind+%size > %1.ind && %ind <= %1.ind
  642. gen move %2,{LOCAL1,%1.ind,1}
  643. pat sti $1==4 leaving sdf 0
  644. pat sti $1>4
  645. with BXREG
  646. kills ALL
  647. gen mov cx,{ANYCON,$1}
  648. joehoe {label, ".sti"}
  649. /* this sort of construction gives problems in the codegenerator
  650. because of the potential very large lookahead
  651. with addreg
  652. kills ALL
  653. gen pop (%1)
  654. add %1,{ANYCON,2} yields %1 leaving sti $1-2
  655. */
  656. pat sts $1==2
  657. with CXREG BXREG
  658. kills ALL
  659. gen joehoe {label,".sts"}
  660. pat sdl
  661. with regorconst regorconst yields %2 %1
  662. leaving stl $1 stl $1+2
  663. with exact STACK leaving stl $1 stl $1+2
  664. pat sde
  665. with regorconst regorconst yields %2 %1
  666. leaving ste $1 ste $1+2
  667. with exact STACK leaving ste $1 ste $1+2
  668. pat sdf
  669. with addreg regorconst regorconst
  670. kills referals
  671. gen move %2,{ind_regoff2,%1,$1}
  672. move %3,{ind_regoff2,%1,$1+2}
  673. with exact addreg STACK
  674. kills referals
  675. gen pop {ind_regoff2,%1,$1}
  676. pop {ind_regoff2,%1,$1+2}
  677. with exact halfindir STACK
  678. kills referals
  679. uses reusing %1,ADDREG=%1
  680. gen pop {ind_regoff2,%a,$1}
  681. pop {ind_regoff2,%a,$1+2}
  682. with exact memory2 STACK
  683. kills referals
  684. uses reusing %1,ADDREG=%1
  685. gen pop {ind_regoff2,%a,$1}
  686. pop {ind_regoff2,%a,$1+2}
  687. with reg_off regorconst regorconst
  688. kills referals
  689. gen move %2,{ind_regoff2,%1.reg,%1.off+$1}
  690. move %3,{ind_regoff2,%1.reg,%1.off+$1+2}
  691. with exact reg_off STACK
  692. kills referals
  693. gen pop {ind_regoff2,%1.reg,$1+%1.off}
  694. pop {ind_regoff2,%1.reg,$1+2+%1.off}
  695. with exact bpreg_off STACK
  696. kills all_locals,indexed
  697. gen pop {ind_bpregoff2, %1.reg,$1+%1.ind}
  698. pop {ind_bpregoff2, %1.reg,$1+2+%1.ind}
  699. with ADDR_LOCAL regorconst regorconst
  700. kills indexed,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+4
  701. gen move %2,{LOCAL,%1.ind+$1,2}
  702. move %3,{LOCAL,%1.ind+$1+2,2}
  703. with exact ADDR_LOCAL STACK
  704. kills indexed,locals %ind+%size > %1.ind+$1 && %ind < %1.ind+$1+4
  705. gen pop {LOCAL,%1.ind+$1,2}
  706. pop {LOCAL,%1.ind+$1+2,2}
  707. with ADDR_EXTERN regorconst regorconst
  708. kills indirects
  709. gen move %2,{EXTERN2,%1.off+$1}
  710. move %3,{EXTERN2,%1.off+$1+2}
  711. with exact ADDR_EXTERN STACK
  712. kills indirects
  713. gen pop {EXTERN2,%1.off+$1}
  714. pop {EXTERN2,%1.off+$1+2}
  715. with bpreg_off regorconst regorconst
  716. kills all_locals,indexed
  717. gen move %2,{ind_bpregoff2,%1.reg,%1.ind+$1}
  718. move %3,{ind_bpregoff2,%1.reg,%1.ind+$1+2}
  719. /****************************************************************
  720. * Group 3 : Integer Arithmetic. *
  721. * *
  722. * Implemented (sometimes with the use of subroutines) : *
  723. * all 2 and 4 byte arithmetic. *
  724. ****************************************************************/
  725. pat adi $1==2
  726. #ifdef REGVARS
  727. with exact ANYCON IREG
  728. yields {Rreg_off,%2,%1.val}
  729. with exact IREG ANYCON
  730. yields {Rreg_off,%1,%2.val}
  731. #endif
  732. with REG rmorconst
  733. gen add %1,%2 yields %1
  734. with rmorconst REG
  735. gen add %2,%1 yields %2
  736. with EXACT rmorconst const
  737. uses reusing %1,REG=%1
  738. gen add %a,%2 yields %a
  739. pat adi $1==4
  740. with EXACT REG REG rmorconst rmorconst
  741. gen add %1,%3
  742. adc %2,%4 yields %2 %1
  743. with rmorconst rmorconst REG REG
  744. gen add %3,%1
  745. adc %4,%2 yields %4 %3
  746. pat adi !defined($1)
  747. with CXREG ACC
  748. kills ALL
  749. gen joehoe {label,".adi"} yields ax
  750. pat sbi $1==2
  751. with rmorconst REG
  752. gen sub %2,%1 yields %2
  753. with EXACT REG rmorconst
  754. gen sub %1,%2
  755. neg %1 yields %1
  756. pat sbi $1==4
  757. with rmorconst rmorconst REG REG
  758. gen sub %3,%1
  759. sbb %4,%2 yields %4 %3
  760. pat sbi !defined($1)
  761. with CXREG ACC
  762. kills ALL
  763. gen joehoe {label,".sbi"} yields ax
  764. pat mli $1==2
  765. with ACC rm
  766. uses reusing %2,DXREG
  767. gen mul %2 yields %1
  768. /* mul and imul have same low order result
  769. but mul is faster
  770. */
  771. with rmnoacc rmorconst
  772. uses reusing %2,DXREG,ACC=%2
  773. gen mul %1 yields %b
  774. pat mli $1==4
  775. with ACC DXREG
  776. kills ALL
  777. gen joehoe {label,".mli4"} yields dx ax
  778. /*
  779. pat mli !defined($1)
  780. with ACC
  781. kills ALL
  782. gen joehoe {label,".mli"}
  783. */
  784. pat dvi $1==2
  785. with rmnoacc rmorconst
  786. uses reusing %2,DXREG,ACC=%2
  787. gen cwd.
  788. idiv %1 yields ax
  789. pat dvi $1==4
  790. kills ALL
  791. gen joehoe {label,".dvi4"} yields dx ax
  792. /*
  793. pat dvi !defined($1)
  794. with ACC
  795. kills ALL
  796. gen joehoe {label,".dvi"}
  797. */
  798. pat rmi $1==2
  799. with rmnoacc rmorconst
  800. uses reusing %2, ACC=%2, DXREG
  801. gen cwd.
  802. idiv %1 yields dx
  803. pat rmi $1==4
  804. kills ALL
  805. gen joehoe {label,".rmi4"} yields dx ax
  806. /*
  807. pat rmi !defined($1)
  808. with ACC
  809. kills ALL
  810. gen joehoe {label,".rmi"}
  811. */
  812. pat ngi $1==2
  813. with REG
  814. gen neg %1 yields %1
  815. pat ngi $1==4
  816. with REG REG
  817. gen neg %2
  818. neg %1
  819. sbb %2,{ANYCON,0} yields %2 %1
  820. /*
  821. pat ngi !defined($1)
  822. with ACC
  823. kills ALL
  824. gen joehoe {label,".ngi"}
  825. */
  826. pat loc sli $1==1 && $2==2
  827. with REG
  828. gen sal %1,{ANYCON,1} yields %1
  829. pat loc sli $1==1 && $2==4
  830. with REG REG
  831. gen sal %1,{ANYCON,1}
  832. rcl %2,{ANYCON,1} yields %2 %1
  833. pat loc sli $1==2 && $2==4
  834. with REG REG
  835. gen sal %1,{ANYCON,1}
  836. rcl %2,{ANYCON,1}
  837. sal %1,{ANYCON,1}
  838. rcl %2,{ANYCON,1} yields %2 %1
  839. pat loc sli $1==3 && $2==4
  840. with REG REG
  841. gen sal %1,{ANYCON,1}
  842. rcl %2,{ANYCON,1}
  843. sal %1,{ANYCON,1}
  844. rcl %2,{ANYCON,1}
  845. sal %1,{ANYCON,1}
  846. rcl %2,{ANYCON,1} yields %2 %1
  847. pat loc sli $1==16 && $2==4
  848. with rmorconst rmorconst yields %1 {ANYCON,0}
  849. pat sli $1==2
  850. with SHIFT_CREG REG
  851. gen sal %2,cl yields %2
  852. pat sli $1==4
  853. with CXREG REG REG
  854. gen jcxz {label,1f}
  855. 2:
  856. sal %2,{ANYCON,1}
  857. rcl %3,{ANYCON,1}
  858. loop {label,2b}
  859. 1:
  860. yields %3 %2
  861. /*
  862. pat sli !defined($1)
  863. with ACC
  864. kills ALL
  865. gen joehoe {label,".sli"}
  866. */
  867. pat loc sri $1==1 && $2==2
  868. with REG
  869. gen sar %1,{ANYCON,1} yields %1
  870. pat loc sri $1==1 && $2==4
  871. with REG REG
  872. gen sar %2,{ANYCON,1}
  873. rcr %1,{ANYCON,1} yields %2 %1
  874. pat loc sri $1==2 && $2==4
  875. with REG REG
  876. gen sar %2,{ANYCON,1}
  877. rcr %1,{ANYCON,1}
  878. sar %2,{ANYCON,1}
  879. rcr %1,{ANYCON,1} yields %2 %1
  880. pat loc sri $1==3 && $2==4
  881. with REG REG
  882. gen sar %2,{ANYCON,1}
  883. rcr %1,{ANYCON,1}
  884. sar %2,{ANYCON,1}
  885. rcr %1,{ANYCON,1}
  886. sar %2,{ANYCON,1}
  887. rcr %1,{ANYCON,1} yields %2 %1
  888. pat sri $1==2
  889. with SHIFT_CREG REG
  890. gen sar %2,cl yields %2
  891. pat sri $1==4
  892. with CXREG REG REG
  893. gen jcxz {label,1f}
  894. 2:
  895. sar %3,{ANYCON,1}
  896. rcr %2,{ANYCON,1}
  897. loop {label,2b}
  898. 1:
  899. yields %3 %2
  900. /*
  901. pat sri !defined($1)
  902. with ACC
  903. kills ALL
  904. gen joehoe {label,".sri"}
  905. */
  906. /*******************************************************************
  907. * Group 4: Unsigned Arithmetic *
  908. *******************************************************************/
  909. pat adu leaving adi $1
  910. pat loc lol adu stl $1==1 && $3==2 && $2==$4 leaving inl $2
  911. pat loc loe adu ste $1==1 && $3==2 && $2==$4 leaving ine $2
  912. pat loc lol adu $1==1 && $3==2 leaving lol $2 inc
  913. pat loc loe adu $1==1 && $3==2 leaving loe $2 inc
  914. pat loc lil adu $1==1 && $3==2 leaving lil $2 inc
  915. pat loc lol adu stl $1==0-1 && $3==2 && $2==$4 leaving del $2
  916. pat loc loe adu ste $1==0-1 && $3==2 && $2==$4 leaving dee $2
  917. pat loc lol adu $1==0-1 && $3==2 leaving lol $2 dec
  918. pat loc loe adu $1==0-1 && $3==2 leaving loe $2 dec
  919. pat loc lil adu $1==0-1 && $3==2 leaving lil $2 dec
  920. pat sbu leaving sbi $1
  921. pat lol loc sbu stl $1==$4 && $2==1 && $3==2 leaving del $1
  922. pat loe loc sbu ste $1==$4 && $2==1 && $3==2 leaving dee $1
  923. pat lol loc sbu $2==1 && $3==2 leaving lol $1 dec
  924. pat loe loc sbu $2==1 && $3==2 leaving loe $1 dec
  925. pat lil loc sbu $2==1 && $3==2 leaving lil $1 dec
  926. pat lol loc sbu stl $1==$4 && $2==0-1 && $3==2 leaving inl $1
  927. pat loe loc sbu ste $1==$4 && $2==0-1 && $3==2 leaving ine $1
  928. pat lol loc sbu $2==0-1 && $3==2 leaving lol $1 inc
  929. pat loe loc sbu $2==0-1 && $3==2 leaving loe $1 inc
  930. pat lil loc sbu $2==0-1 && $3==2 leaving lil $1 inc
  931. pat mlu leaving mli $1
  932. pat loe loc loe adu ste $1==$3 && $1==$5 && $4==2
  933. uses REG = {EXTERN2, $1}
  934. yields %a leaving loc $2 loe $3 adu 2 ste $3
  935. pat lol loc lol adu stl $1==$3 && $1==$5 && $4==2
  936. uses REG = {LOCAL, $1, 2}
  937. yields %a leaving loc $2 lol $3 adu 2 stl $3
  938. pat loe loc loe adi ste $1==$3 && $1==$5 && $4==2
  939. uses REG = {EXTERN2, $1}
  940. yields %a leaving loc $2 loe $3 adi 2 ste $3
  941. pat lol loc lol adi stl $1==$3 && $1==$5 && $4==2
  942. uses REG = {LOCAL, $1, 2}
  943. yields %a leaving loc $2 lol $3 adi 2 stl $3
  944. pat dvu $1==2
  945. with rmnoacc rmorconst
  946. uses reusing %2, ACC=%2, DXREG={ANYCON,0}
  947. gen div %1 yields ax
  948. pat dvu $1==4
  949. kills ALL
  950. gen joehoe {label,".dvu4"} yields dx ax
  951. /*
  952. pat dvu !defined($1)
  953. with ACC STACK
  954. kills ALL
  955. gen joehoe {label,".dvu"}
  956. */
  957. pat rmu $1==2
  958. with rmnoacc rmorconst
  959. uses reusing %2, ACC=%2, DXREG={ANYCON,0}
  960. gen div %1 yields dx
  961. pat rmu $1==4
  962. kills ALL
  963. gen joehoe {label,".rmu4"} yields dx ax
  964. /*
  965. pat rmu !defined($1)
  966. with ACC STACK
  967. kills ALL
  968. gen joehoe {label,".rmu"}
  969. */
  970. pat slu leaving sli $1
  971. pat loc slu leaving loc $1 sli $2
  972. pat loc sru $1==1 && $2==2
  973. with REG
  974. gen shr %1,{ANYCON, 1} yields %1
  975. pat loc sru $1==16 && $2==4
  976. with rmorconst rmorconst yields {ANYCON,0} %2
  977. pat sru $1==2
  978. with SHIFT_CREG REG
  979. gen shr %2,cl yields %2
  980. pat sru $1==4
  981. with CXREG REG REG
  982. gen jcxz {label,1f}
  983. 2:
  984. shr %3,{ANYCON, 1}
  985. rcr %2,{ANYCON, 1}
  986. loop {label,2b}
  987. 1: yields %3 %2
  988. /*
  989. pat sru !defined($1)
  990. with ACC STACK
  991. kills ALL
  992. gen joehoe {label,".sru"}
  993. */
  994. /*******************************************************************
  995. * Group 5: Floating Point Instructions *
  996. *******************************************************************/
  997. pat adf $1==4 leaving cal ".adf4" asp 4
  998. pat adf $1==8 leaving cal ".adf8" asp 8
  999. pat sbf $1==4 leaving cal ".sbf4" asp 4
  1000. pat sbf $1==8 leaving cal ".sbf8" asp 8
  1001. pat mlf $1==4 leaving cal ".mlf4" asp 4
  1002. pat mlf $1==8 leaving cal ".mlf8" asp 8
  1003. pat dvf $1==4 leaving cal ".dvf4" asp 4
  1004. pat dvf $1==8 leaving cal ".dvf8" asp 8
  1005. pat ngf $1==4 leaving cal ".ngf4"
  1006. pat ngf $1==8 leaving cal ".ngf8"
  1007. pat fif $1==4 leaving lor 1 cal ".fif4" asp 2
  1008. pat fif $1==8 leaving lor 1 cal ".fif8" asp 2
  1009. pat fef $1==4 leaving lor 1 adp 0-2 cal ".fef4"
  1010. pat fef $1==8 leaving lor 1 adp 0-2 cal ".fef8"
  1011. /******************************************************************
  1012. * Group 6: Pointer Arithmetic *
  1013. ******************************************************************/
  1014. pat adp $1==1
  1015. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  1016. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  1017. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  1018. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  1019. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  1020. with REG
  1021. gen inc %1 yields %1
  1022. with ADDREG
  1023. gen killreg %1
  1024. yields {Xreg_off, %1, $1}
  1025. with exact RADDREG yields {Rreg_off, %1, $1}
  1026. pat adp $1==0-1
  1027. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  1028. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  1029. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  1030. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  1031. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  1032. with REG
  1033. gen dec %1 yields %1
  1034. with ADDREG
  1035. gen killreg %1
  1036. yields {Xreg_off, %1, $1}
  1037. with exact RADDREG yields {Rreg_off, %1, $1}
  1038. pat adp
  1039. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  1040. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  1041. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  1042. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  1043. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  1044. with ADDREG
  1045. gen killreg %1
  1046. yields {Xreg_off,%1,$1}
  1047. with exact RADDREG yields {Rreg_off, %1, $1}
  1048. with REG
  1049. gen add %1,{ANYCON,$1} yields %1
  1050. pat ads stl $1==2 leaving adi 2 stl $2
  1051. pat ads ste $1==2 leaving adi 2 ste $2
  1052. pat ads sil $1==2 leaving adi 2 sil $2
  1053. pat ads lol stf $1==2 leaving adi 2 lol $2 stf $3
  1054. pat ads loe stf $1==2 leaving adi 2 loe $2 stf $3
  1055. pat ads $1==2
  1056. with exact ANYCON Rreg_off
  1057. yields {Rreg_off,%2.reg,%2.off+%1.val}
  1058. with exact ANYCON Xreg_off
  1059. yields {Xreg_off,%2.reg,%2.off+%1.val}
  1060. with exact ADDR_EXTERN Rreg_off
  1061. yields {Rreg_off,%2.reg,%2.off+%1.off}
  1062. with exact ADDR_EXTERN Xreg_off
  1063. yields {Xreg_off,%2.reg,%2.off+%1.off}
  1064. with rmorconst Xreg_off
  1065. gen add %2.reg,%1 yields %2
  1066. with exact ANYCON Rbpreg_off
  1067. yields {Rbpreg_off,%2.reg,%2.ind+%1.val}
  1068. with Xreg_off rmorconst
  1069. gen add %1.reg,%2 yields %1
  1070. with exact Xreg_off ANYCON
  1071. yields {Xreg_off,%1.reg,%1.off+%2.val}
  1072. with exact Rreg_off ANYCON
  1073. yields {Rreg_off,%1.reg,%1.off+%2.val}
  1074. with exact Xreg_off ADDR_EXTERN
  1075. yields {Xreg_off,%1.reg,%1.off+%2.off}
  1076. with exact Rreg_off ADDR_EXTERN
  1077. yields {Rreg_off,%1.reg,%1.off+%2.off}
  1078. with exact Xreg_off reg_off
  1079. gen add %1.reg,%2.reg
  1080. yields {Xreg_off,%1.reg,%1.off+%2.off}
  1081. with exact IREG ADDR_LOCAL
  1082. yields {Rbpreg_off, %1, %2.ind}
  1083. with exact IREG ADDR_EXTERN
  1084. yields {Rreg_off, %1, %2.off}
  1085. with exact ADDR_EXTERN IREG
  1086. yields {Rreg_off,%2,%1.off}
  1087. with exact ADDR_LOCAL IREG
  1088. yields {Rbpreg_off,%2,%1.ind}
  1089. with exact rmorconst ADDR_EXTERN
  1090. uses reusing %1,ADDREG=%1
  1091. yields {Xreg_off,%a,%2.off}
  1092. with exact ADDR_EXTERN rmorconst
  1093. uses reusing %2,ADDREG=%2
  1094. yields {Xreg_off,%a,%1.off}
  1095. with rmorconst ADDREG
  1096. gen add %2,%1 yields %2
  1097. with ADDREG rmorconst
  1098. gen add %1,%2 yields %1
  1099. pat sbs $1==2
  1100. with exact ANYCON Xreg_off
  1101. yields {Xreg_off,%2.reg,%2.off+"-"+%1.val}
  1102. with exact ANYCON Rreg_off
  1103. yields {Rreg_off,%2.reg,%2.off+"-"+%1.val}
  1104. with exact ANYCON ADDR_LOCAL
  1105. yields {ADDR_LOCAL,%2.ind-%1.val}
  1106. with rm Xreg_off
  1107. gen sub %2.reg,%1 yields {Xreg_off,%2.reg,%2.off}
  1108. /* Should not occur
  1109. with exact reg_off ANYCON
  1110. yields {reg_off,%1.reg,%1.off-%2.val}
  1111. with ANYCON ADDR_EXTERN
  1112. yields {ADDR_EXTERN,%2.off+%1.val}
  1113. with exact ANYCON ADDR_LOCAL
  1114. yields {ADDR_LOCAL,%1.val+%2.ind}
  1115. */
  1116. with rm REG
  1117. gen sub %2,%1 yields %2
  1118. with const ACC
  1119. gen sub %2,%1 yields %2
  1120. /*******************************************************************
  1121. * Group 7 : Increment/Decrement Zero *
  1122. *******************************************************************/
  1123. pat inc
  1124. with REG
  1125. gen inc %1 yields %1
  1126. #ifdef REGVARS
  1127. pat inl inreg($1)==reg_any
  1128. kills regvar($1)
  1129. gen inc {LOCAL,$1,2}
  1130. #endif
  1131. pat inl
  1132. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1133. gen inc {LOCAL, $1, 2}
  1134. pat ine
  1135. kills indirects
  1136. gen inc {EXTERN2, $1}
  1137. pat dec
  1138. with REG
  1139. gen dec %1 yields %1
  1140. #ifdef REGVARS
  1141. pat del inreg($1)==reg_any
  1142. kills regvar($1)
  1143. gen dec {LOCAL,$1,2}
  1144. #endif
  1145. pat del
  1146. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1147. gen dec {LOCAL, $1, 2}
  1148. pat dee
  1149. kills indirects
  1150. gen dec {EXTERN2, $1}
  1151. pat zrl yields {ANYCON, 0} leaving stl $1
  1152. pat zre yields {ANYCON, 0} leaving ste $1
  1153. pat zrf leaving zer $1
  1154. pat zer $1==2 yields {ANYCON, 0}
  1155. pat zer $1==4 yields {ANYCON, 0} {ANYCON, 0}
  1156. pat zer $1==6 yields {ANYCON, 0} {ANYCON, 0}
  1157. {ANYCON, 0}
  1158. pat zer $1==8 yields {ANYCON, 0} {ANYCON, 0}
  1159. {ANYCON, 0} {ANYCON, 0}
  1160. pat zer defined($1)
  1161. with STACK
  1162. gen move {ANYCON, $1/2}, cx
  1163. move {ANYCON, 0}, bx
  1164. 1:
  1165. push bx
  1166. loop {label,1b}
  1167. pat zer !defined($1)
  1168. with CXREG STACK
  1169. gen move {ANYCON, 0}, bx
  1170. sar cx,{ANYCON, 1}
  1171. 1:
  1172. push bx
  1173. loop {label,1b}
  1174. #ifdef REGVARS
  1175. proc lolrxxxstl example lol adi stl
  1176. with rmorconst
  1177. kills regvar($1)
  1178. gen axx* {LOCAL, $1, 2}, %1
  1179. proc lilrxxxsil example lil adi sil
  1180. with regorconst
  1181. kills referals
  1182. gen axx* {ind_reg2, regvar($1)}, %1
  1183. pat lol adi stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("add")
  1184. pat lol adu stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("add")
  1185. pat lol ads stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("add")
  1186. pat lol and stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("and")
  1187. pat lol ior stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("or")
  1188. pat lol xor stl $1==$3 && $2==2 && inreg($1)==reg_any call lolrxxxstl("xor")
  1189. pat lil adi sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("add")
  1190. pat lil adu sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("add")
  1191. pat lil ads sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("add")
  1192. pat lil and sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("and")
  1193. pat lil ior sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("or")
  1194. pat lil xor sil $1==$3 && $2==2 && inreg($1)==reg_any call lilrxxxsil("xor")
  1195. #endif
  1196. proc lolxxxstl example lol adi stl
  1197. with regorconst
  1198. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1199. gen axx* {LOCAL, $1, 2}, %1
  1200. pat lol adi stl $1==$3 && $2==2 call lolxxxstl("add")
  1201. pat lol adu stl $1==$3 && $2==2 call lolxxxstl("add")
  1202. pat lol ads stl $1==$3 && $2==2 call lolxxxstl("add")
  1203. pat lol and stl $1==$3 && $2==2 call lolxxxstl("and")
  1204. pat lol ior stl $1==$3 && $2==2 call lolxxxstl("or")
  1205. pat lol xor stl $1==$3 && $2==2 call lolxxxstl("xor")
  1206. proc lilxxxsil example lil adi sil
  1207. with regorconst
  1208. kills referals
  1209. uses ADDREG={LOCAL, $1, 2}
  1210. gen axx* {ind_reg2, %a}, %1
  1211. killreg %a
  1212. pat lil adi sil $1==$3 && $2==2 call lilxxxsil("add")
  1213. pat lil adu sil $1==$3 && $2==2 call lilxxxsil("add")
  1214. pat lil ads sil $1==$3 && $2==2 call lilxxxsil("add")
  1215. pat lil and sil $1==$3 && $2==2 call lilxxxsil("and")
  1216. pat lil ior sil $1==$3 && $2==2 call lilxxxsil("or")
  1217. pat lil xor sil $1==$3 && $2==2 call lilxxxsil("xor")
  1218. #ifdef REGVARS
  1219. proc lilruxxsil example lil ngi sil
  1220. kills referals
  1221. gen uxx* {ind_reg2, regvar($1)}
  1222. pat lil ngi sil $1==$3 && $2==2 && inreg($1)==reg_any call lilruxxsil("neg")
  1223. pat lil com sil $1==$3 && $2==2 && inreg($1)==reg_any call lilruxxsil("not")
  1224. pat lil dec sil $1==$3 && inreg($1)==reg_any call lilruxxsil("dec")
  1225. pat lil inc sil $1==$3 && inreg($1)==reg_any call lilruxxsil("inc")
  1226. #endif
  1227. proc liluxxsil example lil ngi sil
  1228. kills referals
  1229. uses ADDREG={LOCAL, $1, 2}
  1230. gen uxx* {ind_reg2, %a}
  1231. killreg %a
  1232. pat lil ngi sil $1==$3 && $2==2 call liluxxsil("neg")
  1233. pat lil com sil $1==$3 && $2==2 call liluxxsil("not")
  1234. pat lil dec sil $1==$3 call liluxxsil("dec")
  1235. pat lil inc sil $1==$3 call liluxxsil("inc")
  1236. proc loexxxste example loe adi ste
  1237. with regorconst
  1238. kills indirects
  1239. gen axx* {EXTERN2, $1}, %1
  1240. pat loe adi ste $1==$3 && $2==2 call loexxxste("add")
  1241. pat loe adu ste $1==$3 && $2==2 call loexxxste("add")
  1242. pat loe ads ste $1==$3 && $2==2 call loexxxste("add")
  1243. pat loe and ste $1==$3 && $2==2 call loexxxste("and")
  1244. pat loe ior ste $1==$3 && $2==2 call loexxxste("or")
  1245. pat loe xor ste $1==$3 && $2==2 call loexxxste("xor")
  1246. proc ldlxxxsdl example ldl adi sdl
  1247. with regorconst regorconst
  1248. kills indexed,locals %ind+%size > $1 && %ind < $1+4
  1249. gen axx[1] {LOCAL,$1,2},%1
  1250. axx[2] {LOCAL,$1+2,2},%2
  1251. pat ldl adi sdl $1==$3 && $2==4 call ldlxxxsdl("add", "adc")
  1252. pat ldl adu sdl $1==$3 && $2==4 call ldlxxxsdl("add", "adc")
  1253. pat ldl and sdl $1==$3 && $2==4 call ldlxxxsdl("and", "and")
  1254. pat ldl ior sdl $1==$3 && $2==4 call ldlxxxsdl("or", "or")
  1255. pat ldl xor sdl $1==$3 && $2==4 call ldlxxxsdl("xor", "xor")
  1256. proc ldlcxxsdl example ldl ldc sbi sdl
  1257. kills indexed,locals %ind+%size > $1 && %ind < $1+4
  1258. gen axx[1] {LOCAL,$1,2},{ANYCON,loww($2)}
  1259. axx[2] {LOCAL,$1+2,2},{ANYCON,highw($2)}
  1260. pat ldl ldc sbi sdl $1==$4 && $3==4 call ldlcxxsdl("sub", "sbb")
  1261. pat ldl ldc sbu sdl $1==$4 && $3==4 call ldlcxxsdl("sub", "sbb")
  1262. proc ldexxxsde example lde adi sde
  1263. with regorconst regorconst
  1264. kills indirects
  1265. gen axx[1] {EXTERN2,$1},%1
  1266. axx[2] {EXTERN2,$1+2},%2
  1267. pat lde adi sde $1==$3 && $2==4 call ldexxxsde("add", "adc")
  1268. pat lde adu sde $1==$3 && $2==4 call ldexxxsde("add", "adc")
  1269. pat lde and sde $1==$3 && $2==4 call ldexxxsde("and", "and")
  1270. pat lde ior sde $1==$3 && $2==4 call ldexxxsde("or", "or")
  1271. pat lde xor sde $1==$3 && $2==4 call ldexxxsde("xor", "xor")
  1272. #ifdef REGVARS
  1273. proc lofrxxxsof example lol lof adi lol stf
  1274. with regorconst
  1275. kills referals
  1276. gen axx* {ind_regoff2, regvar($1), $2}, %1
  1277. pat lol lof adi lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1278. call lofrxxxsof("add")
  1279. pat lol lof adu lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1280. call lofrxxxsof("add")
  1281. pat lol lof ads lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1282. call lofrxxxsof("add")
  1283. pat lol lof and lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1284. call lofrxxxsof("and")
  1285. pat lol lof ior lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1286. call lofrxxxsof("or")
  1287. pat lol lof xor lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1288. call lofrxxxsof("xor")
  1289. proc ldfrxxxsdf example lol ldf adi lol sdf
  1290. with regorconst regorconst
  1291. kills referals
  1292. gen axx[1] {ind_regoff2, regvar($1), $2}, %1
  1293. axx[2] {ind_regoff2, regvar($1), $2+2}, %2
  1294. pat lol ldf adi lol sdf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
  1295. call ldfrxxxsdf("add", "adc")
  1296. pat lol ldf adu lol sdf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
  1297. call ldfrxxxsdf("add", "adc")
  1298. pat lol ldf and lol sdf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
  1299. call ldfrxxxsdf("and", "and")
  1300. pat lol ldf ior lol sdf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
  1301. call ldfrxxxsdf("or", "or")
  1302. pat lol ldf xor lol sdf $1==$4 && $2==$5 && $3==4 && inreg($1)==reg_any
  1303. call ldfrxxxsdf("xor", "xor")
  1304. proc ldirxxxsdi example lol loi adi lol sti
  1305. with regorconst regorconst
  1306. kills referals
  1307. gen axx[1] {ind_reg2, regvar($1)}, %1
  1308. axx[2] {ind_regoff2, regvar($1), 2}, %2
  1309. pat lol loi adi lol sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)==reg_any
  1310. call ldirxxxsdi("add", "adc")
  1311. pat lol loi adu lol sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)==reg_any
  1312. call ldirxxxsdi("add", "adc")
  1313. pat lol loi and lol sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)==reg_any
  1314. call ldirxxxsdi("and", "and")
  1315. pat lol loi ior lol sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)==reg_any
  1316. call ldirxxxsdi("or", "or")
  1317. pat lol loi xor lol sti $1==$4 && $2==4 && $5==4 && $3==4 && inreg($1)==reg_any
  1318. call ldirxxxsdi("xor", "xor")
  1319. proc lofruxxsof example lol lof inc lol stf
  1320. kills referals
  1321. gen uxx* {ind_regoff2, regvar($1), $2}
  1322. pat lol lof inc lol stf $1==$4 && $2==$5 && inreg($1)==reg_any
  1323. call lofruxxsof("inc")
  1324. pat lol lof dec lol stf $1==$4 && $2==$5 && inreg($1)==reg_any
  1325. call lofruxxsof("dec")
  1326. pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1327. call lofruxxsof("neg")
  1328. pat lol lof com lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1329. call lofruxxsof("not")
  1330. #endif
  1331. proc lofuxxsof example lol lof inc lol stf
  1332. kills referals
  1333. uses ADDREG={LOCAL,$1,2}
  1334. gen uxx* {ind_regoff2, %a, $2}
  1335. killreg %a
  1336. pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==2 call lofuxxsof("neg")
  1337. pat lol lof com lol stf $1==$4 && $2==$5 && $3==2 call lofuxxsof("not")
  1338. pat lol lof dec lol stf $1==$4 && $2==$5 call lofuxxsof("dec")
  1339. pat lol lof inc lol stf $1==$4 && $2==$5 call lofuxxsof("inc")
  1340. proc lofxxxsof example lol lof adi lol stf
  1341. with regorconstnoaddr
  1342. kills referals
  1343. uses ADDREG={LOCAL,$1,2}
  1344. gen axx* {ind_regoff2, %a, $2}, %1
  1345. killreg %a
  1346. pat lol lof adi lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("add")
  1347. pat lol lof adu lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("add")
  1348. pat lol lof ads lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("add")
  1349. pat lol lof and lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("and")
  1350. pat lol lof ior lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("or")
  1351. pat lol lof xor lol stf $1==$4 && $2==$5 && $3==2 call lofxxxsof("xor")
  1352. proc ldfxxxsdf example lol ldf adi lol sdf
  1353. with regorconstnoaddr regorconstnoaddr
  1354. kills referals
  1355. uses ADDREG={LOCAL,$1,2}
  1356. gen axx[1] {ind_regoff2, %a, $2}, %1
  1357. axx[2] {ind_regoff2, %a, $2+2}, %2
  1358. killreg %a
  1359. pat lol ldf adi lol sdf $1==$4 && $2==$5 && $3==4 call ldfxxxsdf("add", "adc")
  1360. pat lol ldf adu lol sdf $1==$4 && $2==$5 && $3==4 call ldfxxxsdf("add", "adc")
  1361. pat lol ldf and lol sdf $1==$4 && $2==$5 && $3==4 call ldfxxxsdf("and", "and")
  1362. pat lol ldf ior lol sdf $1==$4 && $2==$5 && $3==4 call ldfxxxsdf("or", "or")
  1363. pat lol ldf xor lol sdf $1==$4 && $2==$5 && $3==4 call ldfxxxsdf("xor", "xor")
  1364. proc ldixxxsdi example lol loi adi lol sti
  1365. with regorconstnoaddr regorconstnoaddr
  1366. kills referals
  1367. uses ADDREG={LOCAL,$1,2}
  1368. gen axx[1] {ind_reg2, %a}, %1
  1369. axx[2] {ind_regoff2, %a, 2}, %2
  1370. killreg %a
  1371. pat lol loi adi lol sti $1==$4 && $2==4 && $5==4 && $3==4
  1372. call ldixxxsdi("add", "adc")
  1373. pat lol loi adu lol sti $1==$4 && $2==4 && $5==4 && $3==4
  1374. call ldixxxsdi("add", "adc")
  1375. pat lol loi and lol sti $1==$4 && $2==4 && $5==4 && $3==4
  1376. call ldixxxsdi("and", "and")
  1377. pat lol loi ior lol sti $1==$4 && $2==4 && $5==4 && $3==4
  1378. call ldixxxsdi("or", "or")
  1379. pat lol loi xor lol sti $1==$4 && $2==4 && $5==4 && $3==4
  1380. call ldixxxsdi("xor", "xor")
  1381. proc lefuxxsef example loe lof inc loe stf
  1382. kills referals
  1383. uses ADDREG={EXTERN2,$1}
  1384. gen uxx* {ind_regoff2, %a, $2}
  1385. killreg %a
  1386. pat loe lof ngi loe stf $1==$4 && $2==$5 && $3==2 call lefuxxsef("neg")
  1387. pat loe lof com loe stf $1==$4 && $2==$5 && $3==2 call lefuxxsef("not")
  1388. pat loe lof dec loe stf $1==$4 && $2==$5 call lefuxxsef("dec")
  1389. pat loe lof inc loe stf $1==$4 && $2==$5 call lefuxxsef("inc")
  1390. proc lefxxxsef example loe lof adi loe stf
  1391. with regorconstnoaddr
  1392. kills referals
  1393. uses ADDREG={EXTERN2,$1}
  1394. gen axx* {ind_regoff2, %a, $2}, %1
  1395. killreg %a
  1396. pat loe lof adi loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("add")
  1397. pat loe lof adu loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("add")
  1398. pat loe lof ads loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("add")
  1399. pat loe lof and loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("and")
  1400. pat loe lof ior loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("or")
  1401. pat loe lof xor loe stf $1==$4 && $2==$5 && $3==2 call lefxxxsef("xor")
  1402. proc leiuxxsei example loe loi inc loe sti
  1403. kills referals
  1404. uses ADDREG={EXTERN2,$1}
  1405. gen uxx* {ind_reg2, %a}
  1406. killreg %a
  1407. pat loe loi ngi loe sti $1==$4 && $2==2 && $5==2 && $3==2
  1408. call leiuxxsei("neg")
  1409. pat loe loi com loe sti $1==$4 && $2==2 && $5==2 && $3==2
  1410. call leiuxxsei("not")
  1411. pat loe loi dec loe sti $1==$4 && $2==2 && $5==2 call leiuxxsei("dec")
  1412. pat loe loi inc loe sti $1==$4 && $2==2 && $5==2 call leiuxxsei("inc")
  1413. proc leixxxsei example loe loi adi loe sti
  1414. with regorconstnoaddr
  1415. kills referals
  1416. uses ADDREG={EXTERN2,$1}
  1417. gen axx* {ind_reg2, %a}, %1
  1418. killreg %a
  1419. pat loe loi adi loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("add")
  1420. pat loe loi adu loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("add")
  1421. pat loe loi ads loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("add")
  1422. pat loe loi and loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("and")
  1423. pat loe loi ior loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("or")
  1424. pat loe loi xor loe sti $1==$4 && $2==$5 && $2==2 && $3==2 call leixxxsei("xor")
  1425. #ifdef REGVARS
  1426. proc lolcrxxstl example lol loc sbi stl
  1427. kills regvar($1)
  1428. gen axx* {LOCAL,$1,2},{ANYCON,$2}
  1429. pat lol loc sbi stl $1==$4 && $3==2 && inreg($1)==reg_any
  1430. call lolcrxxstl("sub")
  1431. pat lol loc sbu stl $1==$4 && $3==2 && inreg($1)==reg_any
  1432. call lolcrxxstl("sub")
  1433. pat lol loc sli stl $1==$4 && $3==2 && $2==1 && inreg($1)==reg_any
  1434. call lolcrxxstl("sal")
  1435. pat lol loc slu stl $1==$4 && $3==2 && $2==1 && inreg($1)==reg_any
  1436. call lolcrxxstl("sal")
  1437. pat lol loc sri stl $1==$4 && $3==2 && $2==1 && inreg($1)==reg_any
  1438. call lolcrxxstl("sar")
  1439. pat lol loc sru stl $1==$4 && $3==2 && $2==1 && inreg($1)==reg_any
  1440. call lolcrxxstl("shr")
  1441. proc lolr2shstl example lol loc sli stl
  1442. kills regvar($1)
  1443. gen axx* {LOCAL,$1,2},{ANYCON,1}
  1444. axx* {LOCAL,$1,2},{ANYCON,1}
  1445. pat lol loc sli stl $1==$4 && $3==2 && $2==2 && inreg($1)==reg_any
  1446. call lolr2shstl("sal")
  1447. pat lol loc slu stl $1==$4 && $3==2 && $2==2 && inreg($1)==reg_any
  1448. call lolr2shstl("sal")
  1449. pat lol loc sri stl $1==$4 && $3==2 && $2==2 && inreg($1)==reg_any
  1450. call lolr2shstl("sar")
  1451. pat lol loc sru stl $1==$4 && $3==2 && $2==2 && inreg($1)==reg_any
  1452. call lolr2shstl("shr")
  1453. proc lolrcshstl example lol loc sli stl
  1454. kills regvar($1)
  1455. uses CXREG = {ANYCON,$2}
  1456. gen sxx* {LOCAL,$1,2},cl
  1457. pat lol loc sli stl $1==$4 && $3==2 && inreg($1)==reg_any
  1458. call lolrcshstl("sal")
  1459. pat lol loc slu stl $1==$4 && $3==2 && inreg($1)==reg_any
  1460. call lolrcshstl("sal")
  1461. pat lol loc sri stl $1==$4 && $3==2 && inreg($1)==reg_any
  1462. call lolrcshstl("sar")
  1463. pat lol loc sru stl $1==$4 && $3==2 && inreg($1)==reg_any
  1464. call lolrcshstl("shr")
  1465. #endif
  1466. proc lolcxxstl example lol loc sbi stl
  1467. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1468. gen axx* {LOCAL,$1,2},{ANYCON,$2}
  1469. pat lol loc sbi stl $1==$4 && $3==2 call lolcxxstl("sub")
  1470. pat lol loc sbu stl $1==$4 && $3==2 call lolcxxstl("sub")
  1471. pat lol loc sli stl $1==$4 && $3==2 && $2==1 call lolcxxstl("sal")
  1472. pat lol loc slu stl $1==$4 && $3==2 && $2==1 call lolcxxstl("sal")
  1473. pat lol loc sri stl $1==$4 && $3==2 && $2==1 call lolcxxstl("sar")
  1474. pat lol loc sru stl $1==$4 && $3==2 && $2==1 call lolcxxstl("shr")
  1475. proc lolcshstl example lol loc sli stl
  1476. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1477. uses CXREG = {ANYCON,$2}
  1478. gen sxx* {LOCAL,$1,2},cl
  1479. pat lol loc sli stl $1==$4 && $3==2 call lolcshstl("sal")
  1480. pat lol loc slu stl $1==$4 && $3==2 call lolcshstl("sal")
  1481. pat lol loc sri stl $1==$4 && $3==2 call lolcshstl("sar")
  1482. pat lol loc sru stl $1==$4 && $3==2 call lolcshstl("shr")
  1483. proc loecxxste example loe loc sbi ste
  1484. kills indirects
  1485. gen axx* {EXTERN2,$1},{ANYCON,$2}
  1486. pat loe loc sbi ste $1==$4 && $3==2 call loecxxste("sub")
  1487. pat loe loc sbu ste $1==$4 && $3==2 call loecxxste("sub")
  1488. pat loe loc adu ste $1==$4 && $3==2 call loecxxste("add")
  1489. pat loe loc adi ste $1==$4 && $3==2 call loecxxste("add")
  1490. pat loe loc sli ste $1==$4 && $3==2 && $2==1 call loecxxste("sal")
  1491. pat loe loc slu ste $1==$4 && $3==2 && $2==1 call loecxxste("sal")
  1492. pat loe loc sri ste $1==$4 && $3==2 && $2==1 call loecxxste("sar")
  1493. pat loe loc sru ste $1==$4 && $3==2 && $2==1 call loecxxste("shr")
  1494. proc loecshste example loe loc sli ste
  1495. kills indirects
  1496. uses CXREG = {ANYCON,$2}
  1497. gen sxx* {EXTERN2,$1},cl
  1498. pat loe loc sli ste $1==$4 && $3==2 call loecshste("sal")
  1499. pat loe loc slu ste $1==$4 && $3==2 call loecshste("sal")
  1500. pat loe loc sri ste $1==$4 && $3==2 call loecshste("sar")
  1501. pat loe loc sru ste $1==$4 && $3==2 call loecshste("shr")
  1502. #ifdef REGVARS
  1503. pat lol ngi stl $1==$3 && $2==2 && inreg($1)==reg_any
  1504. kills regvar($1)
  1505. gen neg {LOCAL, $1, 2}
  1506. #endif
  1507. pat lol ngi stl $1==$3 && $2==2
  1508. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1509. gen neg {LOCAL, $1, 2}
  1510. pat ldl ngi sdl $1==$3 && $2==4
  1511. kills indexed,locals %ind+%size > $1 && %ind < $1+4
  1512. gen neg {LOCAL, $1+2, 2}
  1513. neg {LOCAL, $1, 2}
  1514. sbb {LOCAL, $1+2, 2}, {ANYCON, 0}
  1515. pat lol dup adp stl loi stl $1==$4 && $2==2 && $5<=2
  1516. leaving lol $1 loi $5 stl $6 lol $4 adp $3 stl $4
  1517. #ifdef REGVARS
  1518. pat lol dup adp stl loi $1==$4 && $2==2 && $5==1 && inreg($1) > 0
  1519. uses REG1 = {ind_reg1, regvar($1)}
  1520. yields %a
  1521. leaving lol $4 adp $3 stl $4
  1522. pat lol dup adp stl loi $1==$4 && $2==2 && $5==2 && inreg($1) > 0
  1523. uses REG = {ind_reg2, regvar($1)}
  1524. yields %a
  1525. leaving lol $4 adp $3 stl $4
  1526. pat adp stl inreg($2) > 0 leaving stl $2 lol $2 adp $1 stl $2
  1527. #endif
  1528. pat lol dup adp stl $1==$4 && $2==2
  1529. uses ADDREG={LOCAL,$1,2} yields %a
  1530. leaving lol $4 adp $3 stl $4
  1531. pat lol inl $1==$2
  1532. uses REG={LOCAL,$1,2} yields %a
  1533. leaving inl $1
  1534. pat lol del $1==$2
  1535. uses REG={LOCAL,$1,2} yields %a
  1536. leaving del $1
  1537. pat lol adp stl $1==$3 && $2==1 leaving inl $1
  1538. pat lol adp stl $1==$3 && $2==0-1 leaving del $1
  1539. pat lol adp stl $1==$3 leaving loc $2 lol $1 adi 2 stl $3
  1540. #ifdef REGVARS
  1541. pat lol com stl $1==$3 && $2==2 && inreg($1)==reg_any
  1542. kills regvar($1)
  1543. gen not {LOCAL,$1,2}
  1544. #endif
  1545. pat lol com stl $1==$3 && $2==2
  1546. kills indexed,locals %ind+%size > $1 && %ind < $1+2
  1547. gen not {LOCAL, $1, 2}
  1548. pat lil adp dup sil lof $1==$4 && $3==2 && $5==(0-$2)
  1549. leaving lil $4 dup 2 adp $2 sil $4 loi 2
  1550. #ifdef REGVARS
  1551. pat lil dup adp sil $1==$4 && $2==2 && inreg($1)==reg_any
  1552. uses ADDREG={ind_reg2, regvar($1)}
  1553. yields %a
  1554. leaving lil $4 adp $3 sil $4
  1555. pat lil adp dup sil $1==$4 && $3==2 && inreg($1)==reg_any
  1556. leaving lil $4 adp $2 sil $4 lil $4
  1557. pat lil dup inc sil $1==$4 && $2==2 && inreg($1)==reg_any
  1558. uses REG={ind_reg2, regvar($1)}
  1559. yields %a
  1560. leaving lil $4 inc sil $4
  1561. pat lil dup dec sil $1==$4 && $2==2 && inreg($1)==reg_any
  1562. uses REG={ind_reg2, regvar($1)}
  1563. yields %a
  1564. leaving lil $4 dec sil $4
  1565. #endif
  1566. pat lil adp sil $1==$3 && $2==1 leaving lil $1 inc sil $1
  1567. pat lil adp sil $1==$3 && $2==0-1 leaving lil $1 dec sil $1
  1568. pat lil adp sil $1==$3 leaving loc $2 lil $1 adi 2 sil $3
  1569. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==1
  1570. leaving lol $1 lof $2 inc lol $4 stf $5
  1571. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==(0-1)
  1572. leaving lol $1 lof $2 dec lol $4 stf $5
  1573. pat lol lof adp lol stf $1==$4 && $2==$5
  1574. leaving loc $3 lol $1 lof $2 adi 2 lol $4 stf $5
  1575. #ifdef REGVARS
  1576. pat lol lof lol lof adp lol stf
  1577. $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
  1578. uses ADDREG={ind_regoff2, regvar($1), $2}
  1579. yields %a
  1580. leaving lol $1 lof $2 adp $5 lol $6 stf $7
  1581. pat lol lof lol lof inc lol stf
  1582. $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
  1583. uses REG={ind_regoff2, regvar($1), $2}
  1584. yields %a
  1585. leaving lol $1 lof $2 inc lol $6 stf $7
  1586. pat lol lof lol lof dec lol stf
  1587. $1==$3 && $1==$6 && $2==$4 && $2==$7 && inreg($1)==reg_any
  1588. uses REG={ind_regoff2, regvar($1), $2}
  1589. yields %a
  1590. leaving lol $1 lof $2 dec lol $6 stf $7
  1591. pat lol lof dup adp lol stf
  1592. $1==$5 && $2==$6 && $3==2 && inreg($1)==reg_any
  1593. uses ADDREG={ind_regoff2, regvar($1), $2}
  1594. yields %a
  1595. leaving lol $1 lof $2 adp $4 lol $1 stf $2
  1596. pat lol lof dup inc lol stf
  1597. $1==$5 && $2==$6 && $3==2 && inreg($1)==reg_any
  1598. uses REG={ind_regoff2, regvar($1), $2}
  1599. yields %a
  1600. leaving lol $1 lof $2 inc lol $1 stf $2
  1601. pat lol lof dup dec lol stf
  1602. $1==$5 && $2==$6 && $3==2 && inreg($1)==reg_any
  1603. uses REG={ind_regoff2, regvar($1), $2}
  1604. yields %a
  1605. leaving lol $1 lof $2 dec lol $1 stf $2
  1606. #endif
  1607. pat lol lof dup adp lol stf
  1608. $1==$5 && $2==$6 && $3==2 && $4==1
  1609. kills referals
  1610. uses ADDREG={LOCAL,$1,2}, REG
  1611. gen move {ind_regoff2, %a, $2},%b
  1612. inc {ind_regoff2, %a, $2}
  1613. yields %b
  1614. pat loe lof dup adp loe stf
  1615. $1==$5 && $2==$6 && $3==2 && $4==1
  1616. kills referals
  1617. uses ADDREG={EXTERN2,$1}, REG
  1618. gen move {ind_regoff2, %a, $2},%b
  1619. inc {ind_regoff2, %a, $2}
  1620. yields %b
  1621. pat loe loi dup adp loe sti
  1622. $1==$5 && $2==$6 && $3==2 && $2==2 && $4==1
  1623. kills referals
  1624. uses ADDREG={EXTERN2,$1}, REG
  1625. gen move {ind_reg2, %a},%b
  1626. inc {ind_reg2, %a}
  1627. yields %b
  1628. pat lol lof dup adp lol stf
  1629. $1==$5 && $2==$6 && $3==2 && $4==(0-1)
  1630. kills referals
  1631. uses ADDREG={LOCAL,$1,2}, REG
  1632. gen move {ind_regoff2, %a, $2},%b
  1633. dec {ind_regoff2, %a, $2}
  1634. yields %b
  1635. pat loe lof dup adp loe stf
  1636. $1==$5 && $2==$6 && $3==2 && $4==(0-1)
  1637. kills referals
  1638. uses ADDREG={EXTERN2,$1}, REG
  1639. gen move {ind_regoff2, %a, $2},%b
  1640. dec {ind_regoff2, %a, $2}
  1641. yields %b
  1642. pat loe loi dup adp loe sti
  1643. $1==$5 && $2==$6 && $3==2 && $2==2 && $4==(0-1)
  1644. kills referals
  1645. uses ADDREG={EXTERN2,$1}, REG
  1646. gen move {ind_reg2, %a},%b
  1647. dec {ind_reg2, %a}
  1648. yields %b
  1649. pat lol lof dup adp lol stf
  1650. $1==$5 && $2==$6 && $3==2
  1651. kills referals
  1652. uses ADDREG={LOCAL,$1,2}, REG
  1653. gen move {ind_regoff2, %a, $2},%b
  1654. add {ind_regoff2, %a, $2}, {ANYCON, $4}
  1655. yields %b
  1656. pat loe lof dup adp loe stf
  1657. $1==$5 && $2==$6 && $3==2
  1658. kills referals
  1659. uses ADDREG={EXTERN2,$1}, REG
  1660. gen move {ind_regoff2, %a, $2},%b
  1661. add {ind_regoff2, %a, $2}, {ANYCON, $4}
  1662. yields %b
  1663. pat loe loi dup adp loe sti
  1664. $1==$5 && $2==$6 && $3==2 && $2==2
  1665. kills referals
  1666. uses ADDREG={EXTERN2,$1}, REG
  1667. gen move {ind_reg2, %a},%b
  1668. add {ind_reg2, %a}, {ANYCON, $4}
  1669. yields %b
  1670. pat loe ngi ste $1==$3 && $2==2
  1671. kills indirects
  1672. gen neg {EXTERN2, $1}
  1673. pat lde ngi sde $1==$3 && $2==4
  1674. kills indirects
  1675. gen neg {EXTERN2, $1+2}
  1676. neg {EXTERN2, $1}
  1677. sbb {EXTERN2, $1+2}, {ANYCON, 0}
  1678. pat loe dup adp ste $1==$4 && $2==2
  1679. uses ADDREG={EXTERN2,$1} yields %a
  1680. leaving loe $1 adp $3 ste $1
  1681. pat loe ine $1==$2
  1682. uses REG={EXTERN2,$1} yields %a leaving ine $1
  1683. pat loe dee $1==$2
  1684. uses REG={EXTERN2,$1} yields %a leaving dee $1
  1685. pat loe adp ste $1==$3 && $2==1 leaving ine $1
  1686. pat loe adp ste $1==$3 && $2==0-1 leaving dee $1
  1687. pat loe adp ste $1==$3 leaving loc $2 loe $1 adi 2 ste $3
  1688. pat loe com ste $1==$3 && $2==2
  1689. kills indirects
  1690. gen not {EXTERN2, $1}
  1691. pat loe lof adp loe stf $1==$4 && $2==$5 && $3==1
  1692. leaving loe $1 lof $2 inc loe $1 stf $2
  1693. pat loe lof adp loe stf $1==$4 && $2==$5 && $3==0-1
  1694. leaving loe $1 lof $2 dec loe $1 stf $2
  1695. pat loe lof adp loe stf $1==$4 && $2==$5
  1696. leaving loc $3 loe $1 lof $2 adi 2 loe $1 stf $2
  1697. pat loe loi adp loe sti $1==$4 && $2==$5 && $3==1 && $2==2
  1698. leaving loe $1 loi $2 inc loe $1 sti $2
  1699. pat loe loi adp loe sti $1==$4 && $2==$5 && $3==0-1 && $2==2
  1700. leaving loe $1 loi $2 dec loe $1 sti $2
  1701. pat loe loi adp loe sti $1==$4 && $2==$5 && $2==2
  1702. leaving loc $3 loe $1 loi $2 adi 2 loe $1 sti $2
  1703. /*******************************************************************
  1704. * Group 8: Convert Instructions *
  1705. *******************************************************************/
  1706. pat cii
  1707. with CXREG DXREG ACC
  1708. kills ALL
  1709. gen joehoe {label,".cii"} yields %3
  1710. pat ciu leaving cuu
  1711. pat cui leaving cuu
  1712. pat cuu
  1713. with CXREG DXREG ACC
  1714. kills ALL
  1715. gen joehoe {label,".cuu"} yields %3
  1716. pat loc loc cii zeq $1==1 && $2==2
  1717. with GENREG STACK
  1718. gen test %1.1
  1719. je {label, $4}
  1720. pat loc loc cii zne $1==1 && $2==2
  1721. with GENREG STACK
  1722. gen test %1.1
  1723. jne {label, $4}
  1724. pat loc loc cii loc and zeq $4<256 && $4>=0 && $5==2 && $1==1 && $2==2
  1725. leaving loc $4 and $5 zeq $6
  1726. pat loc loc cii loc and zne $4<256 && $4>=0 && $5==2 && $1==1 && $2==2
  1727. leaving loc $4 and $5 zne $6
  1728. pat loc loc cii $1==1 && $2==2
  1729. with ACC
  1730. gen cbw. yields ax
  1731. with exact rmorconst1 ACC
  1732. uses REG
  1733. gen move %2,%a
  1734. move %1,%2.1
  1735. cbw. yields %a ax
  1736. with exact rmorconst1
  1737. uses reusing %1, ACC1=%1
  1738. gen cbw. yields ax
  1739. pat loc loc cii $1==1 && $2==4
  1740. with ACC
  1741. uses DXREG
  1742. gen cbw.
  1743. cwd. yields dx ax
  1744. with exact rmorconst1
  1745. uses reusing %1, ACC1=%1, DXREG
  1746. gen cbw.
  1747. cwd. yields dx ax
  1748. pat loc loc cii $1==2 && $2==4
  1749. with ACC
  1750. uses DXREG
  1751. gen cwd. yields dx ax
  1752. pat loc loc cii $1==4 && $2==2
  1753. with a_word a_word yields %1
  1754. pat loc loc ciu leaving loc $1 loc $2 cuu
  1755. pat loc loc cui leaving loc $1 loc $2 cuu
  1756. pat loc loc cuu $1==$2
  1757. pat loc loc cuu $1==2 && $2==4
  1758. with a_word yields {ANYCON,0} %1
  1759. pat loc loc cuu $1==4 && $2==2
  1760. with a_word a_word yields %1
  1761. pat loc loc cif $1==2 && $2==4 leaving loc $1 cal ".cif4"
  1762. pat loc loc cif $1==4 && $2==4 leaving loc $1 cal ".cif4" asp 2
  1763. pat loc loc cif $1==2 && $2==8
  1764. with REG
  1765. kills ALL
  1766. gen push %1
  1767. push %1
  1768. push %1 leaving loc $1 cal ".cif8"
  1769. pat loc loc cif $1==4 && $2==8
  1770. with REG REG
  1771. kills ALL
  1772. gen push %1
  1773. push %2
  1774. push %1 leaving loc $1 cal ".cif8"
  1775. pat loc loc cuf $1==2 && $2==4 leaving loc $1 cal ".cuf4"
  1776. pat loc loc cuf $1==4 && $2==4 leaving loc $1 cal ".cuf4" asp 2
  1777. pat loc loc cuf $1==2 && $2==8
  1778. with REG
  1779. kills ALL
  1780. gen push %1
  1781. push %1
  1782. push %1 leaving loc $1 cal ".cuf8"
  1783. pat loc loc cuf $1==4 && $2==8
  1784. with REG REG
  1785. kills ALL
  1786. gen push %1
  1787. push %2
  1788. push %1 leaving loc $1 cal ".cuf8"
  1789. pat loc loc cfi $1==4 && $2==2 leaving loc $1 loc $2 cal ".cfi" asp 8 lfr 2
  1790. pat loc loc cfi $2==4 leaving loc $1 loc $2 cal ".cfi" asp $1
  1791. pat loc loc cfi $1==8 && $2==2 leaving loc $1 loc $2 cal ".cfi" asp 12 lfr 2
  1792. pat loc loc cfu $1==4 && $2==2 leaving loc $1 loc $2 cal ".cfu" asp 8 lfr 2
  1793. pat loc loc cfu $2==4 leaving loc $1 loc $2 cal ".cfu" asp $1
  1794. pat loc loc cfu $1==8 && $2==2 leaving loc $1 loc $2 cal ".cfu" asp 12 lfr 2
  1795. pat loc loc cff $1==8 && $2==4 leaving cal ".cff4" asp 4
  1796. pat loc loc cff $1==4 && $2==8
  1797. with REG REG
  1798. kills ALL
  1799. uses REG={ANYCON,0}
  1800. gen push %a
  1801. push %a
  1802. push %2
  1803. push %1 leaving cal ".cff8"
  1804. /********************************************************************
  1805. * Group 9 : Logical Instructions *
  1806. ********************************************************************/
  1807. pat and $1==2
  1808. with REG rmorconst
  1809. gen and %1,%2 yields %1
  1810. with rmorconst REG
  1811. gen and %2,%1 yields %2
  1812. pat loc and $1==65535 && $2==2
  1813. pat loc and $1==255 && $2==2
  1814. with GENREG yields %1.1
  1815. pat loc and $1==0 && $2==2 leaving asp 2 loc 0
  1816. pat and $1==4
  1817. with EXACT REG REG rmorconst rmorconst
  1818. gen and %1,%3
  1819. and %2,%4 yields %2 %1
  1820. with rmorconst rmorconst REG REG
  1821. gen and %3,%1
  1822. and %4,%2 yields %4 %3
  1823. pat ldc and highw($1)==(0-1) && $2==4 leaving loc loww($1) and 2
  1824. pat ldc and loww($1)==0 && $2==4 leaving asp 2 loc highw($1) and 2 loc 0
  1825. pat ldc and loww($1)==65535 && $2==4
  1826. with rmorconst REG
  1827. gen and %2,{ANYCON, highw($1)} yields %2 %1
  1828. pat ldc and highw($1)==0 && $2==4
  1829. with REG rmorconst
  1830. gen and %1,{ANYCON, loww($1)} yields {ANYCON,0} %1
  1831. pat and defined($1)
  1832. kills ALL
  1833. gen mov cx,{ANYCON,$1}
  1834. joehoe {label, ".and"}
  1835. pat and !defined($1)
  1836. with CXREG
  1837. kills ALL
  1838. gen joehoe {label, ".and"}
  1839. pat ior $1==2
  1840. with REG rmorconst
  1841. gen or %1,%2 yields %1
  1842. with rmorconst REG
  1843. gen or %2,%1 yields %2
  1844. pat loc ior $1==0 && $2==2
  1845. pat loc ior $1==65535 && $2==2 leaving asp 2 loc $1
  1846. pat ior $1==4
  1847. with EXACT REG REG rmorconst rmorconst
  1848. gen or %1,%3
  1849. or %2,%4 yields %2 %1
  1850. with rmorconst rmorconst REG REG
  1851. gen or %3,%1
  1852. or %4,%2 yields %4 %3
  1853. pat ldc ior highw($1)==(0-1) && $2==4
  1854. with REG rmorconst
  1855. gen or %1,{ANYCON, loww($1)} yields {ANYCON,0-1} %1
  1856. pat ldc ior highw($1)==0 && $2==4 leaving loc loww($1) ior 2
  1857. pat ldc ior loww($1)==65535 && $2==4 leaving asp 2 loc highw($1) ior 2 loc 0-1
  1858. pat ldc ior loww($1)==0 && $2==4
  1859. with rmorconst REG
  1860. gen or %2,{ANYCON, highw($1)} yields %2 %1
  1861. pat ior defined($1)
  1862. kills ALL
  1863. gen mov cx,{ANYCON,$1}
  1864. joehoe {label, ".ior"}
  1865. pat ior !defined($1)
  1866. with CXREG
  1867. kills ALL
  1868. gen joehoe {label, ".ior"}
  1869. pat xor $1==2
  1870. with REG rmorconst
  1871. gen xor %1,%2 yields %1
  1872. with rmorconst REG
  1873. gen xor %2,%1 yields %2
  1874. pat xor $1==4
  1875. with EXACT REG REG rmorconst rmorconst
  1876. gen xor %1,%3
  1877. xor %2,%4 yields %2 %1
  1878. with rmorconst rmorconst REG REG
  1879. gen xor %3,%1
  1880. xor %4,%2 yields %4 %3
  1881. pat xor defined($1)
  1882. kills ALL
  1883. gen mov cx,{ANYCON,$1}
  1884. joehoe {label, ".xor"}
  1885. pat xor !defined($1)
  1886. with CXREG
  1887. kills ALL
  1888. gen joehoe {label, ".xor"}
  1889. pat com $1==2
  1890. with REG
  1891. gen not %1 yields %1
  1892. pat com $1==4
  1893. with REG REG
  1894. gen not %2
  1895. not %1 yields %2 %1
  1896. pat com defined($1)
  1897. kills ALL
  1898. gen mov cx,{ANYCON,$1}
  1899. joehoe {label, ".com"}
  1900. pat com !defined($1)
  1901. with CXREG
  1902. kills ALL
  1903. gen joehoe {label, ".com"}
  1904. pat loc rol $1==1 && $2==2
  1905. with REG
  1906. gen rol %1,{ANYCON,1} yields %1
  1907. pat rol $1==2
  1908. with SHIFT_CREG REG
  1909. gen rol %2,cl yields %2
  1910. pat rol $1==4
  1911. with CXREG REG REG
  1912. gen jcxz {label, 1f}
  1913. 2: sal %2,{ANYCON,1}
  1914. rcl %3,{ANYCON,1}
  1915. adc %2,{ANYCON,0}
  1916. loop {label, 2b}
  1917. 1:
  1918. pat loc ror $1==1 && $2==2
  1919. with REG
  1920. gen ror %1,{ANYCON,1} yields %1
  1921. pat ror $1==2
  1922. with SHIFT_CREG REG
  1923. gen ror %2,cl yields %2
  1924. pat ror $1==4
  1925. with CXREG REG REG
  1926. gen jcxz {label, 1f}
  1927. neg cx
  1928. add cx,{ANYCON,32}
  1929. 2: sal %2,{ANYCON,1}
  1930. rcl %3,{ANYCON,1}
  1931. adc %2,{ANYCON,0}
  1932. loop {label, 2b}
  1933. 1:
  1934. /*******************************************************************
  1935. * Group 10 : Set Instructions *
  1936. *******************************************************************/
  1937. pat inn $1==2
  1938. with SHIFT_CREG REG
  1939. gen shr %2,cl
  1940. and %2,{ANYCON, 1} yields %2
  1941. pat loc inn $1==1 && $2==2
  1942. with REG
  1943. gen shr %1,{ANYCON, 1}
  1944. and %1,{ANYCON, 1} yields %1
  1945. pat loc inn $1==0 && $2==2
  1946. with REG
  1947. gen and %1,{ANYCON, 1} yields %1
  1948. pat inn defined($1)
  1949. with ACC
  1950. kills ALL
  1951. gen mov cx,{ANYCON, $1}
  1952. joehoe {label,".inn"} yields ax
  1953. pat inn !defined($1)
  1954. with CXREG ACC
  1955. kills ALL
  1956. gen joehoe {label,".inn"} yields ax
  1957. pat loc inn zeq $2==2
  1958. with rm STACK
  1959. gen check %1,{ANYCON,1<<$1}
  1960. je {label,$3}
  1961. pat loc inn zne $2==2
  1962. with rm STACK
  1963. gen check %1,{ANYCON,1<<$1}
  1964. jne {label,$3}
  1965. pat set $1==2
  1966. with SHIFT_CREG
  1967. uses REG={ANYCON, 1}
  1968. gen shl %a,cl yields %a
  1969. pat set defined($1)
  1970. with ACC
  1971. kills ALL
  1972. gen mov cx,{ANYCON, $1}
  1973. joehoe {label,".set"}
  1974. pat set !defined($1)
  1975. with CXREG ACC
  1976. kills ALL
  1977. gen joehoe {label,".set"}
  1978. /********************************************************************
  1979. * Group 11 : Array Instructions *
  1980. ********************************************************************/
  1981. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)==0
  1982. leaving ads 2
  1983. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)!=0
  1984. leaving adp 0-rom($1,1) ads 2
  1985. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)==0
  1986. with ADDREG
  1987. gen sal %1,{ANYCON,1} yields %1 leaving ads 2
  1988. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)!=0
  1989. with ADDREG
  1990. gen sal %1,{ANYCON,1} yields %1 leaving adp 0-2*rom($1,1) ads 2
  1991. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)==0
  1992. with ADDREG
  1993. gen sal %1,{ANYCON,1}
  1994. sal %1,{ANYCON,1} yields %1 leaving ads 2
  1995. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)!=0
  1996. with ADDREG
  1997. gen sal %1,{ANYCON,1}
  1998. sal %1,{ANYCON,1} yields %1 leaving adp 0-4*rom($1,1) ads 2
  1999. pat lae aar $2==2 && rom($1,1)==0
  2000. with ACC
  2001. uses DXREG,REG={ANYCON,rom($1,3)}
  2002. gen mul %b yields %1 leaving ads 2
  2003. pat lae aar $2==2 && defined(rom($1,1))
  2004. with ACC
  2005. uses DXREG,REG={ANYCON,rom($1,3)}
  2006. gen mul %b yields %1
  2007. leaving adp 0-rom($1,1)*rom($1,3) ads 2
  2008. pat loc sli ads sti $1==1 && $2==2 && $3==2
  2009. with exact rmorconst ADDR_EXTERN
  2010. uses reusing %1,ADDREG=%1
  2011. gen sal %a,{ANYCON,1} yields {Xreg_off,%a,%2.off}
  2012. leaving sti $4
  2013. with ADDREG rmorconst
  2014. gen sal %1,{ANYCON,1}
  2015. add %1,%2 yields %1 leaving sti $4
  2016. with REG ADDREG
  2017. gen sal %1,{ANYCON,1}
  2018. add %2,%1 yields %2 leaving sti $4
  2019. pat loc sli ads $1==1 && $2==2 && $3==2
  2020. with exact rmorconst ADDR_EXTERN
  2021. uses reusing %1,ADDREG=%1
  2022. gen sal %a,{ANYCON,1} yields {Xreg_off,%a,%2.off}
  2023. with ADDREG rmorconst
  2024. gen sal %1,{ANYCON,1}
  2025. add %1,%2 yields %1
  2026. with REG ADDREG
  2027. gen sal %1,{ANYCON,1}
  2028. add %2,%1 yields %2
  2029. with REG rmorconst
  2030. gen sal %1,{ANYCON,1}
  2031. add %1,%2 yields %1
  2032. pat loc sli ads sti $1==2 && $2==2 && $3==2
  2033. with exact rmorconst ADDR_EXTERN
  2034. uses reusing %1,ADDREG=%1
  2035. gen sal %a,{ANYCON,1}
  2036. sal %a,{ANYCON,1} yields {Xreg_off,%a,%2.off}
  2037. leaving sti $4
  2038. with ADDREG rmorconst
  2039. gen sal %1,{ANYCON,1}
  2040. sal %1,{ANYCON,1}
  2041. add %1,%2 yields %1 leaving sti $4
  2042. with REG ADDREG
  2043. gen sal %1,{ANYCON,1}
  2044. sal %1,{ANYCON,1}
  2045. add %2,%1 yields %2 leaving sti $4
  2046. pat loc sli ads $1==2 && $2==2 && $3==2
  2047. with exact rmorconst ADDR_EXTERN
  2048. uses reusing %1,ADDREG=%1
  2049. gen sal %a,{ANYCON,1}
  2050. sal %a,{ANYCON,1} yields {Xreg_off,%a,%2.off}
  2051. with ADDREG rmorconst
  2052. gen sal %1,{ANYCON,1}
  2053. sal %1,{ANYCON,1}
  2054. add %1,%2 yields %1
  2055. with REG ADDREG
  2056. gen sal %1,{ANYCON,1}
  2057. sal %1,{ANYCON,1}
  2058. add %2,%1 yields %2
  2059. with REG rmorconst
  2060. gen sal %1,{ANYCON,1}
  2061. sal %1,{ANYCON,1}
  2062. add %1,%2 yields %1
  2063. pat loc sli ads sti $2==2 && $3==2
  2064. with exact rmorconst ADDR_EXTERN
  2065. uses reusing %1,ADDREG=%1,CXREG={ANYCON,$1}
  2066. gen sal %a,cl yields {Xreg_off,%a,%2.off}
  2067. leaving sti $4
  2068. with ADDREG rmorconst
  2069. uses CXREG={ANYCON,$1}
  2070. gen sal %1,cl
  2071. add %1,%2 yields %1 leaving sti $4
  2072. with REG ADDREG
  2073. uses CXREG={ANYCON,$1}
  2074. gen sal %1,cl
  2075. add %2,%1 yields %2 leaving sti $4
  2076. pat loc sli ads $2==2 && $3==2
  2077. with exact rmorconst ADDR_EXTERN
  2078. uses reusing %1,ADDREG=%1,CXREG={ANYCON,$1}
  2079. gen sal %a,cl yields {Xreg_off,%a,%2.off}
  2080. with ADDREG rmorconst
  2081. uses CXREG={ANYCON,$1}
  2082. gen sal %1,cl
  2083. add %1,%2 yields %1
  2084. with REG ADDREG
  2085. uses CXREG={ANYCON,$1}
  2086. gen sal %1,cl
  2087. add %2,%1 yields %2
  2088. with REG rmorconst
  2089. uses CXREG={ANYCON,$1}
  2090. gen sal %1,cl
  2091. add %1,%2 yields %1
  2092. pat aar $1==2
  2093. with AREG ACC
  2094. uses DXREG
  2095. gen sub %2,{ind_reg2,%1}
  2096. mul {ind_regoff2,%1,4} yields %2 leaving ads 2
  2097. with reg_off ACC
  2098. uses DXREG
  2099. gen sub %2,{ind_regoff2, %1.reg, %1.off}
  2100. mul {ind_regoff2, %1.reg, 4+%1.off}
  2101. yields %2 leaving ads 2
  2102. with bpreg_off ACC
  2103. uses DXREG
  2104. gen sub %2,{ind_bpregoff2, %1.reg, %1.ind}
  2105. mul {ind_bpregoff2, %1.reg, 4+%1.ind}
  2106. yields %2 leaving ads 2
  2107. with ADDR_LOCAL ACC
  2108. uses DXREG
  2109. gen sub %2,{LOCAL,%1.ind,2}
  2110. mul {LOCAL, 4+%1.ind,2} yields %2 leaving ads 2
  2111. with ADDR_EXTERN ACC
  2112. uses DXREG
  2113. gen sub %2,{EXTERN2,%1.off}
  2114. mul {EXTERN2,4+%1.off} yields %2 leaving ads 2
  2115. pat lae lar defined(rom($1,3)) leaving lae $1 aar $2 loi rom($1,3)
  2116. pat lae sar defined(rom($1,3)) leaving lae $1 aar $2 sti rom($1,3)
  2117. pat aar !defined($1)
  2118. kills ALL
  2119. gen joehoe {label,".iaar"} yields bx
  2120. pat sar $1==2
  2121. with BXREG ACC
  2122. kills ALL
  2123. gen joehoe {label,".sar2"}
  2124. pat sar !defined($1)
  2125. kills ALL
  2126. gen joehoe {label,".isar"}
  2127. pat lar $1==2
  2128. with BXREG ACC
  2129. kills ALL
  2130. gen joehoe {label,".lar2"}
  2131. pat lar !defined($1)
  2132. kills ALL
  2133. gen joehoe {label,".ilar"}
  2134. /*******************************************************************
  2135. * Group 12 : Compare Instructions *
  2136. *******************************************************************/
  2137. pat cmi $1==2
  2138. with EXACT register rmorconst
  2139. uses REG={ANYCON,0}
  2140. gen cmp %1,%2
  2141. je {label,2f}
  2142. jl {label,1f}
  2143. inc %a
  2144. jmp {label,2f}
  2145. 1:
  2146. dec %a
  2147. 2: yields %a
  2148. with rmorconst register
  2149. uses REG={ANYCON,0}
  2150. gen cmp %2,%1
  2151. je {label,2f}
  2152. jg {label,1f}
  2153. inc %a
  2154. jmp {label,2f}
  2155. 1:
  2156. dec %a
  2157. 2: yields %a
  2158. pat cmi $1==4
  2159. kills ALL
  2160. gen joehoe {label,".cmi4"} yields ax
  2161. pat cmu $1==2 leaving cmp
  2162. pat cmu $1==4
  2163. kills ALL
  2164. gen joehoe {label,".cmu4"} yields ax
  2165. pat cms $1==2
  2166. with EXACT REG rmorconst
  2167. gen sub %1,%2 yields %1
  2168. with rmorconst REG
  2169. gen sub %2,%1 yields %2
  2170. pat cms $1==4
  2171. with rmorconst rmorconst REG REG
  2172. gen sub %3,%1
  2173. sbb %4,%2
  2174. or %4,%3 yields %4
  2175. with EXACT REG REG rmorconst rmorconst
  2176. gen sub %1,%3
  2177. sbb %2,%4
  2178. or %2,%1 yields %2
  2179. pat cms defined($1)
  2180. kills ALL
  2181. gen mov cx,{ANYCON,$1}
  2182. joehoe {label,".cms"} yields cx
  2183. pat cms !defined($1)
  2184. with CXREG
  2185. kills ALL
  2186. gen joehoe {label,".cms"} yields cx
  2187. pat cmf $1==4
  2188. kills ALL
  2189. gen joehoe {label,".cmf4"} leaving asp 8 lfr 2
  2190. pat cmf $1==8
  2191. kills ALL
  2192. gen joehoe {label,".cmf8"} leaving asp 16 lfr 2
  2193. pat cmp
  2194. with EXACT register rmorconst
  2195. uses REG = {ANYCON,0}
  2196. gen cmp %1,%2
  2197. je {label,2f}
  2198. jb {label,1f}
  2199. inc %a
  2200. jmp {label,2f}
  2201. 1: dec %a
  2202. 2: yields %a
  2203. with rmorconst register
  2204. uses REG = {ANYCON,0}
  2205. gen cmp %2,%1
  2206. je {label,2f}
  2207. ja {label,1f}
  2208. inc %a
  2209. jmp {label,2f}
  2210. 1: dec %a
  2211. 2: yields %a
  2212. proc txx
  2213. with rm
  2214. uses REG = {ANYCON,0}
  2215. gen test %1
  2216. jxx* {label,1f}
  2217. inc %a
  2218. 1: yields %a
  2219. pat tlt call txx("jns")
  2220. pat teq call txx("jne")
  2221. pat tne call txx("je")
  2222. pat tge call txx("js")
  2223. /* For the next two patterns there is no I8086 test instruction (one that
  2224. ignores the OF flag. Therefore, condition codes are killed and the test
  2225. is done again.
  2226. */
  2227. pat tgt
  2228. with rm
  2229. uses REG = {ANYCON, 0}
  2230. gen killcc.
  2231. test %1
  2232. jle {label, 1f}
  2233. inc %a
  2234. 1: yields %a
  2235. pat tle
  2236. with rm
  2237. uses REG = {ANYCON, 0}
  2238. gen killcc.
  2239. test %1
  2240. jg {label, 1f}
  2241. inc %a
  2242. 1: yields %a
  2243. proc txxior
  2244. with rm REG
  2245. gen test %1
  2246. jxx* {label,1f}
  2247. or %2,{ANYCON,1}
  2248. 1: yields %2
  2249. pat tlt ior $2==2 call txxior("jns")
  2250. pat tge ior $2==2 call txxior("js")
  2251. pat teq ior $2==2 call txxior("jne")
  2252. pat tne ior $2==2 call txxior("je")
  2253. /* For the next two patterns there is no I8086 test instruction (one that
  2254. ignores the OF flag. Therefore, condition codes are killed and the test
  2255. is done again.
  2256. */
  2257. pat tle ior $2==2
  2258. with rm REG
  2259. gen killcc.
  2260. test %1
  2261. jg {label,1f}
  2262. or %2,{ANYCON,1}
  2263. 1: yields %2
  2264. pat tgt ior $2==2
  2265. with rm REG
  2266. gen killcc.
  2267. test %1
  2268. jle {label,1f}
  2269. or %2,{ANYCON,1}
  2270. 1: yields %2
  2271. proc cmixxior
  2272. with regorconst rm REG
  2273. gen cmp %2,%1
  2274. jxx* {label,1f}
  2275. or %3,{ANYCON,1}
  2276. 1: yields %3
  2277. pat cmi tlt ior $1==2 && $3==2 call cmixxior("jge")
  2278. pat cmi tle ior $1==2 && $3==2 call cmixxior("jg")
  2279. pat cmi teq ior $1==2 && $3==2 call cmixxior("jne")
  2280. pat cmi tne ior $1==2 && $3==2 call cmixxior("je")
  2281. pat cmi tge ior $1==2 && $3==2 call cmixxior("jl")
  2282. pat cmi tgt ior $1==2 && $3==2 call cmixxior("jle")
  2283. proc cmxtxx
  2284. with regorconst rm
  2285. uses REG = {ANYCON,0}
  2286. gen cmp %2,%1
  2287. jxx[1] {label,1f}
  2288. inc %a
  2289. 1: yields %a
  2290. with rm regorconst
  2291. uses REG = {ANYCON,0}
  2292. gen cmp %1,%2
  2293. jxx[2] {label,1f}
  2294. inc %a
  2295. 1: yields %a
  2296. pat cmi tlt $1==2 call cmxtxx("jge","jle")
  2297. pat cmi tle $1==2 call cmxtxx("jg","jl")
  2298. pat cmi teq $1==2 call cmxtxx("jne","jne")
  2299. pat cmi tne $1==2 call cmxtxx("je","je")
  2300. pat cmi tge $1==2 call cmxtxx("jl","jg")
  2301. pat cmi tgt $1==2 call cmxtxx("jle","jge")
  2302. pat cmp tlt call cmxtxx("jae","jbe")
  2303. pat cmp tle call cmxtxx("ja","jb")
  2304. pat cmp teq call cmxtxx("jne","jne")
  2305. pat cmp tne call cmxtxx("je","je")
  2306. pat cmp tge call cmxtxx("jb","ja")
  2307. pat cmp tgt call cmxtxx("jbe","jae")
  2308. pat cms teq $1==2 call cmxtxx("jne","jne")
  2309. pat cms tne $1==2 call cmxtxx("je","je")
  2310. proc cmxzxx example cmp zlt
  2311. with regorconst rm STACK
  2312. gen cmp %2,%1
  2313. jxx[1] {label,$2}
  2314. with rm regorconst STACK
  2315. gen cmp %1,%2
  2316. jxx[2] {label,$2}
  2317. pat cmp zlt call cmxzxx("jb","ja")
  2318. pat cmp zle call cmxzxx("jbe","jae")
  2319. pat cmp zeq call cmxzxx("je","je")
  2320. pat cmp zne call cmxzxx("jne","jne")
  2321. pat cmp zge call cmxzxx("jae","jbe")
  2322. pat cmp zgt call cmxzxx("ja","jb")
  2323. pat cms zeq $1==2 call cmxzxx("je","je")
  2324. pat cms zne $1==2 call cmxzxx("jne","jne")
  2325. proc cmx4zxx example cmi zlt
  2326. with regorconst regorconst rm rm STACK
  2327. gen cmp %4,%2
  2328. jxx[1] {label,$2}
  2329. jne {label,1f}
  2330. cmp %3,%1
  2331. jxx[2] {label,$2}
  2332. 1:
  2333. with rm rm regorconst regorconst STACK
  2334. gen cmp %2,%4
  2335. jxx[3] {label,$2}
  2336. jne {label,1f}
  2337. cmp %1,%3
  2338. jxx[4] {label,$2}
  2339. 1:
  2340. pat cmi zlt $1==4 call cmx4zxx("jl", "jb", "jg", "ja")
  2341. pat cmi zle $1==4 call cmx4zxx("jl", "jbe", "jg", "jae")
  2342. pat cmi zgt $1==4 call cmx4zxx("jg", "ja", "jl", "jb")
  2343. pat cmi zge $1==4 call cmx4zxx("jg", "jae", "jl", "jbe")
  2344. pat cmu zlt $1==4 call cmx4zxx("jb", "jb", "ja", "ja")
  2345. pat cmu zle $1==4 call cmx4zxx("jb", "jbe", "ja", "jae")
  2346. pat cmu zgt $1==4 call cmx4zxx("ja", "ja", "jb", "jb")
  2347. pat cmu zge $1==4 call cmx4zxx("ja", "jae", "jb", "jbe")
  2348. pat ldc cmi zlt highw($1)==0 && loww($1)==0 && $2==4
  2349. with rmorconst rmorconst yields %2 leaving zlt $3
  2350. pat ldc cmi tlt highw($1)==0 && loww($1)==0 && $2==4
  2351. with rmorconst rmorconst yields %2 leaving tlt
  2352. pat ldc cmi zge highw($1)==0 && loww($1)==0 && $2==4
  2353. with rmorconst rmorconst yields %2 leaving zge $3
  2354. pat ldc cmi tge highw($1)==0 && loww($1)==0 && $2==4
  2355. with rmorconst rmorconst yields %2 leaving tge $3
  2356. pat ldc cmi tle highw($1)==0 && loww($1)==0 && $2==4
  2357. with rmorconst rmorconst
  2358. uses REG = {ANYCON, 0}
  2359. gen cmp %a,%2
  2360. jg {label,2f}
  2361. jl {label,1f}
  2362. cmp %a,%1
  2363. jne {label,1f}
  2364. 2:
  2365. inc %a
  2366. 1: yields %a
  2367. pat ldc cmi tgt highw($1)==0 && loww($1)==0 && $2==4
  2368. with rmorconst rmorconst
  2369. uses REG = {ANYCON, 0}
  2370. gen cmp %a,%2
  2371. jl {label,2f}
  2372. jg {label,1f}
  2373. cmp %a,%1
  2374. je {label,1f}
  2375. 2:
  2376. inc %a
  2377. 1: yields %a
  2378. pat loc ldc cms zeq $3==4 && $1==0 && loww($2)==0 && highw($2)==0
  2379. with REG STACK
  2380. gen test %1
  2381. je {label,$4}
  2382. pat loc ldc cms zne $3==4 && $1==0 && loww($2)==0 && highw($2)==0
  2383. with REG STACK
  2384. gen test %1
  2385. jne {label,$4}
  2386. pat loc ldc cms teq $3==4 && $1==0 && loww($2)==0 && highw($2)==0
  2387. with REG
  2388. uses REG = {ANYCON, 0}
  2389. gen test %1
  2390. jne {label,1f}
  2391. inc %a
  2392. 1: yields %a
  2393. pat loc ldc cms tne $3==4 && $1==0 && loww($2)==0 && highw($2)==0
  2394. with REG
  2395. gen test %1
  2396. je {label,1f}
  2397. mov %1,{ANYCON,1}
  2398. 1: yields %1
  2399. pat ldc cms zeq $2==4 && loww($1)==0 && highw($1)==0
  2400. with rmorconst REG STACK
  2401. gen or %2,%1
  2402. je {label,$3}
  2403. with REG rmorconst STACK
  2404. gen or %1,%2
  2405. je {label,$3}
  2406. pat ldc cms zne $2==4 && loww($1)==0 && highw($1)==0
  2407. with rmorconst REG STACK
  2408. gen or %2,%1
  2409. jne {label,$3}
  2410. with REG rmorconst STACK
  2411. gen or %1,%2
  2412. jne {label,$3}
  2413. pat ldc cms teq $2==4 && loww($1)==0 && highw($1)==0
  2414. with rmorconst REG
  2415. uses REG = {ANYCON, 0}
  2416. gen or %2,%1
  2417. jne {label,1f}
  2418. inc %a
  2419. 1: yields %a
  2420. with REG rmorconst
  2421. uses REG = {ANYCON, 0}
  2422. gen or %1,%2
  2423. jne {label,1f}
  2424. inc %a
  2425. 1: yields %a
  2426. pat ldc cms tne $2==4 && loww($1)==0 && highw($1)==0
  2427. with rmorconst REG
  2428. gen or %2,%1
  2429. je {label,1f}
  2430. mov %2,{ANYCON,1}
  2431. 1: yields %2
  2432. with REG rmorconst
  2433. gen or %1,%2
  2434. je {label,1f}
  2435. mov %1,{ANYCON,1}
  2436. 1: yields %1
  2437. pat ldc cms zeq $2==4 && loww($1)==65535 && highw($1)==(0-1)
  2438. with rmorconst REG STACK
  2439. gen and %2,%1
  2440. cmp %2,{ANYCON,0-1}
  2441. je {label,$3}
  2442. with REG rmorconst STACK
  2443. gen and %1,%2
  2444. cmp %1,{ANYCON,0-1}
  2445. je {label,$3}
  2446. pat ldc cms zne $2==4 && loww($1)==65535 && highw($1)==(0-1)
  2447. with rmorconst REG STACK
  2448. gen and %2,%1
  2449. cmp %2,{ANYCON,0-1}
  2450. jne {label,$3}
  2451. with REG rmorconst STACK
  2452. gen and %1,%2
  2453. cmp %1,{ANYCON,0-1}
  2454. jne {label,$3}
  2455. pat cms zne $1==4
  2456. with regorconst regorconst rm rm STACK
  2457. gen cmp %3,%1
  2458. jne {label,$2}
  2459. cmp %4,%2
  2460. jne {label,$2}
  2461. with rm rm regorconst regorconst STACK
  2462. gen cmp %1,%3
  2463. jne {label,$2}
  2464. cmp %2,%4
  2465. jne {label,$2}
  2466. pat cms zeq $1==4
  2467. with regorconst regorconst rm rm STACK
  2468. gen cmp %3,%1
  2469. jne {label, 1f}
  2470. cmp %4,%2
  2471. je {label,$2}
  2472. 1:
  2473. with rm rm regorconst regorconst STACK
  2474. gen cmp %1,%3
  2475. jne {label,1f}
  2476. cmp %2,%4
  2477. je {label,$2}
  2478. 1:
  2479. proc andzxx example and zeq
  2480. with regorconst rm STACK
  2481. gen check %2,%1
  2482. jxx* {label,$2}
  2483. with exact rm regorconst
  2484. kills ALL
  2485. gen check %1,%2
  2486. jxx* {label,$2}
  2487. pat and zeq $1==2 call andzxx("je")
  2488. pat and zne $1==2 call andzxx("jne")
  2489. proc locandzxx example loc and zeq
  2490. with rm12 STACK
  2491. gen testb %1,{ANYCON,$1}
  2492. jxx* {label,$3}
  2493. with GENREG STACK
  2494. gen testb %1.1,{ANYCON,$1}
  2495. jxx* {label,$3}
  2496. with exact IREG
  2497. kills ALL
  2498. gen check %1,{ANYCON,$1}
  2499. jxx* {label,$3}
  2500. pat loc and zeq $1<256 && $1>=0 && $2==2 call locandzxx("je")
  2501. pat loc and zne $1<256 && $1>=0 && $2==2 call locandzxx("jne")
  2502. proc locbxx example loc beq
  2503. with rm1 STACK
  2504. gen cmpb %1,{ANYCON,$1}
  2505. jxx* {label,$2}
  2506. with rm STACK
  2507. gen cmp %1,{ANYCON,$1}
  2508. jxx* {label,$2}
  2509. pat loc beq $1<256 && $1>=0 call locbxx("je")
  2510. pat loc bne $1<256 && $1>=0 call locbxx("jne")
  2511. proc loccmuzxx example loc cmu zeq
  2512. with rm1 STACK
  2513. gen cmpb %1,{ANYCON,$1}
  2514. jxx* {label,$3}
  2515. with rm STACK
  2516. gen cmp %1,{ANYCON,$1}
  2517. jxx* {label,$3}
  2518. pat loc cmu zeq $1<256 && $1>=0 && $2==2 call loccmuzxx("je")
  2519. pat loc cmu zne $1<256 && $1>=0 && $2==2 call loccmuzxx("jne")
  2520. /*******************************************************************
  2521. * Group 13 : Branch Instructions *
  2522. *******************************************************************/
  2523. pat lab topeltsize($1)==2 && !fallthrough($1)
  2524. with STACK
  2525. kills ALL
  2526. gen labeldef $1 yields ax
  2527. pat lab topeltsize($1)==2 && fallthrough($1)
  2528. with ACC STACK
  2529. kills ALL
  2530. gen labeldef $1 yields ax
  2531. pat lab topeltsize($1)!=2
  2532. with STACK
  2533. kills ALL
  2534. gen labeldef $1
  2535. pat bra topeltsize($1)==2
  2536. with ACC STACK
  2537. gen jmp {label,$1}
  2538. pat bra topeltsize($1)!=2
  2539. with STACK
  2540. gen jmp {label,$1}
  2541. proc bxx example blt
  2542. with regorconst rm STACK
  2543. gen cmp %2,%1
  2544. jxx[1] {label,$1}
  2545. with rm regorconst STACK
  2546. gen cmp %1,%2
  2547. jxx[2] {label,$1}
  2548. pat blt call bxx("jl","jg")
  2549. pat ble call bxx("jle","jge")
  2550. pat bge call bxx("jge","jle")
  2551. pat bgt call bxx("jg","jl")
  2552. proc bex example beq
  2553. with regorconst rm STACK
  2554. gen cmp %2,%1
  2555. jxx[1] {label,$1}
  2556. with rm regorconst STACK
  2557. gen cmp %1,%2
  2558. jxx[2] {label,$1}
  2559. with exact rm1 REG1
  2560. kills ALL
  2561. gen cmpb %1,%2
  2562. jxx[2] {label,$1}
  2563. with exact REG1 rm1
  2564. kills ALL
  2565. gen cmpb %2,%1
  2566. jxx[1] {label,$1}
  2567. pat beq call bex("je","je")
  2568. pat bne call bex("jne","jne")
  2569. proc zxx example zlt
  2570. with rm STACK
  2571. gen test %1
  2572. jxx* {label,$1}
  2573. pat zlt call zxx("js")
  2574. pat zge call zxx("jns")
  2575. /* For the next two patterns there is no I8086 test instruction (one that
  2576. ignores the OF flag. Therefore, condition codes are killed and the test
  2577. is done again.
  2578. */
  2579. pat zle
  2580. with rm STACK
  2581. gen killcc.
  2582. test %1
  2583. jle {label,$1}
  2584. pat zgt
  2585. with rm STACK
  2586. gen killcc.
  2587. test %1
  2588. jg {label,$1}
  2589. pat zne
  2590. with rm+rm1 STACK
  2591. gen test %1
  2592. jne {label,$1}
  2593. pat zeq
  2594. with rm+rm1 STACK
  2595. gen test %1
  2596. je {label,$1}
  2597. /*******************************************************************
  2598. * Group 14 : Procedure-call Instructions *
  2599. *******************************************************************/
  2600. pat cal
  2601. kills ALL
  2602. gen joehoe {label,$1}
  2603. pat cai
  2604. with rm
  2605. kills ALL
  2606. gen joehoe %1
  2607. #ifdef REGVARS
  2608. pat lfr adi stl $1==2 && $2==2 && inreg($3) > 0
  2609. kills ALL
  2610. gen pop {LOCAL,$3,2}
  2611. add {LOCAL,$3,2}, ax
  2612. #endif
  2613. pat lfr $1==2 yields ax
  2614. pat lfr $1==4 yields dx ax
  2615. pat lfr $1==6
  2616. kills ALL
  2617. gen joehoe {label, ".lfr6"}
  2618. pat lfr $1==8
  2619. kills ALL
  2620. gen joehoe {label, ".lfr8"}
  2621. pat ret $1==0
  2622. kills ALL
  2623. gen
  2624. #ifdef REGVARS
  2625. return
  2626. #else
  2627. mov sp,bp
  2628. pop bp
  2629. ret.
  2630. #endif
  2631. pat ret $1==2
  2632. with ACC
  2633. kills ALL
  2634. gen
  2635. #ifdef REGVARS
  2636. return
  2637. #else
  2638. mov sp,bp
  2639. pop bp
  2640. ret.
  2641. #endif
  2642. pat ret $1==4
  2643. with ACC DXREG
  2644. kills ALL
  2645. gen
  2646. #ifdef REGVARS
  2647. return
  2648. #else
  2649. mov sp,bp
  2650. pop bp
  2651. ret.
  2652. #endif
  2653. pat ret $1==6
  2654. with STACK
  2655. gen joehoe {label, ".ret6"}
  2656. #ifdef REGVARS
  2657. return
  2658. #else
  2659. mov sp,bp
  2660. pop bp
  2661. ret.
  2662. #endif
  2663. pat ret $1==8
  2664. with STACK
  2665. gen joehoe {label, ".ret8"}
  2666. #ifdef REGVARS
  2667. return
  2668. #else
  2669. mov sp,bp
  2670. pop bp
  2671. ret.
  2672. #endif
  2673. /********************************************************************
  2674. * Group 15 : Miscellaneous Instructions *
  2675. ********************************************************************/
  2676. pat asp $1==2
  2677. with exact a_word
  2678. with STACK
  2679. uses BXREG /* GENREG may contain lfr area */
  2680. gen pop %a
  2681. pat asp $1==4
  2682. with exact a_word a_word
  2683. with STACK
  2684. uses BXREG /* GENREG may contain lfr area */
  2685. gen pop %a
  2686. pop %a
  2687. pat asp $1==0-2
  2688. with STACK yields bp
  2689. pat asp
  2690. with STACK
  2691. gen add sp,{ANYCON,$1}
  2692. pat ass $1==2
  2693. with rmorconst STACK
  2694. gen add sp,%1
  2695. pat ass !defined($1)
  2696. with rm rmorconst STACK
  2697. gen cmp %1,{ANYCON,2}
  2698. jne {label, ".unknown"}
  2699. add sp,%2
  2700. pat blm $1==0 leaving asp 4
  2701. pat blm $1>0
  2702. kills ALL
  2703. gen mov cx,{ANYCON,$1/2}
  2704. joehoe {label, ".blm"}
  2705. pat bls $1==2
  2706. with CXREG
  2707. kills ALL
  2708. gen sar cx,{ANYCON,1}
  2709. joehoe {label, ".blm"}
  2710. pat bls !defined($1)
  2711. with rm-CXREG CXREG
  2712. kills ALL
  2713. gen cmp %1,{ANYCON,2}
  2714. jne {label, ".unknown"}
  2715. sar cx,{ANYCON,1}
  2716. joehoe {label, ".blm"}
  2717. pat lae csa $2==2
  2718. with ACC
  2719. kills ALL
  2720. uses BXREG = { ADDR_EXTERN, $1}
  2721. gen jmp {label, ".csa2"}
  2722. pat csa $1==2
  2723. with BXREG ACC
  2724. kills ALL
  2725. gen jmp {label, ".csa2"}
  2726. pat csa $1==4
  2727. with BXREG ACC DXREG
  2728. kills ALL
  2729. gen jmp {label, ".csa4"}
  2730. pat lae csb $2==2
  2731. with ACC
  2732. kills ALL
  2733. uses BXREG = { ADDR_EXTERN, $1}
  2734. gen jmp {label, ".csb2"}
  2735. pat csb $1==2
  2736. with BXREG ACC
  2737. kills ALL
  2738. gen jmp {label, ".csb2"}
  2739. pat csb $1==4
  2740. with BXREG ACC DXREG
  2741. kills ALL
  2742. gen jmp {label, ".csb4"}
  2743. pat dup $1==2
  2744. with anyreg yields %1 %1
  2745. with ACC1 yields %1 %1
  2746. pat dup $1==4
  2747. with regorconst regorconst yields %2 %1 %2 %1
  2748. pat dup
  2749. kills ALL
  2750. gen mov cx,{ANYCON,$1}
  2751. joehoe {label, ".dup"}
  2752. pat dus $1==2
  2753. with CXREG
  2754. kills ALL
  2755. gen joehoe {label, ".dup"}
  2756. pat dus !defined($1)
  2757. with rm-CXREG CXREG
  2758. kills ALL
  2759. gen cmp %1,{ANYCON,2}
  2760. jne {label, ".unknown"}
  2761. joehoe {label, ".dup"}
  2762. pat exg $1==2
  2763. with a_word a_word yields %1 %2
  2764. pat exg $1==4
  2765. with a_word a_word a_word a_word yields %2 %1 %4 %3
  2766. pat exg defined($1)
  2767. kills ALL
  2768. gen mov cx,{ANYCON,$1}
  2769. joehoe {label, ".exg"}
  2770. pat exg
  2771. with CXREG
  2772. kills ALL
  2773. gen joehoe {label, ".exg"}
  2774. pat gto
  2775. kills ALL
  2776. gen mov bx,{ADDR_EXTERN,$1}
  2777. jmp {label, ".gto"}
  2778. pat fil
  2779. gen mov {EXTERN2,"hol0+4"},{ADDR_EXTERN,$1}
  2780. pat lim
  2781. uses REG
  2782. gen mov %a,{EXTERN2,".ignmask"} yields %a
  2783. pat lin
  2784. gen mov {EXTERN2,"hol0"},{ANYCON,$1}
  2785. pat lni
  2786. gen inc {EXTERN2,"hol0"}
  2787. pat lor $1==0 yields bp
  2788. pat lor $1==1
  2789. with STACK
  2790. uses REG
  2791. gen mov %a,sp yields %a
  2792. pat lor $1==2
  2793. uses REG
  2794. gen mov %a,{EXTERN2,".reghp"} yields %a
  2795. pat mon
  2796. with ACC
  2797. kills ALL
  2798. gen joehoe {label, ".mon"}
  2799. pat nop
  2800. kills ALL
  2801. #if DEBUG
  2802. gen joehoe {label, ".nop"}
  2803. #endif
  2804. pat rck $1==2
  2805. with BXREG ACC
  2806. kills ALL
  2807. gen joehoe {label, ".rck"} yields ax
  2808. pat rck !defined($1)
  2809. with rm-BXREG-ACC BXREG ACC
  2810. kills ALL
  2811. gen cmp %1,{ANYCON,2}
  2812. jne {label, ".unknown"}
  2813. joehoe {label, ".rck"} yields ax
  2814. pat rtt leaving ret 0
  2815. pat sig
  2816. with REG
  2817. gen xchg {EXTERN2,".trppc"},%1 yields %1
  2818. pat sim
  2819. with regorconst
  2820. gen mov {EXTERN2,".ignmask"},%1
  2821. pat str $1==0
  2822. with rmorconst
  2823. gen mov bp,%1
  2824. pat str $1==1
  2825. with rmorconst STACK
  2826. gen mov sp,%1
  2827. pat str $1==2
  2828. kills ALL
  2829. gen joehoe {label, ".strhp"}
  2830. pat trp
  2831. with ACC
  2832. kills ALL
  2833. gen joehoe {label, ".Xtrp"}