1 /*
2  * Copyright (C) 2016 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_mips.h"
18 
19 #include <map>
20 
21 #include "base/stl_util.h"
22 #include "utils/assembler_test.h"
23 
24 #define __ GetAssembler()->
25 
26 namespace art {
27 
28 struct MIPSCpuRegisterCompare {
operator ()art::MIPSCpuRegisterCompare29   bool operator()(const mips::Register& a, const mips::Register& b) const {
30     return a < b;
31   }
32 };
33 
34 class AssemblerMIPS32r6Test : public AssemblerTest<mips::MipsAssembler,
35                                                    mips::MipsLabel,
36                                                    mips::Register,
37                                                    mips::FRegister,
38                                                    uint32_t,
39                                                    mips::VectorRegister> {
40  public:
41   using Base = AssemblerTest<mips::MipsAssembler,
42                              mips::MipsLabel,
43                              mips::Register,
44                              mips::FRegister,
45                              uint32_t,
46                              mips::VectorRegister>;
47 
48   // These tests were taking too long, so we hide the DriverStr() from AssemblerTest<>
49   // and reimplement it without the verification against `assembly_string`. b/73903608
DriverStr(const std::string & assembly_string ATTRIBUTE_UNUSED,const std::string & test_name ATTRIBUTE_UNUSED)50   void DriverStr(const std::string& assembly_string ATTRIBUTE_UNUSED,
51                  const std::string& test_name ATTRIBUTE_UNUSED) {
52     GetAssembler()->FinalizeCode();
53     std::vector<uint8_t> data(GetAssembler()->CodeSize());
54     MemoryRegion code(data.data(), data.size());
55     GetAssembler()->FinalizeInstructions(code);
56   }
57 
AssemblerMIPS32r6Test()58   AssemblerMIPS32r6Test() :
59     instruction_set_features_(MipsInstructionSetFeatures::FromVariant("mips32r6", nullptr)) {
60   }
61 
62  protected:
63   // Get the typically used name for this architecture, e.g., aarch64, x86-64, ...
GetArchitectureString()64   std::string GetArchitectureString() override {
65     return "mips";
66   }
67 
GetAssemblerCmdName()68   std::string GetAssemblerCmdName() override {
69     // We assemble and link for MIPS32R6. See GetAssemblerParameters() for details.
70     return "gcc";
71   }
72 
GetAssemblerParameters()73   std::string GetAssemblerParameters() override {
74     // We assemble and link for MIPS32R6. The reason is that object files produced for MIPS32R6
75     // (and MIPS64R6) with the GNU assembler don't have correct final offsets in PC-relative
76     // branches in the .text section and so they require a relocation pass (there's a relocation
77     // section, .rela.text, that has the needed info to fix up the branches).
78     // We use "-modd-spreg" so we can use odd-numbered single precision FPU registers.
79     // We put the code at address 0x1000000 (instead of 0) to avoid overlapping with the
80     // .MIPS.abiflags section (there doesn't seem to be a way to suppress its generation easily).
81     return " -march=mips32r6 -mmsa -modd-spreg -Wa,--no-warn"
82         " -Wl,-Ttext=0x1000000 -Wl,-e0x1000000 -nostdlib";
83   }
84 
Pad(std::vector<uint8_t> & data)85   void Pad(std::vector<uint8_t>& data) override {
86     // The GNU linker unconditionally pads the code segment with NOPs to a size that is a multiple
87     // of 16 and there doesn't appear to be a way to suppress this padding. Our assembler doesn't
88     // pad, so, in order for two assembler outputs to match, we need to match the padding as well.
89     // NOP is encoded as four zero bytes on MIPS.
90     size_t pad_size = RoundUp(data.size(), 16u) - data.size();
91     data.insert(data.end(), pad_size, 0);
92   }
93 
GetDisassembleParameters()94   std::string GetDisassembleParameters() override {
95     return " -D -bbinary -mmips:isa32r6";
96   }
97 
CreateAssembler(ArenaAllocator * allocator)98   mips::MipsAssembler* CreateAssembler(ArenaAllocator* allocator) override {
99     return new (allocator) mips::MipsAssembler(allocator, instruction_set_features_.get());
100   }
101 
SetUpHelpers()102   void SetUpHelpers() override {
103     if (registers_.size() == 0) {
104       registers_.push_back(new mips::Register(mips::ZERO));
105       registers_.push_back(new mips::Register(mips::AT));
106       registers_.push_back(new mips::Register(mips::V0));
107       registers_.push_back(new mips::Register(mips::V1));
108       registers_.push_back(new mips::Register(mips::A0));
109       registers_.push_back(new mips::Register(mips::A1));
110       registers_.push_back(new mips::Register(mips::A2));
111       registers_.push_back(new mips::Register(mips::A3));
112       registers_.push_back(new mips::Register(mips::T0));
113       registers_.push_back(new mips::Register(mips::T1));
114       registers_.push_back(new mips::Register(mips::T2));
115       registers_.push_back(new mips::Register(mips::T3));
116       registers_.push_back(new mips::Register(mips::T4));
117       registers_.push_back(new mips::Register(mips::T5));
118       registers_.push_back(new mips::Register(mips::T6));
119       registers_.push_back(new mips::Register(mips::T7));
120       registers_.push_back(new mips::Register(mips::S0));
121       registers_.push_back(new mips::Register(mips::S1));
122       registers_.push_back(new mips::Register(mips::S2));
123       registers_.push_back(new mips::Register(mips::S3));
124       registers_.push_back(new mips::Register(mips::S4));
125       registers_.push_back(new mips::Register(mips::S5));
126       registers_.push_back(new mips::Register(mips::S6));
127       registers_.push_back(new mips::Register(mips::S7));
128       registers_.push_back(new mips::Register(mips::T8));
129       registers_.push_back(new mips::Register(mips::T9));
130       registers_.push_back(new mips::Register(mips::K0));
131       registers_.push_back(new mips::Register(mips::K1));
132       registers_.push_back(new mips::Register(mips::GP));
133       registers_.push_back(new mips::Register(mips::SP));
134       registers_.push_back(new mips::Register(mips::FP));
135       registers_.push_back(new mips::Register(mips::RA));
136 
137       secondary_register_names_.emplace(mips::Register(mips::ZERO), "zero");
138       secondary_register_names_.emplace(mips::Register(mips::AT), "at");
139       secondary_register_names_.emplace(mips::Register(mips::V0), "v0");
140       secondary_register_names_.emplace(mips::Register(mips::V1), "v1");
141       secondary_register_names_.emplace(mips::Register(mips::A0), "a0");
142       secondary_register_names_.emplace(mips::Register(mips::A1), "a1");
143       secondary_register_names_.emplace(mips::Register(mips::A2), "a2");
144       secondary_register_names_.emplace(mips::Register(mips::A3), "a3");
145       secondary_register_names_.emplace(mips::Register(mips::T0), "t0");
146       secondary_register_names_.emplace(mips::Register(mips::T1), "t1");
147       secondary_register_names_.emplace(mips::Register(mips::T2), "t2");
148       secondary_register_names_.emplace(mips::Register(mips::T3), "t3");
149       secondary_register_names_.emplace(mips::Register(mips::T4), "t4");
150       secondary_register_names_.emplace(mips::Register(mips::T5), "t5");
151       secondary_register_names_.emplace(mips::Register(mips::T6), "t6");
152       secondary_register_names_.emplace(mips::Register(mips::T7), "t7");
153       secondary_register_names_.emplace(mips::Register(mips::S0), "s0");
154       secondary_register_names_.emplace(mips::Register(mips::S1), "s1");
155       secondary_register_names_.emplace(mips::Register(mips::S2), "s2");
156       secondary_register_names_.emplace(mips::Register(mips::S3), "s3");
157       secondary_register_names_.emplace(mips::Register(mips::S4), "s4");
158       secondary_register_names_.emplace(mips::Register(mips::S5), "s5");
159       secondary_register_names_.emplace(mips::Register(mips::S6), "s6");
160       secondary_register_names_.emplace(mips::Register(mips::S7), "s7");
161       secondary_register_names_.emplace(mips::Register(mips::T8), "t8");
162       secondary_register_names_.emplace(mips::Register(mips::T9), "t9");
163       secondary_register_names_.emplace(mips::Register(mips::K0), "k0");
164       secondary_register_names_.emplace(mips::Register(mips::K1), "k1");
165       secondary_register_names_.emplace(mips::Register(mips::GP), "gp");
166       secondary_register_names_.emplace(mips::Register(mips::SP), "sp");
167       secondary_register_names_.emplace(mips::Register(mips::FP), "fp");
168       secondary_register_names_.emplace(mips::Register(mips::RA), "ra");
169 
170       fp_registers_.push_back(new mips::FRegister(mips::F0));
171       fp_registers_.push_back(new mips::FRegister(mips::F1));
172       fp_registers_.push_back(new mips::FRegister(mips::F2));
173       fp_registers_.push_back(new mips::FRegister(mips::F3));
174       fp_registers_.push_back(new mips::FRegister(mips::F4));
175       fp_registers_.push_back(new mips::FRegister(mips::F5));
176       fp_registers_.push_back(new mips::FRegister(mips::F6));
177       fp_registers_.push_back(new mips::FRegister(mips::F7));
178       fp_registers_.push_back(new mips::FRegister(mips::F8));
179       fp_registers_.push_back(new mips::FRegister(mips::F9));
180       fp_registers_.push_back(new mips::FRegister(mips::F10));
181       fp_registers_.push_back(new mips::FRegister(mips::F11));
182       fp_registers_.push_back(new mips::FRegister(mips::F12));
183       fp_registers_.push_back(new mips::FRegister(mips::F13));
184       fp_registers_.push_back(new mips::FRegister(mips::F14));
185       fp_registers_.push_back(new mips::FRegister(mips::F15));
186       fp_registers_.push_back(new mips::FRegister(mips::F16));
187       fp_registers_.push_back(new mips::FRegister(mips::F17));
188       fp_registers_.push_back(new mips::FRegister(mips::F18));
189       fp_registers_.push_back(new mips::FRegister(mips::F19));
190       fp_registers_.push_back(new mips::FRegister(mips::F20));
191       fp_registers_.push_back(new mips::FRegister(mips::F21));
192       fp_registers_.push_back(new mips::FRegister(mips::F22));
193       fp_registers_.push_back(new mips::FRegister(mips::F23));
194       fp_registers_.push_back(new mips::FRegister(mips::F24));
195       fp_registers_.push_back(new mips::FRegister(mips::F25));
196       fp_registers_.push_back(new mips::FRegister(mips::F26));
197       fp_registers_.push_back(new mips::FRegister(mips::F27));
198       fp_registers_.push_back(new mips::FRegister(mips::F28));
199       fp_registers_.push_back(new mips::FRegister(mips::F29));
200       fp_registers_.push_back(new mips::FRegister(mips::F30));
201       fp_registers_.push_back(new mips::FRegister(mips::F31));
202 
203       vec_registers_.push_back(new mips::VectorRegister(mips::W0));
204       vec_registers_.push_back(new mips::VectorRegister(mips::W1));
205       vec_registers_.push_back(new mips::VectorRegister(mips::W2));
206       vec_registers_.push_back(new mips::VectorRegister(mips::W3));
207       vec_registers_.push_back(new mips::VectorRegister(mips::W4));
208       vec_registers_.push_back(new mips::VectorRegister(mips::W5));
209       vec_registers_.push_back(new mips::VectorRegister(mips::W6));
210       vec_registers_.push_back(new mips::VectorRegister(mips::W7));
211       vec_registers_.push_back(new mips::VectorRegister(mips::W8));
212       vec_registers_.push_back(new mips::VectorRegister(mips::W9));
213       vec_registers_.push_back(new mips::VectorRegister(mips::W10));
214       vec_registers_.push_back(new mips::VectorRegister(mips::W11));
215       vec_registers_.push_back(new mips::VectorRegister(mips::W12));
216       vec_registers_.push_back(new mips::VectorRegister(mips::W13));
217       vec_registers_.push_back(new mips::VectorRegister(mips::W14));
218       vec_registers_.push_back(new mips::VectorRegister(mips::W15));
219       vec_registers_.push_back(new mips::VectorRegister(mips::W16));
220       vec_registers_.push_back(new mips::VectorRegister(mips::W17));
221       vec_registers_.push_back(new mips::VectorRegister(mips::W18));
222       vec_registers_.push_back(new mips::VectorRegister(mips::W19));
223       vec_registers_.push_back(new mips::VectorRegister(mips::W20));
224       vec_registers_.push_back(new mips::VectorRegister(mips::W21));
225       vec_registers_.push_back(new mips::VectorRegister(mips::W22));
226       vec_registers_.push_back(new mips::VectorRegister(mips::W23));
227       vec_registers_.push_back(new mips::VectorRegister(mips::W24));
228       vec_registers_.push_back(new mips::VectorRegister(mips::W25));
229       vec_registers_.push_back(new mips::VectorRegister(mips::W26));
230       vec_registers_.push_back(new mips::VectorRegister(mips::W27));
231       vec_registers_.push_back(new mips::VectorRegister(mips::W28));
232       vec_registers_.push_back(new mips::VectorRegister(mips::W29));
233       vec_registers_.push_back(new mips::VectorRegister(mips::W30));
234       vec_registers_.push_back(new mips::VectorRegister(mips::W31));
235     }
236   }
237 
TearDown()238   void TearDown() override {
239     AssemblerTest::TearDown();
240     STLDeleteElements(&registers_);
241     STLDeleteElements(&fp_registers_);
242     STLDeleteElements(&vec_registers_);
243   }
244 
GetAddresses()245   std::vector<mips::MipsLabel> GetAddresses() override {
246     UNIMPLEMENTED(FATAL) << "Feature not implemented yet";
247     UNREACHABLE();
248   }
249 
GetRegisters()250   std::vector<mips::Register*> GetRegisters() override {
251     return registers_;
252   }
253 
GetFPRegisters()254   std::vector<mips::FRegister*> GetFPRegisters() override {
255     return fp_registers_;
256   }
257 
GetVectorRegisters()258   std::vector<mips::VectorRegister*> GetVectorRegisters() override {
259     return vec_registers_;
260   }
261 
CreateImmediate(int64_t imm_value)262   uint32_t CreateImmediate(int64_t imm_value) override {
263     return imm_value;
264   }
265 
GetSecondaryRegisterName(const mips::Register & reg)266   std::string GetSecondaryRegisterName(const mips::Register& reg) override {
267     CHECK(secondary_register_names_.find(reg) != secondary_register_names_.end());
268     return secondary_register_names_[reg];
269   }
270 
RepeatInsn(size_t count,const std::string & insn)271   std::string RepeatInsn(size_t count, const std::string& insn) {
272     std::string result;
273     for (; count != 0u; --count) {
274       result += insn;
275     }
276     return result;
277   }
278 
BranchHelper(void (mips::MipsAssembler::* f)(mips::MipsLabel *,bool),const std::string & instr_name,bool has_slot,bool is_bare=false)279   void BranchHelper(void (mips::MipsAssembler::*f)(mips::MipsLabel*,
280                                                    bool),
281                     const std::string& instr_name,
282                     bool has_slot,
283                     bool is_bare = false) {
284     __ SetReorder(false);
285     mips::MipsLabel label1, label2;
286     (Base::GetAssembler()->*f)(&label1, is_bare);
287     constexpr size_t kAdduCount1 = 63;
288     for (size_t i = 0; i != kAdduCount1; ++i) {
289       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
290     }
291     __ Bind(&label1);
292     (Base::GetAssembler()->*f)(&label2, is_bare);
293     constexpr size_t kAdduCount2 = 64;
294     for (size_t i = 0; i != kAdduCount2; ++i) {
295       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
296     }
297     __ Bind(&label2);
298     (Base::GetAssembler()->*f)(&label1, is_bare);
299     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
300 
301     std::string expected =
302         ".set noreorder\n" +
303         instr_name + " 1f\n" +
304         ((is_bare || !has_slot) ? "" : "nop\n") +
305         RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
306         "1:\n" +
307         instr_name + " 2f\n" +
308         ((is_bare || !has_slot) ? "" : "nop\n") +
309         RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
310         "2:\n" +
311         instr_name + " 1b\n" +
312         ((is_bare || !has_slot) ? "" : "nop\n") +
313         "addu $zero, $zero, $zero\n";
314     DriverStr(expected, instr_name);
315   }
316 
BranchCondOneRegHelper(void (mips::MipsAssembler::* f)(mips::Register,mips::MipsLabel *,bool),const std::string & instr_name,bool is_bare=false)317   void BranchCondOneRegHelper(void (mips::MipsAssembler::*f)(mips::Register,
318                                                              mips::MipsLabel*,
319                                                              bool),
320                               const std::string& instr_name,
321                               bool is_bare = false) {
322     __ SetReorder(false);
323     mips::MipsLabel label;
324     (Base::GetAssembler()->*f)(mips::A0, &label, is_bare);
325     constexpr size_t kAdduCount1 = 63;
326     for (size_t i = 0; i != kAdduCount1; ++i) {
327       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
328     }
329     __ Bind(&label);
330     constexpr size_t kAdduCount2 = 64;
331     for (size_t i = 0; i != kAdduCount2; ++i) {
332       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
333     }
334     (Base::GetAssembler()->*f)(mips::A1, &label, is_bare);
335     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
336 
337     std::string expected =
338         ".set noreorder\n" +
339         instr_name + " $a0, 1f\n" +
340         (is_bare ? "" : "nop\n") +
341         RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
342         "1:\n" +
343         RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
344         instr_name + " $a1, 1b\n" +
345         (is_bare ? "" : "nop\n") +
346         "addu $zero, $zero, $zero\n";
347     DriverStr(expected, instr_name);
348   }
349 
BranchCondTwoRegsHelper(void (mips::MipsAssembler::* f)(mips::Register,mips::Register,mips::MipsLabel *,bool),const std::string & instr_name,bool is_bare=false)350   void BranchCondTwoRegsHelper(void (mips::MipsAssembler::*f)(mips::Register,
351                                                               mips::Register,
352                                                               mips::MipsLabel*,
353                                                               bool),
354                                const std::string& instr_name,
355                                bool is_bare = false) {
356     __ SetReorder(false);
357     mips::MipsLabel label;
358     (Base::GetAssembler()->*f)(mips::A0, mips::A1, &label, is_bare);
359     constexpr size_t kAdduCount1 = 63;
360     for (size_t i = 0; i != kAdduCount1; ++i) {
361       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
362     }
363     __ Bind(&label);
364     constexpr size_t kAdduCount2 = 64;
365     for (size_t i = 0; i != kAdduCount2; ++i) {
366       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
367     }
368     (Base::GetAssembler()->*f)(mips::A2, mips::A3, &label, is_bare);
369     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
370 
371     std::string expected =
372         ".set noreorder\n" +
373         instr_name + " $a0, $a1, 1f\n" +
374         (is_bare ? "" : "nop\n") +
375         RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
376         "1:\n" +
377         RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
378         instr_name + " $a2, $a3, 1b\n" +
379         (is_bare ? "" : "nop\n") +
380         "addu $zero, $zero, $zero\n";
381     DriverStr(expected, instr_name);
382   }
383 
BranchFpuCondHelper(void (mips::MipsAssembler::* f)(mips::FRegister,mips::MipsLabel *,bool),const std::string & instr_name,bool is_bare=false)384   void BranchFpuCondHelper(void (mips::MipsAssembler::*f)(mips::FRegister,
385                                                           mips::MipsLabel*,
386                                                           bool),
387                            const std::string& instr_name,
388                            bool is_bare = false) {
389     __ SetReorder(false);
390     mips::MipsLabel label;
391     (Base::GetAssembler()->*f)(mips::F0, &label, is_bare);
392     constexpr size_t kAdduCount1 = 63;
393     for (size_t i = 0; i != kAdduCount1; ++i) {
394       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
395     }
396     __ Bind(&label);
397     constexpr size_t kAdduCount2 = 64;
398     for (size_t i = 0; i != kAdduCount2; ++i) {
399       __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
400     }
401     (Base::GetAssembler()->*f)(mips::F30, &label, is_bare);
402     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
403 
404     std::string expected =
405         ".set noreorder\n" +
406         instr_name + " $f0, 1f\n" +
407         (is_bare ? "" : "nop\n") +
408         RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
409         "1:\n" +
410         RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
411         instr_name + " $f30, 1b\n" +
412         (is_bare ? "" : "nop\n") +
413         "addu $zero, $zero, $zero\n";
414     DriverStr(expected, instr_name);
415   }
416 
417  private:
418   std::vector<mips::Register*> registers_;
419   std::map<mips::Register, std::string, MIPSCpuRegisterCompare> secondary_register_names_;
420 
421   std::vector<mips::FRegister*> fp_registers_;
422   std::vector<mips::VectorRegister*> vec_registers_;
423   std::unique_ptr<const MipsInstructionSetFeatures> instruction_set_features_;
424 };
425 
426 
TEST_F(AssemblerMIPS32r6Test,Toolchain)427 TEST_F(AssemblerMIPS32r6Test, Toolchain) {
428   EXPECT_TRUE(CheckTools());
429 }
430 
TEST_F(AssemblerMIPS32r6Test,MulR6)431 TEST_F(AssemblerMIPS32r6Test, MulR6) {
432   DriverStr(RepeatRRR(&mips::MipsAssembler::MulR6, "mul ${reg1}, ${reg2}, ${reg3}"), "MulR6");
433 }
434 
TEST_F(AssemblerMIPS32r6Test,MuhR6)435 TEST_F(AssemblerMIPS32r6Test, MuhR6) {
436   DriverStr(RepeatRRR(&mips::MipsAssembler::MuhR6, "muh ${reg1}, ${reg2}, ${reg3}"), "MuhR6");
437 }
438 
TEST_F(AssemblerMIPS32r6Test,MuhuR6)439 TEST_F(AssemblerMIPS32r6Test, MuhuR6) {
440   DriverStr(RepeatRRR(&mips::MipsAssembler::MuhuR6, "muhu ${reg1}, ${reg2}, ${reg3}"), "MuhuR6");
441 }
442 
TEST_F(AssemblerMIPS32r6Test,DivR6)443 TEST_F(AssemblerMIPS32r6Test, DivR6) {
444   DriverStr(RepeatRRR(&mips::MipsAssembler::DivR6, "div ${reg1}, ${reg2}, ${reg3}"), "DivR6");
445 }
446 
TEST_F(AssemblerMIPS32r6Test,ModR6)447 TEST_F(AssemblerMIPS32r6Test, ModR6) {
448   DriverStr(RepeatRRR(&mips::MipsAssembler::ModR6, "mod ${reg1}, ${reg2}, ${reg3}"), "ModR6");
449 }
450 
TEST_F(AssemblerMIPS32r6Test,DivuR6)451 TEST_F(AssemblerMIPS32r6Test, DivuR6) {
452   DriverStr(RepeatRRR(&mips::MipsAssembler::DivuR6, "divu ${reg1}, ${reg2}, ${reg3}"), "DivuR6");
453 }
454 
TEST_F(AssemblerMIPS32r6Test,ModuR6)455 TEST_F(AssemblerMIPS32r6Test, ModuR6) {
456   DriverStr(RepeatRRR(&mips::MipsAssembler::ModuR6, "modu ${reg1}, ${reg2}, ${reg3}"), "ModuR6");
457 }
458 
459 //////////
460 // MISC //
461 //////////
462 
TEST_F(AssemblerMIPS32r6Test,Aui)463 TEST_F(AssemblerMIPS32r6Test, Aui) {
464   DriverStr(RepeatRRIb(&mips::MipsAssembler::Aui, 16, "aui ${reg1}, ${reg2}, {imm}"), "Aui");
465 }
466 
TEST_F(AssemblerMIPS32r6Test,Auipc)467 TEST_F(AssemblerMIPS32r6Test, Auipc) {
468   DriverStr(RepeatRIb(&mips::MipsAssembler::Auipc, 16, "auipc ${reg}, {imm}"), "Auipc");
469 }
470 
TEST_F(AssemblerMIPS32r6Test,Lwpc)471 TEST_F(AssemblerMIPS32r6Test, Lwpc) {
472   // Lwpc() takes an unsigned 19-bit immediate, while the GNU assembler needs a signed offset,
473   // hence the sign extension from bit 18 with `imm - ((imm & 0x40000) << 1)`.
474   // The GNU assembler also wants the offset to be a multiple of 4, which it will shift right
475   // by 2 positions when encoding, hence `<< 2` to compensate for that shift.
476   // We capture the value of the immediate with `.set imm, {imm}` because the value is needed
477   // twice for the sign extension, but `{imm}` is substituted only once.
478   const char* code = ".set imm, {imm}\nlw ${reg}, ((imm - ((imm & 0x40000) << 1)) << 2)($pc)";
479   DriverStr(RepeatRIb(&mips::MipsAssembler::Lwpc, 19, code), "Lwpc");
480 }
481 
TEST_F(AssemblerMIPS32r6Test,Addiupc)482 TEST_F(AssemblerMIPS32r6Test, Addiupc) {
483   // The comment from the Lwpc() test applies to this Addiupc() test as well.
484   const char* code = ".set imm, {imm}\naddiupc ${reg}, (imm - ((imm & 0x40000) << 1)) << 2";
485   DriverStr(RepeatRIb(&mips::MipsAssembler::Addiupc, 19, code), "Addiupc");
486 }
487 
TEST_F(AssemblerMIPS32r6Test,Bitswap)488 TEST_F(AssemblerMIPS32r6Test, Bitswap) {
489   DriverStr(RepeatRR(&mips::MipsAssembler::Bitswap, "bitswap ${reg1}, ${reg2}"), "bitswap");
490 }
491 
TEST_F(AssemblerMIPS32r6Test,Lsa)492 TEST_F(AssemblerMIPS32r6Test, Lsa) {
493   DriverStr(RepeatRRRIb(&mips::MipsAssembler::Lsa,
494                         2,
495                         "lsa ${reg1}, ${reg2}, ${reg3}, {imm}",
496                         1),
497             "lsa");
498 }
499 
TEST_F(AssemblerMIPS32r6Test,Seleqz)500 TEST_F(AssemblerMIPS32r6Test, Seleqz) {
501   DriverStr(RepeatRRR(&mips::MipsAssembler::Seleqz, "seleqz ${reg1}, ${reg2}, ${reg3}"), "seleqz");
502 }
503 
TEST_F(AssemblerMIPS32r6Test,Selnez)504 TEST_F(AssemblerMIPS32r6Test, Selnez) {
505   DriverStr(RepeatRRR(&mips::MipsAssembler::Selnez, "selnez ${reg1}, ${reg2}, ${reg3}"), "selnez");
506 }
507 
TEST_F(AssemblerMIPS32r6Test,ClzR6)508 TEST_F(AssemblerMIPS32r6Test, ClzR6) {
509   DriverStr(RepeatRR(&mips::MipsAssembler::ClzR6, "clz ${reg1}, ${reg2}"), "clzR6");
510 }
511 
TEST_F(AssemblerMIPS32r6Test,CloR6)512 TEST_F(AssemblerMIPS32r6Test, CloR6) {
513   DriverStr(RepeatRR(&mips::MipsAssembler::CloR6, "clo ${reg1}, ${reg2}"), "cloR6");
514 }
515 
516 ////////////////////
517 // FLOATING POINT //
518 ////////////////////
519 
TEST_F(AssemblerMIPS32r6Test,SelS)520 TEST_F(AssemblerMIPS32r6Test, SelS) {
521   DriverStr(RepeatFFF(&mips::MipsAssembler::SelS, "sel.s ${reg1}, ${reg2}, ${reg3}"), "sel.s");
522 }
523 
TEST_F(AssemblerMIPS32r6Test,SelD)524 TEST_F(AssemblerMIPS32r6Test, SelD) {
525   DriverStr(RepeatFFF(&mips::MipsAssembler::SelD, "sel.d ${reg1}, ${reg2}, ${reg3}"), "sel.d");
526 }
527 
TEST_F(AssemblerMIPS32r6Test,SeleqzS)528 TEST_F(AssemblerMIPS32r6Test, SeleqzS) {
529   DriverStr(RepeatFFF(&mips::MipsAssembler::SeleqzS, "seleqz.s ${reg1}, ${reg2}, ${reg3}"),
530             "seleqz.s");
531 }
532 
TEST_F(AssemblerMIPS32r6Test,SeleqzD)533 TEST_F(AssemblerMIPS32r6Test, SeleqzD) {
534   DriverStr(RepeatFFF(&mips::MipsAssembler::SeleqzD, "seleqz.d ${reg1}, ${reg2}, ${reg3}"),
535             "seleqz.d");
536 }
537 
TEST_F(AssemblerMIPS32r6Test,SelnezS)538 TEST_F(AssemblerMIPS32r6Test, SelnezS) {
539   DriverStr(RepeatFFF(&mips::MipsAssembler::SelnezS, "selnez.s ${reg1}, ${reg2}, ${reg3}"),
540             "selnez.s");
541 }
542 
TEST_F(AssemblerMIPS32r6Test,SelnezD)543 TEST_F(AssemblerMIPS32r6Test, SelnezD) {
544   DriverStr(RepeatFFF(&mips::MipsAssembler::SelnezD, "selnez.d ${reg1}, ${reg2}, ${reg3}"),
545             "selnez.d");
546 }
547 
TEST_F(AssemblerMIPS32r6Test,ClassS)548 TEST_F(AssemblerMIPS32r6Test, ClassS) {
549   DriverStr(RepeatFF(&mips::MipsAssembler::ClassS, "class.s ${reg1}, ${reg2}"), "class.s");
550 }
551 
TEST_F(AssemblerMIPS32r6Test,ClassD)552 TEST_F(AssemblerMIPS32r6Test, ClassD) {
553   DriverStr(RepeatFF(&mips::MipsAssembler::ClassD, "class.d ${reg1}, ${reg2}"), "class.d");
554 }
555 
TEST_F(AssemblerMIPS32r6Test,MinS)556 TEST_F(AssemblerMIPS32r6Test, MinS) {
557   DriverStr(RepeatFFF(&mips::MipsAssembler::MinS, "min.s ${reg1}, ${reg2}, ${reg3}"), "min.s");
558 }
559 
TEST_F(AssemblerMIPS32r6Test,MinD)560 TEST_F(AssemblerMIPS32r6Test, MinD) {
561   DriverStr(RepeatFFF(&mips::MipsAssembler::MinD, "min.d ${reg1}, ${reg2}, ${reg3}"), "min.d");
562 }
563 
TEST_F(AssemblerMIPS32r6Test,MaxS)564 TEST_F(AssemblerMIPS32r6Test, MaxS) {
565   DriverStr(RepeatFFF(&mips::MipsAssembler::MaxS, "max.s ${reg1}, ${reg2}, ${reg3}"), "max.s");
566 }
567 
TEST_F(AssemblerMIPS32r6Test,MaxD)568 TEST_F(AssemblerMIPS32r6Test, MaxD) {
569   DriverStr(RepeatFFF(&mips::MipsAssembler::MaxD, "max.d ${reg1}, ${reg2}, ${reg3}"), "max.d");
570 }
571 
TEST_F(AssemblerMIPS32r6Test,CmpUnS)572 TEST_F(AssemblerMIPS32r6Test, CmpUnS) {
573   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUnS, "cmp.un.s ${reg1}, ${reg2}, ${reg3}"),
574             "cmp.un.s");
575 }
576 
TEST_F(AssemblerMIPS32r6Test,CmpEqS)577 TEST_F(AssemblerMIPS32r6Test, CmpEqS) {
578   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpEqS, "cmp.eq.s ${reg1}, ${reg2}, ${reg3}"),
579             "cmp.eq.s");
580 }
581 
TEST_F(AssemblerMIPS32r6Test,CmpUeqS)582 TEST_F(AssemblerMIPS32r6Test, CmpUeqS) {
583   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUeqS, "cmp.ueq.s ${reg1}, ${reg2}, ${reg3}"),
584             "cmp.ueq.s");
585 }
586 
TEST_F(AssemblerMIPS32r6Test,CmpLtS)587 TEST_F(AssemblerMIPS32r6Test, CmpLtS) {
588   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpLtS, "cmp.lt.s ${reg1}, ${reg2}, ${reg3}"),
589             "cmp.lt.s");
590 }
591 
TEST_F(AssemblerMIPS32r6Test,CmpUltS)592 TEST_F(AssemblerMIPS32r6Test, CmpUltS) {
593   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUltS, "cmp.ult.s ${reg1}, ${reg2}, ${reg3}"),
594             "cmp.ult.s");
595 }
596 
TEST_F(AssemblerMIPS32r6Test,CmpLeS)597 TEST_F(AssemblerMIPS32r6Test, CmpLeS) {
598   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpLeS, "cmp.le.s ${reg1}, ${reg2}, ${reg3}"),
599             "cmp.le.s");
600 }
601 
TEST_F(AssemblerMIPS32r6Test,CmpUleS)602 TEST_F(AssemblerMIPS32r6Test, CmpUleS) {
603   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUleS, "cmp.ule.s ${reg1}, ${reg2}, ${reg3}"),
604             "cmp.ule.s");
605 }
606 
TEST_F(AssemblerMIPS32r6Test,CmpOrS)607 TEST_F(AssemblerMIPS32r6Test, CmpOrS) {
608   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpOrS, "cmp.or.s ${reg1}, ${reg2}, ${reg3}"),
609             "cmp.or.s");
610 }
611 
TEST_F(AssemblerMIPS32r6Test,CmpUneS)612 TEST_F(AssemblerMIPS32r6Test, CmpUneS) {
613   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUneS, "cmp.une.s ${reg1}, ${reg2}, ${reg3}"),
614             "cmp.une.s");
615 }
616 
TEST_F(AssemblerMIPS32r6Test,CmpNeS)617 TEST_F(AssemblerMIPS32r6Test, CmpNeS) {
618   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpNeS, "cmp.ne.s ${reg1}, ${reg2}, ${reg3}"),
619             "cmp.ne.s");
620 }
621 
TEST_F(AssemblerMIPS32r6Test,CmpUnD)622 TEST_F(AssemblerMIPS32r6Test, CmpUnD) {
623   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUnD, "cmp.un.d ${reg1}, ${reg2}, ${reg3}"),
624             "cmp.un.d");
625 }
626 
TEST_F(AssemblerMIPS32r6Test,CmpEqD)627 TEST_F(AssemblerMIPS32r6Test, CmpEqD) {
628   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpEqD, "cmp.eq.d ${reg1}, ${reg2}, ${reg3}"),
629             "cmp.eq.d");
630 }
631 
TEST_F(AssemblerMIPS32r6Test,CmpUeqD)632 TEST_F(AssemblerMIPS32r6Test, CmpUeqD) {
633   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUeqD, "cmp.ueq.d ${reg1}, ${reg2}, ${reg3}"),
634             "cmp.ueq.d");
635 }
636 
TEST_F(AssemblerMIPS32r6Test,CmpLtD)637 TEST_F(AssemblerMIPS32r6Test, CmpLtD) {
638   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpLtD, "cmp.lt.d ${reg1}, ${reg2}, ${reg3}"),
639             "cmp.lt.d");
640 }
641 
TEST_F(AssemblerMIPS32r6Test,CmpUltD)642 TEST_F(AssemblerMIPS32r6Test, CmpUltD) {
643   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUltD, "cmp.ult.d ${reg1}, ${reg2}, ${reg3}"),
644             "cmp.ult.d");
645 }
646 
TEST_F(AssemblerMIPS32r6Test,CmpLeD)647 TEST_F(AssemblerMIPS32r6Test, CmpLeD) {
648   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpLeD, "cmp.le.d ${reg1}, ${reg2}, ${reg3}"),
649             "cmp.le.d");
650 }
651 
TEST_F(AssemblerMIPS32r6Test,CmpUleD)652 TEST_F(AssemblerMIPS32r6Test, CmpUleD) {
653   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUleD, "cmp.ule.d ${reg1}, ${reg2}, ${reg3}"),
654             "cmp.ule.d");
655 }
656 
TEST_F(AssemblerMIPS32r6Test,CmpOrD)657 TEST_F(AssemblerMIPS32r6Test, CmpOrD) {
658   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpOrD, "cmp.or.d ${reg1}, ${reg2}, ${reg3}"),
659             "cmp.or.d");
660 }
661 
TEST_F(AssemblerMIPS32r6Test,CmpUneD)662 TEST_F(AssemblerMIPS32r6Test, CmpUneD) {
663   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpUneD, "cmp.une.d ${reg1}, ${reg2}, ${reg3}"),
664             "cmp.une.d");
665 }
666 
TEST_F(AssemblerMIPS32r6Test,CmpNeD)667 TEST_F(AssemblerMIPS32r6Test, CmpNeD) {
668   DriverStr(RepeatFFF(&mips::MipsAssembler::CmpNeD, "cmp.ne.d ${reg1}, ${reg2}, ${reg3}"),
669             "cmp.ne.d");
670 }
671 
TEST_F(AssemblerMIPS32r6Test,LoadDFromOffset)672 TEST_F(AssemblerMIPS32r6Test, LoadDFromOffset) {
673   __ LoadDFromOffset(mips::F0, mips::A0, -0x8000);
674   __ LoadDFromOffset(mips::F0, mips::A0, +0);
675   __ LoadDFromOffset(mips::F0, mips::A0, +0x7FF8);
676   __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFB);
677   __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFC);
678   __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFF);
679   __ LoadDFromOffset(mips::F0, mips::A0, -0xFFF0);
680   __ LoadDFromOffset(mips::F0, mips::A0, -0x8008);
681   __ LoadDFromOffset(mips::F0, mips::A0, -0x8001);
682   __ LoadDFromOffset(mips::F0, mips::A0, +0x8000);
683   __ LoadDFromOffset(mips::F0, mips::A0, +0xFFF0);
684   __ LoadDFromOffset(mips::F0, mips::A0, -0x17FE8);
685   __ LoadDFromOffset(mips::F0, mips::A0, -0x0FFF8);
686   __ LoadDFromOffset(mips::F0, mips::A0, -0x0FFF1);
687   __ LoadDFromOffset(mips::F0, mips::A0, +0x0FFF1);
688   __ LoadDFromOffset(mips::F0, mips::A0, +0x0FFF8);
689   __ LoadDFromOffset(mips::F0, mips::A0, +0x17FE8);
690   __ LoadDFromOffset(mips::F0, mips::A0, -0x17FF0);
691   __ LoadDFromOffset(mips::F0, mips::A0, -0x17FE9);
692   __ LoadDFromOffset(mips::F0, mips::A0, +0x17FE9);
693   __ LoadDFromOffset(mips::F0, mips::A0, +0x17FF0);
694   __ LoadDFromOffset(mips::F0, mips::A0, +0x12345678);
695 
696   const char* expected =
697       "ldc1 $f0, -0x8000($a0)\n"
698       "ldc1 $f0, 0($a0)\n"
699       "ldc1 $f0, 0x7FF8($a0)\n"
700       "lwc1 $f0, 0x7FFB($a0)\n"
701       "lw $t8, 0x7FFF($a0)\n"
702       "mthc1 $t8, $f0\n"
703       "addiu $at, $a0, 0x7FF8\n"
704       "lwc1 $f0, 4($at)\n"
705       "lw $t8, 8($at)\n"
706       "mthc1 $t8, $f0\n"
707       "addiu $at, $a0, 0x7FF8\n"
708       "lwc1 $f0, 7($at)\n"
709       "lw $t8, 11($at)\n"
710       "mthc1 $t8, $f0\n"
711       "addiu $at, $a0, -0x7FF8\n"
712       "ldc1 $f0, -0x7FF8($at)\n"
713       "addiu $at, $a0, -0x7FF8\n"
714       "ldc1 $f0, -0x10($at)\n"
715       "addiu $at, $a0, -0x7FF8\n"
716       "lwc1 $f0, -9($at)\n"
717       "lw $t8, -5($at)\n"
718       "mthc1 $t8, $f0\n"
719       "addiu $at, $a0, 0x7FF8\n"
720       "ldc1 $f0, 8($at)\n"
721       "addiu $at, $a0, 0x7FF8\n"
722       "ldc1 $f0, 0x7FF8($at)\n"
723       "aui $at, $a0, 0xFFFF\n"
724       "ldc1 $f0, -0x7FE8($at)\n"
725       "aui $at, $a0, 0xFFFF\n"
726       "ldc1 $f0, 0x8($at)\n"
727       "aui $at, $a0, 0xFFFF\n"
728       "lwc1 $f0, 0xF($at)\n"
729       "lw $t8, 0x13($at)\n"
730       "mthc1 $t8, $f0\n"
731       "aui $at, $a0, 0x1\n"
732       "lwc1 $f0, -0xF($at)\n"
733       "lw $t8, -0xB($at)\n"
734       "mthc1 $t8, $f0\n"
735       "aui $at, $a0, 0x1\n"
736       "ldc1 $f0, -0x8($at)\n"
737       "aui $at, $a0, 0x1\n"
738       "ldc1 $f0, 0x7FE8($at)\n"
739       "aui $at, $a0, 0xFFFF\n"
740       "ldc1 $f0, -0x7FF0($at)\n"
741       "aui $at, $a0, 0xFFFF\n"
742       "lwc1 $f0, -0x7FE9($at)\n"
743       "lw $t8, -0x7FE5($at)\n"
744       "mthc1 $t8, $f0\n"
745       "aui $at, $a0, 0x1\n"
746       "lwc1 $f0, 0x7FE9($at)\n"
747       "lw $t8, 0x7FED($at)\n"
748       "mthc1 $t8, $f0\n"
749       "aui $at, $a0, 0x1\n"
750       "ldc1 $f0, 0x7FF0($at)\n"
751       "aui $at, $a0, 0x1234\n"
752       "ldc1 $f0, 0x5678($at)\n";
753   DriverStr(expected, "LoadDFromOffset");
754 }
755 
TEST_F(AssemblerMIPS32r6Test,LoadQFromOffset)756 TEST_F(AssemblerMIPS32r6Test, LoadQFromOffset) {
757   __ LoadQFromOffset(mips::F0, mips::A0, 0);
758   __ LoadQFromOffset(mips::F0, mips::A0, 1);
759   __ LoadQFromOffset(mips::F0, mips::A0, 2);
760   __ LoadQFromOffset(mips::F0, mips::A0, 4);
761   __ LoadQFromOffset(mips::F0, mips::A0, 8);
762   __ LoadQFromOffset(mips::F0, mips::A0, 511);
763   __ LoadQFromOffset(mips::F0, mips::A0, 512);
764   __ LoadQFromOffset(mips::F0, mips::A0, 513);
765   __ LoadQFromOffset(mips::F0, mips::A0, 514);
766   __ LoadQFromOffset(mips::F0, mips::A0, 516);
767   __ LoadQFromOffset(mips::F0, mips::A0, 1022);
768   __ LoadQFromOffset(mips::F0, mips::A0, 1024);
769   __ LoadQFromOffset(mips::F0, mips::A0, 1025);
770   __ LoadQFromOffset(mips::F0, mips::A0, 1026);
771   __ LoadQFromOffset(mips::F0, mips::A0, 1028);
772   __ LoadQFromOffset(mips::F0, mips::A0, 2044);
773   __ LoadQFromOffset(mips::F0, mips::A0, 2048);
774   __ LoadQFromOffset(mips::F0, mips::A0, 2049);
775   __ LoadQFromOffset(mips::F0, mips::A0, 2050);
776   __ LoadQFromOffset(mips::F0, mips::A0, 2052);
777   __ LoadQFromOffset(mips::F0, mips::A0, 4088);
778   __ LoadQFromOffset(mips::F0, mips::A0, 4096);
779   __ LoadQFromOffset(mips::F0, mips::A0, 4097);
780   __ LoadQFromOffset(mips::F0, mips::A0, 4098);
781   __ LoadQFromOffset(mips::F0, mips::A0, 4100);
782   __ LoadQFromOffset(mips::F0, mips::A0, 4104);
783   __ LoadQFromOffset(mips::F0, mips::A0, 0x7FFC);
784   __ LoadQFromOffset(mips::F0, mips::A0, 0x8000);
785   __ LoadQFromOffset(mips::F0, mips::A0, 0x10000);
786   __ LoadQFromOffset(mips::F0, mips::A0, 0x12345678);
787   __ LoadQFromOffset(mips::F0, mips::A0, 0x12350078);
788   __ LoadQFromOffset(mips::F0, mips::A0, -256);
789   __ LoadQFromOffset(mips::F0, mips::A0, -511);
790   __ LoadQFromOffset(mips::F0, mips::A0, -513);
791   __ LoadQFromOffset(mips::F0, mips::A0, -1022);
792   __ LoadQFromOffset(mips::F0, mips::A0, -1026);
793   __ LoadQFromOffset(mips::F0, mips::A0, -2044);
794   __ LoadQFromOffset(mips::F0, mips::A0, -2052);
795   __ LoadQFromOffset(mips::F0, mips::A0, -4096);
796   __ LoadQFromOffset(mips::F0, mips::A0, -4104);
797   __ LoadQFromOffset(mips::F0, mips::A0, -32768);
798   __ LoadQFromOffset(mips::F0, mips::A0, 0xABCDEF00);
799   __ LoadQFromOffset(mips::F0, mips::A0, 0x7FFFABCD);
800 
801   const char* expected =
802       "ld.d $w0, 0($a0)\n"
803       "ld.b $w0, 1($a0)\n"
804       "ld.h $w0, 2($a0)\n"
805       "ld.w $w0, 4($a0)\n"
806       "ld.d $w0, 8($a0)\n"
807       "ld.b $w0, 511($a0)\n"
808       "ld.d $w0, 512($a0)\n"
809       "addiu $at, $a0, 513\n"
810       "ld.b $w0, 0($at)\n"
811       "ld.h $w0, 514($a0)\n"
812       "ld.w $w0, 516($a0)\n"
813       "ld.h $w0, 1022($a0)\n"
814       "ld.d $w0, 1024($a0)\n"
815       "addiu $at, $a0, 1025\n"
816       "ld.b $w0, 0($at)\n"
817       "addiu $at, $a0, 1026\n"
818       "ld.h $w0, 0($at)\n"
819       "ld.w $w0, 1028($a0)\n"
820       "ld.w $w0, 2044($a0)\n"
821       "ld.d $w0, 2048($a0)\n"
822       "addiu $at, $a0, 2049\n"
823       "ld.b $w0, 0($at)\n"
824       "addiu $at, $a0, 2050\n"
825       "ld.h $w0, 0($at)\n"
826       "addiu $at, $a0, 2052\n"
827       "ld.w $w0, 0($at)\n"
828       "ld.d $w0, 4088($a0)\n"
829       "addiu $at, $a0, 4096\n"
830       "ld.d $w0, 0($at)\n"
831       "addiu $at, $a0, 4097\n"
832       "ld.b $w0, 0($at)\n"
833       "addiu $at, $a0, 4098\n"
834       "ld.h $w0, 0($at)\n"
835       "addiu $at, $a0, 4100\n"
836       "ld.w $w0, 0($at)\n"
837       "addiu $at, $a0, 4104\n"
838       "ld.d $w0, 0($at)\n"
839       "addiu $at, $a0, 0x7FFC\n"
840       "ld.w $w0, 0($at)\n"
841       "addiu $at, $a0, 0x7FF8\n"
842       "ld.d $w0, 8($at)\n"
843       "aui $at, $a0, 0x1\n"
844       "ld.d $w0, 0($at)\n"
845       "aui $at, $a0, 0x1234\n"
846       "addiu $at, $at, 0x6000\n"
847       "ld.d $w0, -2440($at) # 0xF678\n"
848       "aui $at, $a0, 0x1235\n"
849       "ld.d $w0, 0x78($at)\n"
850       "ld.d $w0, -256($a0)\n"
851       "ld.b $w0, -511($a0)\n"
852       "addiu $at, $a0, -513\n"
853       "ld.b $w0, 0($at)\n"
854       "ld.h $w0, -1022($a0)\n"
855       "addiu $at, $a0, -1026\n"
856       "ld.h $w0, 0($at)\n"
857       "ld.w $w0, -2044($a0)\n"
858       "addiu $at, $a0, -2052\n"
859       "ld.w $w0, 0($at)\n"
860       "ld.d $w0, -4096($a0)\n"
861       "addiu $at, $a0, -4104\n"
862       "ld.d $w0, 0($at)\n"
863       "addiu $at, $a0, -32768\n"
864       "ld.d $w0, 0($at)\n"
865       "aui $at, $a0, 0xABCE\n"
866       "addiu $at, $at, -8192 # 0xE000\n"
867       "ld.d $w0, 0xF00($at)\n"
868       "aui $at, $a0, 0x8000\n"
869       "addiu $at, $at, -21504 # 0xAC00\n"
870       "ld.b $w0, -51($at) # 0xFFCD\n";
871   DriverStr(expected, "LoadQFromOffset");
872 }
873 
TEST_F(AssemblerMIPS32r6Test,StoreDToOffset)874 TEST_F(AssemblerMIPS32r6Test, StoreDToOffset) {
875   __ StoreDToOffset(mips::F0, mips::A0, -0x8000);
876   __ StoreDToOffset(mips::F0, mips::A0, +0);
877   __ StoreDToOffset(mips::F0, mips::A0, +0x7FF8);
878   __ StoreDToOffset(mips::F0, mips::A0, +0x7FFB);
879   __ StoreDToOffset(mips::F0, mips::A0, +0x7FFC);
880   __ StoreDToOffset(mips::F0, mips::A0, +0x7FFF);
881   __ StoreDToOffset(mips::F0, mips::A0, -0xFFF0);
882   __ StoreDToOffset(mips::F0, mips::A0, -0x8008);
883   __ StoreDToOffset(mips::F0, mips::A0, -0x8001);
884   __ StoreDToOffset(mips::F0, mips::A0, +0x8000);
885   __ StoreDToOffset(mips::F0, mips::A0, +0xFFF0);
886   __ StoreDToOffset(mips::F0, mips::A0, -0x17FE8);
887   __ StoreDToOffset(mips::F0, mips::A0, -0x0FFF8);
888   __ StoreDToOffset(mips::F0, mips::A0, -0x0FFF1);
889   __ StoreDToOffset(mips::F0, mips::A0, +0x0FFF1);
890   __ StoreDToOffset(mips::F0, mips::A0, +0x0FFF8);
891   __ StoreDToOffset(mips::F0, mips::A0, +0x17FE8);
892   __ StoreDToOffset(mips::F0, mips::A0, -0x17FF0);
893   __ StoreDToOffset(mips::F0, mips::A0, -0x17FE9);
894   __ StoreDToOffset(mips::F0, mips::A0, +0x17FE9);
895   __ StoreDToOffset(mips::F0, mips::A0, +0x17FF0);
896   __ StoreDToOffset(mips::F0, mips::A0, +0x12345678);
897 
898   const char* expected =
899       "sdc1 $f0, -0x8000($a0)\n"
900       "sdc1 $f0, 0($a0)\n"
901       "sdc1 $f0, 0x7FF8($a0)\n"
902       "mfhc1 $t8, $f0\n"
903       "swc1 $f0, 0x7FFB($a0)\n"
904       "sw $t8, 0x7FFF($a0)\n"
905       "addiu $at, $a0, 0x7FF8\n"
906       "mfhc1 $t8, $f0\n"
907       "swc1 $f0, 4($at)\n"
908       "sw $t8, 8($at)\n"
909       "addiu $at, $a0, 0x7FF8\n"
910       "mfhc1 $t8, $f0\n"
911       "swc1 $f0, 7($at)\n"
912       "sw $t8, 11($at)\n"
913       "addiu $at, $a0, -0x7FF8\n"
914       "sdc1 $f0, -0x7FF8($at)\n"
915       "addiu $at, $a0, -0x7FF8\n"
916       "sdc1 $f0, -0x10($at)\n"
917       "addiu $at, $a0, -0x7FF8\n"
918       "mfhc1 $t8, $f0\n"
919       "swc1 $f0, -9($at)\n"
920       "sw $t8, -5($at)\n"
921       "addiu $at, $a0, 0x7FF8\n"
922       "sdc1 $f0, 8($at)\n"
923       "addiu $at, $a0, 0x7FF8\n"
924       "sdc1 $f0, 0x7FF8($at)\n"
925       "aui $at, $a0, 0xFFFF\n"
926       "sdc1 $f0, -0x7FE8($at)\n"
927       "aui $at, $a0, 0xFFFF\n"
928       "sdc1 $f0, 0x8($at)\n"
929       "aui $at, $a0, 0xFFFF\n"
930       "mfhc1 $t8, $f0\n"
931       "swc1 $f0, 0xF($at)\n"
932       "sw $t8, 0x13($at)\n"
933       "aui $at, $a0, 0x1\n"
934       "mfhc1 $t8, $f0\n"
935       "swc1 $f0, -0xF($at)\n"
936       "sw $t8, -0xB($at)\n"
937       "aui $at, $a0, 0x1\n"
938       "sdc1 $f0, -0x8($at)\n"
939       "aui $at, $a0, 0x1\n"
940       "sdc1 $f0, 0x7FE8($at)\n"
941       "aui $at, $a0, 0xFFFF\n"
942       "sdc1 $f0, -0x7FF0($at)\n"
943       "aui $at, $a0, 0xFFFF\n"
944       "mfhc1 $t8, $f0\n"
945       "swc1 $f0, -0x7FE9($at)\n"
946       "sw $t8, -0x7FE5($at)\n"
947       "aui $at, $a0, 0x1\n"
948       "mfhc1 $t8, $f0\n"
949       "swc1 $f0, 0x7FE9($at)\n"
950       "sw $t8, 0x7FED($at)\n"
951       "aui $at, $a0, 0x1\n"
952       "sdc1 $f0, 0x7FF0($at)\n"
953       "aui $at, $a0, 0x1234\n"
954       "sdc1 $f0, 0x5678($at)\n";
955   DriverStr(expected, "StoreDToOffset");
956 }
957 
TEST_F(AssemblerMIPS32r6Test,StoreQToOffset)958 TEST_F(AssemblerMIPS32r6Test, StoreQToOffset) {
959   __ StoreQToOffset(mips::F0, mips::A0, 0);
960   __ StoreQToOffset(mips::F0, mips::A0, 1);
961   __ StoreQToOffset(mips::F0, mips::A0, 2);
962   __ StoreQToOffset(mips::F0, mips::A0, 4);
963   __ StoreQToOffset(mips::F0, mips::A0, 8);
964   __ StoreQToOffset(mips::F0, mips::A0, 511);
965   __ StoreQToOffset(mips::F0, mips::A0, 512);
966   __ StoreQToOffset(mips::F0, mips::A0, 513);
967   __ StoreQToOffset(mips::F0, mips::A0, 514);
968   __ StoreQToOffset(mips::F0, mips::A0, 516);
969   __ StoreQToOffset(mips::F0, mips::A0, 1022);
970   __ StoreQToOffset(mips::F0, mips::A0, 1024);
971   __ StoreQToOffset(mips::F0, mips::A0, 1025);
972   __ StoreQToOffset(mips::F0, mips::A0, 1026);
973   __ StoreQToOffset(mips::F0, mips::A0, 1028);
974   __ StoreQToOffset(mips::F0, mips::A0, 2044);
975   __ StoreQToOffset(mips::F0, mips::A0, 2048);
976   __ StoreQToOffset(mips::F0, mips::A0, 2049);
977   __ StoreQToOffset(mips::F0, mips::A0, 2050);
978   __ StoreQToOffset(mips::F0, mips::A0, 2052);
979   __ StoreQToOffset(mips::F0, mips::A0, 4088);
980   __ StoreQToOffset(mips::F0, mips::A0, 4096);
981   __ StoreQToOffset(mips::F0, mips::A0, 4097);
982   __ StoreQToOffset(mips::F0, mips::A0, 4098);
983   __ StoreQToOffset(mips::F0, mips::A0, 4100);
984   __ StoreQToOffset(mips::F0, mips::A0, 4104);
985   __ StoreQToOffset(mips::F0, mips::A0, 0x7FFC);
986   __ StoreQToOffset(mips::F0, mips::A0, 0x8000);
987   __ StoreQToOffset(mips::F0, mips::A0, 0x10000);
988   __ StoreQToOffset(mips::F0, mips::A0, 0x12345678);
989   __ StoreQToOffset(mips::F0, mips::A0, 0x12350078);
990   __ StoreQToOffset(mips::F0, mips::A0, -256);
991   __ StoreQToOffset(mips::F0, mips::A0, -511);
992   __ StoreQToOffset(mips::F0, mips::A0, -513);
993   __ StoreQToOffset(mips::F0, mips::A0, -1022);
994   __ StoreQToOffset(mips::F0, mips::A0, -1026);
995   __ StoreQToOffset(mips::F0, mips::A0, -2044);
996   __ StoreQToOffset(mips::F0, mips::A0, -2052);
997   __ StoreQToOffset(mips::F0, mips::A0, -4096);
998   __ StoreQToOffset(mips::F0, mips::A0, -4104);
999   __ StoreQToOffset(mips::F0, mips::A0, -32768);
1000   __ StoreQToOffset(mips::F0, mips::A0, 0xABCDEF00);
1001   __ StoreQToOffset(mips::F0, mips::A0, 0x7FFFABCD);
1002 
1003   const char* expected =
1004       "st.d $w0, 0($a0)\n"
1005       "st.b $w0, 1($a0)\n"
1006       "st.h $w0, 2($a0)\n"
1007       "st.w $w0, 4($a0)\n"
1008       "st.d $w0, 8($a0)\n"
1009       "st.b $w0, 511($a0)\n"
1010       "st.d $w0, 512($a0)\n"
1011       "addiu $at, $a0, 513\n"
1012       "st.b $w0, 0($at)\n"
1013       "st.h $w0, 514($a0)\n"
1014       "st.w $w0, 516($a0)\n"
1015       "st.h $w0, 1022($a0)\n"
1016       "st.d $w0, 1024($a0)\n"
1017       "addiu $at, $a0, 1025\n"
1018       "st.b $w0, 0($at)\n"
1019       "addiu $at, $a0, 1026\n"
1020       "st.h $w0, 0($at)\n"
1021       "st.w $w0, 1028($a0)\n"
1022       "st.w $w0, 2044($a0)\n"
1023       "st.d $w0, 2048($a0)\n"
1024       "addiu $at, $a0, 2049\n"
1025       "st.b $w0, 0($at)\n"
1026       "addiu $at, $a0, 2050\n"
1027       "st.h $w0, 0($at)\n"
1028       "addiu $at, $a0, 2052\n"
1029       "st.w $w0, 0($at)\n"
1030       "st.d $w0, 4088($a0)\n"
1031       "addiu $at, $a0, 4096\n"
1032       "st.d $w0, 0($at)\n"
1033       "addiu $at, $a0, 4097\n"
1034       "st.b $w0, 0($at)\n"
1035       "addiu $at, $a0, 4098\n"
1036       "st.h $w0, 0($at)\n"
1037       "addiu $at, $a0, 4100\n"
1038       "st.w $w0, 0($at)\n"
1039       "addiu $at, $a0, 4104\n"
1040       "st.d $w0, 0($at)\n"
1041       "addiu $at, $a0, 0x7FFC\n"
1042       "st.w $w0, 0($at)\n"
1043       "addiu $at, $a0, 0x7FF8\n"
1044       "st.d $w0, 8($at)\n"
1045       "aui $at, $a0, 0x1\n"
1046       "st.d $w0, 0($at)\n"
1047       "aui $at, $a0, 0x1234\n"
1048       "addiu $at, $at, 0x6000\n"
1049       "st.d $w0, -2440($at) # 0xF678\n"
1050       "aui $at, $a0, 0x1235\n"
1051       "st.d $w0, 0x78($at)\n"
1052       "st.d $w0, -256($a0)\n"
1053       "st.b $w0, -511($a0)\n"
1054       "addiu $at, $a0, -513\n"
1055       "st.b $w0, 0($at)\n"
1056       "st.h $w0, -1022($a0)\n"
1057       "addiu $at, $a0, -1026\n"
1058       "st.h $w0, 0($at)\n"
1059       "st.w $w0, -2044($a0)\n"
1060       "addiu $at, $a0, -2052\n"
1061       "st.w $w0, 0($at)\n"
1062       "st.d $w0, -4096($a0)\n"
1063       "addiu $at, $a0, -4104\n"
1064       "st.d $w0, 0($at)\n"
1065       "addiu $at, $a0, -32768\n"
1066       "st.d $w0, 0($at)\n"
1067       "aui $at, $a0, 0xABCE\n"
1068       "addiu $at, $at, -8192 # 0xE000\n"
1069       "st.d $w0, 0xF00($at)\n"
1070       "aui $at, $a0, 0x8000\n"
1071       "addiu $at, $at, -21504 # 0xAC00\n"
1072       "st.b $w0, -51($at) # 0xFFCD\n";
1073   DriverStr(expected, "StoreQToOffset");
1074 }
1075 
1076 //////////////
1077 // BRANCHES //
1078 //////////////
1079 
TEST_F(AssemblerMIPS32r6Test,Bc)1080 TEST_F(AssemblerMIPS32r6Test, Bc) {
1081   BranchHelper(&mips::MipsAssembler::Bc, "Bc", /* has_slot= */ false);
1082 }
1083 
TEST_F(AssemblerMIPS32r6Test,Balc)1084 TEST_F(AssemblerMIPS32r6Test, Balc) {
1085   BranchHelper(&mips::MipsAssembler::Balc, "Balc", /* has_slot= */ false);
1086 }
1087 
TEST_F(AssemblerMIPS32r6Test,Beqc)1088 TEST_F(AssemblerMIPS32r6Test, Beqc) {
1089   BranchCondTwoRegsHelper(&mips::MipsAssembler::Beqc, "Beqc");
1090 }
1091 
TEST_F(AssemblerMIPS32r6Test,Bnec)1092 TEST_F(AssemblerMIPS32r6Test, Bnec) {
1093   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bnec, "Bnec");
1094 }
1095 
TEST_F(AssemblerMIPS32r6Test,Beqzc)1096 TEST_F(AssemblerMIPS32r6Test, Beqzc) {
1097   BranchCondOneRegHelper(&mips::MipsAssembler::Beqzc, "Beqzc");
1098 }
1099 
TEST_F(AssemblerMIPS32r6Test,Bnezc)1100 TEST_F(AssemblerMIPS32r6Test, Bnezc) {
1101   BranchCondOneRegHelper(&mips::MipsAssembler::Bnezc, "Bnezc");
1102 }
1103 
TEST_F(AssemblerMIPS32r6Test,Bltzc)1104 TEST_F(AssemblerMIPS32r6Test, Bltzc) {
1105   BranchCondOneRegHelper(&mips::MipsAssembler::Bltzc, "Bltzc");
1106 }
1107 
TEST_F(AssemblerMIPS32r6Test,Bgezc)1108 TEST_F(AssemblerMIPS32r6Test, Bgezc) {
1109   BranchCondOneRegHelper(&mips::MipsAssembler::Bgezc, "Bgezc");
1110 }
1111 
TEST_F(AssemblerMIPS32r6Test,Blezc)1112 TEST_F(AssemblerMIPS32r6Test, Blezc) {
1113   BranchCondOneRegHelper(&mips::MipsAssembler::Blezc, "Blezc");
1114 }
1115 
TEST_F(AssemblerMIPS32r6Test,Bgtzc)1116 TEST_F(AssemblerMIPS32r6Test, Bgtzc) {
1117   BranchCondOneRegHelper(&mips::MipsAssembler::Bgtzc, "Bgtzc");
1118 }
1119 
TEST_F(AssemblerMIPS32r6Test,Bltc)1120 TEST_F(AssemblerMIPS32r6Test, Bltc) {
1121   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltc, "Bltc");
1122 }
1123 
TEST_F(AssemblerMIPS32r6Test,Bgec)1124 TEST_F(AssemblerMIPS32r6Test, Bgec) {
1125   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgec, "Bgec");
1126 }
1127 
TEST_F(AssemblerMIPS32r6Test,Bltuc)1128 TEST_F(AssemblerMIPS32r6Test, Bltuc) {
1129   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltuc, "Bltuc");
1130 }
1131 
TEST_F(AssemblerMIPS32r6Test,Bgeuc)1132 TEST_F(AssemblerMIPS32r6Test, Bgeuc) {
1133   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeuc, "Bgeuc");
1134 }
1135 
TEST_F(AssemblerMIPS32r6Test,Bc1eqz)1136 TEST_F(AssemblerMIPS32r6Test, Bc1eqz) {
1137   BranchFpuCondHelper(&mips::MipsAssembler::Bc1eqz, "Bc1eqz");
1138 }
1139 
TEST_F(AssemblerMIPS32r6Test,Bc1nez)1140 TEST_F(AssemblerMIPS32r6Test, Bc1nez) {
1141   BranchFpuCondHelper(&mips::MipsAssembler::Bc1nez, "Bc1nez");
1142 }
1143 
TEST_F(AssemblerMIPS32r6Test,B)1144 TEST_F(AssemblerMIPS32r6Test, B) {
1145   BranchHelper(&mips::MipsAssembler::B, "Bc", /* has_slot= */ false);
1146 }
1147 
TEST_F(AssemblerMIPS32r6Test,Bal)1148 TEST_F(AssemblerMIPS32r6Test, Bal) {
1149   BranchHelper(&mips::MipsAssembler::Bal, "Balc", /* has_slot= */ false);
1150 }
1151 
TEST_F(AssemblerMIPS32r6Test,Beq)1152 TEST_F(AssemblerMIPS32r6Test, Beq) {
1153   BranchCondTwoRegsHelper(&mips::MipsAssembler::Beq, "Beqc");
1154 }
1155 
TEST_F(AssemblerMIPS32r6Test,Bne)1156 TEST_F(AssemblerMIPS32r6Test, Bne) {
1157   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bne, "Bnec");
1158 }
1159 
TEST_F(AssemblerMIPS32r6Test,Beqz)1160 TEST_F(AssemblerMIPS32r6Test, Beqz) {
1161   BranchCondOneRegHelper(&mips::MipsAssembler::Beqz, "Beqzc");
1162 }
1163 
TEST_F(AssemblerMIPS32r6Test,Bnez)1164 TEST_F(AssemblerMIPS32r6Test, Bnez) {
1165   BranchCondOneRegHelper(&mips::MipsAssembler::Bnez, "Bnezc");
1166 }
1167 
TEST_F(AssemblerMIPS32r6Test,Bltz)1168 TEST_F(AssemblerMIPS32r6Test, Bltz) {
1169   BranchCondOneRegHelper(&mips::MipsAssembler::Bltz, "Bltzc");
1170 }
1171 
TEST_F(AssemblerMIPS32r6Test,Bgez)1172 TEST_F(AssemblerMIPS32r6Test, Bgez) {
1173   BranchCondOneRegHelper(&mips::MipsAssembler::Bgez, "Bgezc");
1174 }
1175 
TEST_F(AssemblerMIPS32r6Test,Blez)1176 TEST_F(AssemblerMIPS32r6Test, Blez) {
1177   BranchCondOneRegHelper(&mips::MipsAssembler::Blez, "Blezc");
1178 }
1179 
TEST_F(AssemblerMIPS32r6Test,Bgtz)1180 TEST_F(AssemblerMIPS32r6Test, Bgtz) {
1181   BranchCondOneRegHelper(&mips::MipsAssembler::Bgtz, "Bgtzc");
1182 }
1183 
TEST_F(AssemblerMIPS32r6Test,Blt)1184 TEST_F(AssemblerMIPS32r6Test, Blt) {
1185   BranchCondTwoRegsHelper(&mips::MipsAssembler::Blt, "Bltc");
1186 }
1187 
TEST_F(AssemblerMIPS32r6Test,Bge)1188 TEST_F(AssemblerMIPS32r6Test, Bge) {
1189   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bge, "Bgec");
1190 }
1191 
TEST_F(AssemblerMIPS32r6Test,Bltu)1192 TEST_F(AssemblerMIPS32r6Test, Bltu) {
1193   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltu, "Bltuc");
1194 }
1195 
TEST_F(AssemblerMIPS32r6Test,Bgeu)1196 TEST_F(AssemblerMIPS32r6Test, Bgeu) {
1197   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeu, "Bgeuc");
1198 }
1199 
TEST_F(AssemblerMIPS32r6Test,BareBc)1200 TEST_F(AssemblerMIPS32r6Test, BareBc) {
1201   BranchHelper(&mips::MipsAssembler::Bc, "Bc", /* has_slot= */ false, /* is_bare= */ true);
1202 }
1203 
TEST_F(AssemblerMIPS32r6Test,BareBalc)1204 TEST_F(AssemblerMIPS32r6Test, BareBalc) {
1205   BranchHelper(&mips::MipsAssembler::Balc, "Balc", /* has_slot= */ false, /* is_bare= */ true);
1206 }
1207 
TEST_F(AssemblerMIPS32r6Test,BareBeqc)1208 TEST_F(AssemblerMIPS32r6Test, BareBeqc) {
1209   BranchCondTwoRegsHelper(&mips::MipsAssembler::Beqc, "Beqc", /* is_bare= */ true);
1210 }
1211 
TEST_F(AssemblerMIPS32r6Test,BareBnec)1212 TEST_F(AssemblerMIPS32r6Test, BareBnec) {
1213   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bnec, "Bnec", /* is_bare= */ true);
1214 }
1215 
TEST_F(AssemblerMIPS32r6Test,BareBeqzc)1216 TEST_F(AssemblerMIPS32r6Test, BareBeqzc) {
1217   BranchCondOneRegHelper(&mips::MipsAssembler::Beqzc, "Beqzc", /* is_bare= */ true);
1218 }
1219 
TEST_F(AssemblerMIPS32r6Test,BareBnezc)1220 TEST_F(AssemblerMIPS32r6Test, BareBnezc) {
1221   BranchCondOneRegHelper(&mips::MipsAssembler::Bnezc, "Bnezc", /* is_bare= */ true);
1222 }
1223 
TEST_F(AssemblerMIPS32r6Test,BareBltzc)1224 TEST_F(AssemblerMIPS32r6Test, BareBltzc) {
1225   BranchCondOneRegHelper(&mips::MipsAssembler::Bltzc, "Bltzc", /* is_bare= */ true);
1226 }
1227 
TEST_F(AssemblerMIPS32r6Test,BareBgezc)1228 TEST_F(AssemblerMIPS32r6Test, BareBgezc) {
1229   BranchCondOneRegHelper(&mips::MipsAssembler::Bgezc, "Bgezc", /* is_bare= */ true);
1230 }
1231 
TEST_F(AssemblerMIPS32r6Test,BareBlezc)1232 TEST_F(AssemblerMIPS32r6Test, BareBlezc) {
1233   BranchCondOneRegHelper(&mips::MipsAssembler::Blezc, "Blezc", /* is_bare= */ true);
1234 }
1235 
TEST_F(AssemblerMIPS32r6Test,BareBgtzc)1236 TEST_F(AssemblerMIPS32r6Test, BareBgtzc) {
1237   BranchCondOneRegHelper(&mips::MipsAssembler::Bgtzc, "Bgtzc", /* is_bare= */ true);
1238 }
1239 
TEST_F(AssemblerMIPS32r6Test,BareBltc)1240 TEST_F(AssemblerMIPS32r6Test, BareBltc) {
1241   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltc, "Bltc", /* is_bare= */ true);
1242 }
1243 
TEST_F(AssemblerMIPS32r6Test,BareBgec)1244 TEST_F(AssemblerMIPS32r6Test, BareBgec) {
1245   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgec, "Bgec", /* is_bare= */ true);
1246 }
1247 
TEST_F(AssemblerMIPS32r6Test,BareBltuc)1248 TEST_F(AssemblerMIPS32r6Test, BareBltuc) {
1249   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltuc, "Bltuc", /* is_bare= */ true);
1250 }
1251 
TEST_F(AssemblerMIPS32r6Test,BareBgeuc)1252 TEST_F(AssemblerMIPS32r6Test, BareBgeuc) {
1253   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeuc, "Bgeuc", /* is_bare= */ true);
1254 }
1255 
TEST_F(AssemblerMIPS32r6Test,BareBc1eqz)1256 TEST_F(AssemblerMIPS32r6Test, BareBc1eqz) {
1257   BranchFpuCondHelper(&mips::MipsAssembler::Bc1eqz, "Bc1eqz", /* is_bare= */ true);
1258 }
1259 
TEST_F(AssemblerMIPS32r6Test,BareBc1nez)1260 TEST_F(AssemblerMIPS32r6Test, BareBc1nez) {
1261   BranchFpuCondHelper(&mips::MipsAssembler::Bc1nez, "Bc1nez", /* is_bare= */ true);
1262 }
1263 
TEST_F(AssemblerMIPS32r6Test,BareB)1264 TEST_F(AssemblerMIPS32r6Test, BareB) {
1265   BranchHelper(&mips::MipsAssembler::B, "B", /* has_slot= */ true, /* is_bare= */ true);
1266 }
1267 
TEST_F(AssemblerMIPS32r6Test,BareBal)1268 TEST_F(AssemblerMIPS32r6Test, BareBal) {
1269   BranchHelper(&mips::MipsAssembler::Bal, "Bal", /* has_slot= */ true, /* is_bare= */ true);
1270 }
1271 
TEST_F(AssemblerMIPS32r6Test,BareBeq)1272 TEST_F(AssemblerMIPS32r6Test, BareBeq) {
1273   BranchCondTwoRegsHelper(&mips::MipsAssembler::Beq, "Beq", /* is_bare= */ true);
1274 }
1275 
TEST_F(AssemblerMIPS32r6Test,BareBne)1276 TEST_F(AssemblerMIPS32r6Test, BareBne) {
1277   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bne, "Bne", /* is_bare= */ true);
1278 }
1279 
TEST_F(AssemblerMIPS32r6Test,BareBeqz)1280 TEST_F(AssemblerMIPS32r6Test, BareBeqz) {
1281   BranchCondOneRegHelper(&mips::MipsAssembler::Beqz, "Beqz", /* is_bare= */ true);
1282 }
1283 
TEST_F(AssemblerMIPS32r6Test,BareBnez)1284 TEST_F(AssemblerMIPS32r6Test, BareBnez) {
1285   BranchCondOneRegHelper(&mips::MipsAssembler::Bnez, "Bnez", /* is_bare= */ true);
1286 }
1287 
TEST_F(AssemblerMIPS32r6Test,BareBltz)1288 TEST_F(AssemblerMIPS32r6Test, BareBltz) {
1289   BranchCondOneRegHelper(&mips::MipsAssembler::Bltz, "Bltz", /* is_bare= */ true);
1290 }
1291 
TEST_F(AssemblerMIPS32r6Test,BareBgez)1292 TEST_F(AssemblerMIPS32r6Test, BareBgez) {
1293   BranchCondOneRegHelper(&mips::MipsAssembler::Bgez, "Bgez", /* is_bare= */ true);
1294 }
1295 
TEST_F(AssemblerMIPS32r6Test,BareBlez)1296 TEST_F(AssemblerMIPS32r6Test, BareBlez) {
1297   BranchCondOneRegHelper(&mips::MipsAssembler::Blez, "Blez", /* is_bare= */ true);
1298 }
1299 
TEST_F(AssemblerMIPS32r6Test,BareBgtz)1300 TEST_F(AssemblerMIPS32r6Test, BareBgtz) {
1301   BranchCondOneRegHelper(&mips::MipsAssembler::Bgtz, "Bgtz", /* is_bare= */ true);
1302 }
1303 
TEST_F(AssemblerMIPS32r6Test,BareBlt)1304 TEST_F(AssemblerMIPS32r6Test, BareBlt) {
1305   BranchCondTwoRegsHelper(&mips::MipsAssembler::Blt, "Blt", /* is_bare= */ true);
1306 }
1307 
TEST_F(AssemblerMIPS32r6Test,BareBge)1308 TEST_F(AssemblerMIPS32r6Test, BareBge) {
1309   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bge, "Bge", /* is_bare= */ true);
1310 }
1311 
TEST_F(AssemblerMIPS32r6Test,BareBltu)1312 TEST_F(AssemblerMIPS32r6Test, BareBltu) {
1313   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltu, "Bltu", /* is_bare= */ true);
1314 }
1315 
TEST_F(AssemblerMIPS32r6Test,BareBgeu)1316 TEST_F(AssemblerMIPS32r6Test, BareBgeu) {
1317   BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeu, "Bgeu", /* is_bare= */ true);
1318 }
1319 
TEST_F(AssemblerMIPS32r6Test,LongBeqc)1320 TEST_F(AssemblerMIPS32r6Test, LongBeqc) {
1321   mips::MipsLabel label;
1322   __ Beqc(mips::A0, mips::A1, &label);
1323   constexpr uint32_t kAdduCount1 = (1u << 15) + 1;
1324   for (uint32_t i = 0; i != kAdduCount1; ++i) {
1325     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1326   }
1327   __ Bind(&label);
1328   constexpr uint32_t kAdduCount2 = (1u << 15) + 1;
1329   for (uint32_t i = 0; i != kAdduCount2; ++i) {
1330     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1331   }
1332   __ Beqc(mips::A2, mips::A3, &label);
1333 
1334   uint32_t offset_forward = 2 + kAdduCount1;  // 2: account for auipc and jic.
1335   offset_forward <<= 2;
1336   offset_forward += (offset_forward & 0x8000) << 1;  // Account for sign extension in jic.
1337 
1338   uint32_t offset_back = -(kAdduCount2 + 1);  // 1: account for bnec.
1339   offset_back <<= 2;
1340   offset_back += (offset_back & 0x8000) << 1;  // Account for sign extension in jic.
1341 
1342   std::ostringstream oss;
1343   oss <<
1344       ".set noreorder\n"
1345       "bnec $a0, $a1, 1f\n"
1346       "auipc $at, 0x" << std::hex << High16Bits(offset_forward) << "\n"
1347       "jic $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n"
1348       "1:\n" <<
1349       RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") <<
1350       "2:\n" <<
1351       RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") <<
1352       "bnec $a2, $a3, 3f\n"
1353       "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
1354       "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n"
1355       "3:\n";
1356   std::string expected = oss.str();
1357   DriverStr(expected, "LongBeqc");
1358 }
1359 
TEST_F(AssemblerMIPS32r6Test,LongBeqzc)1360 TEST_F(AssemblerMIPS32r6Test, LongBeqzc) {
1361   constexpr uint32_t kNopCount1 = (1u << 20) + 1;
1362   constexpr uint32_t kNopCount2 = (1u << 20) + 1;
1363   constexpr uint32_t kRequiredCapacity = (kNopCount1 + kNopCount2 + 6u) * 4u;
1364   ASSERT_LT(__ GetBuffer()->Capacity(), kRequiredCapacity);
1365   __ GetBuffer()->ExtendCapacity(kRequiredCapacity);
1366   mips::MipsLabel label;
1367   __ Beqzc(mips::A0, &label);
1368   for (uint32_t i = 0; i != kNopCount1; ++i) {
1369     __ Nop();
1370   }
1371   __ Bind(&label);
1372   for (uint32_t i = 0; i != kNopCount2; ++i) {
1373     __ Nop();
1374   }
1375   __ Beqzc(mips::A2, &label);
1376 
1377   uint32_t offset_forward = 2 + kNopCount1;  // 2: account for auipc and jic.
1378   offset_forward <<= 2;
1379   offset_forward += (offset_forward & 0x8000) << 1;  // Account for sign extension in jic.
1380 
1381   uint32_t offset_back = -(kNopCount2 + 1);  // 1: account for bnezc.
1382   offset_back <<= 2;
1383   offset_back += (offset_back & 0x8000) << 1;  // Account for sign extension in jic.
1384 
1385   // Note, we're using the ".fill" directive to tell the assembler to generate many NOPs
1386   // instead of generating them ourselves in the source code. This saves test time.
1387   std::ostringstream oss;
1388   oss <<
1389       ".set noreorder\n"
1390       "bnezc $a0, 1f\n"
1391       "auipc $at, 0x" << std::hex << High16Bits(offset_forward) << "\n"
1392       "jic $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n"
1393       "1:\n" <<
1394       ".fill 0x" << std::hex << kNopCount1 << " , 4, 0\n"
1395       "2:\n" <<
1396       ".fill 0x" << std::hex << kNopCount2 << " , 4, 0\n"
1397       "bnezc $a2, 3f\n"
1398       "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
1399       "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n"
1400       "3:\n";
1401   std::string expected = oss.str();
1402   DriverStr(expected, "LongBeqzc");
1403 }
1404 
TEST_F(AssemblerMIPS32r6Test,LongBc)1405 TEST_F(AssemblerMIPS32r6Test, LongBc) {
1406   constexpr uint32_t kNopCount1 = (1u << 25) + 1;
1407   constexpr uint32_t kNopCount2 = (1u << 25) + 1;
1408   constexpr uint32_t kRequiredCapacity = (kNopCount1 + kNopCount2 + 6u) * 4u;
1409   ASSERT_LT(__ GetBuffer()->Capacity(), kRequiredCapacity);
1410   __ GetBuffer()->ExtendCapacity(kRequiredCapacity);
1411   mips::MipsLabel label1, label2;
1412   __ Bc(&label1);
1413   for (uint32_t i = 0; i != kNopCount1; ++i) {
1414     __ Nop();
1415   }
1416   __ Bind(&label1);
1417   __ Bc(&label2);
1418   for (uint32_t i = 0; i != kNopCount2; ++i) {
1419     __ Nop();
1420   }
1421   __ Bind(&label2);
1422   __ Bc(&label1);
1423 
1424   uint32_t offset_forward1 = 2 + kNopCount1;  // 2: account for auipc and jic.
1425   offset_forward1 <<= 2;
1426   offset_forward1 += (offset_forward1 & 0x8000) << 1;  // Account for sign extension in jic.
1427 
1428   uint32_t offset_forward2 = 2 + kNopCount2;  // 2: account for auipc and jic.
1429   offset_forward2 <<= 2;
1430   offset_forward2 += (offset_forward2 & 0x8000) << 1;  // Account for sign extension in jic.
1431 
1432   uint32_t offset_back = -(2 + kNopCount2);  // 2: account for auipc and jic.
1433   offset_back <<= 2;
1434   offset_back += (offset_back & 0x8000) << 1;  // Account for sign extension in jic.
1435 
1436   // Note, we're using the ".fill" directive to tell the assembler to generate many NOPs
1437   // instead of generating them ourselves in the source code. This saves a few minutes
1438   // of test time.
1439   std::ostringstream oss;
1440   oss <<
1441       ".set noreorder\n"
1442       "auipc $at, 0x" << std::hex << High16Bits(offset_forward1) << "\n"
1443       "jic $at, 0x" << std::hex << Low16Bits(offset_forward1) << "\n"
1444       ".fill 0x" << std::hex << kNopCount1 << " , 4, 0\n"
1445       "1:\n"
1446       "auipc $at, 0x" << std::hex << High16Bits(offset_forward2) << "\n"
1447       "jic $at, 0x" << std::hex << Low16Bits(offset_forward2) << "\n"
1448       ".fill 0x" << std::hex << kNopCount2 << " , 4, 0\n"
1449       "2:\n"
1450       "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
1451       "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n";
1452   std::string expected = oss.str();
1453   DriverStr(expected, "LongBc");
1454 }
1455 
TEST_F(AssemblerMIPS32r6Test,ImpossibleReordering)1456 TEST_F(AssemblerMIPS32r6Test, ImpossibleReordering) {
1457   mips::MipsLabel label;
1458   __ SetReorder(true);
1459   __ Bind(&label);
1460 
1461   __ CmpLtD(mips::F0, mips::F2, mips::F4);
1462   __ Bc1nez(mips::F0, &label);  // F0 dependency.
1463 
1464   __ MulD(mips::F10, mips::F2, mips::F4);
1465   __ Bc1eqz(mips::F10, &label);  // F10 dependency.
1466 
1467   std::string expected =
1468       ".set noreorder\n"
1469       "1:\n"
1470 
1471       "cmp.lt.d $f0, $f2, $f4\n"
1472       "bc1nez $f0, 1b\n"
1473       "nop\n"
1474 
1475       "mul.d $f10, $f2, $f4\n"
1476       "bc1eqz $f10, 1b\n"
1477       "nop\n";
1478   DriverStr(expected, "ImpossibleReordering");
1479 }
1480 
TEST_F(AssemblerMIPS32r6Test,Reordering)1481 TEST_F(AssemblerMIPS32r6Test, Reordering) {
1482   mips::MipsLabel label;
1483   __ SetReorder(true);
1484   __ Bind(&label);
1485 
1486   __ CmpLtD(mips::F0, mips::F2, mips::F4);
1487   __ Bc1nez(mips::F2, &label);
1488 
1489   __ MulD(mips::F0, mips::F2, mips::F4);
1490   __ Bc1eqz(mips::F4, &label);
1491 
1492   std::string expected =
1493       ".set noreorder\n"
1494       "1:\n"
1495 
1496       "bc1nez $f2, 1b\n"
1497       "cmp.lt.d $f0, $f2, $f4\n"
1498 
1499       "bc1eqz $f4, 1b\n"
1500       "mul.d $f0, $f2, $f4\n";
1501   DriverStr(expected, "Reordering");
1502 }
1503 
TEST_F(AssemblerMIPS32r6Test,SetReorder)1504 TEST_F(AssemblerMIPS32r6Test, SetReorder) {
1505   mips::MipsLabel label1, label2, label3, label4;
1506 
1507   __ SetReorder(true);
1508   __ Bind(&label1);
1509   __ Addu(mips::T0, mips::T1, mips::T2);
1510   __ Bc1nez(mips::F0, &label1);
1511 
1512   __ SetReorder(false);
1513   __ Bind(&label2);
1514   __ Addu(mips::T0, mips::T1, mips::T2);
1515   __ Bc1nez(mips::F0, &label2);
1516 
1517   __ SetReorder(true);
1518   __ Bind(&label3);
1519   __ Addu(mips::T0, mips::T1, mips::T2);
1520   __ Bc1eqz(mips::F0, &label3);
1521 
1522   __ SetReorder(false);
1523   __ Bind(&label4);
1524   __ Addu(mips::T0, mips::T1, mips::T2);
1525   __ Bc1eqz(mips::F0, &label4);
1526 
1527   std::string expected =
1528       ".set noreorder\n"
1529       "1:\n"
1530       "bc1nez $f0, 1b\n"
1531       "addu $t0, $t1, $t2\n"
1532 
1533       "2:\n"
1534       "addu $t0, $t1, $t2\n"
1535       "bc1nez $f0, 2b\n"
1536       "nop\n"
1537 
1538       "3:\n"
1539       "bc1eqz $f0, 3b\n"
1540       "addu $t0, $t1, $t2\n"
1541 
1542       "4:\n"
1543       "addu $t0, $t1, $t2\n"
1544       "bc1eqz $f0, 4b\n"
1545       "nop\n";
1546   DriverStr(expected, "SetReorder");
1547 }
1548 
TEST_F(AssemblerMIPS32r6Test,ReorderPatchedInstruction)1549 TEST_F(AssemblerMIPS32r6Test, ReorderPatchedInstruction) {
1550   __ SetReorder(true);
1551   mips::MipsLabel label1, label2;
1552   mips::MipsLabel patcher_label1, patcher_label2, patcher_label3, patcher_label4, patcher_label5;
1553   __ Lw(mips::V0, mips::A0, 0x5678, &patcher_label1);
1554   __ Bc1eqz(mips::F0, &label1);
1555   constexpr uint32_t kAdduCount1 = 63;
1556   for (size_t i = 0; i != kAdduCount1; ++i) {
1557     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1558   }
1559   __ Bind(&label1);
1560   __ Sw(mips::V0, mips::A0, 0x5678, &patcher_label2);
1561   __ Bc1nez(mips::F2, &label2);
1562   constexpr uint32_t kAdduCount2 = 64;
1563   for (size_t i = 0; i != kAdduCount2; ++i) {
1564     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1565   }
1566   __ Bind(&label2);
1567   __ Addiu(mips::V0, mips::A0, 0x5678, &patcher_label3);
1568   __ Bc1eqz(mips::F4, &label1);
1569   __ Lw(mips::V0, mips::A0, 0x5678, &patcher_label4);
1570   __ Jalr(mips::T9);
1571   __ Sw(mips::V0, mips::A0, 0x5678, &patcher_label5);
1572   __ Bltc(mips::V0, mips::V1, &label2);
1573   __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1574 
1575   std::string expected =
1576       ".set noreorder\n"
1577       "bc1eqz $f0, 1f\n"
1578       "lw $v0, 0x5678($a0)\n" +
1579       RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
1580       "1:\n"
1581       "bc1nez $f2, 2f\n"
1582       "sw $v0, 0x5678($a0)\n" +
1583       RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
1584       "2:\n"
1585       "bc1eqz $f4, 1b\n"
1586       "addiu $v0, $a0, 0x5678\n"
1587       "jalr $t9\n"
1588       "lw $v0, 0x5678($a0)\n"
1589       "sw $v0, 0x5678($a0)\n"
1590       "bltc $v0, $v1, 2b\n"
1591       "nop\n"
1592       "addu $zero, $zero, $zero\n";
1593   DriverStr(expected, "ReorderPatchedInstruction");
1594   EXPECT_EQ(__ GetLabelLocation(&patcher_label1), 1 * 4u);
1595   EXPECT_EQ(__ GetLabelLocation(&patcher_label2), (kAdduCount1 + 3) * 4u);
1596   EXPECT_EQ(__ GetLabelLocation(&patcher_label3), (kAdduCount1 + kAdduCount2 + 5) * 4u);
1597   EXPECT_EQ(__ GetLabelLocation(&patcher_label4), (kAdduCount1 + kAdduCount2 + 7) * 4u);
1598   EXPECT_EQ(__ GetLabelLocation(&patcher_label5), (kAdduCount1 + kAdduCount2 + 8) * 4u);
1599 }
1600 
TEST_F(AssemblerMIPS32r6Test,LongBranchReorder)1601 TEST_F(AssemblerMIPS32r6Test, LongBranchReorder) {
1602   mips::MipsLabel label, patcher_label1, patcher_label2;
1603   __ SetReorder(true);
1604   __ Addiu(mips::T0, mips::T1, 0x5678, &patcher_label1);
1605   __ Bc1nez(mips::F0, &label);
1606   constexpr uint32_t kAdduCount1 = (1u << 15) + 1;
1607   for (uint32_t i = 0; i != kAdduCount1; ++i) {
1608     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1609   }
1610   __ Bind(&label);
1611   constexpr uint32_t kAdduCount2 = (1u << 15) + 1;
1612   for (uint32_t i = 0; i != kAdduCount2; ++i) {
1613     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1614   }
1615   __ Addiu(mips::T0, mips::T1, 0x5678, &patcher_label2);
1616   __ Bc1eqz(mips::F0, &label);
1617 
1618   uint32_t offset_forward = 2 + kAdduCount1;  // 2: account for auipc and jic.
1619   offset_forward <<= 2;
1620   offset_forward += (offset_forward & 0x8000) << 1;  // Account for sign extension in jic.
1621 
1622   uint32_t offset_back = -(kAdduCount2 + 2);  // 2: account for subu and bc1nez.
1623   offset_back <<= 2;
1624   offset_back += (offset_back & 0x8000) << 1;  // Account for sign extension in jic.
1625 
1626   std::ostringstream oss;
1627   oss <<
1628       ".set noreorder\n"
1629       "addiu $t0, $t1, 0x5678\n"
1630       "bc1eqz $f0, 1f\n"
1631       "auipc $at, 0x" << std::hex << High16Bits(offset_forward) << "\n"
1632       "jic $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n"
1633       "1:\n" <<
1634       RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") <<
1635       "2:\n" <<
1636       RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") <<
1637       "addiu $t0, $t1, 0x5678\n"
1638       "bc1nez $f0, 3f\n"
1639       "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
1640       "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n"
1641       "3:\n";
1642   std::string expected = oss.str();
1643   DriverStr(expected, "LongBranchReorder");
1644   EXPECT_EQ(__ GetLabelLocation(&patcher_label1), 0 * 4u);
1645   EXPECT_EQ(__ GetLabelLocation(&patcher_label2), (kAdduCount1 + kAdduCount2 + 4) * 4u);
1646 }
1647 
1648 ///////////////////////
1649 // Loading Constants //
1650 ///////////////////////
1651 
TEST_F(AssemblerMIPS32r6Test,LoadFarthestNearLabelAddress)1652 TEST_F(AssemblerMIPS32r6Test, LoadFarthestNearLabelAddress) {
1653   mips::MipsLabel label;
1654   __ LoadLabelAddress(mips::V0, mips::ZERO, &label);
1655   constexpr size_t kAdduCount = 0x3FFDE;
1656   for (size_t i = 0; i != kAdduCount; ++i) {
1657     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1658   }
1659   __ Bind(&label);
1660 
1661   std::string expected =
1662       "lapc $v0, 1f\n" +
1663       RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
1664       "1:\n";
1665   DriverStr(expected, "LoadFarthestNearLabelAddress");
1666 }
1667 
TEST_F(AssemblerMIPS32r6Test,LoadNearestFarLabelAddress)1668 TEST_F(AssemblerMIPS32r6Test, LoadNearestFarLabelAddress) {
1669   mips::MipsLabel label;
1670   __ LoadLabelAddress(mips::V0, mips::ZERO, &label);
1671   constexpr size_t kAdduCount = 0x3FFDF;
1672   for (size_t i = 0; i != kAdduCount; ++i) {
1673     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1674   }
1675   __ Bind(&label);
1676 
1677   std::string expected =
1678       "1:\n"
1679       "auipc $at, %hi(2f - 1b)\n"
1680       "addiu $v0, $at, %lo(2f - 1b)\n" +
1681       RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
1682       "2:\n";
1683   DriverStr(expected, "LoadNearestFarLabelAddress");
1684 }
1685 
TEST_F(AssemblerMIPS32r6Test,LoadFarthestNearLiteral)1686 TEST_F(AssemblerMIPS32r6Test, LoadFarthestNearLiteral) {
1687   mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
1688   __ LoadLiteral(mips::V0, mips::ZERO, literal);
1689   constexpr size_t kAdduCount = 0x3FFDE;
1690   for (size_t i = 0; i != kAdduCount; ++i) {
1691     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1692   }
1693 
1694   std::string expected =
1695       "lwpc $v0, 1f\n" +
1696       RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
1697       "1:\n"
1698       ".word 0x12345678\n";
1699   DriverStr(expected, "LoadFarthestNearLiteral");
1700 }
1701 
TEST_F(AssemblerMIPS32r6Test,LoadNearestFarLiteral)1702 TEST_F(AssemblerMIPS32r6Test, LoadNearestFarLiteral) {
1703   mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
1704   __ LoadLiteral(mips::V0, mips::ZERO, literal);
1705   constexpr size_t kAdduCount = 0x3FFDF;
1706   for (size_t i = 0; i != kAdduCount; ++i) {
1707     __ Addu(mips::ZERO, mips::ZERO, mips::ZERO);
1708   }
1709 
1710   std::string expected =
1711       "1:\n"
1712       "auipc $at, %hi(2f - 1b)\n"
1713       "lw $v0, %lo(2f - 1b)($at)\n" +
1714       RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
1715       "2:\n"
1716       ".word 0x12345678\n";
1717   DriverStr(expected, "LoadNearestFarLiteral");
1718 }
1719 
1720 // MSA instructions.
1721 
TEST_F(AssemblerMIPS32r6Test,AndV)1722 TEST_F(AssemblerMIPS32r6Test, AndV) {
1723   DriverStr(RepeatVVV(&mips::MipsAssembler::AndV, "and.v ${reg1}, ${reg2}, ${reg3}"), "and.v");
1724 }
1725 
TEST_F(AssemblerMIPS32r6Test,OrV)1726 TEST_F(AssemblerMIPS32r6Test, OrV) {
1727   DriverStr(RepeatVVV(&mips::MipsAssembler::OrV, "or.v ${reg1}, ${reg2}, ${reg3}"), "or.v");
1728 }
1729 
TEST_F(AssemblerMIPS32r6Test,NorV)1730 TEST_F(AssemblerMIPS32r6Test, NorV) {
1731   DriverStr(RepeatVVV(&mips::MipsAssembler::NorV, "nor.v ${reg1}, ${reg2}, ${reg3}"), "nor.v");
1732 }
1733 
TEST_F(AssemblerMIPS32r6Test,XorV)1734 TEST_F(AssemblerMIPS32r6Test, XorV) {
1735   DriverStr(RepeatVVV(&mips::MipsAssembler::XorV, "xor.v ${reg1}, ${reg2}, ${reg3}"), "xor.v");
1736 }
1737 
TEST_F(AssemblerMIPS32r6Test,AddvB)1738 TEST_F(AssemblerMIPS32r6Test, AddvB) {
1739   DriverStr(RepeatVVV(&mips::MipsAssembler::AddvB, "addv.b ${reg1}, ${reg2}, ${reg3}"), "addv.b");
1740 }
1741 
TEST_F(AssemblerMIPS32r6Test,AddvH)1742 TEST_F(AssemblerMIPS32r6Test, AddvH) {
1743   DriverStr(RepeatVVV(&mips::MipsAssembler::AddvH, "addv.h ${reg1}, ${reg2}, ${reg3}"), "addv.h");
1744 }
1745 
TEST_F(AssemblerMIPS32r6Test,AddvW)1746 TEST_F(AssemblerMIPS32r6Test, AddvW) {
1747   DriverStr(RepeatVVV(&mips::MipsAssembler::AddvW, "addv.w ${reg1}, ${reg2}, ${reg3}"), "addv.w");
1748 }
1749 
TEST_F(AssemblerMIPS32r6Test,AddvD)1750 TEST_F(AssemblerMIPS32r6Test, AddvD) {
1751   DriverStr(RepeatVVV(&mips::MipsAssembler::AddvD, "addv.d ${reg1}, ${reg2}, ${reg3}"), "addv.d");
1752 }
1753 
TEST_F(AssemblerMIPS32r6Test,SubvB)1754 TEST_F(AssemblerMIPS32r6Test, SubvB) {
1755   DriverStr(RepeatVVV(&mips::MipsAssembler::SubvB, "subv.b ${reg1}, ${reg2}, ${reg3}"), "subv.b");
1756 }
1757 
TEST_F(AssemblerMIPS32r6Test,SubvH)1758 TEST_F(AssemblerMIPS32r6Test, SubvH) {
1759   DriverStr(RepeatVVV(&mips::MipsAssembler::SubvH, "subv.h ${reg1}, ${reg2}, ${reg3}"), "subv.h");
1760 }
1761 
TEST_F(AssemblerMIPS32r6Test,SubvW)1762 TEST_F(AssemblerMIPS32r6Test, SubvW) {
1763   DriverStr(RepeatVVV(&mips::MipsAssembler::SubvW, "subv.w ${reg1}, ${reg2}, ${reg3}"), "subv.w");
1764 }
1765 
TEST_F(AssemblerMIPS32r6Test,SubvD)1766 TEST_F(AssemblerMIPS32r6Test, SubvD) {
1767   DriverStr(RepeatVVV(&mips::MipsAssembler::SubvD, "subv.d ${reg1}, ${reg2}, ${reg3}"), "subv.d");
1768 }
1769 
TEST_F(AssemblerMIPS32r6Test,Asub_sB)1770 TEST_F(AssemblerMIPS32r6Test, Asub_sB) {
1771   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_sB, "asub_s.b ${reg1}, ${reg2}, ${reg3}"),
1772             "asub_s.b");
1773 }
1774 
TEST_F(AssemblerMIPS32r6Test,Asub_sH)1775 TEST_F(AssemblerMIPS32r6Test, Asub_sH) {
1776   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_sH, "asub_s.h ${reg1}, ${reg2}, ${reg3}"),
1777             "asub_s.h");
1778 }
1779 
TEST_F(AssemblerMIPS32r6Test,Asub_sW)1780 TEST_F(AssemblerMIPS32r6Test, Asub_sW) {
1781   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_sW, "asub_s.w ${reg1}, ${reg2}, ${reg3}"),
1782             "asub_s.w");
1783 }
1784 
TEST_F(AssemblerMIPS32r6Test,Asub_sD)1785 TEST_F(AssemblerMIPS32r6Test, Asub_sD) {
1786   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_sD, "asub_s.d ${reg1}, ${reg2}, ${reg3}"),
1787             "asub_s.d");
1788 }
1789 
TEST_F(AssemblerMIPS32r6Test,Asub_uB)1790 TEST_F(AssemblerMIPS32r6Test, Asub_uB) {
1791   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_uB, "asub_u.b ${reg1}, ${reg2}, ${reg3}"),
1792             "asub_u.b");
1793 }
1794 
TEST_F(AssemblerMIPS32r6Test,Asub_uH)1795 TEST_F(AssemblerMIPS32r6Test, Asub_uH) {
1796   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_uH, "asub_u.h ${reg1}, ${reg2}, ${reg3}"),
1797             "asub_u.h");
1798 }
1799 
TEST_F(AssemblerMIPS32r6Test,Asub_uW)1800 TEST_F(AssemblerMIPS32r6Test, Asub_uW) {
1801   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_uW, "asub_u.w ${reg1}, ${reg2}, ${reg3}"),
1802             "asub_u.w");
1803 }
1804 
TEST_F(AssemblerMIPS32r6Test,Asub_uD)1805 TEST_F(AssemblerMIPS32r6Test, Asub_uD) {
1806   DriverStr(RepeatVVV(&mips::MipsAssembler::Asub_uD, "asub_u.d ${reg1}, ${reg2}, ${reg3}"),
1807             "asub_u.d");
1808 }
1809 
TEST_F(AssemblerMIPS32r6Test,MulvB)1810 TEST_F(AssemblerMIPS32r6Test, MulvB) {
1811   DriverStr(RepeatVVV(&mips::MipsAssembler::MulvB, "mulv.b ${reg1}, ${reg2}, ${reg3}"), "mulv.b");
1812 }
1813 
TEST_F(AssemblerMIPS32r6Test,MulvH)1814 TEST_F(AssemblerMIPS32r6Test, MulvH) {
1815   DriverStr(RepeatVVV(&mips::MipsAssembler::MulvH, "mulv.h ${reg1}, ${reg2}, ${reg3}"), "mulv.h");
1816 }
1817 
TEST_F(AssemblerMIPS32r6Test,MulvW)1818 TEST_F(AssemblerMIPS32r6Test, MulvW) {
1819   DriverStr(RepeatVVV(&mips::MipsAssembler::MulvW, "mulv.w ${reg1}, ${reg2}, ${reg3}"), "mulv.w");
1820 }
1821 
TEST_F(AssemblerMIPS32r6Test,MulvD)1822 TEST_F(AssemblerMIPS32r6Test, MulvD) {
1823   DriverStr(RepeatVVV(&mips::MipsAssembler::MulvD, "mulv.d ${reg1}, ${reg2}, ${reg3}"), "mulv.d");
1824 }
1825 
TEST_F(AssemblerMIPS32r6Test,Div_sB)1826 TEST_F(AssemblerMIPS32r6Test, Div_sB) {
1827   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_sB, "div_s.b ${reg1}, ${reg2}, ${reg3}"),
1828             "div_s.b");
1829 }
1830 
TEST_F(AssemblerMIPS32r6Test,Div_sH)1831 TEST_F(AssemblerMIPS32r6Test, Div_sH) {
1832   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_sH, "div_s.h ${reg1}, ${reg2}, ${reg3}"),
1833             "div_s.h");
1834 }
1835 
TEST_F(AssemblerMIPS32r6Test,Div_sW)1836 TEST_F(AssemblerMIPS32r6Test, Div_sW) {
1837   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_sW, "div_s.w ${reg1}, ${reg2}, ${reg3}"),
1838             "div_s.w");
1839 }
1840 
TEST_F(AssemblerMIPS32r6Test,Div_sD)1841 TEST_F(AssemblerMIPS32r6Test, Div_sD) {
1842   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_sD, "div_s.d ${reg1}, ${reg2}, ${reg3}"),
1843             "div_s.d");
1844 }
1845 
TEST_F(AssemblerMIPS32r6Test,Div_uB)1846 TEST_F(AssemblerMIPS32r6Test, Div_uB) {
1847   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_uB, "div_u.b ${reg1}, ${reg2}, ${reg3}"),
1848             "div_u.b");
1849 }
1850 
TEST_F(AssemblerMIPS32r6Test,Div_uH)1851 TEST_F(AssemblerMIPS32r6Test, Div_uH) {
1852   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_uH, "div_u.h ${reg1}, ${reg2}, ${reg3}"),
1853             "div_u.h");
1854 }
1855 
TEST_F(AssemblerMIPS32r6Test,Div_uW)1856 TEST_F(AssemblerMIPS32r6Test, Div_uW) {
1857   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_uW, "div_u.w ${reg1}, ${reg2}, ${reg3}"),
1858             "div_u.w");
1859 }
1860 
TEST_F(AssemblerMIPS32r6Test,Div_uD)1861 TEST_F(AssemblerMIPS32r6Test, Div_uD) {
1862   DriverStr(RepeatVVV(&mips::MipsAssembler::Div_uD, "div_u.d ${reg1}, ${reg2}, ${reg3}"),
1863             "div_u.d");
1864 }
1865 
TEST_F(AssemblerMIPS32r6Test,Mod_sB)1866 TEST_F(AssemblerMIPS32r6Test, Mod_sB) {
1867   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_sB, "mod_s.b ${reg1}, ${reg2}, ${reg3}"),
1868             "mod_s.b");
1869 }
1870 
TEST_F(AssemblerMIPS32r6Test,Mod_sH)1871 TEST_F(AssemblerMIPS32r6Test, Mod_sH) {
1872   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_sH, "mod_s.h ${reg1}, ${reg2}, ${reg3}"),
1873             "mod_s.h");
1874 }
1875 
TEST_F(AssemblerMIPS32r6Test,Mod_sW)1876 TEST_F(AssemblerMIPS32r6Test, Mod_sW) {
1877   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_sW, "mod_s.w ${reg1}, ${reg2}, ${reg3}"),
1878             "mod_s.w");
1879 }
1880 
TEST_F(AssemblerMIPS32r6Test,Mod_sD)1881 TEST_F(AssemblerMIPS32r6Test, Mod_sD) {
1882   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_sD, "mod_s.d ${reg1}, ${reg2}, ${reg3}"),
1883             "mod_s.d");
1884 }
1885 
TEST_F(AssemblerMIPS32r6Test,Mod_uB)1886 TEST_F(AssemblerMIPS32r6Test, Mod_uB) {
1887   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_uB, "mod_u.b ${reg1}, ${reg2}, ${reg3}"),
1888             "mod_u.b");
1889 }
1890 
TEST_F(AssemblerMIPS32r6Test,Mod_uH)1891 TEST_F(AssemblerMIPS32r6Test, Mod_uH) {
1892   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_uH, "mod_u.h ${reg1}, ${reg2}, ${reg3}"),
1893             "mod_u.h");
1894 }
1895 
TEST_F(AssemblerMIPS32r6Test,Mod_uW)1896 TEST_F(AssemblerMIPS32r6Test, Mod_uW) {
1897   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_uW, "mod_u.w ${reg1}, ${reg2}, ${reg3}"),
1898             "mod_u.w");
1899 }
1900 
TEST_F(AssemblerMIPS32r6Test,Mod_uD)1901 TEST_F(AssemblerMIPS32r6Test, Mod_uD) {
1902   DriverStr(RepeatVVV(&mips::MipsAssembler::Mod_uD, "mod_u.d ${reg1}, ${reg2}, ${reg3}"),
1903             "mod_u.d");
1904 }
1905 
TEST_F(AssemblerMIPS32r6Test,Add_aB)1906 TEST_F(AssemblerMIPS32r6Test, Add_aB) {
1907   DriverStr(RepeatVVV(&mips::MipsAssembler::Add_aB, "add_a.b ${reg1}, ${reg2}, ${reg3}"),
1908             "add_a.b");
1909 }
1910 
TEST_F(AssemblerMIPS32r6Test,Add_aH)1911 TEST_F(AssemblerMIPS32r6Test, Add_aH) {
1912   DriverStr(RepeatVVV(&mips::MipsAssembler::Add_aH, "add_a.h ${reg1}, ${reg2}, ${reg3}"),
1913             "add_a.h");
1914 }
1915 
TEST_F(AssemblerMIPS32r6Test,Add_aW)1916 TEST_F(AssemblerMIPS32r6Test, Add_aW) {
1917   DriverStr(RepeatVVV(&mips::MipsAssembler::Add_aW, "add_a.w ${reg1}, ${reg2}, ${reg3}"),
1918             "add_a.w");
1919 }
1920 
TEST_F(AssemblerMIPS32r6Test,Add_aD)1921 TEST_F(AssemblerMIPS32r6Test, Add_aD) {
1922   DriverStr(RepeatVVV(&mips::MipsAssembler::Add_aD, "add_a.d ${reg1}, ${reg2}, ${reg3}"),
1923             "add_a.d");
1924 }
1925 
TEST_F(AssemblerMIPS32r6Test,Ave_sB)1926 TEST_F(AssemblerMIPS32r6Test, Ave_sB) {
1927   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_sB, "ave_s.b ${reg1}, ${reg2}, ${reg3}"),
1928             "ave_s.b");
1929 }
1930 
TEST_F(AssemblerMIPS32r6Test,Ave_sH)1931 TEST_F(AssemblerMIPS32r6Test, Ave_sH) {
1932   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_sH, "ave_s.h ${reg1}, ${reg2}, ${reg3}"),
1933             "ave_s.h");
1934 }
1935 
TEST_F(AssemblerMIPS32r6Test,Ave_sW)1936 TEST_F(AssemblerMIPS32r6Test, Ave_sW) {
1937   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_sW, "ave_s.w ${reg1}, ${reg2}, ${reg3}"),
1938             "ave_s.w");
1939 }
1940 
TEST_F(AssemblerMIPS32r6Test,Ave_sD)1941 TEST_F(AssemblerMIPS32r6Test, Ave_sD) {
1942   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_sD, "ave_s.d ${reg1}, ${reg2}, ${reg3}"),
1943             "ave_s.d");
1944 }
1945 
TEST_F(AssemblerMIPS32r6Test,Ave_uB)1946 TEST_F(AssemblerMIPS32r6Test, Ave_uB) {
1947   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_uB, "ave_u.b ${reg1}, ${reg2}, ${reg3}"),
1948             "ave_u.b");
1949 }
1950 
TEST_F(AssemblerMIPS32r6Test,Ave_uH)1951 TEST_F(AssemblerMIPS32r6Test, Ave_uH) {
1952   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_uH, "ave_u.h ${reg1}, ${reg2}, ${reg3}"),
1953             "ave_u.h");
1954 }
1955 
TEST_F(AssemblerMIPS32r6Test,Ave_uW)1956 TEST_F(AssemblerMIPS32r6Test, Ave_uW) {
1957   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_uW, "ave_u.w ${reg1}, ${reg2}, ${reg3}"),
1958             "ave_u.w");
1959 }
1960 
TEST_F(AssemblerMIPS32r6Test,Ave_uD)1961 TEST_F(AssemblerMIPS32r6Test, Ave_uD) {
1962   DriverStr(RepeatVVV(&mips::MipsAssembler::Ave_uD, "ave_u.d ${reg1}, ${reg2}, ${reg3}"),
1963             "ave_u.d");
1964 }
1965 
TEST_F(AssemblerMIPS32r6Test,Aver_sB)1966 TEST_F(AssemblerMIPS32r6Test, Aver_sB) {
1967   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_sB, "aver_s.b ${reg1}, ${reg2}, ${reg3}"),
1968             "aver_s.b");
1969 }
1970 
TEST_F(AssemblerMIPS32r6Test,Aver_sH)1971 TEST_F(AssemblerMIPS32r6Test, Aver_sH) {
1972   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_sH, "aver_s.h ${reg1}, ${reg2}, ${reg3}"),
1973             "aver_s.h");
1974 }
1975 
TEST_F(AssemblerMIPS32r6Test,Aver_sW)1976 TEST_F(AssemblerMIPS32r6Test, Aver_sW) {
1977   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_sW, "aver_s.w ${reg1}, ${reg2}, ${reg3}"),
1978             "aver_s.w");
1979 }
1980 
TEST_F(AssemblerMIPS32r6Test,Aver_sD)1981 TEST_F(AssemblerMIPS32r6Test, Aver_sD) {
1982   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_sD, "aver_s.d ${reg1}, ${reg2}, ${reg3}"),
1983             "aver_s.d");
1984 }
1985 
TEST_F(AssemblerMIPS32r6Test,Aver_uB)1986 TEST_F(AssemblerMIPS32r6Test, Aver_uB) {
1987   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_uB, "aver_u.b ${reg1}, ${reg2}, ${reg3}"),
1988             "aver_u.b");
1989 }
1990 
TEST_F(AssemblerMIPS32r6Test,Aver_uH)1991 TEST_F(AssemblerMIPS32r6Test, Aver_uH) {
1992   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_uH, "aver_u.h ${reg1}, ${reg2}, ${reg3}"),
1993             "aver_u.h");
1994 }
1995 
TEST_F(AssemblerMIPS32r6Test,Aver_uW)1996 TEST_F(AssemblerMIPS32r6Test, Aver_uW) {
1997   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_uW, "aver_u.w ${reg1}, ${reg2}, ${reg3}"),
1998             "aver_u.w");
1999 }
2000 
TEST_F(AssemblerMIPS32r6Test,Aver_uD)2001 TEST_F(AssemblerMIPS32r6Test, Aver_uD) {
2002   DriverStr(RepeatVVV(&mips::MipsAssembler::Aver_uD, "aver_u.d ${reg1}, ${reg2}, ${reg3}"),
2003             "aver_u.d");
2004 }
2005 
TEST_F(AssemblerMIPS32r6Test,Max_sB)2006 TEST_F(AssemblerMIPS32r6Test, Max_sB) {
2007   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_sB, "max_s.b ${reg1}, ${reg2}, ${reg3}"),
2008             "max_s.b");
2009 }
2010 
TEST_F(AssemblerMIPS32r6Test,Max_sH)2011 TEST_F(AssemblerMIPS32r6Test, Max_sH) {
2012   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_sH, "max_s.h ${reg1}, ${reg2}, ${reg3}"),
2013             "max_s.h");
2014 }
2015 
TEST_F(AssemblerMIPS32r6Test,Max_sW)2016 TEST_F(AssemblerMIPS32r6Test, Max_sW) {
2017   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_sW, "max_s.w ${reg1}, ${reg2}, ${reg3}"),
2018             "max_s.w");
2019 }
2020 
TEST_F(AssemblerMIPS32r6Test,Max_sD)2021 TEST_F(AssemblerMIPS32r6Test, Max_sD) {
2022   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_sD, "max_s.d ${reg1}, ${reg2}, ${reg3}"),
2023             "max_s.d");
2024 }
2025 
TEST_F(AssemblerMIPS32r6Test,Max_uB)2026 TEST_F(AssemblerMIPS32r6Test, Max_uB) {
2027   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_uB, "max_u.b ${reg1}, ${reg2}, ${reg3}"),
2028             "max_u.b");
2029 }
2030 
TEST_F(AssemblerMIPS32r6Test,Max_uH)2031 TEST_F(AssemblerMIPS32r6Test, Max_uH) {
2032   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_uH, "max_u.h ${reg1}, ${reg2}, ${reg3}"),
2033             "max_u.h");
2034 }
2035 
TEST_F(AssemblerMIPS32r6Test,Max_uW)2036 TEST_F(AssemblerMIPS32r6Test, Max_uW) {
2037   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_uW, "max_u.w ${reg1}, ${reg2}, ${reg3}"),
2038             "max_u.w");
2039 }
2040 
TEST_F(AssemblerMIPS32r6Test,Max_uD)2041 TEST_F(AssemblerMIPS32r6Test, Max_uD) {
2042   DriverStr(RepeatVVV(&mips::MipsAssembler::Max_uD, "max_u.d ${reg1}, ${reg2}, ${reg3}"),
2043             "max_u.d");
2044 }
2045 
TEST_F(AssemblerMIPS32r6Test,Min_sB)2046 TEST_F(AssemblerMIPS32r6Test, Min_sB) {
2047   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_sB, "min_s.b ${reg1}, ${reg2}, ${reg3}"),
2048             "min_s.b");
2049 }
2050 
TEST_F(AssemblerMIPS32r6Test,Min_sH)2051 TEST_F(AssemblerMIPS32r6Test, Min_sH) {
2052   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_sH, "min_s.h ${reg1}, ${reg2}, ${reg3}"),
2053             "min_s.h");
2054 }
2055 
TEST_F(AssemblerMIPS32r6Test,Min_sW)2056 TEST_F(AssemblerMIPS32r6Test, Min_sW) {
2057   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_sW, "min_s.w ${reg1}, ${reg2}, ${reg3}"),
2058             "min_s.w");
2059 }
2060 
TEST_F(AssemblerMIPS32r6Test,Min_sD)2061 TEST_F(AssemblerMIPS32r6Test, Min_sD) {
2062   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_sD, "min_s.d ${reg1}, ${reg2}, ${reg3}"),
2063             "min_s.d");
2064 }
2065 
TEST_F(AssemblerMIPS32r6Test,Min_uB)2066 TEST_F(AssemblerMIPS32r6Test, Min_uB) {
2067   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_uB, "min_u.b ${reg1}, ${reg2}, ${reg3}"),
2068             "min_u.b");
2069 }
2070 
TEST_F(AssemblerMIPS32r6Test,Min_uH)2071 TEST_F(AssemblerMIPS32r6Test, Min_uH) {
2072   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_uH, "min_u.h ${reg1}, ${reg2}, ${reg3}"),
2073             "min_u.h");
2074 }
2075 
TEST_F(AssemblerMIPS32r6Test,Min_uW)2076 TEST_F(AssemblerMIPS32r6Test, Min_uW) {
2077   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_uW, "min_u.w ${reg1}, ${reg2}, ${reg3}"),
2078             "min_u.w");
2079 }
2080 
TEST_F(AssemblerMIPS32r6Test,Min_uD)2081 TEST_F(AssemblerMIPS32r6Test, Min_uD) {
2082   DriverStr(RepeatVVV(&mips::MipsAssembler::Min_uD, "min_u.d ${reg1}, ${reg2}, ${reg3}"),
2083             "min_u.d");
2084 }
2085 
TEST_F(AssemblerMIPS32r6Test,FaddW)2086 TEST_F(AssemblerMIPS32r6Test, FaddW) {
2087   DriverStr(RepeatVVV(&mips::MipsAssembler::FaddW, "fadd.w ${reg1}, ${reg2}, ${reg3}"), "fadd.w");
2088 }
2089 
TEST_F(AssemblerMIPS32r6Test,FaddD)2090 TEST_F(AssemblerMIPS32r6Test, FaddD) {
2091   DriverStr(RepeatVVV(&mips::MipsAssembler::FaddD, "fadd.d ${reg1}, ${reg2}, ${reg3}"), "fadd.d");
2092 }
2093 
TEST_F(AssemblerMIPS32r6Test,FsubW)2094 TEST_F(AssemblerMIPS32r6Test, FsubW) {
2095   DriverStr(RepeatVVV(&mips::MipsAssembler::FsubW, "fsub.w ${reg1}, ${reg2}, ${reg3}"), "fsub.w");
2096 }
2097 
TEST_F(AssemblerMIPS32r6Test,FsubD)2098 TEST_F(AssemblerMIPS32r6Test, FsubD) {
2099   DriverStr(RepeatVVV(&mips::MipsAssembler::FsubD, "fsub.d ${reg1}, ${reg2}, ${reg3}"), "fsub.d");
2100 }
2101 
TEST_F(AssemblerMIPS32r6Test,FmulW)2102 TEST_F(AssemblerMIPS32r6Test, FmulW) {
2103   DriverStr(RepeatVVV(&mips::MipsAssembler::FmulW, "fmul.w ${reg1}, ${reg2}, ${reg3}"), "fmul.w");
2104 }
2105 
TEST_F(AssemblerMIPS32r6Test,FmulD)2106 TEST_F(AssemblerMIPS32r6Test, FmulD) {
2107   DriverStr(RepeatVVV(&mips::MipsAssembler::FmulD, "fmul.d ${reg1}, ${reg2}, ${reg3}"), "fmul.d");
2108 }
2109 
TEST_F(AssemblerMIPS32r6Test,FdivW)2110 TEST_F(AssemblerMIPS32r6Test, FdivW) {
2111   DriverStr(RepeatVVV(&mips::MipsAssembler::FdivW, "fdiv.w ${reg1}, ${reg2}, ${reg3}"), "fdiv.w");
2112 }
2113 
TEST_F(AssemblerMIPS32r6Test,FdivD)2114 TEST_F(AssemblerMIPS32r6Test, FdivD) {
2115   DriverStr(RepeatVVV(&mips::MipsAssembler::FdivD, "fdiv.d ${reg1}, ${reg2}, ${reg3}"), "fdiv.d");
2116 }
2117 
TEST_F(AssemblerMIPS32r6Test,FmaxW)2118 TEST_F(AssemblerMIPS32r6Test, FmaxW) {
2119   DriverStr(RepeatVVV(&mips::MipsAssembler::FmaxW, "fmax.w ${reg1}, ${reg2}, ${reg3}"), "fmax.w");
2120 }
2121 
TEST_F(AssemblerMIPS32r6Test,FmaxD)2122 TEST_F(AssemblerMIPS32r6Test, FmaxD) {
2123   DriverStr(RepeatVVV(&mips::MipsAssembler::FmaxD, "fmax.d ${reg1}, ${reg2}, ${reg3}"), "fmax.d");
2124 }
2125 
TEST_F(AssemblerMIPS32r6Test,FminW)2126 TEST_F(AssemblerMIPS32r6Test, FminW) {
2127   DriverStr(RepeatVVV(&mips::MipsAssembler::FminW, "fmin.w ${reg1}, ${reg2}, ${reg3}"), "fmin.w");
2128 }
2129 
TEST_F(AssemblerMIPS32r6Test,FminD)2130 TEST_F(AssemblerMIPS32r6Test, FminD) {
2131   DriverStr(RepeatVVV(&mips::MipsAssembler::FminD, "fmin.d ${reg1}, ${reg2}, ${reg3}"), "fmin.d");
2132 }
2133 
TEST_F(AssemblerMIPS32r6Test,Ffint_sW)2134 TEST_F(AssemblerMIPS32r6Test, Ffint_sW) {
2135   DriverStr(RepeatVV(&mips::MipsAssembler::Ffint_sW, "ffint_s.w ${reg1}, ${reg2}"), "ffint_s.w");
2136 }
2137 
TEST_F(AssemblerMIPS32r6Test,Ffint_sD)2138 TEST_F(AssemblerMIPS32r6Test, Ffint_sD) {
2139   DriverStr(RepeatVV(&mips::MipsAssembler::Ffint_sD, "ffint_s.d ${reg1}, ${reg2}"), "ffint_s.d");
2140 }
2141 
TEST_F(AssemblerMIPS32r6Test,Ftint_sW)2142 TEST_F(AssemblerMIPS32r6Test, Ftint_sW) {
2143   DriverStr(RepeatVV(&mips::MipsAssembler::Ftint_sW, "ftint_s.w ${reg1}, ${reg2}"), "ftint_s.w");
2144 }
2145 
TEST_F(AssemblerMIPS32r6Test,Ftint_sD)2146 TEST_F(AssemblerMIPS32r6Test, Ftint_sD) {
2147   DriverStr(RepeatVV(&mips::MipsAssembler::Ftint_sD, "ftint_s.d ${reg1}, ${reg2}"), "ftint_s.d");
2148 }
2149 
TEST_F(AssemblerMIPS32r6Test,SllB)2150 TEST_F(AssemblerMIPS32r6Test, SllB) {
2151   DriverStr(RepeatVVV(&mips::MipsAssembler::SllB, "sll.b ${reg1}, ${reg2}, ${reg3}"), "sll.b");
2152 }
2153 
TEST_F(AssemblerMIPS32r6Test,SllH)2154 TEST_F(AssemblerMIPS32r6Test, SllH) {
2155   DriverStr(RepeatVVV(&mips::MipsAssembler::SllH, "sll.h ${reg1}, ${reg2}, ${reg3}"), "sll.h");
2156 }
2157 
TEST_F(AssemblerMIPS32r6Test,SllW)2158 TEST_F(AssemblerMIPS32r6Test, SllW) {
2159   DriverStr(RepeatVVV(&mips::MipsAssembler::SllW, "sll.w ${reg1}, ${reg2}, ${reg3}"), "sll.w");
2160 }
2161 
TEST_F(AssemblerMIPS32r6Test,SllD)2162 TEST_F(AssemblerMIPS32r6Test, SllD) {
2163   DriverStr(RepeatVVV(&mips::MipsAssembler::SllD, "sll.d ${reg1}, ${reg2}, ${reg3}"), "sll.d");
2164 }
2165 
TEST_F(AssemblerMIPS32r6Test,SraB)2166 TEST_F(AssemblerMIPS32r6Test, SraB) {
2167   DriverStr(RepeatVVV(&mips::MipsAssembler::SraB, "sra.b ${reg1}, ${reg2}, ${reg3}"), "sra.b");
2168 }
2169 
TEST_F(AssemblerMIPS32r6Test,SraH)2170 TEST_F(AssemblerMIPS32r6Test, SraH) {
2171   DriverStr(RepeatVVV(&mips::MipsAssembler::SraH, "sra.h ${reg1}, ${reg2}, ${reg3}"), "sra.h");
2172 }
2173 
TEST_F(AssemblerMIPS32r6Test,SraW)2174 TEST_F(AssemblerMIPS32r6Test, SraW) {
2175   DriverStr(RepeatVVV(&mips::MipsAssembler::SraW, "sra.w ${reg1}, ${reg2}, ${reg3}"), "sra.w");
2176 }
2177 
TEST_F(AssemblerMIPS32r6Test,SraD)2178 TEST_F(AssemblerMIPS32r6Test, SraD) {
2179   DriverStr(RepeatVVV(&mips::MipsAssembler::SraD, "sra.d ${reg1}, ${reg2}, ${reg3}"), "sra.d");
2180 }
2181 
TEST_F(AssemblerMIPS32r6Test,SrlB)2182 TEST_F(AssemblerMIPS32r6Test, SrlB) {
2183   DriverStr(RepeatVVV(&mips::MipsAssembler::SrlB, "srl.b ${reg1}, ${reg2}, ${reg3}"), "srl.b");
2184 }
2185 
TEST_F(AssemblerMIPS32r6Test,SrlH)2186 TEST_F(AssemblerMIPS32r6Test, SrlH) {
2187   DriverStr(RepeatVVV(&mips::MipsAssembler::SrlH, "srl.h ${reg1}, ${reg2}, ${reg3}"), "srl.h");
2188 }
2189 
TEST_F(AssemblerMIPS32r6Test,SrlW)2190 TEST_F(AssemblerMIPS32r6Test, SrlW) {
2191   DriverStr(RepeatVVV(&mips::MipsAssembler::SrlW, "srl.w ${reg1}, ${reg2}, ${reg3}"), "srl.w");
2192 }
2193 
TEST_F(AssemblerMIPS32r6Test,SrlD)2194 TEST_F(AssemblerMIPS32r6Test, SrlD) {
2195   DriverStr(RepeatVVV(&mips::MipsAssembler::SrlD, "srl.d ${reg1}, ${reg2}, ${reg3}"), "srl.d");
2196 }
2197 
TEST_F(AssemblerMIPS32r6Test,SlliB)2198 TEST_F(AssemblerMIPS32r6Test, SlliB) {
2199   DriverStr(RepeatVVIb(&mips::MipsAssembler::SlliB, 3, "slli.b ${reg1}, ${reg2}, {imm}"), "slli.b");
2200 }
2201 
TEST_F(AssemblerMIPS32r6Test,SlliH)2202 TEST_F(AssemblerMIPS32r6Test, SlliH) {
2203   DriverStr(RepeatVVIb(&mips::MipsAssembler::SlliH, 4, "slli.h ${reg1}, ${reg2}, {imm}"), "slli.h");
2204 }
2205 
TEST_F(AssemblerMIPS32r6Test,SlliW)2206 TEST_F(AssemblerMIPS32r6Test, SlliW) {
2207   DriverStr(RepeatVVIb(&mips::MipsAssembler::SlliW, 5, "slli.w ${reg1}, ${reg2}, {imm}"), "slli.w");
2208 }
2209 
TEST_F(AssemblerMIPS32r6Test,SlliD)2210 TEST_F(AssemblerMIPS32r6Test, SlliD) {
2211   DriverStr(RepeatVVIb(&mips::MipsAssembler::SlliD, 6, "slli.d ${reg1}, ${reg2}, {imm}"), "slli.d");
2212 }
2213 
TEST_F(AssemblerMIPS32r6Test,MoveV)2214 TEST_F(AssemblerMIPS32r6Test, MoveV) {
2215   DriverStr(RepeatVV(&mips::MipsAssembler::MoveV, "move.v ${reg1}, ${reg2}"), "move.v");
2216 }
2217 
TEST_F(AssemblerMIPS32r6Test,SplatiB)2218 TEST_F(AssemblerMIPS32r6Test, SplatiB) {
2219   DriverStr(RepeatVVIb(&mips::MipsAssembler::SplatiB, 4, "splati.b ${reg1}, ${reg2}[{imm}]"),
2220             "splati.b");
2221 }
2222 
TEST_F(AssemblerMIPS32r6Test,SplatiH)2223 TEST_F(AssemblerMIPS32r6Test, SplatiH) {
2224   DriverStr(RepeatVVIb(&mips::MipsAssembler::SplatiH, 3, "splati.h ${reg1}, ${reg2}[{imm}]"),
2225             "splati.h");
2226 }
2227 
TEST_F(AssemblerMIPS32r6Test,SplatiW)2228 TEST_F(AssemblerMIPS32r6Test, SplatiW) {
2229   DriverStr(RepeatVVIb(&mips::MipsAssembler::SplatiW, 2, "splati.w ${reg1}, ${reg2}[{imm}]"),
2230             "splati.w");
2231 }
2232 
TEST_F(AssemblerMIPS32r6Test,SplatiD)2233 TEST_F(AssemblerMIPS32r6Test, SplatiD) {
2234   DriverStr(RepeatVVIb(&mips::MipsAssembler::SplatiD, 1, "splati.d ${reg1}, ${reg2}[{imm}]"),
2235             "splati.d");
2236 }
2237 
TEST_F(AssemblerMIPS32r6Test,Copy_sB)2238 TEST_F(AssemblerMIPS32r6Test, Copy_sB) {
2239   DriverStr(RepeatRVIb(&mips::MipsAssembler::Copy_sB, 4, "copy_s.b ${reg1}, ${reg2}[{imm}]"),
2240             "copy_s.b");
2241 }
2242 
TEST_F(AssemblerMIPS32r6Test,Copy_sH)2243 TEST_F(AssemblerMIPS32r6Test, Copy_sH) {
2244   DriverStr(RepeatRVIb(&mips::MipsAssembler::Copy_sH, 3, "copy_s.h ${reg1}, ${reg2}[{imm}]"),
2245             "copy_s.h");
2246 }
2247 
TEST_F(AssemblerMIPS32r6Test,Copy_sW)2248 TEST_F(AssemblerMIPS32r6Test, Copy_sW) {
2249   DriverStr(RepeatRVIb(&mips::MipsAssembler::Copy_sW, 2, "copy_s.w ${reg1}, ${reg2}[{imm}]"),
2250             "copy_s.w");
2251 }
2252 
TEST_F(AssemblerMIPS32r6Test,Copy_uB)2253 TEST_F(AssemblerMIPS32r6Test, Copy_uB) {
2254   DriverStr(RepeatRVIb(&mips::MipsAssembler::Copy_uB, 4, "copy_u.b ${reg1}, ${reg2}[{imm}]"),
2255             "copy_u.b");
2256 }
2257 
TEST_F(AssemblerMIPS32r6Test,Copy_uH)2258 TEST_F(AssemblerMIPS32r6Test, Copy_uH) {
2259   DriverStr(RepeatRVIb(&mips::MipsAssembler::Copy_uH, 3, "copy_u.h ${reg1}, ${reg2}[{imm}]"),
2260             "copy_u.h");
2261 }
2262 
TEST_F(AssemblerMIPS32r6Test,InsertB)2263 TEST_F(AssemblerMIPS32r6Test, InsertB) {
2264   DriverStr(RepeatVRIb(&mips::MipsAssembler::InsertB, 4, "insert.b ${reg1}[{imm}], ${reg2}"),
2265             "insert.b");
2266 }
2267 
TEST_F(AssemblerMIPS32r6Test,InsertH)2268 TEST_F(AssemblerMIPS32r6Test, InsertH) {
2269   DriverStr(RepeatVRIb(&mips::MipsAssembler::InsertH, 3, "insert.h ${reg1}[{imm}], ${reg2}"),
2270             "insert.h");
2271 }
2272 
TEST_F(AssemblerMIPS32r6Test,InsertW)2273 TEST_F(AssemblerMIPS32r6Test, InsertW) {
2274   DriverStr(RepeatVRIb(&mips::MipsAssembler::InsertW, 2, "insert.w ${reg1}[{imm}], ${reg2}"),
2275             "insert.w");
2276 }
2277 
TEST_F(AssemblerMIPS32r6Test,FillB)2278 TEST_F(AssemblerMIPS32r6Test, FillB) {
2279   DriverStr(RepeatVR(&mips::MipsAssembler::FillB, "fill.b ${reg1}, ${reg2}"), "fill.b");
2280 }
2281 
TEST_F(AssemblerMIPS32r6Test,FillH)2282 TEST_F(AssemblerMIPS32r6Test, FillH) {
2283   DriverStr(RepeatVR(&mips::MipsAssembler::FillH, "fill.h ${reg1}, ${reg2}"), "fill.h");
2284 }
2285 
TEST_F(AssemblerMIPS32r6Test,FillW)2286 TEST_F(AssemblerMIPS32r6Test, FillW) {
2287   DriverStr(RepeatVR(&mips::MipsAssembler::FillW, "fill.w ${reg1}, ${reg2}"), "fill.w");
2288 }
2289 
TEST_F(AssemblerMIPS32r6Test,PcntB)2290 TEST_F(AssemblerMIPS32r6Test, PcntB) {
2291   DriverStr(RepeatVV(&mips::MipsAssembler::PcntB, "pcnt.b ${reg1}, ${reg2}"), "pcnt.b");
2292 }
2293 
TEST_F(AssemblerMIPS32r6Test,PcntH)2294 TEST_F(AssemblerMIPS32r6Test, PcntH) {
2295   DriverStr(RepeatVV(&mips::MipsAssembler::PcntH, "pcnt.h ${reg1}, ${reg2}"), "pcnt.h");
2296 }
2297 
TEST_F(AssemblerMIPS32r6Test,PcntW)2298 TEST_F(AssemblerMIPS32r6Test, PcntW) {
2299   DriverStr(RepeatVV(&mips::MipsAssembler::PcntW, "pcnt.w ${reg1}, ${reg2}"), "pcnt.w");
2300 }
2301 
TEST_F(AssemblerMIPS32r6Test,PcntD)2302 TEST_F(AssemblerMIPS32r6Test, PcntD) {
2303   DriverStr(RepeatVV(&mips::MipsAssembler::PcntD, "pcnt.d ${reg1}, ${reg2}"), "pcnt.d");
2304 }
2305 
TEST_F(AssemblerMIPS32r6Test,LdiB)2306 TEST_F(AssemblerMIPS32r6Test, LdiB) {
2307   DriverStr(RepeatVIb(&mips::MipsAssembler::LdiB, -8, "ldi.b ${reg}, {imm}"), "ldi.b");
2308 }
2309 
TEST_F(AssemblerMIPS32r6Test,LdiH)2310 TEST_F(AssemblerMIPS32r6Test, LdiH) {
2311   DriverStr(RepeatVIb(&mips::MipsAssembler::LdiH, -10, "ldi.h ${reg}, {imm}"), "ldi.h");
2312 }
2313 
TEST_F(AssemblerMIPS32r6Test,LdiW)2314 TEST_F(AssemblerMIPS32r6Test, LdiW) {
2315   DriverStr(RepeatVIb(&mips::MipsAssembler::LdiW, -10, "ldi.w ${reg}, {imm}"), "ldi.w");
2316 }
2317 
TEST_F(AssemblerMIPS32r6Test,LdiD)2318 TEST_F(AssemblerMIPS32r6Test, LdiD) {
2319   DriverStr(RepeatVIb(&mips::MipsAssembler::LdiD, -10, "ldi.d ${reg}, {imm}"), "ldi.d");
2320 }
2321 
TEST_F(AssemblerMIPS32r6Test,LdB)2322 TEST_F(AssemblerMIPS32r6Test, LdB) {
2323   DriverStr(RepeatVRIb(&mips::MipsAssembler::LdB, -10, "ld.b ${reg1}, {imm}(${reg2})"), "ld.b");
2324 }
2325 
TEST_F(AssemblerMIPS32r6Test,LdH)2326 TEST_F(AssemblerMIPS32r6Test, LdH) {
2327   DriverStr(RepeatVRIb(&mips::MipsAssembler::LdH, -10, "ld.h ${reg1}, {imm}(${reg2})", 0, 2),
2328             "ld.h");
2329 }
2330 
TEST_F(AssemblerMIPS32r6Test,LdW)2331 TEST_F(AssemblerMIPS32r6Test, LdW) {
2332   DriverStr(RepeatVRIb(&mips::MipsAssembler::LdW, -10, "ld.w ${reg1}, {imm}(${reg2})", 0, 4),
2333             "ld.w");
2334 }
2335 
TEST_F(AssemblerMIPS32r6Test,LdD)2336 TEST_F(AssemblerMIPS32r6Test, LdD) {
2337   DriverStr(RepeatVRIb(&mips::MipsAssembler::LdD, -10, "ld.d ${reg1}, {imm}(${reg2})", 0, 8),
2338             "ld.d");
2339 }
2340 
TEST_F(AssemblerMIPS32r6Test,StB)2341 TEST_F(AssemblerMIPS32r6Test, StB) {
2342   DriverStr(RepeatVRIb(&mips::MipsAssembler::StB, -10, "st.b ${reg1}, {imm}(${reg2})"), "st.b");
2343 }
2344 
TEST_F(AssemblerMIPS32r6Test,StH)2345 TEST_F(AssemblerMIPS32r6Test, StH) {
2346   DriverStr(RepeatVRIb(&mips::MipsAssembler::StH, -10, "st.h ${reg1}, {imm}(${reg2})", 0, 2),
2347             "st.h");
2348 }
2349 
TEST_F(AssemblerMIPS32r6Test,StW)2350 TEST_F(AssemblerMIPS32r6Test, StW) {
2351   DriverStr(RepeatVRIb(&mips::MipsAssembler::StW, -10, "st.w ${reg1}, {imm}(${reg2})", 0, 4),
2352             "st.w");
2353 }
2354 
TEST_F(AssemblerMIPS32r6Test,StD)2355 TEST_F(AssemblerMIPS32r6Test, StD) {
2356   DriverStr(RepeatVRIb(&mips::MipsAssembler::StD, -10, "st.d ${reg1}, {imm}(${reg2})", 0, 8),
2357             "st.d");
2358 }
2359 
TEST_F(AssemblerMIPS32r6Test,IlvlB)2360 TEST_F(AssemblerMIPS32r6Test, IlvlB) {
2361   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvlB, "ilvl.b ${reg1}, ${reg2}, ${reg3}"), "ilvl.b");
2362 }
2363 
TEST_F(AssemblerMIPS32r6Test,IlvlH)2364 TEST_F(AssemblerMIPS32r6Test, IlvlH) {
2365   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvlH, "ilvl.h ${reg1}, ${reg2}, ${reg3}"), "ilvl.h");
2366 }
2367 
TEST_F(AssemblerMIPS32r6Test,IlvlW)2368 TEST_F(AssemblerMIPS32r6Test, IlvlW) {
2369   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvlW, "ilvl.w ${reg1}, ${reg2}, ${reg3}"), "ilvl.w");
2370 }
2371 
TEST_F(AssemblerMIPS32r6Test,IlvlD)2372 TEST_F(AssemblerMIPS32r6Test, IlvlD) {
2373   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvlD, "ilvl.d ${reg1}, ${reg2}, ${reg3}"), "ilvl.d");
2374 }
2375 
TEST_F(AssemblerMIPS32r6Test,IlvrB)2376 TEST_F(AssemblerMIPS32r6Test, IlvrB) {
2377   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvrB, "ilvr.b ${reg1}, ${reg2}, ${reg3}"), "ilvr.b");
2378 }
2379 
TEST_F(AssemblerMIPS32r6Test,IlvrH)2380 TEST_F(AssemblerMIPS32r6Test, IlvrH) {
2381   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvrH, "ilvr.h ${reg1}, ${reg2}, ${reg3}"), "ilvr.h");
2382 }
2383 
TEST_F(AssemblerMIPS32r6Test,IlvrW)2384 TEST_F(AssemblerMIPS32r6Test, IlvrW) {
2385   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvrW, "ilvr.w ${reg1}, ${reg2}, ${reg3}"), "ilvr.w");
2386 }
2387 
TEST_F(AssemblerMIPS32r6Test,IlvrD)2388 TEST_F(AssemblerMIPS32r6Test, IlvrD) {
2389   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvrD, "ilvr.d ${reg1}, ${reg2}, ${reg3}"), "ilvr.d");
2390 }
2391 
TEST_F(AssemblerMIPS32r6Test,IlvevB)2392 TEST_F(AssemblerMIPS32r6Test, IlvevB) {
2393   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvevB, "ilvev.b ${reg1}, ${reg2}, ${reg3}"),
2394             "ilvev.b");
2395 }
2396 
TEST_F(AssemblerMIPS32r6Test,IlvevH)2397 TEST_F(AssemblerMIPS32r6Test, IlvevH) {
2398   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvevH, "ilvev.h ${reg1}, ${reg2}, ${reg3}"),
2399             "ilvev.h");
2400 }
2401 
TEST_F(AssemblerMIPS32r6Test,IlvevW)2402 TEST_F(AssemblerMIPS32r6Test, IlvevW) {
2403   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvevW, "ilvev.w ${reg1}, ${reg2}, ${reg3}"),
2404             "ilvev.w");
2405 }
2406 
TEST_F(AssemblerMIPS32r6Test,IlvevD)2407 TEST_F(AssemblerMIPS32r6Test, IlvevD) {
2408   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvevD, "ilvev.d ${reg1}, ${reg2}, ${reg3}"),
2409             "ilvev.d");
2410 }
2411 
TEST_F(AssemblerMIPS32r6Test,IlvodB)2412 TEST_F(AssemblerMIPS32r6Test, IlvodB) {
2413   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvodB, "ilvod.b ${reg1}, ${reg2}, ${reg3}"),
2414             "ilvod.b");
2415 }
2416 
TEST_F(AssemblerMIPS32r6Test,IlvodH)2417 TEST_F(AssemblerMIPS32r6Test, IlvodH) {
2418   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvodH, "ilvod.h ${reg1}, ${reg2}, ${reg3}"),
2419             "ilvod.h");
2420 }
2421 
TEST_F(AssemblerMIPS32r6Test,IlvodW)2422 TEST_F(AssemblerMIPS32r6Test, IlvodW) {
2423   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvodW, "ilvod.w ${reg1}, ${reg2}, ${reg3}"),
2424             "ilvod.w");
2425 }
2426 
TEST_F(AssemblerMIPS32r6Test,IlvodD)2427 TEST_F(AssemblerMIPS32r6Test, IlvodD) {
2428   DriverStr(RepeatVVV(&mips::MipsAssembler::IlvodD, "ilvod.d ${reg1}, ${reg2}, ${reg3}"),
2429             "ilvod.d");
2430 }
2431 
TEST_F(AssemblerMIPS32r6Test,MaddvB)2432 TEST_F(AssemblerMIPS32r6Test, MaddvB) {
2433   DriverStr(RepeatVVV(&mips::MipsAssembler::MaddvB, "maddv.b ${reg1}, ${reg2}, ${reg3}"),
2434             "maddv.b");
2435 }
2436 
TEST_F(AssemblerMIPS32r6Test,MaddvH)2437 TEST_F(AssemblerMIPS32r6Test, MaddvH) {
2438   DriverStr(RepeatVVV(&mips::MipsAssembler::MaddvH, "maddv.h ${reg1}, ${reg2}, ${reg3}"),
2439             "maddv.h");
2440 }
2441 
TEST_F(AssemblerMIPS32r6Test,MaddvW)2442 TEST_F(AssemblerMIPS32r6Test, MaddvW) {
2443   DriverStr(RepeatVVV(&mips::MipsAssembler::MaddvW, "maddv.w ${reg1}, ${reg2}, ${reg3}"),
2444             "maddv.w");
2445 }
2446 
TEST_F(AssemblerMIPS32r6Test,MaddvD)2447 TEST_F(AssemblerMIPS32r6Test, MaddvD) {
2448   DriverStr(RepeatVVV(&mips::MipsAssembler::MaddvD, "maddv.d ${reg1}, ${reg2}, ${reg3}"),
2449             "maddv.d");
2450 }
2451 
TEST_F(AssemblerMIPS32r6Test,Hadd_sH)2452 TEST_F(AssemblerMIPS32r6Test, Hadd_sH) {
2453   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_sH, "hadd_s.h ${reg1}, ${reg2}, ${reg3}"),
2454             "hadd_s.h");
2455 }
2456 
TEST_F(AssemblerMIPS32r6Test,Hadd_sW)2457 TEST_F(AssemblerMIPS32r6Test, Hadd_sW) {
2458   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_sW, "hadd_s.w ${reg1}, ${reg2}, ${reg3}"),
2459             "hadd_s.w");
2460 }
2461 
TEST_F(AssemblerMIPS32r6Test,Hadd_sD)2462 TEST_F(AssemblerMIPS32r6Test, Hadd_sD) {
2463   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_sD, "hadd_s.d ${reg1}, ${reg2}, ${reg3}"),
2464             "hadd_s.d");
2465 }
2466 
TEST_F(AssemblerMIPS32r6Test,Hadd_uH)2467 TEST_F(AssemblerMIPS32r6Test, Hadd_uH) {
2468   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_uH, "hadd_u.h ${reg1}, ${reg2}, ${reg3}"),
2469             "hadd_u.h");
2470 }
2471 
TEST_F(AssemblerMIPS32r6Test,Hadd_uW)2472 TEST_F(AssemblerMIPS32r6Test, Hadd_uW) {
2473   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_uW, "hadd_u.w ${reg1}, ${reg2}, ${reg3}"),
2474             "hadd_u.w");
2475 }
2476 
TEST_F(AssemblerMIPS32r6Test,Hadd_uD)2477 TEST_F(AssemblerMIPS32r6Test, Hadd_uD) {
2478   DriverStr(RepeatVVV(&mips::MipsAssembler::Hadd_uD, "hadd_u.d ${reg1}, ${reg2}, ${reg3}"),
2479             "hadd_u.d");
2480 }
2481 
TEST_F(AssemblerMIPS32r6Test,MsubvB)2482 TEST_F(AssemblerMIPS32r6Test, MsubvB) {
2483   DriverStr(RepeatVVV(&mips::MipsAssembler::MsubvB, "msubv.b ${reg1}, ${reg2}, ${reg3}"),
2484             "msubv.b");
2485 }
2486 
TEST_F(AssemblerMIPS32r6Test,MsubvH)2487 TEST_F(AssemblerMIPS32r6Test, MsubvH) {
2488   DriverStr(RepeatVVV(&mips::MipsAssembler::MsubvH, "msubv.h ${reg1}, ${reg2}, ${reg3}"),
2489             "msubv.h");
2490 }
2491 
TEST_F(AssemblerMIPS32r6Test,MsubvW)2492 TEST_F(AssemblerMIPS32r6Test, MsubvW) {
2493   DriverStr(RepeatVVV(&mips::MipsAssembler::MsubvW, "msubv.w ${reg1}, ${reg2}, ${reg3}"),
2494             "msubv.w");
2495 }
2496 
TEST_F(AssemblerMIPS32r6Test,MsubvD)2497 TEST_F(AssemblerMIPS32r6Test, MsubvD) {
2498   DriverStr(RepeatVVV(&mips::MipsAssembler::MsubvD, "msubv.d ${reg1}, ${reg2}, ${reg3}"),
2499             "msubv.d");
2500 }
2501 
TEST_F(AssemblerMIPS32r6Test,FmaddW)2502 TEST_F(AssemblerMIPS32r6Test, FmaddW) {
2503   DriverStr(RepeatVVV(&mips::MipsAssembler::FmaddW, "fmadd.w ${reg1}, ${reg2}, ${reg3}"),
2504             "fmadd.w");
2505 }
2506 
TEST_F(AssemblerMIPS32r6Test,FmaddD)2507 TEST_F(AssemblerMIPS32r6Test, FmaddD) {
2508   DriverStr(RepeatVVV(&mips::MipsAssembler::FmaddD, "fmadd.d ${reg1}, ${reg2}, ${reg3}"),
2509             "fmadd.d");
2510 }
2511 
TEST_F(AssemblerMIPS32r6Test,FmsubW)2512 TEST_F(AssemblerMIPS32r6Test, FmsubW) {
2513   DriverStr(RepeatVVV(&mips::MipsAssembler::FmsubW, "fmsub.w ${reg1}, ${reg2}, ${reg3}"),
2514             "fmsub.w");
2515 }
2516 
TEST_F(AssemblerMIPS32r6Test,FmsubD)2517 TEST_F(AssemblerMIPS32r6Test, FmsubD) {
2518   DriverStr(RepeatVVV(&mips::MipsAssembler::FmsubD, "fmsub.d ${reg1}, ${reg2}, ${reg3}"),
2519             "fmsub.d");
2520 }
2521 
2522 #undef __
2523 
2524 }  // namespace art
2525