1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include "qemu/osdep.h"
22#include "cpu.h"
23#include "qemu-common.h"
24#include "exec/helper-proto.h"
25
26
27
28#define V1(X) (((X) & 0xff) * 0x0101010101010101ull)
29#define V2(X) (((X) & 0xffff) * 0x0001000100010001ull)
30
31
32uint64_t helper_v1multu(uint64_t a, uint64_t b)
33{
34 uint64_t r = 0;
35 int i;
36
37 for (i = 0; i < 64; i += 8) {
38 unsigned ae = extract64(a, i, 8);
39 unsigned be = extract64(b, i, 8);
40 r = deposit64(r, i, 8, ae * be);
41 }
42 return r;
43}
44
45uint64_t helper_v2mults(uint64_t a, uint64_t b)
46{
47 uint64_t r = 0;
48 int i;
49
50
51
52 for (i = 0; i < 64; i += 16) {
53 unsigned ae = extract64(a, i, 16);
54 unsigned be = extract64(b, i, 16);
55 r = deposit64(r, i, 16, ae * be);
56 }
57 return r;
58}
59
60uint64_t helper_v1shl(uint64_t a, uint64_t b)
61{
62 uint64_t m;
63
64 b &= 7;
65 m = V1(0xff >> b);
66 return (a & m) << b;
67}
68
69uint64_t helper_v2shl(uint64_t a, uint64_t b)
70{
71 uint64_t m;
72
73 b &= 15;
74 m = V2(0xffff >> b);
75 return (a & m) << b;
76}
77
78uint64_t helper_v1shru(uint64_t a, uint64_t b)
79{
80 uint64_t m;
81
82 b &= 7;
83 m = V1(0xff << b);
84 return (a & m) >> b;
85}
86
87uint64_t helper_v2shru(uint64_t a, uint64_t b)
88{
89 uint64_t m;
90
91 b &= 15;
92 m = V2(0xffff << b);
93 return (a & m) >> b;
94}
95
96uint64_t helper_v1shrs(uint64_t a, uint64_t b)
97{
98 uint64_t r = 0;
99 int i;
100
101 b &= 7;
102 for (i = 0; i < 64; i += 8) {
103 r = deposit64(r, i, 8, sextract64(a, i + b, 8 - b));
104 }
105 return r;
106}
107
108uint64_t helper_v2shrs(uint64_t a, uint64_t b)
109{
110 uint64_t r = 0;
111 int i;
112
113 b &= 15;
114 for (i = 0; i < 64; i += 16) {
115 r = deposit64(r, i, 16, sextract64(a, i + b, 16 - b));
116 }
117 return r;
118}
119
120uint64_t helper_v1int_h(uint64_t a, uint64_t b)
121{
122 uint64_t r = 0;
123 int i;
124
125 for (i = 0; i < 32; i += 8) {
126 r = deposit64(r, 2 * i + 8, 8, extract64(a, i + 32, 8));
127 r = deposit64(r, 2 * i, 8, extract64(b, i + 32, 8));
128 }
129 return r;
130}
131
132uint64_t helper_v1int_l(uint64_t a, uint64_t b)
133{
134 uint64_t r = 0;
135 int i;
136
137 for (i = 0; i < 32; i += 8) {
138 r = deposit64(r, 2 * i + 8, 8, extract64(a, i, 8));
139 r = deposit64(r, 2 * i, 8, extract64(b, i, 8));
140 }
141 return r;
142}
143
144uint64_t helper_v2int_h(uint64_t a, uint64_t b)
145{
146 uint64_t r = 0;
147 int i;
148
149 for (i = 0; i < 32; i += 16) {
150 r = deposit64(r, 2 * i + 16, 16, extract64(a, i + 32, 16));
151 r = deposit64(r, 2 * i, 16, extract64(b, i + 32, 16));
152 }
153 return r;
154}
155
156uint64_t helper_v2int_l(uint64_t a, uint64_t b)
157{
158 uint64_t r = 0;
159 int i;
160
161 for (i = 0; i < 32; i += 16) {
162 r = deposit64(r, 2 * i + 16, 16, extract64(a, i, 16));
163 r = deposit64(r, 2 * i, 16, extract64(b, i, 16));
164 }
165 return r;
166}
167