1 /*
2 * Copyright (C) 2014 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_64.h"
18
19 #include <inttypes.h>
20 #include <map>
21 #include <random>
22
23 #include "base/bit_utils.h"
24 #include "base/macros.h"
25 #include "base/malloc_arena_pool.h"
26 #include "base/stl_util.h"
27 #include "jni_macro_assembler_x86_64.h"
28 #include "utils/assembler_test.h"
29 #include "utils/jni_macro_assembler_test.h"
30
31 namespace art HIDDEN {
32
TEST(AssemblerX86_64,CreateBuffer)33 TEST(AssemblerX86_64, CreateBuffer) {
34 MallocArenaPool pool;
35 ArenaAllocator allocator(&pool);
36 AssemblerBuffer buffer(&allocator);
37 AssemblerBuffer::EnsureCapacity ensured(&buffer);
38 buffer.Emit<uint8_t>(0x42);
39 ASSERT_EQ(static_cast<size_t>(1), buffer.Size());
40 buffer.Emit<int32_t>(42);
41 ASSERT_EQ(static_cast<size_t>(5), buffer.Size());
42 }
43
44 #ifdef ART_TARGET_ANDROID
45 static constexpr size_t kRandomIterations = 1000; // Devices might be puny, don't stress them...
46 #else
47 static constexpr size_t kRandomIterations = 100000; // Hosts are pretty powerful.
48 #endif
49
TEST(AssemblerX86_64,SignExtension)50 TEST(AssemblerX86_64, SignExtension) {
51 // 32bit.
52 for (int32_t i = 0; i < 128; i++) {
53 EXPECT_TRUE(IsInt<8>(i)) << i;
54 }
55 for (int32_t i = 128; i < 255; i++) {
56 EXPECT_FALSE(IsInt<8>(i)) << i;
57 }
58 // Do some higher ones randomly.
59 std::random_device rd;
60 std::default_random_engine e1(rd());
61 std::uniform_int_distribution<int32_t> uniform_dist(256, INT32_MAX);
62 for (size_t i = 0; i < kRandomIterations; i++) {
63 int32_t value = uniform_dist(e1);
64 EXPECT_FALSE(IsInt<8>(value)) << value;
65 }
66
67 // Negative ones.
68 for (int32_t i = -1; i >= -128; i--) {
69 EXPECT_TRUE(IsInt<8>(i)) << i;
70 }
71
72 for (int32_t i = -129; i > -256; i--) {
73 EXPECT_FALSE(IsInt<8>(i)) << i;
74 }
75
76 // Do some lower ones randomly.
77 std::uniform_int_distribution<int32_t> uniform_dist2(INT32_MIN, -256);
78 for (size_t i = 0; i < 100; i++) {
79 int32_t value = uniform_dist2(e1);
80 EXPECT_FALSE(IsInt<8>(value)) << value;
81 }
82
83 // 64bit.
84 for (int64_t i = 0; i < 128; i++) {
85 EXPECT_TRUE(IsInt<8>(i)) << i;
86 }
87 for (int32_t i = 128; i < 255; i++) {
88 EXPECT_FALSE(IsInt<8>(i)) << i;
89 }
90 // Do some higher ones randomly.
91 std::uniform_int_distribution<int64_t> uniform_dist3(256, INT64_MAX);
92 for (size_t i = 0; i < 100; i++) {
93 int64_t value = uniform_dist3(e1);
94 EXPECT_FALSE(IsInt<8>(value)) << value;
95 }
96
97 // Negative ones.
98 for (int64_t i = -1; i >= -128; i--) {
99 EXPECT_TRUE(IsInt<8>(i)) << i;
100 }
101
102 for (int64_t i = -129; i > -256; i--) {
103 EXPECT_FALSE(IsInt<8>(i)) << i;
104 }
105
106 // Do some lower ones randomly.
107 std::uniform_int_distribution<int64_t> uniform_dist4(INT64_MIN, -256);
108 for (size_t i = 0; i < kRandomIterations; i++) {
109 int64_t value = uniform_dist4(e1);
110 EXPECT_FALSE(IsInt<8>(value)) << value;
111 }
112
113 int64_t value = INT64_C(0x1200000010);
114 x86_64::Immediate imm(value);
115 EXPECT_FALSE(imm.is_int8());
116 EXPECT_FALSE(imm.is_int16());
117 EXPECT_FALSE(imm.is_int32());
118 value = INT64_C(0x8000000000000001);
119 x86_64::Immediate imm2(value);
120 EXPECT_FALSE(imm2.is_int8());
121 EXPECT_FALSE(imm2.is_int16());
122 EXPECT_FALSE(imm2.is_int32());
123 }
124
125 struct X86_64CpuRegisterCompare {
operator ()art::X86_64CpuRegisterCompare126 bool operator()(const x86_64::CpuRegister& a, const x86_64::CpuRegister& b) const {
127 return a.AsRegister() < b.AsRegister();
128 }
129 };
130
131 //
132 // Test fixture.
133 //
134
135 class AssemblerX86_64Test : public AssemblerTest<x86_64::X86_64Assembler,
136 x86_64::Address,
137 x86_64::CpuRegister,
138 x86_64::XmmRegister,
139 x86_64::Immediate> {
140 public:
141 using Base = AssemblerTest<x86_64::X86_64Assembler,
142 x86_64::Address,
143 x86_64::CpuRegister,
144 x86_64::XmmRegister,
145 x86_64::Immediate>;
146
147 protected:
GetIsa()148 InstructionSet GetIsa() override {
149 return InstructionSet::kX86_64;
150 }
151
SetUpHelpers()152 void SetUpHelpers() override {
153 if (addresses_singleton_.size() == 0) {
154 // One addressing mode to test the repeat drivers.
155 addresses_singleton_.push_back(
156 x86_64::Address(x86_64::CpuRegister(x86_64::RAX),
157 x86_64::CpuRegister(x86_64::RBX), TIMES_1, -1));
158 }
159
160 if (addresses_.size() == 0) {
161 // Several addressing modes.
162 addresses_.push_back(
163 x86_64::Address(x86_64::CpuRegister(x86_64::RDI),
164 x86_64::CpuRegister(x86_64::RAX), TIMES_1, 15));
165 addresses_.push_back(
166 x86_64::Address(x86_64::CpuRegister(x86_64::RDI),
167 x86_64::CpuRegister(x86_64::RBX), TIMES_2, 16));
168 addresses_.push_back(
169 x86_64::Address(x86_64::CpuRegister(x86_64::RDI),
170 x86_64::CpuRegister(x86_64::RCX), TIMES_4, 17));
171 addresses_.push_back(
172 x86_64::Address(x86_64::CpuRegister(x86_64::RDI),
173 x86_64::CpuRegister(x86_64::RDX), TIMES_8, 18));
174 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RAX), -1));
175 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RBX), 0));
176 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RSI), 1));
177 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RDI), 987654321));
178 // Several addressing modes with the special ESP.
179 addresses_.push_back(
180 x86_64::Address(x86_64::CpuRegister(x86_64::RSP),
181 x86_64::CpuRegister(x86_64::RAX), TIMES_1, 15));
182 addresses_.push_back(
183 x86_64::Address(x86_64::CpuRegister(x86_64::RSP),
184 x86_64::CpuRegister(x86_64::RBX), TIMES_2, 16));
185 addresses_.push_back(
186 x86_64::Address(x86_64::CpuRegister(x86_64::RSP),
187 x86_64::CpuRegister(x86_64::RCX), TIMES_4, 17));
188 addresses_.push_back(
189 x86_64::Address(x86_64::CpuRegister(x86_64::RSP),
190 x86_64::CpuRegister(x86_64::RDX), TIMES_8, 18));
191 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), -1));
192 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 0));
193 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 1));
194 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 987654321));
195 // Several addressing modes with the higher registers.
196 addresses_.push_back(
197 x86_64::Address(x86_64::CpuRegister(x86_64::R8),
198 x86_64::CpuRegister(x86_64::R15), TIMES_2, -1));
199 addresses_.push_back(x86_64::Address(x86_64::CpuRegister(x86_64::R15), 123456789));
200 }
201
202 if (registers_.size() == 0) {
203 registers_.push_back(new x86_64::CpuRegister(x86_64::RAX));
204 registers_.push_back(new x86_64::CpuRegister(x86_64::RBX));
205 registers_.push_back(new x86_64::CpuRegister(x86_64::RCX));
206 registers_.push_back(new x86_64::CpuRegister(x86_64::RDX));
207 registers_.push_back(new x86_64::CpuRegister(x86_64::RBP));
208 registers_.push_back(new x86_64::CpuRegister(x86_64::RSP));
209 registers_.push_back(new x86_64::CpuRegister(x86_64::RSI));
210 registers_.push_back(new x86_64::CpuRegister(x86_64::RDI));
211 registers_.push_back(new x86_64::CpuRegister(x86_64::R8));
212 registers_.push_back(new x86_64::CpuRegister(x86_64::R9));
213 registers_.push_back(new x86_64::CpuRegister(x86_64::R10));
214 registers_.push_back(new x86_64::CpuRegister(x86_64::R11));
215 registers_.push_back(new x86_64::CpuRegister(x86_64::R12));
216 registers_.push_back(new x86_64::CpuRegister(x86_64::R13));
217 registers_.push_back(new x86_64::CpuRegister(x86_64::R14));
218 registers_.push_back(new x86_64::CpuRegister(x86_64::R15));
219
220 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RAX), "eax");
221 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBX), "ebx");
222 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RCX), "ecx");
223 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDX), "edx");
224 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBP), "ebp");
225 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSP), "esp");
226 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSI), "esi");
227 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDI), "edi");
228 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R8), "r8d");
229 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R9), "r9d");
230 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R10), "r10d");
231 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R11), "r11d");
232 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R12), "r12d");
233 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R13), "r13d");
234 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R14), "r14d");
235 secondary_register_names_.emplace(x86_64::CpuRegister(x86_64::R15), "r15d");
236
237 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RAX), "ax");
238 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBX), "bx");
239 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RCX), "cx");
240 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDX), "dx");
241 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBP), "bp");
242 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSP), "sp");
243 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSI), "si");
244 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDI), "di");
245 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R8), "r8w");
246 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R9), "r9w");
247 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R10), "r10w");
248 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R11), "r11w");
249 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R12), "r12w");
250 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R13), "r13w");
251 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R14), "r14w");
252 tertiary_register_names_.emplace(x86_64::CpuRegister(x86_64::R15), "r15w");
253
254 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RAX), "al");
255 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBX), "bl");
256 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RCX), "cl");
257 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDX), "dl");
258 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RBP), "bpl");
259 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSP), "spl");
260 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RSI), "sil");
261 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::RDI), "dil");
262 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R8), "r8b");
263 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R9), "r9b");
264 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R10), "r10b");
265 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R11), "r11b");
266 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R12), "r12b");
267 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R13), "r13b");
268 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R14), "r14b");
269 quaternary_register_names_.emplace(x86_64::CpuRegister(x86_64::R15), "r15b");
270
271 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM0));
272 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM1));
273 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM2));
274 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM3));
275 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM4));
276 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM5));
277 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM6));
278 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM7));
279 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM8));
280 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM9));
281 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM10));
282 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM11));
283 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM12));
284 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM13));
285 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM14));
286 fp_registers_.push_back(new x86_64::XmmRegister(x86_64::XMM15));
287 }
288 }
289
TearDown()290 void TearDown() override {
291 AssemblerTest::TearDown();
292 STLDeleteElements(®isters_);
293 STLDeleteElements(&fp_registers_);
294 }
295
GetAddresses()296 std::vector<x86_64::Address> GetAddresses() override {
297 return addresses_;
298 }
299
GetRegisters()300 std::vector<x86_64::CpuRegister*> GetRegisters() override {
301 return registers_;
302 }
303
GetFPRegisters()304 std::vector<x86_64::XmmRegister*> GetFPRegisters() override {
305 return fp_registers_;
306 }
307
CreateImmediate(int64_t imm_value)308 x86_64::Immediate CreateImmediate(int64_t imm_value) override {
309 return x86_64::Immediate(imm_value);
310 }
311
GetSecondaryRegisterName(const x86_64::CpuRegister & reg)312 std::string GetSecondaryRegisterName(const x86_64::CpuRegister& reg) override {
313 CHECK(secondary_register_names_.find(reg) != secondary_register_names_.end());
314 return secondary_register_names_[reg];
315 }
316
GetTertiaryRegisterName(const x86_64::CpuRegister & reg)317 std::string GetTertiaryRegisterName(const x86_64::CpuRegister& reg) override {
318 CHECK(tertiary_register_names_.find(reg) != tertiary_register_names_.end());
319 return tertiary_register_names_[reg];
320 }
321
GetQuaternaryRegisterName(const x86_64::CpuRegister & reg)322 std::string GetQuaternaryRegisterName(const x86_64::CpuRegister& reg) override {
323 CHECK(quaternary_register_names_.find(reg) != quaternary_register_names_.end());
324 return quaternary_register_names_[reg];
325 }
326
327 std::vector<x86_64::Address> addresses_singleton_;
328
329 private:
330 std::vector<x86_64::Address> addresses_;
331 std::vector<x86_64::CpuRegister*> registers_;
332 std::map<x86_64::CpuRegister, std::string, X86_64CpuRegisterCompare> secondary_register_names_;
333 std::map<x86_64::CpuRegister, std::string, X86_64CpuRegisterCompare> tertiary_register_names_;
334 std::map<x86_64::CpuRegister, std::string, X86_64CpuRegisterCompare> quaternary_register_names_;
335 std::vector<x86_64::XmmRegister*> fp_registers_;
336 };
337
338 class AssemblerX86_64AVXTest : public AssemblerX86_64Test {
339 public:
AssemblerX86_64AVXTest()340 AssemblerX86_64AVXTest()
341 : instruction_set_features_(X86_64InstructionSetFeatures::FromVariant("kabylake", nullptr)) {}
342 protected:
CreateAssembler(ArenaAllocator * allocator)343 x86_64::X86_64Assembler* CreateAssembler(ArenaAllocator* allocator) override {
344 return new (allocator) x86_64::X86_64Assembler(allocator, instruction_set_features_.get());
345 }
346 private:
347 std::unique_ptr<const X86_64InstructionSetFeatures> instruction_set_features_;
348 };
349
350 //
351 // Test some repeat drivers used in the tests.
352 //
353
TEST_F(AssemblerX86_64Test,RepeatI4)354 TEST_F(AssemblerX86_64Test, RepeatI4) {
355 EXPECT_EQ("$0\n$-1\n$18\n$4660\n$-4660\n$305419896\n$-305419896\n",
356 RepeatI(/*f*/ nullptr, /*imm_bytes*/ 4U, "${imm}"));
357 }
358
TEST_F(AssemblerX86_64Test,RepeatI8)359 TEST_F(AssemblerX86_64Test, RepeatI8) {
360 EXPECT_EQ("$0\n$-1\n$18\n$4660\n$-4660\n$305419896\n$-305419896\n"
361 "$20015998343868\n$-20015998343868\n$1311768467463790320\n"
362 "$-1311768467463790320\n",
363 RepeatI(/*f*/ nullptr, /*imm_bytes*/ 8U, "${imm}"));
364 }
365
TEST_F(AssemblerX86_64Test,Repeatr)366 TEST_F(AssemblerX86_64Test, Repeatr) {
367 EXPECT_EQ("%eax\n%ebx\n%ecx\n%edx\n%ebp\n%esp\n%esi\n%edi\n"
368 "%r8d\n%r9d\n%r10d\n%r11d\n%r12d\n%r13d\n%r14d\n%r15d\n",
369 Repeatr(/*f*/ nullptr, "%{reg}"));
370 }
371
TEST_F(AssemblerX86_64Test,RepeatrI)372 TEST_F(AssemblerX86_64Test, RepeatrI) {
373 EXPECT_NE(RepeatrI(/*f*/ nullptr, /*imm_bytes*/ 1U, "%{reg} ${imm}").
374 find("%eax $0\n%eax $-1\n%eax $18\n%ebx $0\n%ebx $-1\n%ebx $18\n"
375 "%ecx $0\n%ecx $-1\n%ecx $18\n%edx $0\n%edx $-1\n%edx $18\n"),
376 std::string::npos);
377 }
378
TEST_F(AssemblerX86_64Test,Repeatrr)379 TEST_F(AssemblerX86_64Test, Repeatrr) {
380 EXPECT_NE(Repeatrr(/*f*/ nullptr, "%{reg1} %{reg2}")
381 .find("%eax %eax\n%eax %ebx\n%eax %ecx\n%eax %edx\n"
382 "%eax %ebp\n%eax %esp\n%eax %esi\n%eax %edi\n"),
383 std::string::npos);
384 }
385
TEST_F(AssemblerX86_64Test,Repeatrb)386 TEST_F(AssemblerX86_64Test, Repeatrb) {
387 EXPECT_NE(Repeatrb(/*f*/ nullptr, "%{reg1} %{reg2}").
388 find("%eax %al\n%eax %bl\n%eax %cl\n%eax %dl\n%eax %bpl\n"
389 "%eax %spl\n%eax %sil\n%eax %dil\n%eax %r8b\n%eax %r9b\n"),
390 std::string::npos);
391 }
392
TEST_F(AssemblerX86_64Test,RepeatrF)393 TEST_F(AssemblerX86_64Test, RepeatrF) {
394 EXPECT_NE(RepeatrF(/*f*/ nullptr, "%{reg1} %{reg2}")
395 .find("%eax %xmm0\n%eax %xmm1\n%eax %xmm2\n%eax %xmm3\n"
396 "%eax %xmm4\n%eax %xmm5\n%eax %xmm6\n%eax %xmm7\n"),
397 std::string::npos);
398 }
399
TEST_F(AssemblerX86_64Test,RepeatR)400 TEST_F(AssemblerX86_64Test, RepeatR) {
401 EXPECT_EQ("%rax\n%rbx\n%rcx\n%rdx\n%rbp\n%rsp\n%rsi\n%rdi\n"
402 "%r8\n%r9\n%r10\n%r11\n%r12\n%r13\n%r14\n%r15\n",
403 RepeatR(/*f*/ nullptr, "%{reg}"));
404 }
405
TEST_F(AssemblerX86_64Test,RepeatRI)406 TEST_F(AssemblerX86_64Test, RepeatRI) {
407 EXPECT_NE(RepeatRI(/*f*/ nullptr, /*imm_bytes*/ 1U, "%{reg} ${imm}")
408 .find("%rax $0\n%rax $-1\n%rax $18\n%rbx $0\n%rbx $-1\n%rbx $18\n"
409 "%rcx $0\n%rcx $-1\n%rcx $18\n%rdx $0\n%rdx $-1\n%rdx $18\n"),
410 std::string::npos);
411 }
412
TEST_F(AssemblerX86_64Test,RepeatRr)413 TEST_F(AssemblerX86_64Test, RepeatRr) {
414 EXPECT_NE(RepeatRr(/*f*/ nullptr, "%{reg1} %{reg2}")
415 .find("%rax %eax\n%rax %ebx\n%rax %ecx\n%rax %edx\n%rax %ebp\n"
416 "%rax %esp\n%rax %esi\n%rax %edi\n%rax %r8d\n%rax %r9d\n"),
417 std::string::npos);
418 }
419
TEST_F(AssemblerX86_64Test,RepeatRR)420 TEST_F(AssemblerX86_64Test, RepeatRR) {
421 EXPECT_NE(RepeatRR(/*f*/ nullptr, "%{reg1} %{reg2}")
422 .find("%rax %rax\n%rax %rbx\n%rax %rcx\n%rax %rdx\n%rax %rbp\n"
423 "%rax %rsp\n%rax %rsi\n%rax %rdi\n%rax %r8\n%rax %r9\n"),
424 std::string::npos);
425 }
426
TEST_F(AssemblerX86_64Test,RepeatRF)427 TEST_F(AssemblerX86_64Test, RepeatRF) {
428 EXPECT_NE(RepeatRF(/*f*/ nullptr, "%{reg1} %{reg2}")
429 .find("%rax %xmm0\n%rax %xmm1\n%rax %xmm2\n%rax %xmm3\n%rax %xmm4\n"
430 "%rax %xmm5\n%rax %xmm6\n%rax %xmm7\n%rax %xmm8\n%rax %xmm9\n"),
431 std::string::npos);
432 }
433
TEST_F(AssemblerX86_64Test,RepeatFF)434 TEST_F(AssemblerX86_64Test, RepeatFF) {
435 EXPECT_NE(RepeatFF(/*f*/ nullptr, "%{reg1} %{reg2}")
436 .find("%xmm0 %xmm0\n%xmm0 %xmm1\n%xmm0 %xmm2\n%xmm0 %xmm3\n%xmm0 %xmm4\n"
437 "%xmm0 %xmm5\n%xmm0 %xmm6\n%xmm0 %xmm7\n%xmm0 %xmm8\n%xmm0 %xmm9\n"),
438 std::string::npos);
439 }
440
TEST_F(AssemblerX86_64Test,RepeatFFI)441 TEST_F(AssemblerX86_64Test, RepeatFFI) {
442 EXPECT_NE(RepeatFFI(/*f*/ nullptr, /*imm_bytes*/ 1U, "%{reg1} %{reg2} ${imm}")
443 .find("%xmm0 %xmm0 $0\n%xmm0 %xmm0 $-1\n%xmm0 %xmm0 $18\n"
444 "%xmm0 %xmm1 $0\n%xmm0 %xmm1 $-1\n%xmm0 %xmm1 $18\n"),
445 std::string::npos);
446 }
447
TEST_F(AssemblerX86_64Test,RepeatA)448 TEST_F(AssemblerX86_64Test, RepeatA) {
449 EXPECT_EQ("-1(%rax,%rbx,1)\n", RepeatA(/*f*/ nullptr, addresses_singleton_, "{mem}"));
450 }
451
TEST_F(AssemblerX86_64Test,RepeatAFull)452 TEST_F(AssemblerX86_64Test, RepeatAFull) {
453 EXPECT_EQ("15(%rdi,%rax,1)\n16(%rdi,%rbx,2)\n17(%rdi,%rcx,4)\n18(%rdi,%rdx,8)\n"
454 "-1(%rax)\n(%rbx)\n1(%rsi)\n987654321(%rdi)\n15(%rsp,%rax,1)\n"
455 "16(%rsp,%rbx,2)\n17(%rsp,%rcx,4)\n18(%rsp,%rdx,8)\n-1(%rsp)\n"
456 "(%rsp)\n1(%rsp)\n987654321(%rsp)\n-1(%r8,%r15,2)\n123456789(%r15)\n",
457 RepeatA(/*f*/ nullptr, "{mem}"));
458 }
459
TEST_F(AssemblerX86_64Test,RepeatAI)460 TEST_F(AssemblerX86_64Test, RepeatAI) {
461 EXPECT_EQ("-1(%rax,%rbx,1) $0\n-1(%rax,%rbx,1) $-1\n-1(%rax,%rbx,1) $18\n",
462 RepeatAI(/*f*/ nullptr, /*imm_bytes*/ 1U, addresses_singleton_, "{mem} ${imm}"));
463 }
464
TEST_F(AssemblerX86_64Test,RepeatRA)465 TEST_F(AssemblerX86_64Test, RepeatRA) {
466 EXPECT_NE(RepeatRA(/*f*/ nullptr, addresses_singleton_, "%{reg} {mem}")
467 .find("%rax -1(%rax,%rbx,1)\n%rbx -1(%rax,%rbx,1)\n%rcx -1(%rax,%rbx,1)\n"
468 "%rdx -1(%rax,%rbx,1)\n%rbp -1(%rax,%rbx,1)\n%rsp -1(%rax,%rbx,1)\n"),
469 std::string::npos);
470 }
471
TEST_F(AssemblerX86_64Test,RepeatrA)472 TEST_F(AssemblerX86_64Test, RepeatrA) {
473 EXPECT_NE(RepeatrA(/*f*/ nullptr, addresses_singleton_, "%{reg} {mem}")
474 .find("%eax -1(%rax,%rbx,1)\n%ebx -1(%rax,%rbx,1)\n%ecx -1(%rax,%rbx,1)\n"
475 "%edx -1(%rax,%rbx,1)\n%ebp -1(%rax,%rbx,1)\n%esp -1(%rax,%rbx,1)\n"),
476 std::string::npos);
477 }
478
TEST_F(AssemblerX86_64Test,RepeatAR)479 TEST_F(AssemblerX86_64Test, RepeatAR) {
480 EXPECT_NE(RepeatAR(/*f*/ nullptr, addresses_singleton_, "{mem} %{reg}")
481 .find("-1(%rax,%rbx,1) %rax\n-1(%rax,%rbx,1) %rbx\n-1(%rax,%rbx,1) %rcx\n"
482 "-1(%rax,%rbx,1) %rdx\n-1(%rax,%rbx,1) %rbp\n-1(%rax,%rbx,1) %rsp\n"),
483 std::string::npos);
484 }
485
TEST_F(AssemblerX86_64Test,RepeatAr)486 TEST_F(AssemblerX86_64Test, RepeatAr) {
487 EXPECT_NE(RepeatAr(/*f*/ nullptr, addresses_singleton_, "{mem} %{reg}")
488 .find("-1(%rax,%rbx,1) %eax\n-1(%rax,%rbx,1) %ebx\n-1(%rax,%rbx,1) %ecx\n"
489 "-1(%rax,%rbx,1) %edx\n-1(%rax,%rbx,1) %ebp\n-1(%rax,%rbx,1) %esp\n"),
490 std::string::npos);
491 }
492
TEST_F(AssemblerX86_64Test,RepeatFA)493 TEST_F(AssemblerX86_64Test, RepeatFA) {
494 EXPECT_NE(RepeatFA(/*f*/ nullptr, addresses_singleton_, "%{reg} {mem}").
495 find("%xmm0 -1(%rax,%rbx,1)\n%xmm1 -1(%rax,%rbx,1)\n%xmm2 -1(%rax,%rbx,1)\n"
496 "%xmm3 -1(%rax,%rbx,1)\n%xmm4 -1(%rax,%rbx,1)\n%xmm5 -1(%rax,%rbx,1)\n"),
497 std::string::npos);
498 }
499
TEST_F(AssemblerX86_64Test,RepeatAF)500 TEST_F(AssemblerX86_64Test, RepeatAF) {
501 EXPECT_NE(RepeatAF(/*f*/ nullptr, addresses_singleton_, "{mem} %{reg}")
502 .find("-1(%rax,%rbx,1) %xmm0\n-1(%rax,%rbx,1) %xmm1\n-1(%rax,%rbx,1) %xmm2\n"
503 "-1(%rax,%rbx,1) %xmm3\n-1(%rax,%rbx,1) %xmm4\n-1(%rax,%rbx,1) %xmm5\n"),
504 std::string::npos);
505 }
506
507 //
508 // Actual x86-64 instruction assembler tests.
509 //
510
TEST_F(AssemblerX86_64Test,Toolchain)511 TEST_F(AssemblerX86_64Test, Toolchain) {
512 EXPECT_TRUE(CheckTools());
513 }
514
TEST_F(AssemblerX86_64Test,PopqAllAddresses)515 TEST_F(AssemblerX86_64Test, PopqAllAddresses) {
516 // Make sure all addressing modes combinations are tested at least once.
517 std::vector<x86_64::Address> all_addresses;
518 for (x86_64::CpuRegister* base : GetRegisters()) {
519 // Base only.
520 all_addresses.push_back(x86_64::Address(*base, -1));
521 all_addresses.push_back(x86_64::Address(*base, 0));
522 all_addresses.push_back(x86_64::Address(*base, 1));
523 all_addresses.push_back(x86_64::Address(*base, 123456789));
524 for (x86_64::CpuRegister* index : GetRegisters()) {
525 if (index->AsRegister() == x86_64::RSP) {
526 // Index cannot be RSP.
527 continue;
528 } else if (base->AsRegister() == index->AsRegister()) {
529 // Index only.
530 all_addresses.push_back(x86_64::Address(*index, TIMES_1, -1));
531 all_addresses.push_back(x86_64::Address(*index, TIMES_2, 0));
532 all_addresses.push_back(x86_64::Address(*index, TIMES_4, 1));
533 all_addresses.push_back(x86_64::Address(*index, TIMES_8, 123456789));
534 }
535 // Base and index.
536 all_addresses.push_back(x86_64::Address(*base, *index, TIMES_1, -1));
537 all_addresses.push_back(x86_64::Address(*base, *index, TIMES_2, 0));
538 all_addresses.push_back(x86_64::Address(*base, *index, TIMES_4, 1));
539 all_addresses.push_back(x86_64::Address(*base, *index, TIMES_8, 123456789));
540 }
541 }
542 DriverStr(RepeatA(&x86_64::X86_64Assembler::popq, all_addresses, "popq {mem}"), "popq");
543 }
544
TEST_F(AssemblerX86_64Test,PushqRegs)545 TEST_F(AssemblerX86_64Test, PushqRegs) {
546 DriverStr(RepeatR(&x86_64::X86_64Assembler::pushq, "pushq %{reg}"), "pushq");
547 }
548
TEST_F(AssemblerX86_64Test,PushqImm)549 TEST_F(AssemblerX86_64Test, PushqImm) {
550 DriverStr(RepeatI(&x86_64::X86_64Assembler::pushq, /*imm_bytes*/ 4U,
551 "pushq ${imm}"), "pushqi");
552 }
553
TEST_F(AssemblerX86_64Test,MovqRegs)554 TEST_F(AssemblerX86_64Test, MovqRegs) {
555 DriverStr(RepeatRR(&x86_64::X86_64Assembler::movq, "movq %{reg2}, %{reg1}"), "movq");
556 }
557
TEST_F(AssemblerX86_64Test,MovqImm)558 TEST_F(AssemblerX86_64Test, MovqImm) {
559 DriverStr(RepeatRI(&x86_64::X86_64Assembler::movq, /*imm_bytes*/ 8U,
560 "movq ${imm}, %{reg}"), "movqi");
561 }
562
TEST_F(AssemblerX86_64Test,MovlRegs)563 TEST_F(AssemblerX86_64Test, MovlRegs) {
564 DriverStr(Repeatrr(&x86_64::X86_64Assembler::movl, "mov %{reg2}, %{reg1}"), "movl");
565 }
566
TEST_F(AssemblerX86_64Test,MovlImm)567 TEST_F(AssemblerX86_64Test, MovlImm) {
568 DriverStr(RepeatrI(&x86_64::X86_64Assembler::movl, /*imm_bytes*/ 4U,
569 "mov ${imm}, %{reg}"), "movli");
570 }
571
TEST_F(AssemblerX86_64Test,AddqRegs)572 TEST_F(AssemblerX86_64Test, AddqRegs) {
573 DriverStr(RepeatRR(&x86_64::X86_64Assembler::addq, "addq %{reg2}, %{reg1}"), "addq");
574 }
575
TEST_F(AssemblerX86_64Test,AddqImm)576 TEST_F(AssemblerX86_64Test, AddqImm) {
577 DriverStr(RepeatRI(&x86_64::X86_64Assembler::addq, /*imm_bytes*/ 4U,
578 "addq ${imm}, %{reg}"), "addqi");
579 }
580
TEST_F(AssemblerX86_64Test,AddlRegs)581 TEST_F(AssemblerX86_64Test, AddlRegs) {
582 DriverStr(Repeatrr(&x86_64::X86_64Assembler::addl, "add %{reg2}, %{reg1}"), "addl");
583 }
584
TEST_F(AssemblerX86_64Test,AddlImm)585 TEST_F(AssemblerX86_64Test, AddlImm) {
586 DriverStr(RepeatrI(&x86_64::X86_64Assembler::addl, /*imm_bytes*/ 4U,
587 "add ${imm}, %{reg}"), "addli");
588 }
589
TEST_F(AssemblerX86_64Test,Addw)590 TEST_F(AssemblerX86_64Test, Addw) {
591 DriverStr(
592 RepeatAI(&x86_64::X86_64Assembler::addw, /*imm_bytes*/2U, "addw ${imm}, {mem}"), "addw");
593 }
594
TEST_F(AssemblerX86_64Test,ImulqReg1)595 TEST_F(AssemblerX86_64Test, ImulqReg1) {
596 DriverStr(RepeatR(&x86_64::X86_64Assembler::imulq, "imulq %{reg}"), "imulq");
597 }
598
TEST_F(AssemblerX86_64Test,ImulqRegs)599 TEST_F(AssemblerX86_64Test, ImulqRegs) {
600 DriverStr(RepeatRR(&x86_64::X86_64Assembler::imulq, "imulq %{reg2}, %{reg1}"), "imulq");
601 }
602
TEST_F(AssemblerX86_64Test,ImulqImm)603 TEST_F(AssemblerX86_64Test, ImulqImm) {
604 DriverStr(RepeatRI(&x86_64::X86_64Assembler::imulq, /*imm_bytes*/ 4U,
605 "imulq ${imm}, %{reg}, %{reg}"),
606 "imulqi");
607 }
608
TEST_F(AssemblerX86_64Test,ImullRegs)609 TEST_F(AssemblerX86_64Test, ImullRegs) {
610 DriverStr(Repeatrr(&x86_64::X86_64Assembler::imull, "imul %{reg2}, %{reg1}"), "imull");
611 }
612
TEST_F(AssemblerX86_64Test,ImullImm)613 TEST_F(AssemblerX86_64Test, ImullImm) {
614 DriverStr(RepeatrI(&x86_64::X86_64Assembler::imull, /*imm_bytes*/ 4U,
615 "imull ${imm}, %{reg}, %{reg}"),
616 "imulli");
617 }
618
TEST_F(AssemblerX86_64Test,Mull)619 TEST_F(AssemblerX86_64Test, Mull) {
620 DriverStr(Repeatr(&x86_64::X86_64Assembler::mull, "mull %{reg}"), "mull");
621 }
622
TEST_F(AssemblerX86_64Test,SubqRegs)623 TEST_F(AssemblerX86_64Test, SubqRegs) {
624 DriverStr(RepeatRR(&x86_64::X86_64Assembler::subq, "subq %{reg2}, %{reg1}"), "subq");
625 }
626
TEST_F(AssemblerX86_64Test,SubqImm)627 TEST_F(AssemblerX86_64Test, SubqImm) {
628 DriverStr(RepeatRI(&x86_64::X86_64Assembler::subq, /*imm_bytes*/ 4U,
629 "subq ${imm}, %{reg}"), "subqi");
630 }
631
TEST_F(AssemblerX86_64Test,SublRegs)632 TEST_F(AssemblerX86_64Test, SublRegs) {
633 DriverStr(Repeatrr(&x86_64::X86_64Assembler::subl, "sub %{reg2}, %{reg1}"), "subl");
634 }
635
TEST_F(AssemblerX86_64Test,SublImm)636 TEST_F(AssemblerX86_64Test, SublImm) {
637 DriverStr(RepeatrI(&x86_64::X86_64Assembler::subl, /*imm_bytes*/ 4U,
638 "sub ${imm}, %{reg}"), "subli");
639 }
640
641 // Shll only allows CL as the shift count.
shll_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)642 std::string shll_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
643 std::ostringstream str;
644 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
645 x86_64::CpuRegister shifter(x86_64::RCX);
646 for (auto reg : registers) {
647 assembler->shll(*reg, shifter);
648 str << "shll %cl, %" << assembler_test->GetSecondaryRegisterName(*reg) << "\n";
649 }
650 return str.str();
651 }
652
TEST_F(AssemblerX86_64Test,ShllReg)653 TEST_F(AssemblerX86_64Test, ShllReg) {
654 DriverFn(&shll_fn, "shll");
655 }
656
TEST_F(AssemblerX86_64Test,ShllImm)657 TEST_F(AssemblerX86_64Test, ShllImm) {
658 DriverStr(RepeatrI(&x86_64::X86_64Assembler::shll, /*imm_bytes*/ 1U,
659 "shll ${imm}, %{reg}"), "shlli");
660 }
661
662 // Shlq only allows CL as the shift count.
shlq_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)663 std::string shlq_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
664 std::ostringstream str;
665 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
666 x86_64::CpuRegister shifter(x86_64::RCX);
667 for (auto reg : registers) {
668 assembler->shlq(*reg, shifter);
669 str << "shlq %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
670 }
671 return str.str();
672 }
673
TEST_F(AssemblerX86_64Test,ShlqReg)674 TEST_F(AssemblerX86_64Test, ShlqReg) {
675 DriverFn(&shlq_fn, "shlq");
676 }
677
TEST_F(AssemblerX86_64Test,ShlqImm)678 TEST_F(AssemblerX86_64Test, ShlqImm) {
679 DriverStr(RepeatRI(&x86_64::X86_64Assembler::shlq, /*imm_bytes*/ 1U,
680 "shlq ${imm}, %{reg}"), "shlqi");
681 }
682
683 // Shrl only allows CL as the shift count.
shrl_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)684 std::string shrl_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
685 std::ostringstream str;
686 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
687 x86_64::CpuRegister shifter(x86_64::RCX);
688 for (auto reg : registers) {
689 assembler->shrl(*reg, shifter);
690 str << "shrl %cl, %" << assembler_test->GetSecondaryRegisterName(*reg) << "\n";
691 }
692 return str.str();
693 }
694
TEST_F(AssemblerX86_64Test,ShrlReg)695 TEST_F(AssemblerX86_64Test, ShrlReg) {
696 DriverFn(&shrl_fn, "shrl");
697 }
698
TEST_F(AssemblerX86_64Test,ShrlImm)699 TEST_F(AssemblerX86_64Test, ShrlImm) {
700 DriverStr(RepeatrI(&x86_64::X86_64Assembler::shrl, /*imm_bytes*/ 1U, "shrl ${imm}, %{reg}"), "shrli");
701 }
702
703 // Shrq only allows CL as the shift count.
shrq_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)704 std::string shrq_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
705 std::ostringstream str;
706 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
707 x86_64::CpuRegister shifter(x86_64::RCX);
708 for (auto reg : registers) {
709 assembler->shrq(*reg, shifter);
710 str << "shrq %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
711 }
712 return str.str();
713 }
714
TEST_F(AssemblerX86_64Test,ShrqReg)715 TEST_F(AssemblerX86_64Test, ShrqReg) {
716 DriverFn(&shrq_fn, "shrq");
717 }
718
TEST_F(AssemblerX86_64Test,ShrqImm)719 TEST_F(AssemblerX86_64Test, ShrqImm) {
720 DriverStr(RepeatRI(&x86_64::X86_64Assembler::shrq, /*imm_bytes*/ 1U, "shrq ${imm}, %{reg}"), "shrqi");
721 }
722
723 // Sarl only allows CL as the shift count.
sarl_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)724 std::string sarl_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
725 std::ostringstream str;
726 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
727 x86_64::CpuRegister shifter(x86_64::RCX);
728 for (auto reg : registers) {
729 assembler->sarl(*reg, shifter);
730 str << "sarl %cl, %" << assembler_test->GetSecondaryRegisterName(*reg) << "\n";
731 }
732 return str.str();
733 }
734
TEST_F(AssemblerX86_64Test,SarlReg)735 TEST_F(AssemblerX86_64Test, SarlReg) {
736 DriverFn(&sarl_fn, "sarl");
737 }
738
TEST_F(AssemblerX86_64Test,SarlImm)739 TEST_F(AssemblerX86_64Test, SarlImm) {
740 DriverStr(RepeatrI(&x86_64::X86_64Assembler::sarl, /*imm_bytes*/ 1U, "sarl ${imm}, %{reg}"), "sarli");
741 }
742
743 // Sarq only allows CL as the shift count.
sarq_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)744 std::string sarq_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
745 std::ostringstream str;
746 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
747 x86_64::CpuRegister shifter(x86_64::RCX);
748 for (auto reg : registers) {
749 assembler->sarq(*reg, shifter);
750 str << "sarq %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
751 }
752 return str.str();
753 }
754
TEST_F(AssemblerX86_64Test,SarqReg)755 TEST_F(AssemblerX86_64Test, SarqReg) {
756 DriverFn(&sarq_fn, "sarq");
757 }
758
TEST_F(AssemblerX86_64Test,SarqImm)759 TEST_F(AssemblerX86_64Test, SarqImm) {
760 DriverStr(RepeatRI(&x86_64::X86_64Assembler::sarq, /*imm_bytes*/ 1U, "sarq ${imm}, %{reg}"), "sarqi");
761 }
762
763 // Rorl only allows CL as the shift count.
rorl_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)764 std::string rorl_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
765 std::ostringstream str;
766 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
767 x86_64::CpuRegister shifter(x86_64::RCX);
768 for (auto reg : registers) {
769 assembler->rorl(*reg, shifter);
770 str << "rorl %cl, %" << assembler_test->GetSecondaryRegisterName(*reg) << "\n";
771 }
772 return str.str();
773 }
774
TEST_F(AssemblerX86_64Test,RorlReg)775 TEST_F(AssemblerX86_64Test, RorlReg) {
776 DriverFn(&rorl_fn, "rorl");
777 }
778
TEST_F(AssemblerX86_64Test,RorlImm)779 TEST_F(AssemblerX86_64Test, RorlImm) {
780 DriverStr(RepeatrI(&x86_64::X86_64Assembler::rorl, /*imm_bytes*/ 1U, "rorl ${imm}, %{reg}"), "rorli");
781 }
782
783 // Roll only allows CL as the shift count.
roll_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)784 std::string roll_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
785 std::ostringstream str;
786 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
787 x86_64::CpuRegister shifter(x86_64::RCX);
788 for (auto reg : registers) {
789 assembler->roll(*reg, shifter);
790 str << "roll %cl, %" << assembler_test->GetSecondaryRegisterName(*reg) << "\n";
791 }
792 return str.str();
793 }
794
TEST_F(AssemblerX86_64Test,RollReg)795 TEST_F(AssemblerX86_64Test, RollReg) {
796 DriverFn(&roll_fn, "roll");
797 }
798
TEST_F(AssemblerX86_64Test,RollImm)799 TEST_F(AssemblerX86_64Test, RollImm) {
800 DriverStr(RepeatrI(&x86_64::X86_64Assembler::roll, /*imm_bytes*/ 1U, "roll ${imm}, %{reg}"), "rolli");
801 }
802
803 // Rorq only allows CL as the shift count.
rorq_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)804 std::string rorq_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
805 std::ostringstream str;
806 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
807 x86_64::CpuRegister shifter(x86_64::RCX);
808 for (auto reg : registers) {
809 assembler->rorq(*reg, shifter);
810 str << "rorq %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
811 }
812 return str.str();
813 }
814
TEST_F(AssemblerX86_64Test,RorqReg)815 TEST_F(AssemblerX86_64Test, RorqReg) {
816 DriverFn(&rorq_fn, "rorq");
817 }
818
TEST_F(AssemblerX86_64Test,RorqImm)819 TEST_F(AssemblerX86_64Test, RorqImm) {
820 DriverStr(RepeatRI(&x86_64::X86_64Assembler::rorq, /*imm_bytes*/ 1U, "rorq ${imm}, %{reg}"), "rorqi");
821 }
822
823 // Rolq only allows CL as the shift count.
rolq_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)824 std::string rolq_fn(AssemblerX86_64Test::Base* assembler_test, x86_64::X86_64Assembler* assembler) {
825 std::ostringstream str;
826 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
827 x86_64::CpuRegister shifter(x86_64::RCX);
828 for (auto reg : registers) {
829 assembler->rolq(*reg, shifter);
830 str << "rolq %cl, %" << assembler_test->GetRegisterName(*reg) << "\n";
831 }
832 return str.str();
833 }
834
TEST_F(AssemblerX86_64Test,RolqReg)835 TEST_F(AssemblerX86_64Test, RolqReg) {
836 DriverFn(&rolq_fn, "rolq");
837 }
838
TEST_F(AssemblerX86_64Test,RolqImm)839 TEST_F(AssemblerX86_64Test, RolqImm) {
840 DriverStr(RepeatRI(&x86_64::X86_64Assembler::rolq, /*imm_bytes*/ 1U, "rolq ${imm}, %{reg}"), "rolqi");
841 }
842
TEST_F(AssemblerX86_64Test,CmpqRegs)843 TEST_F(AssemblerX86_64Test, CmpqRegs) {
844 DriverStr(RepeatRR(&x86_64::X86_64Assembler::cmpq, "cmpq %{reg2}, %{reg1}"), "cmpq");
845 }
846
TEST_F(AssemblerX86_64Test,CmpqImm)847 TEST_F(AssemblerX86_64Test, CmpqImm) {
848 DriverStr(RepeatRI(&x86_64::X86_64Assembler::cmpq,
849 /*imm_bytes*/ 4U,
850 "cmpq ${imm}, %{reg}"), "cmpqi"); // only imm32
851 }
852
TEST_F(AssemblerX86_64Test,CmplRegs)853 TEST_F(AssemblerX86_64Test, CmplRegs) {
854 DriverStr(Repeatrr(&x86_64::X86_64Assembler::cmpl, "cmp %{reg2}, %{reg1}"), "cmpl");
855 }
856
TEST_F(AssemblerX86_64Test,CmplImm)857 TEST_F(AssemblerX86_64Test, CmplImm) {
858 DriverStr(RepeatrI(&x86_64::X86_64Assembler::cmpl, /*imm_bytes*/ 4U, "cmpl ${imm}, %{reg}"), "cmpli");
859 }
860
TEST_F(AssemblerX86_64Test,Testl)861 TEST_F(AssemblerX86_64Test, Testl) {
862 // Note: uses different order for GCC than usual. This makes GCC happy, and doesn't have an
863 // impact on functional correctness.
864 DriverStr(Repeatrr(&x86_64::X86_64Assembler::testl, "testl %{reg1}, %{reg2}"), "testl");
865 }
866
TEST_F(AssemblerX86_64Test,Idivq)867 TEST_F(AssemblerX86_64Test, Idivq) {
868 DriverStr(RepeatR(&x86_64::X86_64Assembler::idivq, "idivq %{reg}"), "idivq");
869 }
870
TEST_F(AssemblerX86_64Test,Idivl)871 TEST_F(AssemblerX86_64Test, Idivl) {
872 DriverStr(Repeatr(&x86_64::X86_64Assembler::idivl, "idivl %{reg}"), "idivl");
873 }
874
TEST_F(AssemblerX86_64Test,Divq)875 TEST_F(AssemblerX86_64Test, Divq) {
876 DriverStr(RepeatR(&x86_64::X86_64Assembler::divq, "divq %{reg}"), "divq");
877 }
878
TEST_F(AssemblerX86_64Test,Divl)879 TEST_F(AssemblerX86_64Test, Divl) {
880 DriverStr(Repeatr(&x86_64::X86_64Assembler::divl, "divl %{reg}"), "divl");
881 }
882
TEST_F(AssemblerX86_64Test,Negq)883 TEST_F(AssemblerX86_64Test, Negq) {
884 DriverStr(RepeatR(&x86_64::X86_64Assembler::negq, "negq %{reg}"), "negq");
885 }
886
TEST_F(AssemblerX86_64Test,Negl)887 TEST_F(AssemblerX86_64Test, Negl) {
888 DriverStr(Repeatr(&x86_64::X86_64Assembler::negl, "negl %{reg}"), "negl");
889 }
890
TEST_F(AssemblerX86_64Test,Notq)891 TEST_F(AssemblerX86_64Test, Notq) {
892 DriverStr(RepeatR(&x86_64::X86_64Assembler::notq, "notq %{reg}"), "notq");
893 }
894
TEST_F(AssemblerX86_64Test,Notl)895 TEST_F(AssemblerX86_64Test, Notl) {
896 DriverStr(Repeatr(&x86_64::X86_64Assembler::notl, "notl %{reg}"), "notl");
897 }
898
TEST_F(AssemblerX86_64Test,AndqRegs)899 TEST_F(AssemblerX86_64Test, AndqRegs) {
900 DriverStr(RepeatRR(&x86_64::X86_64Assembler::andq, "andq %{reg2}, %{reg1}"), "andq");
901 }
902
TEST_F(AssemblerX86_64Test,AndqImm)903 TEST_F(AssemblerX86_64Test, AndqImm) {
904 DriverStr(RepeatRI(&x86_64::X86_64Assembler::andq,
905 /*imm_bytes*/ 4U,
906 "andq ${imm}, %{reg}"), "andqi"); // only imm32
907 }
908
TEST_F(AssemblerX86_64Test,AndlRegs)909 TEST_F(AssemblerX86_64Test, AndlRegs) {
910 DriverStr(Repeatrr(&x86_64::X86_64Assembler::andl, "andl %{reg2}, %{reg1}"), "andl");
911 }
912
TEST_F(AssemblerX86_64Test,AndlImm)913 TEST_F(AssemblerX86_64Test, AndlImm) {
914 DriverStr(RepeatrI(&x86_64::X86_64Assembler::andl,
915 /*imm_bytes*/ 4U,
916 "andl ${imm}, %{reg}"), "andli");
917 }
918
TEST_F(AssemblerX86_64Test,Andw)919 TEST_F(AssemblerX86_64Test, Andw) {
920 DriverStr(
921 RepeatAI(&x86_64::X86_64Assembler::andw, /*imm_bytes*/2U, "andw ${imm}, {mem}"), "andw");
922 }
923
TEST_F(AssemblerX86_64Test,OrqRegs)924 TEST_F(AssemblerX86_64Test, OrqRegs) {
925 DriverStr(RepeatRR(&x86_64::X86_64Assembler::orq, "orq %{reg2}, %{reg1}"), "orq");
926 }
927
TEST_F(AssemblerX86_64Test,OrlRegs)928 TEST_F(AssemblerX86_64Test, OrlRegs) {
929 DriverStr(Repeatrr(&x86_64::X86_64Assembler::orl, "orl %{reg2}, %{reg1}"), "orl");
930 }
931
TEST_F(AssemblerX86_64Test,OrlImm)932 TEST_F(AssemblerX86_64Test, OrlImm) {
933 DriverStr(RepeatrI(&x86_64::X86_64Assembler::orl,
934 /*imm_bytes*/ 4U, "orl ${imm}, %{reg}"), "orli");
935 }
936
TEST_F(AssemblerX86_64Test,XorqRegs)937 TEST_F(AssemblerX86_64Test, XorqRegs) {
938 DriverStr(RepeatRR(&x86_64::X86_64Assembler::xorq, "xorq %{reg2}, %{reg1}"), "xorq");
939 }
940
TEST_F(AssemblerX86_64Test,XorqImm)941 TEST_F(AssemblerX86_64Test, XorqImm) {
942 DriverStr(RepeatRI(&x86_64::X86_64Assembler::xorq,
943 /*imm_bytes*/ 4U, "xorq ${imm}, %{reg}"), "xorqi");
944 }
945
TEST_F(AssemblerX86_64Test,XorlRegs)946 TEST_F(AssemblerX86_64Test, XorlRegs) {
947 DriverStr(Repeatrr(&x86_64::X86_64Assembler::xorl, "xor %{reg2}, %{reg1}"), "xorl");
948 }
949
TEST_F(AssemblerX86_64Test,XorlImm)950 TEST_F(AssemblerX86_64Test, XorlImm) {
951 DriverStr(RepeatrI(&x86_64::X86_64Assembler::xorl,
952 /*imm_bytes*/ 4U, "xor ${imm}, %{reg}"), "xorli");
953 }
954
TEST_F(AssemblerX86_64Test,XchgqReg)955 TEST_F(AssemblerX86_64Test, XchgqReg) {
956 DriverStr(RepeatRR(&x86_64::X86_64Assembler::xchgq, "xchgq %{reg2}, %{reg1}"), "xchgq");
957 }
958
TEST_F(AssemblerX86_64Test,XchgqMem)959 TEST_F(AssemblerX86_64Test, XchgqMem) {
960 DriverStr(RepeatRA(&x86_64::X86_64Assembler::xchgq, "xchgq %{reg}, {mem}"), "xchgq");
961 }
962
TEST_F(AssemblerX86_64Test,XchglReg)963 TEST_F(AssemblerX86_64Test, XchglReg) {
964 // Exclude `xcghl eax, eax` because the reference implementation generates 0x87 0xC0 (contrary to
965 // the intel manual saying that this should be a `nop` 0x90). All other cases are the same.
966 static const std::vector<std::pair<x86_64::CpuRegister, x86_64::CpuRegister>> except = {
967 std::make_pair(x86_64::CpuRegister(x86_64::RAX), x86_64::CpuRegister(x86_64::RAX))
968 };
969 DriverStr(Repeatrr(&x86_64::X86_64Assembler::xchgl, "xchgl %{reg2}, %{reg1}", &except), "xchgl");
970 }
971
TEST_F(AssemblerX86_64Test,XchglMem)972 TEST_F(AssemblerX86_64Test, XchglMem) {
973 DriverStr(RepeatrA(&x86_64::X86_64Assembler::xchgl, "xchgl %{reg}, {mem}"), "xchgl");
974 }
975
TEST_F(AssemblerX86_64Test,XchgwReg)976 TEST_F(AssemblerX86_64Test, XchgwReg) {
977 DriverStr(Repeatww(&x86_64::X86_64Assembler::xchgw, "xchgw %{reg2}, %{reg1}"), "xchgw");
978 }
979
TEST_F(AssemblerX86_64Test,XchgwMem)980 TEST_F(AssemblerX86_64Test, XchgwMem) {
981 DriverStr(RepeatwA(&x86_64::X86_64Assembler::xchgw, "xchgw %{reg}, {mem}"), "xchgw");
982 }
983
TEST_F(AssemblerX86_64Test,XchgbReg)984 TEST_F(AssemblerX86_64Test, XchgbReg) {
985 DriverStr(Repeatbb(&x86_64::X86_64Assembler::xchgb, "xchgb %{reg2}, %{reg1}"), "xchgb");
986 }
987
TEST_F(AssemblerX86_64Test,XchgbMem)988 TEST_F(AssemblerX86_64Test, XchgbMem) {
989 DriverStr(RepeatbA(&x86_64::X86_64Assembler::xchgb, "xchgb %{reg}, {mem}"), "xchgb");
990 }
991
TEST_F(AssemblerX86_64Test,XaddqReg)992 TEST_F(AssemblerX86_64Test, XaddqReg) {
993 DriverStr(RepeatRR(&x86_64::X86_64Assembler::xaddq, "xaddq %{reg2}, %{reg1}"), "xaddq");
994 }
995
TEST_F(AssemblerX86_64Test,XaddqMem)996 TEST_F(AssemblerX86_64Test, XaddqMem) {
997 DriverStr(RepeatAR(&x86_64::X86_64Assembler::xaddq, "xaddq %{reg}, {mem}"), "xaddq");
998 }
999
TEST_F(AssemblerX86_64Test,XaddlReg)1000 TEST_F(AssemblerX86_64Test, XaddlReg) {
1001 DriverStr(Repeatrr(&x86_64::X86_64Assembler::xaddl, "xaddl %{reg2}, %{reg1}"), "xaddl");
1002 }
1003
TEST_F(AssemblerX86_64Test,XaddlMem)1004 TEST_F(AssemblerX86_64Test, XaddlMem) {
1005 DriverStr(RepeatAr(&x86_64::X86_64Assembler::xaddl, "xaddl %{reg}, {mem}"), "xaddl");
1006 }
1007
TEST_F(AssemblerX86_64Test,XaddwReg)1008 TEST_F(AssemblerX86_64Test, XaddwReg) {
1009 DriverStr(Repeatww(&x86_64::X86_64Assembler::xaddw, "xaddw %{reg2}, %{reg1}"), "xaddw");
1010 }
1011
TEST_F(AssemblerX86_64Test,XaddwMem)1012 TEST_F(AssemblerX86_64Test, XaddwMem) {
1013 DriverStr(RepeatAw(&x86_64::X86_64Assembler::xaddw, "xaddw %{reg}, {mem}"), "xaddw");
1014 }
1015
TEST_F(AssemblerX86_64Test,XaddbReg)1016 TEST_F(AssemblerX86_64Test, XaddbReg) {
1017 DriverStr(Repeatbb(&x86_64::X86_64Assembler::xaddb, "xaddb %{reg2}, %{reg1}"), "xaddb");
1018 }
1019
TEST_F(AssemblerX86_64Test,XaddbMem)1020 TEST_F(AssemblerX86_64Test, XaddbMem) {
1021 DriverStr(RepeatAb(&x86_64::X86_64Assembler::xaddb, "xaddb %{reg}, {mem}"), "xaddb");
1022 }
1023
TEST_F(AssemblerX86_64Test,LockXaddq)1024 TEST_F(AssemblerX86_64Test, LockXaddq) {
1025 DriverStr(
1026 RepeatAR(&x86_64::X86_64Assembler::LockXaddq, "lock xaddq %{reg}, {mem}"), "lock_xaddq");
1027 }
1028
TEST_F(AssemblerX86_64Test,LockXaddl)1029 TEST_F(AssemblerX86_64Test, LockXaddl) {
1030 DriverStr(
1031 RepeatAr(&x86_64::X86_64Assembler::LockXaddl, "lock xaddl %{reg}, {mem}"), "lock_xaddl");
1032 }
1033
TEST_F(AssemblerX86_64Test,LockXaddw)1034 TEST_F(AssemblerX86_64Test, LockXaddw) {
1035 DriverStr(
1036 RepeatAw(&x86_64::X86_64Assembler::LockXaddw, "lock xaddw %{reg}, {mem}"), "lock_xaddw");
1037 }
1038
TEST_F(AssemblerX86_64Test,LockXaddb)1039 TEST_F(AssemblerX86_64Test, LockXaddb) {
1040 DriverStr(
1041 RepeatAb(&x86_64::X86_64Assembler::LockXaddb, "lock xaddb %{reg}, {mem}"), "lock_xaddb");
1042 }
1043
TEST_F(AssemblerX86_64Test,Cmpxchgb)1044 TEST_F(AssemblerX86_64Test, Cmpxchgb) {
1045 DriverStr(RepeatAb(&x86_64::X86_64Assembler::cmpxchgb, "cmpxchgb %{reg}, {mem}"), "cmpxchgb");
1046 }
1047
TEST_F(AssemblerX86_64Test,Cmpxchgw)1048 TEST_F(AssemblerX86_64Test, Cmpxchgw) {
1049 DriverStr(RepeatAw(&x86_64::X86_64Assembler::cmpxchgw, "cmpxchgw %{reg}, {mem}"), "cmpxchgw");
1050 }
1051
TEST_F(AssemblerX86_64Test,Cmpxchgl)1052 TEST_F(AssemblerX86_64Test, Cmpxchgl) {
1053 DriverStr(RepeatAr(&x86_64::X86_64Assembler::cmpxchgl, "cmpxchgl %{reg}, {mem}"), "cmpxchgl");
1054 }
1055
TEST_F(AssemblerX86_64Test,Cmpxchgq)1056 TEST_F(AssemblerX86_64Test, Cmpxchgq) {
1057 DriverStr(RepeatAR(&x86_64::X86_64Assembler::cmpxchgq, "cmpxchg %{reg}, {mem}"), "cmpxchg");
1058 }
1059
TEST_F(AssemblerX86_64Test,LockCmpxchgb)1060 TEST_F(AssemblerX86_64Test, LockCmpxchgb) {
1061 DriverStr(RepeatAb(&x86_64::X86_64Assembler::LockCmpxchgb,
1062 "lock cmpxchgb %{reg}, {mem}"), "lock_cmpxchgb");
1063 }
1064
TEST_F(AssemblerX86_64Test,LockCmpxchgw)1065 TEST_F(AssemblerX86_64Test, LockCmpxchgw) {
1066 DriverStr(RepeatAw(&x86_64::X86_64Assembler::LockCmpxchgw,
1067 "lock cmpxchgw %{reg}, {mem}"), "lock_cmpxchgw");
1068 }
1069
TEST_F(AssemblerX86_64Test,LockCmpxchgl)1070 TEST_F(AssemblerX86_64Test, LockCmpxchgl) {
1071 DriverStr(RepeatAr(&x86_64::X86_64Assembler::LockCmpxchgl,
1072 "lock cmpxchgl %{reg}, {mem}"), "lock_cmpxchgl");
1073 }
1074
TEST_F(AssemblerX86_64Test,LockCmpxchgq)1075 TEST_F(AssemblerX86_64Test, LockCmpxchgq) {
1076 DriverStr(RepeatAR(&x86_64::X86_64Assembler::LockCmpxchgq,
1077 "lock cmpxchg %{reg}, {mem}"), "lock_cmpxchg");
1078 }
1079
TEST_F(AssemblerX86_64Test,MovqStore)1080 TEST_F(AssemblerX86_64Test, MovqStore) {
1081 DriverStr(RepeatAR(&x86_64::X86_64Assembler::movq, "movq %{reg}, {mem}"), "movq_s");
1082 }
1083
TEST_F(AssemblerX86_64Test,MovqLoad)1084 TEST_F(AssemblerX86_64Test, MovqLoad) {
1085 DriverStr(RepeatRA(&x86_64::X86_64Assembler::movq, "movq {mem}, %{reg}"), "movq_l");
1086 }
1087
TEST_F(AssemblerX86_64Test,MovlStore)1088 TEST_F(AssemblerX86_64Test, MovlStore) {
1089 DriverStr(RepeatAr(&x86_64::X86_64Assembler::movl, "movl %{reg}, {mem}"), "movl_s");
1090 }
1091
TEST_F(AssemblerX86_64Test,MovlLoad)1092 TEST_F(AssemblerX86_64Test, MovlLoad) {
1093 DriverStr(RepeatrA(&x86_64::X86_64Assembler::movl, "movl {mem}, %{reg}"), "movl_l");
1094 }
1095
TEST_F(AssemblerX86_64Test,MovwStore)1096 TEST_F(AssemblerX86_64Test, MovwStore) {
1097 DriverStr(RepeatAw(&x86_64::X86_64Assembler::movw, "movw %{reg}, {mem}"), "movw_s");
1098 }
1099
TEST_F(AssemblerX86_64Test,MovbStore)1100 TEST_F(AssemblerX86_64Test, MovbStore) {
1101 DriverStr(RepeatAb(&x86_64::X86_64Assembler::movb, "movb %{reg}, {mem}"), "movb_s");
1102 }
1103
TEST_F(AssemblerX86_64Test,Cmpw)1104 TEST_F(AssemblerX86_64Test, Cmpw) {
1105 DriverStr(
1106 RepeatAI(&x86_64::X86_64Assembler::cmpw, /*imm_bytes*/ 2U, "cmpw ${imm}, {mem}"), "cmpw");
1107 }
1108
TEST_F(AssemblerX86_64Test,MovqAddrImm)1109 TEST_F(AssemblerX86_64Test, MovqAddrImm) {
1110 DriverStr(RepeatAI(&x86_64::X86_64Assembler::movq,
1111 /*imm_bytes*/ 4U,
1112 "movq ${imm}, {mem}"), "movq"); // only imm32
1113 }
1114
TEST_F(AssemblerX86_64Test,MovlAddrImm)1115 TEST_F(AssemblerX86_64Test, MovlAddrImm) {
1116 DriverStr(RepeatAI(&x86_64::X86_64Assembler::movl,
1117 /*imm_bytes*/ 4U, "movl ${imm}, {mem}"), "movl");
1118 }
1119
TEST_F(AssemblerX86_64Test,MovwAddrImm)1120 TEST_F(AssemblerX86_64Test, MovwAddrImm) {
1121 DriverStr(RepeatAI(&x86_64::X86_64Assembler::movw,
1122 /*imm_bytes*/ 2U, "movw ${imm}, {mem}"), "movw");
1123 }
1124
TEST_F(AssemblerX86_64Test,MovbAddrImm)1125 TEST_F(AssemblerX86_64Test, MovbAddrImm) {
1126 DriverStr(RepeatAI(&x86_64::X86_64Assembler::movb,
1127 /*imm_bytes*/ 1U, "movb ${imm}, {mem}"), "movb");
1128 }
1129
TEST_F(AssemblerX86_64Test,Movntl)1130 TEST_F(AssemblerX86_64Test, Movntl) {
1131 DriverStr(RepeatAr(&x86_64::X86_64Assembler::movntl, "movntil %{reg}, {mem}"), "movntl");
1132 }
1133
TEST_F(AssemblerX86_64Test,Movntq)1134 TEST_F(AssemblerX86_64Test, Movntq) {
1135 DriverStr(RepeatAR(&x86_64::X86_64Assembler::movntq, "movntiq %{reg}, {mem}"), "movntq");
1136 }
1137
TEST_F(AssemblerX86_64Test,Cvtsi2ssAddr)1138 TEST_F(AssemblerX86_64Test, Cvtsi2ssAddr) {
1139 GetAssembler()->cvtsi2ss(x86_64::XmmRegister(x86_64::XMM0),
1140 x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
1141 /*is64bit*/ false);
1142 GetAssembler()->cvtsi2ss(x86_64::XmmRegister(x86_64::XMM0),
1143 x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
1144 /*is64bit*/ true);
1145 const char* expected = "cvtsi2ss 0(%RAX), %xmm0\n"
1146 "cvtsi2ssq 0(%RAX), %xmm0\n";
1147 DriverStr(expected, "cvtsi2ss");
1148 }
1149
TEST_F(AssemblerX86_64Test,Cvtsi2sdAddr)1150 TEST_F(AssemblerX86_64Test, Cvtsi2sdAddr) {
1151 GetAssembler()->cvtsi2sd(x86_64::XmmRegister(x86_64::XMM0),
1152 x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
1153 /*is64bit*/ false);
1154 GetAssembler()->cvtsi2sd(x86_64::XmmRegister(x86_64::XMM0),
1155 x86_64::Address(x86_64::CpuRegister(x86_64::RAX), 0),
1156 /*is64bit*/ true);
1157 const char* expected = "cvtsi2sd 0(%RAX), %xmm0\n"
1158 "cvtsi2sdq 0(%RAX), %xmm0\n";
1159 DriverStr(expected, "cvtsi2sd");
1160 }
1161
TEST_F(AssemblerX86_64Test,CmpqAddr)1162 TEST_F(AssemblerX86_64Test, CmpqAddr) {
1163 DriverStr(RepeatRA(&x86_64::X86_64Assembler::cmpq, "cmpq {mem}, %{reg}"), "cmpq");
1164 }
1165
TEST_F(AssemblerX86_64Test,MovsxdAddr)1166 TEST_F(AssemblerX86_64Test, MovsxdAddr) {
1167 DriverStr(RepeatRA(&x86_64::X86_64Assembler::movsxd, "movslq {mem}, %{reg}"), "movsxd");
1168 }
1169
TEST_F(AssemblerX86_64Test,TestqAddr)1170 TEST_F(AssemblerX86_64Test, TestqAddr) {
1171 DriverStr(RepeatRA(&x86_64::X86_64Assembler::testq, "testq {mem}, %{reg}"), "testq");
1172 }
1173
TEST_F(AssemblerX86_64Test,AddqAddr)1174 TEST_F(AssemblerX86_64Test, AddqAddr) {
1175 DriverStr(RepeatRA(&x86_64::X86_64Assembler::addq, "addq {mem}, %{reg}"), "addq");
1176 }
1177
TEST_F(AssemblerX86_64Test,SubqAddr)1178 TEST_F(AssemblerX86_64Test, SubqAddr) {
1179 DriverStr(RepeatRA(&x86_64::X86_64Assembler::subq, "subq {mem}, %{reg}"), "subq");
1180 }
1181
TEST_F(AssemblerX86_64Test,Cvtss2sdAddr)1182 TEST_F(AssemblerX86_64Test, Cvtss2sdAddr) {
1183 DriverStr(RepeatFA(&x86_64::X86_64Assembler::cvtss2sd, "cvtss2sd {mem}, %{reg}"), "cvtss2sd");
1184 }
1185
TEST_F(AssemblerX86_64Test,Cvtsd2ssAddr)1186 TEST_F(AssemblerX86_64Test, Cvtsd2ssAddr) {
1187 DriverStr(RepeatFA(&x86_64::X86_64Assembler::cvtsd2ss, "cvtsd2ss {mem}, %{reg}"), "cvtsd2ss");
1188 }
1189
TEST_F(AssemblerX86_64Test,ComissAddr)1190 TEST_F(AssemblerX86_64Test, ComissAddr) {
1191 DriverStr(RepeatFA(&x86_64::X86_64Assembler::comiss, "comiss {mem}, %{reg}"), "comiss");
1192 }
1193
TEST_F(AssemblerX86_64Test,ComisdAddr)1194 TEST_F(AssemblerX86_64Test, ComisdAddr) {
1195 DriverStr(RepeatFA(&x86_64::X86_64Assembler::comisd, "comisd {mem}, %{reg}"), "comisd");
1196 }
1197
TEST_F(AssemblerX86_64Test,UComissAddr)1198 TEST_F(AssemblerX86_64Test, UComissAddr) {
1199 DriverStr(RepeatFA(&x86_64::X86_64Assembler::ucomiss, "ucomiss {mem}, %{reg}"), "ucomiss");
1200 }
1201
TEST_F(AssemblerX86_64Test,UComisdAddr)1202 TEST_F(AssemblerX86_64Test, UComisdAddr) {
1203 DriverStr(RepeatFA(&x86_64::X86_64Assembler::ucomisd, "ucomisd {mem}, %{reg}"), "ucomisd");
1204 }
1205
TEST_F(AssemblerX86_64Test,Andq)1206 TEST_F(AssemblerX86_64Test, Andq) {
1207 DriverStr(RepeatRA(&x86_64::X86_64Assembler::andq, "andq {mem}, %{reg}"), "andq");
1208 }
1209
TEST_F(AssemblerX86_64Test,Orq)1210 TEST_F(AssemblerX86_64Test, Orq) {
1211 DriverStr(RepeatRA(&x86_64::X86_64Assembler::orq, "orq {mem}, %{reg}"), "orq");
1212 }
1213
TEST_F(AssemblerX86_64Test,Xorq)1214 TEST_F(AssemblerX86_64Test, Xorq) {
1215 DriverStr(RepeatRA(&x86_64::X86_64Assembler::xorq, "xorq {mem}, %{reg}"), "xorq");
1216 }
1217
TEST_F(AssemblerX86_64Test,RepneScasb)1218 TEST_F(AssemblerX86_64Test, RepneScasb) {
1219 GetAssembler()->repne_scasb();
1220 const char* expected = "repne scasb\n";
1221 DriverStr(expected, "repne_scasb");
1222 }
1223
TEST_F(AssemblerX86_64Test,RepneScasw)1224 TEST_F(AssemblerX86_64Test, RepneScasw) {
1225 GetAssembler()->repne_scasw();
1226 const char* expected = "repne scasw\n";
1227 DriverStr(expected, "repne_scasw");
1228 }
1229
TEST_F(AssemblerX86_64Test,RepMovsb)1230 TEST_F(AssemblerX86_64Test, RepMovsb) {
1231 GetAssembler()->rep_movsb();
1232 const char* expected = "rep movsb\n";
1233 DriverStr(expected, "rep_movsb");
1234 }
1235
TEST_F(AssemblerX86_64Test,RepMovsw)1236 TEST_F(AssemblerX86_64Test, RepMovsw) {
1237 GetAssembler()->rep_movsw();
1238 const char* expected = "rep movsw\n";
1239 DriverStr(expected, "rep_movsw");
1240 }
1241
TEST_F(AssemblerX86_64Test,RepMovsl)1242 TEST_F(AssemblerX86_64Test, RepMovsl) {
1243 GetAssembler()->rep_movsl();
1244 const char* expected = "rep movsl\n";
1245 DriverStr(expected, "rep_movsl");
1246 }
1247
TEST_F(AssemblerX86_64Test,Movsxd)1248 TEST_F(AssemblerX86_64Test, Movsxd) {
1249 DriverStr(RepeatRr(&x86_64::X86_64Assembler::movsxd, "movslq %{reg2}, %{reg1}"), "movsxd");
1250 }
1251
TEST_F(AssemblerX86_64Test,Movaps)1252 TEST_F(AssemblerX86_64Test, Movaps) {
1253 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movaps, "movaps %{reg2}, %{reg1}"), "movaps");
1254 }
1255
TEST_F(AssemblerX86_64AVXTest,VMovaps)1256 TEST_F(AssemblerX86_64AVXTest, VMovaps) {
1257 DriverStr(RepeatFF(&x86_64::X86_64Assembler::vmovaps, "vmovaps %{reg2}, %{reg1}"), "vmovaps");
1258 }
1259
TEST_F(AssemblerX86_64AVXTest,Movaps)1260 TEST_F(AssemblerX86_64AVXTest, Movaps) {
1261 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movaps, "vmovaps %{reg2}, %{reg1}"), "avx_movaps");
1262 }
1263
TEST_F(AssemblerX86_64Test,MovapsStore)1264 TEST_F(AssemblerX86_64Test, MovapsStore) {
1265 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movaps, "movaps %{reg}, {mem}"), "movaps_s");
1266 }
1267
TEST_F(AssemblerX86_64AVXTest,VMovapsStore)1268 TEST_F(AssemblerX86_64AVXTest, VMovapsStore) {
1269 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovaps, "vmovaps %{reg}, {mem}"), "vmovaps_s");
1270 }
1271
TEST_F(AssemblerX86_64AVXTest,MovapsStore)1272 TEST_F(AssemblerX86_64AVXTest, MovapsStore) {
1273 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movaps, "vmovaps %{reg}, {mem}"), "avx_movaps_s");
1274 }
1275
TEST_F(AssemblerX86_64Test,MovapsLoad)1276 TEST_F(AssemblerX86_64Test, MovapsLoad) {
1277 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movaps, "movaps {mem}, %{reg}"), "movaps_l");
1278 }
1279
TEST_F(AssemblerX86_64AVXTest,VMovapsLoad)1280 TEST_F(AssemblerX86_64AVXTest, VMovapsLoad) {
1281 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovaps, "vmovaps {mem}, %{reg}"), "vmovaps_l");
1282 }
1283
TEST_F(AssemblerX86_64AVXTest,MovapsLoad)1284 TEST_F(AssemblerX86_64AVXTest, MovapsLoad) {
1285 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movaps, "vmovaps {mem}, %{reg}"), "avx_movaps_l");
1286 }
1287
TEST_F(AssemblerX86_64Test,MovupsStore)1288 TEST_F(AssemblerX86_64Test, MovupsStore) {
1289 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movups, "movups %{reg}, {mem}"), "movups_s");
1290 }
1291
TEST_F(AssemblerX86_64AVXTest,VMovupsStore)1292 TEST_F(AssemblerX86_64AVXTest, VMovupsStore) {
1293 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovups, "vmovups %{reg}, {mem}"), "vmovups_s");
1294 }
1295
TEST_F(AssemblerX86_64AVXTest,MovupsStore)1296 TEST_F(AssemblerX86_64AVXTest, MovupsStore) {
1297 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movups, "vmovups %{reg}, {mem}"), "avx_movups_s");
1298 }
1299
TEST_F(AssemblerX86_64Test,MovupsLoad)1300 TEST_F(AssemblerX86_64Test, MovupsLoad) {
1301 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movups, "movups {mem}, %{reg}"), "movups_l");
1302 }
1303
TEST_F(AssemblerX86_64AVXTest,VMovupsLoad)1304 TEST_F(AssemblerX86_64AVXTest, VMovupsLoad) {
1305 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovups, "vmovups {mem}, %{reg}"), "vmovups_l");
1306 }
1307
TEST_F(AssemblerX86_64AVXTest,MovupsLoad)1308 TEST_F(AssemblerX86_64AVXTest, MovupsLoad) {
1309 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movups, "vmovups {mem}, %{reg}"), "avx_movups_l");
1310 }
1311
TEST_F(AssemblerX86_64Test,Movss)1312 TEST_F(AssemblerX86_64Test, Movss) {
1313 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movss, "movss %{reg2}, %{reg1}"), "movss");
1314 }
1315
TEST_F(AssemblerX86_64Test,Movapd)1316 TEST_F(AssemblerX86_64Test, Movapd) {
1317 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movapd, "movapd %{reg2}, %{reg1}"), "movapd");
1318 }
1319
TEST_F(AssemblerX86_64AVXTest,VMovapd)1320 TEST_F(AssemblerX86_64AVXTest, VMovapd) {
1321 DriverStr(RepeatFF(&x86_64::X86_64Assembler::vmovapd, "vmovapd %{reg2}, %{reg1}"), "vmovapd");
1322 }
1323
TEST_F(AssemblerX86_64AVXTest,Movapd)1324 TEST_F(AssemblerX86_64AVXTest, Movapd) {
1325 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movapd, "vmovapd %{reg2}, %{reg1}"), "avx_movapd");
1326 }
1327
TEST_F(AssemblerX86_64Test,MovapdStore)1328 TEST_F(AssemblerX86_64Test, MovapdStore) {
1329 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movapd, "movapd %{reg}, {mem}"), "movapd_s");
1330 }
1331
TEST_F(AssemblerX86_64AVXTest,VMovapdStore)1332 TEST_F(AssemblerX86_64AVXTest, VMovapdStore) {
1333 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovapd, "vmovapd %{reg}, {mem}"), "vmovapd_s");
1334 }
1335
TEST_F(AssemblerX86_64AVXTest,MovapdStore)1336 TEST_F(AssemblerX86_64AVXTest, MovapdStore) {
1337 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movapd, "vmovapd %{reg}, {mem}"), "avx_movapd_s");
1338 }
1339
TEST_F(AssemblerX86_64Test,MovapdLoad)1340 TEST_F(AssemblerX86_64Test, MovapdLoad) {
1341 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movapd, "movapd {mem}, %{reg}"), "movapd_l");
1342 }
1343
TEST_F(AssemblerX86_64AVXTest,VMovapdLoad)1344 TEST_F(AssemblerX86_64AVXTest, VMovapdLoad) {
1345 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovapd, "vmovapd {mem}, %{reg}"), "vmovapd_l");
1346 }
1347
TEST_F(AssemblerX86_64AVXTest,MovapdLoad)1348 TEST_F(AssemblerX86_64AVXTest, MovapdLoad) {
1349 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movapd, "vmovapd {mem}, %{reg}"), "avx_movapd_l");
1350 }
1351
TEST_F(AssemblerX86_64Test,MovupdStore)1352 TEST_F(AssemblerX86_64Test, MovupdStore) {
1353 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movupd, "movupd %{reg}, {mem}"), "movupd_s");
1354 }
1355
TEST_F(AssemblerX86_64AVXTest,VMovupdStore)1356 TEST_F(AssemblerX86_64AVXTest, VMovupdStore) {
1357 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovupd, "vmovupd %{reg}, {mem}"), "vmovupd_s");
1358 }
1359
TEST_F(AssemblerX86_64AVXTest,MovupdStore)1360 TEST_F(AssemblerX86_64AVXTest, MovupdStore) {
1361 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movupd, "vmovupd %{reg}, {mem}"), "avx_movupd_s");
1362 }
1363
TEST_F(AssemblerX86_64Test,MovupdLoad)1364 TEST_F(AssemblerX86_64Test, MovupdLoad) {
1365 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movupd, "movupd {mem}, %{reg}"), "movupd_l");
1366 }
1367
TEST_F(AssemblerX86_64AVXTest,VMovupdLoad)1368 TEST_F(AssemblerX86_64AVXTest, VMovupdLoad) {
1369 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovupd, "vmovupd {mem}, %{reg}"), "vmovupd_l");
1370 }
1371
TEST_F(AssemblerX86_64AVXTest,MovupdLoad)1372 TEST_F(AssemblerX86_64AVXTest, MovupdLoad) {
1373 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movupd, "vmovupd {mem}, %{reg}"), "avx_movupd_l");
1374 }
1375
TEST_F(AssemblerX86_64Test,Movsd)1376 TEST_F(AssemblerX86_64Test, Movsd) {
1377 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movsd, "movsd %{reg2}, %{reg1}"), "movsd");
1378 }
1379
TEST_F(AssemblerX86_64Test,Movdqa)1380 TEST_F(AssemblerX86_64Test, Movdqa) {
1381 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movdqa, "movdqa %{reg2}, %{reg1}"), "movdqa");
1382 }
1383
TEST_F(AssemblerX86_64AVXTest,VMovdqa)1384 TEST_F(AssemblerX86_64AVXTest, VMovdqa) {
1385 DriverStr(RepeatFF(&x86_64::X86_64Assembler::vmovdqa, "vmovdqa %{reg2}, %{reg1}"), "vmovdqa");
1386 }
1387
TEST_F(AssemblerX86_64AVXTest,Movdqa)1388 TEST_F(AssemblerX86_64AVXTest, Movdqa) {
1389 DriverStr(RepeatFF(&x86_64::X86_64Assembler::movdqa, "vmovdqa %{reg2}, %{reg1}"), "avx_movdqa");
1390 }
1391
TEST_F(AssemblerX86_64Test,MovdqaStore)1392 TEST_F(AssemblerX86_64Test, MovdqaStore) {
1393 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movdqa, "movdqa %{reg}, {mem}"), "movdqa_s");
1394 }
1395
TEST_F(AssemblerX86_64AVXTest,VMovdqaStore)1396 TEST_F(AssemblerX86_64AVXTest, VMovdqaStore) {
1397 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovdqa, "vmovdqa %{reg}, {mem}"), "vmovdqa_s");
1398 }
1399
TEST_F(AssemblerX86_64AVXTest,MovdqaStore)1400 TEST_F(AssemblerX86_64AVXTest, MovdqaStore) {
1401 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movdqa, "vmovdqa %{reg}, {mem}"), "avx_movdqa_s");
1402 }
1403
TEST_F(AssemblerX86_64Test,MovdqaLoad)1404 TEST_F(AssemblerX86_64Test, MovdqaLoad) {
1405 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movdqa, "movdqa {mem}, %{reg}"), "movdqa_l");
1406 }
1407
TEST_F(AssemblerX86_64AVXTest,VMovdqaLoad)1408 TEST_F(AssemblerX86_64AVXTest, VMovdqaLoad) {
1409 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovdqa, "vmovdqa {mem}, %{reg}"), "vmovdqa_l");
1410 }
1411
TEST_F(AssemblerX86_64AVXTest,MovdqaLoad)1412 TEST_F(AssemblerX86_64AVXTest, MovdqaLoad) {
1413 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movdqa, "vmovdqa {mem}, %{reg}"), "avx_movdqa_l");
1414 }
1415
TEST_F(AssemblerX86_64Test,MovdquStore)1416 TEST_F(AssemblerX86_64Test, MovdquStore) {
1417 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movdqu, "movdqu %{reg}, {mem}"), "movdqu_s");
1418 }
1419
TEST_F(AssemblerX86_64AVXTest,VMovdquStore)1420 TEST_F(AssemblerX86_64AVXTest, VMovdquStore) {
1421 DriverStr(RepeatAF(&x86_64::X86_64Assembler::vmovdqu, "vmovdqu %{reg}, {mem}"), "vmovdqu_s");
1422 }
1423
TEST_F(AssemblerX86_64AVXTest,MovdquStore)1424 TEST_F(AssemblerX86_64AVXTest, MovdquStore) {
1425 DriverStr(RepeatAF(&x86_64::X86_64Assembler::movdqu, "vmovdqu %{reg}, {mem}"), "avx_movdqu_s");
1426 }
1427
TEST_F(AssemblerX86_64Test,MovdquLoad)1428 TEST_F(AssemblerX86_64Test, MovdquLoad) {
1429 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movdqu, "movdqu {mem}, %{reg}"), "movdqu_l");
1430 }
1431
TEST_F(AssemblerX86_64AVXTest,VMovdquLoad)1432 TEST_F(AssemblerX86_64AVXTest, VMovdquLoad) {
1433 DriverStr(RepeatFA(&x86_64::X86_64Assembler::vmovdqu, "vmovdqu {mem}, %{reg}"), "vmovdqu_l");
1434 }
1435
TEST_F(AssemblerX86_64AVXTest,MovdquLoad)1436 TEST_F(AssemblerX86_64AVXTest, MovdquLoad) {
1437 DriverStr(RepeatFA(&x86_64::X86_64Assembler::movdqu, "vmovdqu {mem}, %{reg}"), "avx_movdqu_l");
1438 }
1439
TEST_F(AssemblerX86_64Test,Movd1)1440 TEST_F(AssemblerX86_64Test, Movd1) {
1441 DriverStr(RepeatFR(&x86_64::X86_64Assembler::movd, "movd %{reg2}, %{reg1}"), "movd.1");
1442 }
1443
TEST_F(AssemblerX86_64Test,Movd2)1444 TEST_F(AssemblerX86_64Test, Movd2) {
1445 DriverStr(RepeatRF(&x86_64::X86_64Assembler::movd, "movd %{reg2}, %{reg1}"), "movd.2");
1446 }
1447
TEST_F(AssemblerX86_64Test,Addss)1448 TEST_F(AssemblerX86_64Test, Addss) {
1449 DriverStr(RepeatFF(&x86_64::X86_64Assembler::addss, "addss %{reg2}, %{reg1}"), "addss");
1450 }
1451
TEST_F(AssemblerX86_64Test,Addsd)1452 TEST_F(AssemblerX86_64Test, Addsd) {
1453 DriverStr(RepeatFF(&x86_64::X86_64Assembler::addsd, "addsd %{reg2}, %{reg1}"), "addsd");
1454 }
1455
TEST_F(AssemblerX86_64Test,Addps)1456 TEST_F(AssemblerX86_64Test, Addps) {
1457 DriverStr(RepeatFF(&x86_64::X86_64Assembler::addps, "addps %{reg2}, %{reg1}"), "addps");
1458 }
1459
TEST_F(AssemblerX86_64AVXTest,VAddps)1460 TEST_F(AssemblerX86_64AVXTest, VAddps) {
1461 DriverStr(
1462 RepeatFFF(&x86_64::X86_64Assembler::vaddps, "vaddps %{reg3}, %{reg2}, %{reg1}"), "vaddps");
1463 }
1464
TEST_F(AssemblerX86_64Test,Addpd)1465 TEST_F(AssemblerX86_64Test, Addpd) {
1466 DriverStr(RepeatFF(&x86_64::X86_64Assembler::addpd, "addpd %{reg2}, %{reg1}"), "addpd");
1467 }
1468
TEST_F(AssemblerX86_64AVXTest,VAddpd)1469 TEST_F(AssemblerX86_64AVXTest, VAddpd) {
1470 DriverStr(
1471 RepeatFFF(&x86_64::X86_64Assembler::vaddpd, "vaddpd %{reg3}, %{reg2}, %{reg1}"), "vaddpd");
1472 }
1473
TEST_F(AssemblerX86_64Test,Subss)1474 TEST_F(AssemblerX86_64Test, Subss) {
1475 DriverStr(RepeatFF(&x86_64::X86_64Assembler::subss, "subss %{reg2}, %{reg1}"), "subss");
1476 }
1477
TEST_F(AssemblerX86_64Test,Subsd)1478 TEST_F(AssemblerX86_64Test, Subsd) {
1479 DriverStr(RepeatFF(&x86_64::X86_64Assembler::subsd, "subsd %{reg2}, %{reg1}"), "subsd");
1480 }
1481
TEST_F(AssemblerX86_64Test,Subps)1482 TEST_F(AssemblerX86_64Test, Subps) {
1483 DriverStr(RepeatFF(&x86_64::X86_64Assembler::subps, "subps %{reg2}, %{reg1}"), "subps");
1484 }
1485
TEST_F(AssemblerX86_64AVXTest,VSubps)1486 TEST_F(AssemblerX86_64AVXTest, VSubps) {
1487 DriverStr(
1488 RepeatFFF(&x86_64::X86_64Assembler::vsubps, "vsubps %{reg3},%{reg2}, %{reg1}"), "vsubps");
1489 }
1490
TEST_F(AssemblerX86_64Test,Subpd)1491 TEST_F(AssemblerX86_64Test, Subpd) {
1492 DriverStr(RepeatFF(&x86_64::X86_64Assembler::subpd, "subpd %{reg2}, %{reg1}"), "subpd");
1493 }
1494
TEST_F(AssemblerX86_64AVXTest,VSubpd)1495 TEST_F(AssemblerX86_64AVXTest, VSubpd) {
1496 DriverStr(
1497 RepeatFFF(&x86_64::X86_64Assembler::vsubpd, "vsubpd %{reg3}, %{reg2}, %{reg1}"), "vsubpd");
1498 }
1499
TEST_F(AssemblerX86_64Test,Mulss)1500 TEST_F(AssemblerX86_64Test, Mulss) {
1501 DriverStr(RepeatFF(&x86_64::X86_64Assembler::mulss, "mulss %{reg2}, %{reg1}"), "mulss");
1502 }
1503
TEST_F(AssemblerX86_64Test,Mulsd)1504 TEST_F(AssemblerX86_64Test, Mulsd) {
1505 DriverStr(RepeatFF(&x86_64::X86_64Assembler::mulsd, "mulsd %{reg2}, %{reg1}"), "mulsd");
1506 }
1507
TEST_F(AssemblerX86_64Test,Mulps)1508 TEST_F(AssemblerX86_64Test, Mulps) {
1509 DriverStr(RepeatFF(&x86_64::X86_64Assembler::mulps, "mulps %{reg2}, %{reg1}"), "mulps");
1510 }
1511
TEST_F(AssemblerX86_64AVXTest,VMulps)1512 TEST_F(AssemblerX86_64AVXTest, VMulps) {
1513 DriverStr(
1514 RepeatFFF(&x86_64::X86_64Assembler::vmulps, "vmulps %{reg3}, %{reg2}, %{reg1}"), "vmulps");
1515 }
1516
TEST_F(AssemblerX86_64Test,Mulpd)1517 TEST_F(AssemblerX86_64Test, Mulpd) {
1518 DriverStr(RepeatFF(&x86_64::X86_64Assembler::mulpd, "mulpd %{reg2}, %{reg1}"), "mulpd");
1519 }
1520
TEST_F(AssemblerX86_64AVXTest,VMulpd)1521 TEST_F(AssemblerX86_64AVXTest, VMulpd) {
1522 DriverStr(
1523 RepeatFFF(&x86_64::X86_64Assembler::vmulpd, "vmulpd %{reg3}, %{reg2}, %{reg1}"), "vmulpd");
1524 }
1525
TEST_F(AssemblerX86_64Test,Divss)1526 TEST_F(AssemblerX86_64Test, Divss) {
1527 DriverStr(RepeatFF(&x86_64::X86_64Assembler::divss, "divss %{reg2}, %{reg1}"), "divss");
1528 }
1529
TEST_F(AssemblerX86_64Test,Divsd)1530 TEST_F(AssemblerX86_64Test, Divsd) {
1531 DriverStr(RepeatFF(&x86_64::X86_64Assembler::divsd, "divsd %{reg2}, %{reg1}"), "divsd");
1532 }
1533
TEST_F(AssemblerX86_64Test,Divps)1534 TEST_F(AssemblerX86_64Test, Divps) {
1535 DriverStr(RepeatFF(&x86_64::X86_64Assembler::divps, "divps %{reg2}, %{reg1}"), "divps");
1536 }
1537
TEST_F(AssemblerX86_64AVXTest,VDivps)1538 TEST_F(AssemblerX86_64AVXTest, VDivps) {
1539 DriverStr(
1540 RepeatFFF(&x86_64::X86_64Assembler::vdivps, "vdivps %{reg3}, %{reg2}, %{reg1}"), "vdivps");
1541 }
1542
TEST_F(AssemblerX86_64Test,Divpd)1543 TEST_F(AssemblerX86_64Test, Divpd) {
1544 DriverStr(RepeatFF(&x86_64::X86_64Assembler::divpd, "divpd %{reg2}, %{reg1}"), "divpd");
1545 }
1546
TEST_F(AssemblerX86_64AVXTest,VDivpd)1547 TEST_F(AssemblerX86_64AVXTest, VDivpd) {
1548 DriverStr(
1549 RepeatFFF(&x86_64::X86_64Assembler::vdivpd, "vdivpd %{reg3}, %{reg2}, %{reg1}"), "vdivpd");
1550 }
1551
TEST_F(AssemblerX86_64Test,Paddb)1552 TEST_F(AssemblerX86_64Test, Paddb) {
1553 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddb, "paddb %{reg2}, %{reg1}"), "paddb");
1554 }
1555
TEST_F(AssemblerX86_64AVXTest,VPaddb)1556 TEST_F(AssemblerX86_64AVXTest, VPaddb) {
1557 DriverStr(
1558 RepeatFFF(&x86_64::X86_64Assembler::vpaddb, "vpaddb %{reg3}, %{reg2}, %{reg1}"), "vpaddb");
1559 }
1560
TEST_F(AssemblerX86_64Test,Psubb)1561 TEST_F(AssemblerX86_64Test, Psubb) {
1562 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubb, "psubb %{reg2}, %{reg1}"), "psubb");
1563 }
1564
TEST_F(AssemblerX86_64AVXTest,VPsubb)1565 TEST_F(AssemblerX86_64AVXTest, VPsubb) {
1566 DriverStr(
1567 RepeatFFF(&x86_64::X86_64Assembler::vpsubb, "vpsubb %{reg3},%{reg2}, %{reg1}"), "vpsubb");
1568 }
1569
TEST_F(AssemblerX86_64Test,Paddw)1570 TEST_F(AssemblerX86_64Test, Paddw) {
1571 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddw, "paddw %{reg2}, %{reg1}"), "paddw");
1572 }
1573
TEST_F(AssemblerX86_64AVXTest,VPsubw)1574 TEST_F(AssemblerX86_64AVXTest, VPsubw) {
1575 DriverStr(
1576 RepeatFFF(&x86_64::X86_64Assembler::vpsubw, "vpsubw %{reg3}, %{reg2}, %{reg1}"), "vpsubw");
1577 }
1578
TEST_F(AssemblerX86_64AVXTest,VPaddw)1579 TEST_F(AssemblerX86_64AVXTest, VPaddw) {
1580 DriverStr(
1581 RepeatFFF(&x86_64::X86_64Assembler::vpaddw, "vpaddw %{reg3}, %{reg2}, %{reg1}"), "vpaddw");
1582 }
1583
TEST_F(AssemblerX86_64Test,Psubw)1584 TEST_F(AssemblerX86_64Test, Psubw) {
1585 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubw, "psubw %{reg2}, %{reg1}"), "psubw");
1586 }
1587
TEST_F(AssemblerX86_64Test,Pmullw)1588 TEST_F(AssemblerX86_64Test, Pmullw) {
1589 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmullw, "pmullw %{reg2}, %{reg1}"), "pmullw");
1590 }
1591
TEST_F(AssemblerX86_64AVXTest,VPmullw)1592 TEST_F(AssemblerX86_64AVXTest, VPmullw) {
1593 DriverStr(
1594 RepeatFFF(&x86_64::X86_64Assembler::vpmullw, "vpmullw %{reg3}, %{reg2}, %{reg1}"), "vpmullw");
1595 }
1596
TEST_F(AssemblerX86_64Test,Paddd)1597 TEST_F(AssemblerX86_64Test, Paddd) {
1598 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddd, "paddd %{reg2}, %{reg1}"), "paddd");
1599 }
1600
TEST_F(AssemblerX86_64AVXTest,VPaddd)1601 TEST_F(AssemblerX86_64AVXTest, VPaddd) {
1602 DriverStr(
1603 RepeatFFF(&x86_64::X86_64Assembler::vpaddd, "vpaddd %{reg3}, %{reg2}, %{reg1}"), "vpaddd");
1604 }
1605
TEST_F(AssemblerX86_64Test,Psubd)1606 TEST_F(AssemblerX86_64Test, Psubd) {
1607 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubd, "psubd %{reg2}, %{reg1}"), "psubd");
1608 }
1609
TEST_F(AssemblerX86_64AVXTest,VPsubd)1610 TEST_F(AssemblerX86_64AVXTest, VPsubd) {
1611 DriverStr(
1612 RepeatFFF(&x86_64::X86_64Assembler::vpsubd, "vpsubd %{reg3}, %{reg2}, %{reg1}"), "vpsubd");
1613 }
1614
TEST_F(AssemblerX86_64Test,Pmulld)1615 TEST_F(AssemblerX86_64Test, Pmulld) {
1616 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmulld, "pmulld %{reg2}, %{reg1}"), "pmulld");
1617 }
1618
TEST_F(AssemblerX86_64AVXTest,VPmulld)1619 TEST_F(AssemblerX86_64AVXTest, VPmulld) {
1620 DriverStr(
1621 RepeatFFF(&x86_64::X86_64Assembler::vpmulld, "vpmulld %{reg3}, %{reg2}, %{reg1}"), "vpmulld");
1622 }
1623
TEST_F(AssemblerX86_64Test,Paddq)1624 TEST_F(AssemblerX86_64Test, Paddq) {
1625 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddq, "paddq %{reg2}, %{reg1}"), "paddq");
1626 }
1627
TEST_F(AssemblerX86_64AVXTest,VPaddq)1628 TEST_F(AssemblerX86_64AVXTest, VPaddq) {
1629 DriverStr(
1630 RepeatFFF(&x86_64::X86_64Assembler::vpaddq, "vpaddq %{reg3}, %{reg2}, %{reg1}"), "vpaddq");
1631 }
1632
TEST_F(AssemblerX86_64Test,Psubq)1633 TEST_F(AssemblerX86_64Test, Psubq) {
1634 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubq, "psubq %{reg2}, %{reg1}"), "psubq");
1635 }
1636
TEST_F(AssemblerX86_64AVXTest,VPsubq)1637 TEST_F(AssemblerX86_64AVXTest, VPsubq) {
1638 DriverStr(
1639 RepeatFFF(&x86_64::X86_64Assembler::vpsubq, "vpsubq %{reg3}, %{reg2}, %{reg1}"), "vpsubq");
1640 }
1641
TEST_F(AssemblerX86_64Test,Paddusb)1642 TEST_F(AssemblerX86_64Test, Paddusb) {
1643 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddusb, "paddusb %{reg2}, %{reg1}"), "paddusb");
1644 }
1645
TEST_F(AssemblerX86_64Test,Paddsb)1646 TEST_F(AssemblerX86_64Test, Paddsb) {
1647 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddsb, "paddsb %{reg2}, %{reg1}"), "paddsb");
1648 }
1649
TEST_F(AssemblerX86_64Test,Paddusw)1650 TEST_F(AssemblerX86_64Test, Paddusw) {
1651 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddusw, "paddusw %{reg2}, %{reg1}"), "paddusw");
1652 }
1653
TEST_F(AssemblerX86_64Test,Paddsw)1654 TEST_F(AssemblerX86_64Test, Paddsw) {
1655 DriverStr(RepeatFF(&x86_64::X86_64Assembler::paddsw, "paddsw %{reg2}, %{reg1}"), "paddsw");
1656 }
1657
TEST_F(AssemblerX86_64Test,Psubusb)1658 TEST_F(AssemblerX86_64Test, Psubusb) {
1659 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubusb, "psubusb %{reg2}, %{reg1}"), "psubusb");
1660 }
1661
TEST_F(AssemblerX86_64Test,Psubsb)1662 TEST_F(AssemblerX86_64Test, Psubsb) {
1663 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubsb, "psubsb %{reg2}, %{reg1}"), "psubsb");
1664 }
1665
TEST_F(AssemblerX86_64Test,Psubusw)1666 TEST_F(AssemblerX86_64Test, Psubusw) {
1667 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubusw, "psubusw %{reg2}, %{reg1}"), "psubusw");
1668 }
1669
TEST_F(AssemblerX86_64Test,Psubsw)1670 TEST_F(AssemblerX86_64Test, Psubsw) {
1671 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psubsw, "psubsw %{reg2}, %{reg1}"), "psubsw");
1672 }
1673
TEST_F(AssemblerX86_64Test,Cvtsi2ss)1674 TEST_F(AssemblerX86_64Test, Cvtsi2ss) {
1675 DriverStr(RepeatFr(&x86_64::X86_64Assembler::cvtsi2ss, "cvtsi2ss %{reg2}, %{reg1}"), "cvtsi2ss");
1676 }
1677
TEST_F(AssemblerX86_64Test,Cvtsi2sd)1678 TEST_F(AssemblerX86_64Test, Cvtsi2sd) {
1679 DriverStr(RepeatFr(&x86_64::X86_64Assembler::cvtsi2sd, "cvtsi2sd %{reg2}, %{reg1}"), "cvtsi2sd");
1680 }
1681
TEST_F(AssemblerX86_64Test,Cvtss2si)1682 TEST_F(AssemblerX86_64Test, Cvtss2si) {
1683 DriverStr(RepeatrF(&x86_64::X86_64Assembler::cvtss2si, "cvtss2si %{reg2}, %{reg1}"), "cvtss2si");
1684 }
1685
TEST_F(AssemblerX86_64Test,Cvtss2sd)1686 TEST_F(AssemblerX86_64Test, Cvtss2sd) {
1687 DriverStr(RepeatFF(&x86_64::X86_64Assembler::cvtss2sd, "cvtss2sd %{reg2}, %{reg1}"), "cvtss2sd");
1688 }
1689
TEST_F(AssemblerX86_64Test,Cvtsd2si)1690 TEST_F(AssemblerX86_64Test, Cvtsd2si) {
1691 DriverStr(RepeatrF(&x86_64::X86_64Assembler::cvtsd2si, "cvtsd2si %{reg2}, %{reg1}"), "cvtsd2si");
1692 }
1693
TEST_F(AssemblerX86_64Test,Cvttss2si)1694 TEST_F(AssemblerX86_64Test, Cvttss2si) {
1695 DriverStr(RepeatrF(&x86_64::X86_64Assembler::cvttss2si, "cvttss2si %{reg2}, %{reg1}"),
1696 "cvttss2si");
1697 }
1698
TEST_F(AssemblerX86_64Test,Cvttsd2si)1699 TEST_F(AssemblerX86_64Test, Cvttsd2si) {
1700 DriverStr(RepeatrF(&x86_64::X86_64Assembler::cvttsd2si, "cvttsd2si %{reg2}, %{reg1}"),
1701 "cvttsd2si");
1702 }
1703
TEST_F(AssemblerX86_64Test,Cvtsd2ss)1704 TEST_F(AssemblerX86_64Test, Cvtsd2ss) {
1705 DriverStr(RepeatFF(&x86_64::X86_64Assembler::cvtsd2ss, "cvtsd2ss %{reg2}, %{reg1}"), "cvtsd2ss");
1706 }
1707
TEST_F(AssemblerX86_64Test,Cvtdq2ps)1708 TEST_F(AssemblerX86_64Test, Cvtdq2ps) {
1709 DriverStr(RepeatFF(&x86_64::X86_64Assembler::cvtdq2ps, "cvtdq2ps %{reg2}, %{reg1}"), "cvtdq2ps");
1710 }
1711
TEST_F(AssemblerX86_64Test,Cvtdq2pd)1712 TEST_F(AssemblerX86_64Test, Cvtdq2pd) {
1713 DriverStr(RepeatFF(&x86_64::X86_64Assembler::cvtdq2pd, "cvtdq2pd %{reg2}, %{reg1}"), "cvtdq2pd");
1714 }
1715
TEST_F(AssemblerX86_64Test,Comiss)1716 TEST_F(AssemblerX86_64Test, Comiss) {
1717 DriverStr(RepeatFF(&x86_64::X86_64Assembler::comiss, "comiss %{reg2}, %{reg1}"), "comiss");
1718 }
1719
TEST_F(AssemblerX86_64Test,Comisd)1720 TEST_F(AssemblerX86_64Test, Comisd) {
1721 DriverStr(RepeatFF(&x86_64::X86_64Assembler::comisd, "comisd %{reg2}, %{reg1}"), "comisd");
1722 }
1723
TEST_F(AssemblerX86_64Test,Ucomiss)1724 TEST_F(AssemblerX86_64Test, Ucomiss) {
1725 DriverStr(RepeatFF(&x86_64::X86_64Assembler::ucomiss, "ucomiss %{reg2}, %{reg1}"), "ucomiss");
1726 }
1727
TEST_F(AssemblerX86_64Test,Ucomisd)1728 TEST_F(AssemblerX86_64Test, Ucomisd) {
1729 DriverStr(RepeatFF(&x86_64::X86_64Assembler::ucomisd, "ucomisd %{reg2}, %{reg1}"), "ucomisd");
1730 }
1731
TEST_F(AssemblerX86_64Test,Sqrtss)1732 TEST_F(AssemblerX86_64Test, Sqrtss) {
1733 DriverStr(RepeatFF(&x86_64::X86_64Assembler::sqrtss, "sqrtss %{reg2}, %{reg1}"), "sqrtss");
1734 }
1735
TEST_F(AssemblerX86_64Test,Sqrtsd)1736 TEST_F(AssemblerX86_64Test, Sqrtsd) {
1737 DriverStr(RepeatFF(&x86_64::X86_64Assembler::sqrtsd, "sqrtsd %{reg2}, %{reg1}"), "sqrtsd");
1738 }
1739
TEST_F(AssemblerX86_64Test,Roundss)1740 TEST_F(AssemblerX86_64Test, Roundss) {
1741 DriverStr(RepeatFFI(&x86_64::X86_64Assembler::roundss, /*imm_bytes*/ 1U,
1742 "roundss ${imm}, %{reg2}, %{reg1}"), "roundss");
1743 }
1744
TEST_F(AssemblerX86_64Test,Roundsd)1745 TEST_F(AssemblerX86_64Test, Roundsd) {
1746 DriverStr(RepeatFFI(&x86_64::X86_64Assembler::roundsd, /*imm_bytes*/ 1U,
1747 "roundsd ${imm}, %{reg2}, %{reg1}"), "roundsd");
1748 }
1749
TEST_F(AssemblerX86_64Test,Xorps)1750 TEST_F(AssemblerX86_64Test, Xorps) {
1751 DriverStr(RepeatFF(&x86_64::X86_64Assembler::xorps, "xorps %{reg2}, %{reg1}"), "xorps");
1752 }
1753
TEST_F(AssemblerX86_64Test,Xorpd)1754 TEST_F(AssemblerX86_64Test, Xorpd) {
1755 DriverStr(RepeatFF(&x86_64::X86_64Assembler::xorpd, "xorpd %{reg2}, %{reg1}"), "xorpd");
1756 }
1757
TEST_F(AssemblerX86_64Test,Pxor)1758 TEST_F(AssemblerX86_64Test, Pxor) {
1759 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pxor, "pxor %{reg2}, %{reg1}"), "pxor");
1760 }
1761
TEST_F(AssemblerX86_64AVXTest,VPXor)1762 TEST_F(AssemblerX86_64AVXTest, VPXor) {
1763 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vpxor,
1764 "vpxor %{reg3}, %{reg2}, %{reg1}"), "vpxor");
1765 }
1766
TEST_F(AssemblerX86_64AVXTest,VXorps)1767 TEST_F(AssemblerX86_64AVXTest, VXorps) {
1768 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vxorps,
1769 "vxorps %{reg3}, %{reg2}, %{reg1}"), "vxorps");
1770 }
1771
TEST_F(AssemblerX86_64AVXTest,VXorpd)1772 TEST_F(AssemblerX86_64AVXTest, VXorpd) {
1773 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vxorpd,
1774 "vxorpd %{reg3}, %{reg2}, %{reg1}"), "vxorpd");
1775 }
1776
TEST_F(AssemblerX86_64Test,Andps)1777 TEST_F(AssemblerX86_64Test, Andps) {
1778 DriverStr(RepeatFF(&x86_64::X86_64Assembler::andps, "andps %{reg2}, %{reg1}"), "andps");
1779 }
1780
TEST_F(AssemblerX86_64Test,Andpd)1781 TEST_F(AssemblerX86_64Test, Andpd) {
1782 DriverStr(RepeatFF(&x86_64::X86_64Assembler::andpd, "andpd %{reg2}, %{reg1}"), "andpd");
1783 }
1784
TEST_F(AssemblerX86_64Test,Pand)1785 TEST_F(AssemblerX86_64Test, Pand) {
1786 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pand, "pand %{reg2}, %{reg1}"), "pand");
1787 }
1788
TEST_F(AssemblerX86_64AVXTest,VPAnd)1789 TEST_F(AssemblerX86_64AVXTest, VPAnd) {
1790 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vpand,
1791 "vpand %{reg3}, %{reg2}, %{reg1}"), "vpand");
1792 }
1793
TEST_F(AssemblerX86_64AVXTest,VAndps)1794 TEST_F(AssemblerX86_64AVXTest, VAndps) {
1795 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vandps,
1796 "vandps %{reg3}, %{reg2}, %{reg1}"), "vandps");
1797 }
1798
TEST_F(AssemblerX86_64AVXTest,VAndpd)1799 TEST_F(AssemblerX86_64AVXTest, VAndpd) {
1800 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vandpd,
1801 "vandpd %{reg3}, %{reg2}, %{reg1}"), "vandpd");
1802 }
1803
TEST_F(AssemblerX86_64Test,Andn)1804 TEST_F(AssemblerX86_64Test, Andn) {
1805 DriverStr(RepeatRRR(&x86_64::X86_64Assembler::andn, "andn %{reg3}, %{reg2}, %{reg1}"), "andn");
1806 }
TEST_F(AssemblerX86_64Test,andnpd)1807 TEST_F(AssemblerX86_64Test, andnpd) {
1808 DriverStr(RepeatFF(&x86_64::X86_64Assembler::andnpd, "andnpd %{reg2}, %{reg1}"), "andnpd");
1809 }
1810
TEST_F(AssemblerX86_64Test,andnps)1811 TEST_F(AssemblerX86_64Test, andnps) {
1812 DriverStr(RepeatFF(&x86_64::X86_64Assembler::andnps, "andnps %{reg2}, %{reg1}"), "andnps");
1813 }
1814
TEST_F(AssemblerX86_64Test,Pandn)1815 TEST_F(AssemblerX86_64Test, Pandn) {
1816 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pandn, "pandn %{reg2}, %{reg1}"), "pandn");
1817 }
1818
TEST_F(AssemblerX86_64AVXTest,VPAndn)1819 TEST_F(AssemblerX86_64AVXTest, VPAndn) {
1820 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vpandn,
1821 "vpandn %{reg3}, %{reg2}, %{reg1}"), "vpandn");
1822 }
1823
TEST_F(AssemblerX86_64AVXTest,VAndnps)1824 TEST_F(AssemblerX86_64AVXTest, VAndnps) {
1825 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vandnps,
1826 "vandnps %{reg3}, %{reg2}, %{reg1}"), "vandnps");
1827 }
1828
TEST_F(AssemblerX86_64AVXTest,VAndnpd)1829 TEST_F(AssemblerX86_64AVXTest, VAndnpd) {
1830 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vandnpd,
1831 "vandnpd %{reg3}, %{reg2}, %{reg1}"), "vandnpd");
1832 }
1833
TEST_F(AssemblerX86_64Test,Orps)1834 TEST_F(AssemblerX86_64Test, Orps) {
1835 DriverStr(RepeatFF(&x86_64::X86_64Assembler::orps, "orps %{reg2}, %{reg1}"), "orps");
1836 }
1837
TEST_F(AssemblerX86_64Test,Orpd)1838 TEST_F(AssemblerX86_64Test, Orpd) {
1839 DriverStr(RepeatFF(&x86_64::X86_64Assembler::orpd, "orpd %{reg2}, %{reg1}"), "orpd");
1840 }
1841
TEST_F(AssemblerX86_64Test,Por)1842 TEST_F(AssemblerX86_64Test, Por) {
1843 DriverStr(RepeatFF(&x86_64::X86_64Assembler::por, "por %{reg2}, %{reg1}"), "por");
1844 }
1845
TEST_F(AssemblerX86_64AVXTest,VPor)1846 TEST_F(AssemblerX86_64AVXTest, VPor) {
1847 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vpor,
1848 "vpor %{reg3}, %{reg2}, %{reg1}"), "vpor");
1849 }
1850
TEST_F(AssemblerX86_64AVXTest,Vorps)1851 TEST_F(AssemblerX86_64AVXTest, Vorps) {
1852 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vorps,
1853 "vorps %{reg3}, %{reg2}, %{reg1}"), "vorps");
1854 }
1855
TEST_F(AssemblerX86_64AVXTest,Vorpd)1856 TEST_F(AssemblerX86_64AVXTest, Vorpd) {
1857 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vorpd,
1858 "vorpd %{reg3}, %{reg2}, %{reg1}"), "vorpd");
1859 }
1860
TEST_F(AssemblerX86_64Test,Pavgb)1861 TEST_F(AssemblerX86_64Test, Pavgb) {
1862 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pavgb, "pavgb %{reg2}, %{reg1}"), "pavgb");
1863 }
1864
TEST_F(AssemblerX86_64Test,Pavgw)1865 TEST_F(AssemblerX86_64Test, Pavgw) {
1866 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pavgw, "pavgw %{reg2}, %{reg1}"), "pavgw");
1867 }
1868
TEST_F(AssemblerX86_64Test,Psadbw)1869 TEST_F(AssemblerX86_64Test, Psadbw) {
1870 DriverStr(RepeatFF(&x86_64::X86_64Assembler::psadbw, "psadbw %{reg2}, %{reg1}"), "psadbw");
1871 }
1872
TEST_F(AssemblerX86_64Test,Pmaddwd)1873 TEST_F(AssemblerX86_64Test, Pmaddwd) {
1874 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaddwd, "pmaddwd %{reg2}, %{reg1}"), "pmadwd");
1875 }
1876
TEST_F(AssemblerX86_64AVXTest,VPmaddwd)1877 TEST_F(AssemblerX86_64AVXTest, VPmaddwd) {
1878 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vpmaddwd,
1879 "vpmaddwd %{reg3}, %{reg2}, %{reg1}"), "vpmaddwd");
1880 }
1881
TEST_F(AssemblerX86_64AVXTest,VFmadd213ss)1882 TEST_F(AssemblerX86_64AVXTest, VFmadd213ss) {
1883 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vfmadd213ss,
1884 "vfmadd213ss %{reg3}, %{reg2}, %{reg1}"), "vfmadd213ss");
1885 }
1886
TEST_F(AssemblerX86_64AVXTest,VFmadd213sd)1887 TEST_F(AssemblerX86_64AVXTest, VFmadd213sd) {
1888 DriverStr(RepeatFFF(&x86_64::X86_64Assembler::vfmadd213sd,
1889 "vfmadd213sd %{reg3}, %{reg2}, %{reg1}"), "vfmadd213sd");
1890 }
1891
TEST_F(AssemblerX86_64Test,Phaddw)1892 TEST_F(AssemblerX86_64Test, Phaddw) {
1893 DriverStr(RepeatFF(&x86_64::X86_64Assembler::phaddw, "phaddw %{reg2}, %{reg1}"), "phaddw");
1894 }
1895
TEST_F(AssemblerX86_64Test,Phaddd)1896 TEST_F(AssemblerX86_64Test, Phaddd) {
1897 DriverStr(RepeatFF(&x86_64::X86_64Assembler::phaddd, "phaddd %{reg2}, %{reg1}"), "phaddd");
1898 }
1899
TEST_F(AssemblerX86_64Test,Haddps)1900 TEST_F(AssemblerX86_64Test, Haddps) {
1901 DriverStr(RepeatFF(&x86_64::X86_64Assembler::haddps, "haddps %{reg2}, %{reg1}"), "haddps");
1902 }
1903
TEST_F(AssemblerX86_64Test,Haddpd)1904 TEST_F(AssemblerX86_64Test, Haddpd) {
1905 DriverStr(RepeatFF(&x86_64::X86_64Assembler::haddpd, "haddpd %{reg2}, %{reg1}"), "haddpd");
1906 }
1907
TEST_F(AssemblerX86_64Test,Phsubw)1908 TEST_F(AssemblerX86_64Test, Phsubw) {
1909 DriverStr(RepeatFF(&x86_64::X86_64Assembler::phsubw, "phsubw %{reg2}, %{reg1}"), "phsubw");
1910 }
1911
TEST_F(AssemblerX86_64Test,Phsubd)1912 TEST_F(AssemblerX86_64Test, Phsubd) {
1913 DriverStr(RepeatFF(&x86_64::X86_64Assembler::phsubd, "phsubd %{reg2}, %{reg1}"), "phsubd");
1914 }
1915
TEST_F(AssemblerX86_64Test,Hsubps)1916 TEST_F(AssemblerX86_64Test, Hsubps) {
1917 DriverStr(RepeatFF(&x86_64::X86_64Assembler::hsubps, "hsubps %{reg2}, %{reg1}"), "hsubps");
1918 }
1919
TEST_F(AssemblerX86_64Test,Hsubpd)1920 TEST_F(AssemblerX86_64Test, Hsubpd) {
1921 DriverStr(RepeatFF(&x86_64::X86_64Assembler::hsubpd, "hsubpd %{reg2}, %{reg1}"), "hsubpd");
1922 }
1923
TEST_F(AssemblerX86_64Test,Pminsb)1924 TEST_F(AssemblerX86_64Test, Pminsb) {
1925 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminsb, "pminsb %{reg2}, %{reg1}"), "pminsb");
1926 }
1927
TEST_F(AssemblerX86_64Test,Pmaxsb)1928 TEST_F(AssemblerX86_64Test, Pmaxsb) {
1929 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxsb, "pmaxsb %{reg2}, %{reg1}"), "pmaxsb");
1930 }
1931
TEST_F(AssemblerX86_64Test,Pminsw)1932 TEST_F(AssemblerX86_64Test, Pminsw) {
1933 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminsw, "pminsw %{reg2}, %{reg1}"), "pminsw");
1934 }
1935
TEST_F(AssemblerX86_64Test,Pmaxsw)1936 TEST_F(AssemblerX86_64Test, Pmaxsw) {
1937 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxsw, "pmaxsw %{reg2}, %{reg1}"), "pmaxsw");
1938 }
1939
TEST_F(AssemblerX86_64Test,Pminsd)1940 TEST_F(AssemblerX86_64Test, Pminsd) {
1941 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminsd, "pminsd %{reg2}, %{reg1}"), "pminsd");
1942 }
1943
TEST_F(AssemblerX86_64Test,Pmaxsd)1944 TEST_F(AssemblerX86_64Test, Pmaxsd) {
1945 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxsd, "pmaxsd %{reg2}, %{reg1}"), "pmaxsd");
1946 }
1947
TEST_F(AssemblerX86_64Test,Pminub)1948 TEST_F(AssemblerX86_64Test, Pminub) {
1949 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminub, "pminub %{reg2}, %{reg1}"), "pminub");
1950 }
1951
TEST_F(AssemblerX86_64Test,Pmaxub)1952 TEST_F(AssemblerX86_64Test, Pmaxub) {
1953 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxub, "pmaxub %{reg2}, %{reg1}"), "pmaxub");
1954 }
1955
TEST_F(AssemblerX86_64Test,Pminuw)1956 TEST_F(AssemblerX86_64Test, Pminuw) {
1957 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminuw, "pminuw %{reg2}, %{reg1}"), "pminuw");
1958 }
1959
TEST_F(AssemblerX86_64Test,Pmaxuw)1960 TEST_F(AssemblerX86_64Test, Pmaxuw) {
1961 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxuw, "pmaxuw %{reg2}, %{reg1}"), "pmaxuw");
1962 }
1963
TEST_F(AssemblerX86_64Test,Pminud)1964 TEST_F(AssemblerX86_64Test, Pminud) {
1965 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pminud, "pminud %{reg2}, %{reg1}"), "pminud");
1966 }
1967
TEST_F(AssemblerX86_64Test,Pmaxud)1968 TEST_F(AssemblerX86_64Test, Pmaxud) {
1969 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pmaxud, "pmaxud %{reg2}, %{reg1}"), "pmaxud");
1970 }
1971
TEST_F(AssemblerX86_64Test,Minps)1972 TEST_F(AssemblerX86_64Test, Minps) {
1973 DriverStr(RepeatFF(&x86_64::X86_64Assembler::minps, "minps %{reg2}, %{reg1}"), "minps");
1974 }
1975
TEST_F(AssemblerX86_64Test,Maxps)1976 TEST_F(AssemblerX86_64Test, Maxps) {
1977 DriverStr(RepeatFF(&x86_64::X86_64Assembler::maxps, "maxps %{reg2}, %{reg1}"), "maxps");
1978 }
1979
TEST_F(AssemblerX86_64Test,Minpd)1980 TEST_F(AssemblerX86_64Test, Minpd) {
1981 DriverStr(RepeatFF(&x86_64::X86_64Assembler::minpd, "minpd %{reg2}, %{reg1}"), "minpd");
1982 }
1983
TEST_F(AssemblerX86_64Test,Maxpd)1984 TEST_F(AssemblerX86_64Test, Maxpd) {
1985 DriverStr(RepeatFF(&x86_64::X86_64Assembler::maxpd, "maxpd %{reg2}, %{reg1}"), "maxpd");
1986 }
1987
TEST_F(AssemblerX86_64Test,PCmpeqb)1988 TEST_F(AssemblerX86_64Test, PCmpeqb) {
1989 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpeqb, "pcmpeqb %{reg2}, %{reg1}"), "pcmpeqb");
1990 }
1991
TEST_F(AssemblerX86_64Test,PCmpeqw)1992 TEST_F(AssemblerX86_64Test, PCmpeqw) {
1993 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpeqw, "pcmpeqw %{reg2}, %{reg1}"), "pcmpeqw");
1994 }
1995
TEST_F(AssemblerX86_64Test,PCmpeqd)1996 TEST_F(AssemblerX86_64Test, PCmpeqd) {
1997 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpeqd, "pcmpeqd %{reg2}, %{reg1}"), "pcmpeqd");
1998 }
1999
TEST_F(AssemblerX86_64Test,PCmpeqq)2000 TEST_F(AssemblerX86_64Test, PCmpeqq) {
2001 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpeqq, "pcmpeqq %{reg2}, %{reg1}"), "pcmpeqq");
2002 }
2003
TEST_F(AssemblerX86_64Test,PCmpgtb)2004 TEST_F(AssemblerX86_64Test, PCmpgtb) {
2005 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpgtb, "pcmpgtb %{reg2}, %{reg1}"), "pcmpgtb");
2006 }
2007
TEST_F(AssemblerX86_64Test,PCmpgtw)2008 TEST_F(AssemblerX86_64Test, PCmpgtw) {
2009 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpgtw, "pcmpgtw %{reg2}, %{reg1}"), "pcmpgtw");
2010 }
2011
TEST_F(AssemblerX86_64Test,PCmpgtd)2012 TEST_F(AssemblerX86_64Test, PCmpgtd) {
2013 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpgtd, "pcmpgtd %{reg2}, %{reg1}"), "pcmpgtd");
2014 }
2015
TEST_F(AssemblerX86_64Test,PCmpgtq)2016 TEST_F(AssemblerX86_64Test, PCmpgtq) {
2017 DriverStr(RepeatFF(&x86_64::X86_64Assembler::pcmpgtq, "pcmpgtq %{reg2}, %{reg1}"), "pcmpgtq");
2018 }
2019
TEST_F(AssemblerX86_64Test,Shufps)2020 TEST_F(AssemblerX86_64Test, Shufps) {
2021 DriverStr(RepeatFFI(&x86_64::X86_64Assembler::shufps, /*imm_bytes*/ 1U,
2022 "shufps ${imm}, %{reg2}, %{reg1}"), "shufps");
2023 }
2024
TEST_F(AssemblerX86_64Test,Shufpd)2025 TEST_F(AssemblerX86_64Test, Shufpd) {
2026 DriverStr(RepeatFFI(&x86_64::X86_64Assembler::shufpd, /*imm_bytes*/ 1U,
2027 "shufpd ${imm}, %{reg2}, %{reg1}"), "shufpd");
2028 }
2029
TEST_F(AssemblerX86_64Test,PShufd)2030 TEST_F(AssemblerX86_64Test, PShufd) {
2031 DriverStr(RepeatFFI(&x86_64::X86_64Assembler::pshufd, /*imm_bytes*/ 1U,
2032 "pshufd ${imm}, %{reg2}, %{reg1}"), "pshufd");
2033 }
2034
TEST_F(AssemblerX86_64Test,Punpcklbw)2035 TEST_F(AssemblerX86_64Test, Punpcklbw) {
2036 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpcklbw,
2037 "punpcklbw %{reg2}, %{reg1}"), "punpcklbw");
2038 }
2039
TEST_F(AssemblerX86_64Test,Punpcklwd)2040 TEST_F(AssemblerX86_64Test, Punpcklwd) {
2041 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpcklwd,
2042 "punpcklwd %{reg2}, %{reg1}"), "punpcklwd");
2043 }
2044
TEST_F(AssemblerX86_64Test,Punpckldq)2045 TEST_F(AssemblerX86_64Test, Punpckldq) {
2046 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpckldq,
2047 "punpckldq %{reg2}, %{reg1}"), "punpckldq");
2048 }
2049
TEST_F(AssemblerX86_64Test,Punpcklqdq)2050 TEST_F(AssemblerX86_64Test, Punpcklqdq) {
2051 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpcklqdq,
2052 "punpcklqdq %{reg2}, %{reg1}"), "punpcklqdq");
2053 }
2054
TEST_F(AssemblerX86_64Test,Punpckhbw)2055 TEST_F(AssemblerX86_64Test, Punpckhbw) {
2056 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpckhbw,
2057 "punpckhbw %{reg2}, %{reg1}"), "punpckhbw");
2058 }
2059
TEST_F(AssemblerX86_64Test,Punpckhwd)2060 TEST_F(AssemblerX86_64Test, Punpckhwd) {
2061 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpckhwd,
2062 "punpckhwd %{reg2}, %{reg1}"), "punpckhwd");
2063 }
2064
TEST_F(AssemblerX86_64Test,Punpckhdq)2065 TEST_F(AssemblerX86_64Test, Punpckhdq) {
2066 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpckhdq,
2067 "punpckhdq %{reg2}, %{reg1}"), "punpckhdq");
2068 }
2069
TEST_F(AssemblerX86_64Test,Punpckhqdq)2070 TEST_F(AssemblerX86_64Test, Punpckhqdq) {
2071 DriverStr(RepeatFF(&x86_64::X86_64Assembler::punpckhqdq,
2072 "punpckhqdq %{reg2}, %{reg1}"), "punpckhqdq");
2073 }
2074
TEST_F(AssemblerX86_64Test,Psllw)2075 TEST_F(AssemblerX86_64Test, Psllw) {
2076 GetAssembler()->psllw(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2077 GetAssembler()->psllw(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2078 DriverStr("psllw $1, %xmm0\n"
2079 "psllw $2, %xmm15\n", "psllwi");
2080 }
2081
TEST_F(AssemblerX86_64Test,Pslld)2082 TEST_F(AssemblerX86_64Test, Pslld) {
2083 GetAssembler()->pslld(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2084 GetAssembler()->pslld(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2085 DriverStr("pslld $1, %xmm0\n"
2086 "pslld $2, %xmm15\n", "pslldi");
2087 }
2088
TEST_F(AssemblerX86_64Test,Psllq)2089 TEST_F(AssemblerX86_64Test, Psllq) {
2090 GetAssembler()->psllq(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2091 GetAssembler()->psllq(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2092 DriverStr("psllq $1, %xmm0\n"
2093 "psllq $2, %xmm15\n", "psllqi");
2094 }
2095
TEST_F(AssemblerX86_64Test,Psraw)2096 TEST_F(AssemblerX86_64Test, Psraw) {
2097 GetAssembler()->psraw(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2098 GetAssembler()->psraw(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2099 DriverStr("psraw $1, %xmm0\n"
2100 "psraw $2, %xmm15\n", "psrawi");
2101 }
2102
TEST_F(AssemblerX86_64Test,Psrad)2103 TEST_F(AssemblerX86_64Test, Psrad) {
2104 GetAssembler()->psrad(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2105 GetAssembler()->psrad(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2106 DriverStr("psrad $1, %xmm0\n"
2107 "psrad $2, %xmm15\n", "psradi");
2108 }
2109
TEST_F(AssemblerX86_64Test,Psrlw)2110 TEST_F(AssemblerX86_64Test, Psrlw) {
2111 GetAssembler()->psrlw(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2112 GetAssembler()->psrlw(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2113 DriverStr("psrlw $1, %xmm0\n"
2114 "psrlw $2, %xmm15\n", "psrlwi");
2115 }
2116
TEST_F(AssemblerX86_64Test,Psrld)2117 TEST_F(AssemblerX86_64Test, Psrld) {
2118 GetAssembler()->psrld(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2119 GetAssembler()->psrld(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2120 DriverStr("psrld $1, %xmm0\n"
2121 "psrld $2, %xmm15\n", "psrldi");
2122 }
2123
TEST_F(AssemblerX86_64Test,Psrlq)2124 TEST_F(AssemblerX86_64Test, Psrlq) {
2125 GetAssembler()->psrlq(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2126 GetAssembler()->psrlq(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2127 DriverStr("psrlq $1, %xmm0\n"
2128 "psrlq $2, %xmm15\n", "psrlqi");
2129 }
2130
TEST_F(AssemblerX86_64Test,Psrldq)2131 TEST_F(AssemblerX86_64Test, Psrldq) {
2132 GetAssembler()->psrldq(x86_64::XmmRegister(x86_64::XMM0), x86_64::Immediate(1));
2133 GetAssembler()->psrldq(x86_64::XmmRegister(x86_64::XMM15), x86_64::Immediate(2));
2134 DriverStr("psrldq $1, %xmm0\n"
2135 "psrldq $2, %xmm15\n", "psrldqi");
2136 }
2137
x87_fn(AssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64Assembler * assembler)2138 std::string x87_fn(AssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2139 x86_64::X86_64Assembler* assembler) {
2140 std::ostringstream str;
2141
2142 assembler->fincstp();
2143 str << "fincstp\n";
2144
2145 assembler->fsin();
2146 str << "fsin\n";
2147
2148 assembler->fcos();
2149 str << "fcos\n";
2150
2151 assembler->fptan();
2152 str << "fptan\n";
2153
2154 return str.str();
2155 }
2156
TEST_F(AssemblerX86_64Test,X87)2157 TEST_F(AssemblerX86_64Test, X87) {
2158 DriverFn(&x87_fn, "x87");
2159 }
2160
TEST_F(AssemblerX86_64Test,FPUIntegerLoads)2161 TEST_F(AssemblerX86_64Test, FPUIntegerLoads) {
2162 DriverStr(RepeatA(&x86_64::X86_64Assembler::filds,
2163 addresses_singleton_, // no ext addressing
2164 "fildl {mem}"), "filds");
2165 }
2166
TEST_F(AssemblerX86_64Test,FPUIntegerLoadl)2167 TEST_F(AssemblerX86_64Test, FPUIntegerLoadl) {
2168 DriverStr(RepeatA(&x86_64::X86_64Assembler::fildl,
2169 addresses_singleton_, // no ext addressing
2170 "fildll {mem}"), "fildl");
2171 }
2172
TEST_F(AssemblerX86_64Test,FPUIntegerStores)2173 TEST_F(AssemblerX86_64Test, FPUIntegerStores) {
2174 DriverStr(RepeatA(&x86_64::X86_64Assembler::fistps,
2175 addresses_singleton_, // no ext addressing
2176 "fistpl {mem}"), "fistps");
2177 }
2178
TEST_F(AssemblerX86_64Test,FPUIntegerStorel)2179 TEST_F(AssemblerX86_64Test, FPUIntegerStorel) {
2180 DriverStr(RepeatA(&x86_64::X86_64Assembler::fistpl,
2181 addresses_singleton_, // no ext addressing
2182 "fistpll {mem}"), "fistpl");
2183 }
2184
TEST_F(AssemblerX86_64Test,Call)2185 TEST_F(AssemblerX86_64Test, Call) {
2186 DriverStr(RepeatR(&x86_64::X86_64Assembler::call, "call *%{reg}"), "call");
2187 }
2188
TEST_F(AssemblerX86_64Test,Jmp)2189 TEST_F(AssemblerX86_64Test, Jmp) {
2190 DriverStr(RepeatR(&x86_64::X86_64Assembler::jmp, "jmp *%{reg}"), "jmp");
2191 }
2192
TEST_F(AssemblerX86_64Test,Enter)2193 TEST_F(AssemblerX86_64Test, Enter) {
2194 DriverStr(RepeatI(&x86_64::X86_64Assembler::enter,
2195 /*imm_bytes*/ 2U,
2196 "enter ${imm}, $0", /*non-negative*/ true), "enter");
2197 }
2198
TEST_F(AssemblerX86_64Test,RetImm)2199 TEST_F(AssemblerX86_64Test, RetImm) {
2200 DriverStr(RepeatI(&x86_64::X86_64Assembler::ret,
2201 /*imm_bytes*/ 2U,
2202 "ret ${imm}", /*non-negative*/ true), "ret");
2203 }
2204
ret_and_leave_fn(AssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64Assembler * assembler)2205 std::string ret_and_leave_fn(AssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2206 x86_64::X86_64Assembler* assembler) {
2207 std::ostringstream str;
2208
2209 assembler->ret();
2210 str << "ret\n";
2211
2212 assembler->leave();
2213 str << "leave\n";
2214
2215 return str.str();
2216 }
2217
TEST_F(AssemblerX86_64Test,RetAndLeave)2218 TEST_F(AssemblerX86_64Test, RetAndLeave) {
2219 DriverFn(&ret_and_leave_fn, "retleave");
2220 }
2221
TEST_F(AssemblerX86_64Test,Blsmask)2222 TEST_F(AssemblerX86_64Test, Blsmask) {
2223 DriverStr(RepeatRR(&x86_64::X86_64Assembler::blsmsk, "blsmsk %{reg2}, %{reg1}"), "blsmsk");
2224 }
2225
TEST_F(AssemblerX86_64Test,Blsi)2226 TEST_F(AssemblerX86_64Test, Blsi) {
2227 DriverStr(RepeatRR(&x86_64::X86_64Assembler::blsi, "blsi %{reg2}, %{reg1}"), "blsi");
2228 }
2229
TEST_F(AssemblerX86_64Test,Blsr)2230 TEST_F(AssemblerX86_64Test, Blsr) {
2231 DriverStr(RepeatRR(&x86_64::X86_64Assembler::blsr, "blsr %{reg2}, %{reg1}"), "blsr");
2232 }
2233
TEST_F(AssemblerX86_64Test,Bswapl)2234 TEST_F(AssemblerX86_64Test, Bswapl) {
2235 DriverStr(Repeatr(&x86_64::X86_64Assembler::bswapl, "bswap %{reg}"), "bswapl");
2236 }
2237
TEST_F(AssemblerX86_64Test,Bswapq)2238 TEST_F(AssemblerX86_64Test, Bswapq) {
2239 DriverStr(RepeatR(&x86_64::X86_64Assembler::bswapq, "bswap %{reg}"), "bswapq");
2240 }
2241
TEST_F(AssemblerX86_64Test,Bsfl)2242 TEST_F(AssemblerX86_64Test, Bsfl) {
2243 DriverStr(Repeatrr(&x86_64::X86_64Assembler::bsfl, "bsfl %{reg2}, %{reg1}"), "bsfl");
2244 }
2245
TEST_F(AssemblerX86_64Test,BsflAddress)2246 TEST_F(AssemblerX86_64Test, BsflAddress) {
2247 DriverStr(RepeatrA(&x86_64::X86_64Assembler::bsfl, "bsfl {mem}, %{reg}"), "bsfl_address");
2248 }
2249
TEST_F(AssemblerX86_64Test,Bsfq)2250 TEST_F(AssemblerX86_64Test, Bsfq) {
2251 DriverStr(RepeatRR(&x86_64::X86_64Assembler::bsfq, "bsfq %{reg2}, %{reg1}"), "bsfq");
2252 }
2253
TEST_F(AssemblerX86_64Test,BsfqAddress)2254 TEST_F(AssemblerX86_64Test, BsfqAddress) {
2255 DriverStr(RepeatRA(&x86_64::X86_64Assembler::bsfq, "bsfq {mem}, %{reg}"), "bsfq_address");
2256 }
2257
TEST_F(AssemblerX86_64Test,Bsrl)2258 TEST_F(AssemblerX86_64Test, Bsrl) {
2259 DriverStr(Repeatrr(&x86_64::X86_64Assembler::bsrl, "bsrl %{reg2}, %{reg1}"), "bsrl");
2260 }
2261
TEST_F(AssemblerX86_64Test,BsrlAddress)2262 TEST_F(AssemblerX86_64Test, BsrlAddress) {
2263 DriverStr(RepeatrA(&x86_64::X86_64Assembler::bsrl, "bsrl {mem}, %{reg}"), "bsrl_address");
2264 }
2265
TEST_F(AssemblerX86_64Test,Bsrq)2266 TEST_F(AssemblerX86_64Test, Bsrq) {
2267 DriverStr(RepeatRR(&x86_64::X86_64Assembler::bsrq, "bsrq %{reg2}, %{reg1}"), "bsrq");
2268 }
2269
TEST_F(AssemblerX86_64Test,BsrqAddress)2270 TEST_F(AssemblerX86_64Test, BsrqAddress) {
2271 DriverStr(RepeatRA(&x86_64::X86_64Assembler::bsrq, "bsrq {mem}, %{reg}"), "bsrq_address");
2272 }
2273
TEST_F(AssemblerX86_64Test,Popcntl)2274 TEST_F(AssemblerX86_64Test, Popcntl) {
2275 DriverStr(Repeatrr(&x86_64::X86_64Assembler::popcntl, "popcntl %{reg2}, %{reg1}"), "popcntl");
2276 }
2277
TEST_F(AssemblerX86_64Test,PopcntlAddress)2278 TEST_F(AssemblerX86_64Test, PopcntlAddress) {
2279 DriverStr(RepeatrA(&x86_64::X86_64Assembler::popcntl, "popcntl {mem}, %{reg}"), "popcntl_address");
2280 }
2281
TEST_F(AssemblerX86_64Test,Popcntq)2282 TEST_F(AssemblerX86_64Test, Popcntq) {
2283 DriverStr(RepeatRR(&x86_64::X86_64Assembler::popcntq, "popcntq %{reg2}, %{reg1}"), "popcntq");
2284 }
2285
TEST_F(AssemblerX86_64Test,PopcntqAddress)2286 TEST_F(AssemblerX86_64Test, PopcntqAddress) {
2287 DriverStr(RepeatRA(&x86_64::X86_64Assembler::popcntq, "popcntq {mem}, %{reg}"), "popcntq_address");
2288 }
2289
TEST_F(AssemblerX86_64Test,CmovlAddress)2290 TEST_F(AssemblerX86_64Test, CmovlAddress) {
2291 GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::R10), x86_64::Address(
2292 x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::RBX), TIMES_4, 12), false);
2293 GetAssembler()->cmov(x86_64::kNotEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
2294 x86_64::CpuRegister(x86_64::R10), x86_64::CpuRegister(x86_64::RBX), TIMES_4, 12), false);
2295 GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
2296 x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::R9), TIMES_4, 12), false);
2297 const char* expected =
2298 "cmovzl 0xc(%RDI,%RBX,4), %R10d\n"
2299 "cmovnzl 0xc(%R10,%RBX,4), %edi\n"
2300 "cmovzl 0xc(%RDI,%R9,4), %edi\n";
2301 DriverStr(expected, "cmovl_address");
2302 }
2303
TEST_F(AssemblerX86_64Test,CmovqAddress)2304 TEST_F(AssemblerX86_64Test, CmovqAddress) {
2305 GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::R10), x86_64::Address(
2306 x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::RBX), TIMES_4, 12), true);
2307 GetAssembler()->cmov(x86_64::kNotEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
2308 x86_64::CpuRegister(x86_64::R10), x86_64::CpuRegister(x86_64::RBX), TIMES_4, 12), true);
2309 GetAssembler()->cmov(x86_64::kEqual, x86_64::CpuRegister(x86_64::RDI), x86_64::Address(
2310 x86_64::CpuRegister(x86_64::RDI), x86_64::CpuRegister(x86_64::R9), TIMES_4, 12), true);
2311 const char* expected =
2312 "cmovzq 0xc(%RDI,%RBX,4), %R10\n"
2313 "cmovnzq 0xc(%R10,%RBX,4), %rdi\n"
2314 "cmovzq 0xc(%RDI,%R9,4), %rdi\n";
2315 DriverStr(expected, "cmovq_address");
2316 }
2317
TEST_F(AssemblerX86_64Test,Jrcxz)2318 TEST_F(AssemblerX86_64Test, Jrcxz) {
2319 x86_64::NearLabel target;
2320 GetAssembler()->jrcxz(&target);
2321 GetAssembler()->addl(x86_64::CpuRegister(x86_64::RDI),
2322 x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 4));
2323 GetAssembler()->Bind(&target);
2324 const char* expected =
2325 "jrcxz 1f\n"
2326 "addl 4(%RSP),%EDI\n"
2327 "1:\n";
2328
2329 DriverStr(expected, "jrcxz");
2330 }
2331
TEST_F(AssemblerX86_64Test,NearLabel)2332 TEST_F(AssemblerX86_64Test, NearLabel) {
2333 // Test both forward and backward branches.
2334 x86_64::NearLabel start, target;
2335 GetAssembler()->Bind(&start);
2336 GetAssembler()->j(x86_64::kEqual, &target);
2337 GetAssembler()->jmp(&target);
2338 GetAssembler()->jrcxz(&target);
2339 GetAssembler()->addl(x86_64::CpuRegister(x86_64::RDI),
2340 x86_64::Address(x86_64::CpuRegister(x86_64::RSP), 4));
2341 GetAssembler()->Bind(&target);
2342 GetAssembler()->j(x86_64::kNotEqual, &start);
2343 GetAssembler()->jmp(&start);
2344 const char* expected =
2345 "1: je 2f\n"
2346 "jmp 2f\n"
2347 "jrcxz 2f\n"
2348 "addl 4(%RSP),%EDI\n"
2349 "2: jne 1b\n"
2350 "jmp 1b\n";
2351
2352 DriverStr(expected, "near_label");
2353 }
2354
setcc_test_fn(AssemblerX86_64Test::Base * assembler_test,x86_64::X86_64Assembler * assembler)2355 std::string setcc_test_fn(AssemblerX86_64Test::Base* assembler_test,
2356 x86_64::X86_64Assembler* assembler) {
2357 // From Condition
2358 /*
2359 kOverflow = 0,
2360 kNoOverflow = 1,
2361 kBelow = 2,
2362 kAboveEqual = 3,
2363 kEqual = 4,
2364 kNotEqual = 5,
2365 kBelowEqual = 6,
2366 kAbove = 7,
2367 kSign = 8,
2368 kNotSign = 9,
2369 kParityEven = 10,
2370 kParityOdd = 11,
2371 kLess = 12,
2372 kGreaterEqual = 13,
2373 kLessEqual = 14,
2374 */
2375 std::string suffixes[15] = { "o", "no", "b", "ae", "e", "ne", "be", "a", "s", "ns", "pe", "po",
2376 "l", "ge", "le" };
2377
2378 std::vector<x86_64::CpuRegister*> registers = assembler_test->GetRegisters();
2379 std::ostringstream str;
2380
2381 for (auto reg : registers) {
2382 for (size_t i = 0; i < 15; ++i) {
2383 assembler->setcc(static_cast<x86_64::Condition>(i), *reg);
2384 str << "set" << suffixes[i] << " %" << assembler_test->GetQuaternaryRegisterName(*reg) << "\n";
2385 }
2386 }
2387
2388 return str.str();
2389 }
2390
TEST_F(AssemblerX86_64Test,SetCC)2391 TEST_F(AssemblerX86_64Test, SetCC) {
2392 DriverFn(&setcc_test_fn, "setcc");
2393 }
2394
TEST_F(AssemblerX86_64Test,MovzxbRegs)2395 TEST_F(AssemblerX86_64Test, MovzxbRegs) {
2396 DriverStr(Repeatrb(&x86_64::X86_64Assembler::movzxb, "movzbl %{reg2}, %{reg1}"), "movzxb");
2397 }
2398
TEST_F(AssemblerX86_64Test,MovsxbRegs)2399 TEST_F(AssemblerX86_64Test, MovsxbRegs) {
2400 DriverStr(Repeatrb(&x86_64::X86_64Assembler::movsxb, "movsbl %{reg2}, %{reg1}"), "movsxb");
2401 }
2402
TEST_F(AssemblerX86_64Test,Repnescasw)2403 TEST_F(AssemblerX86_64Test, Repnescasw) {
2404 GetAssembler()->repne_scasw();
2405 const char* expected = "repne scasw\n";
2406 DriverStr(expected, "Repnescasw");
2407 }
2408
TEST_F(AssemblerX86_64Test,Repecmpsw)2409 TEST_F(AssemblerX86_64Test, Repecmpsw) {
2410 GetAssembler()->repe_cmpsw();
2411 const char* expected = "repe cmpsw\n";
2412 DriverStr(expected, "Repecmpsw");
2413 }
2414
TEST_F(AssemblerX86_64Test,Repecmpsl)2415 TEST_F(AssemblerX86_64Test, Repecmpsl) {
2416 GetAssembler()->repe_cmpsl();
2417 const char* expected = "repe cmpsl\n";
2418 DriverStr(expected, "Repecmpsl");
2419 }
2420
TEST_F(AssemblerX86_64Test,Repecmpsq)2421 TEST_F(AssemblerX86_64Test, Repecmpsq) {
2422 GetAssembler()->repe_cmpsq();
2423 const char* expected = "repe cmpsq\n";
2424 DriverStr(expected, "Repecmpsq");
2425 }
2426
TEST_F(AssemblerX86_64Test,Ud2)2427 TEST_F(AssemblerX86_64Test, Ud2) {
2428 GetAssembler()->ud2();
2429 const char* expected = "ud2\n";
2430 DriverStr(expected, "Ud2");
2431 }
2432
TEST_F(AssemblerX86_64Test,Cmpb)2433 TEST_F(AssemblerX86_64Test, Cmpb) {
2434 DriverStr(RepeatAI(&x86_64::X86_64Assembler::cmpb,
2435 /*imm_bytes*/ 1U,
2436 "cmpb ${imm}, {mem}"), "cmpb");
2437 }
2438
TEST_F(AssemblerX86_64Test,TestbAddressImmediate)2439 TEST_F(AssemblerX86_64Test, TestbAddressImmediate) {
2440 DriverStr(RepeatAI(&x86_64::X86_64Assembler::testb,
2441 /*imm_bytes*/ 1U,
2442 "testb ${imm}, {mem}"), "testbi");
2443 }
2444
TEST_F(AssemblerX86_64Test,TestlAddressImmediate)2445 TEST_F(AssemblerX86_64Test, TestlAddressImmediate) {
2446 DriverStr(RepeatAI(&x86_64::X86_64Assembler::testl,
2447 /*imm_bytes*/ 4U,
2448 "testl ${imm}, {mem}"), "testli");
2449 }
2450
2451 // Test that displacing an existing address is the same as constructing a new one with the same
2452 // initial displacement.
TEST_F(AssemblerX86_64Test,AddressDisplaceBy)2453 TEST_F(AssemblerX86_64Test, AddressDisplaceBy) {
2454 // Test different displacements, including some 8-bit and 32-bit ones, so that changing
2455 // displacement may require a different addressing mode.
2456 static const std::vector<int32_t> displacements = {0, 42, -42, 140, -140};
2457 // Test with all scale factors.
2458 static const std::vector<ScaleFactor> scales = {TIMES_1, TIMES_2, TIMES_4, TIMES_8};
2459
2460 for (int32_t disp0 : displacements) { // initial displacement
2461 for (int32_t disp : displacements) { // extra displacement
2462 for (const x86_64::CpuRegister* reg : GetRegisters()) {
2463 // Test non-SIB addressing.
2464 EXPECT_EQ(x86_64::Address::displace(x86_64::Address(*reg, disp0), disp),
2465 x86_64::Address(*reg, disp0 + disp));
2466
2467 // Test SIB addressing with RBP base.
2468 if (reg->AsRegister() != x86_64::RSP) {
2469 for (ScaleFactor scale : scales) {
2470 EXPECT_EQ(x86_64::Address::displace(x86_64::Address(*reg, scale, disp0), disp),
2471 x86_64::Address(*reg, scale, disp0 + disp));
2472 }
2473 }
2474
2475 // Test SIB addressing with different base.
2476 for (const x86_64::CpuRegister* index : GetRegisters()) {
2477 if (index->AsRegister() == x86_64::RSP) {
2478 continue; // Skip RSP as it cannot be used with this address constructor.
2479 }
2480 for (ScaleFactor scale : scales) {
2481 EXPECT_EQ(x86_64::Address::displace(x86_64::Address(*reg, *index, scale, disp0), disp),
2482 x86_64::Address(*reg, *index, scale, disp0 + disp));
2483 }
2484 }
2485
2486 // Test absolute and RIP-relative addressing.
2487 EXPECT_EQ(x86_64::Address::displace(x86_64::Address::Absolute(disp0, false), disp),
2488 x86_64::Address::Absolute(disp0 + disp, false));
2489 EXPECT_EQ(x86_64::Address::displace(x86_64::Address::Absolute(disp0, true), disp),
2490 x86_64::Address::Absolute(disp0 + disp, true));
2491 }
2492 }
2493 }
2494 }
2495
2496 class JNIMacroAssemblerX86_64Test : public JNIMacroAssemblerTest<x86_64::X86_64JNIMacroAssembler> {
2497 public:
2498 using Base = JNIMacroAssemblerTest<x86_64::X86_64JNIMacroAssembler>;
2499
2500 protected:
GetIsa()2501 InstructionSet GetIsa() override {
2502 return InstructionSet::kX86_64;
2503 }
2504
2505 private:
2506 };
2507
ManagedFromCpu(x86_64::Register r)2508 static x86_64::X86_64ManagedRegister ManagedFromCpu(x86_64::Register r) {
2509 return x86_64::X86_64ManagedRegister::FromCpuRegister(r);
2510 }
2511
ManagedFromFpu(x86_64::FloatRegister r)2512 static x86_64::X86_64ManagedRegister ManagedFromFpu(x86_64::FloatRegister r) {
2513 return x86_64::X86_64ManagedRegister::FromXmmRegister(r);
2514 }
2515
buildframe_test_fn(JNIMacroAssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64JNIMacroAssembler * assembler)2516 std::string buildframe_test_fn(JNIMacroAssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2517 x86_64::X86_64JNIMacroAssembler* assembler) {
2518 // TODO: more interesting spill registers / entry spills.
2519
2520 // Two random spill regs.
2521 const ManagedRegister raw_spill_regs[] = {
2522 ManagedFromCpu(x86_64::R10),
2523 ManagedFromCpu(x86_64::RSI)
2524 };
2525 ArrayRef<const ManagedRegister> spill_regs(raw_spill_regs);
2526
2527 x86_64::X86_64ManagedRegister method_reg = ManagedFromCpu(x86_64::RDI);
2528
2529 size_t frame_size = 10 * kStackAlignment;
2530 assembler->BuildFrame(frame_size, method_reg, spill_regs);
2531
2532 // Three random entry spills.
2533 assembler->Store(FrameOffset(frame_size + 0u), ManagedFromCpu(x86_64::RAX), /* size= */ 8u);
2534 assembler->Store(FrameOffset(frame_size + 8u), ManagedFromCpu(x86_64::RBX), /* size= */ 8u);
2535 assembler->Store(FrameOffset(frame_size + 16u), ManagedFromFpu(x86_64::XMM1), /* size= */ 8u);
2536
2537 // Construct assembly text counterpart.
2538 std::ostringstream str;
2539 // (1) Push the spill_regs.
2540 str << "pushq %rsi\n";
2541 str << "pushq %r10\n";
2542 // (2) Move down the stack pointer.
2543 ssize_t displacement = static_cast<ssize_t>(frame_size) - (spill_regs.size() * 8 + 8);
2544 str << "subq $" << displacement << ", %rsp\n";
2545 // (3) Store method reference.
2546 str << "movq %rdi, (%rsp)\n";
2547 // (4) Entry spills.
2548 str << "movq %rax, " << frame_size + 0 << "(%rsp)\n";
2549 str << "movq %rbx, " << frame_size + 8 << "(%rsp)\n";
2550 str << "movsd %xmm1, " << frame_size + 16 << "(%rsp)\n";
2551
2552 return str.str();
2553 }
2554
TEST_F(JNIMacroAssemblerX86_64Test,BuildFrame)2555 TEST_F(JNIMacroAssemblerX86_64Test, BuildFrame) {
2556 DriverFn(&buildframe_test_fn, "BuildFrame");
2557 }
2558
removeframe_test_fn(JNIMacroAssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64JNIMacroAssembler * assembler)2559 std::string removeframe_test_fn(JNIMacroAssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2560 x86_64::X86_64JNIMacroAssembler* assembler) {
2561 // TODO: more interesting spill registers / entry spills.
2562
2563 // Two random spill regs.
2564 const ManagedRegister raw_spill_regs[] = {
2565 ManagedFromCpu(x86_64::R10),
2566 ManagedFromCpu(x86_64::RSI)
2567 };
2568 ArrayRef<const ManagedRegister> spill_regs(raw_spill_regs);
2569
2570 size_t frame_size = 10 * kStackAlignment;
2571 assembler->RemoveFrame(frame_size, spill_regs, /* may_suspend= */ true);
2572
2573 // Construct assembly text counterpart.
2574 std::ostringstream str;
2575 // (1) Move up the stack pointer.
2576 ssize_t displacement = static_cast<ssize_t>(frame_size) - spill_regs.size() * 8 - 8;
2577 str << "addq $" << displacement << ", %rsp\n";
2578 // (2) Pop spill regs.
2579 str << "popq %r10\n";
2580 str << "popq %rsi\n";
2581 str << "ret\n";
2582
2583 return str.str();
2584 }
2585
TEST_F(JNIMacroAssemblerX86_64Test,RemoveFrame)2586 TEST_F(JNIMacroAssemblerX86_64Test, RemoveFrame) {
2587 DriverFn(&removeframe_test_fn, "RemoveFrame");
2588 }
2589
increaseframe_test_fn(JNIMacroAssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64JNIMacroAssembler * assembler)2590 std::string increaseframe_test_fn(
2591 JNIMacroAssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2592 x86_64::X86_64JNIMacroAssembler* assembler) {
2593 assembler->IncreaseFrameSize(0U);
2594 assembler->IncreaseFrameSize(kStackAlignment);
2595 assembler->IncreaseFrameSize(10 * kStackAlignment);
2596
2597 // Construct assembly text counterpart.
2598 std::ostringstream str;
2599 // Increase by 0 is a NO-OP and ignored by the assembler.
2600 str << "addq $-" << kStackAlignment << ", %rsp\n";
2601 str << "addq $-" << 10 * kStackAlignment << ", %rsp\n";
2602
2603 return str.str();
2604 }
2605
TEST_F(JNIMacroAssemblerX86_64Test,IncreaseFrame)2606 TEST_F(JNIMacroAssemblerX86_64Test, IncreaseFrame) {
2607 DriverFn(&increaseframe_test_fn, "IncreaseFrame");
2608 }
2609
decreaseframe_test_fn(JNIMacroAssemblerX86_64Test::Base * assembler_test ATTRIBUTE_UNUSED,x86_64::X86_64JNIMacroAssembler * assembler)2610 std::string decreaseframe_test_fn(
2611 JNIMacroAssemblerX86_64Test::Base* assembler_test ATTRIBUTE_UNUSED,
2612 x86_64::X86_64JNIMacroAssembler* assembler) {
2613 assembler->DecreaseFrameSize(0U);
2614 assembler->DecreaseFrameSize(kStackAlignment);
2615 assembler->DecreaseFrameSize(10 * kStackAlignment);
2616
2617 // Construct assembly text counterpart.
2618 std::ostringstream str;
2619 // Decrease by 0 is a NO-OP and ignored by the assembler.
2620 str << "addq $" << kStackAlignment << ", %rsp\n";
2621 str << "addq $" << 10 * kStackAlignment << ", %rsp\n";
2622
2623 return str.str();
2624 }
2625
TEST_F(JNIMacroAssemblerX86_64Test,DecreaseFrame)2626 TEST_F(JNIMacroAssemblerX86_64Test, DecreaseFrame) {
2627 DriverFn(&decreaseframe_test_fn, "DecreaseFrame");
2628 }
2629
2630 } // namespace art
2631