fr30.cpu 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862
  1. ; Fujitsu FR30 CPU description. -*- Scheme -*-
  2. ; Copyright 2011 Free Software Foundation, Inc.
  3. ;
  4. ; Contributed by Red Hat Inc;
  5. ;
  6. ; This file is part of the GNU Binutils.
  7. ;
  8. ; This program is free software; you can redistribute it and/or modify
  9. ; it under the terms of the GNU General Public License as published by
  10. ; the Free Software Foundation; either version 3 of the License, or
  11. ; (at your option) any later version.
  12. ;
  13. ; This program is distributed in the hope that it will be useful,
  14. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ; GNU General Public License for more details.
  17. ;
  18. ; You should have received a copy of the GNU General Public License
  19. ; along with this program; if not, write to the Free Software
  20. ; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  21. ; MA 02110-1301, USA.
  22. (define-rtl-version 0 8)
  23. (include "simplify.inc")
  24. ; define-arch must appear first
  25. (define-arch
  26. (name fr30) ; name of cpu family
  27. (comment "Fujitsu FR30")
  28. (default-alignment forced)
  29. (insn-lsb0? #f)
  30. (machs fr30)
  31. (isas fr30)
  32. )
  33. (define-isa
  34. (name fr30)
  35. (base-insn-bitsize 16)
  36. (decode-assist (0 1 2 3 4 5 6 7)) ; Initial bitnumbers to decode insns by.
  37. (liw-insns 1) ; The fr30 fetches 1 insn at a time.
  38. (parallel-insns 1) ; The fr30 executes 1 insn at a time.
  39. )
  40. (define-cpu
  41. ; cpu names must be distinct from the architecture name and machine names.
  42. ; The "b" suffix stands for "base" and is the convention.
  43. ; The "f" suffix stands for "family" and is the convention.
  44. (name fr30bf)
  45. (comment "Fujitsu FR30 base family")
  46. (endian big)
  47. (word-bitsize 32)
  48. )
  49. (define-mach
  50. (name fr30)
  51. (comment "Generic FR30 cpu")
  52. (cpu fr30bf)
  53. )
  54. ; Model descriptions.
  55. ;
  56. (define-model
  57. (name fr30-1) (comment "fr30-1") (attrs)
  58. (mach fr30)
  59. (pipeline all "" () ((fetch) (decode) (execute) (writeback)))
  60. ; `state' is a list of variables for recording model state
  61. (state
  62. ; bit mask of h-gr registers loaded from memory by previous insn
  63. (load-regs UINT)
  64. ; bit mask of h-gr registers loaded from memory by current insn
  65. (load-regs-pending UINT)
  66. )
  67. (unit u-exec "Execution Unit" ()
  68. 1 1 ; issue done
  69. () ; state
  70. ((Ri INT -1) (Rj INT -1)) ; inputs
  71. ((Ri INT -1)) ; outputs
  72. () ; profile action (default)
  73. )
  74. (unit u-cti "Branch Unit" ()
  75. 1 1 ; issue done
  76. () ; state
  77. ((Ri INT -1)) ; inputs
  78. ((pc)) ; outputs
  79. () ; profile action (default)
  80. )
  81. (unit u-load "Memory Load Unit" ()
  82. 1 1 ; issue done
  83. () ; state
  84. ((Rj INT -1)
  85. ;(ld-mem AI)
  86. ) ; inputs
  87. ((Ri INT -1)) ; outputs
  88. () ; profile action (default)
  89. )
  90. (unit u-store "Memory Store Unit" ()
  91. 1 1 ; issue done
  92. () ; state
  93. ((Ri INT -1) (Rj INT -1)) ; inputs
  94. () ; ((st-mem AI)) ; outputs
  95. () ; profile action (default)
  96. )
  97. (unit u-ldm "LDM Memory Load Unit" ()
  98. 1 1 ; issue done
  99. () ; state
  100. ((reglist INT)) ; inputs
  101. () ; outputs
  102. () ; profile action (default)
  103. )
  104. (unit u-stm "STM Memory Store Unit" ()
  105. 1 1 ; issue done
  106. () ; state
  107. ((reglist INT)) ; inputs
  108. () ; outputs
  109. () ; profile action (default)
  110. )
  111. )
  112. ; The instruction fetch/execute cycle.
  113. ;
  114. ; This is how to fetch and decode an instruction.
  115. ; Leave it out for now
  116. ; (define-extract (const SI 0))
  117. ; This is how to execute a decoded instruction.
  118. ; Leave it out for now
  119. ; (define-execute (const SI 0))
  120. ; Instruction fields.
  121. ;
  122. ; Attributes:
  123. ; PCREL-ADDR: pc relative value (for reloc and disassembly purposes)
  124. ; ABS-ADDR: absolute address (for reloc and disassembly purposes?)
  125. ; RESERVED: bits are not used to decode insn, must be all 0
  126. (dnf f-op1 "1st 4 bits of opcode" () 0 4)
  127. (dnf f-op2 "2nd 4 bits of opcode" () 4 4)
  128. (dnf f-op3 "3rd 4 bits of opcode" () 8 4)
  129. (dnf f-op4 "4th 4 bits of opcode" () 12 4)
  130. (dnf f-op5 "5th bit of opcode" () 4 1)
  131. (dnf f-cc "condition code" () 4 4)
  132. (dnf f-ccc "coprocessor calc code" () 16 8)
  133. (dnf f-Rj "register Rj" () 8 4)
  134. (dnf f-Ri "register Ri" () 12 4)
  135. (dnf f-Rs1 "register Rs" () 8 4)
  136. (dnf f-Rs2 "register Rs" () 12 4)
  137. (dnf f-Rjc "register Rj" () 24 4)
  138. (dnf f-Ric "register Ri" () 28 4)
  139. (dnf f-CRj "coprocessor register" () 24 4)
  140. (dnf f-CRi "coprocessor register" () 28 4)
  141. (dnf f-u4 "4 bit 0 extended" () 8 4)
  142. (dnf f-u4c "4 bit 0 extended" () 12 4)
  143. (df f-i4 "4 bit sign extended" () 8 4 INT #f #f)
  144. (df f-m4 "4 bit minus extended" () 8 4 UINT
  145. ((value pc) (and WI value (const #xf)))
  146. ; ??? On a 64 bit host this doesn't get completely sign extended
  147. ; if the value is recorded in a long, as it is during extraction.
  148. ; Various fixes exist, pick one.
  149. ((value pc) (or WI value (sll WI (const -1) (const 4))))
  150. )
  151. (dnf f-u8 "8 bit unsigned" () 8 8)
  152. (dnf f-i8 "8 bit unsigned" () 4 8)
  153. (dnf f-i20-4 "upper 4 bits of i20" () 8 4)
  154. (dnf f-i20-16 "lower 16 bits of i20" () 16 16)
  155. (dnmf f-i20 "20 bit unsigned" () UINT
  156. (f-i20-4 f-i20-16)
  157. (sequence () ; insert
  158. (set (ifield f-i20-4) (srl (ifield f-i20) (const 16)))
  159. (set (ifield f-i20-16) (and (ifield f-i20) (const #xffff)))
  160. )
  161. (sequence () ; extract
  162. (set (ifield f-i20) (or (sll (ifield f-i20-4) (const 16))
  163. (ifield f-i20-16)))
  164. )
  165. )
  166. (dnf f-i32 "32 bit immediate" (SIGN-OPT) 16 32)
  167. (df f-udisp6 "6 bit unsigned offset" () 8 4 UINT
  168. ((value pc) (srl UWI value (const 2)))
  169. ((value pc) (sll UWI value (const 2)))
  170. )
  171. (df f-disp8 "8 bit signed offset" () 4 8 INT #f #f)
  172. (df f-disp9 "9 bit signed offset" () 4 8 INT
  173. ((value pc) (sra WI value (const 1)))
  174. ((value pc) (sll WI value (const 1)))
  175. )
  176. (df f-disp10 "10 bit signed offset" () 4 8 INT
  177. ((value pc) (sra WI value (const 2)))
  178. ((value pc) (sll WI value (const 2)))
  179. )
  180. (df f-s10 "10 bit signed offset" () 8 8 INT
  181. ((value pc) (sra WI value (const 2)))
  182. ((value pc) (sll WI value (const 2)))
  183. )
  184. (df f-u10 "10 bit unsigned offset" () 8 8 UINT
  185. ((value pc) (srl UWI value (const 2)))
  186. ((value pc) (sll UWI value (const 2)))
  187. )
  188. (df f-rel9 "9 pc relative signed offset" (PCREL-ADDR) 8 8 INT
  189. ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
  190. ((value pc) (add WI (sll WI value (const 1)) (add WI pc (const 2))))
  191. )
  192. (dnf f-dir8 "8 bit direct address" () 8 8)
  193. (df f-dir9 "9 bit direct address" () 8 8 UINT
  194. ((value pc) (srl UWI value (const 1)))
  195. ((value pc) (sll UWI value (const 1)))
  196. )
  197. (df f-dir10 "10 bit direct address" () 8 8 UINT
  198. ((value pc) (srl UWI value (const 2)))
  199. ((value pc) (sll UWI value (const 2)))
  200. )
  201. (df f-rel12 "12 bit pc relative signed offset" (PCREL-ADDR) 5 11 INT
  202. ((value pc) (sra WI (sub WI value (add WI pc (const 2))) (const 1)))
  203. ((value pc) (add WI (sll WI value (const 1)) (add WI pc (const 2))))
  204. )
  205. (dnf f-reglist_hi_st "8 bit register mask for stm" () 8 8)
  206. (dnf f-reglist_low_st "8 bit register mask for stm" () 8 8)
  207. (dnf f-reglist_hi_ld "8 bit register mask for ldm" () 8 8)
  208. (dnf f-reglist_low_ld "8 bit register mask for ldm" () 8 8)
  209. ; Enums.
  210. ; insn-op1: bits 0-3
  211. ; FIXME: should use die macro or some such
  212. (define-normal-insn-enum insn-op1 "insn op1 enums" () OP1_ f-op1
  213. ("0" "1" "2" "3" "4" "5" "6" "7"
  214. "8" "9" "A" "B" "C" "D" "E" "F")
  215. )
  216. ; insn-op2: bits 4-7
  217. ; FIXME: should use die macro or some such
  218. (define-normal-insn-enum insn-op2 "insn op2 enums" () OP2_ f-op2
  219. ("0" "1" "2" "3" "4" "5" "6" "7"
  220. "8" "9" "A" "B" "C" "D" "E" "F")
  221. )
  222. ; insn-op3: bits 8-11
  223. ; FIXME: should use die macro or some such
  224. (define-normal-insn-enum insn-op3 "insn op3 enums" () OP3_ f-op3
  225. ("0" "1" "2" "3" "4" "5" "6" "7"
  226. "8" "9" "A" "B" "C" "D" "E" "F")
  227. )
  228. ; insn-op4: bits 12-15
  229. ; FIXME: should use die macro or some such
  230. (define-normal-insn-enum insn-op4 "insn op4 enums" () OP4_ f-op4
  231. ("0")
  232. )
  233. ; insn-op5: bit 4 (5th bit origin 0)
  234. ; FIXME: should use die macro or some such
  235. (define-normal-insn-enum insn-op5 "insn op5 enums" () OP5_ f-op5
  236. ("0" "1")
  237. )
  238. ; insn-cc: condition codes
  239. ; FIXME: should use die macro or some such
  240. (define-normal-insn-enum insn-cc "insn cc enums" () CC_ f-cc
  241. ("ra" "no" "eq" "ne" "c" "nc" "n" "p" "v" "nv" "lt" "ge" "le" "gt" "ls" "hi")
  242. )
  243. ; Hardware pieces.
  244. ; These entries list the elements of the raw hardware.
  245. ; They're also used to provide tables and other elements of the assembly
  246. ; language.
  247. (dnh h-pc "program counter" (PC PROFILE) (pc) () () ())
  248. (define-keyword
  249. (name gr-names)
  250. (enum-prefix H-GR-)
  251. (values (r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6) (r7 7)
  252. (r8 8) (r9 9) (r10 10) (r11 11) (r12 12) (r13 13) (r14 14) (r15 15)
  253. (ac 13) (fp 14) (sp 15))
  254. )
  255. (define-hardware
  256. (name h-gr)
  257. (comment "general registers")
  258. (attrs PROFILE CACHE-ADDR)
  259. (type register WI (16))
  260. (indices extern-keyword gr-names)
  261. )
  262. (define-keyword
  263. (name cr-names)
  264. (enum-prefix H-CR-)
  265. (values (cr0 0) (cr1 1) (cr2 2) (cr3 3)
  266. (cr4 4) (cr5 5) (cr6 6) (cr7 7)
  267. (cr8 8) (cr9 9) (cr10 10) (cr11 11)
  268. (cr12 12) (cr13 13) (cr14 14) (cr15 15))
  269. )
  270. (define-hardware
  271. (name h-cr)
  272. (comment "coprocessor registers")
  273. (attrs)
  274. (type register WI (16))
  275. (indices extern-keyword cr-names)
  276. )
  277. (define-keyword
  278. (name dr-names)
  279. (enum-prefix H-DR-)
  280. (values (tbr 0) (rp 1) (ssp 2) (usp 3) (mdh 4) (mdl 5))
  281. )
  282. (define-hardware
  283. (name h-dr)
  284. (comment "dedicated registers")
  285. (type register WI (6))
  286. (indices extern-keyword dr-names)
  287. (get (index) (c-call WI "@cpu@_h_dr_get_handler" index))
  288. (set (index newval) (c-call VOID "@cpu@_h_dr_set_handler" index newval))
  289. )
  290. (define-hardware
  291. (name h-ps)
  292. (comment "processor status")
  293. (type register UWI)
  294. (indices keyword "" ((ps 0)))
  295. (get () (c-call UWI "@cpu@_h_ps_get_handler"))
  296. (set (newval) (c-call VOID "@cpu@_h_ps_set_handler" newval))
  297. )
  298. (dnh h-r13 "General Register 13 explicitly required"
  299. ()
  300. (register WI)
  301. (keyword "" ((r13 0)))
  302. () ()
  303. )
  304. (dnh h-r14 "General Register 14 explicitly required"
  305. ()
  306. (register WI)
  307. (keyword "" ((r14 0)))
  308. () ()
  309. )
  310. (dnh h-r15 "General Register 15 explicitly required"
  311. ()
  312. (register WI)
  313. (keyword "" ((r15 0)))
  314. () ()
  315. )
  316. ; These bits are actually part of the PS register but are accessed more
  317. ; often than the entire register, so define them directly. We can assemble
  318. ; the PS register from its components when necessary.
  319. (dsh h-nbit "negative bit" () (register BI))
  320. (dsh h-zbit "zero bit" () (register BI))
  321. (dsh h-vbit "overflow bit" () (register BI))
  322. (dsh h-cbit "carry bit" () (register BI))
  323. (dsh h-ibit "interrupt enable bit" () (register BI))
  324. (define-hardware
  325. (name h-sbit)
  326. (comment "stack bit")
  327. (type register BI)
  328. (get () (c-call BI "@cpu@_h_sbit_get_handler"))
  329. (set (newval) (c-call VOID "@cpu@_h_sbit_set_handler" newval))
  330. )
  331. (dsh h-tbit "trace trap bit" () (register BI))
  332. (dsh h-d0bit "division 0 bit" () (register BI))
  333. (dsh h-d1bit "division 1 bit" () (register BI))
  334. ; These represent sub-registers within the program status register
  335. (define-hardware
  336. (name h-ccr)
  337. (comment "condition code bits")
  338. (type register UQI)
  339. (get () (c-call UQI "@cpu@_h_ccr_get_handler"))
  340. (set (newval) (c-call VOID "@cpu@_h_ccr_set_handler" newval))
  341. )
  342. (define-hardware
  343. (name h-scr)
  344. (comment "system condition bits")
  345. (type register UQI)
  346. (get () (c-call UQI "@cpu@_h_scr_get_handler"))
  347. (set (newval) (c-call VOID "@cpu@_h_scr_set_handler" newval))
  348. )
  349. (define-hardware
  350. (name h-ilm)
  351. (comment "interrupt level mask")
  352. (type register UQI)
  353. (get () (c-call UQI "@cpu@_h_ilm_get_handler"))
  354. (set (newval) (c-call VOID "@cpu@_h_ilm_set_handler" newval))
  355. )
  356. ; Instruction Operands.
  357. ; These entries provide a layer between the assembler and the raw hardware
  358. ; description, and are used to refer to hardware elements in the semantic
  359. ; code. Usually there's a bit of over-specification, but in more complicated
  360. ; instruction sets there isn't.
  361. ; FR30 specific operand attributes:
  362. (define-attr
  363. (for operand)
  364. (type boolean)
  365. (name HASH-PREFIX)
  366. (comment "immediates have an optional '#' prefix")
  367. )
  368. ; ??? Convention says this should be o-sr, but then the insn definitions
  369. ; should refer to o-sr which is clumsy. The "o-" could be implicit, but
  370. ; then it should be implicit for all the symbols here, but then there would
  371. ; be confusion between (f-)simm8 and (h-)simm8.
  372. ; So for now the rule is exactly as it appears here.
  373. (dnop Ri "destination register" () h-gr f-Ri)
  374. (dnop Rj "source register" () h-gr f-Rj)
  375. (dnop Ric "target register coproc insn" () h-gr f-Ric)
  376. (dnop Rjc "source register coproc insn" () h-gr f-Rjc)
  377. (dnop CRi "coprocessor register" () h-cr f-CRi)
  378. (dnop CRj "coprocessor register" () h-cr f-CRj)
  379. (dnop Rs1 "dedicated register" () h-dr f-Rs1)
  380. (dnop Rs2 "dedicated register" () h-dr f-Rs2)
  381. (dnop R13 "General Register 13" () h-r13 f-nil)
  382. (dnop R14 "General Register 14" () h-r14 f-nil)
  383. (dnop R15 "General Register 15" () h-r15 f-nil)
  384. (dnop ps "Program Status register" () h-ps f-nil)
  385. (dnop u4 "4 bit unsigned immediate" (HASH-PREFIX) h-uint f-u4)
  386. (dnop u4c "4 bit unsigned immediate" (HASH-PREFIX) h-uint f-u4c)
  387. (dnop u8 "8 bit unsigned immediate" (HASH-PREFIX) h-uint f-u8)
  388. (dnop i8 "8 bit unsigned immediate" (HASH-PREFIX) h-uint f-i8)
  389. (dnop udisp6 "6 bit unsigned immediate" (HASH-PREFIX) h-uint f-udisp6)
  390. (dnop disp8 "8 bit signed immediate" (HASH-PREFIX) h-sint f-disp8)
  391. (dnop disp9 "9 bit signed immediate" (HASH-PREFIX) h-sint f-disp9)
  392. (dnop disp10 "10 bit signed immediate" (HASH-PREFIX) h-sint f-disp10)
  393. (dnop s10 "10 bit signed immediate" (HASH-PREFIX) h-sint f-s10)
  394. (dnop u10 "10 bit unsigned immediate" (HASH-PREFIX) h-uint f-u10)
  395. (dnop i32 "32 bit immediate" (HASH-PREFIX) h-uint f-i32)
  396. (define-operand
  397. (name m4)
  398. (comment "4 bit negative immediate")
  399. (attrs HASH-PREFIX)
  400. (type h-sint)
  401. (index f-m4)
  402. (handlers (print "m4"))
  403. )
  404. (define-operand
  405. (name i20)
  406. (comment "20 bit immediate")
  407. (attrs HASH-PREFIX)
  408. (type h-uint)
  409. (index f-i20)
  410. )
  411. (dnop dir8 "8 bit direct address" () h-uint f-dir8)
  412. (dnop dir9 "9 bit direct address" () h-uint f-dir9)
  413. (dnop dir10 "10 bit direct address" () h-uint f-dir10)
  414. (dnop label9 "9 bit pc relative address" () h-iaddr f-rel9)
  415. (dnop label12 "12 bit pc relative address" () h-iaddr f-rel12)
  416. (define-operand
  417. (name reglist_low_ld)
  418. (comment "8 bit low register mask for ldm")
  419. (attrs)
  420. (type h-uint)
  421. (index f-reglist_low_ld)
  422. (handlers (parse "low_register_list_ld")
  423. (print "low_register_list_ld"))
  424. )
  425. (define-operand
  426. (name reglist_hi_ld)
  427. (comment "8 bit high register mask for ldm")
  428. (attrs)
  429. (type h-uint)
  430. (index f-reglist_hi_ld)
  431. (handlers (parse "hi_register_list_ld")
  432. (print "hi_register_list_ld"))
  433. )
  434. (define-operand
  435. (name reglist_low_st)
  436. (comment "8 bit low register mask for stm")
  437. (attrs)
  438. (type h-uint)
  439. (index f-reglist_low_st)
  440. (handlers (parse "low_register_list_st")
  441. (print "low_register_list_st"))
  442. )
  443. (define-operand
  444. (name reglist_hi_st)
  445. (comment "8 bit high register mask for stm")
  446. (attrs)
  447. (type h-uint)
  448. (index f-reglist_hi_st)
  449. (handlers (parse "hi_register_list_st")
  450. (print "hi_register_list_st"))
  451. )
  452. (dnop cc "condition codes" () h-uint f-cc)
  453. (dnop ccc "coprocessor calc" (HASH-PREFIX) h-uint f-ccc)
  454. (dnop nbit "negative bit" (SEM-ONLY) h-nbit f-nil)
  455. (dnop vbit "overflow bit" (SEM-ONLY) h-vbit f-nil)
  456. (dnop zbit "zero bit" (SEM-ONLY) h-zbit f-nil)
  457. (dnop cbit "carry bit" (SEM-ONLY) h-cbit f-nil)
  458. (dnop ibit "interrupt bit" (SEM-ONLY) h-ibit f-nil)
  459. (dnop sbit "stack bit" (SEM-ONLY) h-sbit f-nil)
  460. (dnop tbit "trace trap bit" (SEM-ONLY) h-tbit f-nil)
  461. (dnop d0bit "division 0 bit" (SEM-ONLY) h-d0bit f-nil)
  462. (dnop d1bit "division 1 bit" (SEM-ONLY) h-d1bit f-nil)
  463. (dnop ccr "condition code bits" (SEM-ONLY) h-ccr f-nil)
  464. (dnop scr "system condition bits" (SEM-ONLY) h-scr f-nil)
  465. (dnop ilm "interrupt level mask" (SEM-ONLY) h-ilm f-nil)
  466. ; Instruction definitions.
  467. ;
  468. ; Notes:
  469. ; - dni is short for "define-normal-instruction"
  470. ; FR30 specific insn attributes:
  471. (define-attr
  472. (for insn)
  473. (type boolean)
  474. (name NOT-IN-DELAY-SLOT)
  475. (comment "insn can't go in delay slot")
  476. )
  477. ; Sets zbit and nbit based on the value of x
  478. ;
  479. (define-pmacro (set-z-and-n x)
  480. (sequence ()
  481. (set zbit (eq x (const 0)))
  482. (set nbit (lt x (const 0))))
  483. )
  484. ; Binary integer instruction which sets status bits
  485. ;
  486. (define-pmacro (binary-int-op name insn comment opc1 opc2 op arg1 arg2)
  487. (dni name
  488. (.str insn " " comment)
  489. ()
  490. (.str insn " $" arg1 ",$" arg2)
  491. (+ opc1 opc2 arg1 arg2)
  492. (sequence ()
  493. (set vbit ((.sym op -oflag) arg2 arg1 (const 0)))
  494. (set cbit ((.sym op -cflag) arg2 arg1 (const 0)))
  495. (set arg2 (op arg2 arg1))
  496. (set-z-and-n arg2))
  497. ()
  498. )
  499. )
  500. ; Binary integer instruction which does *not* set status bits
  501. ;
  502. (define-pmacro (binary-int-op-n name insn comment opc1 opc2 op arg1 arg2)
  503. (dni name
  504. (.str insn " " comment)
  505. ()
  506. (.str insn " $" arg1 ",$" arg2)
  507. (+ opc1 opc2 arg1 arg2)
  508. (set arg2 (op arg2 arg1))
  509. ()
  510. )
  511. )
  512. ; Binary integer instruction with carry which sets status bits
  513. ;
  514. (define-pmacro (binary-int-op-c name insn comment opc1 opc2 op arg1 arg2)
  515. (dni name
  516. (.str insn " " comment)
  517. ()
  518. (.str insn " $" arg1 ",$" arg2)
  519. (+ opc1 opc2 arg1 arg2)
  520. (sequence ((WI tmp))
  521. (set tmp ((.sym op c) arg2 arg1 cbit))
  522. (set vbit ((.sym op -oflag) arg2 arg1 cbit))
  523. (set cbit ((.sym op -cflag) arg2 arg1 cbit))
  524. (set arg2 tmp)
  525. (set-z-and-n arg2))
  526. ()
  527. )
  528. )
  529. (binary-int-op add add "reg/reg" OP1_A OP2_6 add Rj Ri)
  530. (binary-int-op addi add "immed/reg" OP1_A OP2_4 add u4 Ri)
  531. (binary-int-op add2 add2 "immed/reg" OP1_A OP2_5 add m4 Ri)
  532. (binary-int-op-c addc addc "reg/reg" OP1_A OP2_7 add Rj Ri)
  533. (binary-int-op-n addn addn "reg/reg" OP1_A OP2_2 add Rj Ri)
  534. (binary-int-op-n addni addn "immed/reg" OP1_A OP2_0 add u4 Ri)
  535. (binary-int-op-n addn2 addn2 "immed/reg" OP1_A OP2_1 add m4 Ri)
  536. (binary-int-op sub sub "reg/reg" OP1_A OP2_C sub Rj Ri)
  537. (binary-int-op-c subc subc "reg/reg" OP1_A OP2_D sub Rj Ri)
  538. (binary-int-op-n subn subn "reg/reg" OP1_A OP2_E sub Rj Ri)
  539. ; Integer compare instruction
  540. ;
  541. (define-pmacro (int-cmp name insn comment opc1 opc2 arg1 arg2)
  542. (dni name
  543. (.str insn " " comment)
  544. ()
  545. (.str insn " $" arg1 ",$" arg2)
  546. (+ opc1 opc2 arg1 arg2)
  547. (sequence ((WI tmp1))
  548. (set vbit (sub-oflag arg2 arg1 (const 0)))
  549. (set cbit (sub-cflag arg2 arg1 (const 0)))
  550. (set tmp1 (sub arg2 arg1))
  551. (set-z-and-n tmp1)
  552. )
  553. ()
  554. )
  555. )
  556. (int-cmp cmp cmp "reg/reg" OP1_A OP2_A Rj Ri)
  557. (int-cmp cmpi cmp "immed/reg" OP1_A OP2_8 u4 Ri)
  558. (int-cmp cmp2 cmp2 "immed/reg" OP1_A OP2_9 m4 Ri)
  559. ; Binary logical instruction
  560. ;
  561. (define-pmacro (binary-logical-op name insn comment opc1 opc2 op arg1 arg2)
  562. (dni name
  563. (.str insn " " comment)
  564. ()
  565. (.str insn " $" arg1 ",$" arg2)
  566. (+ opc1 opc2 arg1 arg2)
  567. (sequence ()
  568. (set arg2 (op arg2 arg1))
  569. (set-z-and-n arg2))
  570. ()
  571. )
  572. )
  573. (binary-logical-op and and "reg/reg" OP1_8 OP2_2 and Rj Ri)
  574. (binary-logical-op or or "reg/reg" OP1_9 OP2_2 or Rj Ri)
  575. (binary-logical-op eor eor "reg/reg" OP1_9 OP2_A xor Rj Ri)
  576. (define-pmacro (les-units model) ; les: load-exec-store
  577. (model (unit u-exec) (unit u-load) (unit u-store))
  578. )
  579. ; Binary logical instruction to memory
  580. ;
  581. (define-pmacro (binary-logical-op-m name insn comment opc1 opc2 mode op arg1 arg2)
  582. (dni name
  583. (.str insn " " comment)
  584. (NOT-IN-DELAY-SLOT)
  585. (.str insn " $" arg1 ",@$" arg2)
  586. (+ opc1 opc2 arg1 arg2)
  587. (sequence ((mode tmp))
  588. (set mode tmp (op mode (mem mode arg2) arg1))
  589. (set-z-and-n tmp)
  590. (set mode (mem mode arg2) tmp))
  591. ((les-units fr30-1))
  592. )
  593. )
  594. (binary-logical-op-m andm and "reg/mem" OP1_8 OP2_4 WI and Rj Ri)
  595. (binary-logical-op-m andh andh "reg/mem" OP1_8 OP2_5 HI and Rj Ri)
  596. (binary-logical-op-m andb andb "reg/mem" OP1_8 OP2_6 QI and Rj Ri)
  597. (binary-logical-op-m orm or "reg/mem" OP1_9 OP2_4 WI or Rj Ri)
  598. (binary-logical-op-m orh orh "reg/mem" OP1_9 OP2_5 HI or Rj Ri)
  599. (binary-logical-op-m orb orb "reg/mem" OP1_9 OP2_6 QI or Rj Ri)
  600. (binary-logical-op-m eorm eor "reg/mem" OP1_9 OP2_C WI xor Rj Ri)
  601. (binary-logical-op-m eorh eorh "reg/mem" OP1_9 OP2_D HI xor Rj Ri)
  602. (binary-logical-op-m eorb eorb "reg/mem" OP1_9 OP2_E QI xor Rj Ri)
  603. ; Binary logical instruction to low half of byte in memory
  604. ;
  605. (dni bandl
  606. "bandl #u4,@Ri"
  607. (NOT-IN-DELAY-SLOT)
  608. "bandl $u4,@$Ri"
  609. (+ OP1_8 OP2_0 u4 Ri)
  610. (set QI (mem QI Ri)
  611. (and QI
  612. (or QI u4 (const #xf0))
  613. (mem QI Ri)))
  614. ((les-units fr30-1))
  615. )
  616. (dni borl
  617. "borl #u4,@Ri"
  618. (NOT-IN-DELAY-SLOT)
  619. "borl $u4,@$Ri"
  620. (+ OP1_9 OP2_0 u4 Ri)
  621. (set QI (mem QI Ri) (or QI u4 (mem QI Ri)))
  622. ((les-units fr30-1))
  623. )
  624. (dni beorl
  625. "beorl #u4,@Ri"
  626. (NOT-IN-DELAY-SLOT)
  627. "beorl $u4,@$Ri"
  628. (+ OP1_9 OP2_8 u4 Ri)
  629. (set QI (mem QI Ri) (xor QI u4 (mem QI Ri)))
  630. ((les-units fr30-1))
  631. )
  632. ; Binary logical instruction to high half of byte in memory
  633. ;
  634. (dni bandh
  635. "bandh #u4,@Ri"
  636. (NOT-IN-DELAY-SLOT)
  637. "bandh $u4,@$Ri"
  638. (+ OP1_8 OP2_1 u4 Ri)
  639. (set QI (mem QI Ri)
  640. (and QI
  641. (or QI (sll QI u4 (const 4)) (const #x0f))
  642. (mem QI Ri)))
  643. ((les-units fr30-1))
  644. )
  645. (define-pmacro (binary-or-op-mh name insn opc1 opc2 op arg1 arg2)
  646. (dni name
  647. (.str name " #" arg1 ",@" args)
  648. (NOT-IN-DELAY-SLOT)
  649. (.str name " $" arg1 ",@$" arg2)
  650. (+ opc1 opc2 arg1 arg2)
  651. (set QI (mem QI arg2)
  652. (insn QI
  653. (sll QI arg1 (const 4))
  654. (mem QI arg2)))
  655. ((les-units fr30-1))
  656. )
  657. )
  658. (binary-or-op-mh borh or OP1_9 OP2_1 or u4 Ri)
  659. (binary-or-op-mh beorh xor OP1_9 OP2_9 xor u4 Ri)
  660. (dni btstl
  661. "btstl #u4,@Ri"
  662. (NOT-IN-DELAY-SLOT)
  663. "btstl $u4,@$Ri"
  664. (+ OP1_8 OP2_8 u4 Ri)
  665. (sequence ((QI tmp))
  666. (set tmp (and QI u4 (mem QI Ri)))
  667. (set zbit (eq tmp (const 0)))
  668. (set nbit (const 0)))
  669. ((fr30-1 (unit u-load) (unit u-exec (cycles 2))))
  670. )
  671. (dni btsth
  672. "btsth #u4,@Ri"
  673. (NOT-IN-DELAY-SLOT)
  674. "btsth $u4,@$Ri"
  675. (+ OP1_8 OP2_9 u4 Ri)
  676. (sequence ((QI tmp))
  677. (set tmp (and QI (sll QI u4 (const 4)) (mem QI Ri)))
  678. (set zbit (eq tmp (const 0)))
  679. (set nbit (lt tmp (const 0))))
  680. ((fr30-1 (unit u-load) (unit u-exec (cycles 2))))
  681. )
  682. (dni mul
  683. "mul Rj,Ri"
  684. (NOT-IN-DELAY-SLOT)
  685. "mul $Rj,$Ri"
  686. (+ OP1_A OP2_F Rj Ri)
  687. (sequence ((DI tmp))
  688. (set tmp (mul DI (ext DI Rj) (ext DI Ri)))
  689. (set (reg h-dr 5) (trunc WI tmp))
  690. (set (reg h-dr 4) (trunc WI (srl tmp (const 32))))
  691. (set nbit (lt (reg h-dr 5) (const 0)))
  692. (set zbit (eq tmp (const DI 0)))
  693. (set vbit (orif
  694. (gt tmp (const DI #x7fffffff))
  695. (lt tmp (neg (const DI #x80000000))))))
  696. ((fr30-1 (unit u-exec (cycles 5))))
  697. )
  698. (dni mulu
  699. "mulu Rj,Ri"
  700. (NOT-IN-DELAY-SLOT)
  701. "mulu $Rj,$Ri"
  702. (+ OP1_A OP2_B Rj Ri)
  703. (sequence ((DI tmp))
  704. (set tmp (mul DI (zext DI Rj) (zext DI Ri)))
  705. (set (reg h-dr 5) (trunc WI tmp))
  706. (set (reg h-dr 4) (trunc WI (srl tmp (const 32))))
  707. (set nbit (lt (reg h-dr 4) (const 0)))
  708. (set zbit (eq (reg h-dr 5) (const 0)))
  709. (set vbit (ne (reg h-dr 4) (const 0))))
  710. ((fr30-1 (unit u-exec (cycles 5))))
  711. )
  712. (dni mulh
  713. "mulh Rj,Ri"
  714. (NOT-IN-DELAY-SLOT)
  715. "mulh $Rj,$Ri"
  716. (+ OP1_B OP2_F Rj Ri)
  717. (sequence ()
  718. (set (reg h-dr 5) (mul (trunc HI Rj) (trunc HI Ri)))
  719. (set nbit (lt (reg h-dr 5) (const 0)))
  720. (set zbit (ge (reg h-dr 5) (const 0))))
  721. ((fr30-1 (unit u-exec (cycles 3))))
  722. )
  723. (dni muluh
  724. "muluh Rj,Ri"
  725. (NOT-IN-DELAY-SLOT)
  726. "muluh $Rj,$Ri"
  727. (+ OP1_B OP2_B Rj Ri)
  728. (sequence ()
  729. (set (reg h-dr 5) (mul (and Rj (const #xffff))
  730. (and Ri (const #xffff))))
  731. (set nbit (lt (reg h-dr 5) (const 0)))
  732. (set zbit (ge (reg h-dr 5) (const 0))))
  733. ((fr30-1 (unit u-exec (cycles 3))))
  734. )
  735. (dni div0s
  736. "div0s Ri"
  737. ()
  738. "div0s $Ri"
  739. (+ OP1_9 OP2_7 OP3_4 Ri)
  740. (sequence ()
  741. (set d0bit (lt (reg h-dr 5) (const 0)))
  742. (set d1bit (xor d0bit (lt Ri (const 0))))
  743. (if (ne d0bit (const 0))
  744. (set (reg h-dr 4) (const #xffffffff))
  745. (set (reg h-dr 4) (const 0))))
  746. ()
  747. )
  748. (dni div0u
  749. "div0u Ri"
  750. ()
  751. "div0u $Ri"
  752. (+ OP1_9 OP2_7 OP3_5 Ri)
  753. (sequence ()
  754. (set d0bit (const 0))
  755. (set d1bit (const 0))
  756. (set (reg h-dr 4) (const 0)))
  757. ()
  758. )
  759. (dni div1
  760. "div1 Ri"
  761. ()
  762. "div1 $Ri"
  763. (+ OP1_9 OP2_7 OP3_6 Ri)
  764. (sequence ((WI tmp))
  765. (set (reg h-dr 4) (sll (reg h-dr 4) (const 1)))
  766. (if (lt (reg h-dr 5) (const 0))
  767. (set (reg h-dr 4) (add (reg h-dr 4) (const 1))))
  768. (set (reg h-dr 5) (sll (reg h-dr 5) (const 1)))
  769. (if (eq d1bit (const 1))
  770. (sequence ()
  771. (set tmp (add (reg h-dr 4) Ri))
  772. (set cbit (add-cflag (reg h-dr 4) Ri (const 0))))
  773. (sequence ()
  774. (set tmp (sub (reg h-dr 4) Ri))
  775. (set cbit (sub-cflag (reg h-dr 4) Ri (const 0)))))
  776. (if (not (xor (xor d0bit d1bit) cbit))
  777. (sequence ()
  778. (set (reg h-dr 4) tmp)
  779. (set (reg h-dr 5) (or (reg h-dr 5) (const 1)))))
  780. (set zbit (eq (reg h-dr 4) (const 0))))
  781. ()
  782. )
  783. (dni div2
  784. "div2 Ri"
  785. ()
  786. "div2 $Ri"
  787. (+ OP1_9 OP2_7 OP3_7 Ri)
  788. (sequence ((WI tmp))
  789. (if (eq d1bit (const 1))
  790. (sequence ()
  791. (set tmp (add (reg h-dr 4) Ri))
  792. (set cbit (add-cflag (reg h-dr 4) Ri (const 0))))
  793. (sequence ()
  794. (set tmp (sub (reg h-dr 4) Ri))
  795. (set cbit (sub-cflag (reg h-dr 4) Ri (const 0)))))
  796. (if (eq tmp (const 0))
  797. (sequence ()
  798. (set zbit (const 1))
  799. (set (reg h-dr 4) (const 0)))
  800. (set zbit (const 0))))
  801. ()
  802. )
  803. (dni div3
  804. "div3"
  805. ()
  806. "div3"
  807. (+ OP1_9 OP2_F OP3_6 OP4_0)
  808. (if (eq zbit (const 1))
  809. (set (reg h-dr 5) (add (reg h-dr 5) (const 1))))
  810. ()
  811. )
  812. (dni div4s
  813. "div4s"
  814. ()
  815. "div4s"
  816. (+ OP1_9 OP2_F OP3_7 OP4_0)
  817. (if (eq d1bit (const 1))
  818. (set (reg h-dr 5) (neg (reg h-dr 5))))
  819. ()
  820. )
  821. (define-pmacro (leftshift-op name insn opc1 opc2 arg1 arg2 shift-expr)
  822. (dni name
  823. (.str insn " " arg1 "," arg2)
  824. ()
  825. (.str insn " $" arg1 ",$" arg2)
  826. (+ opc1 opc2 arg1 arg2)
  827. (sequence ((WI shift))
  828. (set shift shift-expr)
  829. (if (ne shift (const 0))
  830. (sequence ()
  831. (set cbit (ne (and arg2
  832. (sll (const 1)
  833. (sub (const 32) shift)))
  834. (const 0)))
  835. (set arg2 (sll arg2 shift)))
  836. (set cbit (const 0)))
  837. (set nbit (lt arg2 (const 0)))
  838. (set zbit (eq arg2 (const 0))))
  839. ()
  840. )
  841. )
  842. (leftshift-op lsl lsl OP1_B OP2_6 Rj Ri (and Rj (const #x1f)))
  843. (leftshift-op lsli lsl OP1_B OP2_4 u4 Ri u4)
  844. (leftshift-op lsl2 lsl2 OP1_B OP2_5 u4 Ri (add u4 (const #x10)))
  845. (define-pmacro (rightshift-op name insn opc1 opc2 op arg1 arg2 shift-expr)
  846. (dni name
  847. (.str insn " " arg1 "," arg2)
  848. ()
  849. (.str insn " $" arg1 ",$" arg2)
  850. (+ opc1 opc2 arg1 arg2)
  851. (sequence ((WI shift))
  852. (set shift shift-expr)
  853. (if (ne shift (const 0))
  854. (sequence ()
  855. (set cbit (ne (and arg2
  856. (sll (const 1)
  857. (sub shift (const 1))))
  858. (const 0)))
  859. (set arg2 (op arg2 shift)))
  860. (set cbit (const 0)))
  861. (set nbit (lt arg2 (const 0)))
  862. (set zbit (eq arg2 (const 0))))
  863. ()
  864. )
  865. )
  866. (rightshift-op lsr lsr OP1_B OP2_2 srl Rj Ri (and Rj (const #x1f)))
  867. (rightshift-op lsri lsr OP1_B OP2_0 srl u4 Ri u4)
  868. (rightshift-op lsr2 lsr2 OP1_B OP2_1 srl u4 Ri (add u4 (const #x10)))
  869. (rightshift-op asr asr OP1_B OP2_A sra Rj Ri (and Rj (const #x1f)))
  870. (rightshift-op asri asr OP1_B OP2_8 sra u4 Ri u4)
  871. (rightshift-op asr2 asr2 OP1_B OP2_9 sra u4 Ri (add u4 (const #x10)))
  872. (dni ldi8
  873. "load 8 bit unsigned immediate"
  874. ()
  875. "ldi:8 $i8,$Ri"
  876. (+ OP1_C i8 Ri)
  877. (set Ri i8)
  878. ()
  879. )
  880. ; Typing ldi:8 in in emacs is a pain.
  881. (dnmi ldi8m "ldi:8 without the colon"
  882. (NO-DIS)
  883. "ldi8 $i8,$Ri"
  884. (emit ldi8 i8 Ri)
  885. )
  886. (dni ldi20
  887. "load 20 bit unsigned immediate"
  888. (NOT-IN-DELAY-SLOT)
  889. "ldi:20 $i20,$Ri"
  890. (+ OP1_9 OP2_B Ri i20)
  891. (set Ri i20)
  892. ((fr30-1 (unit u-exec (cycles 2))))
  893. )
  894. ; Typing ldi:20 in in emacs is a pain.
  895. (dnmi ldi20m "ldi:20 without the colon"
  896. (NO-DIS)
  897. "ldi20 $i20,$Ri"
  898. (emit ldi20 i20 Ri)
  899. )
  900. (dni ldi32
  901. "load 32 bit immediate"
  902. (NOT-IN-DELAY-SLOT)
  903. "ldi:32 $i32,$Ri"
  904. (+ OP1_9 OP2_F OP3_8 Ri i32)
  905. (set Ri i32)
  906. ((fr30-1 (unit u-exec (cycles 3))))
  907. )
  908. ; Typing ldi:32 in in emacs is a pain.
  909. (dnmi ldi32m "ldi:32 without the colon"
  910. (NO-DIS)
  911. "ldi32 $i32,$Ri"
  912. (emit ldi32 i32 Ri)
  913. )
  914. (define-pmacro (basic-ld name insn opc1 opc2 mode arg1 arg2)
  915. (dni name
  916. (.str name " @" arg1 "," arg2)
  917. ()
  918. (.str name " @$" arg1 ",$" arg2)
  919. (+ opc1 opc2 arg1 arg2)
  920. (set arg2 (mem mode arg1))
  921. ((fr30-1 (unit u-load)))
  922. )
  923. )
  924. (basic-ld ld ld OP1_0 OP2_4 WI Rj Ri)
  925. (basic-ld lduh lduh OP1_0 OP2_5 UHI Rj Ri)
  926. (basic-ld ldub ldub OP1_0 OP2_6 UQI Rj Ri)
  927. (define-pmacro (r13base-ld name insn opc1 opc2 mode arg1 arg2)
  928. (dni name
  929. (.str insn " @(R13," arg1 ")," arg2)
  930. ()
  931. (.str insn " @($R13,$" arg1 "),$" arg2)
  932. (+ opc1 opc2 arg1 arg2)
  933. (set arg2 (mem mode (add arg1 (reg h-gr 13))))
  934. ((fr30-1 (unit u-load)))
  935. )
  936. )
  937. (r13base-ld ldr13 ld OP1_0 OP2_0 WI Rj Ri)
  938. (r13base-ld ldr13uh lduh OP1_0 OP2_1 UHI Rj Ri)
  939. (r13base-ld ldr13ub ldub OP1_0 OP2_2 UQI Rj Ri)
  940. (define-pmacro (r14base-ld name insn opc1 mode arg1 arg2)
  941. (dni name
  942. (.str insn " @(R14," arg1 ")," arg2)
  943. ()
  944. (.str insn " @($R14,$" arg1 "),$" arg2)
  945. (+ opc1 arg1 arg2)
  946. (set arg2 (mem mode (add arg1 (reg h-gr 14))))
  947. ((fr30-1 (unit u-load)))
  948. )
  949. )
  950. (r14base-ld ldr14 ld OP1_2 WI disp10 Ri)
  951. (r14base-ld ldr14uh lduh OP1_4 UHI disp9 Ri)
  952. (r14base-ld ldr14ub ldub OP1_6 UQI disp8 Ri)
  953. (dni ldr15
  954. "ld @(R15,udisp6),Ri mem/reg"
  955. ()
  956. "ld @($R15,$udisp6),$Ri"
  957. (+ OP1_0 OP2_3 udisp6 Ri)
  958. (set Ri (mem WI (add udisp6 (reg h-gr 15))))
  959. ((fr30-1 (unit u-load)))
  960. )
  961. (dni ldr15gr
  962. "ld @R15+,Ri"
  963. ()
  964. "ld @$R15+,$Ri"
  965. (+ OP1_0 OP2_7 OP3_0 Ri)
  966. (sequence ()
  967. (set Ri (mem WI (reg h-gr 15)))
  968. (if (ne (ifield f-Ri) (const 15))
  969. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  970. ((fr30-1 (unit u-load)))
  971. )
  972. ; This insn loads a value from where r15 points into the target register and
  973. ; then increments r15. If the target register is also r15, then the post
  974. ; increment is not performed.
  975. ;
  976. (dni ldr15dr
  977. "ld @R15+,Rs2"
  978. ()
  979. "ld @$R15+,$Rs2"
  980. (+ OP1_0 OP2_7 OP3_8 Rs2)
  981. ; This seems more straight forward, but doesn't work due to a problem in
  982. ; cgen. We're trying to not increment r15 if it is the target register.
  983. ; (sequence ()
  984. ; (set Rs2 (mem WI (reg h-gr 15)))
  985. ; (if (not (or (and (eq (ifield f-Rs2) (const 2))
  986. ; (eq sbit (const 0)))
  987. ; (and (eq (ifield f-Rs2) (const 3))
  988. ; (eq sbit (const 1)))))
  989. ; (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))
  990. ; )
  991. ; )
  992. (sequence ((WI tmp))
  993. (set tmp (mem WI (reg h-gr 15))) ; save in case target is r15
  994. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))
  995. (set Rs2 tmp))
  996. ((fr30-1 (unit u-load)))
  997. )
  998. (dni ldr15ps
  999. "ld @R15+,ps mem/reg"
  1000. (NOT-IN-DELAY-SLOT)
  1001. "ld @$R15+,$ps"
  1002. (+ OP1_0 OP2_7 OP3_9 OP4_0)
  1003. (sequence ()
  1004. (set ps (mem WI (reg h-gr 15)))
  1005. (set (reg h-gr 15) (add (reg h-gr 15) (const 4))))
  1006. ((fr30-1 (unit u-load)))
  1007. )
  1008. (define-pmacro (basic-st name insn opc1 opc2 mode arg1 arg2)
  1009. (dni name
  1010. (.str name " " arg1 ",@" arg2)
  1011. ()
  1012. (.str name " $" arg1 ",@$" arg2)
  1013. (+ opc1 opc2 arg1 arg2)
  1014. (set (mem mode arg2) arg1)
  1015. ((fr30-1 (unit u-store)))
  1016. )
  1017. )
  1018. (basic-st st st OP1_1 OP2_4 WI Ri Rj)
  1019. (basic-st sth sth OP1_1 OP2_5 HI Ri Rj)
  1020. (basic-st stb stb OP1_1 OP2_6 QI Ri Rj)
  1021. (define-pmacro (r13base-st name insn opc1 opc2 mode arg1 arg2)
  1022. (dni name
  1023. (.str insn " " arg1 ",@(R13," arg2 ")")
  1024. ()
  1025. (.str insn " $" arg1 ",@($R13,$" arg2 ")")
  1026. (+ opc1 opc2 arg1 arg2)
  1027. (set (mem mode (add arg2 (reg h-gr 13))) arg1)
  1028. ((fr30-1 (unit u-store)))
  1029. )
  1030. )
  1031. (r13base-st str13 st OP1_1 OP2_0 WI Ri Rj)
  1032. (r13base-st str13h sth OP1_1 OP2_1 HI Ri Rj)
  1033. (r13base-st str13b stb OP1_1 OP2_2 QI Ri Rj)
  1034. (define-pmacro (r14base-st name insn opc1 mode arg1 arg2)
  1035. (dni name
  1036. (.str insn " " arg1 ",@(R14," arg2 ")")
  1037. ()
  1038. (.str insn " $" arg1 ",@($R14,$" arg2 ")")
  1039. (+ opc1 arg1 arg2)
  1040. (set (mem mode (add arg2 (reg h-gr 14))) arg1)
  1041. ((fr30-1 (unit u-store)))
  1042. )
  1043. )
  1044. (r14base-st str14 st OP1_3 WI Ri disp10)
  1045. (r14base-st str14h sth OP1_5 HI Ri disp9)
  1046. (r14base-st str14b stb OP1_7 QI Ri disp8)
  1047. (dni str15
  1048. "st Ri,@(R15,udisp6) reg/mem"
  1049. ()
  1050. "st $Ri,@($R15,$udisp6)"
  1051. (+ OP1_1 OP2_3 udisp6 Ri)
  1052. (set (mem WI (add (reg h-gr 15) udisp6)) Ri)
  1053. ((fr30-1 (unit u-store)))
  1054. )
  1055. ; These store insns predecrement r15 and then store the contents of the source
  1056. ; register where r15 then points. If the source register is also r15, then the
  1057. ; original value of r15 is stored.
  1058. ;
  1059. (dni str15gr
  1060. "st Ri,@-R15 reg/mem"
  1061. ()
  1062. "st $Ri,@-$R15"
  1063. (+ OP1_1 OP2_7 OP3_0 Ri)
  1064. (sequence ((WI tmp))
  1065. (set tmp Ri) ; save in case it's r15
  1066. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1067. (set (mem WI (reg h-gr 15)) tmp))
  1068. ((fr30-1 (unit u-store)))
  1069. )
  1070. (dni str15dr
  1071. "st Rs,@-R15 reg/mem"
  1072. ()
  1073. "st $Rs2,@-$R15"
  1074. (+ OP1_1 OP2_7 OP3_8 Rs2)
  1075. (sequence ((WI tmp))
  1076. (set tmp Rs2) ; save in case it's r15
  1077. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1078. (set (mem WI (reg h-gr 15)) tmp))
  1079. ((fr30-1 (unit u-store)))
  1080. )
  1081. (dni str15ps
  1082. "st ps,@-R15 reg/mem"
  1083. ()
  1084. "st $ps,@-$R15"
  1085. (+ OP1_1 OP2_7 OP3_9 OP4_0)
  1086. (sequence ()
  1087. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1088. (set (mem WI (reg h-gr 15)) ps))
  1089. ((fr30-1 (unit u-store)))
  1090. )
  1091. (define-pmacro (mov2gr name opc1 opc2 arg1 arg2)
  1092. (dni name
  1093. (.str "mov " arg1 "," arg2)
  1094. ()
  1095. (.str "mov $" arg1 ",$" arg2)
  1096. (+ opc1 opc2 arg1 arg2)
  1097. (set arg2 arg1)
  1098. ()
  1099. )
  1100. )
  1101. (mov2gr mov OP1_8 OP2_B Rj Ri)
  1102. (mov2gr movdr OP1_B OP2_7 Rs1 Ri)
  1103. (dni movps
  1104. "mov ps,Ri reg/reg"
  1105. ()
  1106. "mov $ps,$Ri"
  1107. (+ OP1_1 OP2_7 OP3_1 Ri)
  1108. (set Ri ps)
  1109. ()
  1110. )
  1111. (dni mov2dr
  1112. "mov Ri,Rs reg/reg"
  1113. ()
  1114. "mov $Ri,$Rs1"
  1115. (+ OP1_B OP2_3 Rs1 Ri)
  1116. (set Rs1 Ri)
  1117. ()
  1118. )
  1119. (dni mov2ps
  1120. "mov Ri,ps reg/reg"
  1121. ()
  1122. "mov $Ri,$ps"
  1123. (+ OP1_0 OP2_7 OP3_1 Ri)
  1124. (set ps Ri)
  1125. ()
  1126. )
  1127. (dni jmp
  1128. "jmp with no delay slot"
  1129. (NOT-IN-DELAY-SLOT)
  1130. "jmp @$Ri"
  1131. (+ OP1_9 OP2_7 OP3_0 Ri)
  1132. (set pc Ri)
  1133. ((fr30-1 (unit u-cti)))
  1134. )
  1135. (dni jmpd "jmp with delay slot"
  1136. (NOT-IN-DELAY-SLOT)
  1137. "jmp:d @$Ri"
  1138. (+ OP1_9 OP2_F OP3_0 Ri)
  1139. (delay (const 1)
  1140. (set pc Ri))
  1141. ((fr30-1 (unit u-cti)))
  1142. )
  1143. ; These versions which use registers must appear before the other
  1144. ; versions which use relative addresses due to a problem in cgen
  1145. ; - DB.
  1146. (dni callr
  1147. "call @Ri"
  1148. (NOT-IN-DELAY-SLOT)
  1149. "call @$Ri"
  1150. (+ OP1_9 OP2_7 OP3_1 Ri)
  1151. (sequence ()
  1152. (set (reg h-dr 1) (add pc (const 2)))
  1153. (set pc Ri))
  1154. ((fr30-1 (unit u-cti)))
  1155. )
  1156. (dni callrd
  1157. "call:d @Ri"
  1158. (NOT-IN-DELAY-SLOT)
  1159. "call:d @$Ri"
  1160. (+ OP1_9 OP2_F OP3_1 Ri)
  1161. (delay (const 1)
  1162. (sequence ()
  1163. (set (reg h-dr 1) (add pc (const 4)))
  1164. (set pc Ri)))
  1165. ((fr30-1 (unit u-cti)))
  1166. )
  1167. ; end of reordered insns
  1168. (dni call
  1169. "call relative to pc"
  1170. (NOT-IN-DELAY-SLOT)
  1171. "call $label12"
  1172. (+ OP1_D OP5_0 label12)
  1173. (sequence ()
  1174. (set (reg h-dr 1) (add pc (const 2)))
  1175. (set pc label12))
  1176. ((fr30-1 (unit u-cti)))
  1177. )
  1178. (dni calld
  1179. "call relative to pc"
  1180. (NOT-IN-DELAY-SLOT)
  1181. "call:d $label12"
  1182. (+ OP1_D OP5_1 label12)
  1183. (delay (const 1)
  1184. (sequence ()
  1185. (set (reg h-dr 1) (add pc (const 4)))
  1186. (set pc label12)))
  1187. ((fr30-1 (unit u-cti)))
  1188. )
  1189. (dni ret
  1190. "return from subroutine"
  1191. (NOT-IN-DELAY-SLOT)
  1192. "ret"
  1193. (+ OP1_9 OP2_7 OP3_2 OP4_0)
  1194. (set pc (reg h-dr 1))
  1195. ((fr30-1 (unit u-cti)))
  1196. )
  1197. (dni ret:d
  1198. "return from subroutine with delay slot"
  1199. (NOT-IN-DELAY-SLOT)
  1200. "ret:d"
  1201. (+ OP1_9 OP2_F OP3_2 OP4_0)
  1202. (delay (const 1)
  1203. (set pc (reg h-dr 1)))
  1204. ((fr30-1 (unit u-cti)))
  1205. )
  1206. (dni int
  1207. "interrupt"
  1208. (NOT-IN-DELAY-SLOT)
  1209. "int $u8"
  1210. (+ OP1_1 OP2_F u8)
  1211. (sequence ()
  1212. ; This is defered to fr30_int because for the breakpoint case
  1213. ; we want to change as little of the machine state as possible.
  1214. ; Push PS onto the system stack
  1215. ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
  1216. ;(set UWI (mem UWI (reg h-dr 2)) ps)
  1217. ; Push the return address onto the system stack
  1218. ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
  1219. ;(set UWI (mem UWI (reg h-dr 2)) (add pc (const 2)))
  1220. ; Set status bits
  1221. ;(set ibit (const 0))
  1222. ;(set sbit (const 0))
  1223. ; We still should indicate what is modified by this insn.
  1224. (clobber (reg h-dr 2))
  1225. (clobber ibit)
  1226. (clobber sbit)
  1227. ; ??? (clobber memory)?
  1228. ; fr30_int handles operating vs user mode
  1229. (set WI pc (c-call WI "fr30_int" pc u8))
  1230. )
  1231. ; This is more properly a cti, but branch stall calculation is different.
  1232. ((fr30-1 (unit u-exec (cycles 6))))
  1233. )
  1234. (dni inte
  1235. "interrupt for emulator"
  1236. (NOT-IN-DELAY-SLOT)
  1237. "inte"
  1238. (+ OP1_9 OP2_F OP3_3 OP4_0)
  1239. (sequence ()
  1240. ; This is defered to fr30_inte because for the breakpoint case
  1241. ; we want to change as little of the machine state as possible.
  1242. ; Push PS onto the system stack
  1243. ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
  1244. ;(set UWI (mem UWI (reg h-dr 2)) ps)
  1245. ; Push the return address onto the system stack
  1246. ;(set (reg h-dr 2) (sub (reg h-dr 2) (const 4)))
  1247. ;(set UWI (mem UWI (reg h-dr 2)) (add pc (const 2)))
  1248. ; Set status bits
  1249. ;(set ibit (const 0))
  1250. ;(set ilm (const 4))
  1251. ; We still should indicate what is modified by this insn.
  1252. (clobber (reg h-dr 2))
  1253. (clobber ibit)
  1254. (clobber ilm)
  1255. ; ??? (clobber memory)?
  1256. ; fr30_int handles operating vs user mode
  1257. (set WI pc (c-call WI "fr30_inte" pc))
  1258. )
  1259. ; This is more properly a cti, but branch stall calculation is different.
  1260. ((fr30-1 (unit u-exec (cycles 6))))
  1261. )
  1262. (dni reti
  1263. "return from interrupt"
  1264. (NOT-IN-DELAY-SLOT)
  1265. "reti"
  1266. (+ OP1_9 OP2_7 OP3_3 OP4_0)
  1267. (if (eq sbit (const 0))
  1268. (sequence ()
  1269. ; Pop the return address from the system stack
  1270. (set UWI pc (mem UWI (reg h-dr 2)))
  1271. (set (reg h-dr 2) (add (reg h-dr 2) (const 4)))
  1272. ; Pop PS from the system stack
  1273. (set UWI ps (mem UWI (reg h-dr 2)))
  1274. (set (reg h-dr 2) (add (reg h-dr 2) (const 4)))
  1275. )
  1276. (sequence ()
  1277. ; Pop the return address from the user stack
  1278. (set UWI pc (mem UWI (reg h-dr 3)))
  1279. (set (reg h-dr 3) (add (reg h-dr 3) (const 4)))
  1280. ; Pop PS from the user stack
  1281. (set UWI ps (mem UWI (reg h-dr 3)))
  1282. (set (reg h-dr 3) (add (reg h-dr 3) (const 4)))
  1283. )
  1284. )
  1285. ; This is more properly a cti, but branch stall calculation is different.
  1286. ((fr30-1 (unit u-exec (cycles 4))))
  1287. )
  1288. ; Conditional branches with and without delay slots
  1289. ;
  1290. (define-pmacro (cond-branch cc condition)
  1291. (begin
  1292. (dni (.sym b cc d)
  1293. (.str (.sym b cc :d) " label9")
  1294. (NOT-IN-DELAY-SLOT)
  1295. (.str (.sym b cc :d) " $label9")
  1296. (+ OP1_F (.sym CC_ cc) label9)
  1297. (delay (const 1)
  1298. (if condition (set pc label9)))
  1299. ((fr30-1 (unit u-cti)))
  1300. )
  1301. (dni (.sym b cc)
  1302. (.str (.sym b cc) " label9")
  1303. (NOT-IN-DELAY-SLOT)
  1304. (.str (.sym b cc) " $label9")
  1305. (+ OP1_E (.sym CC_ cc) label9)
  1306. (if condition (set pc label9))
  1307. ((fr30-1 (unit u-cti)))
  1308. )
  1309. )
  1310. )
  1311. (cond-branch ra (const BI 1))
  1312. (cond-branch no (const BI 0))
  1313. (cond-branch eq zbit)
  1314. (cond-branch ne (not zbit))
  1315. (cond-branch c cbit)
  1316. (cond-branch nc (not cbit))
  1317. (cond-branch n nbit)
  1318. (cond-branch p (not nbit))
  1319. (cond-branch v vbit)
  1320. (cond-branch nv (not vbit))
  1321. (cond-branch lt (xor vbit nbit))
  1322. (cond-branch ge (not (xor vbit nbit)))
  1323. (cond-branch le (or (xor vbit nbit) zbit))
  1324. (cond-branch gt (not (or (xor vbit nbit) zbit)))
  1325. (cond-branch ls (or cbit zbit))
  1326. (cond-branch hi (not (or cbit zbit)))
  1327. (define-pmacro (dir2r13 name insn opc1 opc2 mode arg1)
  1328. (dni name
  1329. (.str insn " @" arg1 ",R13")
  1330. ()
  1331. (.str insn " @$" arg1 ",$R13")
  1332. (+ opc1 opc2 arg1)
  1333. (set (reg h-gr 13) (mem mode arg1))
  1334. ((fr30-1 (unit u-load)))
  1335. )
  1336. )
  1337. (define-pmacro (dir2r13-postinc name insn opc1 opc2 mode arg1 incr)
  1338. (dni name
  1339. (.str insn " @" arg1 ",@R13+")
  1340. (NOT-IN-DELAY-SLOT)
  1341. (.str insn " @$" arg1 ",@$R13+")
  1342. (+ opc1 opc2 arg1)
  1343. (sequence ()
  1344. (set (mem mode (reg h-gr 13)) (mem mode arg1))
  1345. (set (reg h-gr 13) (add (reg h-gr 13) incr)))
  1346. ((fr30-1 (unit u-load) (unit u-store)))
  1347. )
  1348. )
  1349. (define-pmacro (r132dir name insn opc1 opc2 mode arg1)
  1350. (dni name
  1351. (.str insn " R13,@" arg1)
  1352. ()
  1353. (.str insn " $R13,@$" arg1)
  1354. (+ opc1 opc2 arg1)
  1355. (set (mem mode arg1) (reg h-gr 13))
  1356. ((fr30-1 (unit u-store)))
  1357. )
  1358. )
  1359. (define-pmacro (r13-postinc2dir name insn opc1 opc2 mode arg1 incr)
  1360. (dni name
  1361. (.str insn " @R13+,@" arg1)
  1362. (NOT-IN-DELAY-SLOT)
  1363. (.str insn " @$R13+,@$" arg1)
  1364. (+ opc1 opc2 arg1)
  1365. (sequence ()
  1366. (set (mem mode arg1) (mem mode (reg h-gr 13)))
  1367. (set (reg h-gr 13) (add (reg h-gr 13) incr)))
  1368. ((fr30-1 (unit u-load) (unit u-store)))
  1369. )
  1370. )
  1371. ; These versions which move from reg to mem must appear before the other
  1372. ; versions which use immediate addresses due to a problem in cgen
  1373. ; - DB.
  1374. (r132dir dmovr13 dmov OP1_1 OP2_8 WI dir10)
  1375. (r132dir dmovr13h dmovh OP1_1 OP2_9 HI dir9)
  1376. (r132dir dmovr13b dmovb OP1_1 OP2_A QI dir8)
  1377. (r13-postinc2dir dmovr13pi dmov OP1_1 OP2_C WI dir10 (const 4))
  1378. (r13-postinc2dir dmovr13pih dmovh OP1_1 OP2_D HI dir9 (const 2))
  1379. (r13-postinc2dir dmovr13pib dmovb OP1_1 OP2_E QI dir8 (const 1))
  1380. (dni dmovr15pi
  1381. "dmov @R15+,@dir10"
  1382. (NOT-IN-DELAY-SLOT)
  1383. "dmov @$R15+,@$dir10"
  1384. (+ OP1_1 OP2_B dir10)
  1385. (sequence ()
  1386. (set (mem WI dir10) (mem WI (reg h-gr 15)))
  1387. (set (reg h-gr 15) (add (reg h-gr 15) (const 4))))
  1388. ((fr30-1 (unit u-load) (unit u-store)))
  1389. )
  1390. ; End of reordered insns.
  1391. (dir2r13 dmov2r13 dmov OP1_0 OP2_8 WI dir10)
  1392. (dir2r13 dmov2r13h dmovh OP1_0 OP2_9 HI dir9)
  1393. (dir2r13 dmov2r13b dmovb OP1_0 OP2_A QI dir8)
  1394. (dir2r13-postinc dmov2r13pi dmov OP1_0 OP2_C WI dir10 (const 4))
  1395. (dir2r13-postinc dmov2r13pih dmovh OP1_0 OP2_D HI dir9 (const 2))
  1396. (dir2r13-postinc dmov2r13pib dmovb OP1_0 OP2_E QI dir8 (const 1))
  1397. (dni dmov2r15pd
  1398. "dmov @dir10,@-R15"
  1399. (NOT-IN-DELAY-SLOT)
  1400. "dmov @$dir10,@-$R15"
  1401. (+ OP1_0 OP2_B dir10)
  1402. (sequence ()
  1403. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1404. (set (mem WI (reg h-gr 15)) (mem WI dir10)))
  1405. ((fr30-1 (unit u-load) (unit u-store)))
  1406. )
  1407. ; Leave these insns as stubs for now, except for the increment of $Ri
  1408. ;
  1409. (dni ldres
  1410. "ldres @Ri+,#u4"
  1411. ()
  1412. "ldres @$Ri+,$u4"
  1413. (+ OP1_B OP2_C u4 Ri)
  1414. (set Ri (add Ri (const 4)))
  1415. ()
  1416. )
  1417. (dni stres
  1418. "stres #u4,@Ri+"
  1419. ()
  1420. "stres $u4,@$Ri+"
  1421. (+ OP1_B OP2_D u4 Ri)
  1422. (set Ri (add Ri (const 4)))
  1423. ()
  1424. )
  1425. ; Leave the coprocessor insns as stubs for now.
  1426. ;
  1427. (define-pmacro (cop-stub name insn opc1 opc2 opc3 arg1 arg2)
  1428. (dni name
  1429. (.str insn " u4c,ccc,CRj," arg1 "," arg2)
  1430. (NOT-IN-DELAY-SLOT)
  1431. (.str insn " $u4c,$ccc,$" arg1 ",$" arg2)
  1432. (+ opc1 opc2 opc3 u4c ccc arg1 arg2)
  1433. (nop) ; STUB
  1434. ()
  1435. )
  1436. )
  1437. (cop-stub copop copop OP1_9 OP2_F OP3_C CRj CRi)
  1438. (cop-stub copld copld OP1_9 OP2_F OP3_D Rjc CRi)
  1439. (cop-stub copst copst OP1_9 OP2_F OP3_E CRj Ric)
  1440. (cop-stub copsv copsv OP1_9 OP2_F OP3_F CRj Ric)
  1441. (dni nop
  1442. "nop"
  1443. ()
  1444. "nop"
  1445. (+ OP1_9 OP2_F OP3_A OP4_0)
  1446. (nop)
  1447. ()
  1448. )
  1449. (dni andccr
  1450. "andccr #u8"
  1451. ()
  1452. "andccr $u8"
  1453. (+ OP1_8 OP2_3 u8)
  1454. (set ccr (and ccr u8))
  1455. ()
  1456. )
  1457. (dni orccr
  1458. "orccr #u8"
  1459. ()
  1460. "orccr $u8"
  1461. (+ OP1_9 OP2_3 u8)
  1462. (set ccr (or ccr u8))
  1463. ()
  1464. )
  1465. (dni stilm
  1466. "stilm #u8"
  1467. ()
  1468. "stilm $u8"
  1469. (+ OP1_8 OP2_7 u8)
  1470. (set ilm (and u8 (const #x1f)))
  1471. ()
  1472. )
  1473. (dni addsp
  1474. "addsp #s10"
  1475. ()
  1476. "addsp $s10"
  1477. (+ OP1_A OP2_3 s10)
  1478. (set (reg h-gr 15) (add (reg h-gr 15) s10))
  1479. ()
  1480. )
  1481. (define-pmacro (ext-op name opc1 opc2 opc3 op mode mask)
  1482. (dni name
  1483. (.str name " Ri")
  1484. ()
  1485. (.str name " $Ri")
  1486. (+ opc1 opc2 opc3 Ri)
  1487. (set Ri (op WI (and mode Ri mask)))
  1488. ()
  1489. )
  1490. )
  1491. (ext-op extsb OP1_9 OP2_7 OP3_8 ext QI (const #xff))
  1492. (ext-op extub OP1_9 OP2_7 OP3_9 zext UQI (const #xff))
  1493. (ext-op extsh OP1_9 OP2_7 OP3_A ext HI (const #xffff))
  1494. (ext-op extuh OP1_9 OP2_7 OP3_B zext UHI (const #xffff))
  1495. (dni ldm0
  1496. "ldm0 (reglist_low_ld)"
  1497. (NOT-IN-DELAY-SLOT)
  1498. "ldm0 ($reglist_low_ld)"
  1499. (+ OP1_8 OP2_C reglist_low_ld)
  1500. (sequence ()
  1501. (if (and reglist_low_ld (const #x1))
  1502. (sequence ()
  1503. (set (reg h-gr 0) (mem WI (reg h-gr 15)))
  1504. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1505. (if (and reglist_low_ld (const #x2))
  1506. (sequence ()
  1507. (set (reg h-gr 1) (mem WI (reg h-gr 15)))
  1508. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1509. (if (and reglist_low_ld (const #x4))
  1510. (sequence ()
  1511. (set (reg h-gr 2) (mem WI (reg h-gr 15)))
  1512. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1513. (if (and reglist_low_ld (const #x8))
  1514. (sequence ()
  1515. (set (reg h-gr 3) (mem WI (reg h-gr 15)))
  1516. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1517. (if (and reglist_low_ld (const #x10))
  1518. (sequence ()
  1519. (set (reg h-gr 4) (mem WI (reg h-gr 15)))
  1520. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1521. (if (and reglist_low_ld (const #x20))
  1522. (sequence ()
  1523. (set (reg h-gr 5) (mem WI (reg h-gr 15)))
  1524. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1525. (if (and reglist_low_ld (const #x40))
  1526. (sequence ()
  1527. (set (reg h-gr 6) (mem WI (reg h-gr 15)))
  1528. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1529. (if (and reglist_low_ld (const #x80))
  1530. (sequence ()
  1531. (set (reg h-gr 7) (mem WI (reg h-gr 15)))
  1532. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1533. )
  1534. ((fr30-1 (unit u-ldm)))
  1535. )
  1536. (dni ldm1
  1537. "ldm1 (reglist_hi_ld)"
  1538. (NOT-IN-DELAY-SLOT)
  1539. "ldm1 ($reglist_hi_ld)"
  1540. (+ OP1_8 OP2_D reglist_hi_ld)
  1541. (sequence ()
  1542. (if (and reglist_hi_ld (const #x1))
  1543. (sequence ()
  1544. (set (reg h-gr 8) (mem WI (reg h-gr 15)))
  1545. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1546. (if (and reglist_hi_ld (const #x2))
  1547. (sequence ()
  1548. (set (reg h-gr 9) (mem WI (reg h-gr 15)))
  1549. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1550. (if (and reglist_hi_ld (const #x4))
  1551. (sequence ()
  1552. (set (reg h-gr 10) (mem WI (reg h-gr 15)))
  1553. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1554. (if (and reglist_hi_ld (const #x8))
  1555. (sequence ()
  1556. (set (reg h-gr 11) (mem WI (reg h-gr 15)))
  1557. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1558. (if (and reglist_hi_ld (const #x10))
  1559. (sequence ()
  1560. (set (reg h-gr 12) (mem WI (reg h-gr 15)))
  1561. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1562. (if (and reglist_hi_ld (const #x20))
  1563. (sequence ()
  1564. (set (reg h-gr 13) (mem WI (reg h-gr 15)))
  1565. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1566. (if (and reglist_hi_ld (const #x40))
  1567. (sequence ()
  1568. (set (reg h-gr 14) (mem WI (reg h-gr 15)))
  1569. (set (reg h-gr 15) (add (reg h-gr 15) (const 4)))))
  1570. (if (and reglist_hi_ld (const #x80))
  1571. (set (reg h-gr 15) (mem WI (reg h-gr 15))))
  1572. )
  1573. ((fr30-1 (unit u-ldm)))
  1574. )
  1575. (dni stm0
  1576. "stm0 (reglist_low_st)"
  1577. (NOT-IN-DELAY-SLOT)
  1578. "stm0 ($reglist_low_st)"
  1579. (+ OP1_8 OP2_E reglist_low_st)
  1580. (sequence ()
  1581. (if (and reglist_low_st (const #x1))
  1582. (sequence ()
  1583. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1584. (set (mem WI (reg h-gr 15)) (reg h-gr 7))))
  1585. (if (and reglist_low_st (const #x2))
  1586. (sequence ()
  1587. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1588. (set (mem WI (reg h-gr 15)) (reg h-gr 6))))
  1589. (if (and reglist_low_st (const #x4))
  1590. (sequence ()
  1591. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1592. (set (mem WI (reg h-gr 15)) (reg h-gr 5))))
  1593. (if (and reglist_low_st (const #x8))
  1594. (sequence ()
  1595. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1596. (set (mem WI (reg h-gr 15)) (reg h-gr 4))))
  1597. (if (and reglist_low_st (const #x10))
  1598. (sequence ()
  1599. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1600. (set (mem WI (reg h-gr 15)) (reg h-gr 3))))
  1601. (if (and reglist_low_st (const #x20))
  1602. (sequence ()
  1603. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1604. (set (mem WI (reg h-gr 15)) (reg h-gr 2))))
  1605. (if (and reglist_low_st (const #x40))
  1606. (sequence ()
  1607. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1608. (set (mem WI (reg h-gr 15)) (reg h-gr 1))))
  1609. (if (and reglist_low_st (const #x80))
  1610. (sequence ()
  1611. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1612. (set (mem WI (reg h-gr 15)) (reg h-gr 0))))
  1613. )
  1614. ((fr30-1 (unit u-stm)))
  1615. )
  1616. (dni stm1
  1617. "stm1 (reglist_hi_st)"
  1618. (NOT-IN-DELAY-SLOT)
  1619. "stm1 ($reglist_hi_st)"
  1620. (+ OP1_8 OP2_F reglist_hi_st)
  1621. (sequence ()
  1622. (if (and reglist_hi_st (const #x1))
  1623. (sequence ((WI save-r15))
  1624. (set save-r15 (reg h-gr 15))
  1625. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1626. (set (mem WI (reg h-gr 15)) save-r15)))
  1627. (if (and reglist_hi_st (const #x2))
  1628. (sequence ()
  1629. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1630. (set (mem WI (reg h-gr 15)) (reg h-gr 14))))
  1631. (if (and reglist_hi_st (const #x4))
  1632. (sequence ()
  1633. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1634. (set (mem WI (reg h-gr 15)) (reg h-gr 13))))
  1635. (if (and reglist_hi_st (const #x8))
  1636. (sequence ()
  1637. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1638. (set (mem WI (reg h-gr 15)) (reg h-gr 12))))
  1639. (if (and reglist_hi_st (const #x10))
  1640. (sequence ()
  1641. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1642. (set (mem WI (reg h-gr 15)) (reg h-gr 11))))
  1643. (if (and reglist_hi_st (const #x20))
  1644. (sequence ()
  1645. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1646. (set (mem WI (reg h-gr 15)) (reg h-gr 10))))
  1647. (if (and reglist_hi_st (const #x40))
  1648. (sequence ()
  1649. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1650. (set (mem WI (reg h-gr 15)) (reg h-gr 9))))
  1651. (if (and reglist_hi_st (const #x80))
  1652. (sequence ()
  1653. (set (reg h-gr 15) (sub (reg h-gr 15) (const 4)))
  1654. (set (mem WI (reg h-gr 15)) (reg h-gr 8))))
  1655. )
  1656. ((fr30-1 (unit u-stm)))
  1657. )
  1658. (dni enter
  1659. "enter #u10"
  1660. (NOT-IN-DELAY-SLOT)
  1661. "enter $u10"
  1662. (+ OP1_0 OP2_F u10)
  1663. (sequence ((WI tmp))
  1664. (set tmp (sub (reg h-gr 15) (const 4)))
  1665. (set (mem WI tmp) (reg h-gr 14))
  1666. (set (reg h-gr 14) tmp)
  1667. (set (reg h-gr 15) (sub (reg h-gr 15) u10)))
  1668. ((fr30-1 (unit u-exec (cycles 2))))
  1669. )
  1670. (dni leave
  1671. "leave"
  1672. ()
  1673. "leave"
  1674. (+ OP1_9 OP2_F OP3_9 OP4_0)
  1675. (sequence ()
  1676. (set (reg h-gr 15) (add (reg h-gr 14) (const 4)))
  1677. (set (reg h-gr 14) (mem WI (sub (reg h-gr 15) (const 4)))))
  1678. ()
  1679. )
  1680. (dni xchb
  1681. "xchb @Rj,Ri"
  1682. (NOT-IN-DELAY-SLOT)
  1683. "xchb @$Rj,$Ri"
  1684. (+ OP1_8 OP2_A Rj Ri)
  1685. (sequence ((WI tmp))
  1686. (set tmp Ri)
  1687. (set Ri (mem UQI Rj))
  1688. (set (mem UQI Rj) tmp))
  1689. ((fr30-1 (unit u-load) (unit u-store)))
  1690. )