table 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250
  1. rscid = "$Header$"
  2. #define UNTESTED
  3. EM_WSIZE=2
  4. EM_PSIZE=2
  5. EM_BSIZE=4
  6. SL=4
  7. FORMAT = "0%lo"
  8. TIMEFACTOR = 1/300
  9. illins = "Illegal"
  10. PROPERTIES
  11. GENREG /* All PDP registers */
  12. REG /* Normal registers (allocatable) */
  13. ODDREG /* All odd registers (allocatable) */
  14. REGPAIR(4) /* Register pairs for division */
  15. FLTREG(4) /* Floating point registers, single precision */
  16. DBLREG(8) /* Same, double precision */
  17. GENFREG(4) /* generic floating point */
  18. GENDREG(8) /* generic floating point */
  19. FLTREGPAIR(8) /* register pair for modf */
  20. DBLREGPAIR(16) /* same, double precision */
  21. LOCALBASE /* Guess what */
  22. STACKPOINTER
  23. PROGRAMCOUNTER
  24. REGISTERS
  25. r0 : GENREG,REG.
  26. r2 : GENREG,REG regvar.
  27. r4 : GENREG,REG regvar.
  28. r1,r3 : GENREG,REG,ODDREG.
  29. r01("r0")=r0+r1 : REGPAIR.
  30. fr0("r0"),fr1("r1"),fr2("r2"),fr3("r3") : GENFREG,FLTREG.
  31. dr0("r0")=fr0,dr1("r1")=fr1,dr2("r2")=fr2,dr3("r3")=fr3 : GENDREG,DBLREG.
  32. fr01("r0")=fr0+fr1,fr23("r2")=fr2+fr3 : FLTREGPAIR.
  33. dr01("r0")=dr0+dr1,dr23("r2")=dr2+dr3 : DBLREGPAIR.
  34. lb("r5") : GENREG,LOCALBASE.
  35. sp : GENREG,STACKPOINTER.
  36. pc : GENREG,PROGRAMCOUNTER.
  37. TOKENS
  38. const2 = { INT num; } 2 "$" num .
  39. LOCAL = { INT ind; INT size; } 2 ind "(r5)" .
  40. ILOCAL = { INT ind; } 2 "*" ind "(r5)" .
  41. DLOCAL = { INT ind; INT size; } 4 ind "(r5)" .
  42. addr_local = { INT ind; } 2 .
  43. addr_external = { ADDR off; } 2 "$" off.
  44. regdef2 = { GENREG reg; } 2 "*" reg.
  45. regind2 = { GENREG reg; ADDR off; } 2 off "(" reg ")" .
  46. reginddef2 = { GENREG reg; ADDR off; } 2 "*" off "(" reg ")" .
  47. regconst2 = { GENREG reg; ADDR off; } 2 .
  48. relative2 = { ADDR off; } 2 off .
  49. reldef2 = { ADDR off; } 2 "*" off.
  50. regdef1 = { GENREG reg; } 2 "*" reg.
  51. regind1 = { GENREG reg; ADDR off; } 2 off "(" reg ")" .
  52. reginddef1 = { GENREG reg; ADDR off; } 2 "*" off "(" reg ")" .
  53. relative1 = { ADDR off; } 2 off.
  54. reldef1 = { ADDR off; } 2 "*" off.
  55. autodec = { GENREG reg; } 2 "-(" reg ")".
  56. autoinc = { GENREG reg; } 2 "(" reg ")+".
  57. ftoint = { GENFREG reg; } 2 .
  58. ftolong = { GENFREG reg; } 4 .
  59. regind4 = { GENREG reg; ADDR off; } 4 off "(" reg ")".
  60. reginddef4 = { GENREG reg; ADDR off; } 4 "*" off "(" reg ")".
  61. relative4 = { ADDR off; } 4 off.
  62. reldef4 = { ADDR off; } 4 "*" off.
  63. regdef4 = { GENREG reg; } 4 "*" reg.
  64. regind8 = { GENREG reg; ADDR off; } 8 off "(" reg ")".
  65. reginddef8 = { GENREG reg; ADDR off; } 8 "*" off "(" reg ")".
  66. relative8 = { ADDR off; } 8 off.
  67. reldef8 = { ADDR off; } 8 "*" off.
  68. regdef8 = { GENREG reg; } 8 "*" reg.
  69. label = { ADDR off; } 2 off.
  70. SETS
  71. src2 = GENREG + regdef2 + regind2 + reginddef2 + relative2 +
  72. reldef2 + addr_external + const2 + LOCAL + ILOCAL +
  73. autodec + autoinc .
  74. dst2 = src2 - ( const2 + addr_external ) .
  75. xsrc2 = src2 + ftoint .
  76. src1 = regdef1 + regind1 + reginddef1 + relative1 + reldef1 .
  77. dst1 = src1 .
  78. src1or2 = src1 + src2 .
  79. src4 = relative4 + regdef4 + DLOCAL + regind4 .
  80. dst4 = src4 .
  81. long4 = src4 + REGPAIR .
  82. longf4 = src4 + reldef4 + reginddef4 + FLTREG .
  83. f4src = longf4 + autoinc + autodec .
  84. f4dst = f4src .
  85. long8 = relative8 + regdef8 + regind8 + DBLREG .
  86. double8 = long8 + reldef8 + reginddef8 .
  87. freg = FLTREG + DBLREG .
  88. fsrc = FLTREG + double8 + autoinc + autodec .
  89. fdst = fsrc .
  90. indexed2 = regind2 + reginddef2 .
  91. indexed4 = regind4 .
  92. indexed8 = regind8 .
  93. indexed = indexed2 + indexed4 + indexed8 .
  94. regdeferred = regdef2 + regdef4 + regdef8 .
  95. indordef = indexed + regdeferred .
  96. locals = LOCAL + DLOCAL .
  97. variable2 = relative2 + reldef2 .
  98. variable4 = relative4 .
  99. variable8 = relative8 .
  100. variable = variable2 + variable4 + variable8 .
  101. regs = REG + REGPAIR + FLTREG + DBLREG .
  102. noconst2 = src2 - const2 - addr_external .
  103. allexeptcon = ALL - ( regs + const2 + addr_local + addr_external ) .
  104. externals = relative1 + relative2 + relative4 + relative8 .
  105. posextern = variable + regdeferred + indexed + externals .
  106. diradr2 = regconst2 + addr_external .
  107. INSTRUCTIONS
  108. /* default cost */
  109. cost(2,450)
  110. /* Normal instructions */
  111. adc dst2:rw:cc .
  112. add src2:ro,dst2:rw:cc .
  113. ash src2:ro,REG:rw:cc .
  114. ashc src2:ro,REGPAIR+ODDREG:rw kills :cc .
  115. asl dst2:rw:cc .
  116. asr dst2:rw:cc .
  117. bxx "syntax error" label . /* generic branch used only as bxx* */
  118. bcc label .
  119. bcs label .
  120. beq label .
  121. bge label .
  122. bgt label .
  123. bhi label .
  124. bhis "bcc" label .
  125. bic src2:ro,dst2:rw:cc .
  126. bis src2:ro,dst2:rw:cc .
  127. bisb src1or2:ro,REG:rw kills :cc .
  128. bit src2:ro,src2:ro kills :cc.
  129. ble label .
  130. blo "bcs" label .
  131. blos label .
  132. blt label .
  133. bmi label .
  134. bne label .
  135. bpl label .
  136. br label .
  137. bvc label .
  138. bvs label .
  139. clr dst2:wo:cc .
  140. clrb dst1:wo kills :cc .
  141. cmp src2:ro,src2:ro kills :cc .
  142. cmpb src1or2:ro,src1or2:ro kills :cc .
  143. com dst2:rw:cc .
  144. dec dst2:rw:cc .
  145. div src2:ro,REG:rw kills :cc .
  146. inc dst2:rw:cc .
  147. jbr label .
  148. jeq label .
  149. jne label .
  150. jxx "syntax error" label .
  151. jmp dst2+label kills :cc r0 r1 r3.
  152. jsr GENREG:rw,dst2+label kills :cc r0 r1 r3.
  153. mov src2:ro,dst2:wo:cc .
  154. movb src1or2:ro,dst1+REG:wo kills :cc .
  155. mul src2:ro,ODDREG:rw:cc .
  156. neg dst2:rw:cc .
  157. rol dst2:rw:cc .
  158. ror dst2:rw:cc .
  159. rts GENREG:rw .
  160. sbc dst2:rw:cc .
  161. sob REG:rw,label .
  162. sub src2:ro,dst2:rw:cc .
  163. sxt dst2:wo .
  164. tst src2:ro:cc .
  165. xor REG:ro,dst2:rw:cc .
  166. /* floating point instructions */
  167. cfcc .
  168. setf .
  169. setd .
  170. seti .
  171. setl .
  172. clrf fdst.
  173. negf fdst .
  174. absf fdst .
  175. tstf fsrc .
  176. movf fsrc,freg .
  177. movf freg,fdst .
  178. movif src2,freg .
  179. movif src4,freg .
  180. movfi freg,dst2 .
  181. movfi freg,dst4 .
  182. movof f4src,freg .
  183. movfo freg,f4dst .
  184. movie src2,freg .
  185. movei freg,dst2 .
  186. addf fsrc,freg .
  187. subf fsrc,freg .
  188. mulf fsrc,freg .
  189. divf fsrc,freg .
  190. cmpf fsrc,freg .
  191. modf fsrc,FLTREGPAIR+DBLREGPAIR .
  192. ldfps src2 .
  193. stfps dst2 .
  194. stst dst2 .
  195. /* weirdo instructions */
  196. mfpt kills r0 .
  197. MOVES
  198. from const2 %num==0 to dst2
  199. gen clr %2
  200. from src2 to dst2
  201. gen mov %1,%2
  202. from FLTREG to longf4-FLTREG
  203. gen movfo %1,%2
  204. from longf4-FLTREG to FLTREG
  205. gen movof %1,%2
  206. from FLTREG to FLTREG
  207. gen movf %1,%2
  208. from DBLREG to double8
  209. gen movf %1,%2
  210. from double8 to DBLREG
  211. gen movf %1,%2
  212. from const2 %num==0 to src1
  213. gen clrb %2
  214. from src1or2 to src1
  215. gen movb %1,%2
  216. from ftoint to dst2
  217. gen movfi %1.reg,%2
  218. TESTS
  219. to test src2
  220. gen tst %1
  221. STACKINGRULES
  222. from const2 %num==0 to STACK
  223. gen clr {autodec,sp}
  224. from src2 to STACK
  225. gen mov %1,{autodec,sp}
  226. from regconst2 to STACK
  227. gen mov %1.reg,{autodec,sp}
  228. add {addr_external, %1.off},{regdef2,sp}
  229. from addr_local to STACK
  230. gen mov lb,{autodec,sp}
  231. add {const2, %1.ind},{regdef2,sp}
  232. from DBLREG to STACK
  233. gen movf %1,{autodec,sp}
  234. from FLTREG to STACK
  235. gen movfo %1,{autodec,sp}
  236. from REGPAIR to STACK
  237. gen mov %1.2,{autodec,sp}
  238. mov %1.1,{autodec,sp}
  239. from regind4 to STACK
  240. gen mov {regind2, %1.reg, 2+%1.off},{autodec,sp}
  241. mov {regind2, %1.reg, %1.off},{autodec,sp}
  242. from relative4 to STACK
  243. gen mov {relative2, 2+%1.off},{autodec,sp}
  244. mov {relative2, %1.off},{autodec,sp}
  245. from regdef4 to STACK
  246. gen mov {regind2, %1.reg, 2},{autodec,sp}
  247. mov {regdef2, %1.reg },{autodec,sp}
  248. from regind8 to STACK
  249. uses REG
  250. gen move %1.reg,%a
  251. add {addr_external, 8+%1.off},%a
  252. mov {autodec, %a},{autodec,sp}
  253. mov {autodec, %a},{autodec,sp}
  254. mov {autodec, %a},{autodec,sp}
  255. mov {autodec, %a},{autodec,sp}
  256. from regind8 to STACK
  257. gen mov {regind2, %1.reg, 6+%1.off},{autodec,sp}
  258. mov {regind2, %1.reg, 4+%1.off},{autodec,sp}
  259. mov {regind2, %1.reg, 2+%1.off},{autodec,sp}
  260. mov {regind2, %1.reg, %1.off},{autodec,sp}
  261. from relative8 to STACK
  262. uses REG
  263. gen mov {addr_external, 8+%1.off},%a
  264. mov {autodec, %a},{autodec,sp}
  265. mov {autodec, %a},{autodec,sp}
  266. mov {autodec, %a},{autodec,sp}
  267. mov {autodec, %a},{autodec,sp}
  268. from relative8 to STACK
  269. gen mov {relative2, 6+%1.off},{autodec,sp}
  270. mov {relative2, 4+%1.off},{autodec,sp}
  271. mov {relative2, 2+%1.off},{autodec,sp}
  272. mov {relative2, %1.off},{autodec,sp}
  273. from regdef8 to STACK
  274. gen mov {regind2, %1.reg, 6},{autodec,sp}
  275. mov {regind2, %1.reg, 4},{autodec,sp}
  276. mov {regind2, %1.reg, 2},{autodec,sp}
  277. mov {regdef2, %1.reg },{autodec,sp}
  278. from DLOCAL to STACK
  279. gen mov {LOCAL, 2+%1.ind, 2},{autodec,sp}
  280. mov {LOCAL, %1.ind, 2},{autodec,sp}
  281. from src1 to STACK
  282. gen clr {autodec,sp}
  283. movb %1,{regdef1,sp}
  284. from ftoint to STACK
  285. gen movfi %1.reg,{autodec,sp}
  286. from ftolong to STACK
  287. gen setl.
  288. movfi %1.reg,{autodec,sp}
  289. seti.
  290. COERCIONS
  291. from STACK
  292. uses REG
  293. gen mov {autoinc,sp},%a yields %a
  294. from STACK
  295. uses REG
  296. gen mov {autoinc,sp},%a yields {regconst2, %a, 0}
  297. from STACK
  298. uses FLTREG
  299. gen movof {autoinc,sp},%a yields %a
  300. from STACK
  301. uses DBLREG
  302. gen movf {autoinc,sp},%a yields %a
  303. from STACK
  304. uses REGPAIR
  305. gen mov {autoinc,sp},%a.1
  306. mov {autoinc,sp},%a.2 yields %a
  307. from LOCAL yields {regind2,lb,%1.ind}
  308. from DLOCAL yields {regind4,lb,%1.ind}
  309. from regconst2
  310. uses reusing %1,REG=%1.reg
  311. gen add {addr_external, %1.off},%a yields %a
  312. from addr_local
  313. uses REG
  314. gen mov lb,%a
  315. add {const2, %1.ind},%a yields %a
  316. from REG yields {regconst2, %1, 0}
  317. from xsrc2
  318. uses reusing %1, REG=%1 yields %a
  319. from xsrc2
  320. uses reusing %1, REG=%1 yields {regconst2, %a, 0}
  321. from longf4
  322. uses FLTREG
  323. gen move %1,%a yields %a
  324. from double8
  325. uses DBLREG
  326. gen move %1,%a yields %a
  327. from src1
  328. uses REG={const2,0}
  329. gen bisb %1,%a yields %a
  330. from REGPAIR yields %1.2 %1.1
  331. from regind4 yields {regind2,%1.reg,2+%1.off}
  332. {regind2,%1.reg,%1.off}
  333. from relative4 yields {relative2,2+%1.off}
  334. {relative2,%1.off}
  335. from regdef4 yields {regind2,%1.reg,2}
  336. {regdef2,%1.reg}
  337. from DLOCAL yields {LOCAL, %1.ind+2, 2}
  338. {LOCAL, %1.ind, 2}
  339. /********************************
  340. * from double8 to long4 *
  341. ********************************/
  342. from regind8 yields {regind4,%1.reg,4+%1.off}
  343. {regind4,%1.reg,%1.off}
  344. from relative8 yields {relative4,4+%1.off}
  345. {relative4,%1.off}
  346. from regdef8 yields {regind4,%1.reg,4}
  347. {regdef4,%1.reg}
  348. PATTERNS
  349. /********************************************************
  350. * Group 1 : load instructions. *
  351. * *
  352. * For most load instructions no code is generated. *
  353. * Action : put something on the fake-stack. *
  354. ********************************************************/
  355. pat loc yields {const2, $1}
  356. pat ldc yields {const2, loww($1)}
  357. {const2, highw($1)}
  358. pat lol yields {LOCAL, $1,2}
  359. pat loe yields {relative2, $1}
  360. pat lil yields {ILOCAL, $1}
  361. pat lof
  362. with REG yields {regind2,%1,$1}
  363. with exact regconst2 yields {regind2,%1.reg,$1+%1.off}
  364. with exact addr_external yields {relative2,$1+%1.off}
  365. with exact addr_local yields {LOCAL, %1.ind + $1,2}
  366. pat lal yields {addr_local, $1}
  367. pat lae yields {addr_external, $1}
  368. pat lpb leaving adp SL
  369. pat lxl $1==0 yields lb
  370. pat lxl $1==1 yields {LOCAL ,SL,2}
  371. pat lxl $1==2
  372. uses REG={LOCAL, SL, 2} yields {regind2,%a, SL}
  373. pat lxl $1==3
  374. uses REG={LOCAL, SL, 2}
  375. gen move {regind2,%a, SL},%a yields {regind2,%a, SL}
  376. pat lxl $1>3
  377. uses REG={LOCAL, SL, 2},
  378. REG={const2,$1-1}
  379. gen 1:
  380. move {regind2,%a, SL},%a
  381. sob %b,{label,1b} yields %a
  382. pat lxa $1==0 yields {addr_local, SL}
  383. pat lxa $1==1
  384. uses REG={LOCAL, SL, 2 } yields {regconst2, %a, SL }
  385. pat lxa $1==2
  386. uses REG={LOCAL, SL, 2 }
  387. gen move {regind2, %a, SL }, %a yields {regconst2, %a, SL }
  388. pat lxa $1==3
  389. uses REG={LOCAL, SL, 2 }
  390. gen move {regind2, %a, SL }, %a
  391. move {regind2, %a, SL }, %a yields {regconst2, %a, SL }
  392. pat lxa $1 > 3
  393. uses REG={LOCAL, SL, 2},
  394. REG={const2,$1-1}
  395. gen 1:
  396. move {regind2,%a, SL},%a
  397. sob %b,{label,1b} yields {regconst2, %a, SL }
  398. pat dch leaving loi 2
  399. pat loi $1==2
  400. with REG yields {regdef2, %1}
  401. with exact regconst2 yields {regind2, %1.reg, %1.off}
  402. with exact relative2 yields {reldef2, %1.off}
  403. with exact regind2 yields {reginddef2, %1.reg, %1.off}
  404. with exact regdef2 yields {reginddef2, %1.reg, 0}
  405. with exact addr_local yields {LOCAL, %1.ind,2}
  406. with exact addr_external yields {relative2, %1.off}
  407. with exact LOCAL yields {reginddef2, lb, %1.ind}
  408. pat loi $1==1
  409. with REG yields {regdef1, %1}
  410. with exact regconst2 yields {regind1, %1.reg, %1.off}
  411. with exact addr_external yields {relative1, %1.off}
  412. with exact addr_local yields {regind1, lb, %1.ind}
  413. with exact relative2 yields {reldef1, %1.off}
  414. with exact regind2 yields {reginddef1, %1.reg, %1.off}
  415. with exact regdef2 yields {reginddef1, %1.reg, 0}
  416. with exact LOCAL yields {reginddef1, lb, %1.ind}
  417. pat loi $1==4
  418. with REG yields {regdef4, %1}
  419. with exact regconst2 yields {regind4, %1.reg, %1.off}
  420. with exact addr_local yields {DLOCAL,%1.ind,4}
  421. with exact addr_external yields {relative4, %1.off}
  422. pat loi $1==8
  423. with REG yields {regdef8, %1}
  424. with exact regconst2 yields {regind8, %1.reg, %1.off}
  425. with exact addr_local yields {regind8, lb , %1.ind}
  426. with exact addr_external yields {relative8, %1.off}
  427. pat loi
  428. with exact addr_local
  429. kills ALL
  430. uses REG={const2,$1/2}, REG
  431. gen move lb,%b
  432. add {const2,%1.ind+$1},%b
  433. 1:
  434. mov {autodec,%b},{autodec,sp}
  435. sob %a,{label,1b}
  436. with exact addr_external
  437. kills ALL
  438. uses REG={const2,$1/2}, REG
  439. gen mov {addr_external,%1.off+$1},%b
  440. 1:
  441. mov {autodec,%b},{autodec,sp}
  442. sob %a,{label,1b}
  443. with REG
  444. kills ALL
  445. uses REG={const2,$1}
  446. gen add %a,%1
  447. asr %a
  448. 1:
  449. mov {autodec,%1},{autodec,sp}
  450. sob %a,{label,1b}
  451. pat ldl yields {DLOCAL, $1,4}
  452. pat lde yields {relative4, $1}
  453. pat ldf
  454. with regconst2 yields {regind4,%1.reg,$1+%1.off}
  455. with exact addr_external yields {relative4, $1+%1.off}
  456. with exact addr_local yields {DLOCAL, %1.ind+$1,4}
  457. pat lpi yields {addr_external, $1}
  458. /****************************************************************
  459. * Group 2 : Store instructions. *
  460. * *
  461. * These instructions are likely to ruin the fake-stack. *
  462. * We don't expect many items on the fake-stack anyway *
  463. * because we seem to have evaluated an expression just now. *
  464. ****************************************************************/
  465. pat stl with xsrc2
  466. kills indordef, locals %ind <= $1 && %ind+%size > $1
  467. gen move %1,{LOCAL,$1,2}
  468. pat ste with xsrc2
  469. kills posextern
  470. gen move %1, {relative2, $1 }
  471. pat sil with xsrc2
  472. kills allexeptcon
  473. gen move %1, {reginddef2,lb,$1}
  474. pat stf
  475. with regconst2 xsrc2
  476. kills allexeptcon
  477. gen move %2,{regind2,%1.reg,$1+%1.off}
  478. with addr_external xsrc2
  479. kills allexeptcon
  480. gen move %2,{relative2,$1+%1.off}
  481. pat sti $1==2
  482. with REG xsrc2
  483. kills allexeptcon
  484. gen move%2,{regdef2,%1}
  485. with regconst2 xsrc2
  486. kills allexeptcon
  487. gen move%2,{regind2,%1.reg,%1.off}
  488. with addr_external xsrc2
  489. kills allexeptcon
  490. gen move %2,{relative2,%1.off}
  491. with addr_local xsrc2
  492. kills allexeptcon
  493. gen move %2,{LOCAL, %1.ind, 2}
  494. with relative2 xsrc2
  495. kills allexeptcon
  496. gen move %2,{reldef2,%1.off}
  497. with regind2 xsrc2
  498. kills allexeptcon
  499. gen move %2,{reginddef2,%1.reg,%1.off}
  500. pat sti $1==1
  501. with REG src1or2
  502. kills allexeptcon
  503. gen move %2,{regdef1,%1}
  504. with exact regconst2 src1or2
  505. kills allexeptcon
  506. gen move %2,{regind1,%1.reg,%1.off}
  507. with exact addr_external src1or2
  508. kills allexeptcon
  509. gen move %2,{relative1,%1.off}
  510. with exact addr_local src1or2
  511. kills allexeptcon
  512. gen move %2,{regind1, lb, %1.ind}
  513. with exact relative2 src1or2
  514. kills allexeptcon
  515. gen move %2,{reldef1,%1.off}
  516. with exact regind2 src1or2
  517. kills allexeptcon
  518. gen move %2,{reginddef1,%1.reg,%1.off}
  519. pat sti $1==4
  520. with exact REG FLTREG
  521. kills allexeptcon
  522. gen movfo %2,{regdef4,%1}
  523. with exact regind2 FLTREG
  524. kills allexeptcon
  525. gen movfo %2,{reginddef4,%1.reg,%1.off}
  526. with exact relative2 FLTREG
  527. kills allexeptcon
  528. gen movfo %2,{reldef4,%1.off}
  529. with exact REG ftolong
  530. kills allexeptcon
  531. gen setl.
  532. movfi %2.reg,{regdef2,%1}
  533. seti.
  534. with exact regind2 ftolong
  535. kills allexeptcon
  536. gen setl.
  537. movfi %2.reg,{reginddef2,%1.reg,%1.off}
  538. seti.
  539. with exact relative2 ftolong
  540. kills allexeptcon
  541. gen setl.
  542. movfi %2.reg,{reldef2,%1.off}
  543. seti.
  544. with exact regconst2 FLTREG
  545. kills allexeptcon
  546. gen movfo %2,{regind4,%1.reg,%1.off}
  547. with exact regconst2 ftolong
  548. kills allexeptcon
  549. gen setl.
  550. movfi %2.reg,{regind2,%1.reg,%1.off}
  551. seti.
  552. with exact addr_local FLTREG
  553. kills allexeptcon
  554. gen movfo %2,{DLOCAL,%1.ind,4}
  555. with exact addr_local ftolong
  556. kills allexeptcon
  557. gen setl.
  558. movfi %2.reg,{DLOCAL,%1.ind,4}
  559. seti.
  560. with exact addr_external FLTREG
  561. kills allexeptcon
  562. gen movfo %2,{relative4,%1.off}
  563. with exact addr_external ftolong
  564. kills allexeptcon
  565. gen setl.
  566. movfi %2.reg,{relative2,%1.off}
  567. seti.
  568. with REG src2 src2
  569. kills allexeptcon
  570. gen move %2,{regdef2,%1}
  571. move %3,{regind2,%1,2}
  572. with REG
  573. kills ALL
  574. gen mov {autoinc,sp},{autoinc,%1}
  575. mov {autoinc,sp},{regdef2,%1}
  576. pat sti $1==8
  577. with exact REG DBLREG
  578. kills allexeptcon
  579. gen movf %2,{regdef8,%1}
  580. with exact regind2 DBLREG
  581. kills allexeptcon
  582. gen movf %2,{reginddef8,%1.reg,%1.off}
  583. with exact relative2 DBLREG
  584. kills allexeptcon
  585. gen movf %2,{reldef8,%1.off}
  586. with exact regconst2 DBLREG
  587. kills allexeptcon
  588. gen movf %2,{regind8,%1.reg,%1.off}
  589. with exact addr_local DBLREG
  590. kills allexeptcon
  591. gen movf %2,{regind8, lb, %1.ind}
  592. with exact addr_external DBLREG
  593. kills allexeptcon
  594. gen movf %2,{relative8, %1.off}
  595. with REG regind8
  596. kills allexeptcon
  597. gen mov {regind2,%2.reg,%2.off },{autoinc,%1}
  598. mov {regind2,%2.reg,%2.off+2},{autoinc,%1}
  599. mov {regind2,%2.reg,%2.off+4},{autoinc,%1}
  600. mov {regind2,%2.reg,%2.off+6},{regdef2,%1}
  601. with REG relative8
  602. kills allexeptcon
  603. uses REG={addr_external,%2.off}
  604. gen mov {autoinc,%a},{autoinc,%1}
  605. mov {autoinc,%a},{autoinc,%1}
  606. mov {autoinc,%a},{autoinc,%1}
  607. mov {regdef2,%a},{regdef2,%1}
  608. with REG
  609. kills ALL
  610. gen mov {autoinc,sp},{autoinc,%1}
  611. mov {autoinc,sp},{autoinc,%1}
  612. mov {autoinc,sp},{autoinc,%1}
  613. mov {autoinc,sp},{regdef2,%1}
  614. pat sti
  615. with REG
  616. kills ALL
  617. uses REG={const2,$1/2}
  618. gen 1:
  619. mov {autoinc,sp},{autoinc,%1}
  620. sob %a,{label,1b}
  621. pat lal sti $2>2 && $2<=8
  622. with exact xsrc2
  623. yields %1
  624. leaving stl $1 lal $1+2 sti $2-2
  625. with
  626. yields {addr_local,$1}
  627. leaving sti $2
  628. pat sdl
  629. with exact FLTREG
  630. kills indordef, locals %ind <= $1+2 && %ind+%size > $1
  631. gen move %1,{DLOCAL,$1,4}
  632. with exact ftolong
  633. kills indordef, locals %ind <= $1+2 && %ind+%size > $1
  634. gen setl.
  635. movfi %1.reg,{DLOCAL,$1,4}
  636. seti.
  637. with src2 src2
  638. kills indordef, locals %ind <= $1+2 && %ind+%size > $1
  639. gen move %1,{LOCAL,$1,2}
  640. move %2,{LOCAL,$1+2,2}
  641. pat sde
  642. with exact FLTREG
  643. kills posextern
  644. gen move %1,{relative4,$1}
  645. with exact ftolong
  646. kills posextern
  647. gen setl.
  648. movfi %1.reg,{relative4,$1}
  649. seti.
  650. with src2 src2
  651. kills posextern
  652. gen move %1, {relative2, $1 }
  653. move %2, {relative2, $1+2}
  654. pat sdf
  655. with exact regconst2 FLTREG
  656. kills allexeptcon
  657. gen move %2,{regind4,%1.reg,$1+%1.off}
  658. with exact regconst2 ftolong
  659. kills allexeptcon
  660. gen setl.
  661. movfi %2.reg,{regind4,%1.reg,$1+%1.off}
  662. seti.
  663. with exact addr_external FLTREG
  664. kills allexeptcon
  665. gen move %2,{relative4,$1+%1.off}
  666. with exact addr_external ftolong
  667. kills allexeptcon
  668. gen setl.
  669. movfi %2.reg,{relative4, $1+%1.off}
  670. seti.
  671. with regconst2 src2 src2
  672. kills allexeptcon
  673. gen move %2,{regind2,%1.reg,$1+%1.off}
  674. move %3,{regind2,%1.reg,$1+2+%1.off}
  675. with addr_external src2 src2
  676. kills allexeptcon
  677. gen move %2,{relative2,$1+%1.off}
  678. move %3,{relative2,$1+2+%1.off}
  679. /****************************************************************
  680. * Group 3 : Integer arithmetic. *
  681. * *
  682. * Implemented (sometimes with the use of subroutines) : *
  683. * all 2 and 4 byte arithmetic. *
  684. ****************************************************************/
  685. pat adi $1==2
  686. with exact REG const2 yields {regconst2,%1,%2.num}
  687. with exact REG addr_external yields {regconst2,%1,%2.off}
  688. with exact REG addr_local
  689. gen add lb,%1 yields {regconst2,%1,%2.ind}
  690. with exact REG addr_local
  691. uses REG
  692. gen mov lb,%a
  693. add %1,%a yields {regconst2,%a,%2.ind}
  694. with exact REG regconst2
  695. gen add %2.reg,%1 yields {regconst2,%1,%2.off}
  696. with exact src2-REG const2+addr_external+addr_local
  697. uses reusing %1,REG=%1 yields %2 %a
  698. leaving adi 2
  699. with exact regconst2 const2 yields {regconst2,%1.reg,%2.num+%1.off}
  700. with exact regconst2 addr_external yields {regconst2,%1.reg,%2.off+%1.off}
  701. with exact regconst2 addr_local
  702. gen add lb,%1.reg yields {regconst2,%1.reg,%2.ind+%1.off}
  703. with exact regconst2 regconst2
  704. gen add %2.reg,%1.reg yields {regconst2,%1.reg,%2.off+%1.off}
  705. with exact regconst2 noconst2
  706. gen add %2,%1.reg yields %1
  707. with exact REG noconst2
  708. gen add %2,%1 yields %1
  709. with exact src2 regconst2
  710. gen add %1,%2.reg yields %2
  711. with exact regconst2 src2
  712. gen add %2,%1.reg yields %1
  713. with src2 REG
  714. gen add %1,%2 yields %2
  715. pat adi $1==4
  716. with REG REG src2 src2
  717. gen add %4,%2
  718. adc %1
  719. add %3,%1 yields %2 %1
  720. with REG REG src2 STACK
  721. gen add {autoinc,sp},%2
  722. adc %1
  723. add %3,%1 yields %2 %1
  724. with REG REG STACK
  725. gen add {autoinc,sp},%1
  726. add {autoinc,sp},%2
  727. adc %1 yields %2 %1
  728. with src2 src2 REG REG
  729. gen add %2,%4
  730. adc %3
  731. add %1,%3 yields %4 %3
  732. pat sbi $1==2
  733. with src2 REG
  734. gen sub %1,%2 yields %2
  735. with exact REG src2-REG
  736. gen sub %2,%1
  737. neg %1 yields %1
  738. pat sbi $1==4
  739. with src2-REG src2-REG REG REG
  740. gen sub %2,%4
  741. sbc %3
  742. sub %1,%3 yields %4 %3
  743. with src2 src2 STACK
  744. gen sub %2,{regind2,sp,2}
  745. sbc {regdef2,sp}
  746. sub %1,{regdef2,sp}
  747. pat mli $1==2
  748. with ODDREG src2
  749. gen mul %2,%1 yields %1
  750. with src2 ODDREG
  751. gen mul %1,%2 yields %2
  752. pat mli $1==4
  753. kills ALL
  754. gen jsr pc,{label, "mli4~"} yields r1 r0
  755. pat dvi $1==2
  756. with src2 src2
  757. uses reusing %2,REGPAIR
  758. gen mov %2,%a.2
  759. sxt %a.1
  760. div %1,%a.1 yields %a.1
  761. with src2 src2 STACK
  762. gen mov %1,{autodec,sp}
  763. mov %2,r1
  764. sxt r0
  765. div {autoinc,sp},r0 yields r0
  766. pat dvi $1==4
  767. kills ALL
  768. gen jsr pc,{label, "dvi4~"} yields r1 r0
  769. pat rmi $1==2
  770. with src2 src2
  771. uses reusing %2,REGPAIR
  772. gen mov %2,%a.2
  773. sxt %a.1
  774. div %1,%a.1 yields %a.2
  775. with src2 src2 STACK
  776. gen mov %1,{autodec,sp}
  777. mov %2,r1
  778. sxt r0
  779. div {autoinc,sp},r0 yields r1
  780. pat rmi $1==4
  781. kills ALL
  782. gen jsr pc,{label, "rmi4~"} yields r1 r0
  783. pat ngi $1==2
  784. with REG
  785. gen neg %1 yields %1
  786. pat ngi $1==4
  787. with REG REG
  788. gen neg %1
  789. neg %2
  790. sbc %1 yields %2 %1
  791. pat loc sli $1==1 && $2==2
  792. with REG
  793. gen asl %1 yields %1
  794. pat sli $1==2
  795. with src2 REG
  796. gen ash %1,%2 yields %2
  797. pat sli $1==4
  798. with src2 REGPAIR
  799. gen ashc %1,%2 yields %2
  800. pat loc sri $1==1 && $2==2
  801. with REG
  802. gen asr %1 yields %1
  803. pat loc sri $2==2
  804. with REG
  805. gen ash {const2,0-$1},%1 yields %1
  806. pat sri $1==2
  807. with REG REG
  808. gen neg %1
  809. ash %1,%2 yields %2
  810. pat loc sri $2==4
  811. with REGPAIR
  812. gen ashc {const2,0-$1},%1 yields %1
  813. pat sri $1==4
  814. with REG REGPAIR
  815. gen neg %1
  816. ashc %1,%2 yields %2
  817. /************************************************
  818. * Group 4 : unsigned arithmetic *
  819. * *
  820. * adu = adi *
  821. * sbu = sbi *
  822. * slu = sli *
  823. * *
  824. * Supported : 2- and 4 byte arithmetic. *
  825. ************************************************/
  826. pat adu leaving adi $1
  827. pat sbu leaving sbi $1
  828. pat mlu $1==2 leaving mli 2
  829. pat mlu $1==4
  830. kills ALL
  831. gen jsr pc,{label, "mlu4~"} yields r1 r0
  832. pat dvu $1==2
  833. kills ALL
  834. gen jsr pc,{label, "dvu2~"} yields r0
  835. pat dvu $1==4
  836. kills ALL
  837. gen jsr pc,{label, "dvu4~"} yields r1 r0
  838. pat rmu $1==2
  839. kills ALL
  840. gen jsr pc,{label, "rmu2~"} yields r1
  841. pat rmu $1==4
  842. kills ALL
  843. gen jsr pc,{label, "rmu4~"} yields r1 r0
  844. pat slu leaving sli $1
  845. pat sru $1==2
  846. with REG xsrc2
  847. uses reusing %2,REGPAIR
  848. gen move %2,%a.2
  849. move {const2,0},%a.1
  850. neg %1
  851. ashc %1,%a yields %a.2
  852. pat loc sru $2==2
  853. with xsrc2
  854. uses reusing %1,REGPAIR
  855. gen move %1,%a.2
  856. move {const2,0},%a.1
  857. ashc {const2,0-$1},%a yields %a.2
  858. pat sru $1==4
  859. kills ALL
  860. gen move {const2,$1},r0
  861. jsr pc,{label, "sru~"}
  862. /************************************************
  863. * Group 5 : Floating point arithmetic *
  864. * *
  865. * Supported : 4- and 8 byte arithmetic. *
  866. ************************************************/
  867. pat adf $1==4
  868. with FLTREG FLTREG
  869. gen addf %1,%2 yields %2
  870. with FLTREG FLTREG
  871. gen addf %2,%1 yields %1
  872. pat adf $1==8
  873. with double8 DBLREG
  874. gen addf %1,%2 yields %2
  875. with DBLREG double8
  876. gen addf %2,%1 yields %1
  877. pat sbf $1==4
  878. with FLTREG FLTREG
  879. gen subf %1,%2 yields %2
  880. pat sbf $1==8
  881. with double8 DBLREG
  882. gen subf %1,%2 yields %2
  883. pat mlf $1==4
  884. with FLTREG FLTREG
  885. gen mulf %1,%2 yields %2
  886. with FLTREG FLTREG
  887. gen mulf %2,%1 yields %1
  888. pat mlf $1==8
  889. with double8 DBLREG
  890. gen mulf %1,%2 yields %2
  891. with DBLREG double8
  892. gen mulf %2,%1 yields %1
  893. pat dvf $1==4
  894. with FLTREG FLTREG
  895. gen divf %1,%2 yields %2
  896. pat dvf $1==8
  897. with double8 DBLREG
  898. gen divf %1,%2 yields %2
  899. pat ngf $1==4
  900. with FLTREG
  901. gen negf %1 yields %1
  902. pat ngf $1==8
  903. with DBLREG
  904. gen negf %1 yields %1
  905. pat fif $1==4
  906. with longf4 FLTREG
  907. uses FLTREGPAIR
  908. gen move %1,%a.1
  909. modf %2,%a yields %a.1 %a.2
  910. pat fif $1==8
  911. with double8 double8
  912. uses DBLREGPAIR
  913. gen move %1,%a.1
  914. modf %2,%a yields %a.1 %a.2
  915. pat fef $1==4
  916. with FLTREG
  917. uses REG
  918. gen movei %1,%a
  919. movie {const2,0},%1 yields %1 %a
  920. pat fef $1==8
  921. with DBLREG
  922. uses REG
  923. gen movei %1,%a
  924. movie {const2,0},%1 yields %1 %a
  925. /****************************************
  926. * Group 6 : pointer arithmetic. *
  927. * *
  928. * Pointers have size 2 bytes. *
  929. ****************************************/
  930. pat adp
  931. with REG yields {regconst2, %1, $1}
  932. with exact regconst2 yields {regconst2, %1.reg, $1+%1.off}
  933. with exact addr_external yields {addr_external, $1+%1.off}
  934. with exact addr_local yields {addr_local,%1.ind+$1}
  935. pat ads $1==2 leaving adi 2
  936. pat sbs $1==2 leaving sbi $1
  937. /****************************************
  938. * Group 7 : increment/decrement/zero *
  939. ****************************************/
  940. pat inc
  941. with REG
  942. gen inc %1 yields %1
  943. pat inl
  944. kills indordef, locals %ind <= $1 && %ind+%size > $1
  945. gen inc {LOCAL,$1,2}
  946. pat ine
  947. kills posextern
  948. gen inc {relative2, $1}
  949. pat dec
  950. with REG
  951. gen dec %1 yields %1
  952. pat del
  953. kills indordef, locals %ind <= $1 && %ind+%size > $1
  954. gen dec {LOCAL, $1, 2}
  955. pat dee
  956. kills posextern
  957. gen dec {relative2, $1}
  958. pat lol loc sbi stl $1==$4 && $3==2
  959. kills indordef, locals %ind <= $1 && %ind+%size > $1
  960. gen sub {const2,$2},{LOCAL,$1,2}
  961. pat lol ngi stl $1==$3 && $2==2
  962. kills indordef, locals %ind <= $1 && %ind+%size > $1
  963. gen neg {LOCAL, $1, 2}
  964. pat lil ngi sil $1==$3 && $2==2
  965. kills allexeptcon
  966. gen neg {ILOCAL, $1}
  967. pat lil inc sil $1==$3
  968. kills allexeptcon
  969. gen inc {ILOCAL, $1}
  970. pat lol adi stl $2==2 && $1==$3
  971. with src2
  972. kills indordef, locals %ind <= $1 && %ind+%size > $1
  973. gen add %1,{LOCAL, $1, 2}
  974. pat lol adp stl $1==$3 && $2==1
  975. kills indordef, locals %ind <= $1 && %ind+%size > $1
  976. gen inc {LOCAL, $1, 2}
  977. pat lol adp stl $1==$3
  978. kills indordef, locals %ind <= $1 && %ind+%size > $1
  979. gen add {const2, $2},{LOCAL, $1, 2}
  980. pat loe adi ste $2==2 && $1==$3
  981. with src2
  982. kills posextern
  983. gen add %1,{relative2, $1}
  984. pat loe adp ste $1==$3
  985. kills posextern
  986. gen add {const2, $2},{relative2, $1}
  987. pat lol ior stl $2==2 && $1==$3
  988. with src2
  989. kills indordef, locals %ind <= $1 && %ind+%size > $1
  990. gen bis %1,{LOCAL, $1, 2}
  991. pat loe ior ste $2==2 && $1==$3
  992. with src2
  993. kills posextern
  994. gen bis %1,{relative2, $1}
  995. pat lol and stl $2==2 && $1==$3
  996. with REG
  997. kills indordef, locals %ind <= $1 && %ind+%size > $1
  998. gen com %1
  999. bic %1,{LOCAL, $1, 2}
  1000. pat loe and ste $2==2 && $1==$3
  1001. with REG
  1002. kills posextern
  1003. gen com %1
  1004. bic %1,{relative2, $1}
  1005. pat loc lol and stl $3==2 && $2==$4
  1006. kills indordef, locals %ind <= $2 && %ind+%size > $2
  1007. gen bic {const2, ~$1},{LOCAL, $2, 2}
  1008. pat loc loe and ste $3==2 && $2==$4
  1009. kills posextern
  1010. gen bic {const2, ~$1},{relative2, $2}
  1011. pat zrl
  1012. kills indordef, locals %ind <= $1 && %ind+%size > $1
  1013. gen clr {LOCAL, $1, 2}
  1014. pat zre
  1015. kills posextern
  1016. gen clr {relative2, $1}
  1017. pat zrf $1==4
  1018. uses FLTREG
  1019. gen clrf %a yields %a
  1020. pat zrf $1==8
  1021. uses DBLREG
  1022. gen clrf %a yields %a
  1023. pat zer $1==2 yields {const2, 0}
  1024. pat zer $1==4 yields {const2,0} {const2,0}
  1025. pat zer $1==6 yields {const2,0} {const2,0} {const2,0}
  1026. pat zer $1==8 yields {const2,0} {const2,0}
  1027. {const2,0} {const2,0}
  1028. pat zer defined($1)
  1029. with STACK
  1030. gen move {const2,$1/2},r0
  1031. 1:
  1032. clr {autodec,sp}
  1033. sob r0,{label, 1b}
  1034. /****************************************
  1035. * Group 8 : Convert instructions *
  1036. ****************************************/
  1037. pat cii
  1038. kills ALL
  1039. gen jsr pc,{label, "cii~"}
  1040. pat cfi leaving cfu
  1041. pat ciu leaving cuu
  1042. pat cui leaving cuu
  1043. pat cfu
  1044. kills ALL
  1045. gen jsr pc,{label, "cfi~"}
  1046. pat cif
  1047. kills ALL
  1048. gen jsr pc,{label, "cif~"}
  1049. pat cuf
  1050. kills ALL
  1051. gen jsr pc,{label, "cuf~"}
  1052. pat cff
  1053. kills ALL
  1054. gen jsr pc,{label, "cff~"}
  1055. pat cuu
  1056. kills ALL
  1057. gen jsr pc,{label, "cuu~"}
  1058. pat loc loc cii $1==1 && $2==2
  1059. with src1or2
  1060. uses reusing %1,REG
  1061. gen movb %1,%a yields %a
  1062. pat loc loc cii $1==1 && $2==4
  1063. with src1or2
  1064. uses reusing %1,REG,REG
  1065. gen movb %1,%a
  1066. sxt %b yields %a %b
  1067. pat loc loc cii $1==2 && $2==4
  1068. with src2
  1069. uses reusing %1,REG,REG
  1070. gen move %1,%a
  1071. test %a
  1072. sxt %b yields %a %b
  1073. pat loc loc loc cii $1>=0 && $2==2 && $3==4 leaving loc $1 loc 0
  1074. pat loc loc loc cii $1< 0 && $2==2 && $3==4 leaving loc $1 loc 0-1
  1075. pat loc loc cii $1==4 && $2==2
  1076. with src2
  1077. pat loc loc cuu $1==2 && $2==4 leaving loc 0
  1078. pat loc loc cuu $1==4 && $2==2
  1079. with src2
  1080. pat loc loc cfu $1==4
  1081. with FLTREG yields {ftolong,%1}
  1082. leaving loc 4 loc $2 cuu
  1083. pat loc loc cfu $1==8
  1084. with DBLREG yields {ftolong,%1.1}
  1085. leaving loc 4 loc $2 cuu
  1086. pat loc loc cfi $1==4 && $2==2
  1087. with FLTREG yields {ftoint,%1}
  1088. pat loc loc cfi $1==4 && $2==4
  1089. with FLTREG yields {ftolong,%1}
  1090. pat loc loc cfi $1==8 && $2==2
  1091. with DBLREG yields {ftoint,%1.1}
  1092. pat loc loc cfi $1==8 && $2==4
  1093. with DBLREG yields {ftolong,%1.1}
  1094. pat loc loc cif $1==2 && $2==4
  1095. with src2
  1096. uses FLTREG
  1097. gen movif %1,%a yields %a
  1098. pat loc loc cif $1==2 && $2==8
  1099. with src2
  1100. uses DBLREG
  1101. gen movif %1,%a yields %a
  1102. pat loc loc cif $1==4 && $2==4
  1103. with exact long4-REGPAIR
  1104. uses FLTREG
  1105. gen setl.
  1106. movif %1,%a
  1107. seti. yields %a
  1108. with STACK
  1109. uses FLTREG
  1110. gen setl.
  1111. movif {autoinc,sp},%a
  1112. seti. yields %a
  1113. pat loc loc cif $1==4 && $2==8
  1114. with exact long4-REGPAIR
  1115. uses DBLREG
  1116. gen setl.
  1117. movif %1,%a
  1118. seti. yields %a
  1119. with STACK
  1120. uses DBLREG
  1121. gen setl.
  1122. movif {autoinc,sp},%a
  1123. seti. yields %a
  1124. pat loc loc cuf $1==2 && $2==4
  1125. with STACK
  1126. uses FLTREG
  1127. gen clr {autodec,sp}
  1128. setl.
  1129. movif {autoinc,sp},%a
  1130. seti. yields %a
  1131. pat loc loc cuf $1==2 && $2==8
  1132. with STACK
  1133. uses DBLREG
  1134. gen clr {autodec,sp}
  1135. setl.
  1136. movif {autoinc,sp},%a
  1137. seti. yields %a
  1138. pat loc loc cuf $1==4 leaving loc $1 loc $2 cif
  1139. pat loc loc cff $1==4 && $2==8
  1140. with longf4 - FLTREG
  1141. uses DBLREG
  1142. gen movof %1,%a yields %a
  1143. with FLTREG
  1144. uses DBLREG
  1145. gen move %1,%a.1 yields %a
  1146. pat loc loc cff $1==8 && $2==4
  1147. with DBLREG yields %1.1
  1148. /****************************************
  1149. * Group 9 : Logical instructions *
  1150. ****************************************/
  1151. pat and $1==2
  1152. with const2 REG
  1153. gen bic {const2,~%1.num},%2 yields %2
  1154. with REG const2
  1155. gen bic {const2,~%2.num},%1 yields %1
  1156. with REG REG
  1157. gen com %1
  1158. bic %1,%2 yields %2
  1159. pat and defined($1)
  1160. kills ALL
  1161. gen move {const2,$1}, r0
  1162. jsr pc,{label, "and~"}
  1163. pat ior $1==2
  1164. with REG src2
  1165. gen bis %2,%1 yields %1
  1166. with src2 REG
  1167. gen bis %1,%2 yields %2
  1168. pat ior $1==8
  1169. with exact src2 src2 src2 src2 STACK
  1170. gen bis %1,{regdef2,sp}
  1171. bis %2,{regind2,sp,2}
  1172. bis %3,{regind2,sp,4}
  1173. bis %4,{regind2,sp,6}
  1174. with STACK
  1175. uses REG={const2,$1}
  1176. gen add sp,%a
  1177. bis {autoinc,sp},{autoinc,%a}
  1178. bis {autoinc,sp},{autoinc,%a}
  1179. bis {autoinc,sp},{autoinc,%a}
  1180. bis {autoinc,sp},{autoinc,%a}
  1181. pat ior defined($1)
  1182. with STACK
  1183. uses REG={const2,$1},REG={const2,$1/2}
  1184. gen add sp,%a
  1185. 1:
  1186. bis {autoinc,sp},{autoinc,%a}
  1187. sob %b,{label,1b}
  1188. pat xor $1==2
  1189. with REG REG
  1190. gen xor %1,%2 yields %2
  1191. with REG REG
  1192. gen xor %2,%1 yields %1
  1193. pat xor defined($1)
  1194. kills ALL
  1195. gen move {const2,$1},r0
  1196. jsr pc,{label, "xor~"}
  1197. pat com $1==2
  1198. with REG
  1199. gen com %1 yields %1
  1200. pat com defined($1)
  1201. with STACK
  1202. uses REG={const2,$1/2},REG
  1203. gen mov sp,%b
  1204. 1:
  1205. com {autoinc,%b}
  1206. sob %a,{label,1b}
  1207. pat rol $1==2
  1208. with const2 ODDREG
  1209. gen ashc {const2,%1.num-16},%2 yields %2
  1210. with REG ODDREG
  1211. gen sub {const2,16},%1
  1212. ashc %1,%2 yields %2
  1213. pat rol defined($1)
  1214. kills ALL
  1215. gen move {const2,$1},r0
  1216. jsr pc,{label, "rol~"}
  1217. pat ror $1==2
  1218. with const2 ODDREG
  1219. gen ashc {const2,0-%1.num},%2 yields %2
  1220. with REG ODDREG
  1221. gen neg %1
  1222. ashc %1,%2 yields %2
  1223. pat ror defined($1)
  1224. kills ALL
  1225. gen move {const2,$1},r0
  1226. jsr pc,{label, "ror~"}
  1227. pat com and $1==2 && $2==2
  1228. with src2 REG
  1229. gen bic %1,%2 yields %2
  1230. pat com and $1==$2
  1231. with STACK
  1232. uses REG={const2,$1},REG
  1233. gen mov sp,%b
  1234. add %a,%b
  1235. asr %a
  1236. 1:
  1237. bic {autoinc,sp},{autoinc,%b}
  1238. sob %a,{label,1b}
  1239. /********************************
  1240. * Group 10 : Set instructions *
  1241. ********************************/
  1242. pat inn $1==2
  1243. with REG REG
  1244. gen neg %1
  1245. ash %1,%2
  1246. bic {const2,0177776},%2 yields %2
  1247. pat loc inn $2==2 && $1==0
  1248. with REG
  1249. gen bic {const2,0177776},%1 yields %1
  1250. pat loc inn $2==2 && $1==1
  1251. with REG
  1252. gen asr %1
  1253. bic {const2,0177776},%1 yields %1
  1254. pat loc inn $2==2
  1255. with REG
  1256. gen ash {const2,0-$1},%1
  1257. bic {const2,0177776},%1 yields %1
  1258. pat loc inn zeq $2==2 yields {const2, 1<<$1}
  1259. leaving and 2 zeq $3
  1260. pat inn zeq $1==2
  1261. with src2
  1262. uses REG={const2,1}
  1263. gen ash %1,%a yields %a
  1264. leaving and 2 zeq $2
  1265. pat loc inn zne $2==2 yields {const2, 1<<$1}
  1266. leaving and 2 zne $3
  1267. pat inn zne $1==2
  1268. with src2
  1269. uses REG={const2,1}
  1270. gen ash %1,%a yields %a
  1271. leaving and 2 zne $2
  1272. pat inn defined($1)
  1273. with src2
  1274. kills ALL
  1275. gen move %1,r1
  1276. move {const2,$1},r0
  1277. jsr pc,{label, "inn~"} yields r0
  1278. pat set $1==2
  1279. with REG
  1280. uses REG={const2,1}
  1281. gen ash %1,%a yields %a
  1282. pat set defined($1)
  1283. with src2
  1284. kills ALL
  1285. gen move %1,r1
  1286. move {const2,$1},r0
  1287. jsr pc,{label, "set~"}
  1288. /****************************************
  1289. * Group 11 : Array instructions *
  1290. ****************************************/
  1291. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)==0 leaving adi 2
  1292. pat lae aar $2==2 && rom($1,3)==1 && rom($1,1)!=0 leaving adi 2 adp 0-rom($1,1)
  1293. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)==0
  1294. with REG
  1295. gen asl %1 yields %1 leaving adi 2
  1296. pat lae aar $2==2 && rom($1,3)==2 && rom($1,1)!=0
  1297. with REG
  1298. gen asl %1 yields {regconst2,%1,(0-2)*rom($1,1)}
  1299. leaving adi 2
  1300. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)==0
  1301. with REG
  1302. gen ash {const2,2},%1 yields %1 leaving adi 2
  1303. pat lae aar $2==2 && rom($1,3)==4 && rom($1,1)!=0
  1304. with REG
  1305. gen ash {const2,2},%1 yields {regconst2,%1,(0-4)*rom($1,1)}
  1306. leaving adi 2
  1307. pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)==0
  1308. with REG
  1309. gen ash {const2,3},%1 yields %1
  1310. leaving adi 2
  1311. pat lae aar $2==2 && rom($1,3)==8 && rom($1,1)!=0
  1312. with REG
  1313. gen ash {const2,3},%1 yields {regconst2,%1,(0-8)*rom($1,1)}
  1314. leaving adi 2
  1315. pat lae aar $2==2 && rom($1,1)==0
  1316. with ODDREG
  1317. gen mul {const2,rom($1,3)},%1 yields %1 leaving adi 2
  1318. pat lae aar $2==2 && defined(rom($1,1))
  1319. with ODDREG
  1320. gen mul {const2,rom($1,3)},%1 yields {regconst2,%1,(0-rom($1,3))*rom($1,1)}
  1321. leaving adi 2
  1322. pat aar $1==2
  1323. kills ALL
  1324. gen mov {autoinc,sp},r0
  1325. mov {autoinc,sp},r1
  1326. jsr pc,{label, "aar~"}
  1327. pat lae sar defined(rom($1,3)) leaving lae $1 aar $2 sti rom($1,3)
  1328. pat lae lar defined(rom($1,3)) leaving lae $1 aar $2 loi rom($1,3)
  1329. pat sar $1==2
  1330. kills ALL
  1331. gen mov {autoinc,sp},r0
  1332. mov {autoinc,sp},r1
  1333. jsr pc,{label, "sar~"}
  1334. pat lar $1==2
  1335. kills ALL
  1336. gen mov {autoinc,sp},r0
  1337. mov {autoinc,sp},r1
  1338. jsr pc,{label, "lar~"}
  1339. #ifdef UNTESTED
  1340. pat aar !defined($1)
  1341. kills ALL
  1342. gen jsr pc,{label, "iaar~"}
  1343. pat sar !defined($1)
  1344. kills ALL
  1345. gen jsr pc,{label, "isar~"}
  1346. pat lar !defined($1)
  1347. kills ALL
  1348. gen jsr pc,{label, "ilar~"}
  1349. #endif
  1350. /****************************************
  1351. * group 12 : Compare instructions *
  1352. ****************************************/
  1353. pat cmi $1==2
  1354. with src2 src2
  1355. uses REG = {const2,0}
  1356. gen cmp %1,%2
  1357. beq {label,2f}
  1358. bgt {label,1f}
  1359. inc %a
  1360. br {label,2f}
  1361. 1:
  1362. dec %a
  1363. 2: yields %a
  1364. pat cmi $1==4
  1365. kills ALL
  1366. gen jsr pc,{label, "cmi4~"} yields r0
  1367. pat cmf defined($1)
  1368. kills ALL
  1369. gen move {const2,$1},r0
  1370. jsr pc,{label, "cmf~"} yields r0
  1371. pat cmu $1==2 leaving cmp
  1372. pat cmu $1==4
  1373. kills ALL
  1374. gen jsr pc,{label, "cmu4~"} yields r0
  1375. pat cmu defined($1)
  1376. kills ALL
  1377. gen move {const2,$1},r0
  1378. jsr pc,{label, "cmu~"} yields r0
  1379. pat cms $1==2 leaving cmi $1
  1380. pat cms defined($1)
  1381. kills ALL
  1382. gen move {const2,$1},r0
  1383. jsr pc,{label, "cms~"} yields r0
  1384. pat cms !defined($1)
  1385. with src2
  1386. kills ALL
  1387. gen move %1,r0
  1388. jsr pc,{label, "cms~"} yields r0
  1389. pat cmp
  1390. with src2 src2
  1391. uses REG = {const2,0}
  1392. gen cmp %1,%2
  1393. beq {label,2f}
  1394. bhi {label,1f}
  1395. inc %a
  1396. br {label,2f}
  1397. 1:
  1398. dec %a
  1399. 2: yields %a
  1400. proc txxand
  1401. with src2 REG
  1402. gen test %1
  1403. bxx* {label,1f}
  1404. clr %2
  1405. 1: yields %2
  1406. proc txxior
  1407. with src2 REG
  1408. gen test %1
  1409. bxx* {label,1f}
  1410. bis {const2,1},%2
  1411. 1: yields %2
  1412. proc txx
  1413. with src2
  1414. uses REG={const2,0}
  1415. gen test %1
  1416. bxx* {label,1f}
  1417. inc %a
  1418. 1: yields %a
  1419. pat tlt and $2==2 call txxand("blt")
  1420. pat tle and $2==2 call txxand("ble")
  1421. pat teq and $2==2 call txxand("beq")
  1422. pat tne and $2==2 call txxand("bne")
  1423. pat tgt and $2==2 call txxand("bgt")
  1424. pat tge and $2==2 call txxand("bge")
  1425. pat tlt ior $2==2 call txxior("bge")
  1426. pat tle ior $2==2 call txxior("bgt")
  1427. pat teq ior $2==2 call txxior("bne")
  1428. pat tne ior $2==2 call txxior("beq")
  1429. pat tgt ior $2==2 call txxior("ble")
  1430. pat tge ior $2==2 call txxior("blt")
  1431. pat tlt call txx("bge")
  1432. pat tle call txx("bgt")
  1433. pat teq call txx("bne")
  1434. pat tne call txx("beq")
  1435. pat tgt call txx("ble")
  1436. pat tge call txx("blt")
  1437. proc andtxx
  1438. with src2 src2
  1439. uses REG={const2,0}
  1440. gen bit %1,%2
  1441. bxx* {label,1f}
  1442. inc %a
  1443. 1: yields %a
  1444. pat and tne $1==2 call andtxx("beq")
  1445. pat and teq $1==2 call andtxx("bne")
  1446. proc cmitxxand
  1447. with src2 src2 REG
  1448. gen cmp %2,%1
  1449. bxx* {label,1f}
  1450. clr %3
  1451. 1: yields %3
  1452. proc cmitxxior
  1453. with src2 src2 REG
  1454. gen cmp %2,%1
  1455. bxx* {label,1f}
  1456. bis {const2,1},%3
  1457. 1: yields %3
  1458. proc cmitxx
  1459. with src2 src2
  1460. uses REG={const2,0}
  1461. gen cmp %2,%1
  1462. bxx* {label,1f}
  1463. inc %a
  1464. 1: yields %a
  1465. pat cmi tlt and $1==2 && $3==2 call cmitxxand("blt")
  1466. pat cmi tle and $1==2 && $3==2 call cmitxxand("ble")
  1467. pat cmi teq and $1==2 && $3==2 call cmitxxand("beq")
  1468. pat cmi tne and $1==2 && $3==2 call cmitxxand("bne")
  1469. pat cmi tgt and $1==2 && $3==2 call cmitxxand("bgt")
  1470. pat cmi tge and $1==2 && $3==2 call cmitxxand("bge")
  1471. pat cmi tlt ior $1==2 && $3==2 call cmitxxior("bge")
  1472. pat cmi tle ior $1==2 && $3==2 call cmitxxior("bgt")
  1473. pat cmi teq ior $1==2 && $3==2 call cmitxxior("bne")
  1474. pat cmi tne ior $1==2 && $3==2 call cmitxxior("beq")
  1475. pat cmi tgt ior $1==2 && $3==2 call cmitxxior("ble")
  1476. pat cmi tge ior $1==2 && $3==2 call cmitxxior("blt")
  1477. pat cmi tlt $1==2 call cmitxx("bge")
  1478. pat cmi tle $1==2 call cmitxx("bgt")
  1479. pat cmi teq $1==2 call cmitxx("bne")
  1480. pat cmi tne $1==2 call cmitxx("beq")
  1481. pat cmi tgt $1==2 call cmitxx("ble")
  1482. pat cmi tge $1==2 call cmitxx("blt")
  1483. pat loc cmi teq and $1>=0 && $1<=127 && $2==2 && $4==2
  1484. with exact src1 REG
  1485. gen cmpb %1,{const2,$1}
  1486. beq {label,1f}
  1487. clr %2
  1488. 1: yields %2
  1489. with yields {const2, $1}
  1490. leaving cmi 2 teq and 2
  1491. pat loc cmi teq ior $1>=0 && $1<=127 && $2==2 && $4==2
  1492. with exact src1 REG
  1493. gen cmpb %1,{const2,$1}
  1494. bne {label,1f}
  1495. bis {const2,1},%2
  1496. 1: yields %2
  1497. with yields {const2, $1}
  1498. leaving cmi 2 teq ior 2
  1499. pat loc cmi teq $1>=0 && $1<=127 && $2==2
  1500. with exact src1
  1501. uses REG={const2,0}
  1502. gen cmpb %1,{const2,$1}
  1503. bne {label,1f}
  1504. inc %a
  1505. 1: yields %a
  1506. with yields {const2, $1}
  1507. leaving cmi 2 teq
  1508. pat loc cmi tne and $1>=0 && $1<=127 && $2==2 && $4==2
  1509. with exact src1 REG
  1510. gen cmpb %1,{const2,$1}
  1511. bne {label,1f}
  1512. clr %2
  1513. 1: yields %2
  1514. with yields {const2, $1}
  1515. leaving cmi 2 tne and 2
  1516. pat loc cmi tne ior $1>=0 && $1<=127 && $2==2 && $4==2
  1517. with exact src1 REG
  1518. gen cmpb %1,{const2,$1}
  1519. beq {label,1f}
  1520. bis {const2,1},%2
  1521. 1: yields %2
  1522. with yields {const2, $1}
  1523. leaving cmi 2 tne ior 2
  1524. pat loc cmi tne $1>=0 && $1<=127 && $2==2
  1525. with exact src1
  1526. uses REG={const2,0}
  1527. gen cmpb %1,{const2,$1}
  1528. beq {label,1f}
  1529. inc %a
  1530. 1: yields %a
  1531. with yields {const2, $1}
  1532. leaving cmi 2 tne
  1533. proc cmptxx
  1534. with src2 src2
  1535. uses REG={const2,0}
  1536. gen cmp %2,%1
  1537. bxx* {label,1f}
  1538. inc %a
  1539. 1: yields %a
  1540. pat cmp tlt call cmptxx("bhis")
  1541. pat cmp tle call cmptxx("bhi")
  1542. pat cmp teq call cmptxx("bne")
  1543. pat cmp tne call cmptxx("beq")
  1544. pat cmp tgt call cmptxx("blos")
  1545. pat cmp tge call cmptxx("blo")
  1546. proc cmf4txx
  1547. with FLTREG FLTREG
  1548. uses REG={const2,0}
  1549. gen cmpf %2,%1
  1550. cfcc.
  1551. bxx* {label,1f}
  1552. inc %a
  1553. 1: yields %a
  1554. pat cmf tlt $1==4 call cmf4txx("bge")
  1555. pat cmf tle $1==4 call cmf4txx("bgt")
  1556. pat cmf teq $1==4 call cmf4txx("bne")
  1557. pat cmf tne $1==4 call cmf4txx("beq")
  1558. pat cmf tgt $1==4 call cmf4txx("ble")
  1559. pat cmf tge $1==4 call cmf4txx("blt")
  1560. proc cmf8txx
  1561. with DBLREG double8
  1562. uses REG={const2,0}
  1563. gen cmpf %2,%1
  1564. cfcc.
  1565. bxx[1] {label,1f}
  1566. inc %a
  1567. 1: yields %a
  1568. with double8 DBLREG
  1569. uses REG={const2,0}
  1570. gen cmpf %1,%2
  1571. cfcc.
  1572. bxx[2] {label,1f}
  1573. inc %a
  1574. 1: yields %a
  1575. pat cmf tlt $1==8 call cmf8txx("bge","ble")
  1576. pat cmf tle $1==8 call cmf8txx("bgt","blt")
  1577. pat cmf teq $1==8 call cmf8txx("bne","bne")
  1578. pat cmf tne $1==8 call cmf8txx("beq","beq")
  1579. pat cmf tgt $1==8 call cmf8txx("ble","bge")
  1580. pat cmf tge $1==8 call cmf8txx("blt","bgt")
  1581. /****************************************
  1582. * Group 13 : Branch instructions *
  1583. ****************************************/
  1584. pat bra
  1585. with STACK
  1586. gen jbr {label, $1}
  1587. proc bxx example beq
  1588. with src2 src2 STACK
  1589. gen cmp %2,%1
  1590. jxx* {label, $1}
  1591. pat blt call bxx("jlt")
  1592. pat ble call bxx("jle")
  1593. pat beq call bxx("jeq")
  1594. pat bne call bxx("jne")
  1595. pat bgt call bxx("jgt")
  1596. pat bge call bxx("jge")
  1597. pat loc beq $1>=0 && $1<=127
  1598. with exact src1 STACK
  1599. gen cmpb %1,{const2,$1}
  1600. jeq {label, $2}
  1601. with yields {const2, $1}
  1602. leaving beq $2
  1603. pat loc bne $1>=0 && $1<=127
  1604. with exact src1 STACK
  1605. gen cmpb %1,{const2,$1}
  1606. jne {label, $2}
  1607. with yields {const2, $1}
  1608. leaving bne $2
  1609. proc zxx example zeq
  1610. with src2 STACK
  1611. gen test %1
  1612. jxx* {label, $1}
  1613. pat zlt call zxx("jlt")
  1614. pat zle call zxx("jle")
  1615. pat zeq call zxx("jeq")
  1616. pat zne call zxx("jne")
  1617. pat zgt call zxx("jgt")
  1618. pat zge call zxx("jge")
  1619. proc cmpzxx example cmp zeq
  1620. with src2 src2 STACK
  1621. gen cmp %2,%1
  1622. jxx* {label, $2}
  1623. pat cmp zlt call cmpzxx("jlo")
  1624. pat cmp zle call cmpzxx("jlos")
  1625. pat cmp zeq call cmpzxx("jeq")
  1626. pat cmp zne call cmpzxx("jne")
  1627. pat cmp zgt call cmpzxx("jhi")
  1628. pat cmp zge call cmpzxx("jhis")
  1629. proc cmf4zxx example cmf zeq
  1630. with FLTREG FLTREG STACK
  1631. gen cmpf %2,%1
  1632. cfcc.
  1633. jxx* {label, $2}
  1634. pat cmf zlt $1==4 call cmf4zxx("jlt")
  1635. pat cmf zle $1==4 call cmf4zxx("jle")
  1636. pat cmf zeq $1==4 call cmf4zxx("jeq")
  1637. pat cmf zne $1==4 call cmf4zxx("jne")
  1638. pat cmf zgt $1==4 call cmf4zxx("jgt")
  1639. pat cmf zge $1==4 call cmf4zxx("jge")
  1640. proc cmf8zxx example cmf zeq
  1641. with DBLREG double8 STACK
  1642. gen cmpf %2,%1
  1643. cfcc.
  1644. jxx[1] {label, $2}
  1645. with double8 DBLREG STACK
  1646. gen cmpf %1,%2
  1647. cfcc.
  1648. jxx[2] {label, $2}
  1649. pat cmf zlt $1==8 call cmf8zxx("jlt","jgt")
  1650. pat cmf zle $1==8 call cmf8zxx("jle","jge")
  1651. pat cmf zeq $1==8 call cmf8zxx("jeq","jeq")
  1652. pat cmf zne $1==8 call cmf8zxx("jne","jne")
  1653. pat cmf zgt $1==8 call cmf8zxx("jgt","jlt")
  1654. pat cmf zge $1==8 call cmf8zxx("jge","jle")
  1655. proc andzen example and zeq
  1656. with src2 src2 STACK
  1657. gen bit %1,%2
  1658. jxx* {label, $2}
  1659. pat and zeq $1==2 call andzen("jeq")
  1660. pat and zne $1==2 call andzen("jne")
  1661. /************************************************
  1662. * group 14 : Procedure call instructions *
  1663. ************************************************/
  1664. pat cal
  1665. kills ALL
  1666. gen jsr pc,{label, $1}
  1667. pat cai
  1668. with REG
  1669. kills ALL
  1670. gen jsr pc,{regdef2,%1}
  1671. pat lfr $1==2 yields r0
  1672. pat lfr $1==4 yields r1 r0
  1673. pat lfr $1==8 yields {relative8,"retar"}
  1674. pat lfr
  1675. kills ALL
  1676. gen move {const2,$1},r0
  1677. jsr pc,{label, "lfr~"}
  1678. pat lfr ret $1==$2 leaving ret 0
  1679. pat ret $1==0
  1680. with STACK
  1681. gen mov lb,sp
  1682. mov {autoinc, sp},lb
  1683. rts pc
  1684. pat ret $1==2
  1685. with src2 STACK
  1686. gen move %1,r0
  1687. mov lb,sp
  1688. mov {autoinc, sp},lb
  1689. rts pc
  1690. pat ret $1==4
  1691. with STACK
  1692. gen mov {autoinc,sp},r0
  1693. mov {autoinc,sp},r1
  1694. mov lb,sp
  1695. mov {autoinc, sp},lb
  1696. rts pc
  1697. pat ret $1==8 yields {addr_external, "retar"}
  1698. leaving sti 8 ret 0
  1699. pat ret
  1700. kills ALL
  1701. gen move {const2,$1},r0
  1702. jmp {label,"ret~"}
  1703. /************************************************
  1704. * Group 15 : Miscellaneous instructions *
  1705. ************************************************/
  1706. pat asp $1==2
  1707. with STACK
  1708. gen tst {autoinc,sp}
  1709. pat asp $1==4
  1710. with STACK
  1711. gen cmp {autoinc,sp},{autoinc,sp}
  1712. pat asp $1==0-2
  1713. with STACK
  1714. gen tst {autodec,sp}
  1715. pat asp
  1716. with STACK
  1717. gen add {const2,$1},sp
  1718. pat ass $1==2
  1719. with STACK
  1720. gen add {autoinc,sp},sp
  1721. pat blm $1==4
  1722. with REG REG
  1723. gen mov {autoinc,%2},{autoinc,%1}
  1724. mov {regdef2,%2},{regdef2,%1}
  1725. pat blm $1==6
  1726. with REG REG
  1727. gen mov {autoinc,%2},{autoinc,%1}
  1728. mov {autoinc,%2},{autoinc,%1}
  1729. mov {regdef2,%2},{regdef2,%1}
  1730. pat blm $1==8
  1731. with REG REG
  1732. gen mov {autoinc,%2},{autoinc,%1}
  1733. mov {autoinc,%2},{autoinc,%1}
  1734. mov {autoinc,%2},{autoinc,%1}
  1735. mov {regdef2,%2},{regdef2,%1}
  1736. pat blm
  1737. with REG REG
  1738. uses REG={const2,$1/2}
  1739. gen 1:
  1740. mov {autoinc,%2},{autoinc,%1}
  1741. sob %a,{label,1b}
  1742. pat bls $1==2
  1743. with REG REG REG
  1744. gen
  1745. asr %1
  1746. beq {label,1f}
  1747. 2:
  1748. mov {autoinc,%3},{autoinc,%2}
  1749. sob %1,{label,2b}
  1750. 1:
  1751. pat lae csa $2==2
  1752. with src2
  1753. kills ALL
  1754. gen move %1,r1
  1755. move {addr_external,$1},r0
  1756. jmp {label, "csa~"}
  1757. pat csa $1==2
  1758. kills ALL
  1759. gen mov {autoinc,sp},r0
  1760. mov {autoinc,sp},r1
  1761. jmp {label, "csa~"}
  1762. pat lae csb $2==2
  1763. with src2
  1764. kills ALL
  1765. gen move %1,r1
  1766. move {addr_external,$1},r0
  1767. jmp {label, "csb~"}
  1768. pat csb $1==2
  1769. kills ALL
  1770. gen mov {autoinc,sp},r0
  1771. mov {autoinc,sp},r1
  1772. jmp {label, "csb~"}
  1773. pat dup $1==2
  1774. with REG yields %1 %1
  1775. pat dup $1==4
  1776. with exact long4 yields %1 %1
  1777. with src2 src2 yields %2 %1 %2 %1
  1778. pat dup $1==8
  1779. with exact long8 yields %1 %1
  1780. with STACK
  1781. kills ALL
  1782. gen move {const2, $1}, r0
  1783. jsr pc,{label, "dup~"}
  1784. pat dup
  1785. kills ALL
  1786. gen move {const2, $1}, r0
  1787. jsr pc,{label, "dup~"}
  1788. pat dus $1==2
  1789. with src2
  1790. kills ALL
  1791. gen move %1,r0
  1792. jsr pc,{label, "dup~"}
  1793. pat gto
  1794. kills ALL
  1795. gen mov {addr_external, $1},{autodec,sp}
  1796. jmp {label, "gto~"}
  1797. pat fil
  1798. gen mov {addr_external, $1},{relative2, "hol0"+4}
  1799. pat lim yields { relative2, "trpim~"}
  1800. pat lin
  1801. gen mov {const2,$1},{relative2, "hol0"}
  1802. pat lni
  1803. gen inc {relative2, "hol0"}
  1804. pat lor $1==0 yields lb
  1805. pat lor $1==1
  1806. with STACK
  1807. uses REG
  1808. gen mov sp,%a yields %a
  1809. pat lor $1==2 yields {relative2,"reghp~"}
  1810. pat mon
  1811. kills ALL
  1812. gen jsr pc,{label, "mon~"}
  1813. pat nop
  1814. kills ALL
  1815. #ifdef DEBUG
  1816. gen jsr pc,{label, "nop~"}
  1817. #endif
  1818. pat rck $1==2
  1819. with src2
  1820. pat rtt leaving ret 0
  1821. pat sig
  1822. with src2
  1823. uses REG
  1824. gen move {relative2,"trppc~"},%a
  1825. mov %1,{relative2,"trppc~"} yields %a
  1826. pat sim
  1827. kills ALL
  1828. gen jsr pc,{label, "sim~"}
  1829. pat str $1==0
  1830. with src2
  1831. kills ALL
  1832. gen mov %1,lb
  1833. pat str $1==1
  1834. with src2
  1835. kills ALL
  1836. gen mov %1,sp
  1837. pat str $1==2
  1838. kills ALL
  1839. gen jsr pc,{label, "strhp~"}
  1840. pat trp
  1841. kills ALL
  1842. gen jsr pc,{label, "trp~"}
  1843. pat exg $1==2
  1844. with src2 src2 yields %1 %2
  1845. pat exg defined($1)
  1846. kills ALL
  1847. gen move {const2,$1},r0
  1848. jsr pc,{label, "exg~"}
  1849. pat lol lal sti $1==$2 && $3==1 /* throw away funny C-proc-prolog */
  1850. pat los
  1851. gen jmp {label, illins}
  1852. pat sts
  1853. gen jmp {label, illins}
  1854. pat inn
  1855. gen jmp {label, illins}
  1856. pat set
  1857. gen jmp {label, illins}