dec20-cmac.sl 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. %
  2. % 20-CMAC.SL - Patterns and predicates for Dec-20 PSL cmacro expansion
  3. %
  4. % Author: Eric Benson
  5. % Symbolic Computation Group
  6. % Computer Science Dept.
  7. % University of Utah
  8. % Date: 14 January 1982
  9. % Copyright (c) 1982 University of Utah
  10. %
  11. % <PSL.20-COMP>20-CMAC.SL.1, 21 October 1982, Griss
  12. % Fixed foreign function for CROSS compiler
  13. % <PSL.20-COMP>20-CMAC.SL.1, 24-Feb-82 12:08:45, Edit by BENSON
  14. % Adapted VAX version for Dec-20
  15. (fluid '(AddressingUnitsPerItem
  16. CharactersPerWord
  17. StackDirection
  18. !*ImmediateQuote
  19. AddressingUnitsPerFunctionCell))
  20. (setq AddressingUnitsPerItem 1)
  21. (setq CharactersPerWord 5)
  22. (setq AddressingUnitsPerFunctionCell 1)
  23. (setq StackDirection 1)
  24. (setq !*ImmediateQuote NIL)
  25. (*
  26. (* "MkItem may be used when evaluating WConst expressions.")
  27. (de MkItem (TagPart InfPart)
  28. (lor (lsh TagPart 27) (land InfPart 16#7ffffff)))
  29. )
  30. (ds BitMask (Start End)
  31. (land (lsh -1 (minus Start)) (lsh -1 (difference 35 End))))
  32. (dm Bit (U)
  33. (progn (setq U (cdr U))
  34. (cond ((null U) 0)
  35. (t (ExpandBit U)))))
  36. (de ExpandBit (U)
  37. (cond ((null (cdr U)) (list 'lsh 1 (list 'difference 35 (car U))))
  38. (t (list 'lor
  39. (list 'lsh 1 (list 'difference 35 (car U)))
  40. (ExpandBit (cdr U))))))
  41. (* "InumP tells what numbers can be immediate operands on the target machine.")
  42. (de InumP (Expression)
  43. (and (FixP Expression)
  44. (leq Expression 8#777777) % 8#177777777777 for extended
  45. (geq Expression (minus 8#1000000)))) % 8#200000000000
  46. (de TagNumber (X)
  47. (cond ((IDP X) (get 'ID 'WConst))
  48. ((PairP X) (get 'PAIR 'WConst))
  49. ((StringP X) (get 'STR 'WConst))
  50. ((InumP X) (cond ((MinusP X) 31) (t 0)))
  51. ((CodeP X) (get 'CODE 'WConst))
  52. ((FloatP X) (get 'FltN 'WConst))
  53. ((VectorP X) (get 'VECT 'WConst))
  54. ((FixP X) (get 'FixN 'WConst))))
  55. (de ImmediateP (X)
  56. (or (EqCar X 'Immediate)
  57. (and (FixP X) (leq X 8#777777) (geq X (minus 8#777777)))))
  58. (de MemoryP (X)
  59. (not (ImmediateP X)))
  60. (de NegativeImmediateP (X)
  61. (and (FixP X)
  62. (MinusP X)
  63. (geq X (minus 8#777777))))
  64. (de EighteenP (X)
  65. (equal X 18))
  66. (de NonIndirectP (Expression)
  67. (not (EqCar Expression 'Indirect)))
  68. (de FakeRegisterNumberP (Expression)
  69. (and (IntP Expression) (GreaterP Expression 5)))
  70. (* "Leave Indexed and Indirect alone in recursive c-macro")
  71. (flag '(Indexed Indirect UnImmediate) 'TerminalOperand)
  72. (DefAnyreg CAR
  73. AnyregCAR
  74. ((RegisterP) (Indexed SOURCE 0))
  75. ((move REGISTER SOURCE) (Indexed REGISTER 0)))
  76. (DefAnyreg CDR
  77. AnyregCDR
  78. ((RegisterP) (Indexed SOURCE 1))
  79. ((move REGISTER SOURCE) (Indexed REGISTER 1)))
  80. (DefAnyreg QUOTE
  81. AnyregQUOTE
  82. ((Null) (REG NIL))
  83. ((EqTP) (FLUID T))
  84. ((InumP) SOURCE)
  85. ((QUOTE SOURCE)))
  86. (DefAnyreg WVAR
  87. AnyregWVAR
  88. ((RegisterNameP) (REG SOURCE))
  89. ((WVAR SOURCE)))
  90. (DefAnyreg MEMORY
  91. AnyregMEMORY
  92. ((RegisterP AnyP) (Indexed SOURCE ARGTWO))
  93. ((AddressConstantP ZeroP) (UnImmediate SOURCE))
  94. ((NonIndirectP ZeroP) (Indirect SOURCE))
  95. ((!*MOVE SOURCE REGISTER)
  96. (Indexed REGISTER ARGTWO)))
  97. (DefAnyreg FRAME
  98. AnyregFRAME
  99. ((Indexed (REG st) SOURCE)))
  100. (DefAnyreg REG
  101. AnyregREG
  102. ((FakeRegisterNumberP) (ExtraReg SOURCE))
  103. ((REG SOURCE)))
  104. (DefCMacro !*Call
  105. ((InternallyCallableP) (pushj (reg st) (InternalEntry ARGONE)))
  106. ((pushj (reg st) (Entry ARGONE))))
  107. (DefCMacro !*JCall
  108. ((InternallyCallableP) (jrst (InternalEntry ARGONE)))
  109. ((jrst (Entry ARGONE))))
  110. (DefCMacro !*Move
  111. (Equal)
  112. ((ZeroP AnyP) (setzm ARGTWO))
  113. ((MinusOneP AnyP) (setom ARGTWO))
  114. ((NegativeImmediateP RegisterP)
  115. (movni ARGTWO (minus ARGONE)))
  116. ((ImmediateP RegisterP) (hrrzi ARGTWO ARGONE))
  117. ((AnyP RegisterP) (move ARGTWO ARGONE))
  118. ((RegisterP AnyP) (movem ARGONE ARGTWO))
  119. ((!*MOVE ARGONE (reg t1)) (movem (reg t1) ARGTWO)))
  120. (DefCMacro !*Alloc
  121. ((ZeroP))
  122. ((adjsp (REG st) ARGONE)))
  123. (DefCMacro !*DeAlloc
  124. ((ZeroP))
  125. ((adjsp (REG st) (minus ARGONE))))
  126. (DefCMacro !*Exit
  127. ((!*DeAlloc ARGONE)
  128. (popj (reg st) 0)))
  129. (DefCMacro !*Jump
  130. ((jrst ARGONE)))
  131. (DefCMacro !*Lbl
  132. (ARGONE))
  133. (DefCMacro !*WPlus2
  134. ((AnyP OneP) (aos ARGONE))
  135. ((AnyP MinusOneP) (sos ARGONE))
  136. ((AnyP RegisterP) (addm ARGTWO ARGONE))
  137. ((RegisterP NegativeImmediateP) (subi ARGONE (minus ARGTWO)))
  138. ((RegisterP ImmediateP) (addi ARGONE ARGTWO))
  139. ((RegisterP AnyP) (add ARGONE ARGTWO))
  140. ((!*MOVE ARGTWO (reg t2)) (addm (reg t2) ARGONE)))
  141. (DefCMacro !*WDifference
  142. ((AnyP OneP) (sos ARGONE))
  143. ((AnyP MinusOneP) (aos ARGONE))
  144. ((RegisterP NegativeImmediateP) (addi ARGONE (minus ARGTWO)))
  145. ((RegisterP ImmediateP) (subi ARGONE ARGTWO))
  146. ((RegisterP AnyP) (sub ARGONE ARGTWO))
  147. ((!*WMINUS (reg t2) ARGTWO) (addm (reg t2) ARGONE)))
  148. (DefCMacro !*WTimes2
  149. ((AnyP MinusOneP) (!*WMINUS ARGONE ARGONE))
  150. ((RegisterP NegativeImmediateP)
  151. (imul ARGONE (lit (fullword ARGTWO))))
  152. ((RegisterP ImmediateP) (imuli ARGONE ARGTWO))
  153. ((RegisterP AnyP) (imul ARGONE ARGTWO))
  154. ((AnyP RegisterP) (imulm ARGTWO ARGONE))
  155. ((!*MOVE ARGTWO (reg t2)) (imulm (reg t2) ARGONE)))
  156. (DefCMacro !*WAnd
  157. ((RegisterP NegativeImmediateP)
  158. (and ARGONE (lit (fullword ARGTWO))))
  159. ((RegisterP ImmediateP) (andi ARGONE ARGTWO))
  160. ((RegisterP AnyP) (and ARGONE ARGTWO))
  161. ((AnyP RegisterP) (andm ARGTWO ARGONE))
  162. ((!*MOVE (reg t2) ARGTWO) (andm (reg t2) ARGONE)))
  163. (DefCMacro !*WOr
  164. ((RegisterP NegativeImmediateP)
  165. (ior ARGONE (lit (fullword ARGTWO))))
  166. ((RegisterP ImmediateP) (iori ARGONE ARGTWO))
  167. ((RegisterP AnyP) (ior ARGONE ARGTWO))
  168. ((AnyP RegisterP) (iorm ARGTWO ARGONE))
  169. ((!*MOVE (reg t2) ARGTWO) (iorm (reg t2) ARGONE)))
  170. (DefCMacro !*WXOr
  171. ((RegisterP NegativeImmediateP)
  172. (xor ARGONE (lit (fullword ARGTWO))))
  173. ((RegisterP ImmediateP) (xori ARGONE ARGTWO))
  174. ((RegisterP AnyP) (xor ARGONE ARGTWO))
  175. ((AnyP RegisterP) (xorm ARGTWO ARGONE))
  176. ((!*MOVE (reg t2) ARGTWO) (xorm (reg t2) ARGONE)))
  177. (DefCMacro !*AShift
  178. ((RegisterP ImmediateP) (ash ARGONE ARGTWO))
  179. ((RegisterP RegisterP) (ash ARGONE (Indexed ARGTWO 0)))
  180. ((RegisterP AnyP)
  181. (move (reg t2) ARGTWO)
  182. (ash ARGONE (Indexed (reg t2) 0)))
  183. ((AnyP ImmediateP)
  184. (move (reg t3) ARGONE)
  185. (ash (reg t3) ARGTWO)
  186. (movem (reg t3) ARGONE))
  187. ((AnyP RegisterP)
  188. (move (reg t3) ARGONE)
  189. (ash (reg t3) (Indexed ARGTWO 0))
  190. (movem (reg t3) ARGONE))
  191. ((move (reg t2) ARGTWO)
  192. (move (reg t3) ARGONE)
  193. (ash (reg t3) (Indexed (reg t2) 0))
  194. (movem (reg t3) ARGONE)))
  195. (DefCMacro !*WShift
  196. ((RegisterP ImmediateP) (lsh ARGONE ARGTWO))
  197. ((RegisterP RegisterP) (lsh ARGONE (Indexed ARGTWO 0)))
  198. ((RegisterP AnyP)
  199. (move (reg t2) ARGTWO)
  200. (lsh ARGONE (Indexed (reg t2) 0)))
  201. ((AnyP ImmediateP)
  202. (move (reg t3) ARGONE)
  203. (lsh (reg t3) ARGTWO)
  204. (movem (reg t3) ARGONE))
  205. ((AnyP RegisterP)
  206. (move (reg t3) ARGONE)
  207. (lsh (reg t3) (Indexed ARGTWO 0))
  208. (movem (reg t3) ARGONE))
  209. ((move (reg t2) ARGTWO)
  210. (move (reg t3) ARGONE)
  211. (lsh (reg t3) (Indexed (reg t2) 0))
  212. (movem (reg t3) ARGONE)))
  213. (DefCMacro !*WNot
  214. (Equal (setcmm ARGONE))
  215. ((RegisterP AnyP) (setcm ARGONE ARGTWO))
  216. ((AnyP RegisterP) (setcam ARGTWO ARGONE))
  217. ((move (reg t1) ARGTWO) (setcam (reg t1) ARGONE)))
  218. (DefCMacro !*WMinus
  219. (Equal (movns ARGONE))
  220. ((RegisterP AnyP) (movn ARGONE ARGTWO))
  221. ((AnyP RegisterP) (movnm ARGTWO ARGONE))
  222. ((move (reg t1) ARGTWO) (movnm (reg t1) ARGONE)))
  223. (DefCMacro !*MkItem
  224. ((RegisterP ImmediateP)
  225. (tlz ARGONE 2#111110000000000000)
  226. (tlo ARGONE (lsh ARGTWO 13)))
  227. ((AnyP RegisterP)
  228. (dpb ARGTWO (lit (fullword (FieldPointer ARGONE 0 5)))))
  229. ((!*MOVE ARGTWO (reg t1))
  230. (dpb (reg t1) (lit (fullword (FieldPointer ARGONE 0 5))))))
  231. (DefCMacro !*JumpType
  232. ((RegisterP ZeroP)
  233. (tlnn ARGONE 2#111110000000000000)
  234. (jrst ARGTHREE))
  235. ((ldb (reg t6) (lit (fullword (FieldPointer ARGONE 0 5))))
  236. (!*JUMPEQ ARGTHREE (reg t6) ARGTWO)))
  237. (DefCMacro !*JumpNotType
  238. ((RegisterP ZeroP)
  239. (tlne ARGONE 2#111110000000000000)
  240. (jrst ARGTHREE))
  241. ((ldb (reg t6) (lit (fullword (FieldPointer ARGONE 0 5))))
  242. (!*JUMPNOTEQ ARGTHREE (reg t6) ARGTWO)))
  243. (DefCMacro !*JumpInType
  244. ((ldb (reg t6) (lit (fullword (FieldPointer ARGONE 0 5))))
  245. (caig (reg t6) ARGTWO)
  246. (jrst ARGTHREE)
  247. (cain (reg t6) 31)
  248. (jrst ARGTHREE))) % (WConst NegInt)
  249. (DefCMacro !*JumpNotInType
  250. ((ldb (reg t6) (lit (fullword (FieldPointer ARGONE 0 5))))
  251. (cain (reg t6) 31) % (WConst NegInt)
  252. (jrst TEMPLABEL)
  253. (caile (reg t6) ARGTWO)
  254. (jrst ARGTHREE)
  255. TEMPLABEL))
  256. (DefCMacro !*JumpEQ
  257. ((RegisterP ZeroP) (jumpe ARGONE ARGTHREE))
  258. ((ZeroP RegisterP) (jumpe ARGTWO ARGTHREE))
  259. ((AnyP ZeroP)
  260. (skipn ARGONE)
  261. (jrst ARGTHREE))
  262. ((ZeroP AnyP)
  263. (skipn ARGTWO)
  264. (jrst ARGTHREE))
  265. ((RegisterP NegativeImmediateP)
  266. (camn ARGONE (lit (fullword ARGTWO)))
  267. (jrst ARGTHREE))
  268. ((NegativeImmediateP RegisterP)
  269. (camn ARGTWO (lit (fullword ARGONE)))
  270. (jrst ARGTHREE))
  271. ((RegisterP ImmediateP)
  272. (cain ARGONE ARGTWO)
  273. (jrst ARGTHREE))
  274. ((ImmediateP RegisterP)
  275. (cain ARGTWO ARGONE)
  276. (jrst ARGTHREE))
  277. ((RegisterP AnyP)
  278. (camn ARGONE ARGTWO)
  279. (jrst ARGTHREE))
  280. ((AnyP RegisterP)
  281. (camn ARGTWO ARGONE)
  282. (jrst ARGTHREE))
  283. ((MemoryP AnyP)
  284. (move (reg t1) ARGONE)
  285. (!*JUMPEQ ARGTHREE (reg t1) ARGTWO))
  286. ((move (reg t2) ARGTWO)
  287. (!*JUMPEQ ARGTHREE ARGONE (reg t2))))
  288. (DefCMacro !*JumpNotEQ
  289. ((RegisterP ZeroP) (jumpn ARGONE ARGTHREE))
  290. ((ZeroP RegisterP) (jumpn ARGTWO ARGTHREE))
  291. ((AnyP ZeroP)
  292. (skipe ARGONE)
  293. (jrst ARGTHREE))
  294. ((ZeroP AnyP)
  295. (skipe ARGTWO)
  296. (jrst ARGTHREE))
  297. ((RegisterP NegativeImmediateP)
  298. (came ARGONE (lit (fullword ARGTWO)))
  299. (jrst ARGTHREE))
  300. ((NegativeImmediateP RegisterP)
  301. (came ARGTWO (lit (fullword ARGONE)))
  302. (jrst ARGTHREE))
  303. ((RegisterP ImmediateP)
  304. (caie ARGONE ARGTWO)
  305. (jrst ARGTHREE))
  306. ((ImmediateP RegisterP)
  307. (caie ARGTWO ARGONE)
  308. (jrst ARGTHREE))
  309. ((RegisterP AnyP)
  310. (came ARGONE ARGTWO)
  311. (jrst ARGTHREE))
  312. ((AnyP RegisterP)
  313. (came ARGTWO ARGONE)
  314. (jrst ARGTHREE))
  315. ((MemoryP AnyP)
  316. (move (reg t1) ARGONE)
  317. (!*JUMPNOTEQ ARGTHREE (reg t1) ARGTWO))
  318. ((move (reg t2) ARGTWO)
  319. (!*JUMPNOTEQ ARGTHREE ARGONE (reg t2))))
  320. (DefCMacro !*JumpWLessP
  321. ((RegisterP ZeroP) (jumpl ARGONE ARGTHREE))
  322. ((ZeroP RegisterP) (jumpg ARGTWO ARGTHREE))
  323. ((RegisterP OneP) (jumple ARGONE ARGTHREE))
  324. ((MinusOneP RegisterP) (jumpge ARGTWO ARGTHREE))
  325. ((AnyP ZeroP)
  326. (skipge ARGONE)
  327. (jrst ARGTHREE))
  328. ((ZeroP AnyP)
  329. (skiple ARGTWO)
  330. (jrst ARGTHREE))
  331. ((AnyP OneP)
  332. (skipg ARGONE)
  333. (jrst ARGTHREE))
  334. ((MinusOneP AnyP)
  335. (skipl ARGTWO)
  336. (jrst ARGTHREE))
  337. ((RegisterP NegativeImmediateP)
  338. (camge ARGONE (lit (fullword ARGTWO)))
  339. (jrst ARGTHREE))
  340. ((NegativeImmediateP RegisterP)
  341. (camle ARGTWO (lit (fullword ARGONE)))
  342. (jrst ARGTHREE))
  343. ((RegisterP ImmediateP)
  344. (caige ARGONE ARGTWO)
  345. (jrst ARGTHREE))
  346. ((ImmediateP RegisterP)
  347. (caile ARGTWO ARGONE)
  348. (jrst ARGTHREE))
  349. ((RegisterP AnyP)
  350. (camge ARGONE ARGTWO)
  351. (jrst ARGTHREE))
  352. ((AnyP RegisterP)
  353. (camle ARGTWO ARGONE)
  354. (jrst ARGTHREE))
  355. ((MemoryP AnyP)
  356. (move (reg t1) ARGONE)
  357. (!*JUMPWLESSP ARGTHREE (reg t1) ARGTWO))
  358. ((move (reg t2) ARGTWO)
  359. (!*JUMPWLESSP ARGTHREE ARGONE (reg t2))))
  360. (DefCMacro !*JumpWGreaterP
  361. ((RegisterP ZeroP) (jumpg ARGONE ARGTHREE))
  362. ((ZeroP RegisterP) (jumpl ARGTWO ARGTHREE))
  363. ((RegisterP MinusOneP) (jumpge ARGONE ARGTHREE))
  364. ((OneP RegisterP) (jumple ARGTWO ARGTHREE))
  365. ((AnyP ZeroP)
  366. (skiple ARGONE)
  367. (jrst ARGTHREE))
  368. ((ZeroP AnyP)
  369. (skipge ARGTWO)
  370. (jrst ARGTHREE))
  371. ((AnyP MinusOneP)
  372. (skipl ARGONE)
  373. (jrst ARGTHREE))
  374. ((OneP AnyP)
  375. (skipg ARGTWO)
  376. (jrst ARGTHREE))
  377. ((RegisterP NegativeImmediateP)
  378. (camle ARGONE (lit (fullword ARGTWO)))
  379. (jrst ARGTHREE))
  380. ((NegativeImmediateP RegisterP)
  381. (camge ARGTWO (lit (fullword ARGONE)))
  382. (jrst ARGTHREE))
  383. ((RegisterP ImmediateP)
  384. (caile ARGONE ARGTWO)
  385. (jrst ARGTHREE))
  386. ((ImmediateP RegisterP)
  387. (caige ARGTWO ARGONE)
  388. (jrst ARGTHREE))
  389. ((RegisterP AnyP)
  390. (camle ARGONE ARGTWO)
  391. (jrst ARGTHREE))
  392. ((AnyP RegisterP)
  393. (camge ARGTWO ARGONE)
  394. (jrst ARGTHREE))
  395. ((MemoryP AnyP)
  396. (move (reg t1) ARGONE)
  397. (!*JUMPWGreaterP ARGTHREE (reg t1) ARGTWO))
  398. ((move (reg t2) ARGTWO)
  399. (!*JUMPWGreaterP ARGTHREE ARGONE (reg t2))))
  400. (DefCMacro !*JumpWLEQ
  401. ((RegisterP ZeroP) (jumple ARGONE ARGTHREE))
  402. ((ZeroP RegisterP) (jumpge ARGTWO ARGTHREE))
  403. ((RegisterP MinusOneP) (jumpl ARGONE ARGTHREE))
  404. ((OneP RegisterP) (jumpg ARGTWO ARGTHREE))
  405. ((AnyP ZeroP)
  406. (skipg ARGONE)
  407. (jrst ARGTHREE))
  408. ((ZeroP AnyP)
  409. (skipl ARGTWO)
  410. (jrst ARGTHREE))
  411. ((AnyP MinusOneP)
  412. (skipge ARGONE)
  413. (jrst ARGTHREE))
  414. ((OneP AnyP)
  415. (skiple ARGTWO)
  416. (jrst ARGTHREE))
  417. ((RegisterP NegativeImmediateP)
  418. (camg ARGONE (lit (fullword ARGTWO)))
  419. (jrst ARGTHREE))
  420. ((NegativeImmediateP RegisterP)
  421. (caml ARGTWO (lit ARGTHREE))
  422. (jrst ARGTHREE))
  423. ((RegisterP ImmediateP)
  424. (caig ARGONE ARGTWO)
  425. (jrst ARGTHREE))
  426. ((ImmediateP RegisterP)
  427. (cail ARGTWO ARGONE)
  428. (jrst ARGTHREE))
  429. ((RegisterP AnyP)
  430. (camg ARGONE ARGTWO)
  431. (jrst ARGTHREE))
  432. ((AnyP RegisterP)
  433. (caml ARGTWO ARGONE)
  434. (jrst ARGTHREE))
  435. ((MemoryP AnyP)
  436. (move (reg t1) ARGONE)
  437. (!*JUMPWLEQ ARGTHREE (reg t1) ARGTWO))
  438. ((move (reg t2) ARGTWO)
  439. (!*JUMPWLEQ ARGTHREE ARGONE (reg t2))))
  440. (DefCMacro !*JumpWGEQ
  441. ((RegisterP ZeroP) (jumpge ARGONE ARGTHREE))
  442. ((ZeroP RegisterP) (jumple ARGTWO ARGTHREE))
  443. ((RegisterP OneP) (jumpg ARGONE ARGTHREE))
  444. ((MinusOneP RegisterP) (jumpl ARGTWO ARGTHREE))
  445. ((AnyP ZeroP)
  446. (skipl ARGONE)
  447. (jrst ARGTHREE))
  448. ((ZeroP AnyP)
  449. (skipg ARGTWO)
  450. (jrst ARGTHREE))
  451. ((AnyP OneP)
  452. (skiple ARGONE)
  453. (jrst ARGTHREE))
  454. ((MinusOneP AnyP)
  455. (skipge ARGTWO)
  456. (jrst ARGTHREE))
  457. ((RegisterP NegativeImmediateP)
  458. (caml ARGONE (lit (fullword ARGTWO)))
  459. (jrst ARGTHREE))
  460. ((NegativeImmediateP RegisterP)
  461. (camg ARGTWO (lit (fullword ARGONE)))
  462. (jrst ARGTHREE))
  463. ((RegisterP ImmediateP)
  464. (cail ARGONE ARGTWO)
  465. (jrst ARGTHREE))
  466. ((ImmediateP RegisterP)
  467. (caig ARGTWO ARGONE)
  468. (jrst ARGTHREE))
  469. ((RegisterP AnyP)
  470. (caml ARGONE ARGTWO)
  471. (jrst ARGTHREE))
  472. ((AnyP RegisterP)
  473. (camg ARGTWO ARGONE)
  474. (jrst ARGTHREE))
  475. ((MemoryP AnyP)
  476. (move (reg t1) ARGONE)
  477. (!*JUMPWGEQ ARGTHREE (reg t1) ARGTWO))
  478. ((move (reg t2) ARGTWO)
  479. (!*JUMPWGEQ ARGTHREE ARGONE (reg t2))))
  480. (DefCMacro !*Push
  481. ((ImmediateP) (push (reg st) (lit (fullword ARGONE))))
  482. ((push (reg st) ARGONE)))
  483. (DefCMacro !*Pop
  484. ((ImmediateP) (pop (reg st) (lit (fullword ARGONE))))
  485. ((pop (reg st) ARGONE)))
  486. (DefCMacro !*Freerstr
  487. ((jsp (reg t5) (Entry FastUnbind)) (fullword ARGONE)))
  488. (DefCMacro !*Loc
  489. ((RegisterP AnyP) (movei ARGONE ARGTWO))
  490. ((movei (reg t2) ARGTWO) (movem (reg t2) ARGONE)))
  491. (DefCMacro !*Field
  492. ((RegisterP AnyP ZeroP EighteenP) (hlrz ARGONE ARGTWO))
  493. ((RegisterP AnyP EighteenP EighteenP) (hrrz ARGONE ARGTWO))
  494. ((AnyP RegisterP ZeroP EighteenP) (hlrzm ARGTWO ARGONE))
  495. ((AnyP RegisterP EighteenP EighteenP) (hrrzm ARGTWO ARGONE))
  496. ((RegisterP)
  497. (ldb ARGONE
  498. (lit (fullword (FieldPointer
  499. ARGTWO ARGTHREE
  500. ARGFOUR)))))
  501. ((ldb (reg t2)
  502. (lit (fullword (FieldPointer
  503. ARGTWO ARGTHREE
  504. ARGFOUR))))
  505. (movem (reg t2) ARGONE)))
  506. (DefCMacro !*SignedField
  507. ((RegisterP AnyP ZeroP EighteenP) (hlre ARGONE ARGTWO))
  508. ((RegisterP AnyP EighteenP EighteenP) (hrre ARGONE ARGTWO))
  509. ((AnyP RegisterP ZeroP EighteenP) (hlrem ARGTWO ARGONE))
  510. ((AnyP RegisterP EighteenP EighteenP) (hrrem ARGTWO ARGONE))
  511. ((RegisterP)
  512. % could optimize to use tlne tlo trne tro
  513. (ldb ARGONE
  514. (lit (fullword (FieldPointer
  515. ARGTWO ARGTHREE
  516. ARGFOUR))))
  517. (tdne ARGONE (lit (fullword (bit ARGTHREE))))
  518. (tdo ARGONE (lit (fullword (bitmask 0 ARGTHREE)))))
  519. ((ldb (reg t2)
  520. (lit (fullword (FieldPointer
  521. ARGTWO ARGTHREE
  522. ARGFOUR))))
  523. (tdne (reg t2) (lit (fullword (bit ARGTHREE))))
  524. (tdo (reg t2) (lit (fullword (bitmask 0 ARGTHREE))))
  525. (movem (reg t2) ARGONE)))
  526. (DefCMacro !*PutField
  527. ((RegisterP)
  528. (dpb ARGONE
  529. (lit (fullword (FieldPointer
  530. ARGTWO ARGTHREE
  531. ARGFOUR)))))
  532. ((!*MOVE ARGONE (reg t1))
  533. (dpb (reg t1)
  534. (lit (fullword (FieldPointer
  535. ARGTWO ARGTHREE
  536. ARGFOUR))))))
  537. (DefCMacro !*ADJSP
  538. ((RegisterP ImmediateP) (adjsp ARGONE ARGTWO))
  539. ((RegisterP RegisterP) (adjsp ARGONE (Indexed ARGTWO 0)))
  540. ((RegisterP)
  541. (move (reg t2) ARGTWO)
  542. (adjsp ARGONE (Indexed (reg t2) 0)))
  543. ((move (reg t1) ARGONE)
  544. (!*ADJSP (reg t1) ARGTWO)
  545. (movem (reg t1) ARGONE)))
  546. (DefList '((WQuotient ((idiv (reg 1) (reg 2))))
  547. (WRemainder ((idiv (reg 1) (reg 2)) (move (reg 1) (reg 2)))))
  548. 'OpenCode)
  549. (!&Tworeg '(WQuotient WRemainder))
  550. (loadtime
  551. (DefList '((Byte ((adjbp (reg 2)
  552. (lit (fullword (FieldPointer
  553. (Indexed (reg 1) 0) 0 7))))
  554. (ldb (reg 1) (reg 2))))
  555. (PutByte ((adjbp (reg 2)
  556. (lit (fullword (FieldPointer
  557. (Indexed (reg 1) 0) 0 7))))
  558. (dpb (reg 3) (reg 2))))
  559. (HalfWord ((adjbp (reg 2)
  560. (lit (fullword (FieldPointer
  561. (Indexed (reg 1) 0) 0 18))))
  562. (ldb (reg 1) (reg 2))))
  563. (PutHalfWord ((adjbp (reg 2)
  564. (lit (fullword (FieldPointer
  565. (Indexed (reg 1) 0) 0 18))))
  566. (dpb (reg 3) (reg 2))))
  567. (BitTable ((adjbp (reg 2)
  568. (lit (fullword (FieldPointer
  569. (Indexed (reg 1) 0) 0 2))))
  570. (ldb (reg 1) (reg 2))))
  571. (PutBitTable ((adjbp (reg 2)
  572. (lit (fullword (FieldPointer
  573. (Indexed (reg 1) 0) 0 2))))
  574. (dpb (reg 3) (reg 2)))))
  575. 'OpenCode))
  576. (loadtime
  577. (!&TwoReg '(Byte PutByte HalfWord PutHalfWord BitTable PutBitTable)))
  578. (DefList '((IDApply0 ((pushj (reg st)
  579. (Indexed (reg 1) (WArray SymFnc)))))
  580. (IDApply1 ((pushj (reg st)
  581. (Indexed (reg 2) (WArray SymFnc)))))
  582. (IDApply2 ((pushj (reg st)
  583. (Indexed (reg 3) (WArray SymFnc)))))
  584. (IDApply3 ((pushj (reg st)
  585. (Indexed (reg 4) (WArray SymFnc)))))
  586. (IDApply4 ((pushj (reg st)
  587. (Indexed (reg 5) (WArray SymFnc))))))
  588. 'OpenCode)
  589. (DefList '((IDApply0 ((jrst (Indexed (reg 1) (WArray SymFnc)))))
  590. (IDApply1 ((jrst (Indexed (reg 2) (WArray SymFnc)))))
  591. (IDApply2 ((jrst (Indexed (reg 3) (WArray SymFnc)))))
  592. (IDApply3 ((jrst (Indexed (reg 4) (WArray SymFnc)))))
  593. (IDApply4 ((jrst (Indexed (reg 5) (WArray SymFnc))))))
  594. 'ExitOpenCode)
  595. (DefList '((CodeApply0 ((pushj (reg st) (Indexed (reg 1) 0))))
  596. (CodeApply1 ((pushj (reg st) (Indexed (reg 2) 0))))
  597. (CodeApply2 ((pushj (reg st) (Indexed (reg 3) 0))))
  598. (CodeApply3 ((pushj (reg st) (Indexed (reg 4) 0))))
  599. (CodeApply4 ((pushj (reg st) (Indexed (reg 5) 0)))))
  600. 'OpenCode)
  601. (DefList '((CodeApply0 ((jrst (Indexed (reg 1) 0))))
  602. (CodeApply1 ((jrst (Indexed (reg 2) 0))))
  603. (CodeApply2 ((jrst (Indexed (reg 3) 0))))
  604. (CodeApply3 ((jrst (Indexed (reg 4) 0))))
  605. (CodeApply4 ((jrst (Indexed (reg 5) 0)))))
  606. 'ExitOpenCode)
  607. (DefList '((AddressApply0 ((pushj (reg st) (Indexed (reg 1) 0))))
  608. (AddressApply1 ((pushj (reg st) (Indexed (reg 2) 0))))
  609. (AddressApply2 ((pushj (reg st) (Indexed (reg 3) 0))))
  610. (AddressApply3 ((pushj (reg st) (Indexed (reg 4) 0))))
  611. (AddressApply4 ((pushj (reg st) (Indexed (reg 5) 0)))))
  612. 'OpenCode)
  613. (DefList '((AddressApply0 ((jrst (Indexed (reg 1) 0))))
  614. (AddressApply1 ((jrst (Indexed (reg 2) 0))))
  615. (AddressApply2 ((jrst (Indexed (reg 3) 0))))
  616. (AddressApply3 ((jrst (Indexed (reg 4) 0))))
  617. (AddressApply4 ((jrst (Indexed (reg 5) 0)))))
  618. 'ExitOpenCode)
  619. (* "*FEQ, *FGreaterP and !*FLessP can only occur once in a function.")
  620. (DefList '((!*WFix ((fix (reg 1) (indexed (reg 1) 0))))
  621. (!*WFloat ((fltr (reg 2) (reg 2))
  622. (movem (reg 2) (indexed (reg 1) 0))
  623. (setzm (indexed (reg 1) 1))))
  624. (!*FAssign ((dmove (reg 2) (indexed (reg 2) 0))
  625. (dmovem (reg 2) (indexed (reg 1) 0))))
  626. (!*FEQ ((dmove (reg 3) (indexed (reg 2) 0))
  627. (came (reg 3) (indexed (reg 1) 0))
  628. (jrst !*NotEQ!*)
  629. (camn (reg 4) (indexed (reg 1) 1))
  630. !*NotEQ!*
  631. (move (reg 1) (reg nil))))
  632. (!*FGreaterP ((dmove (reg 3) (indexed (reg 2) 0))
  633. (camge (reg 3) (indexed (reg 1) 0))
  634. (jrst !*IsGreaterP!*)
  635. (camn (reg 3) (indexed (reg 1) 0))
  636. (caml (reg 4) (indexed (reg 1) 1))
  637. (move (reg 1) (reg nil))
  638. !*IsGreaterP!*))
  639. (!*FLessP ((dmove (reg 3) (indexed (reg 2) 0))
  640. (camle (reg 3) (indexed (reg 1) 0))
  641. (jrst !*IsLessP!*)
  642. (camn (reg 3) (indexed (reg 1) 0))
  643. (camg (reg 4) (indexed (reg 1) 1))
  644. (move (reg 1) (reg nil))
  645. !*IsLessP!*))
  646. (!*FPlus2 ((dmove (reg 3) (indexed (reg 3) 0))
  647. (dfad (reg 3) (indexed (reg 2) 0))
  648. (dmovem (reg 3) (indexed (reg 1) 0))))
  649. (!*FDifference ((dmove (reg 4) (indexed (reg 2) 0))
  650. (dfsb (reg 4) (indexed (reg 3) 0))
  651. (dmovem (reg 4) (indexed (reg 1) 0))))
  652. (!*FTimes2 ((dmove (reg 3) (indexed (reg 3) 0))
  653. (dfmp (reg 3) (indexed (reg 2) 0))
  654. (dmovem (reg 3) (indexed (reg 1) 0))))
  655. (!*FQuotient ((dmove (reg 4) (indexed (reg 2) 0))
  656. (dfdv (reg 4) (indexed (reg 3) 0))
  657. (dmovem (reg 4) (indexed (reg 1) 0)))))
  658. 'OpenCode)
  659. % Later, do as FORTRAN call?
  660. (DE !*ForeignLink (FunctionName FunctionType NumberOfArguments)
  661. (prog NIL
  662. (CodeDeclareExternal FunctionName) % To emit Extern
  663. (return (LIST (LIST 'Pushj '(REG st) (LIST 'InternalEntry FunctionName))))
  664. ))
  665. (DefCMacro !*ForeignLink)