4
Copyright (C) 2003 Thomas M. Ogrisegg <tom@fnord.at>
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2 of the License, or (at your option) any later version.
11
This library 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 GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#define REG (env->gregs[0])
26
#include "op_template.h"
28
#define REG (env->gregs[1])
29
#include "op_template.h"
31
#define REG (env->gregs[2])
32
#include "op_template.h"
34
#define REG (env->gregs[3])
35
#include "op_template.h"
37
#define REG (env->gregs[4])
38
#include "op_template.h"
40
#define REG (env->gregs[5])
41
#include "op_template.h"
43
#define REG (env->gregs[6])
44
#include "op_template.h"
46
#define REG (env->gregs[7])
47
#include "op_template.h"
49
#define REG (REGWPTR[16])
50
#include "op_template.h"
52
#define REG (REGWPTR[17])
53
#include "op_template.h"
55
#define REG (REGWPTR[18])
56
#include "op_template.h"
58
#define REG (REGWPTR[19])
59
#include "op_template.h"
61
#define REG (REGWPTR[20])
62
#include "op_template.h"
64
#define REG (REGWPTR[21])
65
#include "op_template.h"
67
#define REG (REGWPTR[22])
68
#include "op_template.h"
70
#define REG (REGWPTR[23])
71
#include "op_template.h"
73
#define REG (REGWPTR[8])
74
#include "op_template.h"
76
#define REG (REGWPTR[9])
77
#include "op_template.h"
79
#define REG (REGWPTR[10])
80
#include "op_template.h"
82
#define REG (REGWPTR[11])
83
#include "op_template.h"
85
#define REG (REGWPTR[12])
86
#include "op_template.h"
88
#define REG (REGWPTR[13])
89
#include "op_template.h"
91
#define REG (REGWPTR[14])
92
#include "op_template.h"
94
#define REG (REGWPTR[15])
95
#include "op_template.h"
97
#define REG (REGWPTR[0])
98
#include "op_template.h"
100
#define REG (REGWPTR[1])
101
#include "op_template.h"
103
#define REG (REGWPTR[2])
104
#include "op_template.h"
106
#define REG (REGWPTR[3])
107
#include "op_template.h"
109
#define REG (REGWPTR[4])
110
#include "op_template.h"
112
#define REG (REGWPTR[5])
113
#include "op_template.h"
115
#define REG (REGWPTR[6])
116
#include "op_template.h"
118
#define REG (REGWPTR[7])
119
#include "op_template.h"
122
#define REG (env->fpr[0])
123
#include "fop_template.h"
125
#define REG (env->fpr[1])
126
#include "fop_template.h"
128
#define REG (env->fpr[2])
129
#include "fop_template.h"
131
#define REG (env->fpr[3])
132
#include "fop_template.h"
134
#define REG (env->fpr[4])
135
#include "fop_template.h"
137
#define REG (env->fpr[5])
138
#include "fop_template.h"
140
#define REG (env->fpr[6])
141
#include "fop_template.h"
143
#define REG (env->fpr[7])
144
#include "fop_template.h"
146
#define REG (env->fpr[8])
147
#include "fop_template.h"
149
#define REG (env->fpr[9])
150
#include "fop_template.h"
152
#define REG (env->fpr[10])
153
#include "fop_template.h"
155
#define REG (env->fpr[11])
156
#include "fop_template.h"
158
#define REG (env->fpr[12])
159
#include "fop_template.h"
161
#define REG (env->fpr[13])
162
#include "fop_template.h"
164
#define REG (env->fpr[14])
165
#include "fop_template.h"
167
#define REG (env->fpr[15])
168
#include "fop_template.h"
170
#define REG (env->fpr[16])
171
#include "fop_template.h"
173
#define REG (env->fpr[17])
174
#include "fop_template.h"
176
#define REG (env->fpr[18])
177
#include "fop_template.h"
179
#define REG (env->fpr[19])
180
#include "fop_template.h"
182
#define REG (env->fpr[20])
183
#include "fop_template.h"
185
#define REG (env->fpr[21])
186
#include "fop_template.h"
188
#define REG (env->fpr[22])
189
#include "fop_template.h"
191
#define REG (env->fpr[23])
192
#include "fop_template.h"
194
#define REG (env->fpr[24])
195
#include "fop_template.h"
197
#define REG (env->fpr[25])
198
#include "fop_template.h"
200
#define REG (env->fpr[26])
201
#include "fop_template.h"
203
#define REG (env->fpr[27])
204
#include "fop_template.h"
206
#define REG (env->fpr[28])
207
#include "fop_template.h"
209
#define REG (env->fpr[29])
210
#include "fop_template.h"
212
#define REG (env->fpr[30])
213
#include "fop_template.h"
215
#define REG (env->fpr[31])
216
#include "fop_template.h"
218
#ifdef TARGET_SPARC64
220
#define REG (env->fpr[32])
221
#include "fop_template.h"
223
#define REG (env->fpr[34])
224
#include "fop_template.h"
226
#define REG (env->fpr[36])
227
#include "fop_template.h"
229
#define REG (env->fpr[38])
230
#include "fop_template.h"
232
#define REG (env->fpr[40])
233
#include "fop_template.h"
235
#define REG (env->fpr[42])
236
#include "fop_template.h"
238
#define REG (env->fpr[44])
239
#include "fop_template.h"
241
#define REG (env->fpr[46])
242
#include "fop_template.h"
244
#define REG (env->fpr[47])
245
#include "fop_template.h"
247
#define REG (env->fpr[50])
248
#include "fop_template.h"
250
#define REG (env->fpr[52])
251
#include "fop_template.h"
253
#define REG (env->fpr[54])
254
#include "fop_template.h"
256
#define REG (env->fpr[56])
257
#include "fop_template.h"
259
#define REG (env->fpr[58])
260
#include "fop_template.h"
262
#define REG (env->fpr[60])
263
#include "fop_template.h"
265
#define REG (env->fpr[62])
266
#include "fop_template.h"
269
#ifdef TARGET_SPARC64
270
#ifdef WORDS_BIGENDIAN
271
typedef union UREG64 {
272
struct { uint16_t v3, v2, v1, v0; } w;
273
struct { uint32_t v1, v0; } l;
277
typedef union UREG64 {
278
struct { uint16_t v0, v1, v2, v3; } w;
279
struct { uint32_t v0, v1; } l;
292
void OPPROTO op_movq_T0_im64(void)
297
void OPPROTO op_movq_T1_im64(void)
302
#define XFLAG_SET(x) ((env->xcc&x)?1:0)
305
#define EIP (env->pc)
308
#define FLAG_SET(x) ((env->psr&x)?1:0)
310
void OPPROTO op_movl_T0_0(void)
315
void OPPROTO op_movl_T0_im(void)
317
T0 = (uint32_t)PARAM1;
320
void OPPROTO op_movl_T1_im(void)
322
T1 = (uint32_t)PARAM1;
325
void OPPROTO op_movl_T2_im(void)
327
T2 = (uint32_t)PARAM1;
330
void OPPROTO op_movl_T0_sim(void)
332
T0 = (int32_t)PARAM1;
335
void OPPROTO op_movl_T1_sim(void)
337
T1 = (int32_t)PARAM1;
340
void OPPROTO op_movl_T2_sim(void)
342
T2 = (int32_t)PARAM1;
345
void OPPROTO op_movl_T0_env(void)
347
T0 = *(uint32_t *)((char *)env + PARAM1);
350
void OPPROTO op_movl_env_T0(void)
352
*(uint32_t *)((char *)env + PARAM1) = T0;
355
void OPPROTO op_movtl_T0_env(void)
357
T0 = *(target_ulong *)((char *)env + PARAM1);
360
void OPPROTO op_movtl_env_T0(void)
362
*(target_ulong *)((char *)env + PARAM1) = T0;
365
void OPPROTO op_add_T1_T0(void)
370
void OPPROTO op_add_T1_T0_cc(void)
377
#ifdef TARGET_SPARC64
378
if (!(T0 & 0xffffffff))
379
env->psr |= PSR_ZERO;
380
if ((int32_t) T0 < 0)
382
if ((T0 & 0xffffffff) < (src1 & 0xffffffff))
383
env->psr |= PSR_CARRY;
384
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
385
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
390
env->xcc |= PSR_ZERO;
391
if ((int64_t) T0 < 0)
394
env->xcc |= PSR_CARRY;
395
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
399
env->psr |= PSR_ZERO;
400
if ((int32_t) T0 < 0)
403
env->psr |= PSR_CARRY;
404
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
410
void OPPROTO op_addx_T1_T0(void)
412
T0 += T1 + FLAG_SET(PSR_CARRY);
415
void OPPROTO op_addx_T1_T0_cc(void)
419
if (FLAG_SET(PSR_CARRY))
423
#ifdef TARGET_SPARC64
424
if ((T0 & 0xffffffff) <= (src1 & 0xffffffff))
425
env->psr |= PSR_CARRY;
428
env->xcc |= PSR_CARRY;
431
env->psr |= PSR_CARRY;
438
#ifdef TARGET_SPARC64
439
if ((T0 & 0xffffffff) < (src1 & 0xffffffff))
440
env->psr |= PSR_CARRY;
443
env->xcc |= PSR_CARRY;
446
env->psr |= PSR_CARRY;
449
#ifdef TARGET_SPARC64
450
if (!(T0 & 0xffffffff))
451
env->psr |= PSR_ZERO;
452
if ((int32_t) T0 < 0)
454
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
455
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
459
env->xcc |= PSR_ZERO;
460
if ((int64_t) T0 < 0)
462
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
466
env->psr |= PSR_ZERO;
467
if ((int32_t) T0 < 0)
469
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
475
void OPPROTO op_tadd_T1_T0_cc(void)
482
#ifdef TARGET_SPARC64
483
if (!(T0 & 0xffffffff))
484
env->psr |= PSR_ZERO;
485
if ((int32_t) T0 < 0)
487
if ((T0 & 0xffffffff) < (src1 & 0xffffffff))
488
env->psr |= PSR_CARRY;
489
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
490
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
492
if ((src1 & 0x03) || (T1 & 0x03))
497
env->xcc |= PSR_ZERO;
498
if ((int64_t) T0 < 0)
501
env->xcc |= PSR_CARRY;
502
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1ULL << 63))
506
env->psr |= PSR_ZERO;
507
if ((int32_t) T0 < 0)
510
env->psr |= PSR_CARRY;
511
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
513
if ((src1 & 0x03) || (T1 & 0x03))
519
void OPPROTO op_tadd_T1_T0_ccTV(void)
523
if ((T0 & 0x03) || (T1 & 0x03)) {
524
raise_exception(TT_TOVF);
532
#ifdef TARGET_SPARC64
533
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff) ^ -1) &
534
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
535
raise_exception(TT_TOVF);
537
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
538
raise_exception(TT_TOVF);
542
#ifdef TARGET_SPARC64
543
if (!(T0 & 0xffffffff))
544
env->psr |= PSR_ZERO;
545
if ((int32_t) T0 < 0)
547
if ((T0 & 0xffffffff) < (src1 & 0xffffffff))
548
env->psr |= PSR_CARRY;
552
env->xcc |= PSR_ZERO;
553
if ((int64_t) T0 < 0)
556
env->xcc |= PSR_CARRY;
559
env->psr |= PSR_ZERO;
560
if ((int32_t) T0 < 0)
563
env->psr |= PSR_CARRY;
568
void OPPROTO op_sub_T1_T0(void)
573
void OPPROTO op_sub_T1_T0_cc(void)
580
#ifdef TARGET_SPARC64
581
if (!(T0 & 0xffffffff))
582
env->psr |= PSR_ZERO;
583
if ((int32_t) T0 < 0)
585
if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
586
env->psr |= PSR_CARRY;
587
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
588
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
593
env->xcc |= PSR_ZERO;
594
if ((int64_t) T0 < 0)
597
env->xcc |= PSR_CARRY;
598
if (((src1 ^ T1) & (src1 ^ T0)) & (1ULL << 63))
602
env->psr |= PSR_ZERO;
603
if ((int32_t) T0 < 0)
606
env->psr |= PSR_CARRY;
607
if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
613
void OPPROTO op_subx_T1_T0(void)
615
T0 -= T1 + FLAG_SET(PSR_CARRY);
618
void OPPROTO op_subx_T1_T0_cc(void)
622
if (FLAG_SET(PSR_CARRY))
626
#ifdef TARGET_SPARC64
627
if ((src1 & 0xffffffff) <= (T1 & 0xffffffff))
628
env->psr |= PSR_CARRY;
631
env->xcc |= PSR_CARRY;
634
env->psr |= PSR_CARRY;
641
#ifdef TARGET_SPARC64
642
if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
643
env->psr |= PSR_CARRY;
646
env->xcc |= PSR_CARRY;
649
env->psr |= PSR_CARRY;
652
#ifdef TARGET_SPARC64
653
if (!(T0 & 0xffffffff))
654
env->psr |= PSR_ZERO;
655
if ((int32_t) T0 < 0)
657
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
658
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
662
env->xcc |= PSR_ZERO;
663
if ((int64_t) T0 < 0)
665
if (((src1 ^ T1) & (src1 ^ T0)) & (1ULL << 63))
669
env->psr |= PSR_ZERO;
670
if ((int32_t) T0 < 0)
672
if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
678
void OPPROTO op_tsub_T1_T0_cc(void)
685
#ifdef TARGET_SPARC64
686
if (!(T0 & 0xffffffff))
687
env->psr |= PSR_ZERO;
688
if ((int32_t) T0 < 0)
690
if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
691
env->psr |= PSR_CARRY;
692
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
693
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
695
if ((src1 & 0x03) || (T1 & 0x03))
700
env->xcc |= PSR_ZERO;
701
if ((int64_t) T0 < 0)
704
env->xcc |= PSR_CARRY;
705
if (((src1 ^ T1) & (src1 ^ T0)) & (1ULL << 63))
709
env->psr |= PSR_ZERO;
710
if ((int32_t) T0 < 0)
713
env->psr |= PSR_CARRY;
714
if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
716
if ((src1 & 0x03) || (T1 & 0x03))
722
void OPPROTO op_tsub_T1_T0_ccTV(void)
726
if ((T0 & 0x03) || (T1 & 0x03))
727
raise_exception(TT_TOVF);
732
#ifdef TARGET_SPARC64
733
if ((((src1 & 0xffffffff) ^ (T1 & 0xffffffff)) &
734
((src1 & 0xffffffff) ^ (T0 & 0xffffffff))) & (1 << 31))
735
raise_exception(TT_TOVF);
737
if (((src1 ^ T1) & (src1 ^ T0)) & (1 << 31))
738
raise_exception(TT_TOVF);
742
#ifdef TARGET_SPARC64
743
if (!(T0 & 0xffffffff))
744
env->psr |= PSR_ZERO;
745
if ((int32_t) T0 < 0)
747
if ((src1 & 0xffffffff) < (T1 & 0xffffffff))
748
env->psr |= PSR_CARRY;
752
env->xcc |= PSR_ZERO;
753
if ((int64_t) T0 < 0)
756
env->xcc |= PSR_CARRY;
759
env->psr |= PSR_ZERO;
760
if ((int32_t) T0 < 0)
763
env->psr |= PSR_CARRY;
768
void OPPROTO op_and_T1_T0(void)
773
void OPPROTO op_or_T1_T0(void)
778
void OPPROTO op_xor_T1_T0(void)
783
void OPPROTO op_andn_T1_T0(void)
788
void OPPROTO op_orn_T1_T0(void)
793
void OPPROTO op_xnor_T1_T0(void)
798
void OPPROTO op_umul_T1_T0(void)
801
res = (uint64_t) T0 * (uint64_t) T1;
802
#ifdef TARGET_SPARC64
805
T0 = res & 0xffffffff;
810
void OPPROTO op_smul_T1_T0(void)
813
res = (int64_t) ((int32_t) T0) * (int64_t) ((int32_t) T1);
814
#ifdef TARGET_SPARC64
817
T0 = res & 0xffffffff;
822
void OPPROTO op_mulscc_T1_T0(void)
824
unsigned int b1, N, V, b2;
827
N = FLAG_SET(PSR_NEG);
828
V = FLAG_SET(PSR_OVF);
831
T0 = (b1 << 31) | (T0 >> 1);
834
/* do addition and update flags */
839
env->psr |= PSR_ZERO;
840
if ((int32_t) T0 < 0)
843
env->psr |= PSR_CARRY;
844
if (((src1 ^ T1 ^ -1) & (src1 ^ T0)) & (1 << 31))
846
env->y = (b2 << 31) | (env->y >> 1);
850
void OPPROTO op_udiv_T1_T0(void)
855
x0 = T0 | ((uint64_t) (env->y) << 32);
859
raise_exception(TT_DIV_ZERO);
863
if (x0 > 0xffffffff) {
873
void OPPROTO op_sdiv_T1_T0(void)
878
x0 = T0 | ((int64_t) (env->y) << 32);
882
raise_exception(TT_DIV_ZERO);
886
if ((int32_t) x0 != x0) {
887
T0 = x0 < 0? 0x80000000: 0x7fffffff;
896
void OPPROTO op_div_cc(void)
899
#ifdef TARGET_SPARC64
901
env->psr |= PSR_ZERO;
902
if ((int32_t) T0 < 0)
909
env->xcc |= PSR_ZERO;
910
if ((int64_t) T0 < 0)
914
env->psr |= PSR_ZERO;
915
if ((int32_t) T0 < 0)
923
#ifdef TARGET_SPARC64
924
void OPPROTO op_mulx_T1_T0(void)
930
void OPPROTO op_udivx_T1_T0(void)
933
raise_exception(TT_DIV_ZERO);
939
void OPPROTO op_sdivx_T1_T0(void)
942
raise_exception(TT_DIV_ZERO);
944
if (T0 == INT64_MIN && T1 == -1)
947
T0 /= (target_long) T1;
952
void OPPROTO op_logic_T0_cc(void)
955
#ifdef TARGET_SPARC64
956
if (!(T0 & 0xffffffff))
957
env->psr |= PSR_ZERO;
958
if ((int32_t) T0 < 0)
963
env->xcc |= PSR_ZERO;
964
if ((int64_t) T0 < 0)
968
env->psr |= PSR_ZERO;
969
if ((int32_t) T0 < 0)
975
void OPPROTO op_sll(void)
980
#ifdef TARGET_SPARC64
981
void OPPROTO op_sllx(void)
986
void OPPROTO op_srl(void)
988
T0 = (T0 & 0xffffffff) >> (T1 & 0x1f);
991
void OPPROTO op_srlx(void)
996
void OPPROTO op_sra(void)
998
T0 = ((int32_t) (T0 & 0xffffffff)) >> (T1 & 0x1f);
1001
void OPPROTO op_srax(void)
1003
T0 = ((int64_t) T0) >> (T1 & 0x3f);
1006
void OPPROTO op_srl(void)
1011
void OPPROTO op_sra(void)
1013
T0 = ((int32_t) T0) >> (T1 & 0x1f);
1017
/* Load and store */
1018
#define MEMSUFFIX _raw
1020
#if !defined(CONFIG_USER_ONLY)
1021
#define MEMSUFFIX _user
1024
#define MEMSUFFIX _kernel
1027
#ifdef TARGET_SPARC64
1028
#define MEMSUFFIX _hypv
1033
void OPPROTO op_ldfsr(void)
1035
PUT_FSR32(env, *((uint32_t *) &FT0));
1039
void OPPROTO op_stfsr(void)
1041
*((uint32_t *) &FT0) = GET_FSR32(env);
1044
#ifndef TARGET_SPARC64
1045
void OPPROTO op_rdpsr(void)
1050
void OPPROTO op_wrpsr(void)
1056
void OPPROTO op_wrwim(void)
1061
env->wim = T0 & ((1 << NWINDOWS) - 1);
1065
void OPPROTO op_rett(void)
1071
/* XXX: use another pointer for %iN registers to avoid slow wrapping
1073
void OPPROTO op_save(void)
1076
cwp = (env->cwp - 1) & (NWINDOWS - 1);
1077
if (env->wim & (1 << cwp)) {
1078
raise_exception(TT_WIN_OVF);
1084
void OPPROTO op_restore(void)
1087
cwp = (env->cwp + 1) & (NWINDOWS - 1);
1088
if (env->wim & (1 << cwp)) {
1089
raise_exception(TT_WIN_UNF);
1095
void OPPROTO op_rdccr(void)
1100
void OPPROTO op_wrccr(void)
1105
void OPPROTO op_rdtick(void)
1107
T0 = do_tick_get_count(env->tick);
1110
void OPPROTO op_wrtick(void)
1112
do_tick_set_count(env->tick, T0);
1115
void OPPROTO op_wrtick_cmpr(void)
1117
do_tick_set_limit(env->tick, T0);
1120
void OPPROTO op_rdstick(void)
1122
T0 = do_tick_get_count(env->stick);
1125
void OPPROTO op_wrstick(void)
1127
do_tick_set_count(env->stick, T0);
1128
do_tick_set_count(env->hstick, T0);
1131
void OPPROTO op_wrstick_cmpr(void)
1133
do_tick_set_limit(env->stick, T0);
1136
void OPPROTO op_wrhstick_cmpr(void)
1138
do_tick_set_limit(env->hstick, T0);
1141
void OPPROTO op_rdtpc(void)
1143
T0 = env->tpc[env->tl];
1146
void OPPROTO op_wrtpc(void)
1148
env->tpc[env->tl] = T0;
1151
void OPPROTO op_rdtnpc(void)
1153
T0 = env->tnpc[env->tl];
1156
void OPPROTO op_wrtnpc(void)
1158
env->tnpc[env->tl] = T0;
1161
void OPPROTO op_rdtstate(void)
1163
T0 = env->tstate[env->tl];
1166
void OPPROTO op_wrtstate(void)
1168
env->tstate[env->tl] = T0;
1171
void OPPROTO op_rdtt(void)
1173
T0 = env->tt[env->tl];
1176
void OPPROTO op_wrtt(void)
1178
env->tt[env->tl] = T0;
1181
void OPPROTO op_rdpstate(void)
1186
void OPPROTO op_wrpstate(void)
1191
// CWP handling is reversed in V9, but we still use the V8 register
1193
void OPPROTO op_rdcwp(void)
1195
T0 = GET_CWP64(env);
1198
void OPPROTO op_wrcwp(void)
1203
/* XXX: use another pointer for %iN registers to avoid slow wrapping
1205
void OPPROTO op_save(void)
1208
cwp = (env->cwp - 1) & (NWINDOWS - 1);
1209
if (env->cansave == 0) {
1210
raise_exception(TT_SPILL | (env->otherwin != 0 ?
1211
(TT_WOTHER | ((env->wstate & 0x38) >> 1)):
1212
((env->wstate & 0x7) << 2)));
1214
if (env->cleanwin - env->canrestore == 0) {
1215
// XXX Clean windows without trap
1216
raise_exception(TT_CLRWIN);
1226
void OPPROTO op_restore(void)
1229
cwp = (env->cwp + 1) & (NWINDOWS - 1);
1230
if (env->canrestore == 0) {
1231
raise_exception(TT_FILL | (env->otherwin != 0 ?
1232
(TT_WOTHER | ((env->wstate & 0x38) >> 1)):
1233
((env->wstate & 0x7) << 2)));
1243
void OPPROTO op_exception(void)
1245
env->exception_index = PARAM1;
1250
void OPPROTO op_trap_T0(void)
1252
env->exception_index = TT_TRAP + (T0 & 0x7f);
1257
void OPPROTO op_trapcc_T0(void)
1260
env->exception_index = TT_TRAP + (T0 & 0x7f);
1266
void OPPROTO op_fpexception_im(void)
1268
env->exception_index = TT_FP_EXCP;
1269
env->fsr &= ~FSR_FTT_MASK;
1275
void OPPROTO op_debug(void)
1280
void OPPROTO op_exit_tb(void)
1285
void OPPROTO op_eval_ba(void)
1290
void OPPROTO op_eval_be(void)
1292
T2 = FLAG_SET(PSR_ZERO);
1295
void OPPROTO op_eval_ble(void)
1297
target_ulong Z = FLAG_SET(PSR_ZERO), N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);
1302
void OPPROTO op_eval_bl(void)
1304
target_ulong N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);
1309
void OPPROTO op_eval_bleu(void)
1311
target_ulong Z = FLAG_SET(PSR_ZERO), C = FLAG_SET(PSR_CARRY);
1316
void OPPROTO op_eval_bcs(void)
1318
T2 = FLAG_SET(PSR_CARRY);
1321
void OPPROTO op_eval_bvs(void)
1323
T2 = FLAG_SET(PSR_OVF);
1326
void OPPROTO op_eval_bn(void)
1331
void OPPROTO op_eval_bneg(void)
1333
T2 = FLAG_SET(PSR_NEG);
1336
void OPPROTO op_eval_bne(void)
1338
T2 = !FLAG_SET(PSR_ZERO);
1341
void OPPROTO op_eval_bg(void)
1343
target_ulong Z = FLAG_SET(PSR_ZERO), N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);
1345
T2 = !(Z | (N ^ V));
1348
void OPPROTO op_eval_bge(void)
1350
target_ulong N = FLAG_SET(PSR_NEG), V = FLAG_SET(PSR_OVF);
1355
void OPPROTO op_eval_bgu(void)
1357
target_ulong Z = FLAG_SET(PSR_ZERO), C = FLAG_SET(PSR_CARRY);
1362
void OPPROTO op_eval_bcc(void)
1364
T2 = !FLAG_SET(PSR_CARRY);
1367
void OPPROTO op_eval_bpos(void)
1369
T2 = !FLAG_SET(PSR_NEG);
1372
void OPPROTO op_eval_bvc(void)
1374
T2 = !FLAG_SET(PSR_OVF);
1377
#ifdef TARGET_SPARC64
1378
void OPPROTO op_eval_xbe(void)
1380
T2 = XFLAG_SET(PSR_ZERO);
1383
void OPPROTO op_eval_xble(void)
1385
target_ulong Z = XFLAG_SET(PSR_ZERO), N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);
1390
void OPPROTO op_eval_xbl(void)
1392
target_ulong N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);
1397
void OPPROTO op_eval_xbleu(void)
1399
target_ulong Z = XFLAG_SET(PSR_ZERO), C = XFLAG_SET(PSR_CARRY);
1404
void OPPROTO op_eval_xbcs(void)
1406
T2 = XFLAG_SET(PSR_CARRY);
1409
void OPPROTO op_eval_xbvs(void)
1411
T2 = XFLAG_SET(PSR_OVF);
1414
void OPPROTO op_eval_xbneg(void)
1416
T2 = XFLAG_SET(PSR_NEG);
1419
void OPPROTO op_eval_xbne(void)
1421
T2 = !XFLAG_SET(PSR_ZERO);
1424
void OPPROTO op_eval_xbg(void)
1426
target_ulong Z = XFLAG_SET(PSR_ZERO), N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);
1428
T2 = !(Z | (N ^ V));
1431
void OPPROTO op_eval_xbge(void)
1433
target_ulong N = XFLAG_SET(PSR_NEG), V = XFLAG_SET(PSR_OVF);
1438
void OPPROTO op_eval_xbgu(void)
1440
target_ulong Z = XFLAG_SET(PSR_ZERO), C = XFLAG_SET(PSR_CARRY);
1445
void OPPROTO op_eval_xbcc(void)
1447
T2 = !XFLAG_SET(PSR_CARRY);
1450
void OPPROTO op_eval_xbpos(void)
1452
T2 = !XFLAG_SET(PSR_NEG);
1455
void OPPROTO op_eval_xbvc(void)
1457
T2 = !XFLAG_SET(PSR_OVF);
1462
#define FFLAG_SET(x) (env->fsr & x? 1: 0)
1463
#include "fbranch_template.h"
1465
#ifdef TARGET_SPARC64
1467
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 32))? 1: 0)
1468
#include "fbranch_template.h"
1470
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 34))? 1: 0)
1471
#include "fbranch_template.h"
1473
#define FFLAG_SET(x) ((env->fsr & ((uint64_t)x >> 36))? 1: 0)
1474
#include "fbranch_template.h"
1477
#ifdef TARGET_SPARC64
1478
void OPPROTO op_eval_brz(void)
1483
void OPPROTO op_eval_brnz(void)
1488
void OPPROTO op_eval_brlz(void)
1490
T2 = ((int64_t)T0 < 0);
1493
void OPPROTO op_eval_brlez(void)
1495
T2 = ((int64_t)T0 <= 0);
1498
void OPPROTO op_eval_brgz(void)
1500
T2 = ((int64_t)T0 > 0);
1503
void OPPROTO op_eval_brgez(void)
1505
T2 = ((int64_t)T0 >= 0);
1508
void OPPROTO op_jmp_im64(void)
1513
void OPPROTO op_movq_npc_im64(void)
1519
void OPPROTO op_jmp_im(void)
1521
env->pc = (uint32_t)PARAM1;
1524
void OPPROTO op_movl_npc_im(void)
1526
env->npc = (uint32_t)PARAM1;
1529
void OPPROTO op_movl_npc_T0(void)
1534
void OPPROTO op_mov_pc_npc(void)
1539
void OPPROTO op_next_insn(void)
1542
env->npc = env->npc + 4;
1545
void OPPROTO op_goto_tb0(void)
1547
GOTO_TB(op_goto_tb0, PARAM1, 0);
1550
void OPPROTO op_goto_tb1(void)
1552
GOTO_TB(op_goto_tb1, PARAM1, 1);
1555
void OPPROTO op_jmp_label(void)
1557
GOTO_LABEL_PARAM(1);
1560
void OPPROTO op_jnz_T2_label(void)
1563
GOTO_LABEL_PARAM(1);
1567
void OPPROTO op_jz_T2_label(void)
1570
GOTO_LABEL_PARAM(1);
1574
void OPPROTO op_flush_T0(void)
1579
void OPPROTO op_clear_ieee_excp_and_FTT(void)
1581
env->fsr &= ~(FSR_FTT_MASK | FSR_CEXC_MASK);;
1584
#define F_OP(name, p) void OPPROTO op_f##name##p(void)
1586
#if defined(CONFIG_USER_ONLY)
1587
#define F_BINOP(name) \
1590
set_float_exception_flags(0, &env->fp_status); \
1591
FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
1592
check_ieee_exceptions(); \
1596
set_float_exception_flags(0, &env->fp_status); \
1597
DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
1598
check_ieee_exceptions(); \
1602
set_float_exception_flags(0, &env->fp_status); \
1603
QT0 = float128_ ## name (QT0, QT1, &env->fp_status); \
1604
check_ieee_exceptions(); \
1607
#define F_BINOP(name) \
1610
set_float_exception_flags(0, &env->fp_status); \
1611
FT0 = float32_ ## name (FT0, FT1, &env->fp_status); \
1612
check_ieee_exceptions(); \
1616
set_float_exception_flags(0, &env->fp_status); \
1617
DT0 = float64_ ## name (DT0, DT1, &env->fp_status); \
1618
check_ieee_exceptions(); \
1628
void OPPROTO op_fsmuld(void)
1630
set_float_exception_flags(0, &env->fp_status);
1631
DT0 = float64_mul(float32_to_float64(FT0, &env->fp_status),
1632
float32_to_float64(FT1, &env->fp_status),
1634
check_ieee_exceptions();
1637
#if defined(CONFIG_USER_ONLY)
1638
void OPPROTO op_fdmulq(void)
1640
set_float_exception_flags(0, &env->fp_status);
1641
QT0 = float128_mul(float64_to_float128(DT0, &env->fp_status),
1642
float64_to_float128(DT1, &env->fp_status),
1644
check_ieee_exceptions();
1648
#if defined(CONFIG_USER_ONLY)
1649
#define F_HELPER(name) \
1663
#define F_HELPER(name) \
1678
FT0 = float32_chs(FT1);
1689
#ifdef TARGET_SPARC64
1692
DT0 = float64_chs(DT1);
1700
#if defined(CONFIG_USER_ONLY)
1703
QT0 = float128_chs(QT1);
1712
void OPPROTO op_fcmps_fcc1(void)
1717
void OPPROTO op_fcmpd_fcc1(void)
1722
void OPPROTO op_fcmps_fcc2(void)
1727
void OPPROTO op_fcmpd_fcc2(void)
1732
void OPPROTO op_fcmps_fcc3(void)
1737
void OPPROTO op_fcmpd_fcc3(void)
1742
void OPPROTO op_fcmpes_fcc1(void)
1747
void OPPROTO op_fcmped_fcc1(void)
1752
void OPPROTO op_fcmpes_fcc2(void)
1757
void OPPROTO op_fcmped_fcc2(void)
1762
void OPPROTO op_fcmpes_fcc3(void)
1767
void OPPROTO op_fcmped_fcc3(void)
1772
#if defined(CONFIG_USER_ONLY)
1773
void OPPROTO op_fcmpq_fcc1(void)
1778
void OPPROTO op_fcmpq_fcc2(void)
1783
void OPPROTO op_fcmpq_fcc3(void)
1788
void OPPROTO op_fcmpeq_fcc1(void)
1793
void OPPROTO op_fcmpeq_fcc2(void)
1798
void OPPROTO op_fcmpeq_fcc3(void)
1806
/* Integer to float conversion. */
1807
#ifdef USE_INT_TO_FLOAT_HELPERS
1809
#ifdef TARGET_SPARC64
1815
set_float_exception_flags(0, &env->fp_status);
1816
FT0 = int32_to_float32(*((int32_t *)&FT1), &env->fp_status);
1817
check_ieee_exceptions();
1822
set_float_exception_flags(0, &env->fp_status);
1823
DT0 = int32_to_float64(*((int32_t *)&FT1), &env->fp_status);
1824
check_ieee_exceptions();
1827
#if defined(CONFIG_USER_ONLY)
1830
set_float_exception_flags(0, &env->fp_status);
1831
QT0 = int32_to_float128(*((int32_t *)&FT1), &env->fp_status);
1832
check_ieee_exceptions();
1836
#ifdef TARGET_SPARC64
1839
set_float_exception_flags(0, &env->fp_status);
1840
FT0 = int64_to_float32(*((int64_t *)&DT1), &env->fp_status);
1841
check_ieee_exceptions();
1846
set_float_exception_flags(0, &env->fp_status);
1847
DT0 = int64_to_float64(*((int64_t *)&DT1), &env->fp_status);
1848
check_ieee_exceptions();
1850
#if defined(CONFIG_USER_ONLY)
1853
set_float_exception_flags(0, &env->fp_status);
1854
QT0 = int64_to_float128(*((int64_t *)&DT1), &env->fp_status);
1855
check_ieee_exceptions();
1862
/* floating point conversion */
1863
void OPPROTO op_fdtos(void)
1865
set_float_exception_flags(0, &env->fp_status);
1866
FT0 = float64_to_float32(DT1, &env->fp_status);
1867
check_ieee_exceptions();
1870
void OPPROTO op_fstod(void)
1872
set_float_exception_flags(0, &env->fp_status);
1873
DT0 = float32_to_float64(FT1, &env->fp_status);
1874
check_ieee_exceptions();
1877
#if defined(CONFIG_USER_ONLY)
1878
void OPPROTO op_fqtos(void)
1880
set_float_exception_flags(0, &env->fp_status);
1881
FT0 = float128_to_float32(QT1, &env->fp_status);
1882
check_ieee_exceptions();
1885
void OPPROTO op_fstoq(void)
1887
set_float_exception_flags(0, &env->fp_status);
1888
QT0 = float32_to_float128(FT1, &env->fp_status);
1889
check_ieee_exceptions();
1892
void OPPROTO op_fqtod(void)
1894
set_float_exception_flags(0, &env->fp_status);
1895
DT0 = float128_to_float64(QT1, &env->fp_status);
1896
check_ieee_exceptions();
1899
void OPPROTO op_fdtoq(void)
1901
set_float_exception_flags(0, &env->fp_status);
1902
QT0 = float64_to_float128(DT1, &env->fp_status);
1903
check_ieee_exceptions();
1907
/* Float to integer conversion. */
1908
void OPPROTO op_fstoi(void)
1910
set_float_exception_flags(0, &env->fp_status);
1911
*((int32_t *)&FT0) = float32_to_int32_round_to_zero(FT1, &env->fp_status);
1912
check_ieee_exceptions();
1915
void OPPROTO op_fdtoi(void)
1917
set_float_exception_flags(0, &env->fp_status);
1918
*((int32_t *)&FT0) = float64_to_int32_round_to_zero(DT1, &env->fp_status);
1919
check_ieee_exceptions();
1922
#if defined(CONFIG_USER_ONLY)
1923
void OPPROTO op_fqtoi(void)
1925
set_float_exception_flags(0, &env->fp_status);
1926
*((int32_t *)&FT0) = float128_to_int32_round_to_zero(QT1, &env->fp_status);
1927
check_ieee_exceptions();
1931
#ifdef TARGET_SPARC64
1932
void OPPROTO op_fstox(void)
1934
set_float_exception_flags(0, &env->fp_status);
1935
*((int64_t *)&DT0) = float32_to_int64_round_to_zero(FT1, &env->fp_status);
1936
check_ieee_exceptions();
1939
void OPPROTO op_fdtox(void)
1941
set_float_exception_flags(0, &env->fp_status);
1942
*((int64_t *)&DT0) = float64_to_int64_round_to_zero(DT1, &env->fp_status);
1943
check_ieee_exceptions();
1946
#if defined(CONFIG_USER_ONLY)
1947
void OPPROTO op_fqtox(void)
1949
set_float_exception_flags(0, &env->fp_status);
1950
*((int64_t *)&DT0) = float128_to_int64_round_to_zero(QT1, &env->fp_status);
1951
check_ieee_exceptions();
1955
void OPPROTO op_fmovs_cc(void)
1961
void OPPROTO op_fmovd_cc(void)
1967
#if defined(CONFIG_USER_ONLY)
1968
void OPPROTO op_fmovq_cc(void)
1975
void OPPROTO op_mov_cc(void)
1981
void OPPROTO op_flushw(void)
1983
if (env->cansave != NWINDOWS - 2) {
1984
raise_exception(TT_SPILL | (env->otherwin != 0 ?
1985
(TT_WOTHER | ((env->wstate & 0x38) >> 1)):
1986
((env->wstate & 0x7) << 2)));
1990
void OPPROTO op_saved(void)
1993
if (env->otherwin == 0)
2000
void OPPROTO op_restored(void)
2003
if (env->cleanwin < NWINDOWS - 1)
2005
if (env->otherwin == 0)
2012
void OPPROTO op_popc(void)
2017
void OPPROTO op_done(void)
2022
void OPPROTO op_retry(void)
2027
void OPPROTO op_sir(void)
2032
void OPPROTO op_ld_asi_reg()
2035
helper_ld_asi(env->asi, PARAM2, PARAM3);
2038
void OPPROTO op_st_asi_reg()
2041
helper_st_asi(env->asi, PARAM2);
2044
void OPPROTO op_ldf_asi_reg()
2047
helper_ldf_asi(env->asi, PARAM2, PARAM3);
2050
void OPPROTO op_stf_asi_reg()
2053
helper_stf_asi(env->asi, PARAM2, PARAM3);
2056
void OPPROTO op_ldf_asi()
2058
helper_ldf_asi(PARAM1, PARAM2, PARAM3);
2061
void OPPROTO op_stf_asi()
2063
helper_stf_asi(PARAM1, PARAM2, PARAM3);
2066
void OPPROTO op_ldstub_asi_reg() /* XXX: should be atomically */
2071
helper_ld_asi(env->asi, 1, 0);
2074
helper_st_asi(env->asi, 1);
2078
void OPPROTO op_swap_asi_reg() /* XXX: should be atomically */
2080
target_ulong tmp1, tmp2;
2084
helper_ld_asi(env->asi, 4, 0);
2087
helper_st_asi(env->asi, 4);
2091
void OPPROTO op_ldda_asi()
2093
helper_ld_asi(PARAM1, 8, 0);
2094
T0 = T1 & 0xffffffffUL;
2098
void OPPROTO op_ldda_asi_reg()
2101
helper_ld_asi(env->asi, 8, 0);
2102
T0 = T1 & 0xffffffffUL;
2106
void OPPROTO op_stda_asi()
2109
T1 += T2 & 0xffffffffUL;
2110
helper_st_asi(PARAM1, 8);
2113
void OPPROTO op_stda_asi_reg()
2117
T1 += T2 & 0xffffffffUL;
2118
helper_st_asi(env->asi, 8);
2121
void OPPROTO op_cas_asi() /* XXX: should be atomically */
2125
tmp = T1 & 0xffffffffUL;
2126
helper_ld_asi(PARAM1, 4, 0);
2129
T1 = T2 & 0xffffffffUL;
2130
helper_st_asi(PARAM1, 4);
2136
void OPPROTO op_cas_asi_reg() /* XXX: should be atomically */
2141
tmp = T1 & 0xffffffffUL;
2142
helper_ld_asi(env->asi, 4, 0);
2145
T1 = T2 & 0xffffffffUL;
2146
helper_st_asi(env->asi, 4);
2152
void OPPROTO op_casx_asi() /* XXX: should be atomically */
2157
helper_ld_asi(PARAM1, 8, 0);
2161
helper_st_asi(PARAM1, 8);
2166
void OPPROTO op_casx_asi_reg() /* XXX: should be atomically */
2172
helper_ld_asi(env->asi, 8, 0);
2176
helper_st_asi(env->asi, 8);
2182
#if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
2183
void OPPROTO op_ld_asi()
2185
helper_ld_asi(PARAM1, PARAM2, PARAM3);
2188
void OPPROTO op_st_asi()
2190
helper_st_asi(PARAM1, PARAM2);
2193
void OPPROTO op_ldstub_asi() /* XXX: should be atomically */
2197
helper_ld_asi(PARAM1, 1, 0);
2200
helper_st_asi(PARAM1, 1);
2204
void OPPROTO op_swap_asi() /* XXX: should be atomically */
2206
target_ulong tmp1, tmp2;
2209
helper_ld_asi(PARAM1, 4, 0);
2212
helper_st_asi(PARAM1, 4);
2217
#ifdef TARGET_SPARC64
2218
// This function uses non-native bit order
2219
#define GET_FIELD(X, FROM, TO) \
2220
((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1))
2222
// This function uses the order in the manuals, i.e. bit 0 is 2^0
2223
#define GET_FIELD_SP(X, FROM, TO) \
2224
GET_FIELD(X, 63 - (TO), 63 - (FROM))
2226
void OPPROTO op_array8()
2228
T0 = (GET_FIELD_SP(T0, 60, 63) << (17 + 2 * T1)) |
2229
(GET_FIELD_SP(T0, 39, 39 + T1 - 1) << (17 + T1)) |
2230
(GET_FIELD_SP(T0, 17 + T1 - 1, 17) << 17) |
2231
(GET_FIELD_SP(T0, 56, 59) << 13) | (GET_FIELD_SP(T0, 35, 38) << 9) |
2232
(GET_FIELD_SP(T0, 13, 16) << 5) | (((T0 >> 55) & 1) << 4) |
2233
(GET_FIELD_SP(T0, 33, 34) << 2) | GET_FIELD_SP(T0, 11, 12);
2236
void OPPROTO op_array16()
2238
T0 = ((GET_FIELD_SP(T0, 60, 63) << (17 + 2 * T1)) |
2239
(GET_FIELD_SP(T0, 39, 39 + T1 - 1) << (17 + T1)) |
2240
(GET_FIELD_SP(T0, 17 + T1 - 1, 17) << 17) |
2241
(GET_FIELD_SP(T0, 56, 59) << 13) | (GET_FIELD_SP(T0, 35, 38) << 9) |
2242
(GET_FIELD_SP(T0, 13, 16) << 5) | (((T0 >> 55) & 1) << 4) |
2243
(GET_FIELD_SP(T0, 33, 34) << 2) | GET_FIELD_SP(T0, 11, 12)) << 1;
2246
void OPPROTO op_array32()
2248
T0 = ((GET_FIELD_SP(T0, 60, 63) << (17 + 2 * T1)) |
2249
(GET_FIELD_SP(T0, 39, 39 + T1 - 1) << (17 + T1)) |
2250
(GET_FIELD_SP(T0, 17 + T1 - 1, 17) << 17) |
2251
(GET_FIELD_SP(T0, 56, 59) << 13) | (GET_FIELD_SP(T0, 35, 38) << 9) |
2252
(GET_FIELD_SP(T0, 13, 16) << 5) | (((T0 >> 55) & 1) << 4) |
2253
(GET_FIELD_SP(T0, 33, 34) << 2) | GET_FIELD_SP(T0, 11, 12)) << 2;
2256
void OPPROTO op_alignaddr()
2262
env->gsr |= tmp & 7ULL;
2266
void OPPROTO op_faligndata()
2270
tmp = (*((uint64_t *)&DT0)) << ((env->gsr & 7) * 8);
2271
tmp |= (*((uint64_t *)&DT1)) >> (64 - (env->gsr & 7) * 8);
2272
*((uint64_t *)&DT0) = tmp;
2275
void OPPROTO op_movl_FT0_0(void)
2277
*((uint32_t *)&FT0) = 0;
2280
void OPPROTO op_movl_DT0_0(void)
2282
*((uint64_t *)&DT0) = 0;
2285
void OPPROTO op_movl_FT0_1(void)
2287
*((uint32_t *)&FT0) = 0xffffffff;
2290
void OPPROTO op_movl_DT0_1(void)
2292
*((uint64_t *)&DT0) = 0xffffffffffffffffULL;
2295
void OPPROTO op_fnot(void)
2297
*(uint64_t *)&DT0 = ~*(uint64_t *)&DT1;
2300
void OPPROTO op_fnots(void)
2302
*(uint32_t *)&FT0 = ~*(uint32_t *)&FT1;
2305
void OPPROTO op_fnor(void)
2307
*(uint64_t *)&DT0 = ~(*(uint64_t *)&DT0 | *(uint64_t *)&DT1);
2310
void OPPROTO op_fnors(void)
2312
*(uint32_t *)&FT0 = ~(*(uint32_t *)&FT0 | *(uint32_t *)&FT1);
2315
void OPPROTO op_for(void)
2317
*(uint64_t *)&DT0 |= *(uint64_t *)&DT1;
2320
void OPPROTO op_fors(void)
2322
*(uint32_t *)&FT0 |= *(uint32_t *)&FT1;
2325
void OPPROTO op_fxor(void)
2327
*(uint64_t *)&DT0 ^= *(uint64_t *)&DT1;
2330
void OPPROTO op_fxors(void)
2332
*(uint32_t *)&FT0 ^= *(uint32_t *)&FT1;
2335
void OPPROTO op_fand(void)
2337
*(uint64_t *)&DT0 &= *(uint64_t *)&DT1;
2340
void OPPROTO op_fands(void)
2342
*(uint32_t *)&FT0 &= *(uint32_t *)&FT1;
2345
void OPPROTO op_fornot(void)
2347
*(uint64_t *)&DT0 = *(uint64_t *)&DT0 | ~*(uint64_t *)&DT1;
2350
void OPPROTO op_fornots(void)
2352
*(uint32_t *)&FT0 = *(uint32_t *)&FT0 | ~*(uint32_t *)&FT1;
2355
void OPPROTO op_fandnot(void)
2357
*(uint64_t *)&DT0 = *(uint64_t *)&DT0 & ~*(uint64_t *)&DT1;
2360
void OPPROTO op_fandnots(void)
2362
*(uint32_t *)&FT0 = *(uint32_t *)&FT0 & ~*(uint32_t *)&FT1;
2365
void OPPROTO op_fnand(void)
2367
*(uint64_t *)&DT0 = ~(*(uint64_t *)&DT0 & *(uint64_t *)&DT1);
2370
void OPPROTO op_fnands(void)
2372
*(uint32_t *)&FT0 = ~(*(uint32_t *)&FT0 & *(uint32_t *)&FT1);
2375
void OPPROTO op_fxnor(void)
2377
*(uint64_t *)&DT0 ^= ~*(uint64_t *)&DT1;
2380
void OPPROTO op_fxnors(void)
2382
*(uint32_t *)&FT0 ^= ~*(uint32_t *)&FT1;
2385
#ifdef WORDS_BIGENDIAN
2386
#define VIS_B64(n) b[7 - (n)]
2387
#define VIS_W64(n) w[3 - (n)]
2388
#define VIS_SW64(n) sw[3 - (n)]
2389
#define VIS_L64(n) l[1 - (n)]
2390
#define VIS_B32(n) b[3 - (n)]
2391
#define VIS_W32(n) w[1 - (n)]
2393
#define VIS_B64(n) b[n]
2394
#define VIS_W64(n) w[n]
2395
#define VIS_SW64(n) sw[n]
2396
#define VIS_L64(n) l[n]
2397
#define VIS_B32(n) b[n]
2398
#define VIS_W32(n) w[n]
2416
void OPPROTO op_fpmerge(void)
2423
// Reverse calculation order to handle overlap
2424
d.VIS_B64(7) = s.VIS_B64(3);
2425
d.VIS_B64(6) = d.VIS_B64(3);
2426
d.VIS_B64(5) = s.VIS_B64(2);
2427
d.VIS_B64(4) = d.VIS_B64(2);
2428
d.VIS_B64(3) = s.VIS_B64(1);
2429
d.VIS_B64(2) = d.VIS_B64(1);
2430
d.VIS_B64(1) = s.VIS_B64(0);
2431
//d.VIS_B64(0) = d.VIS_B64(0);
2436
void OPPROTO op_fmul8x16(void)
2445
tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B64(r); \
2446
if ((tmp & 0xff) > 0x7f) \
2448
d.VIS_W64(r) = tmp >> 8;
2459
void OPPROTO op_fmul8x16al(void)
2468
tmp = (int32_t)d.VIS_SW64(1) * (int32_t)s.VIS_B64(r); \
2469
if ((tmp & 0xff) > 0x7f) \
2471
d.VIS_W64(r) = tmp >> 8;
2482
void OPPROTO op_fmul8x16au(void)
2491
tmp = (int32_t)d.VIS_SW64(0) * (int32_t)s.VIS_B64(r); \
2492
if ((tmp & 0xff) > 0x7f) \
2494
d.VIS_W64(r) = tmp >> 8;
2505
void OPPROTO op_fmul8sux16(void)
2514
tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
2515
if ((tmp & 0xff) > 0x7f) \
2517
d.VIS_W64(r) = tmp >> 8;
2528
void OPPROTO op_fmul8ulx16(void)
2537
tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
2538
if ((tmp & 0xff) > 0x7f) \
2540
d.VIS_W64(r) = tmp >> 8;
2551
void OPPROTO op_fmuld8sux16(void)
2560
tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \
2561
if ((tmp & 0xff) > 0x7f) \
2565
// Reverse calculation order to handle overlap
2573
void OPPROTO op_fmuld8ulx16(void)
2582
tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \
2583
if ((tmp & 0xff) > 0x7f) \
2587
// Reverse calculation order to handle overlap
2595
void OPPROTO op_fexpand(void)
2600
s.l = (uint32_t)(*(uint64_t *)&DT0 & 0xffffffff);
2602
d.VIS_L64(0) = s.VIS_W32(0) << 4;
2603
d.VIS_L64(1) = s.VIS_W32(1) << 4;
2604
d.VIS_L64(2) = s.VIS_W32(2) << 4;
2605
d.VIS_L64(3) = s.VIS_W32(3) << 4;
2610
#define VIS_OP(name, F) \
2611
void OPPROTO name##16(void) \
2618
d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0)); \
2619
d.VIS_W64(1) = F(d.VIS_W64(1), s.VIS_W64(1)); \
2620
d.VIS_W64(2) = F(d.VIS_W64(2), s.VIS_W64(2)); \
2621
d.VIS_W64(3) = F(d.VIS_W64(3), s.VIS_W64(3)); \
2626
void OPPROTO name##16s(void) \
2633
d.VIS_W32(0) = F(d.VIS_W32(0), s.VIS_W32(0)); \
2634
d.VIS_W32(1) = F(d.VIS_W32(1), s.VIS_W32(1)); \
2639
void OPPROTO name##32(void) \
2646
d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0)); \
2647
d.VIS_L64(1) = F(d.VIS_L64(1), s.VIS_L64(1)); \
2652
void OPPROTO name##32s(void) \
2659
d.l = F(d.l, s.l); \
2664
#define FADD(a, b) ((a) + (b))
2665
#define FSUB(a, b) ((a) - (b))
2666
VIS_OP(op_fpadd, FADD)
2667
VIS_OP(op_fpsub, FSUB)
2669
#define VIS_CMPOP(name, F) \
2670
void OPPROTO name##16(void) \
2677
d.VIS_W64(0) = F(d.VIS_W64(0), s.VIS_W64(0))? 1: 0; \
2678
d.VIS_W64(0) |= F(d.VIS_W64(1), s.VIS_W64(1))? 2: 0; \
2679
d.VIS_W64(0) |= F(d.VIS_W64(2), s.VIS_W64(2))? 4: 0; \
2680
d.VIS_W64(0) |= F(d.VIS_W64(3), s.VIS_W64(3))? 8: 0; \
2685
void OPPROTO name##32(void) \
2692
d.VIS_L64(0) = F(d.VIS_L64(0), s.VIS_L64(0))? 1: 0; \
2693
d.VIS_L64(0) |= F(d.VIS_L64(1), s.VIS_L64(1))? 2: 0; \
2698
#define FCMPGT(a, b) ((a) > (b))
2699
#define FCMPEQ(a, b) ((a) == (b))
2700
#define FCMPLE(a, b) ((a) <= (b))
2701
#define FCMPNE(a, b) ((a) != (b))
2703
VIS_CMPOP(op_fcmpgt, FCMPGT)
2704
VIS_CMPOP(op_fcmpeq, FCMPEQ)
2705
VIS_CMPOP(op_fcmple, FCMPLE)
2706
VIS_CMPOP(op_fcmpne, FCMPNE)
2710
#define CHECK_ALIGN_OP(align) \
2711
void OPPROTO op_check_align_T0_ ## align (void) \
2714
raise_exception(TT_UNALIGNED); \