1 /*
2  * Copyright (C) 2011 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "assembler_x86.h"
18 
19 #include "base/arena_allocator.h"
20 #include "base/malloc_arena_pool.h"
21 #include "base/stl_util.h"
22 #include "utils/assembler_test.h"
23 
24 namespace art {
25 
TEST(AssemblerX86,CreateBuffer)26 TEST(AssemblerX86, CreateBuffer) {
27   MallocArenaPool pool;
28   ArenaAllocator allocator(&pool);
29   AssemblerBuffer buffer(&allocator);
30   AssemblerBuffer::EnsureCapacity ensured(&buffer);
31   buffer.Emit<uint8_t>(0x42);
32   ASSERT_EQ(static_cast<size_t>(1), buffer.Size());
33   buffer.Emit<int32_t>(42);
34   ASSERT_EQ(static_cast<size_t>(5), buffer.Size());
35 }
36 
37 //
38 // Test fixture.
39 //
40 
41 class AssemblerX86Test : public AssemblerTest<x86::X86Assembler,
42                                               x86::Address,
43                                               x86::Register,
44                                               x86::XmmRegister,
45                                               x86::Immediate> {
46  public:
47   using Base = AssemblerTest<x86::X86Assembler,
48                              x86::Address,
49                              x86::Register,
50                              x86::XmmRegister,
51                              x86::Immediate>;
52 
53  protected:
GetArchitectureString()54   std::string GetArchitectureString() override {
55     return "x86";
56   }
57 
GetAssemblerParameters()58   std::string GetAssemblerParameters() override {
59     return " --32";
60   }
61 
GetDisassembleParameters()62   std::string GetDisassembleParameters() override {
63     return " -D -bbinary -mi386 --no-show-raw-insn";
64   }
65 
SetUpHelpers()66   void SetUpHelpers() override {
67     if (addresses_singleton_.size() == 0) {
68       // One addressing mode to test the repeat drivers.
69       addresses_singleton_.push_back(x86::Address(x86::EAX, x86::EBX, x86::TIMES_1, 2));
70     }
71 
72     if (addresses_.size() == 0) {
73       // Several addressing modes.
74       addresses_.push_back(x86::Address(x86::EDI, x86::EAX, x86::TIMES_1, 15));
75       addresses_.push_back(x86::Address(x86::EDI, x86::EBX, x86::TIMES_2, 16));
76       addresses_.push_back(x86::Address(x86::EDI, x86::ECX, x86::TIMES_4, 17));
77       addresses_.push_back(x86::Address(x86::EDI, x86::EDX, x86::TIMES_8, 18));
78       addresses_.push_back(x86::Address(x86::EAX, -1));
79       addresses_.push_back(x86::Address(x86::EBX, 0));
80       addresses_.push_back(x86::Address(x86::ESI, 1));
81       addresses_.push_back(x86::Address(x86::EDI, 987654321));
82       // Several addressing modes with the special ESP.
83       addresses_.push_back(x86::Address(x86::ESP, x86::EAX, x86::TIMES_1, 15));
84       addresses_.push_back(x86::Address(x86::ESP, x86::EBX, x86::TIMES_2, 16));
85       addresses_.push_back(x86::Address(x86::ESP, x86::ECX, x86::TIMES_4, 17));
86       addresses_.push_back(x86::Address(x86::ESP, x86::EDX, x86::TIMES_8, 18));
87       addresses_.push_back(x86::Address(x86::ESP, -1));
88       addresses_.push_back(x86::Address(x86::ESP, 0));
89       addresses_.push_back(x86::Address(x86::ESP, 1));
90       addresses_.push_back(x86::Address(x86::ESP, 987654321));
91     }
92     if (registers_.size() == 0) {
93       registers_.insert(end(registers_),
94                         {
95                           new x86::Register(x86::EAX),
96                           new x86::Register(x86::EBX),
97                           new x86::Register(x86::ECX),
98                           new x86::Register(x86::EDX),
99                           new x86::Register(x86::EBP),
100                           new x86::Register(x86::ESP),
101                           new x86::Register(x86::ESI),
102                           new x86::Register(x86::EDI)
103                         });
104     }
105 
106     if (fp_registers_.size() == 0) {
107       fp_registers_.insert(end(fp_registers_),
108                            {
109                              new x86::XmmRegister(x86::XMM0),
110                              new x86::XmmRegister(x86::XMM1),
111                              new x86::XmmRegister(x86::XMM2),
112                              new x86::XmmRegister(x86::XMM3),
113                              new x86::XmmRegister(x86::XMM4),
114                              new x86::XmmRegister(x86::XMM5),
115                              new x86::XmmRegister(x86::XMM6),
116                              new x86::XmmRegister(x86::XMM7)
117                            });
118     }
119   }
120 
TearDown()121   void TearDown() override {
122     AssemblerTest::TearDown();
123     STLDeleteElements(&registers_);
124     STLDeleteElements(&fp_registers_);
125   }
126 
GetAddresses()127   std::vector<x86::Address> GetAddresses() override {
128     return addresses_;
129   }
130 
GetRegisters()131   std::vector<x86::Register*> GetRegisters() override {
132     return registers_;
133   }
134 
GetFPRegisters()135   std::vector<x86::XmmRegister*> GetFPRegisters() override {
136     return fp_registers_;
137   }
138 
CreateImmediate(int64_t imm_value)139   x86::Immediate CreateImmediate(int64_t imm_value) override {
140     return x86::Immediate(imm_value);
141   }
142 
143   std::vector<x86::Address> addresses_singleton_;
144 
145  private:
146   std::vector<x86::Address> addresses_;
147   std::vector<x86::Register*> registers_;
148   std::vector<x86::XmmRegister*> fp_registers_;
149 };
150 
151 class AssemblerX86AVXTest : public AssemblerX86Test {
152  public:
AssemblerX86AVXTest()153   AssemblerX86AVXTest()
154       : instruction_set_features_(X86InstructionSetFeatures::FromVariant("kabylake", nullptr)) {}
155  protected:
CreateAssembler(ArenaAllocator * allocator)156   x86::X86Assembler* CreateAssembler(ArenaAllocator* allocator) override {
157   return new (allocator) x86::X86Assembler(allocator, instruction_set_features_.get());
158   }
159  private:
160   std::unique_ptr<const X86InstructionSetFeatures> instruction_set_features_;
161 };
162 
163 //
164 // Test some repeat drivers used in the tests.
165 //
166 
TEST_F(AssemblerX86Test,RepeatRR)167 TEST_F(AssemblerX86Test, RepeatRR) {
168   EXPECT_NE(RepeatRR(/*f*/ nullptr, "%{reg1} %{reg2}")
169             .find("%eax %eax\n%eax %ebx\n%eax %ecx\n%eax %edx\n%eax %ebp\n%eax %esp\n%eax %esi\n"
170                   "%eax %edi\n%ebx %eax\n%ebx %ebx\n%ebx %ecx\n%ebx %edx\n%ebx %ebp\n%ebx %esp\n"),
171             std::string::npos);
172 }
173 
TEST_F(AssemblerX86Test,RepeatRI)174 TEST_F(AssemblerX86Test, RepeatRI) {
175   EXPECT_EQ("%eax $0\n%eax $-1\n%eax $18\n%ebx $0\n%ebx $-1\n%ebx $18\n%ecx $0\n%ecx $-1\n"
176             "%ecx $18\n%edx $0\n%edx $-1\n%edx $18\n%ebp $0\n%ebp $-1\n%ebp $18\n%esp $0\n"
177             "%esp $-1\n%esp $18\n%esi $0\n%esi $-1\n%esi $18\n%edi $0\n%edi $-1\n%edi $18\n",
178             RepeatRI(/*f*/ nullptr, /*imm_bytes*/ 1U, "%{reg} ${imm}"));
179 }
180 
TEST_F(AssemblerX86Test,RepeatFF)181 TEST_F(AssemblerX86Test, RepeatFF) {
182   EXPECT_NE(RepeatFF(/*f*/ nullptr, "%{reg1} %{reg2}")
183             .find("%XMM0 %XMM0\n%XMM0 %XMM1\n%XMM0 %XMM2\n%XMM0 %XMM3\n%XMM0 %XMM4\n%XMM0 %XMM5\n"
184                   "%XMM0 %XMM6\n%XMM0 %XMM7\n%XMM1 %XMM0\n%XMM1 %XMM1\n%XMM1 %XMM2\n%XMM1 %XMM3\n"),
185             std::string::npos);
186 }
187 
TEST_F(AssemblerX86Test,RepeatFFI)188 TEST_F(AssemblerX86Test, RepeatFFI) {
189   EXPECT_NE(RepeatFFI(/*f*/ nullptr, /*imm_bytes*/ 1U, "%{reg1} %{reg2} ${imm}")
190             .find("%XMM0 %XMM0 $0\n%XMM0 %XMM0 $-1\n%XMM0 %XMM0 $18\n"
191                   "%XMM0 %XMM1 $0\n%XMM0 %XMM1 $-1\n%XMM0 %XMM1 $18\n"),
192             std::string::npos);
193 }
194 
TEST_F(AssemblerX86Test,RepeatA)195 TEST_F(AssemblerX86Test, RepeatA) {
196   EXPECT_EQ("2(%eax,%ebx,1)\n", RepeatA(/*f*/ nullptr, addresses_singleton_, "{mem}"));
197 }
198 
TEST_F(AssemblerX86Test,RepeatAI)199 TEST_F(AssemblerX86Test, RepeatAI) {
200   EXPECT_EQ("2(%eax,%ebx,1) $0\n2(%eax,%ebx,1) $-1\n2(%eax,%ebx,1) $18\n",
201             RepeatAI(/*f*/ nullptr, /*imm_bytes*/ 1U, addresses_singleton_, "{mem} ${imm}"));
202 }
203 
TEST_F(AssemblerX86Test,RepeatRA)204 TEST_F(AssemblerX86Test, RepeatRA) {
205   EXPECT_EQ("%eax 2(%eax,%ebx,1)\n%ebx 2(%eax,%ebx,1)\n%ecx 2(%eax,%ebx,1)\n"
206             "%edx 2(%eax,%ebx,1)\n%ebp 2(%eax,%ebx,1)\n%esp 2(%eax,%ebx,1)\n"
207             "%esi 2(%eax,%ebx,1)\n%edi 2(%eax,%ebx,1)\n",
208             RepeatRA(/*f*/ nullptr, addresses_singleton_, "%{reg} {mem}"));
209 }
210 
TEST_F(AssemblerX86Test,RepeatAR)211 TEST_F(AssemblerX86Test, RepeatAR) {
212   EXPECT_EQ("2(%eax,%ebx,1) %eax\n2(%eax,%ebx,1) %ebx\n2(%eax,%ebx,1) %ecx\n"
213             "2(%eax,%ebx,1) %edx\n2(%eax,%ebx,1) %ebp\n2(%eax,%ebx,1) %esp\n"
214             "2(%eax,%ebx,1) %esi\n2(%eax,%ebx,1) %edi\n",
215             RepeatAR(/*f*/ nullptr, addresses_singleton_, "{mem} %{reg}"));
216 }
217 
TEST_F(AssemblerX86Test,RepeatFA)218 TEST_F(AssemblerX86Test, RepeatFA) {
219   EXPECT_EQ("%XMM0 2(%eax,%ebx,1)\n%XMM1 2(%eax,%ebx,1)\n%XMM2 2(%eax,%ebx,1)\n"
220             "%XMM3 2(%eax,%ebx,1)\n%XMM4 2(%eax,%ebx,1)\n%XMM5 2(%eax,%ebx,1)\n"
221             "%XMM6 2(%eax,%ebx,1)\n%XMM7 2(%eax,%ebx,1)\n",
222             RepeatFA(/*f*/ nullptr, addresses_singleton_, "%{reg} {mem}"));
223 }
224 
TEST_F(AssemblerX86Test,RepeatAF)225 TEST_F(AssemblerX86Test, RepeatAF) {
226   EXPECT_EQ("2(%eax,%ebx,1) %XMM0\n2(%eax,%ebx,1) %XMM1\n2(%eax,%ebx,1) %XMM2\n"
227             "2(%eax,%ebx,1) %XMM3\n2(%eax,%ebx,1) %XMM4\n2(%eax,%ebx,1) %XMM5\n"
228             "2(%eax,%ebx,1) %XMM6\n2(%eax,%ebx,1) %XMM7\n",
229             RepeatAF(/*f*/ nullptr, addresses_singleton_, "{mem} %{reg}"));
230 }
231 
232 //
233 // Actual x86 instruction assembler tests.
234 //
235 
TEST_F(AssemblerX86Test,PoplAllAddresses)236 TEST_F(AssemblerX86Test, PoplAllAddresses) {
237   // Make sure all addressing modes combinations are tested at least once.
238   std::vector<x86::Address> all_addresses;
239   for (x86::Register* base : GetRegisters()) {
240     // Base only.
241     all_addresses.push_back(x86::Address(*base, -1));
242     all_addresses.push_back(x86::Address(*base, 0));
243     all_addresses.push_back(x86::Address(*base, 1));
244     all_addresses.push_back(x86::Address(*base, 123456789));
245     for (x86::Register* index : GetRegisters()) {
246       if (*index == x86::ESP) {
247         // Index cannot be ESP.
248         continue;
249       } else if (*base == *index) {
250        // Index only.
251        all_addresses.push_back(x86::Address(*index, x86::TIMES_1, -1));
252        all_addresses.push_back(x86::Address(*index, x86::TIMES_2, 0));
253        all_addresses.push_back(x86::Address(*index, x86::TIMES_4, 1));
254        all_addresses.push_back(x86::Address(*index, x86::TIMES_8, 123456789));
255       }
256       // Base and index.
257       all_addresses.push_back(x86::Address(*base, *index, x86::TIMES_1, -1));
258       all_addresses.push_back(x86::Address(*base, *index, x86::TIMES_2, 0));
259       all_addresses.push_back(x86::Address(*base, *index, x86::TIMES_4, 1));
260       all_addresses.push_back(x86::Address(*base, *index, x86::TIMES_8, 123456789));
261     }
262   }
263   DriverStr(RepeatA(&x86::X86Assembler::popl, all_addresses, "popl {mem}"), "popq");
264 }
265 
TEST_F(AssemblerX86Test,Movl)266 TEST_F(AssemblerX86Test, Movl) {
267   DriverStr(RepeatRR(&x86::X86Assembler::movl, "movl %{reg2}, %{reg1}"), "movl");
268 }
269 
TEST_F(AssemblerX86Test,MovlLoad)270 TEST_F(AssemblerX86Test, MovlLoad) {
271   DriverStr(RepeatRA(&x86::X86Assembler::movl, "movl {mem}, %{reg}"), "movl-load");
272 }
273 
TEST_F(AssemblerX86Test,Addw)274 TEST_F(AssemblerX86Test, Addw) {
275   DriverStr(RepeatAI(&x86::X86Assembler::addw, /*imm_bytes*/ 2U, "addw ${imm}, {mem}"), "addw");
276 }
277 
TEST_F(AssemblerX86Test,MovlStore)278 TEST_F(AssemblerX86Test, MovlStore) {
279   DriverStr(RepeatAR(&x86::X86Assembler::movl, "movl %{reg}, {mem}"), "movl-store");
280 }
281 
TEST_F(AssemblerX86Test,Movntl)282 TEST_F(AssemblerX86Test, Movntl) {
283   DriverStr(RepeatAR(&x86::X86Assembler::movntl, "movntil %{reg}, {mem}"), "movntl");
284 }
285 
TEST_F(AssemblerX86Test,LoadLongConstant)286 TEST_F(AssemblerX86Test, LoadLongConstant) {
287   GetAssembler()->LoadLongConstant(x86::XMM0, 51);
288   const char* expected =
289       "push $0x0\n"
290       "push $0x33\n"
291       "movsd 0(%esp), %xmm0\n"
292       "add $8, %esp\n";
293   DriverStr(expected, "LoadLongConstant");
294 }
295 
TEST_F(AssemblerX86Test,LockCmpxchgl)296 TEST_F(AssemblerX86Test, LockCmpxchgl) {
297   DriverStr(RepeatAR(&x86::X86Assembler::LockCmpxchgl,
298                      "lock cmpxchgl %{reg}, {mem}"), "lock_cmpxchgl");
299 }
300 
TEST_F(AssemblerX86Test,LockCmpxchg8b)301 TEST_F(AssemblerX86Test, LockCmpxchg8b) {
302   DriverStr(RepeatA(&x86::X86Assembler::LockCmpxchg8b,
303                     "lock cmpxchg8b {mem}"), "lock_cmpxchg8b");
304 }
305 
TEST_F(AssemblerX86Test,FPUIntegerLoadS)306 TEST_F(AssemblerX86Test, FPUIntegerLoadS) {
307   DriverStr(RepeatA(&x86::X86Assembler::filds, "fildl {mem}"), "fildd");
308 }
309 
TEST_F(AssemblerX86Test,FPUIntegerLoadL)310 TEST_F(AssemblerX86Test, FPUIntegerLoadL) {
311   DriverStr(RepeatA(&x86::X86Assembler::fildl, "fildll {mem}"), "fildl");
312 }
313 
TEST_F(AssemblerX86Test,FPUIntegerStoreS)314 TEST_F(AssemblerX86Test, FPUIntegerStoreS) {
315   DriverStr(RepeatA(&x86::X86Assembler::fistps, "fistpl {mem}"), "fistps");
316 }
317 
TEST_F(AssemblerX86Test,FPUIntegerStoreL)318 TEST_F(AssemblerX86Test, FPUIntegerStoreL) {
319   DriverStr(RepeatA(&x86::X86Assembler::fistpl, "fistpll {mem}"), "fistpl");
320 }
321 
TEST_F(AssemblerX86Test,Repnescasb)322 TEST_F(AssemblerX86Test, Repnescasb) {
323   GetAssembler()->repne_scasb();
324   const char* expected = "repne scasb\n";
325   DriverStr(expected, "Repnescasb");
326 }
327 
TEST_F(AssemblerX86Test,Repnescasw)328 TEST_F(AssemblerX86Test, Repnescasw) {
329   GetAssembler()->repne_scasw();
330   const char* expected = "repne scasw\n";
331   DriverStr(expected, "Repnescasw");
332 }
333 
TEST_F(AssemblerX86Test,Repecmpsb)334 TEST_F(AssemblerX86Test, Repecmpsb) {
335   GetAssembler()->repe_cmpsb();
336   const char* expected = "repe cmpsb\n";
337   DriverStr(expected, "Repecmpsb");
338 }
339 
TEST_F(AssemblerX86Test,Repecmpsw)340 TEST_F(AssemblerX86Test, Repecmpsw) {
341   GetAssembler()->repe_cmpsw();
342   const char* expected = "repe cmpsw\n";
343   DriverStr(expected, "Repecmpsw");
344 }
345 
TEST_F(AssemblerX86Test,Repecmpsl)346 TEST_F(AssemblerX86Test, Repecmpsl) {
347   GetAssembler()->repe_cmpsl();
348   const char* expected = "repe cmpsl\n";
349   DriverStr(expected, "Repecmpsl");
350 }
351 
TEST_F(AssemblerX86Test,RepMovsb)352 TEST_F(AssemblerX86Test, RepMovsb) {
353   GetAssembler()->rep_movsb();
354   const char* expected = "rep movsb\n";
355   DriverStr(expected, "rep_movsb");
356 }
357 
TEST_F(AssemblerX86Test,RepMovsw)358 TEST_F(AssemblerX86Test, RepMovsw) {
359   GetAssembler()->rep_movsw();
360   const char* expected = "rep movsw\n";
361   DriverStr(expected, "rep_movsw");
362 }
363 
TEST_F(AssemblerX86Test,Blsmask)364 TEST_F(AssemblerX86Test, Blsmask) {
365   DriverStr(RepeatRR(&x86::X86Assembler::blsmsk, "blsmsk %{reg2}, %{reg1}"), "blsmsk");
366 }
367 
TEST_F(AssemblerX86Test,Blsi)368 TEST_F(AssemblerX86Test, Blsi) {
369   DriverStr(RepeatRR(&x86::X86Assembler::blsi, "blsi %{reg2}, %{reg1}"), "blsi");
370 }
371 
TEST_F(AssemblerX86Test,Blsr)372 TEST_F(AssemblerX86Test, Blsr) {
373   DriverStr(RepeatRR(&x86::X86Assembler::blsr, "blsr %{reg2}, %{reg1}"), "blsr");
374 }
375 
TEST_F(AssemblerX86Test,Bsfl)376 TEST_F(AssemblerX86Test, Bsfl) {
377   DriverStr(RepeatRR(&x86::X86Assembler::bsfl, "bsfl %{reg2}, %{reg1}"), "bsfl");
378 }
379 
TEST_F(AssemblerX86Test,BsflAddress)380 TEST_F(AssemblerX86Test, BsflAddress) {
381   DriverStr(RepeatRA(&x86::X86Assembler::bsfl, "bsfl {mem}, %{reg}"), "bsfl_address");
382 }
383 
TEST_F(AssemblerX86Test,Bsrl)384 TEST_F(AssemblerX86Test, Bsrl) {
385   DriverStr(RepeatRR(&x86::X86Assembler::bsrl, "bsrl %{reg2}, %{reg1}"), "bsrl");
386 }
387 
TEST_F(AssemblerX86Test,BsrlAddress)388 TEST_F(AssemblerX86Test, BsrlAddress) {
389   DriverStr(RepeatRA(&x86::X86Assembler::bsrl, "bsrl {mem}, %{reg}"), "bsrl_address");
390 }
391 
TEST_F(AssemblerX86Test,Popcntl)392 TEST_F(AssemblerX86Test, Popcntl) {
393   DriverStr(RepeatRR(&x86::X86Assembler::popcntl, "popcntl %{reg2}, %{reg1}"), "popcntl");
394 }
395 
TEST_F(AssemblerX86Test,PopcntlAddress)396 TEST_F(AssemblerX86Test, PopcntlAddress) {
397   DriverStr(RepeatRA(&x86::X86Assembler::popcntl, "popcntl {mem}, %{reg}"), "popcntl_address");
398 }
399 
400 // Rorl only allows CL as the shift count.
rorl_fn(AssemblerX86Test::Base * assembler_test,x86::X86Assembler * assembler)401 std::string rorl_fn(AssemblerX86Test::Base* assembler_test, x86::X86Assembler* assembler) {
402   std::ostringstream str;
403   std::vector<x86::Register*> registers = assembler_test->GetRegisters();
404   x86::Register shifter(x86::ECX);
405   for (auto reg : registers) {
406     assembler->rorl(*reg, shifter);
407     str << "rorl %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
408   }
409   return str.str();
410 }
411 
TEST_F(AssemblerX86Test,RorlReg)412 TEST_F(AssemblerX86Test, RorlReg) {
413   DriverFn(&rorl_fn, "rorl");
414 }
415 
TEST_F(AssemblerX86Test,RorlImm)416 TEST_F(AssemblerX86Test, RorlImm) {
417   DriverStr(RepeatRI(&x86::X86Assembler::rorl, /*imm_bytes*/ 1U, "rorl ${imm}, %{reg}"), "rorli");
418 }
419 
420 // Roll only allows CL as the shift count.
roll_fn(AssemblerX86Test::Base * assembler_test,x86::X86Assembler * assembler)421 std::string roll_fn(AssemblerX86Test::Base* assembler_test, x86::X86Assembler* assembler) {
422   std::ostringstream str;
423   std::vector<x86::Register*> registers = assembler_test->GetRegisters();
424   x86::Register shifter(x86::ECX);
425   for (auto reg : registers) {
426     assembler->roll(*reg, shifter);
427     str << "roll %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
428   }
429   return str.str();
430 }
431 
TEST_F(AssemblerX86Test,RollReg)432 TEST_F(AssemblerX86Test, RollReg) {
433   DriverFn(&roll_fn, "roll");
434 }
435 
TEST_F(AssemblerX86Test,RollImm)436 TEST_F(AssemblerX86Test, RollImm) {
437   DriverStr(RepeatRI(&x86::X86Assembler::roll, /*imm_bytes*/ 1U, "roll ${imm}, %{reg}"), "rolli");
438 }
439 
TEST_F(AssemblerX86Test,Cvtdq2ps)440 TEST_F(AssemblerX86Test, Cvtdq2ps) {
441   DriverStr(RepeatFF(&x86::X86Assembler::cvtdq2ps, "cvtdq2ps %{reg2}, %{reg1}"), "cvtdq2ps");
442 }
443 
TEST_F(AssemblerX86Test,Cvtdq2pd)444 TEST_F(AssemblerX86Test, Cvtdq2pd) {
445   DriverStr(RepeatFF(&x86::X86Assembler::cvtdq2pd, "cvtdq2pd %{reg2}, %{reg1}"), "cvtdq2pd");
446 }
447 
TEST_F(AssemblerX86Test,ComissAddr)448 TEST_F(AssemblerX86Test, ComissAddr) {
449   DriverStr(RepeatFA(&x86::X86Assembler::comiss, "comiss {mem}, %{reg}"), "comiss");
450 }
451 
TEST_F(AssemblerX86Test,UComissAddr)452 TEST_F(AssemblerX86Test, UComissAddr) {
453   DriverStr(RepeatFA(&x86::X86Assembler::ucomiss, "ucomiss {mem}, %{reg}"), "ucomiss");
454 }
455 
TEST_F(AssemblerX86Test,ComisdAddr)456 TEST_F(AssemblerX86Test, ComisdAddr) {
457   DriverStr(RepeatFA(&x86::X86Assembler::comisd, "comisd {mem}, %{reg}"), "comisd");
458 }
459 
TEST_F(AssemblerX86Test,UComisdAddr)460 TEST_F(AssemblerX86Test, UComisdAddr) {
461   DriverStr(RepeatFA(&x86::X86Assembler::ucomisd, "ucomisd {mem}, %{reg}"), "ucomisd");
462 }
463 
TEST_F(AssemblerX86Test,RoundSS)464 TEST_F(AssemblerX86Test, RoundSS) {
465   DriverStr(RepeatFFI(&x86::X86Assembler::roundss, /*imm_bytes*/ 1U,
466                       "roundss ${imm}, %{reg2}, %{reg1}"), "roundss");
467 }
468 
TEST_F(AssemblerX86Test,RoundSD)469 TEST_F(AssemblerX86Test, RoundSD) {
470   DriverStr(RepeatFFI(&x86::X86Assembler::roundsd, /*imm_bytes*/ 1U,
471                       "roundsd ${imm}, %{reg2}, %{reg1}"), "roundsd");
472 }
473 
TEST_F(AssemblerX86Test,CmovlAddress)474 TEST_F(AssemblerX86Test, CmovlAddress) {
475   GetAssembler()->cmovl(x86::kEqual, x86::Register(x86::EAX), x86::Address(
476       x86::Register(x86::EDI), x86::Register(x86::EBX), x86::TIMES_4, 12));
477   GetAssembler()->cmovl(x86::kNotEqual, x86::Register(x86::EDI), x86::Address(
478       x86::Register(x86::ESI), x86::Register(x86::EBX), x86::TIMES_4, 12));
479   GetAssembler()->cmovl(x86::kEqual, x86::Register(x86::EDI), x86::Address(
480       x86::Register(x86::EDI), x86::Register(x86::EAX), x86::TIMES_4, 12));
481   const char* expected =
482     "cmovzl 0xc(%EDI,%EBX,4), %eax\n"
483     "cmovnzl 0xc(%ESI,%EBX,4), %edi\n"
484     "cmovzl 0xc(%EDI,%EAX,4), %edi\n";
485   DriverStr(expected, "cmovl_address");
486 }
487 
TEST_F(AssemblerX86Test,TestbAddressImmediate)488 TEST_F(AssemblerX86Test, TestbAddressImmediate) {
489   DriverStr(RepeatAI(&x86::X86Assembler::testb, /*imm_bytes*/ 1U, "testb ${imm}, {mem}"), "testb");
490 }
491 
TEST_F(AssemblerX86Test,TestlAddressImmediate)492 TEST_F(AssemblerX86Test, TestlAddressImmediate) {
493   DriverStr(RepeatAI(&x86::X86Assembler::testl, /*imm_bytes*/ 4U, "testl ${imm}, {mem}"), "testl");
494 }
495 
TEST_F(AssemblerX86Test,Movaps)496 TEST_F(AssemblerX86Test, Movaps) {
497   DriverStr(RepeatFF(&x86::X86Assembler::movaps, "movaps %{reg2}, %{reg1}"), "movaps");
498 }
499 
TEST_F(AssemblerX86AVXTest,VMovaps)500 TEST_F(AssemblerX86AVXTest, VMovaps) {
501   DriverStr(RepeatFF(&x86::X86Assembler::vmovaps, "vmovaps %{reg2}, %{reg1}"), "vmovaps");
502 }
503 
TEST_F(AssemblerX86AVXTest,Movaps)504 TEST_F(AssemblerX86AVXTest, Movaps) {
505   DriverStr(RepeatFF(&x86::X86Assembler::movaps, "vmovaps %{reg2}, %{reg1}"), "avx_movaps");
506 }
507 
TEST_F(AssemblerX86Test,MovapsLoad)508 TEST_F(AssemblerX86Test, MovapsLoad) {
509   DriverStr(RepeatFA(&x86::X86Assembler::movaps, "movaps {mem}, %{reg}"), "movaps_load");
510 }
511 
TEST_F(AssemblerX86AVXTest,VMovapsLoad)512 TEST_F(AssemblerX86AVXTest, VMovapsLoad) {
513   DriverStr(RepeatFA(&x86::X86Assembler::vmovaps, "vmovaps {mem}, %{reg}"), "vmovaps_load");
514 }
515 
TEST_F(AssemblerX86AVXTest,MovapsLoad)516 TEST_F(AssemblerX86AVXTest, MovapsLoad) {
517   DriverStr(RepeatFA(&x86::X86Assembler::movaps, "vmovaps {mem}, %{reg}"), "avx_movaps_load");
518 }
519 
TEST_F(AssemblerX86Test,MovapsStore)520 TEST_F(AssemblerX86Test, MovapsStore) {
521   DriverStr(RepeatAF(&x86::X86Assembler::movaps, "movaps %{reg}, {mem}"), "movaps_store");
522 }
523 
TEST_F(AssemblerX86AVXTest,VMovapsStore)524 TEST_F(AssemblerX86AVXTest, VMovapsStore) {
525   DriverStr(RepeatAF(&x86::X86Assembler::vmovaps, "vmovaps %{reg}, {mem}"), "vmovaps_store");
526 }
527 
TEST_F(AssemblerX86AVXTest,MovapsStore)528 TEST_F(AssemblerX86AVXTest, MovapsStore) {
529   DriverStr(RepeatAF(&x86::X86Assembler::movaps, "vmovaps %{reg}, {mem}"), "avx_movaps_store");
530 }
531 
TEST_F(AssemblerX86Test,MovupsLoad)532 TEST_F(AssemblerX86Test, MovupsLoad) {
533   DriverStr(RepeatFA(&x86::X86Assembler::movups, "movups {mem}, %{reg}"), "movups_load");
534 }
535 
TEST_F(AssemblerX86AVXTest,VMovupsLoad)536 TEST_F(AssemblerX86AVXTest, VMovupsLoad) {
537   DriverStr(RepeatFA(&x86::X86Assembler::vmovups, "vmovups {mem}, %{reg}"), "vmovups_load");
538 }
539 
TEST_F(AssemblerX86AVXTest,MovupsLoad)540 TEST_F(AssemblerX86AVXTest, MovupsLoad) {
541   DriverStr(RepeatFA(&x86::X86Assembler::movups, "vmovups {mem}, %{reg}"), "avx_movups_load");
542 }
543 
TEST_F(AssemblerX86Test,MovupsStore)544 TEST_F(AssemblerX86Test, MovupsStore) {
545   DriverStr(RepeatAF(&x86::X86Assembler::movups, "movups %{reg}, {mem}"), "movups_store");
546 }
547 
TEST_F(AssemblerX86AVXTest,VMovupsStore)548 TEST_F(AssemblerX86AVXTest, VMovupsStore) {
549   DriverStr(RepeatAF(&x86::X86Assembler::vmovups, "vmovups %{reg}, {mem}"), "vmovups_store");
550 }
551 
TEST_F(AssemblerX86AVXTest,MovupsStore)552 TEST_F(AssemblerX86AVXTest, MovupsStore) {
553   DriverStr(RepeatAF(&x86::X86Assembler::movups, "vmovups %{reg}, {mem}"), "avx_movups_store");
554 }
555 
TEST_F(AssemblerX86Test,Movapd)556 TEST_F(AssemblerX86Test, Movapd) {
557   DriverStr(RepeatFF(&x86::X86Assembler::movapd, "movapd %{reg2}, %{reg1}"), "movapd");
558 }
559 
TEST_F(AssemblerX86AVXTest,VMovapd)560 TEST_F(AssemblerX86AVXTest, VMovapd) {
561   DriverStr(RepeatFF(&x86::X86Assembler::vmovapd, "vmovapd %{reg2}, %{reg1}"), "vmovapd");
562 }
563 
TEST_F(AssemblerX86AVXTest,Movapd)564 TEST_F(AssemblerX86AVXTest, Movapd) {
565   DriverStr(RepeatFF(&x86::X86Assembler::movapd, "vmovapd %{reg2}, %{reg1}"), "avx_movapd");
566 }
567 
TEST_F(AssemblerX86Test,MovapdLoad)568 TEST_F(AssemblerX86Test, MovapdLoad) {
569   DriverStr(RepeatFA(&x86::X86Assembler::movapd, "movapd {mem}, %{reg}"), "movapd_load");
570 }
571 
TEST_F(AssemblerX86AVXTest,VMovapdLoad)572 TEST_F(AssemblerX86AVXTest, VMovapdLoad) {
573   DriverStr(RepeatFA(&x86::X86Assembler::vmovapd, "vmovapd {mem}, %{reg}"), "vmovapd_load");
574 }
575 
TEST_F(AssemblerX86AVXTest,MovapdLoad)576 TEST_F(AssemblerX86AVXTest, MovapdLoad) {
577   DriverStr(RepeatFA(&x86::X86Assembler::movapd, "vmovapd {mem}, %{reg}"), "avx_movapd_load");
578 }
579 
TEST_F(AssemblerX86Test,MovapdStore)580 TEST_F(AssemblerX86Test, MovapdStore) {
581   DriverStr(RepeatAF(&x86::X86Assembler::movapd, "movapd %{reg}, {mem}"), "movapd_store");
582 }
583 
TEST_F(AssemblerX86AVXTest,VMovapdStore)584 TEST_F(AssemblerX86AVXTest, VMovapdStore) {
585   DriverStr(RepeatAF(&x86::X86Assembler::vmovapd, "vmovapd %{reg}, {mem}"), "vmovapd_store");
586 }
587 
TEST_F(AssemblerX86AVXTest,MovapdStore)588 TEST_F(AssemblerX86AVXTest, MovapdStore) {
589   DriverStr(RepeatAF(&x86::X86Assembler::movapd, "vmovapd %{reg}, {mem}"), "avx_movapd_store");
590 }
591 
TEST_F(AssemblerX86Test,MovupdLoad)592 TEST_F(AssemblerX86Test, MovupdLoad) {
593   DriverStr(RepeatFA(&x86::X86Assembler::movupd, "movupd {mem}, %{reg}"), "movupd_load");
594 }
595 
TEST_F(AssemblerX86AVXTest,VMovupdLoad)596 TEST_F(AssemblerX86AVXTest, VMovupdLoad) {
597   DriverStr(RepeatFA(&x86::X86Assembler::vmovupd, "vmovupd {mem}, %{reg}"), "vmovupd_load");
598 }
599 
TEST_F(AssemblerX86AVXTest,MovupdLoad)600 TEST_F(AssemblerX86AVXTest, MovupdLoad) {
601   DriverStr(RepeatFA(&x86::X86Assembler::movupd, "vmovupd {mem}, %{reg}"), "avx_movupd_load");
602 }
603 
TEST_F(AssemblerX86Test,MovupdStore)604 TEST_F(AssemblerX86Test, MovupdStore) {
605   DriverStr(RepeatAF(&x86::X86Assembler::movupd, "movupd %{reg}, {mem}"), "movupd_store");
606 }
607 
TEST_F(AssemblerX86AVXTest,VMovupdStore)608 TEST_F(AssemblerX86AVXTest, VMovupdStore) {
609   DriverStr(RepeatAF(&x86::X86Assembler::vmovupd, "vmovupd %{reg}, {mem}"), "vmovupd_store");
610 }
611 
TEST_F(AssemblerX86AVXTest,MovupdStore)612 TEST_F(AssemblerX86AVXTest, MovupdStore) {
613   DriverStr(RepeatAF(&x86::X86Assembler::movupd, "vmovupd %{reg}, {mem}"), "avx_movupd_store");
614 }
615 
TEST_F(AssemblerX86Test,Movdqa)616 TEST_F(AssemblerX86Test, Movdqa) {
617   DriverStr(RepeatFF(&x86::X86Assembler::movdqa, "movdqa %{reg2}, %{reg1}"), "movdqa");
618 }
619 
TEST_F(AssemblerX86AVXTest,VMovdqa)620 TEST_F(AssemblerX86AVXTest, VMovdqa) {
621   DriverStr(RepeatFF(&x86::X86Assembler::vmovdqa, "vmovdqa %{reg2}, %{reg1}"), "vmovdqa");
622 }
623 
TEST_F(AssemblerX86AVXTest,Movdqa)624 TEST_F(AssemblerX86AVXTest, Movdqa) {
625   DriverStr(RepeatFF(&x86::X86Assembler::movdqa, "vmovdqa %{reg2}, %{reg1}"), "avx_movdqa");
626 }
627 
TEST_F(AssemblerX86Test,MovdqaLoad)628 TEST_F(AssemblerX86Test, MovdqaLoad) {
629   DriverStr(RepeatFA(&x86::X86Assembler::movdqa, "movdqa {mem}, %{reg}"), "movdqa_load");
630 }
631 
TEST_F(AssemblerX86AVXTest,VMovdqaLoad)632 TEST_F(AssemblerX86AVXTest, VMovdqaLoad) {
633   DriverStr(RepeatFA(&x86::X86Assembler::vmovdqa, "vmovdqa {mem}, %{reg}"), "vmovdqa_load");
634 }
635 
TEST_F(AssemblerX86AVXTest,MovdqaLoad)636 TEST_F(AssemblerX86AVXTest, MovdqaLoad) {
637   DriverStr(RepeatFA(&x86::X86Assembler::movdqa, "vmovdqa {mem}, %{reg}"), "avx_movdqa_load");
638 }
639 
TEST_F(AssemblerX86Test,MovdqaStore)640 TEST_F(AssemblerX86Test, MovdqaStore) {
641   DriverStr(RepeatAF(&x86::X86Assembler::movdqa, "movdqa %{reg}, {mem}"), "movdqa_store");
642 }
643 
TEST_F(AssemblerX86AVXTest,VMovdqaStore)644 TEST_F(AssemblerX86AVXTest, VMovdqaStore) {
645   DriverStr(RepeatAF(&x86::X86Assembler::vmovdqa, "vmovdqa %{reg}, {mem}"), "vmovdqa_store");
646 }
647 
TEST_F(AssemblerX86AVXTest,MovdqaStore)648 TEST_F(AssemblerX86AVXTest, MovdqaStore) {
649   DriverStr(RepeatAF(&x86::X86Assembler::movdqa, "vmovdqa %{reg}, {mem}"), "avx_movdqa_store");
650 }
651 
TEST_F(AssemblerX86Test,MovdquLoad)652 TEST_F(AssemblerX86Test, MovdquLoad) {
653   DriverStr(RepeatFA(&x86::X86Assembler::movdqu, "movdqu {mem}, %{reg}"), "movdqu_load");
654 }
655 
TEST_F(AssemblerX86AVXTest,VMovdquLoad)656 TEST_F(AssemblerX86AVXTest, VMovdquLoad) {
657   DriverStr(RepeatFA(&x86::X86Assembler::vmovdqu, "vmovdqu {mem}, %{reg}"), "vmovdqu_load");
658 }
659 
TEST_F(AssemblerX86AVXTest,MovdquLoad)660 TEST_F(AssemblerX86AVXTest, MovdquLoad) {
661   DriverStr(RepeatFA(&x86::X86Assembler::movdqu, "vmovdqu {mem}, %{reg}"), "avx_movdqu_load");
662 }
663 
TEST_F(AssemblerX86Test,MovdquStore)664 TEST_F(AssemblerX86Test, MovdquStore) {
665   DriverStr(RepeatAF(&x86::X86Assembler::movdqu, "movdqu %{reg}, {mem}"), "movdqu_store");
666 }
667 
TEST_F(AssemblerX86AVXTest,VMovdquStore)668 TEST_F(AssemblerX86AVXTest, VMovdquStore) {
669   DriverStr(RepeatAF(&x86::X86Assembler::vmovdqu, "vmovdqu %{reg}, {mem}"), "vmovdqu_store");
670 }
671 
TEST_F(AssemblerX86AVXTest,MovdquStore)672 TEST_F(AssemblerX86AVXTest, MovdquStore) {
673   DriverStr(RepeatAF(&x86::X86Assembler::movdqu, "vmovdqu %{reg}, {mem}"), "avx_movdqu_store");
674 }
675 
TEST_F(AssemblerX86Test,AddPS)676 TEST_F(AssemblerX86Test, AddPS) {
677   DriverStr(RepeatFF(&x86::X86Assembler::addps, "addps %{reg2}, %{reg1}"), "addps");
678 }
679 
TEST_F(AssemblerX86AVXTest,VAddPS)680 TEST_F(AssemblerX86AVXTest, VAddPS) {
681   DriverStr(RepeatFFF(&x86::X86Assembler::vaddps, "vaddps %{reg3}, %{reg2}, %{reg1}"), "vaddps");
682 }
683 
TEST_F(AssemblerX86Test,AddPD)684 TEST_F(AssemblerX86Test, AddPD) {
685   DriverStr(RepeatFF(&x86::X86Assembler::addpd, "addpd %{reg2}, %{reg1}"), "addpd");
686 }
687 
TEST_F(AssemblerX86AVXTest,VAddpd)688 TEST_F(AssemblerX86AVXTest, VAddpd) {
689   DriverStr(RepeatFFF(&x86::X86Assembler::vaddpd, "vaddpd %{reg3}, %{reg2}, %{reg1}"), "vaddpd");
690 }
691 
TEST_F(AssemblerX86Test,SubPS)692 TEST_F(AssemblerX86Test, SubPS) {
693   DriverStr(RepeatFF(&x86::X86Assembler::subps, "subps %{reg2}, %{reg1}"), "subps");
694 }
695 
TEST_F(AssemblerX86AVXTest,VSubPS)696 TEST_F(AssemblerX86AVXTest, VSubPS) {
697   DriverStr(RepeatFFF(&x86::X86Assembler::vsubps, "vsubps %{reg3},%{reg2}, %{reg1}"), "vsubps");
698 }
699 
TEST_F(AssemblerX86Test,SubPD)700 TEST_F(AssemblerX86Test, SubPD) {
701   DriverStr(RepeatFF(&x86::X86Assembler::subpd, "subpd %{reg2}, %{reg1}"), "subpd");
702 }
703 
TEST_F(AssemblerX86AVXTest,VSubPD)704 TEST_F(AssemblerX86AVXTest, VSubPD) {
705   DriverStr(RepeatFFF(&x86::X86Assembler::vsubpd, "vsubpd %{reg3}, %{reg2}, %{reg1}"), "vsubpd");
706 }
707 
TEST_F(AssemblerX86Test,MulPS)708 TEST_F(AssemblerX86Test, MulPS) {
709   DriverStr(RepeatFF(&x86::X86Assembler::mulps, "mulps %{reg2}, %{reg1}"), "mulps");
710 }
711 
TEST_F(AssemblerX86AVXTest,VMulPS)712 TEST_F(AssemblerX86AVXTest, VMulPS) {
713   DriverStr(RepeatFFF(&x86::X86Assembler::vmulps, "vmulps %{reg3}, %{reg2}, %{reg1}"), "vmulps");
714 }
715 
TEST_F(AssemblerX86Test,MulPD)716 TEST_F(AssemblerX86Test, MulPD) {
717   DriverStr(RepeatFF(&x86::X86Assembler::mulpd, "mulpd %{reg2}, %{reg1}"), "mulpd");
718 }
719 
TEST_F(AssemblerX86AVXTest,VMulPD)720 TEST_F(AssemblerX86AVXTest, VMulPD) {
721   DriverStr(RepeatFFF(&x86::X86Assembler::vmulpd, "vmulpd %{reg3}, %{reg2}, %{reg1}"), "vmulpd");
722 }
723 
TEST_F(AssemblerX86Test,DivPS)724 TEST_F(AssemblerX86Test, DivPS) {
725   DriverStr(RepeatFF(&x86::X86Assembler::divps, "divps %{reg2}, %{reg1}"), "divps");
726 }
727 
TEST_F(AssemblerX86AVXTest,VDivPS)728 TEST_F(AssemblerX86AVXTest, VDivPS) {
729   DriverStr(RepeatFFF(&x86::X86Assembler::vdivps, "vdivps %{reg3}, %{reg2}, %{reg1}"), "vdivps");
730 }
731 
TEST_F(AssemblerX86Test,DivPD)732 TEST_F(AssemblerX86Test, DivPD) {
733   DriverStr(RepeatFF(&x86::X86Assembler::divpd, "divpd %{reg2}, %{reg1}"), "divpd");
734 }
735 
TEST_F(AssemblerX86AVXTest,VDivPD)736 TEST_F(AssemblerX86AVXTest, VDivPD) {
737   DriverStr(RepeatFFF(&x86::X86Assembler::vdivpd, "vdivpd %{reg3}, %{reg2}, %{reg1}"), "vdivpd");
738 }
739 
TEST_F(AssemblerX86Test,PAddB)740 TEST_F(AssemblerX86Test, PAddB) {
741   DriverStr(RepeatFF(&x86::X86Assembler::paddb, "paddb %{reg2}, %{reg1}"), "paddb");
742 }
743 
TEST_F(AssemblerX86AVXTest,VPaddB)744 TEST_F(AssemblerX86AVXTest, VPaddB) {
745   DriverStr(RepeatFFF(&x86::X86Assembler::vpaddb, "vpaddb %{reg3}, %{reg2}, %{reg1}"), "vpaddb");
746 }
747 
TEST_F(AssemblerX86Test,PSubB)748 TEST_F(AssemblerX86Test, PSubB) {
749   DriverStr(RepeatFF(&x86::X86Assembler::psubb, "psubb %{reg2}, %{reg1}"), "psubb");
750 }
751 
TEST_F(AssemblerX86AVXTest,VPsubB)752 TEST_F(AssemblerX86AVXTest, VPsubB) {
753   DriverStr(RepeatFFF(&x86::X86Assembler::vpsubb, "vpsubb %{reg3},%{reg2}, %{reg1}"), "vpsubb");
754 }
755 
TEST_F(AssemblerX86Test,PAddW)756 TEST_F(AssemblerX86Test, PAddW) {
757   DriverStr(RepeatFF(&x86::X86Assembler::paddw, "paddw %{reg2}, %{reg1}"), "paddw");
758 }
759 
TEST_F(AssemblerX86AVXTest,VPaddW)760 TEST_F(AssemblerX86AVXTest, VPaddW) {
761   DriverStr(RepeatFFF(&x86::X86Assembler::vpaddw, "vpaddw %{reg3}, %{reg2}, %{reg1}"), "vpaddw");
762 }
763 
TEST_F(AssemblerX86Test,PSubW)764 TEST_F(AssemblerX86Test, PSubW) {
765   DriverStr(RepeatFF(&x86::X86Assembler::psubw, "psubw %{reg2}, %{reg1}"), "psubw");
766 }
767 
TEST_F(AssemblerX86AVXTest,VPsubW)768 TEST_F(AssemblerX86AVXTest, VPsubW) {
769   DriverStr(RepeatFFF(&x86::X86Assembler::vpsubw, "vpsubw %{reg3}, %{reg2}, %{reg1}"), "vpsubw");
770 }
771 
TEST_F(AssemblerX86Test,PMullW)772 TEST_F(AssemblerX86Test, PMullW) {
773   DriverStr(RepeatFF(&x86::X86Assembler::pmullw, "pmullw %{reg2}, %{reg1}"), "pmullw");
774 }
775 
TEST_F(AssemblerX86AVXTest,VPMullW)776 TEST_F(AssemblerX86AVXTest, VPMullW) {
777   DriverStr(RepeatFFF(&x86::X86Assembler::vpmullw, "vpmullw %{reg3}, %{reg2}, %{reg1}"), "vpmullw");
778 }
779 
TEST_F(AssemblerX86Test,PAddD)780 TEST_F(AssemblerX86Test, PAddD) {
781   DriverStr(RepeatFF(&x86::X86Assembler::paddd, "paddd %{reg2}, %{reg1}"), "paddd");
782 }
783 
TEST_F(AssemblerX86AVXTest,VPaddD)784 TEST_F(AssemblerX86AVXTest, VPaddD) {
785   DriverStr(RepeatFFF(&x86::X86Assembler::vpaddd, "vpaddd %{reg3}, %{reg2}, %{reg1}"), "vpaddd");
786 }
787 
TEST_F(AssemblerX86Test,PSubD)788 TEST_F(AssemblerX86Test, PSubD) {
789   DriverStr(RepeatFF(&x86::X86Assembler::psubd, "psubd %{reg2}, %{reg1}"), "psubd");
790 }
791 
TEST_F(AssemblerX86AVXTest,VPsubD)792 TEST_F(AssemblerX86AVXTest, VPsubD) {
793   DriverStr(RepeatFFF(&x86::X86Assembler::vpsubd, "vpsubd %{reg3}, %{reg2}, %{reg1}"), "vpsubd");
794 }
795 
TEST_F(AssemblerX86Test,PMullD)796 TEST_F(AssemblerX86Test, PMullD) {
797   DriverStr(RepeatFF(&x86::X86Assembler::pmulld, "pmulld %{reg2}, %{reg1}"), "pmulld");
798 }
799 
TEST_F(AssemblerX86AVXTest,VPMullD)800 TEST_F(AssemblerX86AVXTest, VPMullD) {
801   DriverStr(RepeatFFF(&x86::X86Assembler::vpmulld, "vpmulld %{reg3}, %{reg2}, %{reg1}"), "vpmulld");
802 }
803 
TEST_F(AssemblerX86Test,PAddQ)804 TEST_F(AssemblerX86Test, PAddQ) {
805   DriverStr(RepeatFF(&x86::X86Assembler::paddq, "paddq %{reg2}, %{reg1}"), "paddq");
806 }
807 
TEST_F(AssemblerX86AVXTest,VPaddQ)808 TEST_F(AssemblerX86AVXTest, VPaddQ) {
809   DriverStr(RepeatFFF(&x86::X86Assembler::vpaddq, "vpaddq %{reg3}, %{reg2}, %{reg1}"), "vpaddq");
810 }
811 
TEST_F(AssemblerX86Test,PSubQ)812 TEST_F(AssemblerX86Test, PSubQ) {
813   DriverStr(RepeatFF(&x86::X86Assembler::psubq, "psubq %{reg2}, %{reg1}"), "psubq");
814 }
815 
TEST_F(AssemblerX86AVXTest,VPsubQ)816 TEST_F(AssemblerX86AVXTest, VPsubQ) {
817   DriverStr(RepeatFFF(&x86::X86Assembler::vpsubq, "vpsubq %{reg3}, %{reg2}, %{reg1}"), "vpsubq");
818 }
819 
TEST_F(AssemblerX86Test,PAddUSB)820 TEST_F(AssemblerX86Test, PAddUSB) {
821   DriverStr(RepeatFF(&x86::X86Assembler::paddusb, "paddusb %{reg2}, %{reg1}"), "paddusb");
822 }
823 
TEST_F(AssemblerX86Test,PAddSB)824 TEST_F(AssemblerX86Test, PAddSB) {
825   DriverStr(RepeatFF(&x86::X86Assembler::paddsb, "paddsb %{reg2}, %{reg1}"), "paddsb");
826 }
827 
TEST_F(AssemblerX86Test,PAddUSW)828 TEST_F(AssemblerX86Test, PAddUSW) {
829   DriverStr(RepeatFF(&x86::X86Assembler::paddusw, "paddusw %{reg2}, %{reg1}"), "paddusw");
830 }
831 
TEST_F(AssemblerX86Test,PAddSW)832 TEST_F(AssemblerX86Test, PAddSW) {
833   DriverStr(RepeatFF(&x86::X86Assembler::psubsw, "psubsw %{reg2}, %{reg1}"), "psubsw");
834 }
835 
TEST_F(AssemblerX86Test,PSubUSB)836 TEST_F(AssemblerX86Test, PSubUSB) {
837   DriverStr(RepeatFF(&x86::X86Assembler::psubusb, "psubusb %{reg2}, %{reg1}"), "psubusb");
838 }
839 
TEST_F(AssemblerX86Test,PSubSB)840 TEST_F(AssemblerX86Test, PSubSB) {
841   DriverStr(RepeatFF(&x86::X86Assembler::psubsb, "psubsb %{reg2}, %{reg1}"), "psubsb");
842 }
843 
TEST_F(AssemblerX86Test,PSubUSW)844 TEST_F(AssemblerX86Test, PSubUSW) {
845   DriverStr(RepeatFF(&x86::X86Assembler::psubusw, "psubusw %{reg2}, %{reg1}"), "psubusw");
846 }
847 
TEST_F(AssemblerX86Test,PSubSW)848 TEST_F(AssemblerX86Test, PSubSW) {
849   DriverStr(RepeatFF(&x86::X86Assembler::psubsw, "psubsw %{reg2}, %{reg1}"), "psubsw");
850 }
851 
TEST_F(AssemblerX86Test,XorPD)852 TEST_F(AssemblerX86Test, XorPD) {
853   DriverStr(RepeatFF(&x86::X86Assembler::xorpd, "xorpd %{reg2}, %{reg1}"), "xorpd");
854 }
855 
TEST_F(AssemblerX86Test,XorPS)856 TEST_F(AssemblerX86Test, XorPS) {
857   DriverStr(RepeatFF(&x86::X86Assembler::xorps, "xorps %{reg2}, %{reg1}"), "xorps");
858 }
859 
TEST_F(AssemblerX86Test,PXor)860 TEST_F(AssemblerX86Test, PXor) {
861   DriverStr(RepeatFF(&x86::X86Assembler::pxor, "pxor %{reg2}, %{reg1}"), "pxor");
862 }
863 
TEST_F(AssemblerX86AVXTest,VPXor)864 TEST_F(AssemblerX86AVXTest, VPXor) {
865   DriverStr(RepeatFFF(&x86::X86Assembler::vpxor, "vpxor %{reg3}, %{reg2}, %{reg1}"), "vpxor");
866 }
867 
TEST_F(AssemblerX86AVXTest,VXorPS)868 TEST_F(AssemblerX86AVXTest, VXorPS) {
869   DriverStr(RepeatFFF(&x86::X86Assembler::vxorps, "vxorps %{reg3}, %{reg2}, %{reg1}"), "vxorps");
870 }
871 
TEST_F(AssemblerX86AVXTest,VXorPD)872 TEST_F(AssemblerX86AVXTest, VXorPD) {
873   DriverStr(RepeatFFF(&x86::X86Assembler::vxorpd, "vxorpd %{reg3}, %{reg2}, %{reg1}"), "vxorpd");
874 }
875 
TEST_F(AssemblerX86Test,AndPD)876 TEST_F(AssemblerX86Test, AndPD) {
877   DriverStr(RepeatFF(&x86::X86Assembler::andpd, "andpd %{reg2}, %{reg1}"), "andpd");
878 }
879 
TEST_F(AssemblerX86Test,AndPS)880 TEST_F(AssemblerX86Test, AndPS) {
881   DriverStr(RepeatFF(&x86::X86Assembler::andps, "andps %{reg2}, %{reg1}"), "andps");
882 }
883 
TEST_F(AssemblerX86Test,PAnd)884 TEST_F(AssemblerX86Test, PAnd) {
885   DriverStr(RepeatFF(&x86::X86Assembler::pand, "pand %{reg2}, %{reg1}"), "pand");
886 }
887 
TEST_F(AssemblerX86AVXTest,VPAnd)888 TEST_F(AssemblerX86AVXTest, VPAnd) {
889   DriverStr(RepeatFFF(&x86::X86Assembler::vpand, "vpand %{reg3}, %{reg2}, %{reg1}"), "vpand");
890 }
891 
TEST_F(AssemblerX86AVXTest,VAndPS)892 TEST_F(AssemblerX86AVXTest, VAndPS) {
893   DriverStr(RepeatFFF(&x86::X86Assembler::vandps, "vandps %{reg3}, %{reg2}, %{reg1}"), "vandps");
894 }
895 
TEST_F(AssemblerX86AVXTest,VAndPD)896 TEST_F(AssemblerX86AVXTest, VAndPD) {
897   DriverStr(RepeatFFF(&x86::X86Assembler::vandpd, "vandpd %{reg3}, %{reg2}, %{reg1}"), "vandpd");
898 }
899 
TEST_F(AssemblerX86Test,Andn)900 TEST_F(AssemblerX86Test, Andn) {
901   DriverStr(RepeatRRR(&x86::X86Assembler::andn, "andn %{reg3}, %{reg2}, %{reg1}"), "andn");
902 }
903 
TEST_F(AssemblerX86Test,AndnPD)904 TEST_F(AssemblerX86Test, AndnPD) {
905   DriverStr(RepeatFF(&x86::X86Assembler::andnpd, "andnpd %{reg2}, %{reg1}"), "andnpd");
906 }
907 
TEST_F(AssemblerX86Test,AndnPS)908 TEST_F(AssemblerX86Test, AndnPS) {
909   DriverStr(RepeatFF(&x86::X86Assembler::andnps, "andnps %{reg2}, %{reg1}"), "andnps");
910 }
911 
TEST_F(AssemblerX86Test,PAndn)912 TEST_F(AssemblerX86Test, PAndn) {
913   DriverStr(RepeatFF(&x86::X86Assembler::pandn, "pandn %{reg2}, %{reg1}"), "pandn");
914 }
915 
TEST_F(AssemblerX86AVXTest,VPAndn)916 TEST_F(AssemblerX86AVXTest, VPAndn) {
917   DriverStr(RepeatFFF(&x86::X86Assembler::vpandn, "vpandn %{reg3}, %{reg2}, %{reg1}"), "vpandn");
918 }
919 
TEST_F(AssemblerX86AVXTest,VAndnPS)920 TEST_F(AssemblerX86AVXTest, VAndnPS) {
921   DriverStr(RepeatFFF(&x86::X86Assembler::vandnps, "vandnps %{reg3}, %{reg2}, %{reg1}"), "vandnps");
922 }
923 
TEST_F(AssemblerX86AVXTest,VAndnPD)924 TEST_F(AssemblerX86AVXTest, VAndnPD) {
925   DriverStr(RepeatFFF(&x86::X86Assembler::vandnpd, "vandnpd %{reg3}, %{reg2}, %{reg1}"), "vandnpd");
926 }
927 
TEST_F(AssemblerX86Test,OrPD)928 TEST_F(AssemblerX86Test, OrPD) {
929   DriverStr(RepeatFF(&x86::X86Assembler::orpd, "orpd %{reg2}, %{reg1}"), "orpd");
930 }
931 
TEST_F(AssemblerX86Test,OrPS)932 TEST_F(AssemblerX86Test, OrPS) {
933   DriverStr(RepeatFF(&x86::X86Assembler::orps, "orps %{reg2}, %{reg1}"), "orps");
934 }
935 
TEST_F(AssemblerX86Test,POr)936 TEST_F(AssemblerX86Test, POr) {
937   DriverStr(RepeatFF(&x86::X86Assembler::por, "por %{reg2}, %{reg1}"), "por");
938 }
939 
TEST_F(AssemblerX86AVXTest,VPor)940 TEST_F(AssemblerX86AVXTest, VPor) {
941   DriverStr(RepeatFFF(&x86::X86Assembler::vpor, "vpor %{reg3}, %{reg2}, %{reg1}"), "vpor");
942 }
943 
TEST_F(AssemblerX86AVXTest,VorPS)944 TEST_F(AssemblerX86AVXTest, VorPS) {
945   DriverStr(RepeatFFF(&x86::X86Assembler::vorps, "vorps %{reg3}, %{reg2}, %{reg1}"), "vorps");
946 }
947 
TEST_F(AssemblerX86AVXTest,VorPD)948 TEST_F(AssemblerX86AVXTest, VorPD) {
949   DriverStr(RepeatFFF(&x86::X86Assembler::vorpd, "vorpd %{reg3}, %{reg2}, %{reg1}"), "vorpd");
950 }
951 
TEST_F(AssemblerX86Test,PAvgB)952 TEST_F(AssemblerX86Test, PAvgB) {
953   DriverStr(RepeatFF(&x86::X86Assembler::pavgb, "pavgb %{reg2}, %{reg1}"), "pavgb");
954 }
955 
TEST_F(AssemblerX86Test,PAvgW)956 TEST_F(AssemblerX86Test, PAvgW) {
957   DriverStr(RepeatFF(&x86::X86Assembler::pavgw, "pavgw %{reg2}, %{reg1}"), "pavgw");
958 }
959 
TEST_F(AssemblerX86Test,PSadBW)960 TEST_F(AssemblerX86Test, PSadBW) {
961   DriverStr(RepeatFF(&x86::X86Assembler::psadbw, "psadbw %{reg2}, %{reg1}"), "psadbw");
962 }
963 
TEST_F(AssemblerX86Test,PMAddWD)964 TEST_F(AssemblerX86Test, PMAddWD) {
965   DriverStr(RepeatFF(&x86::X86Assembler::pmaddwd, "pmaddwd %{reg2}, %{reg1}"), "pmaddwd");
966 }
967 
TEST_F(AssemblerX86AVXTest,VPMAddWD)968 TEST_F(AssemblerX86AVXTest, VPMAddWD) {
969   DriverStr(
970       RepeatFFF(&x86::X86Assembler::vpmaddwd, "vpmaddwd %{reg3}, %{reg2}, %{reg1}"), "vpmaddwd");
971 }
972 
TEST_F(AssemblerX86Test,PHAddW)973 TEST_F(AssemblerX86Test, PHAddW) {
974   DriverStr(RepeatFF(&x86::X86Assembler::phaddw, "phaddw %{reg2}, %{reg1}"), "phaddw");
975 }
976 
TEST_F(AssemblerX86Test,PHAddD)977 TEST_F(AssemblerX86Test, PHAddD) {
978   DriverStr(RepeatFF(&x86::X86Assembler::phaddd, "phaddd %{reg2}, %{reg1}"), "phaddd");
979 }
980 
TEST_F(AssemblerX86Test,HAddPS)981 TEST_F(AssemblerX86Test, HAddPS) {
982   DriverStr(RepeatFF(&x86::X86Assembler::haddps, "haddps %{reg2}, %{reg1}"), "haddps");
983 }
984 
TEST_F(AssemblerX86Test,HAddPD)985 TEST_F(AssemblerX86Test, HAddPD) {
986   DriverStr(RepeatFF(&x86::X86Assembler::haddpd, "haddpd %{reg2}, %{reg1}"), "haddpd");
987 }
988 
TEST_F(AssemblerX86Test,PHSubW)989 TEST_F(AssemblerX86Test, PHSubW) {
990   DriverStr(RepeatFF(&x86::X86Assembler::phsubw, "phsubw %{reg2}, %{reg1}"), "phsubw");
991 }
992 
TEST_F(AssemblerX86Test,PHSubD)993 TEST_F(AssemblerX86Test, PHSubD) {
994   DriverStr(RepeatFF(&x86::X86Assembler::phsubd, "phsubd %{reg2}, %{reg1}"), "phsubd");
995 }
996 
TEST_F(AssemblerX86Test,HSubPS)997 TEST_F(AssemblerX86Test, HSubPS) {
998   DriverStr(RepeatFF(&x86::X86Assembler::hsubps, "hsubps %{reg2}, %{reg1}"), "hsubps");
999 }
1000 
TEST_F(AssemblerX86Test,HSubPD)1001 TEST_F(AssemblerX86Test, HSubPD) {
1002   DriverStr(RepeatFF(&x86::X86Assembler::hsubpd, "hsubpd %{reg2}, %{reg1}"), "hsubpd");
1003 }
1004 
TEST_F(AssemblerX86Test,PMinSB)1005 TEST_F(AssemblerX86Test, PMinSB) {
1006   DriverStr(RepeatFF(&x86::X86Assembler::pminsb, "pminsb %{reg2}, %{reg1}"), "pminsb");
1007 }
1008 
TEST_F(AssemblerX86Test,PMaxSB)1009 TEST_F(AssemblerX86Test, PMaxSB) {
1010   DriverStr(RepeatFF(&x86::X86Assembler::pmaxsb, "pmaxsb %{reg2}, %{reg1}"), "pmaxsb");
1011 }
1012 
TEST_F(AssemblerX86Test,PMinSW)1013 TEST_F(AssemblerX86Test, PMinSW) {
1014   DriverStr(RepeatFF(&x86::X86Assembler::pminsw, "pminsw %{reg2}, %{reg1}"), "pminsw");
1015 }
1016 
TEST_F(AssemblerX86Test,PMaxSW)1017 TEST_F(AssemblerX86Test, PMaxSW) {
1018   DriverStr(RepeatFF(&x86::X86Assembler::pmaxsw, "pmaxsw %{reg2}, %{reg1}"), "pmaxsw");
1019 }
1020 
TEST_F(AssemblerX86Test,PMinSD)1021 TEST_F(AssemblerX86Test, PMinSD) {
1022   DriverStr(RepeatFF(&x86::X86Assembler::pminsd, "pminsd %{reg2}, %{reg1}"), "pminsd");
1023 }
1024 
TEST_F(AssemblerX86Test,PMaxSD)1025 TEST_F(AssemblerX86Test, PMaxSD) {
1026   DriverStr(RepeatFF(&x86::X86Assembler::pmaxsd, "pmaxsd %{reg2}, %{reg1}"), "pmaxsd");
1027 }
1028 
TEST_F(AssemblerX86Test,PMinUB)1029 TEST_F(AssemblerX86Test, PMinUB) {
1030   DriverStr(RepeatFF(&x86::X86Assembler::pminub, "pminub %{reg2}, %{reg1}"), "pminub");
1031 }
1032 
TEST_F(AssemblerX86Test,PMaxUB)1033 TEST_F(AssemblerX86Test, PMaxUB) {
1034   DriverStr(RepeatFF(&x86::X86Assembler::pmaxub, "pmaxub %{reg2}, %{reg1}"), "pmaxub");
1035 }
1036 
TEST_F(AssemblerX86Test,PMinUW)1037 TEST_F(AssemblerX86Test, PMinUW) {
1038   DriverStr(RepeatFF(&x86::X86Assembler::pminuw, "pminuw %{reg2}, %{reg1}"), "pminuw");
1039 }
1040 
TEST_F(AssemblerX86Test,PMaxUW)1041 TEST_F(AssemblerX86Test, PMaxUW) {
1042   DriverStr(RepeatFF(&x86::X86Assembler::pmaxuw, "pmaxuw %{reg2}, %{reg1}"), "pmaxuw");
1043 }
1044 
TEST_F(AssemblerX86Test,PMinUD)1045 TEST_F(AssemblerX86Test, PMinUD) {
1046   DriverStr(RepeatFF(&x86::X86Assembler::pminud, "pminud %{reg2}, %{reg1}"), "pminud");
1047 }
1048 
TEST_F(AssemblerX86Test,PMaxUD)1049 TEST_F(AssemblerX86Test, PMaxUD) {
1050   DriverStr(RepeatFF(&x86::X86Assembler::pmaxud, "pmaxud %{reg2}, %{reg1}"), "pmaxud");
1051 }
1052 
TEST_F(AssemblerX86Test,MinPS)1053 TEST_F(AssemblerX86Test, MinPS) {
1054   DriverStr(RepeatFF(&x86::X86Assembler::minps, "minps %{reg2}, %{reg1}"), "minps");
1055 }
1056 
TEST_F(AssemblerX86Test,MaxPS)1057 TEST_F(AssemblerX86Test, MaxPS) {
1058   DriverStr(RepeatFF(&x86::X86Assembler::maxps, "maxps %{reg2}, %{reg1}"), "maxps");
1059 }
1060 
TEST_F(AssemblerX86Test,MinPD)1061 TEST_F(AssemblerX86Test, MinPD) {
1062   DriverStr(RepeatFF(&x86::X86Assembler::minpd, "minpd %{reg2}, %{reg1}"), "minpd");
1063 }
1064 
TEST_F(AssemblerX86Test,MaxPD)1065 TEST_F(AssemblerX86Test, MaxPD) {
1066   DriverStr(RepeatFF(&x86::X86Assembler::maxpd, "maxpd %{reg2}, %{reg1}"), "maxpd");
1067 }
1068 
TEST_F(AssemblerX86Test,PCmpeqB)1069 TEST_F(AssemblerX86Test, PCmpeqB) {
1070   DriverStr(RepeatFF(&x86::X86Assembler::pcmpeqb, "pcmpeqb %{reg2}, %{reg1}"), "cmpeqb");
1071 }
1072 
TEST_F(AssemblerX86Test,PCmpeqW)1073 TEST_F(AssemblerX86Test, PCmpeqW) {
1074   DriverStr(RepeatFF(&x86::X86Assembler::pcmpeqw, "pcmpeqw %{reg2}, %{reg1}"), "cmpeqw");
1075 }
1076 
TEST_F(AssemblerX86Test,PCmpeqD)1077 TEST_F(AssemblerX86Test, PCmpeqD) {
1078   DriverStr(RepeatFF(&x86::X86Assembler::pcmpeqd, "pcmpeqd %{reg2}, %{reg1}"), "cmpeqd");
1079 }
1080 
TEST_F(AssemblerX86Test,PCmpeqQ)1081 TEST_F(AssemblerX86Test, PCmpeqQ) {
1082   DriverStr(RepeatFF(&x86::X86Assembler::pcmpeqq, "pcmpeqq %{reg2}, %{reg1}"), "cmpeqq");
1083 }
1084 
TEST_F(AssemblerX86Test,PCmpgtB)1085 TEST_F(AssemblerX86Test, PCmpgtB) {
1086   DriverStr(RepeatFF(&x86::X86Assembler::pcmpgtb, "pcmpgtb %{reg2}, %{reg1}"), "cmpgtb");
1087 }
1088 
TEST_F(AssemblerX86Test,PCmpgtW)1089 TEST_F(AssemblerX86Test, PCmpgtW) {
1090   DriverStr(RepeatFF(&x86::X86Assembler::pcmpgtw, "pcmpgtw %{reg2}, %{reg1}"), "cmpgtw");
1091 }
1092 
TEST_F(AssemblerX86Test,PCmpgtD)1093 TEST_F(AssemblerX86Test, PCmpgtD) {
1094   DriverStr(RepeatFF(&x86::X86Assembler::pcmpgtd, "pcmpgtd %{reg2}, %{reg1}"), "cmpgtd");
1095 }
1096 
TEST_F(AssemblerX86Test,PCmpgtQ)1097 TEST_F(AssemblerX86Test, PCmpgtQ) {
1098   DriverStr(RepeatFF(&x86::X86Assembler::pcmpgtq, "pcmpgtq %{reg2}, %{reg1}"), "cmpgtq");
1099 }
1100 
TEST_F(AssemblerX86Test,ShufPS)1101 TEST_F(AssemblerX86Test, ShufPS) {
1102   DriverStr(RepeatFFI(&x86::X86Assembler::shufps, 1, "shufps ${imm}, %{reg2}, %{reg1}"), "shufps");
1103 }
1104 
TEST_F(AssemblerX86Test,ShufPD)1105 TEST_F(AssemblerX86Test, ShufPD) {
1106   DriverStr(RepeatFFI(&x86::X86Assembler::shufpd, 1, "shufpd ${imm}, %{reg2}, %{reg1}"), "shufpd");
1107 }
1108 
TEST_F(AssemblerX86Test,PShufD)1109 TEST_F(AssemblerX86Test, PShufD) {
1110   DriverStr(RepeatFFI(&x86::X86Assembler::pshufd, 1, "pshufd ${imm}, %{reg2}, %{reg1}"), "pshufd");
1111 }
1112 
TEST_F(AssemblerX86Test,Punpcklbw)1113 TEST_F(AssemblerX86Test, Punpcklbw) {
1114   DriverStr(RepeatFF(&x86::X86Assembler::punpcklbw, "punpcklbw %{reg2}, %{reg1}"), "punpcklbw");
1115 }
1116 
TEST_F(AssemblerX86Test,Punpcklwd)1117 TEST_F(AssemblerX86Test, Punpcklwd) {
1118   DriverStr(RepeatFF(&x86::X86Assembler::punpcklwd, "punpcklwd %{reg2}, %{reg1}"), "punpcklwd");
1119 }
1120 
TEST_F(AssemblerX86Test,Punpckldq)1121 TEST_F(AssemblerX86Test, Punpckldq) {
1122   DriverStr(RepeatFF(&x86::X86Assembler::punpckldq, "punpckldq %{reg2}, %{reg1}"), "punpckldq");
1123 }
1124 
TEST_F(AssemblerX86Test,Punpcklqdq)1125 TEST_F(AssemblerX86Test, Punpcklqdq) {
1126   DriverStr(RepeatFF(&x86::X86Assembler::punpcklqdq, "punpcklqdq %{reg2}, %{reg1}"), "punpcklqdq");
1127 }
1128 
TEST_F(AssemblerX86Test,Punpckhbw)1129 TEST_F(AssemblerX86Test, Punpckhbw) {
1130   DriverStr(RepeatFF(&x86::X86Assembler::punpckhbw, "punpckhbw %{reg2}, %{reg1}"), "punpckhbw");
1131 }
1132 
TEST_F(AssemblerX86Test,Punpckhwd)1133 TEST_F(AssemblerX86Test, Punpckhwd) {
1134   DriverStr(RepeatFF(&x86::X86Assembler::punpckhwd, "punpckhwd %{reg2}, %{reg1}"), "punpckhwd");
1135 }
1136 
TEST_F(AssemblerX86Test,Punpckhdq)1137 TEST_F(AssemblerX86Test, Punpckhdq) {
1138   DriverStr(RepeatFF(&x86::X86Assembler::punpckhdq, "punpckhdq %{reg2}, %{reg1}"), "punpckhdq");
1139 }
1140 
TEST_F(AssemblerX86Test,Punpckhqdq)1141 TEST_F(AssemblerX86Test, Punpckhqdq) {
1142   DriverStr(RepeatFF(&x86::X86Assembler::punpckhqdq, "punpckhqdq %{reg2}, %{reg1}"), "punpckhqdq");
1143 }
1144 
TEST_F(AssemblerX86Test,psllw)1145 TEST_F(AssemblerX86Test, psllw) {
1146   GetAssembler()->psllw(x86::XMM0, CreateImmediate(16));
1147   DriverStr("psllw $0x10, %xmm0\n", "psllwi");
1148 }
1149 
TEST_F(AssemblerX86Test,pslld)1150 TEST_F(AssemblerX86Test, pslld) {
1151   GetAssembler()->pslld(x86::XMM0, CreateImmediate(16));
1152   DriverStr("pslld $0x10, %xmm0\n", "pslldi");
1153 }
1154 
TEST_F(AssemblerX86Test,psllq)1155 TEST_F(AssemblerX86Test, psllq) {
1156   GetAssembler()->psllq(x86::XMM0, CreateImmediate(16));
1157   DriverStr("psllq $0x10, %xmm0\n", "psllqi");
1158 }
1159 
TEST_F(AssemblerX86Test,psraw)1160 TEST_F(AssemblerX86Test, psraw) {
1161   GetAssembler()->psraw(x86::XMM0, CreateImmediate(16));
1162   DriverStr("psraw $0x10, %xmm0\n", "psrawi");
1163 }
1164 
TEST_F(AssemblerX86Test,psrad)1165 TEST_F(AssemblerX86Test, psrad) {
1166   GetAssembler()->psrad(x86::XMM0, CreateImmediate(16));
1167   DriverStr("psrad $0x10, %xmm0\n", "psradi");
1168 }
1169 
TEST_F(AssemblerX86Test,psrlw)1170 TEST_F(AssemblerX86Test, psrlw) {
1171   GetAssembler()->psrlw(x86::XMM0, CreateImmediate(16));
1172   DriverStr("psrlw $0x10, %xmm0\n", "psrlwi");
1173 }
1174 
TEST_F(AssemblerX86Test,psrld)1175 TEST_F(AssemblerX86Test, psrld) {
1176   GetAssembler()->psrld(x86::XMM0, CreateImmediate(16));
1177   DriverStr("psrld $0x10, %xmm0\n", "psrldi");
1178 }
1179 
TEST_F(AssemblerX86Test,psrlq)1180 TEST_F(AssemblerX86Test, psrlq) {
1181   GetAssembler()->psrlq(x86::XMM0, CreateImmediate(16));
1182   DriverStr("psrlq $0x10, %xmm0\n", "psrlqi");
1183 }
1184 
TEST_F(AssemblerX86Test,psrldq)1185 TEST_F(AssemblerX86Test, psrldq) {
1186   GetAssembler()->psrldq(x86::XMM0, CreateImmediate(16));
1187   DriverStr("psrldq $0x10, %xmm0\n", "psrldqi");
1188 }
1189 
TEST_F(AssemblerX86Test,Jecxz)1190 TEST_F(AssemblerX86Test, Jecxz) {
1191   x86::NearLabel target;
1192   GetAssembler()->jecxz(&target);
1193   GetAssembler()->addl(x86::EDI, x86::Address(x86::ESP, 4));
1194   GetAssembler()->Bind(&target);
1195   const char* expected =
1196     "jecxz 1f\n"
1197     "addl 4(%ESP),%EDI\n"
1198     "1:\n";
1199   DriverStr(expected, "jecxz");
1200 }
1201 
TEST_F(AssemblerX86Test,NearLabel)1202 TEST_F(AssemblerX86Test, NearLabel) {
1203   // Test both forward and backward branches.
1204   x86::NearLabel start, target;
1205   GetAssembler()->Bind(&start);
1206   GetAssembler()->j(x86::kEqual, &target);
1207   GetAssembler()->jmp(&target);
1208   GetAssembler()->jecxz(&target);
1209   GetAssembler()->addl(x86::EDI, x86::Address(x86::ESP, 4));
1210   GetAssembler()->Bind(&target);
1211   GetAssembler()->j(x86::kNotEqual, &start);
1212   GetAssembler()->jmp(&start);
1213   const char* expected =
1214     "1: je 2f\n"
1215     "jmp 2f\n"
1216     "jecxz 2f\n"
1217     "addl 4(%ESP),%EDI\n"
1218     "2: jne 1b\n"
1219     "jmp 1b\n";
1220   DriverStr(expected, "near_label");
1221 }
1222 
TEST_F(AssemblerX86Test,Cmpb)1223 TEST_F(AssemblerX86Test, Cmpb) {
1224   DriverStr(RepeatAI(&x86::X86Assembler::cmpb,
1225                      /*imm_bytes*/ 1U,
1226                      "cmpb ${imm}, {mem}"), "cmpb");
1227 }
1228 
TEST_F(AssemblerX86Test,Cmpw)1229 TEST_F(AssemblerX86Test, Cmpw) {
1230   DriverStr(RepeatAI(&x86::X86Assembler::cmpw, /*imm_bytes*/ 2U, "cmpw ${imm}, {mem}"), "cmpw");
1231 }
1232 
1233 }  // namespace art
1234