1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
/*
* Alpha emulation cpu micro-operations for qemu.
*
* Copyright (c) 2007 Jocelyn Mayer
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define DEBUG_OP
#include "config.h"
#include "exec.h"
#include "host-utils.h"
#include "op_helper.h"
#define REG 0
#include "op_template.h"
#define REG 1
#include "op_template.h"
#define REG 2
#include "op_template.h"
#define REG 3
#include "op_template.h"
#define REG 4
#include "op_template.h"
#define REG 5
#include "op_template.h"
#define REG 6
#include "op_template.h"
#define REG 7
#include "op_template.h"
#define REG 8
#include "op_template.h"
#define REG 9
#include "op_template.h"
#define REG 10
#include "op_template.h"
#define REG 11
#include "op_template.h"
#define REG 12
#include "op_template.h"
#define REG 13
#include "op_template.h"
#define REG 14
#include "op_template.h"
#define REG 15
#include "op_template.h"
#define REG 16
#include "op_template.h"
#define REG 17
#include "op_template.h"
#define REG 18
#include "op_template.h"
#define REG 19
#include "op_template.h"
#define REG 20
#include "op_template.h"
#define REG 21
#include "op_template.h"
#define REG 22
#include "op_template.h"
#define REG 23
#include "op_template.h"
#define REG 24
#include "op_template.h"
#define REG 25
#include "op_template.h"
#define REG 26
#include "op_template.h"
#define REG 27
#include "op_template.h"
#define REG 28
#include "op_template.h"
#define REG 29
#include "op_template.h"
#define REG 30
#include "op_template.h"
#define REG 31
#include "op_template.h"
/* Debug stuff */
void OPPROTO op_no_op (void)
{
#if !defined (DEBUG_OP)
__asm__ __volatile__("nop" : : : "memory");
#endif
RETURN();
}
/* Load and stores */
#define MEMSUFFIX _raw
#include "op_mem.h"
#if !defined(CONFIG_USER_ONLY)
#define MEMSUFFIX _kernel
#include "op_mem.h"
#define MEMSUFFIX _executive
#include "op_mem.h"
#define MEMSUFFIX _supervisor
#include "op_mem.h"
#define MEMSUFFIX _user
#include "op_mem.h"
/* This is used for pal modes */
#define MEMSUFFIX _data
#include "op_mem.h"
#endif
/* Misc */
void OPPROTO op_load_fpcr (void)
{
helper_load_fpcr();
RETURN();
}
void OPPROTO op_store_fpcr (void)
{
helper_store_fpcr();
RETURN();
}
/* Tests */
#if 0 // Qemu does not know how to do this...
void OPPROTO op_bcond (void)
{
if (T0)
env->pc = T1 & ~3;
else
env->pc = PARAM(1);
RETURN();
}
#else
void OPPROTO op_bcond (void)
{
if (T0)
env->pc = T1 & ~3;
else
env->pc = ((uint64_t)PARAM(1) << 32) | (uint64_t)PARAM(2);
RETURN();
}
#endif
/* IEEE floating point arithmetic */
/* S floating (single) */
void OPPROTO op_adds (void)
{
FT0 = float32_add(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_subs (void)
{
FT0 = float32_sub(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_muls (void)
{
FT0 = float32_mul(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_divs (void)
{
FT0 = float32_div(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_sqrts (void)
{
helper_sqrts();
RETURN();
}
void OPPROTO op_cpys (void)
{
helper_cpys();
RETURN();
}
void OPPROTO op_cpysn (void)
{
helper_cpysn();
RETURN();
}
void OPPROTO op_cpyse (void)
{
helper_cpyse();
RETURN();
}
void OPPROTO op_itofs (void)
{
helper_itofs();
RETURN();
}
void OPPROTO op_ftois (void)
{
helper_ftois();
RETURN();
}
/* T floating (double) */
void OPPROTO op_addt (void)
{
FT0 = float64_add(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_subt (void)
{
FT0 = float64_sub(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_mult (void)
{
FT0 = float64_mul(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_divt (void)
{
FT0 = float64_div(FT0, FT1, &FP_STATUS);
RETURN();
}
void OPPROTO op_sqrtt (void)
{
helper_sqrtt();
RETURN();
}
void OPPROTO op_cmptun (void)
{
helper_cmptun();
RETURN();
}
void OPPROTO op_cmpteq (void)
{
helper_cmpteq();
RETURN();
}
void OPPROTO op_cmptle (void)
{
helper_cmptle();
RETURN();
}
void OPPROTO op_cmptlt (void)
{
helper_cmptlt();
RETURN();
}
void OPPROTO op_itoft (void)
{
helper_itoft();
RETURN();
}
void OPPROTO op_ftoit (void)
{
helper_ftoit();
RETURN();
}
/* VAX floating point arithmetic */
/* F floating */
void OPPROTO op_addf (void)
{
helper_addf();
RETURN();
}
void OPPROTO op_subf (void)
{
helper_subf();
RETURN();
}
void OPPROTO op_mulf (void)
{
helper_mulf();
RETURN();
}
void OPPROTO op_divf (void)
{
helper_divf();
RETURN();
}
void OPPROTO op_sqrtf (void)
{
helper_sqrtf();
RETURN();
}
void OPPROTO op_cmpfeq (void)
{
helper_cmpfeq();
RETURN();
}
void OPPROTO op_cmpfne (void)
{
helper_cmpfne();
RETURN();
}
void OPPROTO op_cmpflt (void)
{
helper_cmpflt();
RETURN();
}
void OPPROTO op_cmpfle (void)
{
helper_cmpfle();
RETURN();
}
void OPPROTO op_cmpfgt (void)
{
helper_cmpfgt();
RETURN();
}
void OPPROTO op_cmpfge (void)
{
helper_cmpfge();
RETURN();
}
void OPPROTO op_itoff (void)
{
helper_itoff();
RETURN();
}
/* G floating */
void OPPROTO op_addg (void)
{
helper_addg();
RETURN();
}
void OPPROTO op_subg (void)
{
helper_subg();
RETURN();
}
void OPPROTO op_mulg (void)
{
helper_mulg();
RETURN();
}
void OPPROTO op_divg (void)
{
helper_divg();
RETURN();
}
void OPPROTO op_sqrtg (void)
{
helper_sqrtg();
RETURN();
}
void OPPROTO op_cmpgeq (void)
{
helper_cmpgeq();
RETURN();
}
void OPPROTO op_cmpglt (void)
{
helper_cmpglt();
RETURN();
}
void OPPROTO op_cmpgle (void)
{
helper_cmpgle();
RETURN();
}
/* Floating point format conversion */
void OPPROTO op_cvtst (void)
{
FT0 = (float)FT0;
RETURN();
}
void OPPROTO op_cvtqs (void)
{
helper_cvtqs();
RETURN();
}
void OPPROTO op_cvtts (void)
{
FT0 = (float)FT0;
RETURN();
}
void OPPROTO op_cvttq (void)
{
helper_cvttq();
RETURN();
}
void OPPROTO op_cvtqt (void)
{
helper_cvtqt();
RETURN();
}
void OPPROTO op_cvtqf (void)
{
helper_cvtqf();
RETURN();
}
void OPPROTO op_cvtgf (void)
{
helper_cvtgf();
RETURN();
}
void OPPROTO op_cvtgd (void)
{
helper_cvtgd();
RETURN();
}
void OPPROTO op_cvtgq (void)
{
helper_cvtgq();
RETURN();
}
void OPPROTO op_cvtqg (void)
{
helper_cvtqg();
RETURN();
}
void OPPROTO op_cvtdg (void)
{
helper_cvtdg();
RETURN();
}
void OPPROTO op_cvtlq (void)
{
helper_cvtlq();
RETURN();
}
void OPPROTO op_cvtql (void)
{
helper_cvtql();
RETURN();
}
void OPPROTO op_cvtqlv (void)
{
helper_cvtqlv();
RETURN();
}
void OPPROTO op_cvtqlsv (void)
{
helper_cvtqlsv();
RETURN();
}
/* PALcode support special instructions */
#if !defined (CONFIG_USER_ONLY)
void OPPROTO op_hw_rei (void)
{
env->pc = env->ipr[IPR_EXC_ADDR] & ~3;
env->ipr[IPR_EXC_ADDR] = env->ipr[IPR_EXC_ADDR] & 1;
/* XXX: re-enable interrupts and memory mapping */
RETURN();
}
void OPPROTO op_hw_ret (void)
{
env->pc = T0 & ~3;
env->ipr[IPR_EXC_ADDR] = T0 & 1;
/* XXX: re-enable interrupts and memory mapping */
RETURN();
}
void OPPROTO op_mfpr (void)
{
helper_mfpr(PARAM(1));
RETURN();
}
void OPPROTO op_mtpr (void)
{
helper_mtpr(PARAM(1));
RETURN();
}
void OPPROTO op_set_alt_mode (void)
{
env->saved_mode = env->ps & 0xC;
env->ps = (env->ps & ~0xC) | (env->ipr[IPR_ALT_MODE] & 0xC);
RETURN();
}
void OPPROTO op_restore_mode (void)
{
env->ps = (env->ps & ~0xC) | env->saved_mode;
RETURN();
}
void OPPROTO op_ld_phys_to_virt (void)
{
helper_ld_phys_to_virt();
RETURN();
}
void OPPROTO op_st_phys_to_virt (void)
{
helper_st_phys_to_virt();
RETURN();
}
#endif /* !defined (CONFIG_USER_ONLY) */
|