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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [or1ksim/] [cpu/] [or32/] [op.c] - Blame information for rev 1662

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1452 nogj
/* op.c -- Micro operations for the recompiler
2
   Copyright (C) 2005 György `nog' Jeney, nog@sdf.lonestar.org
3
 
4
This file is part of OpenRISC 1000 Architectural Simulator.
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 2 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, write to the Free Software
18
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
 
20
 
21
#include <stdio.h>
22
#include <stdint.h>
23
#include <stdlib.h>
24
 
25
#include "config.h"
26
 
27
#ifdef HAVE_INTTYPES_H
28
#include <inttypes.h>
29
#endif
30
 
31
#include "port.h"
32
#include "arch.h"
33
#include "spr_defs.h"
34
#include "opcode/or32.h"
35
#include "sim-config.h"
36
#include "except.h"
37
#include "abstract.h"
38
#include "execute.h"
39
#include "sprs.h"
40
#include "sched.h"
41
 
42
#include "op_support.h"
43
 
44
#include "i386_regs.h"
45
 
46
#include "dyn_rec.h"
47
 
48
/* This must be here since the function in op_i386.h use this variable */
49
register struct cpu_state *env asm(CPU_STATE_REG);
50
 
51
#include "op_i386.h"
52
 
53
/*
54 1549 nogj
 * WARNING: Before going of and wildly editing everything in this file remember
55 1452 nogj
 * the following about its contents:
56
 * 1) The `functions' don't EVER return.  In otherwords haveing return state-
57
 *    ments _anywere_ in this file is likely not to work.  This is because
58
 *    dyngen just strips away the ret from the end of the function and just uses
59
 *    the function `body'.  If a ret statement is executed _anyware_ inside the
60
 *    dynamicly generated code, then it is undefined were we shall jump to.
61
 * 2) Because of 1), try not to have overly complicated functions.  In too
62
 *    complicated functions, gcc may decide to generate premature `exits'.  This
63
 *    is what passing the -fno-reorder-blocks command line switch to gcc helps
64
 *    with.  This is ofcourse not desired and is rather flaky as we don't (and
65
 *    can't) control the kind of code that gcc generates: It may work for one
66
 *    and break for another.  The less branches there are the less likely it is
67
 *    that a premature return shall occur.
68
 * 3) If gcc decides that it is going to be a basterd then it will optimise a
69
 *    very simple condition (if/switch) with a premature exit.  But gcc can't
70
 *    fuck ME over!  Just stick a FORCE_RET; at the END of the offending
71
 *    function.
72
 * 4) All operations must start with `op_'.  dyngen ignores all other functions.
73
 * 5) Local variables are depriciated: They hinder performance.
74
 * 6) Function calls are expensive as the stack has to be shifted (twice).
75
 */
76
 
77
/*#define __or_dynop __attribute__((noreturn))*/
78
#define __or_dynop
79
 
80
/* Temporaries to hold the (simulated) registers in */
81
register uint32_t t0 asm(T0_REG);
82
register uint32_t t1 asm(T1_REG);
83
register uint32_t t2 asm(T2_REG);
84
 
85
#define OP_PARAM1 ((uorreg_t)(&__op_param1))
86
#define OP_PARAM2 ((uorreg_t)(&__op_param2))
87
#define OP_PARAM3 ((uorreg_t)(&__op_param3))
88
 
89
extern uorreg_t __op_param1;
90
extern uorreg_t __op_param2;
91
extern uorreg_t __op_param3;
92
 
93
 
94
/* Helper function.  Whenever we escape the recompiled code and there is a
95
 * potential that an exception may happen this function must be called */
96
static inline void save_t_temporary(void)
97
{
98
  env->t0 = t0;
99
  env->t1 = t1;
100
  env->t2 = t2;
101
}
102
 
103
/* Wrapper around do_scheduler.  This is needed because op_do_sched must be as
104
 * small as possible. */
105
void do_sched_wrap(void)
106
{
107
  save_t_temporary();
108
  upd_sim_cycles();
109
  do_scheduler();
110
}
111
 
112 1481 nogj
/* do_scheduler wrapper for instructions that are in the delay slot */
113
void do_sched_wrap_delay(void)
114
{
115
  save_t_temporary();
116
  upd_sim_cycles();
117
  env->ts_current = 1;
118
  /* The PC gets set to the location of the jump, but do_sched increments that
119
   * so pull it back here to point to the right location again.  This could be
120
   * done in op_add_pc/op_set_pc_pc_delay but that would enlarge the recompiled
121
   * code. */
122
  //env->pc -= 4;
123
  do_scheduler();
124
  env->ts_current = 0;
125
}
126
 
127
void enter_dyn_code(oraddr_t addr, struct dyn_page *dp)
128
{
129
  uint16_t reg;
130
 
131 1483 nogj
  addr &= config.immu.pagesize - 1;
132 1481 nogj
  addr >>= 2;
133
 
134
  reg = dp->ts_bound[addr];
135
 
136
  if(reg & 0x1f)
137
    t0 = cpu_state.reg[reg & 0x1f];
138
 
139
  if((reg >> 5) & 0x1f)
140
    t1 = cpu_state.reg[(reg >> 5) & 0x1f];
141
 
142
  if((reg >> 10) & 0x1f)
143
    t2 = cpu_state.reg[(reg >> 10) & 0x1f];
144
 
145
  or_longjmp(dp->locs[addr]);
146
}
147
 
148 1452 nogj
 
149 1481 nogj
__or_dynop void op_set_pc_pc_delay(void)
150 1452 nogj
{
151 1481 nogj
  env->sprs[SPR_PPC] = get_pc();
152
  /* pc_delay is pulled back 4 since imediatly after this is run, the scheduler
153
   * runs which also increments it by 4 */
154
  set_pc(env->pc_delay - 4);
155 1452 nogj
}
156
 
157
__or_dynop void op_set_pc_delay_imm(void)
158
{
159
  env->pc_delay = get_pc() + (orreg_t)OP_PARAM1;
160
  env->delay_insn = 1;
161
}
162
 
163
__or_dynop void op_set_pc_delay_pc(void)
164
{
165
  env->pc_delay = get_pc();
166
  env->delay_insn = 1;
167
}
168
 
169
__or_dynop void op_clear_pc_delay(void)
170
{
171
  env->pc_delay = 0;
172
  env->delay_insn = 1;
173
}
174
 
175
__or_dynop void op_do_jump(void)
176
{
177 1481 nogj
  do_jump(get_pc());
178
}
179
 
180
__or_dynop void op_do_jump_delay(void)
181
{
182 1452 nogj
  do_jump(env->pc_delay);
183
}
184
 
185 1481 nogj
__or_dynop void op_clear_delay_insn(void)
186 1452 nogj
{
187 1481 nogj
  env->delay_insn = 0;
188 1452 nogj
}
189
 
190 1481 nogj
__or_dynop void op_set_delay_insn(void)
191 1452 nogj
{
192 1481 nogj
  env->delay_insn = 1;
193 1452 nogj
}
194
 
195 1481 nogj
__or_dynop void op_check_delay_slot(void)
196 1452 nogj
{
197 1481 nogj
  if(!env->delay_insn)
198
    OP_JUMP(OP_PARAM1);
199 1452 nogj
}
200
 
201
__or_dynop void op_jmp_imm(void)
202
{
203
  OP_JUMP(OP_PARAM1);
204
}
205
 
206
__or_dynop void op_set_flag(void)
207
{
208
  env->sprs[SPR_SR] |= SPR_SR_F;
209
}
210
 
211
__or_dynop void op_clear_flag(void)
212
{
213
  env->sprs[SPR_SR] &= ~SPR_SR_F;
214
}
215
 
216 1481 nogj
/* Used for the l.bf instruction.  Therefore if the flag is not set, jump over
217
 * all the jumping stuff */
218 1452 nogj
__or_dynop void op_check_flag(void)
219
{
220 1481 nogj
  if(!(env->sprs[SPR_SR] & SPR_SR_F)) {
221
    HANDLE_SCHED(do_sched_wrap, "no_sched_chk_flg");
222
    OP_JUMP(OP_PARAM1);
223
  }
224
}
225
 
226
/* Used for l.bf if the delay slot instruction is on another page */
227
__or_dynop void op_check_flag_delay(void)
228
{
229 1452 nogj
  if(env->sprs[SPR_SR] & SPR_SR_F) {
230 1481 nogj
    env->delay_insn = 1;
231 1452 nogj
    env->pc_delay = get_pc() + (orreg_t)OP_PARAM1;
232
  }
233
}
234
 
235 1481 nogj
/* Used for the l.bnf instruction.  Therefore if the flag is set, jump over all
236
 * the jumping stuff */
237 1452 nogj
__or_dynop void op_check_not_flag(void)
238
{
239 1481 nogj
  if(env->sprs[SPR_SR] & SPR_SR_F) {
240
    HANDLE_SCHED(do_sched_wrap, "no_sched_chk_not_flg");
241
    OP_JUMP(OP_PARAM1);
242
  }
243
}
244
 
245
/* Used for l.bnf if the delay slot instruction is on another page */
246
__or_dynop void op_check_not_flag_delay(void)
247
{
248 1452 nogj
  if(!(env->sprs[SPR_SR] & SPR_SR_F)) {
249 1481 nogj
    env->delay_insn = 1;
250 1452 nogj
    env->pc_delay = get_pc() + (orreg_t)OP_PARAM1;
251
  }
252
}
253
 
254
__or_dynop void op_set_ts_current(void)
255
{
256
  env->ts_current = 1;
257
}
258
 
259 1481 nogj
__or_dynop void op_add_pc(void)
260 1452 nogj
{
261 1481 nogj
  /* FIXME: Optimise */
262
  set_pc(get_pc() + OP_PARAM1);
263 1452 nogj
}
264
 
265
__or_dynop void op_nop_exit(void)
266
{
267
  upd_sim_cycles();
268
  save_t_temporary();
269
  op_support_nop_exit();
270
  FORCE_RET;
271
}
272
 
273
__or_dynop void op_nop_reset(void)
274
{
275
  upd_sim_cycles();
276
  op_support_nop_reset();
277 1481 nogj
  do_jump(EXCEPT_RESET);
278 1452 nogj
}
279
 
280
__or_dynop void op_nop_printf(void)
281
{
282
  save_t_temporary();
283
  upd_sim_cycles();
284
  op_support_nop_printf();
285
  FORCE_RET;
286
}
287
 
288
__or_dynop void op_nop_report(void)
289
{
290
  save_t_temporary();
291
  upd_sim_cycles();
292
  op_support_nop_report();
293
  FORCE_RET;
294
}
295
 
296
__or_dynop void op_nop_report_imm(void)
297
{
298
  save_t_temporary();
299
  upd_sim_cycles();
300
  op_support_nop_report_imm(OP_PARAM1);
301
}
302
 
303 1657 nogj
__or_dynop void op_analysis(void)
304 1452 nogj
{
305 1657 nogj
  env->iqueue.insn_index = OP_PARAM1;
306
  env->iqueue.insn = OP_PARAM2;
307
  env->iqueue.insn_addr = get_pc();
308
  save_t_temporary();
309
  op_support_analysis();
310
  FORCE_RET;
311 1452 nogj
}
312
 
313 1657 nogj
__or_dynop void op_move_gpr1_pc_delay(void)
314
{
315
  env->pc_delay = env->reg[1];
316
  env->delay_insn = 1;
317
}
318 1452 nogj
 
319 1657 nogj
__or_dynop void op_move_gpr2_pc_delay(void)
320 1452 nogj
{
321 1657 nogj
  env->pc_delay = env->reg[2];
322
  env->delay_insn = 1;
323 1452 nogj
}
324
 
325 1657 nogj
__or_dynop void op_move_gpr3_pc_delay(void)
326 1452 nogj
{
327 1657 nogj
  env->pc_delay = env->reg[3];
328
  env->delay_insn = 1;
329 1452 nogj
}
330
 
331 1657 nogj
__or_dynop void op_move_gpr4_pc_delay(void)
332
{
333
  env->pc_delay = env->reg[4];
334
  env->delay_insn = 1;
335
}
336 1452 nogj
 
337 1657 nogj
__or_dynop void op_move_gpr5_pc_delay(void)
338 1452 nogj
{
339 1657 nogj
  env->pc_delay = env->reg[5];
340
  env->delay_insn = 1;
341 1452 nogj
}
342
 
343 1657 nogj
__or_dynop void op_move_gpr6_pc_delay(void)
344 1452 nogj
{
345 1657 nogj
  env->pc_delay = env->reg[6];
346
  env->delay_insn = 1;
347 1452 nogj
}
348
 
349 1657 nogj
__or_dynop void op_move_gpr7_pc_delay(void)
350 1452 nogj
{
351 1657 nogj
  env->pc_delay = env->reg[7];
352
  env->delay_insn = 1;
353 1452 nogj
}
354
 
355 1657 nogj
__or_dynop void op_move_gpr8_pc_delay(void)
356 1452 nogj
{
357 1657 nogj
  env->pc_delay = env->reg[8];
358
  env->delay_insn = 1;
359 1452 nogj
}
360
 
361 1657 nogj
__or_dynop void op_move_gpr9_pc_delay(void)
362
{
363
  env->pc_delay = env->reg[9];
364
  env->delay_insn = 1;
365
}
366
 
367
__or_dynop void op_move_gpr10_pc_delay(void)
368
{
369
  env->pc_delay = env->reg[10];
370
  env->delay_insn = 1;
371
}
372
 
373
__or_dynop void op_move_gpr11_pc_delay(void)
374
{
375
  env->pc_delay = env->reg[11];
376
  env->delay_insn = 1;
377
}
378
 
379
__or_dynop void op_move_gpr12_pc_delay(void)
380
{
381
  env->pc_delay = env->reg[12];
382
  env->delay_insn = 1;
383
}
384
 
385
__or_dynop void op_move_gpr13_pc_delay(void)
386
{
387
  env->pc_delay = env->reg[13];
388
  env->delay_insn = 1;
389
}
390
 
391
__or_dynop void op_move_gpr14_pc_delay(void)
392
{
393
  env->pc_delay = env->reg[14];
394
  env->delay_insn = 1;
395
}
396
 
397
__or_dynop void op_move_gpr15_pc_delay(void)
398
{
399
  env->pc_delay = env->reg[15];
400
  env->delay_insn = 1;
401
}
402
 
403
__or_dynop void op_move_gpr16_pc_delay(void)
404
{
405
  env->pc_delay = env->reg[16];
406
  env->delay_insn = 1;
407
}
408
 
409
__or_dynop void op_move_gpr17_pc_delay(void)
410
{
411
  env->pc_delay = env->reg[17];
412
  env->delay_insn = 1;
413
}
414
 
415
__or_dynop void op_move_gpr18_pc_delay(void)
416
{
417
  env->pc_delay = env->reg[18];
418
  env->delay_insn = 1;
419
}
420
 
421
__or_dynop void op_move_gpr19_pc_delay(void)
422
{
423
  env->pc_delay = env->reg[19];
424
  env->delay_insn = 1;
425
}
426
 
427
__or_dynop void op_move_gpr20_pc_delay(void)
428
{
429
  env->pc_delay = env->reg[20];
430
  env->delay_insn = 1;
431
}
432
 
433
__or_dynop void op_move_gpr21_pc_delay(void)
434
{
435
  env->pc_delay = env->reg[21];
436
  env->delay_insn = 1;
437
}
438
 
439
__or_dynop void op_move_gpr22_pc_delay(void)
440
{
441
  env->pc_delay = env->reg[22];
442
  env->delay_insn = 1;
443
}
444
 
445
__or_dynop void op_move_gpr23_pc_delay(void)
446
{
447
  env->pc_delay = env->reg[23];
448
  env->delay_insn = 1;
449
}
450
 
451
__or_dynop void op_move_gpr24_pc_delay(void)
452
{
453
  env->pc_delay = env->reg[24];
454
  env->delay_insn = 1;
455
}
456
 
457
__or_dynop void op_move_gpr25_pc_delay(void)
458
{
459
  env->pc_delay = env->reg[25];
460
  env->delay_insn = 1;
461
}
462
 
463
__or_dynop void op_move_gpr26_pc_delay(void)
464
{
465
  env->pc_delay = env->reg[26];
466
  env->delay_insn = 1;
467
}
468
 
469
__or_dynop void op_move_gpr27_pc_delay(void)
470
{
471
  env->pc_delay = env->reg[27];
472
  env->delay_insn = 1;
473
}
474
 
475
__or_dynop void op_move_gpr28_pc_delay(void)
476
{
477
  env->pc_delay = env->reg[28];
478
  env->delay_insn = 1;
479
}
480
 
481
__or_dynop void op_move_gpr29_pc_delay(void)
482
{
483
  env->pc_delay = env->reg[29];
484
  env->delay_insn = 1;
485
}
486
 
487
__or_dynop void op_move_gpr30_pc_delay(void)
488
{
489
  env->pc_delay = env->reg[30];
490
  env->delay_insn = 1;
491
}
492
 
493
__or_dynop void op_move_gpr31_pc_delay(void)
494
{
495
  env->pc_delay = env->reg[31];
496
  env->delay_insn = 1;
497
}
498
 
499
#define OP_FILE "op_1t_op.h"
500
#include "op_1t.h"
501
#undef OP_FILE
502 1658 nogj
 
503
#define OP_FILE "op_2t_op.h"
504
#include "op_2t.h"
505
#undef OP_FILE
506 1660 nogj
 
507
#define OP_FILE "op_3t_op.h"
508
#include "op_3t.h"
509
#undef OP_FILE
510
 
511 1661 nogj
#define OP_FILE "op_arith_op.h"
512 1452 nogj
#define OP_EXTRA
513
 
514
#define OP /
515 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
516 1452 nogj
#define OP_NAME div
517 1661 nogj
#include "op_3t.h"
518 1452 nogj
#undef OP_NAME
519
#undef OP_CAST
520
#undef OP
521
 
522
#define OP /
523 1661 nogj
#define OP_CAST(x) (x)
524 1452 nogj
#define OP_NAME divu
525 1661 nogj
#include "op_3t.h"
526 1452 nogj
#undef OP_NAME
527
#undef OP_CAST
528
#undef OP
529
 
530
#define OP *
531 1661 nogj
#define OP_CAST(x) (x)
532 1452 nogj
#define OP_NAME mulu
533 1661 nogj
#include "op_3t.h"
534 1452 nogj
#undef OP_NAME
535
#undef OP_CAST
536
#undef OP
537
 
538
#define OP -
539 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
540 1452 nogj
#define OP_NAME sub
541 1661 nogj
#include "op_3t.h"
542 1452 nogj
#undef OP_NAME
543
#undef OP_CAST
544
#undef OP
545
 
546
#undef OP_EXTRA
547
 
548
#define OP_EXTRA + ((env->sprs[SPR_SR] & SPR_SR_CY) >> 10)
549
#define OP +
550 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
551 1452 nogj
#define OP_NAME addc
552 1661 nogj
#include "op_3t.h"
553
#include "op_2t.h"
554 1452 nogj
#undef OP_NAME
555
#undef OP_CAST
556
#undef OP
557
 
558
#undef OP_EXTRA
559
#define OP_EXTRA
560
 
561
#define OP +
562 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
563 1452 nogj
#define OP_NAME add
564 1661 nogj
#include "op_3t.h"
565
#include "op_2t.h"
566 1452 nogj
#undef OP_NAME
567
#undef OP_CAST
568
#undef OP
569
 
570
#define OP &
571 1661 nogj
#define OP_CAST(x) (x)
572 1452 nogj
#define OP_NAME and
573 1661 nogj
#include "op_3t.h"
574
#include "op_2t.h"
575 1452 nogj
#undef OP_NAME
576
#undef OP_CAST
577
#undef OP
578
 
579
#define OP *
580 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
581 1452 nogj
#define OP_NAME mul
582 1661 nogj
#include "op_3t.h"
583
#include "op_2t.h"
584 1452 nogj
#undef OP_NAME
585
#undef OP_CAST
586
#undef OP
587
 
588
#define OP |
589 1661 nogj
#define OP_CAST(x) (x)
590 1452 nogj
#define OP_NAME or
591 1661 nogj
#include "op_3t.h"
592
#include "op_2t.h"
593 1452 nogj
#undef OP_NAME
594
#undef OP_CAST
595
#undef OP
596
 
597
#define OP <<
598 1661 nogj
#define OP_CAST(x) (x)
599 1452 nogj
#define OP_NAME sll
600 1661 nogj
#include "op_3t.h"
601
#include "op_2t.h"
602 1452 nogj
#undef OP_NAME
603
#undef OP_CAST
604
#undef OP
605
 
606
#define OP >>
607 1661 nogj
#define OP_CAST(x) (orreg_t)(x)
608 1452 nogj
#define OP_NAME sra
609 1661 nogj
#include "op_3t.h"
610
#include "op_2t.h"
611 1452 nogj
#undef OP_NAME
612
#undef OP_CAST
613
#undef OP
614
 
615
#define OP >>
616 1661 nogj
#define OP_CAST(x) (x)
617 1452 nogj
#define OP_NAME srl
618 1661 nogj
#include "op_3t.h"
619
#include "op_2t.h"
620 1452 nogj
#undef OP_NAME
621
#undef OP_CAST
622
#undef OP
623
 
624
#define OP ^
625 1661 nogj
#define OP_CAST(x) (x)
626 1452 nogj
#define OP_NAME xor
627 1661 nogj
#include "op_3t.h"
628
#include "op_2t.h"
629 1452 nogj
#undef OP_NAME
630
#undef OP_CAST
631
#undef OP
632
 
633
#undef OP_EXTRA
634 1661 nogj
#undef OP_FILE
635 1452 nogj
 
636 1662 nogj
#define OP_FILE "op_extend_op.h"
637
 
638 1452 nogj
#define EXT_NAME extbs
639
#define EXT_TYPE int8_t
640
#define EXT_CAST (orreg_t)
641 1662 nogj
#include "op_2t.h"
642 1452 nogj
#undef EXT_CAST
643
#undef EXT_TYPE
644
#undef EXT_NAME
645
 
646
#define EXT_NAME extbz
647
#define EXT_TYPE uint8_t
648
#define EXT_CAST (uorreg_t)
649 1662 nogj
#include "op_2t.h"
650 1452 nogj
#undef EXT_CAST
651
#undef EXT_TYPE
652
#undef EXT_NAME
653
 
654
#define EXT_NAME exths
655
#define EXT_TYPE int16_t
656
#define EXT_CAST (orreg_t)
657 1662 nogj
#include "op_2t.h"
658 1452 nogj
#undef EXT_CAST
659
#undef EXT_TYPE
660
#undef EXT_NAME
661
 
662
#define EXT_NAME exthz
663
#define EXT_TYPE uint16_t
664
#define EXT_CAST (uorreg_t)
665 1662 nogj
#include "op_2t.h"
666 1452 nogj
#undef EXT_CAST
667
#undef EXT_TYPE
668
#undef EXT_NAME
669
 
670 1662 nogj
#undef OP_FILE
671
 
672 1452 nogj
#define COMP ==
673
#define COMP_NAME sfeq
674
#define COMP_CAST(t) t
675
#include "op_comp_op.h"
676
#undef COMP_CAST
677
#undef COMP_NAME
678
#undef COMP
679
 
680
#define COMP !=
681
#define COMP_NAME sfne
682
#define COMP_CAST(t) t
683
#include "op_comp_op.h"
684
#undef COMP_CAST
685
#undef COMP_NAME
686
#undef COMP
687
 
688
#define COMP >
689
#define COMP_NAME sfgtu
690
#define COMP_CAST(t) t
691
#include "op_comp_op.h"
692
#undef COMP_CAST
693
#undef COMP_NAME
694
#undef COMP
695
 
696
#define COMP >=
697
#define COMP_NAME sfgeu
698
#define COMP_CAST(t) t
699
#include "op_comp_op.h"
700
#undef COMP_CAST
701
#undef COMP_NAME
702
#undef COMP
703
 
704
#define COMP <
705
#define COMP_NAME sfltu
706
#define COMP_CAST(t) t
707
#include "op_comp_op.h"
708
#undef COMP_CAST
709
#undef COMP_NAME
710
#undef COMP
711
 
712
#define COMP <=
713
#define COMP_NAME sfleu
714
#define COMP_CAST(t) t
715
#include "op_comp_op.h"
716
#undef COMP_CAST
717
#undef COMP_NAME
718
#undef COMP
719
 
720
#define COMP >
721
#define COMP_NAME sfgts
722
#define COMP_CAST(t) (orreg_t)t
723
#include "op_comp_op.h"
724
#undef COMP_CAST
725
#undef COMP_NAME
726
#undef COMP
727
 
728
#define COMP >=
729
#define COMP_NAME sfges
730
#define COMP_CAST(t) (orreg_t)t
731
#include "op_comp_op.h"
732
#undef COMP_CAST
733
#undef COMP_NAME
734
#undef COMP
735
 
736
#define COMP <
737
#define COMP_NAME sflts
738
#define COMP_CAST(t) (orreg_t)t
739
#include "op_comp_op.h"
740
#undef COMP_CAST
741
#undef COMP_NAME
742
#undef COMP
743
 
744
#define COMP <=
745
#define COMP_NAME sfles
746
#define COMP_CAST(t) (orreg_t)t
747
#include "op_comp_op.h"
748
#undef COMP_CAST
749
#undef COMP_NAME
750
#undef COMP
751
 
752 1657 nogj
#define OP_FILE "op_t_reg_mov_op.h"
753
#include "op_1t.h"
754
#undef OP_FILE
755 1452 nogj
 
756
#define SPR_T_NAME SPR_T
757
#define GPR_T_NAME GPR_T
758
 
759
#define SPR_T t0
760
#define GPR_T t0
761
#include "op_mftspr_op.h"
762
#undef GPR_T
763
 
764
#define GPR_T t1
765
#include "op_mftspr_op.h"
766
#undef GPR_T
767
 
768
#define GPR_T t2
769
#include "op_mftspr_op.h"
770
#undef GPR_T
771
#undef SPR_T
772
 
773
#define SPR_T t1
774
#define GPR_T t0
775
#include "op_mftspr_op.h"
776
#undef GPR_T
777
 
778
#define GPR_T t1
779
#include "op_mftspr_op.h"
780
#undef GPR_T
781
 
782
#define GPR_T t2
783
#include "op_mftspr_op.h"
784
#undef GPR_T
785
#undef SPR_T
786
 
787
#define SPR_T t2
788
#define GPR_T t0
789
#include "op_mftspr_op.h"
790
#undef GPR_T
791
 
792
#define GPR_T t1
793
#include "op_mftspr_op.h"
794
#undef GPR_T
795
 
796
#define GPR_T t2
797
#include "op_mftspr_op.h"
798
#undef GPR_T
799
#undef SPR_T
800
 
801
#undef GPR_T_NAME
802
#undef SPR_T_NAME
803
 
804
#define SPR_T_NAME imm
805
#define GPR_T_NAME GPR_T
806
 
807
#define SPR_T 0
808
 
809
#define GPR_T t0
810
#include "op_mftspr_op.h"
811
#undef GPR_T
812
 
813
#define GPR_T t1
814
#include "op_mftspr_op.h"
815
#undef GPR_T
816
 
817
#define GPR_T t2
818
#include "op_mftspr_op.h"
819
#undef GPR_T
820
#undef SPR_T
821
 
822
#undef SPR_T_NAME
823
#undef GPR_T_NAME
824
 
825
#define ONLY_MTSPR
826
#define SPR_T_NAME SPR_T
827
#define GPR_T_NAME clear
828
 
829
#define GPR_T 0
830
 
831
#define SPR_T t0
832
#include "op_mftspr_op.h"
833
#undef SPR_T
834
 
835
#define SPR_T t1
836
#include "op_mftspr_op.h"
837
#undef SPR_T
838
 
839
#define SPR_T t2
840
#include "op_mftspr_op.h"
841
#undef SPR_T
842
 
843
#undef GPR_T
844
 
845
#undef SPR_T_NAME
846
#undef GPR_T_NAME
847
 
848
#define SPR_T_NAME imm
849
#define GPR_T_NAME clear
850
#define GPR_T 0
851
#define SPR_T 0
852
#include "op_mftspr_op.h"
853
#undef SPR_T
854
#undef GPR_T
855
#undef GPR_T_NAME
856
#undef SPR_T_NAME
857
 
858
#undef ONLY_MTSPR
859
 
860
#define OP +=
861
#define OP_NAME mac
862
#include "op_mac_op.h"
863
#undef OP_NAME
864
#undef OP
865
 
866
#define OP -=
867
#define OP_NAME msb
868
#include "op_mac_op.h"
869
#undef OP_NAME
870
#undef OP
871
 
872
#define LS_OP_NAME lbz
873
#define LS_OP_CAST
874
#define LS_OP_FUNC eval_mem8
875
#include "op_lwhb_op.h"
876
#undef LS_OP_FUNC
877
#undef LS_OP_CAST
878
#undef LS_OP_NAME
879
 
880
#define LS_OP_NAME lbs
881
#define LS_OP_CAST (int8_t)
882
#define LS_OP_FUNC eval_mem8
883
#include "op_lwhb_op.h"
884
#undef LS_OP_FUNC
885
#undef LS_OP_CAST
886
#undef LS_OP_NAME
887
 
888
#define LS_OP_NAME lhz
889
#define LS_OP_CAST
890
#define LS_OP_FUNC eval_mem16
891
#include "op_lwhb_op.h"
892
#undef LS_OP_FUNC
893
#undef LS_OP_CAST
894
#undef LS_OP_NAME
895
 
896
#define LS_OP_NAME lhs
897
#define LS_OP_CAST (int16_t)
898
#define LS_OP_FUNC eval_mem16
899
#include "op_lwhb_op.h"
900
#undef LS_OP_FUNC
901
#undef LS_OP_CAST
902
#undef LS_OP_NAME
903
 
904
#define LS_OP_NAME lwz
905
#define LS_OP_CAST
906
#define LS_OP_FUNC eval_mem32
907
#include "op_lwhb_op.h"
908
#undef LS_OP_FUNC
909
#undef LS_OP_CAST
910
#undef LS_OP_NAME
911
 
912
#define LS_OP_NAME lws
913
#define LS_OP_CAST (int32_t)
914
#define LS_OP_FUNC eval_mem32
915
#include "op_lwhb_op.h"
916
#undef LS_OP_FUNC
917
#undef LS_OP_CAST
918
#undef LS_OP_NAME
919
 
920
#define S_OP_NAME sb
921
#define S_FUNC set_mem8
922
#include "op_swhb_op.h"
923
#undef S_FUNC
924
#undef S_OP_NAME
925
 
926
#define S_OP_NAME sh
927
#define S_FUNC set_mem16
928
#include "op_swhb_op.h"
929
#undef S_FUNC
930
#undef S_OP_NAME
931
 
932
#define S_OP_NAME sw
933
#define S_FUNC set_mem32
934
#include "op_swhb_op.h"
935
#undef S_FUNC
936
#undef S_OP_NAME
937
 
938
__or_dynop void op_join_mem_cycles(void)
939
{
940
  join_mem_cycles();
941
}
942
 
943
__or_dynop void op_store_link_addr_gpr(void)
944
{
945
  env->reg[LINK_REGNO] = get_pc() + 8;
946
}
947
 
948
__or_dynop void op_prep_rfe(void)
949
{
950
  env->sprs[SPR_SR] = env->sprs[SPR_ESR_BASE] | SPR_SR_FO;
951
  env->sprs[SPR_PPC] = get_pc();
952 1481 nogj
  env->ts_current = 1;
953
  set_pc(env->sprs[SPR_EPCR_BASE] - 4);
954 1452 nogj
}
955
 
956
static inline void prep_except(oraddr_t epcr_base)
957
{
958
  env->sprs[SPR_EPCR_BASE] = epcr_base;
959
 
960
  env->sprs[SPR_ESR_BASE] = env->sprs[SPR_SR];
961
 
962
  /* Address translation is always disabled when starting exception. */
963
  env->sprs[SPR_SR] &= ~SPR_SR_DME;
964
  env->sprs[SPR_SR] &= ~SPR_SR_IME;
965
 
966
  env->sprs[SPR_SR] &= ~SPR_SR_OVE;   /* Disable overflow flag exception. */
967
 
968
  env->sprs[SPR_SR] |= SPR_SR_SM;     /* SUPV mode */
969
  env->sprs[SPR_SR] &= ~(SPR_SR_IEE | SPR_SR_TEE);    /* Disable interrupts. */
970
}
971
 
972
__or_dynop void op_set_except_pc(void)
973
{
974
  set_pc(OP_PARAM1);
975
}
976
 
977
/* Before the code in op_{sys,trap}{,_delay} gets run, the scheduler runs.
978
 * Therefore the pc will point to the instruction after the l.sys or l.trap
979
 * instruction */
980
__or_dynop void op_prep_sys_delay(void)
981
{
982
  env->delay_insn = 0;
983 1481 nogj
  env->ts_current = 1;
984 1452 nogj
  prep_except(get_pc() - 4);
985 1481 nogj
  set_pc(EXCEPT_SYSCALL - 4);
986 1452 nogj
}
987
 
988
__or_dynop void op_prep_sys(void)
989
{
990 1481 nogj
  env->ts_current = 1;
991 1452 nogj
  prep_except(get_pc() + 4);
992 1481 nogj
  set_pc(EXCEPT_SYSCALL - 4);
993 1452 nogj
}
994
 
995
__or_dynop void op_prep_trap_delay(void)
996
{
997 1481 nogj
  env->ts_current = 1;
998 1452 nogj
  env->delay_insn = 0;
999
  prep_except(get_pc() - 4);
1000 1481 nogj
  set_pc(EXCEPT_TRAP - 4);
1001 1452 nogj
}
1002
 
1003
__or_dynop void op_prep_trap(void)
1004
{
1005 1481 nogj
  env->ts_current = 1;
1006 1452 nogj
  prep_except(get_pc());
1007 1481 nogj
  set_pc(EXCEPT_TRAP - 4);
1008 1452 nogj
}
1009
 
1010
/* FIXME: This `instruction' should be split up like the l.trap and l.sys
1011
 * instructions are done */
1012
__or_dynop void op_illegal_delay(void)
1013
{
1014
  env->delay_insn = 0;
1015 1481 nogj
  env->ts_current = 1;
1016 1452 nogj
  env->sprs[SPR_EEAR_BASE] = get_pc() - 4;
1017 1481 nogj
  do_jump(EXCEPT_ILLEGAL - 4);
1018 1452 nogj
}
1019
 
1020
__or_dynop void op_illegal(void)
1021
{
1022
  env->sprs[SPR_EEAR_BASE] = get_pc();
1023 1481 nogj
  do_jump(EXCEPT_ILLEGAL);
1024 1452 nogj
}
1025
 
1026
__or_dynop void op_do_sched(void)
1027
{
1028 1481 nogj
  HANDLE_SCHED(do_sched_wrap, "no_sched");
1029 1452 nogj
}
1030
 
1031 1481 nogj
__or_dynop void op_do_sched_delay(void)
1032
{
1033
  HANDLE_SCHED(do_sched_wrap_delay, "no_sched_delay");
1034
}
1035
 
1036 1452 nogj
__or_dynop void op_macc(void)
1037
{
1038
  env->sprs[SPR_MACLO] = 0;
1039
  env->sprs[SPR_MACHI] = 0;
1040
}
1041
 
1042
__or_dynop void op_store_insn_ea(void)
1043
{
1044
  env->insn_ea = OP_PARAM1;
1045
}
1046
 

powered by: WebSVN 2.1.0

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