xref: /netbsd-src/external/gpl3/gdb/dist/cpu/or1kcommon.cpu (revision 8dffb485a119f39f727115fa0bcb569045caf7cb)
1968cf8f2Schristos; OpenRISC 1000 32-bit CPU hardware description.  -*- Scheme -*-
2*8dffb485Schristos; Copyright 2000-2019 Free Software Foundation, Inc.
3968cf8f2Schristos; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org
4968cf8f2Schristos; Modified by Julius Baxter, juliusbaxter@gmail.com
5*8dffb485Schristos; Modified by Andrey Bacherov, avbacherov@opencores.org
6968cf8f2Schristos;
7968cf8f2Schristos; This program is free software; you can redistribute it and/or modify
8968cf8f2Schristos; it under the terms of the GNU General Public License as published by
9968cf8f2Schristos; the Free Software Foundation; either version 3 of the License, or
10968cf8f2Schristos; (at your option) any later version.
11968cf8f2Schristos;
12968cf8f2Schristos; This program is distributed in the hope that it will be useful,
13968cf8f2Schristos; but WITHOUT ANY WARRANTY; without even the implied warranty of
14968cf8f2Schristos; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15968cf8f2Schristos; GNU General Public License for more details.
16968cf8f2Schristos;
17968cf8f2Schristos; You should have received a copy of the GNU General Public License
18968cf8f2Schristos; along with this program; if not, see <http://www.gnu.org/licenses/>
19968cf8f2Schristos
20968cf8f2Schristos; Hardware pieces.
21968cf8f2Schristos; These entries list the elements of the raw hardware.
22968cf8f2Schristos; They're also used to provide tables and other elements of the assembly
23968cf8f2Schristos; language.
24968cf8f2Schristos
25968cf8f2Schristos(define-hardware
26968cf8f2Schristos  (name h-pc)
27968cf8f2Schristos  (comment "program counter")
28968cf8f2Schristos  (attrs PC (MACH ORBIS-MACHS))
29968cf8f2Schristos  (type pc UWI)
30796c32c9Schristos  (get () (raw-reg h-pc))
31796c32c9Schristos  (set (newval) (sequence ()
32796c32c9Schristos                 (set (reg h-sys-ppc) (raw-reg h-pc))
33796c32c9Schristos                 (set (raw-reg h-pc) newval)
34796c32c9Schristos                ))
35968cf8f2Schristos  )
36968cf8f2Schristos
37968cf8f2Schristos(define-pmacro REG-INDICES
38968cf8f2Schristos  ((r0 0)
39968cf8f2Schristos   (r1 1)
40968cf8f2Schristos   (r2 2)
41968cf8f2Schristos   (r3 3)
42968cf8f2Schristos   (r4 4)
43968cf8f2Schristos   (r5 5)
44968cf8f2Schristos   (r6 6)
45968cf8f2Schristos   (r7 7)
46968cf8f2Schristos   (r8 8)
47968cf8f2Schristos   (r9 9)
48968cf8f2Schristos   (r10 10)
49968cf8f2Schristos   (r11 11)
50968cf8f2Schristos   (r12 12)
51968cf8f2Schristos   (r13 13)
52968cf8f2Schristos   (r14 14)
53968cf8f2Schristos   (r15 15)
54968cf8f2Schristos   (r16 16)
55968cf8f2Schristos   (r17 17)
56968cf8f2Schristos   (r18 18)
57968cf8f2Schristos   (r19 19)
58968cf8f2Schristos   (r20 20)
59968cf8f2Schristos   (r21 21)
60968cf8f2Schristos   (r22 22)
61968cf8f2Schristos   (r23 23)
62968cf8f2Schristos   (r24 24)
63968cf8f2Schristos   (r25 25)
64968cf8f2Schristos   (r26 26)
65968cf8f2Schristos   (r27 27)
66968cf8f2Schristos   (r28 28)
67968cf8f2Schristos   (r29 29)
68968cf8f2Schristos   (r30 30)
69968cf8f2Schristos   (r31 31)
70968cf8f2Schristos   (lr 9)
71968cf8f2Schristos   (sp 1)
72968cf8f2Schristos   (fp 2))
73968cf8f2Schristos  )
74968cf8f2Schristos
75*8dffb485Schristos;
76*8dffb485Schristos; Hardware: [S]pecial [P]urpose [R]egisters
77*8dffb485Schristos;
78968cf8f2Schristos(define-hardware
79968cf8f2Schristos  (name h-spr) (comment "special purpose registers")
80968cf8f2Schristos  (attrs VIRTUAL (MACH ORBIS-MACHS))
81968cf8f2Schristos  (type register UWI (#x20000))
82968cf8f2Schristos  (get (index) (c-call UWI "@cpu@_h_spr_get_raw" index))
83968cf8f2Schristos  (set (index newval) (c-call VOID "@cpu@_h_spr_set_raw" index newval))
84968cf8f2Schristos)
85968cf8f2Schristos
86968cf8f2Schristos(define-pmacro spr-shift 11)
87968cf8f2Schristos(define-pmacro (spr-address spr-group spr-index)
88968cf8f2Schristos  (or (sll UWI (enum UWI (.sym "SPR-GROUP-" spr-group)) spr-shift)
89968cf8f2Schristos      (enum UWI (.sym "SPR-INDEX-" spr-group "-" spr-index))))
90968cf8f2Schristos
91*8dffb485Schristos;
92*8dffb485Schristos; Hardware: [G]enepral  [P]urpose [R]egisters
93*8dffb485Schristos;
94968cf8f2Schristos(define-hardware
95968cf8f2Schristos  (name h-gpr) (comment "general registers")
96968cf8f2Schristos  (attrs (MACH ORBIS-MACHS))
97968cf8f2Schristos  (type register UWI (32))
98968cf8f2Schristos  (indices keyword "" REG-INDICES)
99968cf8f2Schristos  (get (index) (reg UWI h-spr (add index (spr-address SYS GPR0))))
100968cf8f2Schristos  (set (index newval) (set UWI (reg UWI h-spr (add index (spr-address SYS GPR0))) newval))
101968cf8f2Schristos  )
102968cf8f2Schristos
103*8dffb485Schristos;
104*8dffb485Schristos; Hardware: virtual registerts for FPU (single precision)
105*8dffb485Schristos;           mapped to GPRs
106*8dffb485Schristos;
107*8dffb485Schristos(define-hardware
108*8dffb485Schristos  (name h-fsr)
109*8dffb485Schristos  (comment "floating point registers (single, virtual)")
110*8dffb485Schristos  (attrs VIRTUAL (MACH ORFPX32-MACHS))
111*8dffb485Schristos  (type register SF (32))
112*8dffb485Schristos  (indices keyword "" REG-INDICES)
113*8dffb485Schristos  (get (index) (subword SF (trunc SI (reg h-gpr index)) 0))
114*8dffb485Schristos  (set (index newval) (set UWI (reg h-gpr index) (zext UWI (subword SI newval 0))))
115*8dffb485Schristos  )
116*8dffb485Schristos
117*8dffb485Schristos;
118*8dffb485Schristos; Register pairs are offset by 2 for registers r16 and above.  This is to
119*8dffb485Schristos; be able to allow registers to be call saved in GCC across function calls.
120*8dffb485Schristos;
121*8dffb485Schristos(define-pmacro (reg-pair-reg-lo index)
122*8dffb485Schristos  (and index (const #x1f))
123*8dffb485Schristos)
124*8dffb485Schristos
125*8dffb485Schristos(define-pmacro (reg-pair-reg-hi index)
126*8dffb485Schristos  (add (and index (const #x1f))
127*8dffb485Schristos       (if (eq (sra index (const 5))
128*8dffb485Schristos	       (const 1))
129*8dffb485Schristos	   (const 2)
130*8dffb485Schristos	   (const 1)
131*8dffb485Schristos	 )
132*8dffb485Schristos    )
133*8dffb485Schristos)
134*8dffb485Schristos
135*8dffb485Schristos;
136*8dffb485Schristos; Hardware: vrtual registers for double precision floating point
137*8dffb485Schristos;           operands on 32-bit machines
138*8dffb485Schristos;           mapped to GPRs
139*8dffb485Schristos;
140*8dffb485Schristos(define-hardware
141*8dffb485Schristos  (name h-fd32r)
142*8dffb485Schristos  (comment "or32 floating point registers (double, virtual)")
143*8dffb485Schristos  (attrs VIRTUAL (MACH ORFPX64A32-MACHS))
144*8dffb485Schristos  (type register DF (32))
145*8dffb485Schristos  (get (index) (join DF SI
146*8dffb485Schristos                        (reg h-gpr (reg-pair-reg-lo index))
147*8dffb485Schristos                        (reg h-gpr (reg-pair-reg-hi index))))
148*8dffb485Schristos  (set (index newval)
149*8dffb485Schristos       (sequence ()
150*8dffb485Schristos                 (set (reg h-gpr (reg-pair-reg-lo index)) (subword SI newval 0))
151*8dffb485Schristos                 (set (reg h-gpr (reg-pair-reg-hi index))
152*8dffb485Schristos                                 (subword SI newval 1))))
153*8dffb485Schristos)
154*8dffb485Schristos
155*8dffb485Schristos;
156*8dffb485Schristos; Hardware: vrtual 64-bit integer registers for conversions
157*8dffb485Schristos;           float64 <-> int64 on 32-bit machines
158*8dffb485Schristos;           mapped to GPRs
159*8dffb485Schristos;
160*8dffb485Schristos(define-hardware
161*8dffb485Schristos  (name h-i64r)
162*8dffb485Schristos  (comment "or32 double word registers (int64, virtual)")
163*8dffb485Schristos  (attrs VIRTUAL (MACH ORFPX64A32-MACHS))
164*8dffb485Schristos  (type register DI (32))
165*8dffb485Schristos  (get (index) (join DI SI
166*8dffb485Schristos                        (reg h-gpr (reg-pair-reg-lo index))
167*8dffb485Schristos                        (reg h-gpr (reg-pair-reg-hi index))))
168*8dffb485Schristos  (set (index newval)
169*8dffb485Schristos       (sequence ()
170*8dffb485Schristos                 (set (reg h-gpr (reg-pair-reg-lo index)) (subword SI newval 0))
171*8dffb485Schristos                 (set (reg h-gpr (reg-pair-reg-hi index))
172*8dffb485Schristos                                 (subword SI newval 1))))
173*8dffb485Schristos)
174*8dffb485Schristos
175*8dffb485Schristos
176968cf8f2Schristos(define-normal-enum
177968cf8f2Schristos  except-number
178968cf8f2Schristos  "Exception numbers"
179968cf8f2Schristos  ()
180968cf8f2Schristos  EXCEPT-
181968cf8f2Schristos  (("NONE"     #x00)
182968cf8f2Schristos   ("RESET"    #x01)
183968cf8f2Schristos   ("BUSERR"   #x02)
184968cf8f2Schristos   ("DPF"      #x03)
185968cf8f2Schristos   ("IPF"      #x04)
186968cf8f2Schristos   ("TICK"     #x05)
187968cf8f2Schristos   ("ALIGN"    #x06)
188968cf8f2Schristos   ("ILLEGAL"  #x07)
189968cf8f2Schristos   ("INT"      #x08)
190968cf8f2Schristos   ("DTLBMISS" #x09)
191968cf8f2Schristos   ("ITLBMISS" #x0a)
192968cf8f2Schristos   ("RANGE"    #x0b)
193968cf8f2Schristos   ("SYSCALL"  #x0c)
194968cf8f2Schristos   ("FPE"      #x0d)
195968cf8f2Schristos   ("TRAP"     #x0e)
196968cf8f2Schristos   )
197968cf8f2Schristos  )
198968cf8f2Schristos
199968cf8f2Schristos(define-pmacro (raise-exception exnum)
200968cf8f2Schristos  (c-call VOID "@cpu@_exception" pc exnum))
201968cf8f2Schristos
202968cf8f2Schristos(define-normal-enum
203968cf8f2Schristos  spr-groups
204968cf8f2Schristos  "special purpose register groups"
205968cf8f2Schristos  ()
206968cf8f2Schristos  SPR-GROUP-
207968cf8f2Schristos  (("SYS"          #x0)
208968cf8f2Schristos   ("DMMU"         #x1)
209968cf8f2Schristos   ("IMMU"         #x2)
210968cf8f2Schristos   ("DCACHE"       #x3)
211968cf8f2Schristos   ("ICACHE"       #x4)
212968cf8f2Schristos   ("MAC"          #x5)
213968cf8f2Schristos   ("DEBUG"        #x6)
214968cf8f2Schristos   ("PERF"         #x7)
215968cf8f2Schristos   ("POWER"        #x8)
216968cf8f2Schristos   ("PIC"          #x9)
217968cf8f2Schristos   ("TICK"         #xa)
218968cf8f2Schristos   ("FPU"          #xb)
219968cf8f2Schristos   )
220968cf8f2Schristos  )
221968cf8f2Schristos
222968cf8f2Schristos(define-pmacro (spr-reg-info)
223968cf8f2Schristos  (.splice
224968cf8f2Schristos   (SYS VR       #x000 "version register")
225968cf8f2Schristos   (SYS UPR      #x001 "unit present register")
226968cf8f2Schristos   (SYS CPUCFGR  #x002 "cpu configuration register")
227968cf8f2Schristos   (SYS DMMUCFGR #x003 "Data MMU configuration register")
228968cf8f2Schristos   (SYS IMMUCFGR #x004 "Insn MMU configuration register")
229968cf8f2Schristos   (SYS DCCFGR   #x005 "Data cache configuration register")
230968cf8f2Schristos   (SYS ICCFGR   #x006 "Insn cache configuration register")
231968cf8f2Schristos   (SYS DCFGR    #x007 "Debug configuration register")
232968cf8f2Schristos   (SYS PCCFGR   #x008 "Performance counters configuration register")
233968cf8f2Schristos   (SYS NPC      #x010 "Next program counter")
2344559860eSchristos   (SYS SR       #x011 "Supervision Register")
235968cf8f2Schristos   (SYS PPC      #x012 "Previous program counter")
236968cf8f2Schristos   (SYS FPCSR    #x014 "Floating point control status register")
237968cf8f2Schristos   (.unsplice
238968cf8f2Schristos    (.map (.pmacro (n) (.splice SYS (.sym "EPCR" n) (.add n #x20) (.str "Exception PC register " n)))
239968cf8f2Schristos          (.iota #x10)))
240968cf8f2Schristos   (.unsplice
241968cf8f2Schristos    (.map (.pmacro (n) (.splice SYS (.sym "EEAR" n) (.add n #x30) (.str "Exception effective address register " n)))
242968cf8f2Schristos          (.iota #x10)))
243968cf8f2Schristos   (.unsplice
244968cf8f2Schristos    (.map (.pmacro (n) (.splice SYS (.sym "ESR" n) (.add n #x40) (.str "Exception supervision register " n)))
245968cf8f2Schristos          (.iota #x10)))
246968cf8f2Schristos   (.unsplice
247968cf8f2Schristos    (.map (.pmacro (n) (.splice SYS (.sym "GPR" n) (.add n #x400) (.str "General purpose register " n)))
248968cf8f2Schristos          (.iota #x200)))
249968cf8f2Schristos
250968cf8f2Schristos   (MAC MACLO    #x001 "Multiply and accumulate result (low)")
251968cf8f2Schristos   (MAC MACHI    #x002 "Multiply and accumulate result (high)")
252968cf8f2Schristos   (TICK TTMR    #x000 "Tick timer mode register")
253968cf8f2Schristos   )
254968cf8f2Schristos  )
255968cf8f2Schristos
256968cf8f2Schristos(define-normal-enum
257968cf8f2Schristos  spr-reg-indices
2584559860eSchristos  "special purpose register indices"
259968cf8f2Schristos  ()
260968cf8f2Schristos  SPR-INDEX-
261968cf8f2Schristos  (.map (.pmacro (args)
262968cf8f2Schristos                 (.apply (.pmacro (group index n comment)
263968cf8f2Schristos                                  ((.sym group "-" index) n))
264968cf8f2Schristos                         args)
265968cf8f2Schristos                 )
266968cf8f2Schristos        (spr-reg-info)
267968cf8f2Schristos        )
268968cf8f2Schristos  )
269968cf8f2Schristos
270968cf8f2Schristos(define-pmacro (define-h-spr-reg spr-group spr-index n spr-comment)
271968cf8f2Schristos  (define-hardware
272968cf8f2Schristos    (name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index)))
273968cf8f2Schristos    (comment spr-comment)
274968cf8f2Schristos    (attrs VIRTUAL (MACH ORBIS-MACHS))
275968cf8f2Schristos    (type register UWI)
276968cf8f2Schristos    (get ()       (reg UWI h-spr (spr-address spr-group spr-index)))
277968cf8f2Schristos    (set (newval) (set (reg UWI h-spr (spr-address spr-group spr-index)) newval))
278968cf8f2Schristos    )
279968cf8f2Schristos  )
280968cf8f2Schristos(.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-reg args)) (spr-reg-info))))
281968cf8f2Schristos
282968cf8f2Schristos(define-pmacro (spr-field-info)
283968cf8f2Schristos  ((SYS VR      REV    5  0 "revision field")
284968cf8f2Schristos   (SYS VR      CFG   23 16 "configuration template field")
285968cf8f2Schristos   (SYS VR      VER   31 24 "version field")
286968cf8f2Schristos   (SYS UPR     UP     0  0 "UPR present bit")
287968cf8f2Schristos   (SYS UPR     DCP    1  1 "data cache present bit")
288968cf8f2Schristos   (SYS UPR     ICP    2  2 "insn cache present bit")
289968cf8f2Schristos   (SYS UPR     DMP    3  3 "data MMU present bit")
290968cf8f2Schristos   (SYS UPR     MP     4  4 "MAC unit present bit")
291968cf8f2Schristos   (SYS UPR     IMP    5  5 "insn MMU present bit")
292968cf8f2Schristos   (SYS UPR     DUP    6  6 "debug unit present bit")
293968cf8f2Schristos   (SYS UPR     PCUP   7  7 "performance counters unit present bit")
294968cf8f2Schristos   (SYS UPR     PICP   8  8 "programmable interrupt controller present bit")
295968cf8f2Schristos   (SYS UPR     PMP    9  9 "power management present bit")
296968cf8f2Schristos   (SYS UPR     TTP   10 10 "tick timer present bit")
297968cf8f2Schristos   (SYS UPR     CUP   31 24 "custom units present field")
298968cf8f2Schristos   (SYS CPUCFGR NSGR   3  0 "number of shadow GPR files field")
299968cf8f2Schristos   (SYS CPUCFGR CGF    4  4 "custom GPR file bit")
300968cf8f2Schristos   (SYS CPUCFGR OB32S  5  5 "ORBIS32 supported bit")
301968cf8f2Schristos   (SYS CPUCFGR OB64S  6  6 "ORBIS64 supported bit")
302968cf8f2Schristos   (SYS CPUCFGR OF32S  7  7 "ORFPX32 supported bit")
303968cf8f2Schristos   (SYS CPUCFGR OF64S  8  8 "ORFPX64 supported bit")
304968cf8f2Schristos   (SYS CPUCFGR OV64S  9  9 "ORVDX64 supported bit")
305968cf8f2Schristos   (SYS CPUCFGR ND    10 10 "no transfer delay bit")
306968cf8f2Schristos   (SYS SR      SM     0  0 "supervisor mode bit")
307968cf8f2Schristos   (SYS SR      TEE    1  1 "tick timer exception enabled bit")
308968cf8f2Schristos   (SYS SR      IEE    2  2 "interrupt exception enabled bit")
309968cf8f2Schristos   (SYS SR      DCE    3  3 "data cache enabled bit")
310968cf8f2Schristos   (SYS SR      ICE    4  4 "insn cache enabled bit")
311968cf8f2Schristos   (SYS SR      DME    5  5 "data MMU enabled bit")
312968cf8f2Schristos   (SYS SR      IME    6  6 "insn MMU enabled bit")
313968cf8f2Schristos   (SYS SR      LEE    7  7 "little endian enabled bit")
314968cf8f2Schristos   (SYS SR      CE     8  8 "CID enable bit")
315968cf8f2Schristos   (SYS SR      F      9  9 "flag bit")
316968cf8f2Schristos   (SYS SR      CY    10 10 "carry bit")
317968cf8f2Schristos   (SYS SR      OV    11 11 "overflow bit")
318968cf8f2Schristos   (SYS SR      OVE   12 12 "overflow exception enabled bit")
319968cf8f2Schristos   (SYS SR      DSX   13 13 "delay slot exception bit")
320968cf8f2Schristos   (SYS SR      EPH   14 14 "exception prefix high bit")
321968cf8f2Schristos   (SYS SR      FO    15 15 "fixed one bit")
322968cf8f2Schristos   (SYS SR      SUMRA 16 16 "SPRs user mode read access bit")
323968cf8f2Schristos   (SYS SR      CID   31 28 "context ID field")
324968cf8f2Schristos   (SYS FPCSR   FPEE   0  0 "floating point exceptions enabled bit")
325968cf8f2Schristos   (SYS FPCSR   RM     2  1 "floating point rounding mode field")
326968cf8f2Schristos   (SYS FPCSR   OVF    3  3 "floating point overflow flag bit")
327968cf8f2Schristos   (SYS FPCSR   UNF    4  4 "floating point underflow bit")
328968cf8f2Schristos   (SYS FPCSR   SNF    5  5 "floating point SNAN flag bit")
329968cf8f2Schristos   (SYS FPCSR   QNF    6  6 "floating point QNAN flag bit")
330968cf8f2Schristos   (SYS FPCSR   ZF     7  7 "floating point zero flag bit")
331968cf8f2Schristos   (SYS FPCSR   IXF    8  8 "floating point inexact flag bit")
332968cf8f2Schristos   (SYS FPCSR   IVF    9  9 "floating point invalid flag bit")
333968cf8f2Schristos   (SYS FPCSR   INF   10 10 "floating point infinity flag bit")
334968cf8f2Schristos   (SYS FPCSR   DZF   11 11 "floating point divide by zero flag bit")
335968cf8f2Schristos   )
336968cf8f2Schristos  )
337968cf8f2Schristos
338968cf8f2Schristos(define-normal-enum
339968cf8f2Schristos  spr-field-msbs
340968cf8f2Schristos  "SPR field msb positions"
341968cf8f2Schristos  ()
342968cf8f2Schristos  SPR-FIELD-MSB-
343968cf8f2Schristos  (.map (.pmacro (args)
344968cf8f2Schristos                 (.apply (.pmacro (group index field msb lsb comment)
345968cf8f2Schristos                                  ((.sym group "-" index "-" field) msb)
346968cf8f2Schristos                                  )
347968cf8f2Schristos                         args
348968cf8f2Schristos                         )
349968cf8f2Schristos                 )
350968cf8f2Schristos        (spr-field-info)
351968cf8f2Schristos        )
352968cf8f2Schristos  )
353968cf8f2Schristos
354968cf8f2Schristos(define-normal-enum
355968cf8f2Schristos  spr-field-lsbs
356968cf8f2Schristos  "SPR field lsb positions"
357968cf8f2Schristos  ()
358968cf8f2Schristos  SPR-FIELD-SIZE-
359968cf8f2Schristos  (.map (.pmacro (args)
360968cf8f2Schristos                 (.apply (.pmacro (group index field msb lsb comment)
361968cf8f2Schristos                                  ((.sym group "-" index "-" field) lsb)
362968cf8f2Schristos                                  )
363968cf8f2Schristos                         args
364968cf8f2Schristos                         )
365968cf8f2Schristos                 )
366968cf8f2Schristos        (spr-field-info)
367968cf8f2Schristos        )
368968cf8f2Schristos  )
369968cf8f2Schristos
370968cf8f2Schristos(define-normal-enum
371968cf8f2Schristos  spr-field-masks
372968cf8f2Schristos  "SPR field masks"
373968cf8f2Schristos  ()
374968cf8f2Schristos  SPR-FIELD-MASK-
375968cf8f2Schristos  (.map (.pmacro (args)
376968cf8f2Schristos                 (.apply (.pmacro (group index field msb lsb comment)
377968cf8f2Schristos                                  (.splice (.str group "-" index "-" field) (.sll (.inv (.sll (.inv 0) (.add (.sub msb lsb) 1))) lsb))
378968cf8f2Schristos                                  )
379968cf8f2Schristos                         args
380968cf8f2Schristos                         )
381968cf8f2Schristos                 )
382968cf8f2Schristos        (spr-field-info)
383968cf8f2Schristos        )
384968cf8f2Schristos  )
385968cf8f2Schristos
386968cf8f2Schristos(define-pmacro (define-h-spr-field spr-group spr-index spr-field spr-field-msb spr-field-lsb spr-field-comment)
387968cf8f2Schristos  (.let ((spr-field-name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index) "-" (.downcase spr-field)))
388968cf8f2Schristos         )
389968cf8f2Schristos        (begin
390968cf8f2Schristos          (define-hardware
391968cf8f2Schristos            (name spr-field-name)
392968cf8f2Schristos            (comment spr-field-comment)
393968cf8f2Schristos            (attrs VIRTUAL (MACH ORBIS-MACHS))
394968cf8f2Schristos            (type register UWI)
395968cf8f2Schristos            (get ()      (c-call UWI  "@cpu@_h_spr_field_get_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb))
396968cf8f2Schristos            (set (value) (c-call VOID "@cpu@_h_spr_field_set_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb value))
397968cf8f2Schristos            )
398968cf8f2Schristos          )
399968cf8f2Schristos        )
400968cf8f2Schristos  )
401968cf8f2Schristos(.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-field args)) (spr-field-info))))
402968cf8f2Schristos
403968cf8f2Schristos(define-attr
404968cf8f2Schristos  (type boolean)
405968cf8f2Schristos  (for insn)
406968cf8f2Schristos  (name DELAYED-CTI)
407968cf8f2Schristos  (comment "delayed control transfer instruction")
408968cf8f2Schristos  (values #f #t)
409968cf8f2Schristos  (default #f)
410968cf8f2Schristos  )
411968cf8f2Schristos
412968cf8f2Schristos(define-attr
413968cf8f2Schristos  (for insn)
414968cf8f2Schristos  (type boolean)
415968cf8f2Schristos  (name NOT-IN-DELAY-SLOT)
416968cf8f2Schristos  (comment "instruction cannot be in delay slot")
417968cf8f2Schristos  (values #f #t)
418968cf8f2Schristos  (default #f)
419968cf8f2Schristos  )
420968cf8f2Schristos
421968cf8f2Schristos(define-attr
422968cf8f2Schristos  (for insn)
423968cf8f2Schristos  (type boolean)
424968cf8f2Schristos  (name FORCED-CTI)
425968cf8f2Schristos  (comment "instruction may forcefully transfer control (e.g., rfe)")
426968cf8f2Schristos  )
427