table 61 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749
  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 = "$Header$"
  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. ")" .
  86. Rbpreg_off = { AREG reg; INT ind;} 2 cost(1,11) ind "(bp)" "("
  87. reg ")" .
  88. Xreg_off = { AREG reg; ADDR off;} 2 cost(1,9) off "(" reg
  89. ")" .
  90. ind_reg2 = { AREG reg;} 2 cost(0,11) "(" reg ")" .
  91. ind_regoff2 = { AREG reg; ADDR off;} 2 cost(1,15) off "(" reg
  92. ")" .
  93. ind_bpregoff2 = { AREG reg; INT ind;} 2 cost(1,18) ind "(bp)" "("
  94. reg ")" .
  95. ind_reg1 = { AREG reg;} 2 cost(0,11) "(" reg ")" .
  96. ind_regoff1 = { AREG reg; ADDR off;} 2 cost(1,15) off "(" reg
  97. ")" .
  98. ind_bpregoff1 = { AREG reg; INT ind;} 2 cost(1,18) ind "(bp)" "("
  99. reg ")" .
  100. label = { ADDR off;} 2 off .
  101. /*****************************************************************/
  102. SETS
  103. /*****************************************************************/
  104. /* Mode refering to a word in memory */
  105. memory2 = EXTERN2 + ind_reg2 + ind_regoff2 + ind_bpregoff2 +
  106. LOCAL .
  107. memory1 = EXTERN1 + ind_reg1 + ind_regoff1 + ind_bpregoff1 +
  108. LOCAL1 .
  109. const = ANYCON + ADDR_EXTERN + CONSTR .
  110. register = REG + AREG
  111. #ifdef REGVARS
  112. + IREG
  113. #endif
  114. .
  115. addreg = ADDREG
  116. #ifdef REGVARS
  117. + RADDREG
  118. #endif
  119. .
  120. anyreg = register + BREG .
  121. rm = anyreg + memory2 .
  122. rmnoacc = IREG + BXREG + CXREG + memory2 .
  123. rmorconst = const + rm .
  124. regorconst = const + anyreg .
  125. #ifdef REGVARS
  126. /* Needed because there is a shortage of ADDREG-registers.
  127. This is the main penalty for having register variables.
  128. */
  129. regorconstnoaddr = const + IREG + ACC + CXREG + DXREG .
  130. #else
  131. regorconstnoaddr = regorconst .
  132. #endif
  133. dest = register + memory2 .
  134. rm1 = REG1 + memory1 .
  135. rmorconst1 = const + rm1 .
  136. regorconst12 = REG1 + GENREG + const .
  137. dest1 = REG1 + memory1 .
  138. rm12 = rm1 + memory2 .
  139. /* Modes used to indicate tokens to be removed from the fakestack */
  140. reg_indexed = ind_reg2 + ind_regoff2 + ind_reg1 + ind_regoff1 .
  141. lb_indexed = ind_bpregoff2 + ind_bpregoff1 .
  142. indexed = reg_indexed + lb_indexed .
  143. externals = EXTERN2 + EXTERN1 .
  144. locals = LOCAL + LOCAL1 .
  145. all_locals = locals + lb_indexed .
  146. indirects = externals + reg_indexed .
  147. referals = indirects + locals .
  148. /* Miscellaneous */
  149. reg_off = Xreg_off + Rreg_off .
  150. bpreg_off = Rbpreg_off .
  151. halfindir = reg_off + bpreg_off + ADDR_LOCAL .
  152. some_off = halfindir + ADDR_EXTERN + addreg .
  153. a_word = rmorconst + rm1 + halfindir .
  154. no_reg_off = rmorconst + rm1 + ADDR_LOCAL .
  155. /*****************************************************************/
  156. INSTRUCTIONS
  157. /*****************************************************************/
  158. cost(1,3)
  159. adc rm:rw:cc, regorconst:ro.
  160. adc anyreg:rw:cc, rmorconst:ro.
  161. #ifdef REGVARS
  162. add LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  163. #endif
  164. add anyreg:rw:cc, a_word:ro.
  165. add memory2:rw:cc, regorconst:ro.
  166. #ifdef REGVARS
  167. and LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  168. #endif
  169. and rm:rw:cc, regorconst:ro.
  170. and anyreg:rw:cc, rmorconst:ro.
  171. cbw kills ah cost(1,2).
  172. cmp rm:ro, regorconst:ro kills :cc.
  173. cmp anyreg:ro, rmorconst:ro kills :cc.
  174. cmpb rm1:rw, const:ro kills :cc.
  175. cwd kills dx cost(1,5).
  176. dec rm:rw:cc cost(1,2).
  177. div rm:ro kills:cc ax dx cost(1,150).
  178. idiv rm:ro kills:cc ax dx cost(1,170).
  179. inc rm:rw:cc cost(1,2).
  180. ja label cost(1,4).
  181. jae label cost(1,4).
  182. jb label cost(1,4).
  183. jbe label cost(1,4).
  184. jcxz label cost(1,5).
  185. je label cost(1,4).
  186. jg label cost(1,4).
  187. jge label cost(1,4).
  188. jl label cost(1,4).
  189. jle label cost(1,4).
  190. jne label cost(1,4).
  191. jmp label cost(1,7).
  192. joehoe "call" label+rm cost(1,8).
  193. jxx "syntax error" label.
  194. lea anyreg:wo, halfindir:ro cost(1,2).
  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+rm1:wo cost(1,8).
  215. push rmorconst+rm1:ro cost(1,10).
  216. rcl rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  217. rcr rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  218. ret cost(1,8).
  219. rol rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  220. ror rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  221. sal rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  222. sar rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  223. sbb rm:rw:cc, regorconst:ro.
  224. sbb anyreg:rw:cc, rmorconst:ro.
  225. shl rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  226. shr rm:rw:cc, ANYCON+SHIFT_CREG:ro.
  227. #ifdef REGVARS
  228. sub LOCAL:rw:cc, rmorconst:ro. /* only for register variables; UNSAFE !!! */
  229. #endif
  230. sub rm:rw:cc, regorconst:ro.
  231. sub anyreg:rw:cc, rmorconst+halfindir:ro.
  232. check "test" rm:ro, regorconst:ro kills :cc.
  233. check "test" anyreg:ro, rmorconst:ro kills :cc.
  234. testb "testb" rm12:ro, regorconst:ro kills :cc.
  235. testb "testb" REG1:ro, rmorconst:ro kills :cc.
  236. testb "testb" ACC1:ro, const:ro kills :cc.
  237. xchg rm:rw, anyreg:rw.
  238. xchg anyreg:rw, rm:rw.
  239. xor rm:rw:cc, regorconst:ro.
  240. xor anyreg:rw:cc, rmorconst:ro.
  241. xorb rm1:rw:cc, regorconst12:ro.
  242. xorb anyreg:rw:cc, rm1:ro.
  243. killreg "! kill" anyreg:wo cost(0,0).
  244. data ".sect .data".
  245. word ".data2" const:ro.
  246. text ".sect .text".
  247. /*****************************************************************/
  248. MOVES
  249. /*****************************************************************/
  250. #ifdef REGVARS
  251. from memory2 to LOCAL /* unsafe !!! */
  252. gen mov %2,%1
  253. #endif
  254. from rm to register
  255. gen mov %2,%1
  256. from anyreg to dest
  257. gen mov %2,%1
  258. from halfindir to register+AREG
  259. gen lea %2,%1
  260. from rm1 to REG1
  261. gen movb %2,%1
  262. from GENREG to rm1
  263. gen movb %2,%1.1
  264. from ANYCON %val==0 to register
  265. gen xor %2,%2
  266. from ANYCON %val==0 to REG1
  267. gen xorb %2,%2
  268. from const to dest
  269. gen mov %2,%1
  270. from const+REG1 to rm1
  271. gen movb %2,%1
  272. /*****************************************************************/
  273. TESTS
  274. /*****************************************************************/
  275. to test anyreg
  276. gen OR %1,%1
  277. to test memory2
  278. gen cmp %1, {ANYCON,0}
  279. to test REG1
  280. gen ORB %1,%1
  281. to test memory1
  282. gen cmpb %1, {ANYCON,0}
  283. /*****************************************************************/
  284. STACKINGRULES
  285. /*****************************************************************/
  286. from anyreg to STACK
  287. gen push %1
  288. from memory2 to STACK
  289. gen push %1
  290. from const to STACK
  291. uses REG
  292. gen move %1,%a
  293. push %a
  294. from const to STACK
  295. gen data.
  296. 1:
  297. word %1
  298. text.
  299. push {EXTERN2,"1b"}
  300. from rm1 to STACK
  301. uses GENREG
  302. gen move {ANYCON,0},%a
  303. move %1,%a.1
  304. push %a
  305. from rm1 to STACK
  306. gen push %1
  307. push bx
  308. mov bx,sp
  309. movb {ind_regoff1,bx,3},{ANYCON,0}
  310. pop bx
  311. from Xreg_off to STACK
  312. gen add %1.reg,{CONSTR,%1.off}
  313. push %1.reg
  314. from ADDR_LOCAL %ind==0 to STACK
  315. gen
  316. push bp
  317. from halfindir to STACK
  318. uses REG
  319. gen move %1,%a
  320. push %a
  321. from halfindir to STACK
  322. gen push ax
  323. push bx
  324. lea ax,%1
  325. mov bx,sp
  326. xchg {ind_regoff2,bx,2},ax
  327. pop bx
  328. /*****************************************************************/
  329. COERCIONS
  330. /*****************************************************************/
  331. /***************************
  332. * From source to register *
  333. ***************************/
  334. from rmorconst
  335. uses reusing %1,REG=%1 yields %a
  336. from Xreg_off
  337. gen add %1.reg,{CONSTR,%1.off} yields %1.reg
  338. from halfindir
  339. uses reusing %1,ADDREG
  340. gen move %1,%a yields %a
  341. from halfindir
  342. uses REG
  343. gen move %1,%a yields %a
  344. /************************
  345. * From source to token *
  346. ************************/
  347. from ANYCON yields {ADDR_EXTERN,%1.val}
  348. /****************
  349. * From source1 *
  350. ****************/
  351. from rm1
  352. uses reusing %1,REG1=%1 yields %a
  353. from rm1
  354. uses reusing %1,GENREG
  355. gen move %1,%a.1
  356. xorb %a.2,%a.2 yields %a
  357. from ACC1
  358. uses reusing %1,ACC
  359. gen xorb %a.2,%a.2 yields %a
  360. /************************
  361. * From STACK coercions *
  362. ************************/
  363. from STACK
  364. uses REG
  365. gen pop %a yields %a
  366. /*****************************************************************/
  367. PATTERNS
  368. /*****************************************************************/
  369. /******************************************************************
  370. * Group 1 : Load Instructions *
  371. ******************************************************************/
  372. pat loc yields {ANYCON,$1}
  373. pat ldc yields {ANYCON,highw($1)}
  374. {ANYCON,loww($1)}
  375. pat lol yields {LOCAL,$1,2}
  376. pat lol lol $1==$2
  377. #ifdef REGVARS
  378. && inreg($1) <= 0
  379. #endif
  380. uses GENREG = {LOCAL, $1, 2} yields %a %a
  381. pat loe yields {EXTERN2,$1}
  382. pat loe loe $1==$2
  383. uses GENREG = {EXTERN2, $1} yields %a %a
  384. #ifdef REGVARS
  385. pat lil inreg($1) > 0 yields {ind_reg2, regvar($1)}
  386. #endif
  387. pat lil
  388. uses ADDREG={ind_regoff2,bp,$1} yields {ind_reg2,%a}
  389. pat lof
  390. with exact reg_off yields {ind_regoff2,%1.reg,%1.off+$1}
  391. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+$1}
  392. with exact ADDR_EXTERN yields {EXTERN2,%1.off+$1}
  393. with exact ADDR_LOCAL yields {LOCAL,%1.ind + $1,2}
  394. with addreg yields {ind_regoff2,%1,$1}
  395. pat lal yields {ADDR_LOCAL,$1}
  396. pat lae yields {ADDR_EXTERN,$1}
  397. pat lpb leaving adp SL
  398. pat lxl $1==0 yields {ADDR_LOCAL,0}
  399. pat lxl $1==1 yields {LOCAL,SL,2}
  400. pat lxl $1==2
  401. uses ADDREG={ind_regoff2,bp,SSL} yields {ind_regoff2,%a,SSL}
  402. pat lxl $1>2
  403. uses ADDREG={ind_regoff2,bp,SSL},
  404. CXREG={ANYCON,$1-1}
  405. gen 1:
  406. mov %a,{ind_regoff2,%a,4}
  407. loop {label,1b} yields %a
  408. pat lxa $1==0 yields {ADDR_LOCAL,SL}
  409. pat lxa $1==1
  410. uses ADDREG={ind_regoff2,bp,SSL} yields {Xreg_off,%a,SSL}
  411. pat lxa $1==2
  412. uses ADDREG={ind_regoff2,bp,SSL}
  413. gen move {ind_regoff2,%a,SSL},%a yields {Xreg_off,%a,SSL}
  414. pat lxa $1>2
  415. uses ADDREG={ind_regoff2,bp,SSL},
  416. CXREG={ANYCON,$1-1}
  417. gen 1:
  418. mov %a,{ind_regoff2,%a,4}
  419. loop {label,1b} yields {Xreg_off,%a,SSL}
  420. pat dch leaving loi 2
  421. pat loi $1==2
  422. with addreg yields {ind_reg2,%1}
  423. with exact reg_off yields {ind_regoff2,%1.reg,%1.off}
  424. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind}
  425. with exact ADDR_EXTERN yields {EXTERN2,%1.off}
  426. with exact ADDR_LOCAL yields {LOCAL,%1.ind,2}
  427. pat loi $1==1
  428. with addreg yields {ind_reg1,%1}
  429. with exact reg_off yields {ind_regoff1,%1.reg,%1.off}
  430. with exact bpreg_off yields {ind_bpregoff1,%1.reg,%1.ind}
  431. with exact ADDR_EXTERN yields {EXTERN1,%1.off}
  432. with exact ADDR_LOCAL yields {LOCAL1,%1.ind,1}
  433. pat loi $1==4
  434. with addreg yields {ind_regoff2,%1,2}
  435. {ind_reg2,%1}
  436. with exact reg_off yields {ind_regoff2,%1.reg,%1.off+2}
  437. {ind_regoff2,%1.reg,%1.off}
  438. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+2}
  439. {ind_bpregoff2,%1.reg,%1.ind}
  440. with exact ADDR_LOCAL yields {LOCAL,%1.ind+2,2}
  441. {LOCAL,%1.ind,2}
  442. with exact ADDR_EXTERN yields {EXTERN2,%1.off + 2}
  443. {EXTERN2,%1.off}
  444. pat loi $1>4
  445. with BXREG
  446. kills ALL
  447. gen mov cx,{ANYCON,$1}
  448. joehoe {label,".loi"}
  449. pat los $1==2
  450. with CXREG BXREG
  451. kills ALL
  452. gen joehoe {label,".loi"}
  453. pat los !defined($1)
  454. with rm CXREG BXREG
  455. kills ALL
  456. gen cmp %1,{ANYCON,2}
  457. jne {label,".unknown"}
  458. joehoe {label,".loi"}
  459. pat ldl yields {LOCAL,$1+2,2}
  460. {LOCAL,$1,2}
  461. pat lde yields {EXTERN2,$1 + 2}
  462. {EXTERN2,$1}
  463. pat ldf
  464. with exact reg_off yields {ind_regoff2,%1.reg,
  465. %1.off + 2 + $1}
  466. {ind_regoff2,%1.reg,
  467. %1.off + $1}
  468. with addreg yields {ind_regoff2,%1,$1+2}
  469. {ind_regoff2,%1,$1}
  470. with exact bpreg_off yields {ind_bpregoff2,%1.reg,%1.ind+2+$1}
  471. {ind_bpregoff2,%1.reg,%1.ind+$1}
  472. with exact ADDR_EXTERN yields {EXTERN2,%1.off+2+$1}
  473. {EXTERN2,%1.off+$1}
  474. with exact ADDR_LOCAL yields {LOCAL,%1.ind + $1 + 2,2}
  475. {LOCAL,%1.ind + $1,2}
  476. pat lpi yields {ADDR_EXTERN,$1}
  477. /* this code sequence is generated by the C-compiler to tackle
  478. char parameters, on the 8086 it reduces to nil */
  479. pat lol lal sti $1==$2 && $3<=2
  480. /*******************************************************************
  481. * Group 2 : Store Instructions *
  482. *******************************************************************/
  483. #ifdef REGVARS
  484. pat stl inreg($1)==reg_any
  485. with rmorconst
  486. kills regvar($1)
  487. gen move %1, {LOCAL,$1,2}
  488. with exact STACK
  489. kills regvar($1)
  490. gen pop {LOCAL, $1, 2}
  491. #endif
  492. pat stl
  493. with regorconst
  494. kills indexed,locals %ind>=$1 && %ind<$1+2
  495. gen move %1,{ind_regoff2,bp,$1}
  496. with exact STACK
  497. kills ALL
  498. gen pop {ind_regoff2,bp,$1}
  499. pat ste
  500. with regorconst
  501. kills indirects
  502. gen move %1,{EXTERN2,$1}
  503. with exact STACK
  504. kills ALL
  505. gen pop {EXTERN2,$1}
  506. #ifdef REGVARS
  507. pat sil inreg($1)==reg_any
  508. with regorconst
  509. kills referals
  510. gen move %1,{ind_reg2,regvar($1)}
  511. with exact STACK
  512. kills ALL
  513. gen pop {ind_reg2,regvar($1)}
  514. #endif
  515. pat sil
  516. with regorconstnoaddr
  517. kills referals
  518. uses ADDREG={ind_regoff2,bp,$1}
  519. gen move %1,{ind_reg2,%a}
  520. killreg %a
  521. with exact STACK
  522. kills ALL
  523. uses ADDREG={ind_regoff2,bp,$1}
  524. gen pop {ind_reg2,%a}
  525. killreg %a
  526. pat stf
  527. with addreg regorconst
  528. kills referals
  529. gen move %2,{ind_regoff2,%1,$1}
  530. with exact addreg STACK
  531. kills ALL
  532. gen pop {ind_regoff2, %1,$1}
  533. with reg_off regorconst
  534. kills referals
  535. gen move %2,{ind_regoff2,%1.reg,%1.off+$1}
  536. with exact reg_off STACK
  537. gen pop {ind_regoff2,%1.reg,$1+%1.off}
  538. with exact bpreg_off STACK
  539. gen pop {ind_bpregoff2,%1.reg,$1+%1.ind}
  540. with exact ADDR_LOCAL leaving stl %1.ind+$1
  541. with bpreg_off regorconst
  542. kills all_locals,indexed
  543. gen move %2,{ind_bpregoff2,%1.reg,%1.ind+$1}
  544. with ADDR_EXTERN regorconst
  545. kills indirects
  546. gen move %2,{EXTERN2,%1.off+$1}
  547. with exact ADDR_EXTERN STACK
  548. kills indirects
  549. gen pop {EXTERN2,%1.off+$1}
  550. pat sti $1==2
  551. with addreg regorconst
  552. kills referals
  553. gen move %2,{ind_reg2,%1}
  554. with exact addreg STACK
  555. kills ALL
  556. gen pop {ind_reg2,%1}
  557. with reg_off regorconst
  558. kills referals
  559. gen move %2,{ind_regoff2,%1.reg,%1.off}
  560. with exact reg_off STACK
  561. kills ALL
  562. gen pop {ind_regoff2,%1.reg,%1.off}
  563. with exact ADDR_LOCAL leaving stl %1.ind
  564. with bpreg_off regorconst
  565. kills all_locals,indexed
  566. gen move %2,{ind_bpregoff2,%1.reg,%1.ind}
  567. with exact bpreg_off STACK
  568. gen pop {ind_bpregoff2,%1.reg,%1.ind}
  569. with exact ADDR_EXTERN leaving ste %1.off
  570. pat sti $1==1
  571. with addreg regorconst12
  572. kills referals
  573. gen move %2,{ind_reg1,%1}
  574. with reg_off regorconst12
  575. kills referals
  576. gen move %2,{ind_regoff1,%1.reg,%1.off}
  577. with bpreg_off regorconst12
  578. kills all_locals,indexed
  579. gen move %2,{ind_bpregoff1,%1.reg,%1.ind}
  580. with ADDR_EXTERN regorconst12
  581. kills indirects
  582. gen move %2,{EXTERN1,%1.off}
  583. with ADDR_LOCAL regorconst12
  584. kills indexed,locals %ind<=%1.ind && %ind+%size>%1.ind
  585. gen move %2,{ind_regoff1,bp,%1.ind}
  586. pat sti $1==4
  587. with addreg regorconst regorconst
  588. kills referals
  589. gen move %2,{ind_reg2,%1}
  590. move %3,{ind_regoff2,%1,2}
  591. with exact addreg STACK
  592. kills referals
  593. gen pop {ind_reg2,%1}
  594. pop {ind_regoff2,%1,2}
  595. with reg_off regorconst regorconst
  596. kills referals
  597. gen move %2,{ind_regoff2,%1.reg,%1.off}
  598. move %3,{ind_regoff2,%1.reg,%1.off+2}
  599. with exact reg_off STACK
  600. kills referals
  601. gen pop {ind_regoff2,%1.reg,%1.off}
  602. pop {ind_regoff2,%1.reg,%1.off+2}
  603. with bpreg_off regorconst regorconst
  604. kills all_locals,indexed
  605. gen move %2,{ind_bpregoff2,%1.reg,%1.ind}
  606. move %3,{ind_bpregoff2,%1.reg,%1.ind+2}
  607. with exact bpreg_off STACK
  608. kills all_locals,indexed
  609. gen pop {ind_bpregoff2,%1.reg,%1.ind}
  610. pop {ind_bpregoff2,%1.reg,%1.ind+2}
  611. with exact ADDR_EXTERN leaving sde %1.off
  612. with exact ADDR_LOCAL leaving sdl %1.ind
  613. pat sti $1>4
  614. with BXREG
  615. kills ALL
  616. gen mov cx,{ANYCON,$1}
  617. joehoe {label, ".sti"}
  618. /* this sort of construction gives problems in the codegenerator
  619. because of the potential very large lookahead
  620. with addreg
  621. kills ALL
  622. gen pop (%1)
  623. add %1,{ANYCON,2} yields %1 leaving sti $1-2
  624. */
  625. pat sts $1==2
  626. with CXREG BXREG
  627. kills ALL
  628. gen joehoe {label,".sti"}
  629. pat sdl
  630. with regorconst regorconst yields %2 %1
  631. leaving stl $1 stl $1+2
  632. with exact STACK leaving stl $1 stl $1+2
  633. pat sde
  634. with regorconst regorconst yields %2 %1
  635. leaving ste $1 ste $1+2
  636. with exact STACK leaving ste $1 ste $1+2
  637. pat sdf
  638. with addreg regorconst regorconst
  639. kills referals
  640. gen move %2,{ind_regoff2,%1,$1}
  641. move %3,{ind_regoff2,%1,$1+2}
  642. with exact addreg STACK
  643. kills ALL
  644. gen pop {ind_regoff2,%1,$1}
  645. pop {ind_regoff2,%1,$1+2}
  646. with reg_off regorconst regorconst
  647. kills referals
  648. gen move %2,{ind_regoff2,%1.reg,%1.off+$1}
  649. move %3,{ind_regoff2,%1.reg,%1.off+$1+2}
  650. with exact reg_off STACK
  651. kills ALL
  652. gen pop {ind_regoff2,%1.reg,$1+%1.off}
  653. pop {ind_regoff2,%1.reg,$1+2+%1.off}
  654. with exact bpreg_off STACK
  655. kills ALL
  656. gen pop {ind_bpregoff2, %1.reg,$1+%1.ind}
  657. pop {ind_bpregoff2, %1.reg,$1+2+%1.ind}
  658. /* Funny things happen when the sign changes in the stl parameters */
  659. with exact ADDR_LOCAL leaving stl %1.ind+$1
  660. stl %1.ind+$1+2
  661. with exact ADDR_EXTERN leaving sde %1.off+$1
  662. with bpreg_off regorconst regorconst
  663. kills all_locals,indexed
  664. gen move %2,{ind_bpregoff2,%1.reg,%1.ind+$1}
  665. move %3,{ind_bpregoff2,%1.reg,%1.ind+$1+2}
  666. with halfindir regorconst
  667. kills referals
  668. gen mov %1,%2 yields %1 leaving stf $1+2
  669. /****************************************************************
  670. * Group 3 : Integer Arithmetic. *
  671. * *
  672. * Implemented (sometimes with the use of subroutines) : *
  673. * all 2 and 4 byte arithmetic. *
  674. ****************************************************************/
  675. pat adi $1==2
  676. with EXACT REG rmorconst
  677. gen add %1,%2 yields %1
  678. with rmorconst REG
  679. gen add %2,%1 yields %2
  680. with EXACT rmorconst const
  681. uses reusing %1,REG=%1
  682. gen add %a,%2 yields %a
  683. pat adi $1==4
  684. with EXACT REG REG rmorconst rmorconst
  685. gen add %1,%3
  686. adc %2,%4 yields %2 %1
  687. with rmorconst rmorconst REG REG
  688. gen add %3,%1
  689. adc %4,%2 yields %4 %3
  690. pat adi !defined($1)
  691. with CXREG ACC
  692. kills ALL
  693. gen joehoe {label,".adi"} yields ax
  694. pat sbi $1==2
  695. with rmorconst REG
  696. gen sub %2,%1 yields %2
  697. with EXACT REG rmorconst
  698. gen sub %1,%2
  699. neg %1 yields %1
  700. pat sbi $1==4
  701. with rmorconst rmorconst REG REG
  702. gen sub %3,%1
  703. sbb %4,%2 yields %4 %3
  704. pat sbi !defined($1)
  705. with CXREG ACC
  706. kills ALL
  707. gen joehoe {label,".sbi"} yields ax
  708. pat mli $1==2
  709. with ACC rm
  710. uses reusing %2,DXREG
  711. gen mul %2 yields %1
  712. /* mul and imul have same low order result
  713. but mul is faster
  714. */
  715. with rmnoacc rmorconst
  716. uses reusing %2,DXREG,ACC=%2
  717. gen mul %1 yields %b
  718. pat mli $1==4
  719. with ACC DXREG
  720. kills ALL
  721. gen joehoe {label,".mli4"} yields dx ax
  722. /*
  723. pat mli !defined($1)
  724. with ACC
  725. kills ALL
  726. gen joehoe {label,".mli"}
  727. */
  728. pat dvi $1==2
  729. with rmnoacc rmorconst
  730. uses reusing %2,DXREG,ACC=%2
  731. gen cwd.
  732. idiv %1 yields ax
  733. pat dvi $1==4
  734. kills ALL
  735. gen joehoe {label,".dvi4"} yields dx ax
  736. /*
  737. pat dvi !defined($1)
  738. with ACC
  739. kills ALL
  740. gen joehoe {label,".dvi"}
  741. */
  742. pat rmi $1==2
  743. with rmnoacc rmorconst
  744. uses reusing %2, ACC=%2, DXREG
  745. gen cwd.
  746. idiv %1 yields dx
  747. pat rmi $1==4
  748. kills ALL
  749. gen joehoe {label,".rmi4"} yields dx ax
  750. /*
  751. pat rmi !defined($1)
  752. with ACC
  753. kills ALL
  754. gen joehoe {label,".rmi"}
  755. */
  756. pat ngi $1==2
  757. with REG
  758. gen neg %1 yields %1
  759. pat ngi $1==4
  760. with REG REG
  761. gen neg %2
  762. neg %1
  763. sbb %2,{ANYCON,0} yields %2 %1
  764. /*
  765. pat ngi !defined($1)
  766. with ACC
  767. kills ALL
  768. gen joehoe {label,".ngi"}
  769. */
  770. pat loc sli $1==1 && $2==2
  771. with REG
  772. gen sal %1,{ANYCON,1} yields %1
  773. pat loc sli $1==1 && $2==4
  774. with REG REG
  775. gen sal %1,{ANYCON,1}
  776. rcl %2,{ANYCON,1} yields %2 %1
  777. pat loc sli $1==16 && $2==4
  778. with rmorconst rmorconst yields %1 {ANYCON,0}
  779. pat sli $1==2
  780. with SHIFT_CREG REG
  781. gen sal %2,cl yields %2
  782. pat sli $1==4
  783. with CXREG REG REG
  784. gen jcxz {label,1f}
  785. 2:
  786. sal %2,{ANYCON,1}
  787. rcl %3,{ANYCON,1}
  788. loop {label,2b}
  789. 1:
  790. yields %3 %2
  791. /*
  792. pat sli !defined($1)
  793. with ACC
  794. kills ALL
  795. gen joehoe {label,".sli"}
  796. */
  797. pat loc sri $1==1 && $2==2
  798. with REG
  799. gen sar %1,{ANYCON,1} yields %1
  800. pat loc sri $1==1 && $2==4
  801. with REG REG
  802. gen sar %2,{ANYCON,1}
  803. rcr %1,{ANYCON,1} yields %2 %1
  804. pat sri $1==2
  805. with SHIFT_CREG REG
  806. gen sar %2,cl yields %2
  807. pat sri $1==4
  808. with CXREG REG REG
  809. gen jcxz {label,1f}
  810. 2:
  811. sar %3,{ANYCON,1}
  812. rcr %2,{ANYCON,1}
  813. loop {label,2b}
  814. 1:
  815. yields %3 %2
  816. /*
  817. pat sri !defined($1)
  818. with ACC
  819. kills ALL
  820. gen joehoe {label,".sri"}
  821. */
  822. /*******************************************************************
  823. * Group 4: Unsigned Arithmetic *
  824. *******************************************************************/
  825. pat adu leaving adi $1
  826. pat sbu leaving sbi $1
  827. pat mlu leaving mli $1
  828. pat dvu $1==2
  829. with rmnoacc rmorconst
  830. uses reusing %2, ACC=%2, DXREG={ANYCON,0}
  831. gen div %1 yields ax
  832. pat dvu $1==4
  833. kills ALL
  834. gen joehoe {label,".dvu4"} yields dx ax
  835. /*
  836. pat dvu !defined($1)
  837. with ACC STACK
  838. kills ALL
  839. gen joehoe {label,".dvu"}
  840. */
  841. pat rmu $1==2
  842. with rmnoacc rmorconst
  843. uses reusing %2, ACC=%2, DXREG={ANYCON,0}
  844. gen div %1 yields dx
  845. pat rmu $1==4
  846. kills ALL
  847. gen joehoe {label,".rmu4"} yields dx ax
  848. /*
  849. pat rmu !defined($1)
  850. with ACC STACK
  851. kills ALL
  852. gen joehoe {label,".rmu"}
  853. */
  854. pat slu leaving sli $1
  855. pat loc slu leaving loc $1 sli $2
  856. pat lol loc slu leaving lol $1 loc $2 sli $3
  857. pat loc sru $1==1 && $2==2
  858. with REG
  859. gen shr %1,{ANYCON, 1} yields %1
  860. pat loc sru $1==16 && $2==4
  861. with rmorconst rmorconst yields {ANYCON,0} %2
  862. pat sru $1==2
  863. with SHIFT_CREG REG
  864. gen shr %2,cl yields %2
  865. pat sru $1==4
  866. with CXREG REG REG
  867. gen jcxz {label,1f}
  868. 2:
  869. shr %3,{ANYCON, 1}
  870. rcr %2,{ANYCON, 1}
  871. loop {label,2b}
  872. 1: yields %3 %2
  873. /*
  874. pat sru !defined($1)
  875. with ACC STACK
  876. kills ALL
  877. gen joehoe {label,".sru"}
  878. */
  879. /*******************************************************************
  880. * Group 5: Floating Point Instructions *
  881. *******************************************************************/
  882. pat adf $1==4 leaving cal ".adf4" asp 4
  883. pat adf $1==8 leaving cal ".adf8" asp 8
  884. pat sbf $1==4 leaving cal ".sbf4" asp 4
  885. pat sbf $1==8 leaving cal ".sbf8" asp 8
  886. pat mlf $1==4 leaving cal ".mlf4" asp 4
  887. pat mlf $1==8 leaving cal ".mlf8" asp 8
  888. pat dvf $1==4 leaving cal ".dvf4" asp 4
  889. pat dvf $1==8 leaving cal ".dvf8" asp 8
  890. pat ngf $1==4 leaving cal ".ngf4"
  891. pat ngf $1==8 leaving cal ".ngf8"
  892. pat fif $1==4 leaving cal ".fif4"
  893. pat fif $1==8 leaving cal ".fif8"
  894. pat fef $1==4
  895. with REG REG
  896. kills ALL
  897. gen push %2
  898. push %2
  899. push %1 leaving cal ".fef4"
  900. pat fef $1==8
  901. with REG REG REG REG
  902. kills ALL
  903. gen push %4
  904. push %4
  905. push %3
  906. push %2
  907. push %1 leaving cal ".fef8"
  908. /******************************************************************
  909. * Group 6: Pointer Arithmetic *
  910. ******************************************************************/
  911. pat adp $1==1
  912. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  913. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  914. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  915. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  916. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  917. with REG
  918. gen inc %1 yields %1
  919. with ADDREG
  920. gen killreg %1
  921. yields {Xreg_off, %1, $1}
  922. with exact RADDREG yields {Rreg_off, %1, $1}
  923. pat adp $1==0-1
  924. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  925. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  926. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  927. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  928. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  929. with REG
  930. gen dec %1 yields %1
  931. with ADDREG
  932. gen killreg %1
  933. yields {Xreg_off, %1, $1}
  934. with exact RADDREG yields {Rreg_off, %1, $1}
  935. pat adp
  936. with exact Xreg_off yields {Xreg_off,%1.reg,%1.off+$1}
  937. with exact Rreg_off yields {Rreg_off,%1.reg,%1.off+$1}
  938. with exact ADDR_EXTERN yields {ADDR_EXTERN,%1.off+$1}
  939. with exact ADDR_LOCAL yields {ADDR_LOCAL,%1.ind+$1}
  940. with exact Rbpreg_off yields {Rbpreg_off,%1.reg,%1.ind+$1}
  941. with ADDREG
  942. gen killreg %1
  943. yields {Xreg_off,%1,$1}
  944. with exact RADDREG yields {Rreg_off, %1, $1}
  945. with REG
  946. gen add %1,{ANYCON,$1} yields %1
  947. pat ads $1==2
  948. with exact ANYCON Rreg_off
  949. yields {Rreg_off,%2.reg,%2.off+%1.val}
  950. with exact ANYCON Xreg_off
  951. yields {Xreg_off,%2.reg,%2.off+%1.val}
  952. with exact ADDR_EXTERN Rreg_off
  953. yields {Rreg_off,%2.reg,%2.off+%1.off}
  954. with exact ADDR_EXTERN Xreg_off
  955. yields {Xreg_off,%2.reg,%2.off+%1.off}
  956. with rmorconst Xreg_off
  957. gen add %2.reg,%1 yields %2
  958. with exact ANYCON Rbpreg_off
  959. yields {Rbpreg_off,%2.reg,%2.ind+%1.val}
  960. with Xreg_off rmorconst
  961. gen add %1.reg,%2 yields %1
  962. with exact Xreg_off ANYCON
  963. yields {Xreg_off,%1.reg,%1.off+%2.val}
  964. with exact Rreg_off ANYCON
  965. yields {Rreg_off,%1.reg,%1.off+%2.val}
  966. with exact Xreg_off ADDR_EXTERN
  967. yields {Xreg_off,%1.reg,%1.off+%2.off}
  968. with exact Rreg_off ADDR_EXTERN
  969. yields {Rreg_off,%1.reg,%1.off+%2.off}
  970. with exact Xreg_off reg_off
  971. gen add %1.reg,%2.reg
  972. yields {Xreg_off,%1.reg,%1.off+%2.off}
  973. with exact IREG ADDR_LOCAL
  974. yields {Rbpreg_off, %1, %2.ind}
  975. with exact IREG ADDR_EXTERN
  976. yields {Rreg_off, %1, %2.off}
  977. with exact ADDR_EXTERN IREG
  978. yields {Rreg_off,%2,%1.off}
  979. with exact ADDR_LOCAL IREG
  980. yields {Rbpreg_off,%2,%1.ind}
  981. with exact rmorconst ADDR_EXTERN
  982. uses reusing %1,ADDREG=%1
  983. yields {Xreg_off,%a,%2.off}
  984. with exact ADDR_EXTERN rmorconst
  985. uses reusing %2,ADDREG=%2
  986. yields {Xreg_off,%a,%1.off}
  987. with rm ADDREG
  988. gen add %2,%1 yields %2
  989. with ADDREG rm
  990. gen add %1,%2 yields %1
  991. pat sbs $1==2
  992. with exact ANYCON Xreg_off
  993. yields {Xreg_off,%2.reg,%2.off+"-"+%1.val}
  994. with exact ANYCON Rreg_off
  995. yields {Rreg_off,%2.reg,%2.off+"-"+%1.val}
  996. with exact ANYCON ADDR_LOCAL
  997. yields {ADDR_LOCAL,%2.ind-%1.val}
  998. with rm Xreg_off
  999. gen sub %2.reg,%1 yields {Xreg_off,%2.reg,%2.off}
  1000. /* Should not occur
  1001. with exact reg_off ANYCON
  1002. yields {reg_off,%1.reg,%1.off-%2.val}
  1003. with ANYCON ADDR_EXTERN
  1004. yields {ADDR_EXTERN,%2.off+%1.val}
  1005. with exact ANYCON ADDR_LOCAL
  1006. yields {ADDR_LOCAL,%1.val+%2.ind}
  1007. */
  1008. with rm REG
  1009. gen sub %2,%1 yields %2
  1010. with const ACC
  1011. gen sub %2,%1 yields %2
  1012. /*******************************************************************
  1013. * Group 7 : Increment/Decrement Zero *
  1014. *******************************************************************/
  1015. pat inc
  1016. with REG
  1017. gen inc %1 yields %1
  1018. #ifdef REGVARS
  1019. pat inl inreg($1)==reg_any
  1020. kills regvar($1)
  1021. gen inc {LOCAL,$1,2}
  1022. #endif
  1023. pat inl
  1024. kills indexed, locals %ind>=$1 && %ind<$1+2
  1025. gen inc {LOCAL, $1, 2}
  1026. pat ine
  1027. kills indirects
  1028. gen inc {EXTERN2, $1}
  1029. pat dec
  1030. with REG
  1031. gen dec %1 yields %1
  1032. #ifdef REGVARS
  1033. pat del inreg($1)==reg_any
  1034. kills regvar($1)
  1035. gen dec {LOCAL,$1,2}
  1036. #endif
  1037. pat del
  1038. kills indexed, locals %ind>=$1 && %ind<$1+2
  1039. gen dec {LOCAL, $1, 2}
  1040. pat dee
  1041. kills indirects
  1042. gen dec {EXTERN2, $1}
  1043. #ifdef REGVARS
  1044. pat zrl inreg($1)==reg_any
  1045. kills regvar($1)
  1046. gen move {ANYCON, 0}, {LOCAL,$1,2}
  1047. #endif
  1048. pat zrl
  1049. kills indexed, locals %ind>=$1 && %ind<$1+2
  1050. gen move {ANYCON, 0}, {LOCAL,$1,2}
  1051. pat zre
  1052. kills indirects
  1053. gen move {ANYCON, 0}, {EXTERN2, $1}
  1054. pat zrf leaving zer $1
  1055. pat zer $1==2 yields {ANYCON, 0}
  1056. pat zer $1==4 yields {ANYCON, 0} {ANYCON, 0}
  1057. pat zer $1==6 yields {ANYCON, 0} {ANYCON, 0}
  1058. {ANYCON, 0}
  1059. pat zer $1==8 yields {ANYCON, 0} {ANYCON, 0}
  1060. {ANYCON, 0} {ANYCON, 0}
  1061. pat zer defined($1)
  1062. with STACK
  1063. gen move {ANYCON, $1/2}, cx
  1064. move {ANYCON, 0}, bx
  1065. 1:
  1066. push bx
  1067. loop {label,1b}
  1068. pat zer !defined($1)
  1069. with CXREG STACK
  1070. gen move {ANYCON, $1/2}, bx
  1071. sar cx,{ANYCON, 1}
  1072. 1:
  1073. push bx
  1074. loop {label,1b}
  1075. #ifdef REGVARS
  1076. pat lol adi stl $1==$3 && $2==2 && inreg($1)==reg_any
  1077. with rmorconst
  1078. kills regvar($1)
  1079. gen add {LOCAL,$1,2}, %1
  1080. #endif
  1081. pat lol adi stl $1==$3 && $2==2
  1082. with regorconst
  1083. kills indexed, locals %ind>=$1 && %ind<$1+2
  1084. gen add {LOCAL, $1, 2}, %1
  1085. pat ldl adi sdl $1==$3 && $2==4
  1086. with regorconst regorconst
  1087. kills indexed, locals %ind>=$1 && %ind<$1+4
  1088. gen add {LOCAL,$1,2},%1
  1089. adc {LOCAL,$1+2,2},%2
  1090. #ifdef REGVARS
  1091. pat lol loc sbi stl $1==$4 && $3==2 && inreg($1)==reg_any
  1092. kills regvar($1)
  1093. gen sub {LOCAL,$1,2},{ANYCON,$2}
  1094. #endif
  1095. pat lol loc sbi stl $1==$4 && $3==2
  1096. kills indexed, locals %ind>=$1 && %ind<$1+2
  1097. gen sub {LOCAL,$1,2},{ANYCON,$2}
  1098. #ifdef REGVARS
  1099. pat lol loc sli stl $1==$4 && $2==1 && $3==2 && inreg($1)==reg_any
  1100. kills regvar($1)
  1101. gen sal {LOCAL,$1,2},{ANYCON,1}
  1102. pat lol loc sli stl $1==$4 && $2==2 && $3==2 && inreg($1)==reg_any
  1103. kills regvar($1)
  1104. gen sal {LOCAL,$1,2},{ANYCON,1}
  1105. sal {LOCAL,$1,2},{ANYCON,1}
  1106. pat lol loc sli stl $1==$4 && $3==2 && inreg($1)==reg_any
  1107. kills regvar($1)
  1108. uses CXREG={ANYCON,$2}
  1109. gen sal {LOCAL,$1,2},cl
  1110. pat lol loc sri stl $1==$4 && $2==1 && $3==2 && inreg($1)==reg_any
  1111. kills regvar($1)
  1112. gen sar {LOCAL,$1,2},{ANYCON,1}
  1113. pat lol loc sri stl $1==$4 && $2==2 && $3==2 && inreg($1)==reg_any
  1114. kills regvar($1)
  1115. gen sar {LOCAL,$1,2},{ANYCON,1}
  1116. sar {LOCAL,$1,2},{ANYCON,1}
  1117. pat lol loc sri stl $1==$4 && $3==2 && inreg($1)==reg_any
  1118. kills regvar($1)
  1119. uses CXREG={ANYCON,$2}
  1120. gen sar {LOCAL,$1,2},cl
  1121. #endif
  1122. #ifdef REGVARS
  1123. pat lol ngi stl $1==$3 && $2==2 && inreg($1)==reg_any
  1124. kills regvar($1)
  1125. gen neg {LOCAL, $1, 2}
  1126. #endif
  1127. pat lol ngi stl $1==$3 && $2==2
  1128. kills indexed, locals %ind>=$1 && %ind<$1+2
  1129. gen neg {LOCAL, $1, 2}
  1130. pat ldl ngi sdl $1==$3 && $2==4
  1131. kills indexed, locals %ind>=$1 && %ind<$1+4
  1132. gen neg {LOCAL, $1, 2}
  1133. neg {LOCAL, $1+2, 2}
  1134. sbb {LOCAL, $1+2, 2}, {ANYCON, 0}
  1135. pat lol ads stl $1==$3 && $2==2 leaving lol $1 adi $2 stl $1
  1136. pat lol lol adp stl $1==$2 && $2==$4
  1137. uses ADDREG={LOCAL,$1,2} yields %a
  1138. leaving lol $2 adp $3 stl $2
  1139. pat lol inl $1==$2
  1140. uses REG={LOCAL,$1,2} yields %a
  1141. leaving inl $1
  1142. pat lol del $1==$2
  1143. uses REG={LOCAL,$1,2} yields %a
  1144. leaving del $1
  1145. pat lol adp stl $1==$3 && $2==1 leaving inl $1
  1146. pat lol adp stl $1==$3 && $2==0-1 leaving del $1
  1147. #ifdef REGVARS
  1148. pat lol adp stl $1==$3 && inreg($1)==reg_any
  1149. kills regvar($1)
  1150. gen add {LOCAL,$1,2}, {ANYCON,$2}
  1151. #endif
  1152. pat lol adp stl $1==$3
  1153. kills indexed, locals %ind>=$1 && %ind<$1+2
  1154. gen add {LOCAL,$1,2}, {ANYCON,$2}
  1155. #ifdef REGVARS
  1156. pat lol and stl $1==$3 && $2==2 && inreg($1)==reg_any
  1157. with rmorconst
  1158. kills regvar($1)
  1159. gen and {LOCAL,$1,2}, %1
  1160. #endif
  1161. pat lol and stl $1==$3 && $2==2
  1162. with regorconst
  1163. kills indexed, locals %ind>=$1 && %ind<$1+2
  1164. gen and {LOCAL, $1, 2}, %1
  1165. #ifdef REGVARS
  1166. pat lol ior stl $1==$3 && $2==2 && inreg($1)==reg_any
  1167. with rmorconst
  1168. kills regvar($1)
  1169. gen or {LOCAL,$1,2}, %1
  1170. #endif
  1171. pat lol ior stl $1==$3 && $2==2
  1172. with regorconst
  1173. kills indexed, locals %ind>=$1 && %ind<$1+2
  1174. gen or {LOCAL, $1, 2}, %1
  1175. #ifdef REGVARS
  1176. pat lol com stl $1==$3 && $2==2 && inreg($1)==reg_any
  1177. kills regvar($1)
  1178. gen not {LOCAL,$1,2}
  1179. #endif
  1180. pat lol com stl $1==$3 && $2==2
  1181. kills indexed, locals %ind>=$1 && %ind<$1+2
  1182. gen not {LOCAL, $1, 2}
  1183. #ifdef REGVARS
  1184. pat lil adi sil $1==$3 && $2==2 && inreg($1)==reg_any
  1185. with regorconst
  1186. kills referals
  1187. gen add {ind_reg2, regvar($1)}, %1
  1188. #endif
  1189. pat lil adi sil $1==$3 && $2==2
  1190. with regorconst
  1191. kills referals
  1192. uses ADDREG={LOCAL, $1, 2}
  1193. gen add {ind_reg2, %a}, %1
  1194. killreg %a
  1195. #ifdef REGVARS
  1196. pat lil ngi sil $1==$3 && $2==2 && inreg($1)==reg_any
  1197. kills referals
  1198. gen neg {ind_reg2, regvar($1)}
  1199. #endif
  1200. pat lil ngi sil $1==$3 && $2==2
  1201. kills referals
  1202. uses ADDREG={LOCAL, $1, 2}
  1203. gen neg {ind_reg2, %a}
  1204. killreg %a
  1205. pat lil ads sil $1==$3 && $2==2 leaving lil $1 adi $2 sil $3
  1206. #ifdef REGVARS
  1207. pat lil adp sil $1==$3 && $2==1 && inreg($1)==reg_any
  1208. kills referals
  1209. gen inc {ind_reg2, regvar($1)}
  1210. pat lil adp sil $1==$3 && $2==0-1 && inreg($1)==reg_any
  1211. kills referals
  1212. gen dec {ind_reg2, regvar($1)}
  1213. pat lil adp sil $1==$3 && inreg($1)==reg_any
  1214. kills referals
  1215. gen add {ind_reg2, regvar($1)}, {ANYCON,$2}
  1216. #endif
  1217. pat lil adp sil $1==$3
  1218. kills referals
  1219. uses ADDREG={LOCAL, $1, 2}
  1220. gen add {ind_reg2, %a}, {ANYCON,$2}
  1221. killreg %a
  1222. pat lil adp sil $1==$3 && $2==1
  1223. kills referals
  1224. uses ADDREG={LOCAL, $1, 2}
  1225. gen inc {ind_reg2, %a}
  1226. killreg %a
  1227. pat lil adp sil $1==$3 && $2==0-1
  1228. kills referals
  1229. uses ADDREG={LOCAL, $1, 2}
  1230. gen dec {ind_reg2, %a}
  1231. killreg %a
  1232. #ifdef REGVARS
  1233. pat lil and sil $1==$3 && $2==2 && inreg($1)==reg_any
  1234. with regorconst
  1235. kills referals
  1236. gen and {ind_reg2, regvar($1)}, %1
  1237. #endif
  1238. pat lil and sil $1==$3 && $2==2
  1239. with regorconst
  1240. kills referals
  1241. uses ADDREG={LOCAL, $1, 2}
  1242. gen and {ind_reg2, %a}, %1
  1243. killreg %a
  1244. #ifdef REGVARS
  1245. pat lil ior sil $1==$3 && $2==2 && inreg($1)==reg_any
  1246. with regorconst
  1247. kills referals
  1248. gen or {ind_reg2, regvar($1)}, %1
  1249. #endif
  1250. pat lil ior sil $1==$3 && $2==2
  1251. with regorconst
  1252. kills referals
  1253. uses ADDREG={LOCAL, $1, 2}
  1254. gen or {ind_reg2, %a}, %1
  1255. killreg %a
  1256. #ifdef REGVARS
  1257. pat lil com sil $1==$3 && $2==2 && inreg($1)==reg_any
  1258. kills referals
  1259. gen not {ind_reg2, regvar($1)}
  1260. #endif
  1261. pat lil com sil $1==$3 && $2==2
  1262. kills referals
  1263. uses ADDREG={LOCAL, $1, 2}
  1264. gen not {ind_reg2, %a}
  1265. killreg %a
  1266. pat lol lof inc lol stf $1==$4 && $2==$5
  1267. leaving lol $1 lof $2 adp 1 lol $4 stf $5
  1268. pat lol lof dec lol stf $1==$4 && $2==$5
  1269. leaving lol $1 lof $2 adp (0-1) lol $4 stf $5
  1270. #ifdef REGVARS
  1271. pat lol lof adi lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1272. with regorconst
  1273. kills referals
  1274. gen add {ind_regoff2, regvar($1), $2}, %1
  1275. #endif
  1276. pat lol lof adi lol stf $1==$4 && $2==$5 && $3==2
  1277. with regorconstnoaddr
  1278. kills referals
  1279. uses ADDREG={LOCAL,$1,2}
  1280. gen add {ind_regoff2, %a, $2}, %1
  1281. killreg %a
  1282. #ifdef REGVARS
  1283. pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1284. kills referals
  1285. gen neg {ind_regoff2, regvar($1), $2}
  1286. #endif
  1287. pat lol lof ngi lol stf $1==$4 && $2==$5 && $3==2
  1288. kills referals
  1289. uses ADDREG={LOCAL,$1,2}
  1290. gen neg {ind_regoff2, %a, $2}
  1291. killreg %a
  1292. pat lol lof ads lol stf $1==$4 && $2==$5 && $3==2
  1293. leaving lol $1 lof $2 adi $3 lol $4 stf $5
  1294. #ifdef REGVARS
  1295. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==1 && inreg($1)==reg_any
  1296. kills referals
  1297. gen inc {ind_regoff2, regvar($1), $2}
  1298. #endif
  1299. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==1
  1300. kills referals
  1301. uses ADDREG={LOCAL,$1,2}
  1302. gen inc {ind_regoff2, %a, $2}
  1303. killreg %a
  1304. #ifdef REGVARS
  1305. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==0-1 && inreg($1)==reg_any
  1306. kills referals
  1307. gen dec {ind_regoff2, regvar($1), $2}
  1308. #endif
  1309. pat lol lof adp lol stf $1==$4 && $2==$5 && $3==0-1
  1310. kills referals
  1311. uses ADDREG={LOCAL,$1,2}
  1312. gen dec {ind_regoff2, %a, $2}
  1313. killreg %a
  1314. #ifdef REGVARS
  1315. pat lol lof adp lol stf $1==$4 && $2==$5 && inreg($1)==reg_any
  1316. kills referals
  1317. gen add {ind_regoff2, regvar($1), $2},{ANYCON,$3}
  1318. #endif
  1319. pat lol lof adp lol stf $1==$4 && $2==$5
  1320. kills referals
  1321. uses ADDREG={LOCAL,$1,2}
  1322. gen add {ind_regoff2, %a, $2},{ANYCON,$3}
  1323. killreg %a
  1324. #ifdef REGVARS
  1325. pat lol lof and lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1326. with regorconst
  1327. kills referals
  1328. gen and {ind_regoff2, regvar($1), $2}, %1
  1329. #endif
  1330. pat lol lof and lol stf $1==$4 && $2==$5 && $3==2
  1331. with regorconstnoaddr
  1332. kills referals
  1333. uses ADDREG={LOCAL,$1,2}
  1334. gen and {ind_regoff2, %a, $2}, %1
  1335. killreg %a
  1336. #ifdef REGVARS
  1337. pat lol lof ior lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1338. with regorconst
  1339. kills referals
  1340. gen or {ind_regoff2, regvar($1), $2}, %1
  1341. #endif
  1342. pat lol lof ior lol stf $1==$4 && $2==$5 && $3==2
  1343. with regorconstnoaddr
  1344. kills referals
  1345. uses ADDREG={LOCAL,$1,2}
  1346. gen or {ind_regoff2, %a, $2}, %1
  1347. killreg %a
  1348. #ifdef REGVARS
  1349. pat lol lof com lol stf $1==$4 && $2==$5 && $3==2 && inreg($1)==reg_any
  1350. kills referals
  1351. gen not {ind_regoff2, regvar($1), $2}
  1352. #endif
  1353. pat lol lof com lol stf $1==$4 && $2==$5 && $3==2
  1354. kills referals
  1355. uses ADDREG={LOCAL,$1,2}
  1356. gen not {ind_regoff2, %a, $2}
  1357. killreg %a
  1358. pat loe adi ste $1==$3 && $2==2
  1359. with regorconst
  1360. kills indirects
  1361. gen add {EXTERN2, $1}, %1
  1362. pat lde adi sde $1==$3 && $2==4
  1363. with regorconst regorconst
  1364. kills indirects
  1365. gen add {EXTERN2, $1}, %1
  1366. adc {EXTERN2, $1+2}, %2
  1367. pat loe ngi ste $1==$3 && $2==2
  1368. kills indirects
  1369. gen neg {EXTERN2, $1}
  1370. pat lde ngi sde $1==$3 && $2==4
  1371. kills indirects
  1372. gen neg {EXTERN2, $1}
  1373. neg {EXTERN2, $1+2}
  1374. sbb {EXTERN2, $1+2}, {ANYCON, 0}
  1375. pat loe ads ste $1==$3 && $2==2
  1376. with regorconst
  1377. kills indirects
  1378. gen add {EXTERN2, $1}, %1
  1379. pat loe loe adp ste $1==$2 && $1==$4
  1380. uses ADDREG={EXTERN2,$1} yields %a
  1381. leaving loe $1 adp $3 ste $1
  1382. pat loe ine $1==$2
  1383. uses ADDREG={EXTERN2,$1} yields %a
  1384. leaving ine $1
  1385. pat loe dee $1==$2
  1386. uses ADDREG={EXTERN2,$1} yields %a
  1387. leaving dee $1
  1388. pat loe adp ste $1==$3
  1389. kills indirects
  1390. gen add {EXTERN2, $1}, {ANYCON,$2}
  1391. pat loe adp ste $1==$3 && $2==1
  1392. kills indirects
  1393. gen inc {EXTERN2, $1}
  1394. pat loe adp ste $1==$3 && $2==0-1
  1395. kills indirects
  1396. gen dec {EXTERN2, $1}
  1397. pat loe and ste $1==$3 && $2==2
  1398. with regorconst
  1399. kills indirects
  1400. gen and {EXTERN2, $1}, %1
  1401. pat loe ior ste $1==$3 && $2==2
  1402. with regorconst
  1403. kills indirects
  1404. gen or {EXTERN2, $1}, %1
  1405. pat loe com ste $1==$3 && $2==2
  1406. kills indirects
  1407. gen not {EXTERN2, $1}
  1408. pat loe lof adi loe stf $1==$4 && $2==$5 && $3==2
  1409. with regorconstnoaddr
  1410. kills referals
  1411. uses ADDREG={EXTERN2,$1}
  1412. gen add {ind_regoff2, %a, $2}, %1
  1413. killreg %a
  1414. pat loe lof ngi loe stf $1==$4 && $2==$5 && $3==2
  1415. kills referals
  1416. uses ADDREG={EXTERN2,$1}
  1417. gen neg {ind_regoff2, %a, $2}
  1418. killreg %a
  1419. pat loe lof adp loe stf $1==$4 && $2==$5 && $3==1
  1420. kills referals
  1421. uses ADDREG={EXTERN2,$1}
  1422. gen inc {ind_regoff2, %a, $2}
  1423. killreg %a
  1424. pat loe lof adp loe stf $1==$4 && $2==$5 && $3==0-1
  1425. kills referals
  1426. uses ADDREG={EXTERN2,$1}
  1427. gen dec {ind_regoff2, %a, $2}
  1428. killreg %a
  1429. pat loe lof adp loe stf $1==$4 && $2==$5
  1430. kills referals
  1431. uses ADDREG={EXTERN2,$1}
  1432. gen add {ind_regoff2, %a, $2}, {ANYCON, $3}
  1433. killreg %a
  1434. pat loe lof ads loe stf $1==$4 && $2==$5 && $3==2
  1435. with regorconstnoaddr
  1436. kills referals
  1437. uses ADDREG={EXTERN2,$1}
  1438. gen add {ind_regoff2, %a, $2}, %1
  1439. killreg %a
  1440. pat loe lof and loe stf $1==$4 && $2==$5 && $3==2
  1441. with regorconstnoaddr
  1442. kills referals
  1443. uses ADDREG={EXTERN2,$1}
  1444. gen and {ind_regoff2, %a, $2}, %1
  1445. killreg %a
  1446. pat loe lof ior loe stf $1==$4 && $2==$5 && $3==2
  1447. with regorconstnoaddr
  1448. kills referals
  1449. uses ADDREG={EXTERN2,$1}
  1450. gen or {ind_regoff2, %a, $2}, %1
  1451. killreg %a
  1452. pat loe lof com loe stf $1==$4 && $2==$5 && $3==2
  1453. kills referals
  1454. uses ADDREG={EXTERN2,$1}
  1455. gen not {ind_regoff2, %a, $2}
  1456. killreg %a
  1457. /*******************************************************************
  1458. * Group 8: Convert Instructions *
  1459. *******************************************************************/
  1460. pat cii
  1461. with CXREG DXREG ACC
  1462. kills ALL
  1463. gen joehoe {label,".cii"} yields %3
  1464. pat ciu leaving cuu
  1465. pat cui leaving cuu
  1466. pat cuu
  1467. with CXREG DXREG ACC
  1468. kills ALL
  1469. gen joehoe {label,".cuu"} yields %3
  1470. pat loc loc cii $1==1 && $2==2
  1471. with ACC
  1472. gen cbw. yields ax
  1473. with exact rmorconst1
  1474. uses reusing %1, ACC1=%1
  1475. gen cbw. yields ax
  1476. pat loc loc cii $1==1 && $2==4
  1477. with ACC
  1478. uses DXREG
  1479. gen cbw.
  1480. cwd. yields dx ax
  1481. with exact rmorconst1
  1482. uses reusing %1, ACC1=%1, DXREG
  1483. gen cbw.
  1484. cwd. yields dx ax
  1485. pat loc loc cii $1==2 && $2==4
  1486. with ACC
  1487. uses DXREG
  1488. gen cwd. yields dx ax
  1489. pat loc loc cii $1==4 && $2==2
  1490. with a_word a_word yields %1
  1491. pat loc loc ciu leaving loc $1 loc $2 cuu
  1492. pat loc loc cui leaving loc $1 loc $2 cuu
  1493. pat loc loc cuu $1==$2
  1494. pat loc loc cuu $1==2 && $2==4
  1495. with a_word yields {ANYCON,0} %1
  1496. pat loc loc cuu $1==4 && $2==2
  1497. with a_word a_word yields %1
  1498. pat loc loc cif $1==2 && $2==4 leaving loc $1 cal ".cif4"
  1499. pat loc loc cif $1==4 && $2==4 leaving loc $1 cal ".cif4" asp 2
  1500. pat loc loc cif $1==2 && $2==8
  1501. with REG
  1502. kills ALL
  1503. gen push %1
  1504. push %1
  1505. push %1 leaving loc $1 cal ".cif8"
  1506. pat loc loc cif $1==4 && $2==8
  1507. with REG REG
  1508. kills ALL
  1509. gen push %1
  1510. push %2
  1511. push %1 leaving loc $1 cal ".cif8"
  1512. pat loc loc cuf $1==2 && $2==4 leaving loc $1 cal ".cuf4"
  1513. pat loc loc cuf $1==4 && $2==4 leaving loc $1 cal ".cuf4" asp 2
  1514. pat loc loc cuf $1==2 && $2==8
  1515. with REG
  1516. kills ALL
  1517. gen push %1
  1518. push %1
  1519. push %1 leaving loc $1 cal ".cuf8"
  1520. pat loc loc cuf $1==4 && $2==8
  1521. with REG REG
  1522. kills ALL
  1523. gen push %1
  1524. push %2
  1525. push %1 leaving loc $1 cal ".cuf8"
  1526. pat loc loc cfi $1==4 && $2==2 leaving loc $1 loc $2 cal ".cfi" asp 8 lfr 2
  1527. pat loc loc cfi $2==4 leaving loc $1 loc $2 cal ".cfi" asp $1
  1528. pat loc loc cfi $1==8 && $2==2 leaving loc $1 loc $2 cal ".cfi" asp 12 lfr 2
  1529. pat loc loc cfu $1==4 && $2==2 leaving loc $1 loc $2 cal ".cfu" asp 8 lfr 2
  1530. pat loc loc cfu $2==4 leaving loc $1 loc $2 cal ".cfu" asp $1
  1531. pat loc loc cfu $1==8 && $2==2 leaving loc $1 loc $2 cal ".cfu" asp 12 lfr 2
  1532. pat loc loc cff $1==8 && $2==4 leaving cal ".cff4" asp 4
  1533. pat loc loc cff $1==4 && $2==8
  1534. with REG REG
  1535. kills ALL
  1536. uses REG={ANYCON,0}
  1537. gen push %a
  1538. push %a
  1539. push %2
  1540. push %1 leaving cal ".cff8"
  1541. /********************************************************************
  1542. * Group 9 : Logical Instructions *
  1543. ********************************************************************/
  1544. pat and $1==2
  1545. with EXACT REG rmorconst
  1546. gen and %1,%2 yields %1
  1547. with rmorconst REG
  1548. gen and %2,%1 yields %2
  1549. pat and $1==4
  1550. with EXACT REG REG rmorconst rmorconst
  1551. gen and %1,%3
  1552. and %2,%4 yields %2 %1
  1553. with rmorconst rmorconst REG REG
  1554. gen and %3,%1
  1555. and %4,%2 yields %4 %3
  1556. pat and defined($1)
  1557. kills ALL
  1558. gen mov cx,{ANYCON,$1}
  1559. joehoe {label, ".and"}
  1560. pat and !defined($1)
  1561. with CXREG
  1562. kills ALL
  1563. gen joehoe {label, ".and"}
  1564. pat ior $1==2
  1565. with EXACT REG rmorconst
  1566. gen or %1,%2 yields %1
  1567. with rmorconst REG
  1568. gen or %2,%1 yields %2
  1569. pat ior $1==4
  1570. with EXACT REG REG rmorconst rmorconst
  1571. gen or %1,%3
  1572. or %2,%4 yields %2 %1
  1573. with rmorconst rmorconst REG REG
  1574. gen or %3,%1
  1575. or %4,%2 yields %4 %3
  1576. pat ior defined($1)
  1577. kills ALL
  1578. gen mov cx,{ANYCON,$1}
  1579. joehoe {label, ".ior"}
  1580. pat ior !defined($1)
  1581. with CXREG
  1582. kills ALL
  1583. gen joehoe {label, ".ior"}
  1584. pat xor $1==2
  1585. with EXACT REG rmorconst
  1586. gen xor %1,%2 yields %1
  1587. with rmorconst REG
  1588. gen xor %2,%1 yields %2
  1589. pat xor $1==4
  1590. with EXACT REG REG rmorconst rmorconst
  1591. gen xor %1,%3
  1592. xor %2,%4 yields %2 %1
  1593. with rmorconst rmorconst REG REG
  1594. gen xor %3,%1
  1595. xor %4,%2 yields %4 %3
  1596. pat xor defined($1)
  1597. kills ALL
  1598. gen mov cx,{ANYCON,$1}
  1599. joehoe {label, ".xor"}
  1600. pat xor !defined($1)
  1601. with CXREG
  1602. kills ALL
  1603. gen joehoe {label, ".xor"}
  1604. pat com $1==2
  1605. with REG
  1606. gen not %1 yields %1
  1607. pat com $1==4
  1608. with REG REG
  1609. gen not %2
  1610. not %1 yields %2 %1
  1611. pat com defined($1)
  1612. kills ALL
  1613. gen mov cx,{ANYCON,$1}
  1614. joehoe {label, ".com"}
  1615. pat com !defined($1)
  1616. with CXREG
  1617. kills ALL
  1618. gen joehoe {label, ".com"}
  1619. pat loc rol $1==1 && $2==2
  1620. with REG
  1621. gen rol %1,{ANYCON,1} yields %1
  1622. pat rol $1==2
  1623. with SHIFT_CREG REG
  1624. gen rol %2,cl yields %2
  1625. pat rol $1==4
  1626. with CXREG REG REG
  1627. gen jcxz {label, 1f}
  1628. 2: sal %2,{ANYCON,1}
  1629. rcl %3,{ANYCON,1}
  1630. adc %2,{ANYCON,0}
  1631. loop {label, 2b}
  1632. 1:
  1633. pat loc ror $1==1 && $2==2
  1634. with REG
  1635. gen ror %1,{ANYCON,1} yields %1
  1636. pat ror $1==2
  1637. with SHIFT_CREG REG
  1638. gen ror %2,cl yields %2
  1639. pat ror $1==4
  1640. with CXREG REG REG
  1641. gen jcxz {label, 1f}
  1642. neg cx
  1643. add cx,{ANYCON,32}
  1644. 2: sal %2,{ANYCON,1}
  1645. rcl %3,{ANYCON,1}
  1646. adc %2,{ANYCON,0}
  1647. loop {label, 2b}
  1648. 1:
  1649. /*******************************************************************
  1650. * Group 10 : Set Instructions *
  1651. *******************************************************************/
  1652. pat inn $1==2
  1653. with SHIFT_CREG REG
  1654. gen shr %2,cl
  1655. and %2,{ANYCON, 1} yields %2
  1656. with SHIFT_CREG ACC
  1657. gen shr %2,cl
  1658. and %2,{ANYCON, 1} yields %2
  1659. pat loc inn $1==1 && $2==2
  1660. with REG
  1661. gen shr %1,{ANYCON, 1}
  1662. and %1,{ANYCON, 1} yields %1
  1663. with ACC
  1664. gen shr %1,{ANYCON, 1}
  1665. and %1,{ANYCON, 1} yields %1
  1666. pat loc inn $1==0 && $2==2
  1667. with REG
  1668. gen and %1,{ANYCON, 1} yields %1
  1669. with ACC
  1670. gen and %1,{ANYCON, 1} yields %1
  1671. pat inn defined($1)
  1672. with ACC
  1673. kills ALL
  1674. gen mov cx,{ANYCON, $1}
  1675. joehoe {label,".inn"} yields ax
  1676. pat inn !defined($1)
  1677. with CXREG ACC
  1678. kills ALL
  1679. gen joehoe {label,".inn"} yields ax
  1680. pat loc inn zeq $2==2
  1681. with rm STACK
  1682. gen check %1,{ANYCON,1<<$1}
  1683. je {label,$3}
  1684. pat loc inn zne $2==2
  1685. with rm STACK
  1686. gen check %1,{ANYCON,1<<$1}
  1687. jne {label,$3}
  1688. pat set $1==2
  1689. with SHIFT_CREG
  1690. uses REG={ANYCON, 1}
  1691. gen shl %a,cl yields %a
  1692. pat set defined($1)
  1693. with ACC
  1694. kills ALL
  1695. gen mov cx,{ANYCON, $1}
  1696. joehoe {label,".set"}
  1697. pat set !defined($1)
  1698. with CXREG ACC
  1699. kills ALL
  1700. gen joehoe {label,".set"}
  1701. /********************************************************************
  1702. * Group 11 : Array Instructions *
  1703. ********************************************************************/
  1704. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)==0
  1705. leaving ads 2
  1706. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)!=0
  1707. leaving adp 0-rom($1,1) ads 2
  1708. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)==0
  1709. with ADDREG
  1710. gen sal %1,{ANYCON,1} yields %1 leaving ads 2
  1711. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)!=0
  1712. with ADDREG
  1713. gen sal %1,{ANYCON,1} yields %1 leaving adp 0-2*rom($1,1) ads 2
  1714. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)==0
  1715. with ADDREG
  1716. gen sal %1,{ANYCON,1}
  1717. sal %1,{ANYCON,1} yields %1 leaving ads 2
  1718. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)!=0
  1719. with ADDREG
  1720. gen sal %1,{ANYCON,1}
  1721. sal %1,{ANYCON,1} yields %1 leaving adp 0-4*rom($1,1) ads 2
  1722. pat lae aar $2==2 && rom($1,1)==0
  1723. with ACC
  1724. uses DXREG,REG={ANYCON,rom($1,3)}
  1725. gen mul %b yields %1 leaving ads 2
  1726. pat lae aar $2==2 && defined(rom($1,1))
  1727. with ACC
  1728. uses DXREG,REG={ANYCON,rom($1,3)}
  1729. gen mul %b yields %1
  1730. leaving adp 0-rom($1,1)*rom($1,3) ads 2
  1731. pat loc sli ads $1==1 && $2==2 && $3==2
  1732. with ADDREG
  1733. gen sal %1,{ANYCON,1} yields %1 leaving ads 2
  1734. pat loc sli ads $1==2 && $2==2 && $3==2
  1735. with ADDREG
  1736. gen sal %1,{ANYCON,1}
  1737. sal %1,{ANYCON,1} yields %1 leaving ads 2
  1738. pat loc sli ads $2==2 && $3==2
  1739. with ADDREG
  1740. uses CXREG={ANYCON,$1}
  1741. gen sal %1,cl yields %1 leaving ads 2
  1742. pat aar $1==2
  1743. with AREG ACC
  1744. uses DXREG
  1745. gen sub %2,{ind_reg2,%1}
  1746. mul {ind_regoff2,%1,4} yields %2 leaving ads 2
  1747. with reg_off ACC
  1748. uses DXREG
  1749. gen sub %2,{ind_regoff2, %1.reg, %1.off}
  1750. mul {ind_regoff2, %1.reg, 4+%1.off}
  1751. yields %2 leaving ads 2
  1752. with bpreg_off ACC
  1753. uses DXREG
  1754. gen sub %2,{ind_bpregoff2, %1.reg, %1.ind}
  1755. mul {ind_bpregoff2, %1.reg, 4+%1.ind}
  1756. yields %2 leaving ads 2
  1757. with ADDR_LOCAL ACC
  1758. uses DXREG
  1759. gen sub %2,{LOCAL,%1.ind,2}
  1760. mul {LOCAL, 4+%1.ind,2} yields %2 leaving ads 2
  1761. with ADDR_EXTERN ACC
  1762. uses DXREG
  1763. gen sub %2,{EXTERN2,%1.off}
  1764. mul {EXTERN2,4+%1.off} yields %2 leaving ads 2
  1765. pat lae lar defined(rom($1,3)) leaving lae $1 aar $2 loi rom($1,3)
  1766. pat lae sar defined(rom($1,3)) leaving lae $1 aar $2 sti rom($1,3)
  1767. pat aar !defined($1)
  1768. kills ALL
  1769. gen joehoe {label,".iaar"} yields bx
  1770. pat sar $1==2
  1771. with BXREG ACC
  1772. kills ALL
  1773. gen joehoe {label,".sar2"}
  1774. pat sar !defined($1)
  1775. kills ALL
  1776. gen joehoe {label,".isar"}
  1777. pat lar $1==2
  1778. with BXREG ACC
  1779. kills ALL
  1780. gen joehoe {label,".lar2"}
  1781. pat lar !defined($1)
  1782. kills ALL
  1783. gen joehoe {label,".ilar"}
  1784. /*******************************************************************
  1785. * Group 12 : Compare Instructions *
  1786. *******************************************************************/
  1787. pat cmi $1==2
  1788. with EXACT register rmorconst
  1789. uses REG={ANYCON,0}
  1790. gen cmp %1,%2
  1791. je {label,2f}
  1792. jl {label,1f}
  1793. inc %a
  1794. jmp {label,2f}
  1795. 1:
  1796. dec %a
  1797. 2: yields %a
  1798. with rmorconst register
  1799. uses REG={ANYCON,0}
  1800. gen cmp %2,%1
  1801. je {label,2f}
  1802. jg {label,1f}
  1803. inc %a
  1804. jmp {label,2f}
  1805. 1:
  1806. dec %a
  1807. 2: yields %a
  1808. pat cmi $1==4
  1809. kills ALL
  1810. gen joehoe {label,".cmi4"} yields ax
  1811. pat cmu $1==2 leaving cmp
  1812. pat cmu $1==4
  1813. kills ALL
  1814. gen joehoe {label,".cmu4"} yields ax
  1815. pat cms $1==2
  1816. with EXACT REG rmorconst
  1817. gen sub %1,%2 yields %1
  1818. with rmorconst REG
  1819. gen sub %2,%1 yields %2
  1820. pat cms $1==4
  1821. with rmorconst rmorconst REG REG
  1822. gen sub %3,%1
  1823. sbb %4,%2
  1824. or %4,%3 yields %4
  1825. with EXACT REG REG rmorconst rmorconst
  1826. gen sub %1,%3
  1827. sbb %2,%4
  1828. or %2,%1 yields %2
  1829. pat cms defined($1)
  1830. kills ALL
  1831. gen mov cx,{ANYCON,$1}
  1832. joehoe {label,".cms"} yields cx
  1833. pat cms !defined($1)
  1834. kills ALL
  1835. gen joehoe {label,".cms"} yields cx
  1836. pat cmf $1==4
  1837. kills ALL
  1838. gen joehoe {label,".cmf4"} leaving asp 8 lfr 2
  1839. pat cmf $1==8
  1840. kills ALL
  1841. gen joehoe {label,".cmf8"} leaving asp 16 lfr 2
  1842. pat cmp
  1843. with EXACT register rmorconst
  1844. uses REG = {ANYCON,0}
  1845. gen cmp %1,%2
  1846. je {label,2f}
  1847. jb {label,1f}
  1848. inc %a
  1849. jmp {label,2f}
  1850. 1: dec %a
  1851. 2: yields %a
  1852. with rmorconst register
  1853. uses REG = {ANYCON,0}
  1854. gen cmp %2,%1
  1855. je {label,2f}
  1856. ja {label,1f}
  1857. inc %a
  1858. jmp {label,2f}
  1859. 1: dec %a
  1860. 2: yields %a
  1861. proc txx
  1862. with rm
  1863. uses REG = {ANYCON,0}
  1864. gen test %1
  1865. jxx* {label,1f}
  1866. inc %a
  1867. 1: yields %a
  1868. pat tlt call txx("jge")
  1869. pat tle call txx("jg")
  1870. pat teq call txx("jne")
  1871. pat tne call txx("je")
  1872. pat tge call txx("jl")
  1873. pat tgt call txx("jle")
  1874. proc txxior
  1875. with rm REG
  1876. gen test %1
  1877. jxx* {label,1f}
  1878. or %2,{ANYCON,1}
  1879. 1: yields %2
  1880. pat tlt ior $2==2 call txxior("jge")
  1881. pat tle ior $2==2 call txxior("jg")
  1882. pat teq ior $2==2 call txxior("jne")
  1883. pat tne ior $2==2 call txxior("je")
  1884. pat tge ior $2==2 call txxior("jl")
  1885. pat tgt ior $2==2 call txxior("jle")
  1886. proc cmixxior
  1887. with regorconst rm REG
  1888. gen cmp %2,%1
  1889. jxx* {label,1f}
  1890. or %3,{ANYCON,1}
  1891. 1: yields %3
  1892. pat cmi tlt ior $1==2 && $3==2 call cmixxior("jge")
  1893. pat cmi tle ior $1==2 && $3==2 call cmixxior("jg")
  1894. pat cmi teq ior $1==2 && $3==2 call cmixxior("jne")
  1895. pat cmi tne ior $1==2 && $3==2 call cmixxior("je")
  1896. pat cmi tge ior $1==2 && $3==2 call cmixxior("jl")
  1897. pat cmi tgt ior $1==2 && $3==2 call cmixxior("jle")
  1898. proc cmxtxx
  1899. with regorconst rm
  1900. uses REG = {ANYCON,0}
  1901. gen cmp %2,%1
  1902. jxx[1] {label,1f}
  1903. inc %a
  1904. 1: yields %a
  1905. with EXACT rm regorconst
  1906. uses REG = {ANYCON,0}
  1907. gen cmp %1,%2
  1908. jxx[2] {label,1f}
  1909. inc %a
  1910. 1: yields %a
  1911. pat cmi tlt $1==2 call cmxtxx("jge","jle")
  1912. pat cmi tle $1==2 call cmxtxx("jg","jl")
  1913. pat cmi teq $1==2 call cmxtxx("jne","jne")
  1914. pat cmi tne $1==2 call cmxtxx("je","je")
  1915. pat cmi tge $1==2 call cmxtxx("jl","jg")
  1916. pat cmi tgt $1==2 call cmxtxx("jle","jge")
  1917. pat cmp tlt call cmxtxx("jae","jbe")
  1918. pat cmp tle call cmxtxx("ja","jb")
  1919. pat cmp teq call cmxtxx("jne","jne")
  1920. pat cmp tne call cmxtxx("je","je")
  1921. pat cmp tge call cmxtxx("jb","ja")
  1922. pat cmp tgt call cmxtxx("jbe","jae")
  1923. pat cms teq $1==2 call cmxtxx("jne","jne")
  1924. pat cms tne $1==2 call cmxtxx("je","je")
  1925. proc cmxzxx example cmp zlt
  1926. with regorconst rm STACK
  1927. gen cmp %2,%1
  1928. jxx[1] {label,$2}
  1929. with EXACT rm regorconst
  1930. kills ALL
  1931. gen cmp %1,%2
  1932. jxx[2] {label,$2}
  1933. pat cmp zlt call cmxzxx("jb","ja")
  1934. pat cmp zle call cmxzxx("jbe","jae")
  1935. pat cmp zeq call cmxzxx("je","je")
  1936. pat cmp zne call cmxzxx("jne","jne")
  1937. pat cmp zge call cmxzxx("jae","jbe")
  1938. pat cmp zgt call cmxzxx("ja","jb")
  1939. pat cms zeq $1==2 call cmxzxx("je","je")
  1940. pat cms zne $1==2 call cmxzxx("jne","jne")
  1941. pat ldc cmi zlt highw($1)==0 && loww($1)==0 && $2==4
  1942. with rmorconst rmorconst yields %2 leaving zlt $3
  1943. pat ldc cmi zge highw($1)==0 && loww($1)==0 && $2==4
  1944. with rmorconst rmorconst yields %2 leaving zge $3
  1945. pat ldc cms zeq $2==4 && loww($1)==0 && highw($1)==0
  1946. with rmorconst REG STACK
  1947. gen or %2,%1
  1948. je {label,$3}
  1949. with REG rmorconst STACK
  1950. gen or %1,%2
  1951. je {label,$3}
  1952. pat ldc cms zne $2==4 && loww($1)==0 && highw($1)==0
  1953. with rmorconst REG STACK
  1954. gen or %2,%1
  1955. jne {label,$3}
  1956. with REG rmorconst STACK
  1957. gen or %1,%2
  1958. jne {label,$3}
  1959. pat ldc cms zeq $2==4
  1960. with rm rm STACK
  1961. gen cmp %1, {ANYCON, loww($1)}
  1962. jne {label,1f}
  1963. cmp %2, {ANYCON, highw($1)}
  1964. je {label,$3}
  1965. 1:
  1966. pat ldc cms zne $2==4
  1967. with rm rm STACK
  1968. gen cmp %1, {ANYCON, loww($1)}
  1969. jne {label,$3}
  1970. cmp %2, {ANYCON, highw($1)}
  1971. jne {label,$3}
  1972. pat cms zne $1==4
  1973. with regorconst regorconst rm rm STACK
  1974. gen cmp %3,%1
  1975. jne {label,$2}
  1976. cmp %4,%2
  1977. jne {label,$2}
  1978. with EXACT rm rm regorconst regorconst
  1979. kills ALL
  1980. gen cmp %1,%3
  1981. jne {label,$2}
  1982. cmp %2,%4
  1983. jne {label,$2}
  1984. pat cms zeq $1==4
  1985. with regorconst regorconst rm rm STACK
  1986. gen cmp %3,%1
  1987. jne {label, 1f}
  1988. cmp %4,%2
  1989. je {label,$2}
  1990. 1:
  1991. with EXACT rm rm regorconst regorconst
  1992. kills ALL
  1993. gen cmp %1,%3
  1994. jne {label,1f}
  1995. cmp %2,%4
  1996. je {label,$2}
  1997. 1:
  1998. proc andzxx example and zeq
  1999. with regorconst rm STACK
  2000. gen check %2,%1
  2001. jxx* {label,$2}
  2002. with exact rm regorconst
  2003. kills ALL
  2004. gen check %1,%2
  2005. jxx* {label,$2}
  2006. pat and zeq $1==2 call andzxx("je")
  2007. pat and zne $1==2 call andzxx("jne")
  2008. proc locandzxx example loc and zeq
  2009. with exact rm12
  2010. kills ALL
  2011. gen testb %1,{ANYCON,$1}
  2012. jxx* {label,$3}
  2013. with GENREG STACK
  2014. gen testb %1.1,{ANYCON,$1}
  2015. jxx* {label,$3}
  2016. with exact IREG
  2017. kills ALL
  2018. gen check %1,{ANYCON,$1}
  2019. jxx* {label,$3}
  2020. pat loc and zeq $1<256 && $1>=0 && $2==2 call locandzxx("je")
  2021. pat loc and zne $1<256 && $1>=0 && $2==2 call locandzxx("jne")
  2022. proc locbxx example loc beq
  2023. with exact rm1
  2024. kills ALL
  2025. gen cmpb %1,{ANYCON,$1}
  2026. jxx* {label,$2}
  2027. with rm STACK
  2028. gen cmp %1,{ANYCON,$1}
  2029. jxx* {label,$2}
  2030. pat loc beq $1<256 && $1>=0 call locbxx("je")
  2031. pat loc bne $1<256 && $1>=0 call locbxx("jne")
  2032. proc loccmuzxx example loc cmu zeq
  2033. with exact rm1
  2034. kills ALL
  2035. gen cmpb %1,{ANYCON,$1}
  2036. jxx* {label,$3}
  2037. with rm STACK
  2038. gen cmp %1,{ANYCON,$1}
  2039. jxx* {label,$3}
  2040. pat loc cmu zeq $1<256 && $1>=0 && $2==2 call loccmuzxx("je")
  2041. pat loc cmu zne $1<256 && $1>=0 && $2==2 call loccmuzxx("jne")
  2042. /*******************************************************************
  2043. * Group 13 : Branch Instructions *
  2044. *******************************************************************/
  2045. pat bra
  2046. with STACK
  2047. gen jmp {label,$1}
  2048. proc bxx example blt
  2049. with regorconst rm STACK
  2050. kills ALL
  2051. gen cmp %2,%1
  2052. jxx[1] {label,$1}
  2053. with EXACT rm regorconst
  2054. kills ALL
  2055. gen cmp %1,%2
  2056. jxx[2] {label,$1}
  2057. pat blt call bxx("jl","jg")
  2058. pat ble call bxx("jle","jge")
  2059. pat beq call bxx("je","je")
  2060. pat bne call bxx("jne","jne")
  2061. pat bge call bxx("jge","jle")
  2062. pat bgt call bxx("jg","jl")
  2063. proc zxx example zlt
  2064. with rm STACK
  2065. gen test %1
  2066. jxx* {label,$1}
  2067. pat zlt call zxx("jl")
  2068. pat zle call zxx("jle")
  2069. pat zge call zxx("jge")
  2070. pat zgt call zxx("jg")
  2071. pat zne
  2072. with rm+rm1 STACK
  2073. gen test %1
  2074. jne {label,$1}
  2075. pat zeq
  2076. with rm+rm1 STACK
  2077. gen test %1
  2078. je {label,$1}
  2079. /*******************************************************************
  2080. * Group 14 : Procedure-call Instructions *
  2081. *******************************************************************/
  2082. pat cal
  2083. kills ALL
  2084. gen joehoe {label,$1}
  2085. pat cai
  2086. with rm
  2087. kills ALL
  2088. gen joehoe %1
  2089. pat lfr $1==2 yields ax
  2090. pat lfr $1==4 yields dx ax
  2091. pat lfr $1==6
  2092. kills ALL
  2093. gen joehoe {label, ".lfr6"}
  2094. pat lfr $1==8
  2095. kills ALL
  2096. gen joehoe {label, ".lfr8"}
  2097. pat ret $1==0
  2098. kills ALL
  2099. gen
  2100. #ifdef REGVARS
  2101. return
  2102. #else
  2103. mov sp,bp
  2104. pop bp
  2105. ret.
  2106. #endif
  2107. pat ret $1==2
  2108. with ACC
  2109. kills ALL
  2110. gen
  2111. #ifdef REGVARS
  2112. return
  2113. #else
  2114. mov sp,bp
  2115. pop bp
  2116. ret.
  2117. #endif
  2118. pat ret $1==4
  2119. with ACC DXREG
  2120. kills ALL
  2121. gen
  2122. #ifdef REGVARS
  2123. return
  2124. #else
  2125. mov sp,bp
  2126. pop bp
  2127. ret.
  2128. #endif
  2129. pat ret $1==6
  2130. with STACK
  2131. gen joehoe {label, ".ret6"}
  2132. #ifdef REGVARS
  2133. return
  2134. #else
  2135. mov sp,bp
  2136. pop bp
  2137. ret.
  2138. #endif
  2139. pat ret $1==8
  2140. with STACK
  2141. gen joehoe {label, ".ret8"}
  2142. #ifdef REGVARS
  2143. return
  2144. #else
  2145. mov sp,bp
  2146. pop bp
  2147. ret.
  2148. #endif
  2149. /********************************************************************
  2150. * Group 15 : Miscellaneous Instructions *
  2151. ********************************************************************/
  2152. pat asp $1==2
  2153. with exact a_word
  2154. with STACK
  2155. uses BXREG /* GENREG may contain lfr area */
  2156. gen pop %a
  2157. pat asp $1==4
  2158. with exact a_word a_word
  2159. with STACK
  2160. uses BXREG /* GENREG may contain lfr area */
  2161. gen pop %a
  2162. pop %a
  2163. pat asp $1==0-2
  2164. with STACK yields bp
  2165. pat asp
  2166. with STACK
  2167. gen add sp,{ANYCON,$1}
  2168. pat ass $1==2
  2169. with rmorconst STACK
  2170. gen add sp,%1
  2171. pat ass !defined($1)
  2172. with rm rmorconst STACK
  2173. gen cmp %1,{ANYCON,2}
  2174. jne {label, ".unknown"}
  2175. add sp,%2
  2176. pat blm $1==0 leaving asp 4
  2177. pat blm $1>0
  2178. kills ALL
  2179. gen mov cx,{ANYCON,$1/2}
  2180. joehoe {label, ".blm"}
  2181. pat bls $1==2
  2182. with CXREG
  2183. kills ALL
  2184. gen sar cx,{ANYCON,1}
  2185. joehoe {label, ".blm"}
  2186. pat bls !defined($1)
  2187. with rm-CXREG CXREG
  2188. kills ALL
  2189. gen cmp %1,{ANYCON,2}
  2190. jne {label, ".unknown"}
  2191. sar cx,{ANYCON,1}
  2192. joehoe {label, ".blm"}
  2193. pat csa $1==2
  2194. with BXREG ACC
  2195. kills ALL
  2196. gen jmp {label, ".csa2"}
  2197. pat csa !defined($1)
  2198. with rm-BXREG-ACC ACC
  2199. kills ALL
  2200. gen cmp %1,{ANYCON,2}
  2201. jne {label, ".unknown"}
  2202. jmp {label, ".csa2"}
  2203. pat csb $1==2
  2204. with BXREG ACC
  2205. kills ALL
  2206. gen jmp {label, ".csb2"}
  2207. pat csb !defined($1)
  2208. with rm-BXREG-ACC BXREG ACC
  2209. gen cmp %1,{ANYCON,2}
  2210. jne {label, ".unknown"}
  2211. jmp {label, ".csb2"}
  2212. pat dup $1==2
  2213. with regorconst yields %1 %1
  2214. with ACC1 yields %1 %1
  2215. pat dup $1==4
  2216. with regorconst regorconst yields %2 %1 %2 %1
  2217. pat dup
  2218. kills ALL
  2219. gen mov cx,{ANYCON,$1}
  2220. joehoe {label, ".dup"}
  2221. pat dus $1==2
  2222. with CXREG
  2223. kills ALL
  2224. gen joehoe {label, ".dup"}
  2225. pat dus !defined($1)
  2226. with rm-CXREG CXREG
  2227. kills ALL
  2228. gen cmp %1,{ANYCON,2}
  2229. jne {label, ".unknown"}
  2230. joehoe {label, ".dup"}
  2231. pat exg $1==2
  2232. with a_word a_word yields %1 %2
  2233. pat exg $1==4
  2234. with a_word a_word a_word a_word yields %2 %1 %4 %3
  2235. pat exg defined($1)
  2236. kills ALL
  2237. gen mov cx,{ANYCON,$1}
  2238. joehoe {label, ".exg"}
  2239. pat exg
  2240. with CXREG
  2241. kills ALL
  2242. gen joehoe {label, ".exg"}
  2243. pat gto
  2244. kills ALL
  2245. gen mov bx,{ADDR_EXTERN,$1}
  2246. jmp {label, ".gto"}
  2247. pat fil
  2248. gen mov {EXTERN2,"hol0+4"},{ADDR_EXTERN,$1}
  2249. pat lim
  2250. uses REG
  2251. gen mov %a,{EXTERN2,".ignmask"} yields %a
  2252. pat lin
  2253. gen mov {EXTERN2,"hol0"},{ANYCON,$1}
  2254. pat lni
  2255. gen inc {EXTERN2,"hol0"}
  2256. pat lor $1==0 yields bp
  2257. pat lor $1==1
  2258. with STACK
  2259. uses REG
  2260. gen mov %a,sp yields %a
  2261. pat lor $1==2
  2262. uses REG
  2263. gen mov %a,{EXTERN2,".reghp"} yields %a
  2264. pat mon
  2265. with ACC
  2266. kills ALL
  2267. gen joehoe {label, ".mon"}
  2268. pat nop
  2269. kills ALL
  2270. gen joehoe {label, ".nop"}
  2271. pat rck $1==2
  2272. with BXREG ACC
  2273. kills ALL
  2274. gen joehoe {label, ".rck"} yields ax
  2275. pat rck !defined($1)
  2276. with rm-BXREG-ACC BXREG ACC
  2277. kills ALL
  2278. gen cmp %1,{ANYCON,2}
  2279. jne {label, ".unknown"}
  2280. joehoe {label, ".rck"} yields ax
  2281. pat rtt leaving ret 0
  2282. pat sig
  2283. with REG
  2284. gen xchg {EXTERN2,".trppc"},%1 yields %1
  2285. pat sim
  2286. with regorconst
  2287. gen mov {EXTERN2,".ignmask"},%1
  2288. pat str $1==0
  2289. with rmorconst
  2290. gen mov bp,%1
  2291. pat str $1==1
  2292. with rmorconst STACK
  2293. gen mov sp,%1
  2294. pat str $1==2
  2295. kills ALL
  2296. gen joehoe {label, ".strhp"}
  2297. pat trp
  2298. with ACC
  2299. kills ALL
  2300. gen joehoe {label, ".Xtrp"}