or1korbis.cpu 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  1. ; OpenRISC Basic Instruction Set 32-bit (ORBIS) -*- Scheme -*-
  2. ; Copyright 2000-2014 Free Software Foundation, Inc.
  3. ; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org
  4. ; Modified by Julius Baxter, juliusbaxter@gmail.com
  5. ; Modified by Peter Gavin, pgavin@gmail.com
  6. ;
  7. ; This program is free software; you can redistribute it and/or modify
  8. ; it under the terms of the GNU General Public License as published by
  9. ; the Free Software Foundation; either version 3 of the License, or
  10. ; (at your option) any later version.
  11. ;
  12. ; This program is distributed in the hope that it will be useful,
  13. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ; GNU General Public License for more details.
  16. ;
  17. ; You should have received a copy of the GNU General Public License
  18. ; along with this program; if not, see <http://www.gnu.org/licenses/>
  19. ; Instruction fields.
  20. ; Hardware for immediate operands
  21. (dnh h-simm16 "16-bit signed immediate" ((MACH ORBIS-MACHS)) (immediate (INT 16)) () () ())
  22. (dnh h-uimm16 "16-bit unsigned immediate" () (immediate (UINT 16)) () () ())
  23. (dnh h-uimm6 "6-bit unsigned immediate" () (immediate (UINT 6)) () () ())
  24. ; Hardware for the (internal) atomic registers
  25. (dsh h-atomic-reserve "atomic reserve flag" () (register BI))
  26. (dsh h-atomic-address "atomic reserve address" () (register SI))
  27. ; Instruction classes.
  28. (dnf f-opcode "insn opcode" ((MACH ORBIS-MACHS)) 31 6)
  29. ; Register fields.
  30. (dnf f-r1 "r1" ((MACH ORBIS-MACHS)) 25 5)
  31. (dnf f-r2 "r2" ((MACH ORBIS-MACHS)) 20 5)
  32. (dnf f-r3 "r3" ((MACH ORBIS-MACHS)) 15 5)
  33. ; Sub fields
  34. (dnf f-op-25-2 "op-25-2" ((MACH ORBIS-MACHS)) 25 2) ;; nop
  35. (dnf f-op-25-5 "op-25-5" ((MACH ORBIS-MACHS)) 25 5) ;; sys, trap, *sync, sf*
  36. (dnf f-op-16-1 "op-16-1" ((MACH ORBIS-MACHS)) 16 1) ;; movhi,macrc
  37. (dnf f-op-7-4 "op-7-4" ((MACH ORBIS-MACHS)) 7 4)
  38. (dnf f-op-3-4 "op-3-4" ((MACH ORBIS-MACHS)) 3 4)
  39. (dnf f-op-9-2 "op-9-2" ((MACH ORBIS-MACHS)) 9 2) ;; alu ops upper opcode
  40. (dnf f-op-9-4 "op-9-4" ((MACH ORBIS-MACHS)) 9 4) ;;
  41. (dnf f-op-7-8 "op-7-8" ((MACH ORBIS-MACHS)) 7 8)
  42. (dnf f-op-7-2 "op-7-2" ((MACH ORBIS-MACHS)) 7 2) ;; alu lower upper opc,shroti
  43. ; Reserved fields
  44. (dnf f-resv-25-26 "resv-25-26" ((MACH ORBIS-MACHS) RESERVED) 25 26)
  45. (dnf f-resv-25-10 "resv-25-10" ((MACH ORBIS-MACHS) RESERVED) 25 10)
  46. (dnf f-resv-25-5 "resv-25-5" ((MACH ORBIS-MACHS) RESERVED) 25 5)
  47. (dnf f-resv-23-8 "resv-23-8" ((MACH ORBIS-MACHS) RESERVED) 23 8)
  48. (dnf f-resv-20-21 "resv-20-21" ((MACH ORBIS-MACHS) RESERVED) 20 21)
  49. (dnf f-resv-20-5 "resv-20-5" ((MACH ORBIS-MACHS) RESERVED) 20 5)
  50. (dnf f-resv-20-4 "resv-20-4" ((MACH ORBIS-MACHS) RESERVED) 20 4)
  51. (dnf f-resv-15-8 "resv-15-8" ((MACH ORBIS-MACHS) RESERVED) 15 8)
  52. (dnf f-resv-15-6 "resv-15-6" ((MACH ORBIS-MACHS) RESERVED) 15 6)
  53. (dnf f-resv-10-11 "resv-10-11" ((MACH ORBIS-MACHS) RESERVED) 10 11)
  54. (dnf f-resv-10-7 "resv-10-7" ((MACH ORBIS-MACHS) RESERVED) 10 7)
  55. (dnf f-resv-10-3 "resv-10-3" ((MACH ORBIS-MACHS) RESERVED) 10 3)
  56. (dnf f-resv-10-1 "resv-10-1" ((MACH ORBIS-MACHS) RESERVED) 10 1)
  57. (dnf f-resv-7-4 "resv-7-4" ((MACH ORBIS-MACHS) RESERVED) 7 4)
  58. (dnf f-resv-5-2 "resv-5-2" ((MACH ORBIS-MACHS) RESERVED) 5 2)
  59. (dnf f-imm16-25-5 "imm16-25-5" ((MACH ORBIS-MACHS)) 25 5)
  60. (dnf f-imm16-10-11 "imm16-10-11" ((MACH ORBIS-MACHS)) 10 11)
  61. ; PC relative, 26-bit (2 shifted to right)
  62. (df f-disp26
  63. "disp26"
  64. ((MACH ORBIS-MACHS) PCREL-ADDR)
  65. 25
  66. 26
  67. INT
  68. ((value pc) (sra SI (sub IAI value pc) (const 2)))
  69. ((value pc) (add IAI (sll IAI value (const 2)) pc))
  70. )
  71. ; Immediates.
  72. (dnf f-uimm16 "uimm16" ((MACH ORBIS-MACHS)) 15 16)
  73. (df f-simm16 "simm16" ((MACH ORBIS-MACHS) SIGN-OPT) 15 16 INT #f #f)
  74. (dnf f-uimm6 "uimm6" ((MACH ORBIS-MACHS)) 5 6) ;; shroti
  75. (define-multi-ifield
  76. (name f-uimm16-split)
  77. (comment "16-bit split unsigned immediate")
  78. (attrs (MACH ORBIS-MACHS))
  79. (mode UINT)
  80. (subfields f-imm16-25-5 f-imm16-10-11)
  81. (insert (sequence ()
  82. (set (ifield f-imm16-25-5)
  83. (and (srl (ifield f-uimm16-split)
  84. (const 11))
  85. (const #x1f)))
  86. (set (ifield f-imm16-10-11)
  87. (and (ifield f-uimm16-split)
  88. (const #x7ff)))))
  89. (extract
  90. (set (ifield f-uimm16-split)
  91. (trunc UHI
  92. (or (sll (ifield f-imm16-25-5)
  93. (const 11))
  94. (ifield f-imm16-10-11)))))
  95. )
  96. (define-multi-ifield
  97. (name f-simm16-split)
  98. (comment "16-bit split signed immediate")
  99. (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  100. (mode INT)
  101. (subfields f-imm16-25-5 f-imm16-10-11)
  102. (insert (sequence ()
  103. (set (ifield f-imm16-25-5)
  104. (and (sra (ifield f-simm16-split)
  105. (const 11))
  106. (const #x1f)))
  107. (set (ifield f-imm16-10-11)
  108. (and (ifield f-simm16-split)
  109. (const #x7ff)))))
  110. (extract
  111. (set (ifield f-simm16-split)
  112. (trunc HI
  113. (or (sll (ifield f-imm16-25-5)
  114. (const 11))
  115. (ifield f-imm16-10-11)))))
  116. )
  117. ; Enums.
  118. ; insn-opcode: bits 31-26
  119. (define-normal-insn-enum
  120. insn-opcode "insn main opcode enums" ((MACH ORBIS-MACHS)) OPC_ f-opcode
  121. (("J" #x00)
  122. ("JAL" #x01)
  123. ("BNF" #x03)
  124. ("BF" #x04)
  125. ("NOP" #x05)
  126. ("MOVHIMACRC" #x06)
  127. ("SYSTRAPSYNCS" #x08)
  128. ("RFE" #x09)
  129. ("VECTOR" #x0a)
  130. ("JR" #x11)
  131. ("JALR" #x12)
  132. ("MACI" #x13)
  133. ("LWA" #x1b)
  134. ("CUST1" #x1c)
  135. ("CUST2" #x1d)
  136. ("CUST3" #x1e)
  137. ("CUST4" #x1f)
  138. ("LD" #x20)
  139. ("LWZ" #x21)
  140. ("LWS" #x22)
  141. ("LBZ" #x23)
  142. ("LBS" #x24)
  143. ("LHZ" #x25)
  144. ("LHS" #x26)
  145. ("ADDI" #x27)
  146. ("ADDIC" #x28)
  147. ("ANDI" #x29)
  148. ("ORI" #x2a)
  149. ("XORI" #x2b)
  150. ("MULI" #x2c)
  151. ("MFSPR" #x2d)
  152. ("SHROTI" #x2e)
  153. ("SFI" #x2f)
  154. ("MTSPR" #x30)
  155. ("MAC" #x31)
  156. ("FLOAT" #x32)
  157. ("SWA" #x33)
  158. ("SD" #x34)
  159. ("SW" #x35)
  160. ("SB" #x36)
  161. ("SH" #x37)
  162. ("ALU" #x38)
  163. ("SF" #x39)
  164. ("CUST5" #x3c)
  165. ("CUST6" #x3d)
  166. ("CUST7" #x3e)
  167. ("CUST8" #x3f)
  168. )
  169. )
  170. (define-normal-insn-enum insn-opcode-systrapsyncs
  171. "systrapsync insn opcode enums" ((MACH ORBIS-MACHS))
  172. OPC_SYSTRAPSYNCS_ f-op-25-5
  173. (("SYSCALL" #x00 )
  174. ("TRAP" #x08 )
  175. ("MSYNC" #x10 )
  176. ("PSYNC" #x14 )
  177. ("CSYNC" #x18 )
  178. )
  179. )
  180. (define-normal-insn-enum insn-opcode-movehimacrc
  181. "movhi/macrc insn opcode enums" ((MACH ORBIS-MACHS))
  182. OPC_MOVHIMACRC_ f-op-16-1
  183. (("MOVHI" #x0)
  184. ("MACRC" #x1)
  185. )
  186. )
  187. (define-normal-insn-enum insn-opcode-mac
  188. "multiply/accumulate insn opcode enums" ((MACH ORBIS-MACHS))
  189. OPC_MAC_ f-op-3-4
  190. (("MAC" #x1)
  191. ("MSB" #x2)
  192. )
  193. )
  194. (define-normal-insn-enum insn-opcode-shorts
  195. "shift/rotate insn opcode enums" ((MACH ORBIS-MACHS))
  196. OPC_SHROTS_ f-op-7-2
  197. (("SLL" #x0 )
  198. ("SRL" #x1 )
  199. ("SRA" #x2 )
  200. ("ROR" #x3 )
  201. )
  202. )
  203. (define-normal-insn-enum insn-opcode-extbhs
  204. "extend byte/half opcode enums" ((MACH ORBIS-MACHS))
  205. OPC_EXTBHS_ f-op-9-4
  206. (("EXTHS" #x0)
  207. ("EXTBS" #x1)
  208. ("EXTHZ" #x2)
  209. ("EXTBZ" #x3)
  210. )
  211. )
  212. (define-normal-insn-enum insn-opcode-extws
  213. "extend word opcode enums" ((MACH ORBIS-MACHS))
  214. OPC_EXTWS_ f-op-9-4
  215. (("EXTWS" #x0)
  216. ("EXTWZ" #x1)
  217. )
  218. )
  219. (define-normal-insn-enum insn-opcode-alu-regreg
  220. "alu reg/reg insn opcode enums" ((MACH ORBIS-MACHS))
  221. OPC_ALU_REGREG_ f-op-3-4
  222. (("ADD" #x0)
  223. ("ADDC" #x1)
  224. ("SUB" #x2)
  225. ("AND" #x3)
  226. ("OR" #x4)
  227. ("XOR" #x5)
  228. ("MUL" #x6)
  229. ("SHROT" #x8)
  230. ("DIV" #x9)
  231. ("DIVU" #xA)
  232. ("MULU" #xB)
  233. ("EXTBH" #xC)
  234. ("EXTW" #xD)
  235. ("CMOV" #xE)
  236. ("FFL1" #xF)
  237. )
  238. )
  239. (define-normal-insn-enum insn-opcode-setflag
  240. "setflag insn opcode enums" ((MACH ORBIS-MACHS))
  241. OPC_SF_ f-op-25-5
  242. (("EQ" #x00)
  243. ("NE" #x01)
  244. ("GTU" #x02)
  245. ("GEU" #x03)
  246. ("LTU" #x04)
  247. ("LEU" #x05)
  248. ("GTS" #x0A)
  249. ("GES" #x0B)
  250. ("LTS" #x0C)
  251. ("LES" #x0D)
  252. )
  253. )
  254. ; Instruction operands.
  255. (dnop sys-sr "supervision register" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr f-nil)
  256. (dnop sys-esr0 "exception supervision register 0" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-esr0 f-nil)
  257. (dnop sys-epcr0 "exception PC register 0" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-epcr0 f-nil)
  258. (dnop sys-sr-lee "SR little endian enable bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-lee f-nil)
  259. (dnop sys-sr-f "SR flag bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-f f-nil)
  260. (dnop sys-sr-cy "SR carry bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-cy f-nil)
  261. (dnop sys-sr-ov "SR overflow bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ov f-nil)
  262. (dnop sys-sr-ove "SR overflow exception enable bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ove f-nil)
  263. (dnop sys-cpucfgr-ob64s "CPUCFGR ORBIS64 supported bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-ob64s f-nil)
  264. (dnop sys-cpucfgr-nd "CPUCFGR no delay bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-nd f-nil)
  265. (dnop sys-fpcsr-rm "floating point round mode" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-fpcsr-rm f-nil)
  266. (dnop mac-machi "MAC HI result register" ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-machi f-nil)
  267. (dnop mac-maclo "MAC LO result register" ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-maclo f-nil)
  268. (dnop atomic-reserve "atomic reserve flag" ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-reserve f-nil)
  269. (dnop atomic-address "atomic address" ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-address f-nil)
  270. (dnop uimm6 "uimm6" ((MACH ORBIS-MACHS)) h-uimm6 f-uimm6)
  271. (dnop rD "destination register" ((MACH ORBIS-MACHS)) h-gpr f-r1)
  272. (dnop rA "source register A" ((MACH ORBIS-MACHS)) h-gpr f-r2)
  273. (dnop rB "source register B" ((MACH ORBIS-MACHS)) h-gpr f-r3)
  274. (define-operand
  275. (name disp26)
  276. (comment "pc-rel 26 bit")
  277. (attrs (MACH ORBIS-MACHS))
  278. (type h-iaddr)
  279. (index f-disp26)
  280. (handlers (parse "disp26"))
  281. )
  282. (define-operand
  283. (name simm16)
  284. (comment "16-bit signed immediate")
  285. (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  286. (type h-simm16)
  287. (index f-simm16)
  288. (handlers (parse "simm16"))
  289. )
  290. (define-operand
  291. (name uimm16)
  292. (comment "16-bit unsigned immediate")
  293. (attrs (MACH ORBIS-MACHS))
  294. (type h-uimm16)
  295. (index f-uimm16)
  296. (handlers (parse "uimm16"))
  297. )
  298. (define-operand
  299. (name simm16-split)
  300. (comment "split 16-bit signed immediate")
  301. (attrs (MACH ORBIS-MACHS) SIGN-OPT)
  302. (type h-simm16)
  303. (index f-simm16-split)
  304. (handlers (parse "simm16"))
  305. )
  306. (define-operand
  307. (name uimm16-split)
  308. (comment "split 16-bit unsigned immediate")
  309. (attrs (MACH ORBIS-MACHS))
  310. (type h-uimm16)
  311. (index f-uimm16-split)
  312. (handlers (parse "uimm16"))
  313. )
  314. ; Instructions.
  315. ; Branch releated instructions
  316. (define-pmacro (cti-link-return)
  317. (set IAI (reg h-gpr 9) (add pc (if sys-cpucfgr-nd 4 8)))
  318. )
  319. (define-pmacro (cti-transfer-control condition target)
  320. ;; this mess is necessary because we're
  321. ;; skipping the delay slot, but it's
  322. ;; actually the start of the next basic
  323. ;; block
  324. (sequence ()
  325. (if condition
  326. (delay 1 (set IAI pc target))
  327. (if sys-cpucfgr-nd
  328. (delay 1 (set IAI pc (add pc 4))))
  329. )
  330. (if sys-cpucfgr-nd
  331. (skip 1)
  332. )
  333. )
  334. )
  335. (define-pmacro
  336. (define-cti
  337. cti-name
  338. cti-comment
  339. cti-attrs
  340. cti-syntax
  341. cti-format
  342. cti-semantics)
  343. (begin
  344. (dni
  345. cti-name
  346. cti-comment
  347. (.splice (MACH ORBIS-MACHS) DELAYED-CTI NOT-IN-DELAY-SLOT (.unsplice cti-attrs))
  348. cti-syntax
  349. cti-format
  350. (cti-semantics)
  351. ()
  352. )
  353. )
  354. )
  355. (define-cti
  356. l-j
  357. "jump (pc-relative iaddr)"
  358. (!COND-CTI UNCOND-CTI)
  359. "l.j ${disp26}"
  360. (+ OPC_J disp26)
  361. (.pmacro ()
  362. (cti-transfer-control 1 disp26)
  363. )
  364. )
  365. (define-cti
  366. l-jal
  367. "jump and link (pc-relative iaddr)"
  368. (!COND-CTI UNCOND-CTI)
  369. "l.jal ${disp26}"
  370. (+ OPC_JAL disp26)
  371. (.pmacro ()
  372. (sequence ()
  373. (cti-link-return)
  374. (cti-transfer-control 1 disp26)
  375. )
  376. )
  377. )
  378. (define-cti
  379. l-jr
  380. "jump register (absolute iaddr)"
  381. (!COND-CTI UNCOND-CTI)
  382. "l.jr $rB"
  383. (+ OPC_JR (f-resv-25-10 0) rB (f-resv-10-11 0))
  384. (.pmacro ()
  385. (cti-transfer-control 1 rB)
  386. )
  387. )
  388. (define-cti
  389. l-jalr
  390. "jump register and link (absolute iaddr)"
  391. (!COND-CTI UNCOND-CTI)
  392. "l.jalr $rB"
  393. (+ OPC_JALR (f-resv-25-10 0) rB (f-resv-10-11 0) )
  394. (.pmacro ()
  395. (sequence ()
  396. (cti-link-return)
  397. (cti-transfer-control 1 rB)
  398. )
  399. )
  400. )
  401. (define-cti
  402. l-bnf
  403. "branch if condition bit not set (pc relative iaddr)"
  404. (COND-CTI !UNCOND-CTI)
  405. "l.bnf ${disp26}"
  406. (+ OPC_BNF disp26)
  407. (.pmacro ()
  408. (cti-transfer-control (not sys-sr-f) disp26)
  409. )
  410. )
  411. (define-cti
  412. l-bf
  413. "branch if condition bit set (pc relative iaddr)"
  414. (COND-CTI !UNCOND-CTI)
  415. "l.bf ${disp26}"
  416. (+ OPC_BF disp26)
  417. (.pmacro ()
  418. (cti-transfer-control sys-sr-f disp26)
  419. )
  420. )
  421. (dni l-trap "trap (exception)"
  422. ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT)
  423. "l.trap ${uimm16}"
  424. (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_TRAP (f-resv-20-5 0) uimm16)
  425. ; Do exception entry handling in C function, PC set based on SR state
  426. (raise-exception EXCEPT-TRAP)
  427. ()
  428. )
  429. (dni l-sys "syscall (exception)"
  430. ; This function may not be in delay slot
  431. ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT)
  432. "l.sys ${uimm16}"
  433. (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_SYSCALL (f-resv-20-5 0) uimm16)
  434. ; Do exception entry handling in C function, PC set based on SR state
  435. (raise-exception EXCEPT-SYSCALL)
  436. ()
  437. )
  438. (dni l-msync "memory sync"
  439. ((MACH ORBIS-MACHS))
  440. "l.msync"
  441. (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_MSYNC (f-resv-20-21 0))
  442. (nop)
  443. ()
  444. )
  445. (dni l-psync "pipeline sync"
  446. ((MACH ORBIS-MACHS))
  447. "l.psync"
  448. (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_PSYNC (f-resv-20-21 0))
  449. (nop)
  450. ()
  451. )
  452. (dni l-csync "context sync"
  453. ((MACH ORBIS-MACHS))
  454. "l.csync"
  455. (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_CSYNC (f-resv-20-21 0))
  456. (nop)
  457. ()
  458. )
  459. (dni l-rfe "return from exception"
  460. ; This function may not be in delay slot
  461. ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT FORCED-CTI)
  462. "l.rfe"
  463. (+ OPC_RFE (f-resv-25-26 0))
  464. (c-call VOID "@cpu@_rfe")
  465. ()
  466. )
  467. ; Misc instructions
  468. ; l.nop with immediate must be first so it handles all l.nops in sim
  469. (dni l-nop-imm "nop uimm16"
  470. ((MACH ORBIS-MACHS))
  471. "l.nop ${uimm16}"
  472. (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16)
  473. (c-call VOID "@cpu@_nop" (zext UWI uimm16))
  474. ()
  475. )
  476. (if (application-is? SIMULATOR)
  477. (begin)
  478. (begin
  479. (dni l-nop "nop"
  480. ((MACH ORBIS-MACHS))
  481. "l.nop"
  482. (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16)
  483. (nop)
  484. ()
  485. )
  486. )
  487. )
  488. (dni l-movhi "movhi reg/uimm16"
  489. ((MACH ORBIS-MACHS))
  490. "l.movhi $rD,$uimm16"
  491. (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MOVHI uimm16)
  492. (set UWI rD (sll UWI (zext UWI uimm16) (const 16)))
  493. ()
  494. )
  495. (dni l-macrc "macrc reg"
  496. ((MACH ORBIS-MACHS))
  497. "l.macrc $rD"
  498. (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MACRC (f-uimm16 0))
  499. (sequence ()
  500. (set UWI rD mac-maclo)
  501. (set UWI mac-maclo 0)
  502. (set UWI mac-machi 0)
  503. )
  504. ()
  505. )
  506. ; System releated instructions
  507. (dni l-mfspr "mfspr"
  508. ((MACH ORBIS-MACHS))
  509. "l.mfspr $rD,$rA,${uimm16}"
  510. (+ OPC_MFSPR rD rA uimm16)
  511. (set UWI rD (c-call UWI "@cpu@_mfspr" (or rA (zext UWI uimm16))))
  512. ()
  513. )
  514. (dni l-mtspr "mtspr"
  515. ((MACH ORBIS-MACHS))
  516. "l.mtspr $rA,$rB,${uimm16-split}"
  517. (+ OPC_MTSPR rA rB uimm16-split )
  518. (c-call VOID "@cpu@_mtspr" (or rA (zext WI uimm16-split)) rB)
  519. ()
  520. )
  521. ; Load instructions
  522. (define-pmacro (load-store-addr base offset size)
  523. (c-call AI "@cpu@_make_load_store_addr" base (ext SI offset) size))
  524. (dni l-lwz "l.lwz reg/simm16(reg)"
  525. ((MACH ORBIS-MACHS))
  526. "l.lwz $rD,${simm16}($rA)"
  527. (+ OPC_LWZ rD rA simm16)
  528. (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4))))
  529. ()
  530. )
  531. (dni l-lws "l.lws reg/simm16(reg)"
  532. ((MACH ORBIS-MACHS))
  533. "l.lws $rD,${simm16}($rA)"
  534. (+ OPC_LWS rD rA simm16)
  535. (set WI rD (ext WI (mem SI (load-store-addr rA simm16 4))))
  536. ()
  537. )
  538. (dni l-lwa "l.lwa reg/simm16(reg)"
  539. ((MACH ORBIS-MACHS))
  540. "l.lwa $rD,${simm16}($rA)"
  541. (+ OPC_LWA rD rA simm16)
  542. (sequence ()
  543. (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4))))
  544. (set atomic-reserve (const 1))
  545. (set atomic-address (load-store-addr rA simm16 4))
  546. )
  547. ()
  548. )
  549. (dni l-lbz "l.lbz reg/simm16(reg)"
  550. ((MACH ORBIS-MACHS))
  551. "l.lbz $rD,${simm16}($rA)"
  552. (+ OPC_LBZ rD rA simm16)
  553. (set UWI rD (zext UWI (mem UQI (load-store-addr rA simm16 1))))
  554. ()
  555. )
  556. (dni l-lbs "l.lbs reg/simm16(reg)"
  557. ((MACH ORBIS-MACHS))
  558. "l.lbs $rD,${simm16}($rA)"
  559. (+ OPC_LBS rD rA simm16)
  560. (set WI rD (ext WI (mem QI (load-store-addr rA simm16 1))))
  561. ()
  562. )
  563. (dni l-lhz "l.lhz reg/simm16(reg)"
  564. ((MACH ORBIS-MACHS))
  565. "l.lhz $rD,${simm16}($rA)"
  566. (+ OPC_LHZ rD simm16 rA)
  567. (set UWI rD (zext UWI (mem UHI (load-store-addr rA simm16 2))))
  568. ()
  569. )
  570. (dni l-lhs "l.lhs reg/simm16(reg)"
  571. ((MACH ORBIS-MACHS))
  572. "l.lhs $rD,${simm16}($rA)"
  573. (+ OPC_LHS rD rA simm16)
  574. (set WI rD (ext WI (mem HI (load-store-addr rA simm16 2))))
  575. ()
  576. )
  577. ; Store instructions
  578. (define-pmacro (store-insn mnemonic opc-op mode size)
  579. (begin
  580. (dni (.sym l- mnemonic)
  581. (.str "l." mnemonic " simm16(reg)/reg")
  582. ((MACH ORBIS-MACHS))
  583. (.str "l." mnemonic " ${simm16-split}($rA),$rB")
  584. (+ opc-op rA rB simm16-split)
  585. (sequence ((SI addr))
  586. (set addr (load-store-addr rA simm16-split size))
  587. (set mode (mem mode addr) (trunc mode rB))
  588. (if (eq (and addr #xffffffc) atomic-address)
  589. (set atomic-reserve (const 0))
  590. )
  591. )
  592. ()
  593. )
  594. )
  595. )
  596. (store-insn sw OPC_SW USI 4)
  597. (store-insn sb OPC_SB UQI 1)
  598. (store-insn sh OPC_SH UHI 2)
  599. (dni l-swa "l.swa simm16(reg)/reg"
  600. ((MACH ORBIS-MACHS))
  601. "l.swa ${simm16-split}($rA),$rB"
  602. (+ OPC_SWA rA rB simm16)
  603. (sequence ((SI addr) (BI flag))
  604. (set addr (load-store-addr rA simm16-split 4))
  605. (set sys-sr-f (and atomic-reserve (eq addr atomic-address)))
  606. (if sys-sr-f
  607. (set USI (mem USI addr) (trunc USI rB))
  608. )
  609. (set atomic-reserve (const 0))
  610. )
  611. ()
  612. )
  613. ; Shift and rotate instructions
  614. (define-pmacro (shift-insn mnemonic)
  615. (begin
  616. (dni (.sym l- mnemonic)
  617. (.str "l." mnemonic " reg/reg/reg")
  618. ((MACH ORBIS-MACHS))
  619. (.str "l." mnemonic " $rD,$rA,$rB")
  620. (+ OPC_ALU rD rA rB (f-resv-10-3 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) (f-resv-5-2 0)
  621. OPC_ALU_REGREG_SHROT )
  622. (set UWI rD (mnemonic rA rB))
  623. ()
  624. )
  625. (dni (.sym l- mnemonic "i")
  626. (.str "l." mnemonic " reg/reg/uimm6")
  627. ((MACH ORBIS-MACHS))
  628. (.str "l." mnemonic "i $rD,$rA,${uimm6}")
  629. (+ OPC_SHROTI rD rA (f-resv-15-8 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) uimm6)
  630. (set rD (mnemonic rA uimm6))
  631. ()
  632. )
  633. )
  634. )
  635. (shift-insn sll)
  636. (shift-insn srl)
  637. (shift-insn sra)
  638. (shift-insn ror)
  639. ; Arithmetic insns
  640. ; ALU op macro
  641. (define-pmacro (alu-insn mnemonic)
  642. (begin
  643. (dni (.sym l- mnemonic)
  644. (.str "l." mnemonic " reg/reg/reg")
  645. ((MACH ORBIS-MACHS))
  646. (.str "l." mnemonic " $rD,$rA,$rB")
  647. (+ OPC_ALU rD rA rB (f-resv-10-7 0) (.sym OPC_ALU_REGREG_ (.upcase mnemonic)))
  648. (set rD (mnemonic rA rB))
  649. ()
  650. )
  651. )
  652. )
  653. (alu-insn and)
  654. (alu-insn or)
  655. (alu-insn xor)
  656. (define-pmacro (alu-carry-insn mnemonic)
  657. (begin
  658. (dni (.sym l- mnemonic)
  659. (.str "l." mnemonic " reg/reg/reg")
  660. ((MACH ORBIS-MACHS))
  661. (.str "l." mnemonic " $rD,$rA,$rB")
  662. (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) (.sym OPC_ALU_REGREG_ (.upcase mnemonic)))
  663. (sequence ()
  664. (sequence ()
  665. (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA rB 0))
  666. (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA rB 0))
  667. (set rD (mnemonic WI rA rB))
  668. )
  669. (if (andif sys-sr-ov sys-sr-ove)
  670. (raise-exception EXCEPT-RANGE))
  671. )
  672. ()
  673. )
  674. )
  675. )
  676. (alu-carry-insn add)
  677. (alu-carry-insn sub)
  678. (dni (l-addc) "l.addc reg/reg/reg"
  679. ((MACH ORBIS-MACHS))
  680. ("l.addc $rD,$rA,$rB")
  681. (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_ADDC)
  682. (sequence ()
  683. (sequence ((BI tmp-sys-sr-cy))
  684. (set BI tmp-sys-sr-cy sys-sr-cy)
  685. (set BI sys-sr-cy (addc-cflag WI rA rB tmp-sys-sr-cy))
  686. (set BI sys-sr-ov (addc-oflag WI rA rB tmp-sys-sr-cy))
  687. (set rD (addc WI rA rB tmp-sys-sr-cy))
  688. )
  689. (if (andif sys-sr-ov sys-sr-ove)
  690. (raise-exception EXCEPT-RANGE))
  691. )
  692. ()
  693. )
  694. (dni (l-mul) "l.mul reg/reg/reg"
  695. ((MACH ORBIS-MACHS))
  696. ("l.mul $rD,$rA,$rB")
  697. (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MUL)
  698. (sequence ()
  699. (sequence ()
  700. ; 2's complement overflow
  701. (set BI sys-sr-ov (mul-o2flag WI rA rB))
  702. ; 1's complement overflow
  703. (set BI sys-sr-cy (mul-o1flag WI rA rB))
  704. (set rD (mul WI rA rB))
  705. )
  706. (if (andif sys-sr-ov sys-sr-ove)
  707. (raise-exception EXCEPT-RANGE))
  708. )
  709. ()
  710. )
  711. (dni (l-mulu) "l.mulu reg/reg/reg"
  712. ((MACH ORBIS-MACHS))
  713. ("l.mulu $rD,$rA,$rB")
  714. (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULU)
  715. (sequence ()
  716. (sequence ()
  717. ; 2's complement overflow
  718. (set BI sys-sr-ov 0)
  719. ; 1's complement overflow
  720. (set BI sys-sr-cy (mul-o1flag UWI rA rB))
  721. (set rD (mul UWI rA rB))
  722. )
  723. (if (andif sys-sr-ov sys-sr-ove)
  724. (raise-exception EXCEPT-RANGE))
  725. )
  726. ()
  727. )
  728. (dni l-div "divide (signed)"
  729. ((MACH ORBIS-MACHS))
  730. "l.div $rD,$rA,$rB"
  731. (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIV)
  732. (sequence ()
  733. (if (ne rB 0)
  734. (sequence ()
  735. (set BI sys-sr-cy 0)
  736. (set WI rD (div WI rA rB))
  737. )
  738. (set BI sys-sr-cy 1)
  739. )
  740. (set BI sys-sr-ov 0)
  741. (if (andif sys-sr-cy sys-sr-ove)
  742. (raise-exception EXCEPT-RANGE))
  743. )
  744. ()
  745. )
  746. (dni l-divu "divide (unsigned)"
  747. ((MACH ORBIS-MACHS))
  748. "l.divu $rD,$rA,$rB"
  749. (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIVU)
  750. (sequence ()
  751. (if (ne rB 0)
  752. (sequence ()
  753. (set BI sys-sr-cy 0)
  754. (set rD (udiv UWI rA rB))
  755. )
  756. (set BI sys-sr-cy 1)
  757. )
  758. (set BI sys-sr-ov 0)
  759. (if (andif sys-sr-cy sys-sr-ove)
  760. (raise-exception EXCEPT-RANGE))
  761. )
  762. ()
  763. )
  764. (dni l-ff1 "find first '1'"
  765. ((MACH ORBIS-MACHS))
  766. "l.ff1 $rD,$rA"
  767. (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_FFL1)
  768. (set rD (c-call UWI "@cpu@_ff1" rA))
  769. ()
  770. )
  771. (dni l-fl1 "find last '1'"
  772. ((MACH ORBIS-MACHS))
  773. "l.fl1 $rD,$rA"
  774. (+ OPC_ALU rD rA rB (f-resv-10-7 #x10) OPC_ALU_REGREG_FFL1)
  775. (set rD (c-call UWI "@cpu@_fl1" rA))
  776. ()
  777. )
  778. (define-pmacro (alu-insn-simm mnemonic)
  779. (begin
  780. (dni (.sym l- mnemonic "i")
  781. (.str "l." mnemonic " reg/reg/simm16")
  782. ((MACH ORBIS-MACHS))
  783. (.str "l." mnemonic "i $rD,$rA,$simm16")
  784. (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16)
  785. (set rD (mnemonic rA (ext WI simm16)))
  786. ()
  787. )
  788. )
  789. )
  790. (define-pmacro (alu-insn-uimm mnemonic)
  791. (begin
  792. (dni (.sym l- mnemonic "i")
  793. (.str "l." mnemonic " reg/reg/uimm16")
  794. ((MACH ORBIS-MACHS))
  795. (.str "l." mnemonic "i $rD,$rA,$uimm16")
  796. (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA uimm16)
  797. (set rD (mnemonic rA (zext UWI uimm16)))
  798. ()
  799. )
  800. )
  801. )
  802. (alu-insn-uimm and)
  803. (alu-insn-uimm or)
  804. (alu-insn-simm xor)
  805. (define-pmacro (alu-carry-insn-simm mnemonic)
  806. (begin
  807. (dni (.sym l- mnemonic "i")
  808. (.str "l." mnemonic "i reg/reg/simm16")
  809. ((MACH ORBIS-MACHS))
  810. (.str "l." mnemonic "i $rD,$rA,$simm16")
  811. (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16)
  812. (sequence ()
  813. (sequence ()
  814. (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA (ext WI simm16) 0))
  815. (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA (ext WI simm16) 0))
  816. (set rD (mnemonic WI rA (ext WI simm16)))
  817. )
  818. (if (andif sys-sr-ov sys-sr-ove)
  819. (raise-exception EXCEPT-RANGE))
  820. )
  821. ()
  822. )
  823. )
  824. )
  825. (alu-carry-insn-simm add)
  826. (dni (l-addic)
  827. ("l.addic reg/reg/simm16")
  828. ((MACH ORBIS-MACHS))
  829. ("l.addic $rD,$rA,$simm16")
  830. (+ OPC_ADDIC rD rA simm16)
  831. (sequence ()
  832. (sequence ((BI tmp-sys-sr-cy))
  833. (set BI tmp-sys-sr-cy sys-sr-cy)
  834. (set BI sys-sr-cy (addc-cflag WI rA (ext WI simm16) tmp-sys-sr-cy))
  835. (set BI sys-sr-ov (addc-oflag WI rA (ext WI simm16) tmp-sys-sr-cy))
  836. (set WI rD (addc WI rA (ext WI simm16) tmp-sys-sr-cy))
  837. )
  838. (if (andif sys-sr-ov sys-sr-ove)
  839. (raise-exception EXCEPT-RANGE))
  840. )
  841. ()
  842. )
  843. (dni (l-muli)
  844. "l.muli reg/reg/simm16"
  845. ((MACH ORBIS-MACHS))
  846. ("l.muli $rD,$rA,$simm16")
  847. (+ OPC_MULI rD rA simm16)
  848. (sequence ()
  849. (sequence ()
  850. ; 2's complement overflow
  851. (set sys-sr-ov (mul-o2flag WI rA (ext WI simm16)))
  852. ; 1's complement overflow
  853. (set sys-sr-cy (mul-o1flag UWI rA (ext UWI simm16)))
  854. (set rD (mul WI rA (ext WI simm16)))
  855. )
  856. (if (andif sys-sr-ov sys-sr-ove)
  857. (raise-exception EXCEPT-RANGE))
  858. )
  859. ()
  860. )
  861. (define-pmacro (extbh-insn mnemonic extop extmode truncmode)
  862. (begin
  863. (dni (.sym l- mnemonic)
  864. (.str "l." mnemonic " reg/reg")
  865. ((MACH ORBIS-MACHS))
  866. (.str "l." mnemonic " $rD,$rA")
  867. (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTBHS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTBH)
  868. (set rD (extop extmode (trunc truncmode rA)))
  869. ()
  870. )
  871. )
  872. )
  873. (extbh-insn exths ext WI HI)
  874. (extbh-insn extbs ext WI QI)
  875. (extbh-insn exthz zext UWI UHI)
  876. (extbh-insn extbz zext UWI UQI)
  877. (define-pmacro (extw-insn mnemonic extop extmode truncmode)
  878. (begin
  879. (dni (.sym l- mnemonic)
  880. (.str "l." mnemonic " reg/reg")
  881. ((MACH ORBIS-MACHS))
  882. (.str "l." mnemonic " $rD,$rA")
  883. (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTWS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTW)
  884. (set rD (extop extmode (trunc truncmode rA)))
  885. ()
  886. )
  887. )
  888. )
  889. (extw-insn extws ext WI SI)
  890. (extw-insn extwz zext USI USI)
  891. (dni l-cmov
  892. "l.cmov reg/reg/reg"
  893. ((MACH ORBIS-MACHS))
  894. "l.cmov $rD,$rA,$rB"
  895. (+ OPC_ALU rD rA rB (f-resv-10-1 0) (f-op-9-2 0) (f-resv-7-4 0) OPC_ALU_REGREG_CMOV)
  896. (if sys-sr-f
  897. (set UWI rD rA)
  898. (set UWI rD rB)
  899. )
  900. ()
  901. )
  902. ; Compare instructions
  903. ; Ordering compare
  904. (define-pmacro (sf-insn op)
  905. (begin
  906. (dni (.sym l- "sf" op "s") ; l-sfgts
  907. (.str "l.sf" op "s reg/reg") ; "l.sfgts reg/reg"
  908. ((MACH ORBIS-MACHS))
  909. (.str "l.sf" op "s $rA,$rB") ; "l.sfgts $rA,$rB"
  910. (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "S") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTS rA rB (f-resv-10-11 0))
  911. (set sys-sr-f (op WI rA rB)) ; (set sys-sr-f (gt WI rA rB))
  912. ()
  913. )
  914. (dni (.sym l- "sf" op "si") ; l-sfgtsi
  915. (.str "l.sf" op "si reg/simm16") ; "l.sfgtsi reg/simm16"
  916. ((MACH ORBIS-MACHS))
  917. (.str "l.sf" op "si $rA,$simm16") ; "l.sfgtsi $rA,$simm16"
  918. (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "S") rA simm16) ; (+ OPC_SFI OPC_SF_GTS rA simm16)
  919. (set sys-sr-f (op WI rA (ext WI simm16))) ; (set sys-sr-f (gt WI rA (ext WI simm16)))
  920. ()
  921. )
  922. (dni (.sym l- "sf" op "u") ; l-sfgtu
  923. (.str "l.sf" op "u reg/reg") ; "l.sfgtu reg/reg"
  924. ((MACH ORBIS-MACHS))
  925. (.str "l.sf" op "u $rA,$rB") ; "l.sfgtu $rA,$rB"
  926. (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "U") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTU rA rB (f-resv-10-11 0))
  927. (set sys-sr-f ((.sym op "u") WI rA rB)) ; (set sys-sr-f (gtu WI rA rB))
  928. ()
  929. )
  930. ; immediate is sign extended even for unsigned compare
  931. (dni (.sym l- "sf" op "ui") ; l-sfgtui
  932. (.str "l.sf" op "ui reg/simm16") ; "l.sfgtui reg/uimm16"
  933. ((MACH ORBIS-MACHS))
  934. (.str "l.sf" op "ui $rA,$simm16") ; "l.sfgtui $rA,$simm16"
  935. (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "U") rA simm16) ; (+ OPC_SFI OPC_SF_GTU rA simm16)
  936. (set sys-sr-f ((.sym op "u") WI rA (ext WI simm16))) ; (set sys-sr-f (gtu WI rA (ext WI simm16)))
  937. ()
  938. )
  939. )
  940. )
  941. (sf-insn gt)
  942. (sf-insn ge)
  943. (sf-insn lt)
  944. (sf-insn le)
  945. ; Equality compare
  946. (define-pmacro (sf-insn-eq op)
  947. (begin
  948. (dni (.sym l- "sf" op)
  949. (.str "l." op " reg/reg")
  950. ((MACH ORBIS-MACHS))
  951. (.str "l.sf" op " $rA,$rB")
  952. (+ OPC_SF (.sym "OPC_SF_" (.upcase op)) rA rB (f-resv-10-11 0))
  953. (set sys-sr-f (op WI rA rB))
  954. ()
  955. )
  956. (dni (.sym l- "sf" op "i")
  957. (.str "l.sf" op "i reg/simm16")
  958. ((MACH ORBIS-MACHS))
  959. (.str "l.sf" op "i $rA,$simm16")
  960. (+ OPC_SFI (.sym "OPC_SF_" (.upcase op)) rA simm16)
  961. (set sys-sr-f (op WI rA (ext WI simm16)))
  962. ()
  963. )
  964. )
  965. )
  966. (sf-insn-eq eq)
  967. (sf-insn-eq ne)
  968. (dni l-mac
  969. "l.mac reg/reg"
  970. ((MACH ORBIS-MACHS))
  971. "l.mac $rA,$rB"
  972. (+ OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MAC)
  973. (sequence ((WI prod) (DI result))
  974. (set WI prod (mul WI rA rB))
  975. (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod)))
  976. (set SI mac-machi (subword SI result 0))
  977. (set SI mac-maclo (subword SI result 1))
  978. )
  979. ()
  980. )
  981. (dni l-msb
  982. "l.msb reg/reg"
  983. ((MACH ORBIS-MACHS))
  984. "l.msb $rA,$rB"
  985. (+ OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MSB)
  986. (sequence ((WI prod) (DI result))
  987. (set WI prod (mul WI rA rB))
  988. (set DI result (sub (join DI SI mac-machi mac-maclo) (ext DI prod)))
  989. (set SI mac-machi (subword SI result 0))
  990. (set SI mac-maclo (subword SI result 1))
  991. )
  992. ()
  993. )
  994. (dni l-maci
  995. "l.maci reg/simm16"
  996. ((MACH ORBIS-MACHS))
  997. "l.maci $rA,${simm16}"
  998. (+ OPC_MACI (f-resv-25-5 0) rA simm16)
  999. (sequence ((WI prod) (DI result))
  1000. (set WI prod (mul WI (ext WI simm16) rA))
  1001. (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod)))
  1002. (set SI mac-machi (subword SI result 0))
  1003. (set SI mac-maclo (subword SI result 1))
  1004. )
  1005. ()
  1006. )
  1007. (define-pmacro (cust-insn cust-num)
  1008. (begin
  1009. (dni (.sym l- "cust" cust-num)
  1010. (.str "l.cust" cust-num)
  1011. ((MACH ORBIS-MACHS))
  1012. (.str "l.cust" cust-num)
  1013. (+ (.sym OPC_CUST cust-num) (f-resv-25-26 0))
  1014. (nop)
  1015. ()
  1016. )
  1017. )
  1018. )
  1019. (cust-insn "1")
  1020. (cust-insn "2")
  1021. (cust-insn "3")
  1022. (cust-insn "4")
  1023. (cust-insn "5")
  1024. (cust-insn "6")
  1025. (cust-insn "7")
  1026. (cust-insn "8")