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