1 ; IQ2000-only CPU description. -*- Scheme -*-
3 ; Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
5 ; Contributed by Red Hat Inc; developed under contract from Vitesse.
7 ; This file is part of the GNU Binutils.
9 ; This program is free software; you can redistribute it and/or modify
10 ; it under the terms of the GNU General Public License as published by
11 ; the Free Software Foundation; either version 2 of the License, or
12 ; (at your option) any later version.
14 ; This program is distributed in the hope that it will be useful,
15 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ; GNU General Public License for more details.
19 ; You should have received a copy of the GNU General Public License
20 ; along with this program; if not, write to the Free Software
21 ; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 (dni andoui "and upper ones immediate" (MACH2000 USES-RS USES-RT)
24 "andoui $rt,$rs,$hi16"
25 (+ OP_ANDOUI rs rt hi16)
26 (set rt (and rs (or (sll hi16 16) #xFFFF)))
29 (dni andoui2 "and upper ones immediate" (ALIAS NO-DIS MACH2000 USES-RS USES-RT)
30 "andoui ${rt-rs},$hi16"
31 (+ OP_ANDOUI rt-rs hi16)
32 (set rt-rs (and rt-rs (or (sll hi16 16) #xFFFF)))
35 (dni orui2 "or upper immediate" (ALIAS NO-DIS MACH2000 USES-RS USES-RT)
37 (+ OP_ORUI rt-rs hi16)
38 (set rt-rs (or rt-rs (sll hi16 16)))
41 (dni orui "or upper immediate" (MACH2000 USES-RS USES-RT)
43 (+ OP_ORUI rs rt hi16)
44 (set rt (or rs (sll hi16 16)))
47 (dni bgtz "branch if greater than zero" (MACH2000 USES-RS)
49 (+ OP_BGTZ rs (f-rt 0) offset)
51 (delay 1 (set pc offset)))
55 (dni bgtzl "branch if greater than zero likely" (MACH2000 USES-RS)
57 (+ OP_BGTZL rs (f-rt 0) offset)
59 (delay 1 (set pc offset))
63 (dni blez "branch if less than or equal to zero" (MACH2000 USES-RS)
65 (+ OP_BLEZ rs (f-rt 0) offset)
67 (delay 1 (set pc offset)))
70 (dni blezl "branch if less than or equal to zero likely" (MACH2000 USES-RS)
72 (+ OP_BLEZL rs (f-rt 0) offset)
74 (delay 1 (set pc offset))
79 (dni mrgb "merge bytes" (MACH2000 USES-RD USES-RS USES-RT)
80 "mrgb $rd,$rs,$rt,$mask"
81 (+ OP_SPECIAL rs rt rd (f-10 0) mask FUNC_MRGB)
83 (if (bitclear? mask 0)
84 (set temp (and rs #xFF))
85 (set temp (and rt #xFF)))
86 (if (bitclear? mask 1)
87 (set temp (or temp (and rs #xFF00)))
88 (set temp (or temp (and rt #xFF00))))
89 (if (bitclear? mask 2)
90 (set temp (or temp (and rs #xFF0000)))
91 (set temp (or temp (and rt #xFF0000))))
92 (if (bitclear? mask 3)
93 (set temp (or temp (and rs #xFF000000)))
94 (set temp (or temp (and rt #xFF000000))))
98 (dni mrgb2 "merge bytes" (ALIAS NO-DIS MACH2000 USES-RD USES-RS USES-RT)
99 "mrgb ${rd-rs},$rt,$mask"
100 (+ OP_SPECIAL rt rd-rs (f-10 0) mask FUNC_MRGB)
101 (sequence ((SI temp))
102 (if (bitclear? mask 0)
103 (set temp (and rd-rs #xFF))
104 (set temp (and rt #xFF)))
105 (if (bitclear? mask 1)
106 (set temp (or temp (and rd-rs #xFF00)))
107 (set temp (or temp (and rt #xFF00))))
108 (if (bitclear? mask 2)
109 (set temp (or temp (and rd-rs #xFF0000)))
110 (set temp (or temp (and rt #xFF0000))))
111 (if (bitclear? mask 3)
112 (set temp (or temp (and rd-rs #xFF000000)))
113 (set temp (or temp (and rt #xFF000000))))
117 ; NOTE: None of these instructions' semantics are specified, so they
118 ; will not work in a simulator.
120 ; Architectural and coprocessor instructions.
121 ; BREAK and SYSCALL are implemented with escape hatches to the C
122 ; code. These are used by the test suite to indicate pass/failures.
124 (dni bctxt "branch and switch context" (MACH2000 DELAY-SLOT COND-CTI USES-RS)
126 (+ OP_REGIMM rs (f-rt 6) offset)
130 (dni bc0f "branch if copro 0 condition false" (MACH2000 DELAY-SLOT COND-CTI)
132 (+ OP_COP0 (f-rs 8) (f-rt 0) offset)
136 (dni bc0fl "branch if copro 0 condition false likely" (MACH2000 DELAY-SLOT COND-CTI SKIP-CTI)
138 (+ OP_COP0 (f-rs 8) (f-rt 2) offset)
142 (dni bc3f "branch if copro 3 condition false" (MACH2000 DELAY-SLOT COND-CTI)
144 (+ OP_COP3 (f-rs 8) (f-rt 0) offset)
148 (dni bc3fl "branch if copro 3 condition false likely" (MACH2000 DELAY-SLOT COND-CTI SKIP-CTI)
150 (+ OP_COP3 (f-rs 8) (f-rt 2) offset)
154 (dni bc0t "branch if copro 0 condition true" (MACH2000 DELAY-SLOT COND-CTI)
156 (+ OP_COP0 (f-rs 8) (f-rt 1) offset)
160 (dni bc0tl "branch if copro 0 condition true likely" (MACH2000 DELAY-SLOT COND-CTI SKIP-CTI)
162 (+ OP_COP0 (f-rs 8) (f-rt 3) offset)
166 (dni bc3t "branch if copro 3 condition true" (MACH2000 DELAY-SLOT COND-CTI)
168 (+ OP_COP3 (f-rs 8) (f-rt 1) offset)
172 (dni bc3tl "branch if copro 3 condition true likely" (MACH2000 DELAY-SLOT COND-CTI SKIP-CTI)
174 (+ OP_COP3 (f-rs 8) (f-rt 3) offset)
178 ; Note that we don't set the USES-RD or USES-RT attributes for many of the following
179 ; instructions, as it's the COP register that's being specified.
181 (dni cfc0 "control from coprocessor 0" (MACH2000 LOAD-DELAY USES-RT)
183 (+ OP_COP0 (f-rs 2) rt rd (f-10-11 0))
187 (dni cfc1 "control from coprocessor 1" (MACH2000 LOAD-DELAY USES-RT)
189 (+ OP_COP1 (f-rs 2) rt rd (f-10-11 0))
193 (dni cfc2 "control from coprocessor 2" (MACH2000 LOAD-DELAY USES-RT YIELD-INSN)
195 (+ OP_COP2 (f-rs 2) rt rd (f-10-11 0))
199 (dni cfc3 "control from coprocessor 3" (MACH2000 LOAD-DELAY USES-RT YIELD-INSN)
201 (+ OP_COP3 (f-rs 2) rt rd (f-10-11 0))
205 ; COPz instructions are an instruction form, not real instructions
206 ; with associated assembly mnemonics. Therefore, they are omitted
207 ; from the ISA description.
209 (dni chkhdr "check header" (MACH2000 LOAD-DELAY USES-RD YIELD-INSN)
211 (+ OP_COP3 (f-rs 9) rt rd (f-shamt 0) (f-func 0))
215 (dni ctc0 "control to coprocessor 0" (MACH2000 USES-RT)
217 (+ OP_COP0 (f-rs 6) rt rd (f-10-11 0))
221 (dni ctc1 "control to coprocessor 1" (MACH2000 USES-RT)
223 (+ OP_COP1 (f-rs 6) rt rd (f-10-11 0))
227 (dni ctc2 "control to coprocessor 2" (MACH2000 USES-RT)
229 (+ OP_COP2 (f-rs 6) rt rd (f-10-11 0))
233 (dni ctc3 "control to coprocessor 3" (MACH2000 USES-RT)
235 (+ OP_COP3 (f-rs 6) rt rd (f-10-11 0))
239 (dni jcr "jump context register" (MACH2000 DELAY-SLOT UNCOND-CTI USES-RS)
241 (+ OP_SPECIAL rs (f-rt 0) (f-rd 0) (f-shamt 0) FUNC_JCR)
245 (dni luc32 "lookup chain 32 bits" (MACH2000 USES-RD USES-RT YIELD-INSN)
247 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 3))
251 (dni luc32l "lookup chain 32 bits and lock" (MACH2000 USES-RD USES-RT YIELD-INSN)
253 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 7))
257 (dni luc64 "lookup chain 64 bits" (MACH2000 USES-RD USES-RT YIELD-INSN)
259 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 11))
263 (dni luc64l "lookup chain 64 bits and lock" (MACH2000 USES-RD USES-RT YIELD-INSN)
265 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 15))
269 (dni luk "lookup key" (MACH2000 USES-RD USES-RT)
271 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 8))
275 (dni lulck "lookup lock" (MACH2000 USES-RT YIELD-INSN)
277 (+ OP_COP2 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 4))
281 (dni lum32 "lookup match 32 bits" (MACH2000 USES-RD USES-RT YIELD-INSN)
283 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 2))
287 (dni lum32l "lookup match 32 bits and lock" (MACH2000 USES-RD USES-RT YIELD-INSN)
289 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 6))
293 (dni lum64 "lookup match 64 bits" (MACH2000 USES-RD USES-RT YIELD-INSN)
295 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 10))
299 (dni lum64l "lookup match 64 bits and lock" (MACH2000 USES-RD USES-RT YIELD-INSN)
301 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 14))
305 (dni lur "lookup read" (MACH2000 USES-RD USES-RT YIELD-INSN)
307 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 1))
311 (dni lurl "lookup read and lock" (MACH2000 USES-RD USES-RT YIELD-INSN)
313 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 5))
317 (dni luulck "lookup unlock" (MACH2000 USES-RT YIELD-INSN)
319 (+ OP_COP2 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 0))
323 (dni mfc0 "move from coprocessor 0" (MACH2000 LOAD-DELAY USES-RT)
325 (+ OP_COP0 (f-rs 0) rt rd (f-10-11 0))
329 (dni mfc1 "move from coprocessor 1" (MACH2000 LOAD-DELAY USES-RT)
331 (+ OP_COP1 (f-rs 0) rt rd (f-10-11 0))
335 (dni mfc2 "move from coprocessor 2" (MACH2000 LOAD-DELAY USES-RT YIELD-INSN)
337 (+ OP_COP2 (f-rs 0) rt rd (f-10-11 0))
341 (dni mfc3 "move from coprocessor 3" (MACH2000 LOAD-DELAY USES-RT YIELD-INSN)
343 (+ OP_COP3 (f-rs 0) rt rd (f-10-11 0))
347 (dni mtc0 "move to coprocessor 0" (MACH2000 USES-RT)
349 (+ OP_COP0 (f-rs 4) rt rd (f-10-11 0))
353 (dni mtc1 "move to coprocessor 1" (MACH2000 USES-RT)
355 (+ OP_COP1 (f-rs 4) rt rd (f-10-11 0))
359 (dni mtc2 "move to coprocessor 2" (MACH2000 USES-RT)
361 (+ OP_COP2 (f-rs 4) rt rd (f-10-11 0))
365 (dni mtc3 "move to coprocessor 3" (MACH2000 USES-RT)
367 (+ OP_COP3 (f-rs 4) rt rd (f-10-11 0))
371 (dni pkrl "pkrl" (MACH2000 USES-RD USES-RT YIELD-INSN)
373 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 7))
377 (dni pkrlr1 "pkrlr1" (MACH2000 USES-RT YIELD-INSN)
379 (+ OP_COP3 (f-rs 29) rt count)
383 (dni pkrlr30 "pkrlr30" (MACH2000 USES-RT YIELD-INSN)
385 (+ OP_COP3 (f-rs 31) rt count)
389 (dni rb "dma read bytes" (MACH2000 USES-RD USES-RT YIELD-INSN)
391 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 4))
395 (dni rbr1 "dma read bytes using r1" (MACH2000 USES-RT YIELD-INSN)
397 (+ OP_COP3 (f-rs 24) rt count)
401 (dni rbr30 "dma read bytes using r30" (MACH2000 USES-RT YIELD-INSN)
403 (+ OP_COP3 (f-rs 26) rt count)
407 (dni rfe "restore from exception" (MACH2000)
409 (+ OP_COP0 (f-25 1) (f-24-19 0) (f-func 16))
413 (dni rx "dma read word64s" (MACH2000 USES-RD USES-RT YIELD-INSN)
415 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 6))
419 (dni rxr1 "dma read word64s using r1" (MACH2000 USES-RT YIELD-INSN)
421 (+ OP_COP3 (f-rs 28) rt count)
425 (dni rxr30 "dma read word 64s using r30" (MACH2000 USES-RT YIELD-INSN)
427 (+ OP_COP3 (f-rs 30) rt count)
431 (dni sleep "sleep" (MACH2000 YIELD-INSN)
433 (+ OP_SPECIAL execode FUNC_SLEEP)
437 (dni srrd "sram read" (MACH2000 USES-RT YIELD-INSN)
439 (+ OP_COP2 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 16))
443 (dni srrdl "sram read and lock" (MACH2000 USES-RT YIELD-INSN)
445 (+ OP_COP2 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 20))
449 (dni srulck "sram unlock" (MACH2000 USES-RT YIELD-INSN)
451 (+ OP_COP2 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 22))
455 (dni srwr "sram write" (MACH2000 USES-RD USES-RT YIELD-INSN)
457 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 17))
461 (dni srwru "sram write and unlock" (MACH2000 USES-RD USES-RT YIELD-INSN)
463 (+ OP_COP2 (f-rs 1) rt rd (f-shamt 0) (f-func 21))
467 (dni trapqfl "yield if dma queue full" (MACH2000 YIELD-INSN)
469 (+ OP_COP3 (f-rs 1) (f-rt 0) (f-rd 0) (f-shamt 0) (f-func 8))
473 (dni trapqne "yield if dma queue not empty" (MACH2000 YIELD-INSN)
475 (+ OP_COP3 (f-rs 1) (f-rt 0) (f-rd 0) (f-shamt 0) (f-func 9))
479 (dni traprel "traprel" (MACH2000 USES-RT YIELD-INSN)
481 (+ OP_COP3 (f-rs 1) rt (f-rd 0) (f-shamt 0) (f-func 10))
485 (dni wb "dma write bytes" (MACH2000 USES-RD USES-RT YIELD-INSN)
487 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 0))
491 (dni wbu "dma write bytes and unlock" (MACH2000 USES-RD USES-RT YIELD-INSN)
493 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 1))
497 (dni wbr1 "dma write bytes using r1" (MACH2000 USES-RT YIELD-INSN)
499 (+ OP_COP3 (f-rs 16) rt count)
503 (dni wbr1u "dma write bytes using r1 and unlock" (MACH2000 USES-RT YIELD-INSN)
505 (+ OP_COP3 (f-rs 17) rt count)
509 (dni wbr30 "dma write bytes using r30" (MACH2000 USES-RT YIELD-INSN)
511 (+ OP_COP3 (f-rs 18) rt count)
515 (dni wbr30u "dma write bytes using r30 and unlock" (MACH2000 USES-RT YIELD-INSN)
517 (+ OP_COP3 (f-rs 19) rt count)
521 (dni wx "dma write word64s" (MACH2000 USES-RD USES-RT YIELD-INSN)
523 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 2))
527 (dni wxu "dma write word64s and unlock" (MACH2000 USES-RD USES-RT YIELD-INSN)
529 (+ OP_COP3 (f-rs 1) rt rd (f-shamt 0) (f-func 3))
533 (dni wxr1 "dma write word64s using r1" (MACH2000 USES-RT YIELD-INSN)
535 (+ OP_COP3 (f-rs 20) rt count)
539 (dni wxr1u "dma write word64s using r1 and unlock" (MACH2000 USES-RT YIELD-INSN)
541 (+ OP_COP3 (f-rs 21) rt count)
545 (dni wxr30 "dma write word64s using r30" (MACH2000 USES-RT YIELD-INSN)
547 (+ OP_COP3 (f-rs 22) rt count)
551 (dni wxr30u "dma write word64s using r30 and unlock" (MACH2000 USES-RT YIELD-INSN)
553 (+ OP_COP3 (f-rs 23) rt count)
558 ; Load/Store instructions.
560 (dni ldw "load double word" (MACH2000 EVEN-REG-NUM LOAD-DELAY USES-RT)
561 "ldw $rt,$lo16($base)"
562 (+ OP_LDW base rt lo16)
563 (sequence ((SI addr))
564 (set addr (and (add base lo16) (inv 3)))
565 (set (reg h-gr (add (ifield f-rt) 1)) (mem SI addr))
566 (set rt (mem SI (add addr 4))))
569 (dni sdw "store double word" (MACH2000 EVEN-REG-NUM USES-RT)
570 "sdw $rt,$lo16($base)"
571 (+ OP_SDW base rt lo16)
572 (sequence ((SI addr))
573 (set addr (and (add base lo16) (inv 3)))
574 (set (mem SI (add addr 4)) rt)
575 (set (mem SI addr) (reg h-gr (add (ifield f-rt) 1))))
581 (dni j "jump" (MACH2000)
583 (+ OP_J (f-rsrvd 0) jmptarg)
584 (delay 1 (set pc jmptarg))
587 (dni jal "jump and link" (MACH2000 USES-R31)
589 (+ OP_JAL (f-rsrvd 0) jmptarg)
592 (set (reg h-gr 31) (add pc 8))
596 (dni bmb "branch if matching byte-lane" (MACH2000 USES-RS USES-RT)
597 "bmb $rs,$rt,$offset"
598 (+ OP_BMB rs rt offset)
599 (sequence ((BI branch?))
601 (if (eq (and rs #xFF) (and rt #xFF))
603 (if (eq (and rs #xFF00) (and rt #xFF00))
605 (if (eq (and rs #xFF0000) (and rt #xFF0000))
607 (if (eq (and rs #xFF000000) (and rt #xFF000000))
610 (delay 1 (set pc offset))))
616 (dnmi ldw-base-0 "load double word - implied base 0" (MACH2000 EVEN-REG-NUM LOAD-DELAY USES-RT USES-RS NO-DIS)
618 (emit ldw rt lo16 (base 0))
621 (dnmi sdw-base-0 "store double word - implied base 0" (MACH2000 EVEN-REG-NUM USES-RT NO-DIS)
623 (emit sdw rt lo16 (base 0))