Line data Source code
1 : // Copyright 2011 the V8 project authors. All rights reserved.
2 : // Redistribution and use in source and binary forms, with or without
3 : // modification, are permitted provided that the following conditions are
4 : // met:
5 : //
6 : // * Redistributions of source code must retain the above copyright
7 : // notice, this list of conditions and the following disclaimer.
8 : // * Redistributions in binary form must reproduce the above
9 : // copyright notice, this list of conditions and the following
10 : // disclaimer in the documentation and/or other materials provided
11 : // with the distribution.
12 : // * Neither the name of Google Inc. nor the names of its
13 : // contributors may be used to endorse or promote products derived
14 : // from this software without specific prior written permission.
15 : //
16 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 : // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 :
28 : #include <stdlib.h>
29 :
30 : #include "src/v8.h"
31 :
32 : #include "src/code-factory.h"
33 : #include "src/debug/debug.h"
34 : #include "src/disasm.h"
35 : #include "src/disassembler.h"
36 : #include "src/frames-inl.h"
37 : #include "src/macro-assembler.h"
38 : #include "src/objects-inl.h"
39 : #include "test/cctest/cctest.h"
40 :
41 : namespace v8 {
42 : namespace internal {
43 :
44 : #define __ assm.
45 :
46 :
47 : static void DummyStaticFunction(Object* result) {
48 : }
49 :
50 :
51 23724 : TEST(DisasmX64) {
52 6 : CcTest::InitializeVM();
53 : Isolate* isolate = CcTest::i_isolate();
54 : HandleScope scope(isolate);
55 : v8::internal::byte buffer[8192];
56 12 : Assembler assm(isolate, buffer, sizeof buffer);
57 : DummyStaticFunction(nullptr); // just bloody use it (DELETE; debugging)
58 :
59 : // Short immediate instructions
60 6 : __ addq(rax, Immediate(12345678));
61 6 : __ orq(rax, Immediate(12345678));
62 6 : __ subq(rax, Immediate(12345678));
63 6 : __ xorq(rax, Immediate(12345678));
64 6 : __ andq(rax, Immediate(12345678));
65 :
66 : // ---- This one caused crash
67 12 : __ movq(rbx, Operand(rsp, rcx, times_2, 0)); // [rsp+rcx*4]
68 :
69 : // ---- All instructions that I can think of
70 6 : __ addq(rdx, rbx);
71 12 : __ addq(rdx, Operand(rbx, 0));
72 12 : __ addq(rdx, Operand(rbx, 16));
73 12 : __ addq(rdx, Operand(rbx, 1999));
74 12 : __ addq(rdx, Operand(rbx, -4));
75 12 : __ addq(rdx, Operand(rbx, -1999));
76 12 : __ addq(rdx, Operand(rsp, 0));
77 12 : __ addq(rdx, Operand(rsp, 16));
78 12 : __ addq(rdx, Operand(rsp, 1999));
79 12 : __ addq(rdx, Operand(rsp, -4));
80 12 : __ addq(rdx, Operand(rsp, -1999));
81 6 : __ nop();
82 12 : __ addq(rsi, Operand(rcx, times_4, 0));
83 12 : __ addq(rsi, Operand(rcx, times_4, 24));
84 12 : __ addq(rsi, Operand(rcx, times_4, -4));
85 12 : __ addq(rsi, Operand(rcx, times_4, -1999));
86 6 : __ nop();
87 12 : __ addq(rdi, Operand(rbp, rcx, times_4, 0));
88 12 : __ addq(rdi, Operand(rbp, rcx, times_4, 12));
89 12 : __ addq(rdi, Operand(rbp, rcx, times_4, -8));
90 12 : __ addq(rdi, Operand(rbp, rcx, times_4, -3999));
91 12 : __ addq(Operand(rbp, rcx, times_4, 12), Immediate(12));
92 :
93 6 : __ bsrl(rax, r15);
94 6 : __ bsrl(r9, Operand(rcx, times_8, 91919));
95 :
96 6 : __ nop();
97 6 : __ addq(rbx, Immediate(12));
98 6 : __ nop();
99 6 : __ nop();
100 6 : __ andq(rdx, Immediate(3));
101 12 : __ andq(rdx, Operand(rsp, 4));
102 6 : __ cmpq(rdx, Immediate(3));
103 12 : __ cmpq(rdx, Operand(rsp, 4));
104 12 : __ cmpq(Operand(rbp, rcx, times_4, 0), Immediate(1000));
105 12 : __ cmpb(rbx, Operand(rbp, rcx, times_2, 0));
106 12 : __ cmpb(Operand(rbp, rcx, times_2, 0), rbx);
107 6 : __ orq(rdx, Immediate(3));
108 6 : __ xorq(rdx, Immediate(3));
109 6 : __ nop();
110 6 : __ cpuid();
111 6 : __ movsxbl(rdx, Operand(rcx, 0));
112 6 : __ movsxbq(rdx, Operand(rcx, 0));
113 6 : __ movsxwl(rdx, Operand(rcx, 0));
114 6 : __ movsxwq(rdx, Operand(rcx, 0));
115 12 : __ movzxbl(rdx, Operand(rcx, 0));
116 12 : __ movzxwl(rdx, Operand(rcx, 0));
117 12 : __ movzxbq(rdx, Operand(rcx, 0));
118 12 : __ movzxwq(rdx, Operand(rcx, 0));
119 :
120 6 : __ nop();
121 : __ imulq(rdx, rcx);
122 6 : __ shld(rdx, rcx);
123 6 : __ shrd(rdx, rcx);
124 12 : __ shlq(Operand(rdi, rax, times_4, 100), Immediate(1));
125 12 : __ shlq(Operand(rdi, rax, times_4, 100), Immediate(6));
126 12 : __ shlq(Operand(r15, 0), Immediate(1));
127 12 : __ shlq(Operand(r15, 0), Immediate(6));
128 12 : __ shlq_cl(Operand(r15, 0));
129 12 : __ shlq_cl(Operand(r15, 0));
130 12 : __ shlq_cl(Operand(rdi, rax, times_4, 100));
131 12 : __ shlq_cl(Operand(rdi, rax, times_4, 100));
132 : __ shlq(rdx, Immediate(1));
133 : __ shlq(rdx, Immediate(6));
134 12 : __ shll(Operand(rdi, rax, times_4, 100), Immediate(1));
135 12 : __ shll(Operand(rdi, rax, times_4, 100), Immediate(6));
136 12 : __ shll(Operand(r15, 0), Immediate(1));
137 12 : __ shll(Operand(r15, 0), Immediate(6));
138 12 : __ shll_cl(Operand(r15, 0));
139 12 : __ shll_cl(Operand(r15, 0));
140 12 : __ shll_cl(Operand(rdi, rax, times_4, 100));
141 12 : __ shll_cl(Operand(rdi, rax, times_4, 100));
142 : __ shll(rdx, Immediate(1));
143 : __ shll(rdx, Immediate(6));
144 6 : __ bts(Operand(rdx, 0), rcx);
145 6 : __ bts(Operand(rbx, rcx, times_4, 0), rcx);
146 6 : __ nop();
147 6 : __ pushq(Immediate(12));
148 6 : __ pushq(Immediate(23456));
149 6 : __ pushq(rcx);
150 6 : __ pushq(rsi);
151 6 : __ pushq(Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
152 6 : __ pushq(Operand(rbx, rcx, times_4, 0));
153 6 : __ pushq(Operand(rbx, rcx, times_4, 0));
154 6 : __ pushq(Operand(rbx, rcx, times_4, 10000));
155 6 : __ popq(rdx);
156 6 : __ popq(rax);
157 6 : __ popq(Operand(rbx, rcx, times_4, 0));
158 6 : __ nop();
159 :
160 12 : __ addq(rdx, Operand(rsp, 16));
161 6 : __ addq(rdx, rcx);
162 6 : __ movb(rdx, Operand(rcx, 0));
163 6 : __ movb(rcx, Immediate(6));
164 6 : __ movb(Operand(rsp, 16), rdx);
165 6 : __ movw(Operand(rsp, 16), rdx);
166 6 : __ nop();
167 6 : __ movsxwq(rdx, Operand(rsp, 12));
168 6 : __ movsxbq(rdx, Operand(rsp, 12));
169 6 : __ movsxlq(rdx, Operand(rsp, 12));
170 12 : __ movzxwq(rdx, Operand(rsp, 12));
171 12 : __ movzxbq(rdx, Operand(rsp, 12));
172 6 : __ nop();
173 : __ movq(rdx, Immediate(1234567));
174 12 : __ movq(rdx, Operand(rsp, 12));
175 12 : __ movq(Operand(rbx, rcx, times_4, 10000), Immediate(12345));
176 12 : __ movq(Operand(rbx, rcx, times_4, 10000), rdx);
177 6 : __ nop();
178 6 : __ decb(rdx);
179 6 : __ decb(Operand(rax, 10));
180 6 : __ decb(Operand(rbx, rcx, times_4, 10000));
181 : __ decq(rdx);
182 6 : __ cdq();
183 :
184 6 : __ nop();
185 : __ idivq(rdx);
186 6 : __ mull(rdx);
187 6 : __ mulq(rdx);
188 : __ negq(rdx);
189 : __ notq(rdx);
190 12 : __ testq(Operand(rbx, rcx, times_4, 10000), rdx);
191 :
192 : __ imulq(rdx, rcx, Immediate(12));
193 : __ imulq(rdx, rcx, Immediate(1000));
194 12 : __ imulq(rdx, Operand(rbx, rcx, times_4, 10000));
195 12 : __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(12));
196 12 : __ imulq(rdx, Operand(rbx, rcx, times_4, 10000), Immediate(1000));
197 : __ imull(r15, rcx, Immediate(12));
198 : __ imull(r15, rcx, Immediate(1000));
199 12 : __ imull(r15, Operand(rbx, rcx, times_4, 10000));
200 12 : __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(12));
201 12 : __ imull(r15, Operand(rbx, rcx, times_4, 10000), Immediate(1000));
202 :
203 : __ incq(rdx);
204 12 : __ incq(Operand(rbx, rcx, times_4, 10000));
205 6 : __ pushq(Operand(rbx, rcx, times_4, 10000));
206 6 : __ popq(Operand(rbx, rcx, times_4, 10000));
207 : // TODO(mstarzinger): The following is protected.
208 : // __ jmp(Operand(rbx, rcx, times_4, 10000));
209 :
210 12 : __ leaq(rdx, Operand(rbx, rcx, times_4, 10000));
211 6 : __ orq(rdx, Immediate(12345));
212 12 : __ orq(rdx, Operand(rbx, rcx, times_4, 10000));
213 :
214 6 : __ nop();
215 :
216 : __ rclq(rdx, Immediate(1));
217 : __ rclq(rdx, Immediate(7));
218 : __ rcrq(rdx, Immediate(1));
219 : __ rcrq(rdx, Immediate(7));
220 : __ sarq(rdx, Immediate(1));
221 : __ sarq(rdx, Immediate(6));
222 : __ sarq_cl(rdx);
223 6 : __ sbbq(rdx, rbx);
224 6 : __ shld(rdx, rbx);
225 : __ shlq(rdx, Immediate(1));
226 : __ shlq(rdx, Immediate(6));
227 : __ shlq_cl(rdx);
228 6 : __ shrd(rdx, rbx);
229 : __ shrq(rdx, Immediate(1));
230 : __ shrq(rdx, Immediate(7));
231 : __ shrq_cl(rdx);
232 :
233 :
234 : // Immediates
235 :
236 6 : __ addq(rbx, Immediate(12));
237 12 : __ addq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
238 :
239 6 : __ andq(rbx, Immediate(12345));
240 :
241 6 : __ cmpq(rbx, Immediate(12345));
242 6 : __ cmpq(rbx, Immediate(12));
243 12 : __ cmpq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
244 : __ cmpb(rax, Immediate(100));
245 :
246 6 : __ orq(rbx, Immediate(12345));
247 :
248 6 : __ subq(rbx, Immediate(12));
249 12 : __ subq(Operand(rdx, rcx, times_4, 10000), Immediate(12));
250 :
251 6 : __ xorq(rbx, Immediate(12345));
252 :
253 : __ imulq(rdx, rcx, Immediate(12));
254 : __ imulq(rdx, rcx, Immediate(1000));
255 :
256 6 : __ cld();
257 :
258 12 : __ subq(rdx, Operand(rbx, rcx, times_4, 10000));
259 6 : __ subq(rdx, rbx);
260 :
261 : __ testq(rdx, Immediate(12345));
262 12 : __ testq(Operand(rbx, rcx, times_8, 10000), rdx);
263 6 : __ testb(Operand(rcx, rbx, times_2, 1000), rdx);
264 6 : __ testb(Operand(rax, -20), Immediate(0x9A));
265 6 : __ nop();
266 :
267 6 : __ xorq(rdx, Immediate(12345));
268 12 : __ xorq(rdx, Operand(rbx, rcx, times_8, 10000));
269 6 : __ bts(Operand(rbx, rcx, times_8, 10000), rdx);
270 6 : __ pshufw(xmm5, xmm1, 3);
271 6 : __ hlt();
272 6 : __ int3();
273 6 : __ ret(0);
274 6 : __ ret(8);
275 :
276 : // Calls
277 :
278 : Label L1, L2;
279 6 : __ bind(&L1);
280 6 : __ nop();
281 6 : __ call(&L1);
282 6 : __ call(&L2);
283 6 : __ nop();
284 6 : __ bind(&L2);
285 : // TODO(mstarzinger): The following is protected.
286 : // __ call(Operand(rbx, rcx, times_4, 10000));
287 6 : __ nop();
288 6 : Handle<Code> ic = BUILTIN_CODE(isolate, LoadIC);
289 6 : __ call(ic, RelocInfo::CODE_TARGET);
290 6 : __ nop();
291 6 : __ nop();
292 :
293 6 : __ jmp(&L1);
294 : // TODO(mstarzinger): The following is protected.
295 : // __ jmp(Operand(rbx, rcx, times_4, 10000));
296 6 : __ jmp(ic, RelocInfo::CODE_TARGET);
297 6 : __ nop();
298 :
299 :
300 : Label Ljcc;
301 6 : __ nop();
302 : // long jumps
303 6 : __ j(overflow, &Ljcc);
304 6 : __ j(no_overflow, &Ljcc);
305 6 : __ j(below, &Ljcc);
306 6 : __ j(above_equal, &Ljcc);
307 6 : __ j(equal, &Ljcc);
308 6 : __ j(not_equal, &Ljcc);
309 6 : __ j(below_equal, &Ljcc);
310 6 : __ j(above, &Ljcc);
311 6 : __ j(sign, &Ljcc);
312 6 : __ j(not_sign, &Ljcc);
313 6 : __ j(parity_even, &Ljcc);
314 6 : __ j(parity_odd, &Ljcc);
315 6 : __ j(less, &Ljcc);
316 6 : __ j(greater_equal, &Ljcc);
317 6 : __ j(less_equal, &Ljcc);
318 6 : __ j(greater, &Ljcc);
319 6 : __ nop();
320 6 : __ bind(&Ljcc);
321 : // short jumps
322 6 : __ j(overflow, &Ljcc);
323 6 : __ j(no_overflow, &Ljcc);
324 6 : __ j(below, &Ljcc);
325 6 : __ j(above_equal, &Ljcc);
326 6 : __ j(equal, &Ljcc);
327 6 : __ j(not_equal, &Ljcc);
328 6 : __ j(below_equal, &Ljcc);
329 6 : __ j(above, &Ljcc);
330 6 : __ j(sign, &Ljcc);
331 6 : __ j(not_sign, &Ljcc);
332 6 : __ j(parity_even, &Ljcc);
333 6 : __ j(parity_odd, &Ljcc);
334 6 : __ j(less, &Ljcc);
335 6 : __ j(greater_equal, &Ljcc);
336 6 : __ j(less_equal, &Ljcc);
337 6 : __ j(greater, &Ljcc);
338 :
339 : // 0xD9 instructions
340 6 : __ nop();
341 :
342 6 : __ fld(1);
343 6 : __ fld1();
344 6 : __ fldz();
345 6 : __ fldpi();
346 6 : __ fabs();
347 6 : __ fchs();
348 6 : __ fprem();
349 6 : __ fprem1();
350 6 : __ fincstp();
351 6 : __ ftst();
352 6 : __ fxch(3);
353 6 : __ fld_s(Operand(rbx, rcx, times_4, 10000));
354 6 : __ fstp_s(Operand(rbx, rcx, times_4, 10000));
355 6 : __ ffree(3);
356 6 : __ fld_d(Operand(rbx, rcx, times_4, 10000));
357 6 : __ fstp_d(Operand(rbx, rcx, times_4, 10000));
358 6 : __ nop();
359 :
360 6 : __ fild_s(Operand(rbx, rcx, times_4, 10000));
361 6 : __ fistp_s(Operand(rbx, rcx, times_4, 10000));
362 6 : __ fild_d(Operand(rbx, rcx, times_4, 10000));
363 6 : __ fistp_d(Operand(rbx, rcx, times_4, 10000));
364 6 : __ fnstsw_ax();
365 6 : __ nop();
366 6 : __ fadd(3);
367 6 : __ fsub(3);
368 6 : __ fmul(3);
369 6 : __ fdiv(3);
370 :
371 6 : __ faddp(3);
372 6 : __ fsubp(3);
373 6 : __ fmulp(3);
374 6 : __ fdivp(3);
375 6 : __ fcompp();
376 6 : __ fwait();
377 6 : __ frndint();
378 6 : __ fninit();
379 6 : __ nop();
380 :
381 : // SSE instruction
382 : {
383 : // Move operation
384 6 : __ cvttss2si(rdx, Operand(rbx, rcx, times_4, 10000));
385 6 : __ cvttss2si(rdx, xmm1);
386 6 : __ cvtsd2ss(xmm0, xmm1);
387 6 : __ cvtsd2ss(xmm0, Operand(rbx, rcx, times_4, 10000));
388 6 : __ movaps(xmm0, xmm1);
389 6 : __ shufps(xmm0, xmm9, 0x0);
390 :
391 : // logic operation
392 6 : __ andps(xmm0, xmm1);
393 6 : __ andps(xmm0, Operand(rbx, rcx, times_4, 10000));
394 6 : __ orps(xmm0, xmm1);
395 6 : __ orps(xmm0, Operand(rbx, rcx, times_4, 10000));
396 6 : __ xorps(xmm0, xmm1);
397 6 : __ xorps(xmm0, Operand(rbx, rcx, times_4, 10000));
398 :
399 : // Arithmetic operation
400 6 : __ addss(xmm1, xmm0);
401 6 : __ addss(xmm1, Operand(rbx, rcx, times_4, 10000));
402 6 : __ mulss(xmm1, xmm0);
403 6 : __ mulss(xmm1, Operand(rbx, rcx, times_4, 10000));
404 6 : __ subss(xmm1, xmm0);
405 6 : __ subss(xmm1, Operand(rbx, rcx, times_4, 10000));
406 6 : __ divss(xmm1, xmm0);
407 6 : __ divss(xmm1, Operand(rbx, rcx, times_4, 10000));
408 6 : __ maxss(xmm1, xmm0);
409 6 : __ maxss(xmm1, Operand(rbx, rcx, times_4, 10000));
410 6 : __ minss(xmm1, xmm0);
411 6 : __ minss(xmm1, Operand(rbx, rcx, times_4, 10000));
412 6 : __ addps(xmm1, xmm0);
413 6 : __ addps(xmm1, Operand(rbx, rcx, times_4, 10000));
414 6 : __ subps(xmm1, xmm0);
415 6 : __ subps(xmm1, Operand(rbx, rcx, times_4, 10000));
416 6 : __ mulps(xmm1, xmm0);
417 6 : __ mulps(xmm1, Operand(rbx, rcx, times_4, 10000));
418 6 : __ divps(xmm1, xmm0);
419 6 : __ divps(xmm1, Operand(rbx, rcx, times_4, 10000));
420 :
421 6 : __ ucomiss(xmm0, xmm1);
422 6 : __ ucomiss(xmm0, Operand(rbx, rcx, times_4, 10000));
423 : }
424 :
425 : // SSE2 instructions
426 : {
427 6 : __ cvttsd2si(rdx, Operand(rbx, rcx, times_4, 10000));
428 6 : __ cvttsd2si(rdx, xmm1);
429 6 : __ cvttsd2siq(rdx, xmm1);
430 6 : __ cvttsd2siq(rdx, Operand(rbx, rcx, times_4, 10000));
431 6 : __ cvtqsi2sd(xmm1, Operand(rbx, rcx, times_4, 10000));
432 6 : __ cvtqsi2sd(xmm1, rdx);
433 6 : __ movsd(xmm1, Operand(rbx, rcx, times_4, 10000));
434 6 : __ movsd(Operand(rbx, rcx, times_4, 10000), xmm1);
435 : // 128 bit move instructions.
436 6 : __ movupd(xmm0, Operand(rbx, rcx, times_4, 10000));
437 6 : __ movupd(Operand(rbx, rcx, times_4, 10000), xmm0);
438 6 : __ movdqa(xmm0, Operand(rbx, rcx, times_4, 10000));
439 6 : __ movdqa(Operand(rbx, rcx, times_4, 10000), xmm0);
440 :
441 6 : __ addsd(xmm1, xmm0);
442 6 : __ addsd(xmm1, Operand(rbx, rcx, times_4, 10000));
443 6 : __ mulsd(xmm1, xmm0);
444 6 : __ mulsd(xmm1, Operand(rbx, rcx, times_4, 10000));
445 6 : __ subsd(xmm1, xmm0);
446 6 : __ subsd(xmm1, Operand(rbx, rcx, times_4, 10000));
447 6 : __ divsd(xmm1, xmm0);
448 6 : __ divsd(xmm1, Operand(rbx, rcx, times_4, 10000));
449 6 : __ minsd(xmm1, xmm0);
450 6 : __ minsd(xmm1, Operand(rbx, rcx, times_4, 10000));
451 6 : __ maxsd(xmm1, xmm0);
452 6 : __ maxsd(xmm1, Operand(rbx, rcx, times_4, 10000));
453 6 : __ ucomisd(xmm0, xmm1);
454 :
455 6 : __ andpd(xmm0, xmm1);
456 6 : __ andpd(xmm0, Operand(rbx, rcx, times_4, 10000));
457 6 : __ orpd(xmm0, xmm1);
458 6 : __ orpd(xmm0, Operand(rbx, rcx, times_4, 10000));
459 6 : __ xorpd(xmm0, xmm1);
460 6 : __ xorpd(xmm0, Operand(rbx, rcx, times_4, 10000));
461 :
462 6 : __ pslld(xmm0, 6);
463 6 : __ psrld(xmm0, 6);
464 6 : __ psllq(xmm0, 6);
465 6 : __ psrlq(xmm0, 6);
466 :
467 : __ pcmpeqd(xmm1, xmm0);
468 :
469 6 : __ punpckldq(xmm1, xmm11);
470 6 : __ punpckldq(xmm5, Operand(rdx, 4));
471 6 : __ punpckhdq(xmm8, xmm15);
472 :
473 6 : __ pshuflw(xmm2, xmm4, 3);
474 6 : __ pshufhw(xmm1, xmm9, 6);
475 :
476 : #define EMIT_SSE2_INSTR(instruction, notUsed1, notUsed2, notUsed3) \
477 : __ instruction(xmm5, xmm1); \
478 : __ instruction(xmm5, Operand(rdx, 4));
479 :
480 468 : SSE2_INSTRUCTION_LIST(EMIT_SSE2_INSTR)
481 : #undef EMIT_SSE2_INSTR
482 : }
483 :
484 : // cmov.
485 : {
486 6 : __ cmovq(overflow, rax, Operand(rax, 0));
487 6 : __ cmovq(no_overflow, rax, Operand(rax, 1));
488 6 : __ cmovq(below, rax, Operand(rax, 2));
489 6 : __ cmovq(above_equal, rax, Operand(rax, 3));
490 6 : __ cmovq(equal, rax, Operand(rbx, 0));
491 6 : __ cmovq(not_equal, rax, Operand(rbx, 1));
492 6 : __ cmovq(below_equal, rax, Operand(rbx, 2));
493 6 : __ cmovq(above, rax, Operand(rbx, 3));
494 6 : __ cmovq(sign, rax, Operand(rcx, 0));
495 6 : __ cmovq(not_sign, rax, Operand(rcx, 1));
496 6 : __ cmovq(parity_even, rax, Operand(rcx, 2));
497 6 : __ cmovq(parity_odd, rax, Operand(rcx, 3));
498 6 : __ cmovq(less, rax, Operand(rdx, 0));
499 6 : __ cmovq(greater_equal, rax, Operand(rdx, 1));
500 6 : __ cmovq(less_equal, rax, Operand(rdx, 2));
501 6 : __ cmovq(greater, rax, Operand(rdx, 3));
502 : }
503 :
504 : {
505 6 : if (CpuFeatures::IsSupported(SSE3)) {
506 : CpuFeatureScope scope(&assm, SSE3);
507 6 : __ lddqu(xmm1, Operand(rdx, 4));
508 : }
509 : }
510 :
511 : #define EMIT_SSE34_INSTR(instruction, notUsed1, notUsed2, notUsed3, notUsed4) \
512 : __ instruction(xmm5, xmm1); \
513 : __ instruction(xmm5, Operand(rdx, 4));
514 :
515 : {
516 6 : if (CpuFeatures::IsSupported(SSSE3)) {
517 : CpuFeatureScope scope(&assm, SSSE3);
518 108 : SSSE3_INSTRUCTION_LIST(EMIT_SSE34_INSTR)
519 : }
520 : }
521 :
522 : {
523 6 : if (CpuFeatures::IsSupported(SSE4_1)) {
524 : CpuFeatureScope scope(&assm, SSE4_1);
525 6 : __ insertps(xmm5, xmm1, 123);
526 6 : __ extractps(rax, xmm1, 0);
527 6 : __ pextrw(rbx, xmm2, 1);
528 6 : __ pinsrw(xmm2, rcx, 1);
529 6 : __ pextrd(rbx, xmm15, 0);
530 6 : __ pextrd(r12, xmm0, 1);
531 6 : __ pinsrd(xmm9, r9, 0);
532 6 : __ pinsrd(xmm5, Operand(rax, 4), 1);
533 :
534 6 : __ cmpps(xmm5, xmm1, 1);
535 6 : __ cmpps(xmm5, Operand(rbx, rcx, times_4, 10000), 1);
536 : __ cmpeqps(xmm5, xmm1);
537 12 : __ cmpeqps(xmm5, Operand(rbx, rcx, times_4, 10000));
538 : __ cmpltps(xmm5, xmm1);
539 12 : __ cmpltps(xmm5, Operand(rbx, rcx, times_4, 10000));
540 : __ cmpleps(xmm5, xmm1);
541 12 : __ cmpleps(xmm5, Operand(rbx, rcx, times_4, 10000));
542 : __ cmpneqps(xmm5, xmm1);
543 12 : __ cmpneqps(xmm5, Operand(rbx, rcx, times_4, 10000));
544 : __ cmpnltps(xmm5, xmm1);
545 12 : __ cmpnltps(xmm5, Operand(rbx, rcx, times_4, 10000));
546 : __ cmpnleps(xmm5, xmm1);
547 12 : __ cmpnleps(xmm5, Operand(rbx, rcx, times_4, 10000));
548 6 : __ cmppd(xmm5, xmm1, 1);
549 6 : __ cmppd(xmm5, Operand(rbx, rcx, times_4, 10000), 1);
550 : __ cmpeqpd(xmm5, xmm1);
551 12 : __ cmpeqpd(xmm5, Operand(rbx, rcx, times_4, 10000));
552 : __ cmpltpd(xmm5, xmm1);
553 12 : __ cmpltpd(xmm5, Operand(rbx, rcx, times_4, 10000));
554 : __ cmplepd(xmm5, xmm1);
555 12 : __ cmplepd(xmm5, Operand(rbx, rcx, times_4, 10000));
556 : __ cmpneqpd(xmm5, xmm1);
557 12 : __ cmpneqpd(xmm5, Operand(rbx, rcx, times_4, 10000));
558 : __ cmpnltpd(xmm5, xmm1);
559 12 : __ cmpnltpd(xmm5, Operand(rbx, rcx, times_4, 10000));
560 : __ cmpnlepd(xmm5, xmm1);
561 12 : __ cmpnlepd(xmm5, Operand(rbx, rcx, times_4, 10000));
562 :
563 6 : __ minps(xmm5, xmm1);
564 6 : __ minps(xmm5, Operand(rdx, 4));
565 6 : __ maxps(xmm5, xmm1);
566 6 : __ maxps(xmm5, Operand(rdx, 4));
567 6 : __ rcpps(xmm5, xmm1);
568 6 : __ rcpps(xmm5, Operand(rdx, 4));
569 6 : __ sqrtps(xmm5, xmm1);
570 6 : __ sqrtps(xmm5, Operand(rdx, 4));
571 6 : __ movups(xmm5, xmm1);
572 6 : __ movups(xmm5, Operand(rdx, 4));
573 6 : __ movups(Operand(rdx, 4), xmm5);
574 : __ pmulld(xmm5, xmm1);
575 12 : __ pmulld(xmm5, Operand(rdx, 4));
576 : __ pmullw(xmm5, xmm1);
577 12 : __ pmullw(xmm5, Operand(rdx, 4));
578 : __ pmuludq(xmm5, xmm1);
579 12 : __ pmuludq(xmm5, Operand(rdx, 4));
580 6 : __ psrldq(xmm5, 123);
581 6 : __ pshufd(xmm5, xmm1, 3);
582 : __ cvtps2dq(xmm5, xmm1);
583 12 : __ cvtps2dq(xmm5, Operand(rdx, 4));
584 6 : __ cvtdq2ps(xmm5, xmm1);
585 6 : __ cvtdq2ps(xmm5, Operand(rdx, 4));
586 :
587 132 : SSE4_INSTRUCTION_LIST(EMIT_SSE34_INSTR)
588 : }
589 : }
590 : #undef EMIT_SSE34_INSTR
591 :
592 : // AVX instruction
593 : {
594 6 : if (CpuFeatures::IsSupported(AVX)) {
595 : CpuFeatureScope scope(&assm, AVX);
596 : __ vmovss(xmm6, xmm14, xmm2);
597 12 : __ vmovss(xmm9, Operand(rbx, rcx, times_4, 10000));
598 12 : __ vmovss(Operand(rbx, rcx, times_4, 10000), xmm0);
599 :
600 : __ vaddss(xmm0, xmm1, xmm2);
601 12 : __ vaddss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
602 : __ vmulss(xmm0, xmm1, xmm2);
603 12 : __ vmulss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
604 : __ vsubss(xmm0, xmm1, xmm2);
605 12 : __ vsubss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
606 : __ vdivss(xmm0, xmm1, xmm2);
607 12 : __ vdivss(xmm0, xmm1, Operand(rbx, rcx, times_2, 10000));
608 : __ vminss(xmm8, xmm1, xmm2);
609 12 : __ vminss(xmm9, xmm1, Operand(rbx, rcx, times_8, 10000));
610 : __ vmaxss(xmm8, xmm1, xmm2);
611 12 : __ vmaxss(xmm9, xmm1, Operand(rbx, rcx, times_1, 10000));
612 12 : __ vmovss(xmm9, Operand(r11, rcx, times_8, -10000));
613 12 : __ vmovss(Operand(rbx, r9, times_4, 10000), xmm1);
614 6 : __ vucomiss(xmm9, xmm1);
615 6 : __ vucomiss(xmm8, Operand(rbx, rdx, times_2, 10981));
616 :
617 6 : __ vmovd(xmm5, rdi);
618 6 : __ vmovd(xmm9, Operand(rbx, rcx, times_4, 10000));
619 6 : __ vmovd(r9, xmm6);
620 6 : __ vmovq(xmm5, rdi);
621 6 : __ vmovq(xmm9, Operand(rbx, rcx, times_4, 10000));
622 6 : __ vmovq(r9, xmm6);
623 :
624 6 : __ vmovsd(xmm6, xmm14, xmm2);
625 6 : __ vmovsd(xmm9, Operand(rbx, rcx, times_4, 10000));
626 6 : __ vmovsd(Operand(rbx, rcx, times_4, 10000), xmm0);
627 :
628 6 : __ vaddsd(xmm0, xmm1, xmm2);
629 6 : __ vaddsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
630 6 : __ vmulsd(xmm0, xmm1, xmm2);
631 6 : __ vmulsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
632 6 : __ vsubsd(xmm0, xmm1, xmm2);
633 6 : __ vsubsd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
634 6 : __ vdivsd(xmm0, xmm1, xmm2);
635 6 : __ vdivsd(xmm0, xmm1, Operand(rbx, rcx, times_2, 10000));
636 6 : __ vminsd(xmm8, xmm1, xmm2);
637 6 : __ vminsd(xmm9, xmm1, Operand(rbx, rcx, times_8, 10000));
638 6 : __ vmaxsd(xmm8, xmm1, xmm2);
639 6 : __ vmaxsd(xmm9, xmm1, Operand(rbx, rcx, times_1, 10000));
640 6 : __ vroundsd(xmm8, xmm3, xmm0, kRoundDown);
641 6 : __ vsqrtsd(xmm8, xmm1, xmm2);
642 6 : __ vsqrtsd(xmm9, xmm1, Operand(rbx, rcx, times_1, 10000));
643 : __ vucomisd(xmm9, xmm1);
644 12 : __ vucomisd(xmm8, Operand(rbx, rdx, times_2, 10981));
645 :
646 : __ vcvtss2sd(xmm4, xmm9, xmm11);
647 6 : __ vcvtsd2ss(xmm9, xmm3, xmm2);
648 12 : __ vcvtss2sd(xmm4, xmm9, Operand(rbx, rcx, times_1, 10000));
649 6 : __ vcvtsd2ss(xmm9, xmm3, Operand(rbx, rcx, times_1, 10000));
650 : __ vcvtlsi2sd(xmm5, xmm9, rcx);
651 12 : __ vcvtlsi2sd(xmm9, xmm3, Operand(rbx, r9, times_4, 10000));
652 : __ vcvtqsi2sd(xmm5, xmm9, r11);
653 6 : __ vcvttsd2si(r9, xmm6);
654 6 : __ vcvttsd2si(rax, Operand(rbx, r9, times_4, 10000));
655 6 : __ vcvttsd2siq(rdi, xmm9);
656 6 : __ vcvttsd2siq(r8, Operand(r9, rbx, times_4, 10000));
657 6 : __ vcvtsd2si(rdi, xmm9);
658 :
659 : __ vmovaps(xmm10, xmm11);
660 : __ vmovapd(xmm7, xmm0);
661 12 : __ vmovupd(xmm0, Operand(rbx, rcx, times_4, 10000));
662 12 : __ vmovupd(Operand(rbx, rcx, times_4, 10000), xmm0);
663 : __ vmovmskpd(r9, xmm4);
664 :
665 : __ vmovups(xmm5, xmm1);
666 12 : __ vmovups(xmm5, Operand(rdx, 4));
667 12 : __ vmovups(Operand(rdx, 4), xmm5);
668 :
669 : __ vandps(xmm0, xmm9, xmm2);
670 12 : __ vandps(xmm9, xmm1, Operand(rbx, rcx, times_4, 10000));
671 : __ vxorps(xmm0, xmm1, xmm9);
672 12 : __ vxorps(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
673 :
674 : __ vandpd(xmm0, xmm9, xmm2);
675 12 : __ vandpd(xmm9, xmm1, Operand(rbx, rcx, times_4, 10000));
676 : __ vorpd(xmm0, xmm1, xmm9);
677 12 : __ vorpd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
678 : __ vxorpd(xmm0, xmm1, xmm9);
679 12 : __ vxorpd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
680 :
681 : __ vpcmpeqd(xmm0, xmm15, xmm5);
682 12 : __ vpcmpeqd(xmm15, xmm0, Operand(rbx, rcx, times_4, 10000));
683 : __ vpsllq(xmm0, xmm15, 21);
684 : __ vpsrlq(xmm15, xmm0, 21);
685 :
686 : __ vcmpps(xmm5, xmm4, xmm1, 1);
687 12 : __ vcmpps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000), 1);
688 6 : __ vcmpeqps(xmm5, xmm4, xmm1);
689 6 : __ vcmpeqps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
690 6 : __ vcmpltps(xmm5, xmm4, xmm1);
691 6 : __ vcmpltps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
692 6 : __ vcmpleps(xmm5, xmm4, xmm1);
693 6 : __ vcmpleps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
694 6 : __ vcmpneqps(xmm5, xmm4, xmm1);
695 6 : __ vcmpneqps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
696 6 : __ vcmpnltps(xmm5, xmm4, xmm1);
697 6 : __ vcmpnltps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
698 6 : __ vcmpnleps(xmm5, xmm4, xmm1);
699 6 : __ vcmpnleps(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
700 : __ vcmppd(xmm5, xmm4, xmm1, 1);
701 12 : __ vcmppd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000), 1);
702 6 : __ vcmpeqpd(xmm5, xmm4, xmm1);
703 6 : __ vcmpeqpd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
704 6 : __ vcmpltpd(xmm5, xmm4, xmm1);
705 6 : __ vcmpltpd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
706 6 : __ vcmplepd(xmm5, xmm4, xmm1);
707 6 : __ vcmplepd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
708 6 : __ vcmpneqpd(xmm5, xmm4, xmm1);
709 6 : __ vcmpneqpd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
710 6 : __ vcmpnltpd(xmm5, xmm4, xmm1);
711 6 : __ vcmpnltpd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
712 6 : __ vcmpnlepd(xmm5, xmm4, xmm1);
713 6 : __ vcmpnlepd(xmm5, xmm4, Operand(rbx, rcx, times_4, 10000));
714 :
715 : #define EMIT_SSE2_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3) \
716 : __ v##instruction(xmm10, xmm5, xmm1); \
717 : __ v##instruction(xmm10, xmm5, Operand(rdx, 4));
718 :
719 : #define EMIT_SSE34_AVXINSTR(instruction, notUsed1, notUsed2, notUsed3, \
720 : notUsed4) \
721 : __ v##instruction(xmm10, xmm5, xmm1); \
722 : __ v##instruction(xmm10, xmm5, Operand(rdx, 4));
723 :
724 468 : SSE2_INSTRUCTION_LIST(EMIT_SSE2_AVXINSTR)
725 108 : SSSE3_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR)
726 132 : SSE4_INSTRUCTION_LIST(EMIT_SSE34_AVXINSTR)
727 : #undef EMIT_SSE2_AVXINSTR
728 : #undef EMIT_SSE34_AVXINSTR
729 :
730 12 : __ vlddqu(xmm1, Operand(rbx, rcx, times_4, 10000));
731 6 : __ vpsllw(xmm0, xmm15, 21);
732 6 : __ vpsrlw(xmm0, xmm15, 21);
733 6 : __ vpsraw(xmm0, xmm15, 21);
734 6 : __ vpsrad(xmm0, xmm15, 21);
735 6 : __ vpextrb(rax, xmm2, 12);
736 6 : __ vpextrb(Operand(rbx, rcx, times_4, 10000), xmm2, 12);
737 6 : __ vpextrw(rax, xmm2, 5);
738 6 : __ vpextrw(Operand(rbx, rcx, times_4, 10000), xmm2, 5);
739 6 : __ vpextrd(rax, xmm2, 2);
740 6 : __ vpextrd(Operand(rbx, rcx, times_4, 10000), xmm2, 2);
741 :
742 6 : __ vpinsrb(xmm1, xmm2, rax, 12);
743 6 : __ vpinsrb(xmm1, xmm2, Operand(rbx, rcx, times_4, 10000), 12);
744 6 : __ vpinsrw(xmm1, xmm2, rax, 5);
745 6 : __ vpinsrw(xmm1, xmm2, Operand(rbx, rcx, times_4, 10000), 5);
746 6 : __ vpinsrd(xmm1, xmm2, rax, 2);
747 6 : __ vpinsrd(xmm1, xmm2, Operand(rbx, rcx, times_4, 10000), 2);
748 6 : __ vpshufd(xmm1, xmm2, 85);
749 : }
750 : }
751 :
752 : // FMA3 instruction
753 : {
754 6 : if (CpuFeatures::IsSupported(FMA3)) {
755 : CpuFeatureScope scope(&assm, FMA3);
756 : __ vfmadd132sd(xmm0, xmm1, xmm2);
757 12 : __ vfmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
758 : __ vfmadd213sd(xmm0, xmm1, xmm2);
759 12 : __ vfmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
760 : __ vfmadd231sd(xmm0, xmm1, xmm2);
761 12 : __ vfmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
762 :
763 : __ vfmadd132sd(xmm9, xmm10, xmm11);
764 12 : __ vfmadd132sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
765 : __ vfmadd213sd(xmm9, xmm10, xmm11);
766 12 : __ vfmadd213sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
767 : __ vfmadd231sd(xmm9, xmm10, xmm11);
768 12 : __ vfmadd231sd(xmm9, xmm10, Operand(r9, r11, times_4, 10000));
769 :
770 : __ vfmsub132sd(xmm0, xmm1, xmm2);
771 12 : __ vfmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
772 : __ vfmsub213sd(xmm0, xmm1, xmm2);
773 12 : __ vfmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
774 : __ vfmsub231sd(xmm0, xmm1, xmm2);
775 12 : __ vfmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
776 :
777 : __ vfnmadd132sd(xmm0, xmm1, xmm2);
778 12 : __ vfnmadd132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
779 : __ vfnmadd213sd(xmm0, xmm1, xmm2);
780 12 : __ vfnmadd213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
781 : __ vfnmadd231sd(xmm0, xmm1, xmm2);
782 12 : __ vfnmadd231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
783 :
784 : __ vfnmsub132sd(xmm0, xmm1, xmm2);
785 12 : __ vfnmsub132sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
786 : __ vfnmsub213sd(xmm0, xmm1, xmm2);
787 12 : __ vfnmsub213sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
788 : __ vfnmsub231sd(xmm0, xmm1, xmm2);
789 12 : __ vfnmsub231sd(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
790 :
791 : __ vfmadd132ss(xmm0, xmm1, xmm2);
792 12 : __ vfmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
793 : __ vfmadd213ss(xmm0, xmm1, xmm2);
794 12 : __ vfmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
795 : __ vfmadd231ss(xmm0, xmm1, xmm2);
796 12 : __ vfmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
797 :
798 : __ vfmsub132ss(xmm0, xmm1, xmm2);
799 12 : __ vfmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
800 : __ vfmsub213ss(xmm0, xmm1, xmm2);
801 12 : __ vfmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
802 : __ vfmsub231ss(xmm0, xmm1, xmm2);
803 12 : __ vfmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
804 :
805 : __ vfnmadd132ss(xmm0, xmm1, xmm2);
806 12 : __ vfnmadd132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
807 : __ vfnmadd213ss(xmm0, xmm1, xmm2);
808 12 : __ vfnmadd213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
809 : __ vfnmadd231ss(xmm0, xmm1, xmm2);
810 12 : __ vfnmadd231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
811 :
812 : __ vfnmsub132ss(xmm0, xmm1, xmm2);
813 12 : __ vfnmsub132ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
814 : __ vfnmsub213ss(xmm0, xmm1, xmm2);
815 12 : __ vfnmsub213ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
816 : __ vfnmsub231ss(xmm0, xmm1, xmm2);
817 12 : __ vfnmsub231ss(xmm0, xmm1, Operand(rbx, rcx, times_4, 10000));
818 : }
819 : }
820 :
821 : // BMI1 instructions
822 : {
823 6 : if (CpuFeatures::IsSupported(BMI1)) {
824 : CpuFeatureScope scope(&assm, BMI1);
825 : __ andnq(rax, rbx, rcx);
826 12 : __ andnq(rax, rbx, Operand(rbx, rcx, times_4, 10000));
827 : __ andnl(rax, rbx, rcx);
828 12 : __ andnl(rax, rbx, Operand(rbx, rcx, times_4, 10000));
829 : __ bextrq(rax, rbx, rcx);
830 12 : __ bextrq(rax, Operand(rbx, rcx, times_4, 10000), rbx);
831 : __ bextrl(rax, rbx, rcx);
832 12 : __ bextrl(rax, Operand(rbx, rcx, times_4, 10000), rbx);
833 : __ blsiq(rax, rbx);
834 12 : __ blsiq(rax, Operand(rbx, rcx, times_4, 10000));
835 : __ blsil(rax, rbx);
836 12 : __ blsil(rax, Operand(rbx, rcx, times_4, 10000));
837 : __ blsmskq(rax, rbx);
838 12 : __ blsmskq(rax, Operand(rbx, rcx, times_4, 10000));
839 : __ blsmskl(rax, rbx);
840 12 : __ blsmskl(rax, Operand(rbx, rcx, times_4, 10000));
841 : __ blsrq(rax, rbx);
842 12 : __ blsrq(rax, Operand(rbx, rcx, times_4, 10000));
843 : __ blsrl(rax, rbx);
844 12 : __ blsrl(rax, Operand(rbx, rcx, times_4, 10000));
845 6 : __ tzcntq(rax, rbx);
846 6 : __ tzcntq(rax, Operand(rbx, rcx, times_4, 10000));
847 6 : __ tzcntl(rax, rbx);
848 6 : __ tzcntl(rax, Operand(rbx, rcx, times_4, 10000));
849 : }
850 : }
851 :
852 : // LZCNT instructions
853 : {
854 6 : if (CpuFeatures::IsSupported(LZCNT)) {
855 : CpuFeatureScope scope(&assm, LZCNT);
856 6 : __ lzcntq(rax, rbx);
857 6 : __ lzcntq(rax, Operand(rbx, rcx, times_4, 10000));
858 6 : __ lzcntl(rax, rbx);
859 6 : __ lzcntl(rax, Operand(rbx, rcx, times_4, 10000));
860 : }
861 : }
862 :
863 : // POPCNT instructions
864 : {
865 6 : if (CpuFeatures::IsSupported(POPCNT)) {
866 : CpuFeatureScope scope(&assm, POPCNT);
867 6 : __ popcntq(rax, rbx);
868 6 : __ popcntq(rax, Operand(rbx, rcx, times_4, 10000));
869 6 : __ popcntl(rax, rbx);
870 6 : __ popcntl(rax, Operand(rbx, rcx, times_4, 10000));
871 : }
872 : }
873 :
874 : // BMI2 instructions
875 : {
876 6 : if (CpuFeatures::IsSupported(BMI2)) {
877 : CpuFeatureScope scope(&assm, BMI2);
878 : __ bzhiq(rax, rbx, rcx);
879 12 : __ bzhiq(rax, Operand(rbx, rcx, times_4, 10000), rbx);
880 : __ bzhil(rax, rbx, rcx);
881 12 : __ bzhil(rax, Operand(rbx, rcx, times_4, 10000), rbx);
882 : __ mulxq(rax, rbx, rcx);
883 12 : __ mulxq(rax, rbx, Operand(rbx, rcx, times_4, 10000));
884 : __ mulxl(rax, rbx, rcx);
885 12 : __ mulxl(rax, rbx, Operand(rbx, rcx, times_4, 10000));
886 : __ pdepq(rax, rbx, rcx);
887 12 : __ pdepq(rax, rbx, Operand(rbx, rcx, times_4, 10000));
888 : __ pdepl(rax, rbx, rcx);
889 12 : __ pdepl(rax, rbx, Operand(rbx, rcx, times_4, 10000));
890 : __ pextq(rax, rbx, rcx);
891 12 : __ pextq(rax, rbx, Operand(rbx, rcx, times_4, 10000));
892 : __ pextl(rax, rbx, rcx);
893 12 : __ pextl(rax, rbx, Operand(rbx, rcx, times_4, 10000));
894 : __ sarxq(rax, rbx, rcx);
895 12 : __ sarxq(rax, Operand(rbx, rcx, times_4, 10000), rbx);
896 : __ sarxl(rax, rbx, rcx);
897 12 : __ sarxl(rax, Operand(rbx, rcx, times_4, 10000), rbx);
898 : __ shlxq(rax, rbx, rcx);
899 12 : __ shlxq(rax, Operand(rbx, rcx, times_4, 10000), rbx);
900 : __ shlxl(rax, rbx, rcx);
901 12 : __ shlxl(rax, Operand(rbx, rcx, times_4, 10000), rbx);
902 : __ shrxq(rax, rbx, rcx);
903 12 : __ shrxq(rax, Operand(rbx, rcx, times_4, 10000), rbx);
904 : __ shrxl(rax, rbx, rcx);
905 12 : __ shrxl(rax, Operand(rbx, rcx, times_4, 10000), rbx);
906 6 : __ rorxq(rax, rbx, 63);
907 6 : __ rorxq(rax, Operand(rbx, rcx, times_4, 10000), 63);
908 6 : __ rorxl(rax, rbx, 31);
909 6 : __ rorxl(rax, Operand(rbx, rcx, times_4, 10000), 31);
910 : }
911 : }
912 :
913 : // xchg.
914 : {
915 6 : __ xchgb(rax, Operand(rax, 8));
916 6 : __ xchgw(rax, Operand(rbx, 8));
917 : __ xchgq(rax, rax);
918 : __ xchgq(rax, rbx);
919 : __ xchgq(rbx, rbx);
920 12 : __ xchgq(rbx, Operand(rsp, 12));
921 : }
922 :
923 : // cmpxchg.
924 : {
925 6 : __ cmpxchgb(Operand(rsp, 12), rax);
926 6 : __ cmpxchgw(Operand(rbx, rcx, times_4, 10000), rax);
927 12 : __ cmpxchgl(Operand(rbx, rcx, times_4, 10000), rax);
928 12 : __ cmpxchgq(Operand(rbx, rcx, times_4, 10000), rax);
929 : }
930 :
931 : // lock prefix.
932 : {
933 6 : __ lock();
934 12 : __ cmpxchgl(Operand(rsp, 12), rbx);
935 :
936 6 : __ lock();
937 6 : __ xchgw(rax, Operand(rcx, 8));
938 : }
939 :
940 : // Nop instructions
941 102 : for (int i = 0; i < 16; i++) {
942 96 : __ Nop(i);
943 : }
944 :
945 6 : __ ret(0);
946 :
947 : CodeDesc desc;
948 6 : assm.GetCode(isolate, &desc);
949 : Handle<Code> code =
950 6 : isolate->factory()->NewCode(desc, Code::STUB, Handle<Code>());
951 : USE(code);
952 : #ifdef OBJECT_PRINT
953 : OFStream os(stdout);
954 : code->Print(os);
955 : byte* begin = code->instruction_start();
956 : byte* end = begin + code->instruction_size();
957 : disasm::Disassembler::Disassemble(stdout, begin, end);
958 : #endif
959 6 : }
960 :
961 : #undef __
962 :
963 : } // namespace internal
964 71154 : } // namespace v8
|