OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [cpu/] [fr30.cpu] - Blame information for rev 6

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.