or1k: add missing l.msync, l.psync and l.psync instructions.
[deliverable/binutils-gdb.git] / cpu / or1kcommon.cpu
1 ; OpenRISC 1000 32-bit CPU hardware description. -*- Scheme -*-
2 ; Copyright 2000-2014 Free Software Foundation, Inc.
3 ; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org
4 ; Modified by Julius Baxter, juliusbaxter@gmail.com
5 ;
6 ; This program is free software; you can redistribute it and/or modify
7 ; it under the terms of the GNU General Public License as published by
8 ; the Free Software Foundation; either version 3 of the License, or
9 ; (at your option) any later version.
10 ;
11 ; This program is distributed in the hope that it will be useful,
12 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ; GNU General Public License for more details.
15 ;
16 ; You should have received a copy of the GNU General Public License
17 ; along with this program; if not, see <http://www.gnu.org/licenses/>
18
19 ; Hardware pieces.
20 ; These entries list the elements of the raw hardware.
21 ; They're also used to provide tables and other elements of the assembly
22 ; language.
23
24 (define-hardware
25 (name h-pc)
26 (comment "program counter")
27 (attrs PC (MACH ORBIS-MACHS))
28 (type pc UWI)
29 )
30
31 (define-pmacro REG-INDICES
32 ((r0 0)
33 (r1 1)
34 (r2 2)
35 (r3 3)
36 (r4 4)
37 (r5 5)
38 (r6 6)
39 (r7 7)
40 (r8 8)
41 (r9 9)
42 (r10 10)
43 (r11 11)
44 (r12 12)
45 (r13 13)
46 (r14 14)
47 (r15 15)
48 (r16 16)
49 (r17 17)
50 (r18 18)
51 (r19 19)
52 (r20 20)
53 (r21 21)
54 (r22 22)
55 (r23 23)
56 (r24 24)
57 (r25 25)
58 (r26 26)
59 (r27 27)
60 (r28 28)
61 (r29 29)
62 (r30 30)
63 (r31 31)
64 (lr 9)
65 (sp 1)
66 (fp 2))
67 )
68
69 (define-hardware
70 (name h-fsr)
71 (comment "floating point registers (single, virtual)")
72 (attrs VIRTUAL (MACH ORFPX32-MACHS))
73 (type register SF (32))
74 (indices keyword "" REG-INDICES)
75 (get (index) (subword SF (trunc SI (reg h-gpr index)) 0))
76 (set (index newval) (set UWI (reg h-gpr index) (zext UWI (subword SI newval 0))))
77 )
78
79 (define-hardware
80 (name h-fdr) (comment "floating point registers (double, virtual)")
81 (attrs VIRTUAL (MACH ORFPX64-MACHS))
82 (type register DF (32))
83 (indices keyword "" REG-INDICES)
84 (get (index) (subword DF (trunc DI (reg h-gpr index)) 0))
85 (set (index newval) (set UDI (reg h-gpr index) (zext UDI (subword DI newval 0))))
86 )
87
88 (define-hardware
89 (name h-spr) (comment "special purpose registers")
90 (attrs VIRTUAL (MACH ORBIS-MACHS))
91 (type register UWI (#x20000))
92 (get (index) (c-call UWI "@cpu@_h_spr_get_raw" index))
93 (set (index newval) (c-call VOID "@cpu@_h_spr_set_raw" index newval))
94 )
95
96 (define-pmacro spr-shift 11)
97 (define-pmacro (spr-address spr-group spr-index)
98 (or (sll UWI (enum UWI (.sym "SPR-GROUP-" spr-group)) spr-shift)
99 (enum UWI (.sym "SPR-INDEX-" spr-group "-" spr-index))))
100
101 (define-hardware
102 (name h-gpr) (comment "general registers")
103 (attrs (MACH ORBIS-MACHS))
104 (type register UWI (32))
105 (indices keyword "" REG-INDICES)
106 (get (index) (reg UWI h-spr (add index (spr-address SYS GPR0))))
107 (set (index newval) (set UWI (reg UWI h-spr (add index (spr-address SYS GPR0))) newval))
108 )
109
110 (define-normal-enum
111 except-number
112 "Exception numbers"
113 ()
114 EXCEPT-
115 (("NONE" #x00)
116 ("RESET" #x01)
117 ("BUSERR" #x02)
118 ("DPF" #x03)
119 ("IPF" #x04)
120 ("TICK" #x05)
121 ("ALIGN" #x06)
122 ("ILLEGAL" #x07)
123 ("INT" #x08)
124 ("DTLBMISS" #x09)
125 ("ITLBMISS" #x0a)
126 ("RANGE" #x0b)
127 ("SYSCALL" #x0c)
128 ("FPE" #x0d)
129 ("TRAP" #x0e)
130 )
131 )
132
133 (define-pmacro (raise-exception exnum)
134 (c-call VOID "@cpu@_exception" pc exnum))
135
136 (define-normal-enum
137 spr-groups
138 "special purpose register groups"
139 ()
140 SPR-GROUP-
141 (("SYS" #x0)
142 ("DMMU" #x1)
143 ("IMMU" #x2)
144 ("DCACHE" #x3)
145 ("ICACHE" #x4)
146 ("MAC" #x5)
147 ("DEBUG" #x6)
148 ("PERF" #x7)
149 ("POWER" #x8)
150 ("PIC" #x9)
151 ("TICK" #xa)
152 ("FPU" #xb)
153 )
154 )
155
156 (define-pmacro (spr-reg-info)
157 (.splice
158 (SYS VR #x000 "version register")
159 (SYS UPR #x001 "unit present register")
160 (SYS CPUCFGR #x002 "cpu configuration register")
161 (SYS DMMUCFGR #x003 "Data MMU configuration register")
162 (SYS IMMUCFGR #x004 "Insn MMU configuration register")
163 (SYS DCCFGR #x005 "Data cache configuration register")
164 (SYS ICCFGR #x006 "Insn cache configuration register")
165 (SYS DCFGR #x007 "Debug configuration register")
166 (SYS PCCFGR #x008 "Performance counters configuration register")
167 (SYS NPC #x010 "Next program counter")
168 (SYS SR #x011 "Supervision Regsiter")
169 (SYS PPC #x012 "Previous program counter")
170 (SYS FPCSR #x014 "Floating point control status register")
171 (.unsplice
172 (.map (.pmacro (n) (.splice SYS (.sym "EPCR" n) (.add n #x20) (.str "Exception PC register " n)))
173 (.iota #x10)))
174 (.unsplice
175 (.map (.pmacro (n) (.splice SYS (.sym "EEAR" n) (.add n #x30) (.str "Exception effective address register " n)))
176 (.iota #x10)))
177 (.unsplice
178 (.map (.pmacro (n) (.splice SYS (.sym "ESR" n) (.add n #x40) (.str "Exception supervision register " n)))
179 (.iota #x10)))
180 (.unsplice
181 (.map (.pmacro (n) (.splice SYS (.sym "GPR" n) (.add n #x400) (.str "General purpose register " n)))
182 (.iota #x200)))
183
184 (MAC MACLO #x001 "Multiply and accumulate result (low)")
185 (MAC MACHI #x002 "Multiply and accumulate result (high)")
186 (TICK TTMR #x000 "Tick timer mode register")
187 )
188 )
189
190 (define-normal-enum
191 spr-reg-indices
192 "special purpose register indicies"
193 ()
194 SPR-INDEX-
195 (.map (.pmacro (args)
196 (.apply (.pmacro (group index n comment)
197 ((.sym group "-" index) n))
198 args)
199 )
200 (spr-reg-info)
201 )
202 )
203
204 (define-pmacro (define-h-spr-reg spr-group spr-index n spr-comment)
205 (define-hardware
206 (name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index)))
207 (comment spr-comment)
208 (attrs VIRTUAL (MACH ORBIS-MACHS))
209 (type register UWI)
210 (get () (reg UWI h-spr (spr-address spr-group spr-index)))
211 (set (newval) (set (reg UWI h-spr (spr-address spr-group spr-index)) newval))
212 )
213 )
214 (.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-reg args)) (spr-reg-info))))
215
216 (define-pmacro (spr-field-info)
217 ((SYS VR REV 5 0 "revision field")
218 (SYS VR CFG 23 16 "configuration template field")
219 (SYS VR VER 31 24 "version field")
220 (SYS UPR UP 0 0 "UPR present bit")
221 (SYS UPR DCP 1 1 "data cache present bit")
222 (SYS UPR ICP 2 2 "insn cache present bit")
223 (SYS UPR DMP 3 3 "data MMU present bit")
224 (SYS UPR MP 4 4 "MAC unit present bit")
225 (SYS UPR IMP 5 5 "insn MMU present bit")
226 (SYS UPR DUP 6 6 "debug unit present bit")
227 (SYS UPR PCUP 7 7 "performance counters unit present bit")
228 (SYS UPR PICP 8 8 "programmable interrupt controller present bit")
229 (SYS UPR PMP 9 9 "power management present bit")
230 (SYS UPR TTP 10 10 "tick timer present bit")
231 (SYS UPR CUP 31 24 "custom units present field")
232 (SYS CPUCFGR NSGR 3 0 "number of shadow GPR files field")
233 (SYS CPUCFGR CGF 4 4 "custom GPR file bit")
234 (SYS CPUCFGR OB32S 5 5 "ORBIS32 supported bit")
235 (SYS CPUCFGR OB64S 6 6 "ORBIS64 supported bit")
236 (SYS CPUCFGR OF32S 7 7 "ORFPX32 supported bit")
237 (SYS CPUCFGR OF64S 8 8 "ORFPX64 supported bit")
238 (SYS CPUCFGR OV64S 9 9 "ORVDX64 supported bit")
239 (SYS CPUCFGR ND 10 10 "no transfer delay bit")
240 (SYS SR SM 0 0 "supervisor mode bit")
241 (SYS SR TEE 1 1 "tick timer exception enabled bit")
242 (SYS SR IEE 2 2 "interrupt exception enabled bit")
243 (SYS SR DCE 3 3 "data cache enabled bit")
244 (SYS SR ICE 4 4 "insn cache enabled bit")
245 (SYS SR DME 5 5 "data MMU enabled bit")
246 (SYS SR IME 6 6 "insn MMU enabled bit")
247 (SYS SR LEE 7 7 "little endian enabled bit")
248 (SYS SR CE 8 8 "CID enable bit")
249 (SYS SR F 9 9 "flag bit")
250 (SYS SR CY 10 10 "carry bit")
251 (SYS SR OV 11 11 "overflow bit")
252 (SYS SR OVE 12 12 "overflow exception enabled bit")
253 (SYS SR DSX 13 13 "delay slot exception bit")
254 (SYS SR EPH 14 14 "exception prefix high bit")
255 (SYS SR FO 15 15 "fixed one bit")
256 (SYS SR SUMRA 16 16 "SPRs user mode read access bit")
257 (SYS SR CID 31 28 "context ID field")
258 (SYS FPCSR FPEE 0 0 "floating point exceptions enabled bit")
259 (SYS FPCSR RM 2 1 "floating point rounding mode field")
260 (SYS FPCSR OVF 3 3 "floating point overflow flag bit")
261 (SYS FPCSR UNF 4 4 "floating point underflow bit")
262 (SYS FPCSR SNF 5 5 "floating point SNAN flag bit")
263 (SYS FPCSR QNF 6 6 "floating point QNAN flag bit")
264 (SYS FPCSR ZF 7 7 "floating point zero flag bit")
265 (SYS FPCSR IXF 8 8 "floating point inexact flag bit")
266 (SYS FPCSR IVF 9 9 "floating point invalid flag bit")
267 (SYS FPCSR INF 10 10 "floating point infinity flag bit")
268 (SYS FPCSR DZF 11 11 "floating point divide by zero flag bit")
269 )
270 )
271
272 (define-normal-enum
273 spr-field-msbs
274 "SPR field msb positions"
275 ()
276 SPR-FIELD-MSB-
277 (.map (.pmacro (args)
278 (.apply (.pmacro (group index field msb lsb comment)
279 ((.sym group "-" index "-" field) msb)
280 )
281 args
282 )
283 )
284 (spr-field-info)
285 )
286 )
287
288 (define-normal-enum
289 spr-field-lsbs
290 "SPR field lsb positions"
291 ()
292 SPR-FIELD-SIZE-
293 (.map (.pmacro (args)
294 (.apply (.pmacro (group index field msb lsb comment)
295 ((.sym group "-" index "-" field) lsb)
296 )
297 args
298 )
299 )
300 (spr-field-info)
301 )
302 )
303
304 (define-normal-enum
305 spr-field-masks
306 "SPR field masks"
307 ()
308 SPR-FIELD-MASK-
309 (.map (.pmacro (args)
310 (.apply (.pmacro (group index field msb lsb comment)
311 (.splice (.str group "-" index "-" field) (.sll (.inv (.sll (.inv 0) (.add (.sub msb lsb) 1))) lsb))
312 )
313 args
314 )
315 )
316 (spr-field-info)
317 )
318 )
319
320 (define-pmacro (define-h-spr-field spr-group spr-index spr-field spr-field-msb spr-field-lsb spr-field-comment)
321 (.let ((spr-field-name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index) "-" (.downcase spr-field)))
322 )
323 (begin
324 (define-hardware
325 (name spr-field-name)
326 (comment spr-field-comment)
327 (attrs VIRTUAL (MACH ORBIS-MACHS))
328 (type register UWI)
329 (get () (c-call UWI "@cpu@_h_spr_field_get_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb))
330 (set (value) (c-call VOID "@cpu@_h_spr_field_set_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb value))
331 )
332 )
333 )
334 )
335 (.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-field args)) (spr-field-info))))
336
337 (define-attr
338 (type boolean)
339 (for insn)
340 (name DELAYED-CTI)
341 (comment "delayed control transfer instruction")
342 (values #f #t)
343 (default #f)
344 )
345
346 (define-attr
347 (for insn)
348 (type boolean)
349 (name NOT-IN-DELAY-SLOT)
350 (comment "instruction cannot be in delay slot")
351 (values #f #t)
352 (default #f)
353 )
354
355 (define-attr
356 (for insn)
357 (type boolean)
358 (name FORCED-CTI)
359 (comment "instruction may forcefully transfer control (e.g., rfe)")
360 )
This page took 0.040564 seconds and 4 git commands to generate.