blob: 31d3e4c33baaa41ca6f19a7a7b6bc003a5f8aa95 [file] [log] [blame]
Chris Larsendbce0d72015-09-17 13:34:00 -07001/*
2 * Copyright (C) 2015 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_mips64.h"
18
19#include <inttypes.h>
20#include <map>
21#include <random>
22
23#include "base/bit_utils.h"
24#include "base/stl_util.h"
25#include "utils/assembler_test.h"
26
Alexey Frunzea0e87b02015-09-24 22:57:20 -070027#define __ GetAssembler()->
28
Chris Larsendbce0d72015-09-17 13:34:00 -070029namespace art {
30
31struct MIPS64CpuRegisterCompare {
32 bool operator()(const mips64::GpuRegister& a, const mips64::GpuRegister& b) const {
33 return a < b;
34 }
35};
36
37class AssemblerMIPS64Test : public AssemblerTest<mips64::Mips64Assembler,
38 mips64::GpuRegister,
39 mips64::FpuRegister,
40 uint32_t> {
41 public:
42 typedef AssemblerTest<mips64::Mips64Assembler,
43 mips64::GpuRegister,
44 mips64::FpuRegister,
45 uint32_t> Base;
46
47 protected:
48 // Get the typically used name for this architecture, e.g., aarch64, x86-64, ...
49 std::string GetArchitectureString() OVERRIDE {
50 return "mips64";
51 }
52
Alexey Frunzea0e87b02015-09-24 22:57:20 -070053 std::string GetAssemblerCmdName() OVERRIDE {
54 // We assemble and link for MIPS64R6. See GetAssemblerParameters() for details.
55 return "gcc";
56 }
57
Chris Larsendbce0d72015-09-17 13:34:00 -070058 std::string GetAssemblerParameters() OVERRIDE {
Alexey Frunzea0e87b02015-09-24 22:57:20 -070059 // We assemble and link for MIPS64R6. The reason is that object files produced for MIPS64R6
60 // (and MIPS32R6) with the GNU assembler don't have correct final offsets in PC-relative
61 // branches in the .text section and so they require a relocation pass (there's a relocation
62 // section, .rela.text, that has the needed info to fix up the branches).
63 return " -march=mips64r6 -Wa,--no-warn -Wl,-Ttext=0 -Wl,-e0 -nostdlib";
64 }
65
66 void Pad(std::vector<uint8_t>& data) OVERRIDE {
67 // The GNU linker unconditionally pads the code segment with NOPs to a size that is a multiple
68 // of 16 and there doesn't appear to be a way to suppress this padding. Our assembler doesn't
69 // pad, so, in order for two assembler outputs to match, we need to match the padding as well.
70 // NOP is encoded as four zero bytes on MIPS.
71 size_t pad_size = RoundUp(data.size(), 16u) - data.size();
72 data.insert(data.end(), pad_size, 0);
Chris Larsendbce0d72015-09-17 13:34:00 -070073 }
74
75 std::string GetDisassembleParameters() OVERRIDE {
76 return " -D -bbinary -mmips:isa64r6";
77 }
78
79 void SetUpHelpers() OVERRIDE {
80 if (registers_.size() == 0) {
81 registers_.push_back(new mips64::GpuRegister(mips64::ZERO));
82 registers_.push_back(new mips64::GpuRegister(mips64::AT));
83 registers_.push_back(new mips64::GpuRegister(mips64::V0));
84 registers_.push_back(new mips64::GpuRegister(mips64::V1));
85 registers_.push_back(new mips64::GpuRegister(mips64::A0));
86 registers_.push_back(new mips64::GpuRegister(mips64::A1));
87 registers_.push_back(new mips64::GpuRegister(mips64::A2));
88 registers_.push_back(new mips64::GpuRegister(mips64::A3));
89 registers_.push_back(new mips64::GpuRegister(mips64::A4));
90 registers_.push_back(new mips64::GpuRegister(mips64::A5));
91 registers_.push_back(new mips64::GpuRegister(mips64::A6));
92 registers_.push_back(new mips64::GpuRegister(mips64::A7));
93 registers_.push_back(new mips64::GpuRegister(mips64::T0));
94 registers_.push_back(new mips64::GpuRegister(mips64::T1));
95 registers_.push_back(new mips64::GpuRegister(mips64::T2));
96 registers_.push_back(new mips64::GpuRegister(mips64::T3));
97 registers_.push_back(new mips64::GpuRegister(mips64::S0));
98 registers_.push_back(new mips64::GpuRegister(mips64::S1));
99 registers_.push_back(new mips64::GpuRegister(mips64::S2));
100 registers_.push_back(new mips64::GpuRegister(mips64::S3));
101 registers_.push_back(new mips64::GpuRegister(mips64::S4));
102 registers_.push_back(new mips64::GpuRegister(mips64::S5));
103 registers_.push_back(new mips64::GpuRegister(mips64::S6));
104 registers_.push_back(new mips64::GpuRegister(mips64::S7));
105 registers_.push_back(new mips64::GpuRegister(mips64::T8));
106 registers_.push_back(new mips64::GpuRegister(mips64::T9));
107 registers_.push_back(new mips64::GpuRegister(mips64::K0));
108 registers_.push_back(new mips64::GpuRegister(mips64::K1));
109 registers_.push_back(new mips64::GpuRegister(mips64::GP));
110 registers_.push_back(new mips64::GpuRegister(mips64::SP));
111 registers_.push_back(new mips64::GpuRegister(mips64::S8));
112 registers_.push_back(new mips64::GpuRegister(mips64::RA));
113
114 secondary_register_names_.emplace(mips64::GpuRegister(mips64::ZERO), "zero");
115 secondary_register_names_.emplace(mips64::GpuRegister(mips64::AT), "at");
116 secondary_register_names_.emplace(mips64::GpuRegister(mips64::V0), "v0");
117 secondary_register_names_.emplace(mips64::GpuRegister(mips64::V1), "v1");
118 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A0), "a0");
119 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A1), "a1");
120 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A2), "a2");
121 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A3), "a3");
122 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A4), "a4");
123 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A5), "a5");
124 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A6), "a6");
125 secondary_register_names_.emplace(mips64::GpuRegister(mips64::A7), "a7");
126 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T0), "t0");
127 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T1), "t1");
128 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T2), "t2");
129 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T3), "t3");
130 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S0), "s0");
131 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S1), "s1");
132 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S2), "s2");
133 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S3), "s3");
134 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S4), "s4");
135 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S5), "s5");
136 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S6), "s6");
137 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S7), "s7");
138 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T8), "t8");
139 secondary_register_names_.emplace(mips64::GpuRegister(mips64::T9), "t9");
140 secondary_register_names_.emplace(mips64::GpuRegister(mips64::K0), "k0");
141 secondary_register_names_.emplace(mips64::GpuRegister(mips64::K1), "k1");
142 secondary_register_names_.emplace(mips64::GpuRegister(mips64::GP), "gp");
143 secondary_register_names_.emplace(mips64::GpuRegister(mips64::SP), "sp");
144 secondary_register_names_.emplace(mips64::GpuRegister(mips64::S8), "s8");
145 secondary_register_names_.emplace(mips64::GpuRegister(mips64::RA), "ra");
146
147 fp_registers_.push_back(new mips64::FpuRegister(mips64::F0));
148 fp_registers_.push_back(new mips64::FpuRegister(mips64::F1));
149 fp_registers_.push_back(new mips64::FpuRegister(mips64::F2));
150 fp_registers_.push_back(new mips64::FpuRegister(mips64::F3));
151 fp_registers_.push_back(new mips64::FpuRegister(mips64::F4));
152 fp_registers_.push_back(new mips64::FpuRegister(mips64::F5));
153 fp_registers_.push_back(new mips64::FpuRegister(mips64::F6));
154 fp_registers_.push_back(new mips64::FpuRegister(mips64::F7));
155 fp_registers_.push_back(new mips64::FpuRegister(mips64::F8));
156 fp_registers_.push_back(new mips64::FpuRegister(mips64::F9));
157 fp_registers_.push_back(new mips64::FpuRegister(mips64::F10));
158 fp_registers_.push_back(new mips64::FpuRegister(mips64::F11));
159 fp_registers_.push_back(new mips64::FpuRegister(mips64::F12));
160 fp_registers_.push_back(new mips64::FpuRegister(mips64::F13));
161 fp_registers_.push_back(new mips64::FpuRegister(mips64::F14));
162 fp_registers_.push_back(new mips64::FpuRegister(mips64::F15));
163 fp_registers_.push_back(new mips64::FpuRegister(mips64::F16));
164 fp_registers_.push_back(new mips64::FpuRegister(mips64::F17));
165 fp_registers_.push_back(new mips64::FpuRegister(mips64::F18));
166 fp_registers_.push_back(new mips64::FpuRegister(mips64::F19));
167 fp_registers_.push_back(new mips64::FpuRegister(mips64::F20));
168 fp_registers_.push_back(new mips64::FpuRegister(mips64::F21));
169 fp_registers_.push_back(new mips64::FpuRegister(mips64::F22));
170 fp_registers_.push_back(new mips64::FpuRegister(mips64::F23));
171 fp_registers_.push_back(new mips64::FpuRegister(mips64::F24));
172 fp_registers_.push_back(new mips64::FpuRegister(mips64::F25));
173 fp_registers_.push_back(new mips64::FpuRegister(mips64::F26));
174 fp_registers_.push_back(new mips64::FpuRegister(mips64::F27));
175 fp_registers_.push_back(new mips64::FpuRegister(mips64::F28));
176 fp_registers_.push_back(new mips64::FpuRegister(mips64::F29));
177 fp_registers_.push_back(new mips64::FpuRegister(mips64::F30));
178 fp_registers_.push_back(new mips64::FpuRegister(mips64::F31));
179 }
180 }
181
182 void TearDown() OVERRIDE {
183 AssemblerTest::TearDown();
184 STLDeleteElements(&registers_);
185 STLDeleteElements(&fp_registers_);
186 }
187
188 std::vector<mips64::GpuRegister*> GetRegisters() OVERRIDE {
189 return registers_;
190 }
191
192 std::vector<mips64::FpuRegister*> GetFPRegisters() OVERRIDE {
193 return fp_registers_;
194 }
195
196 uint32_t CreateImmediate(int64_t imm_value) OVERRIDE {
197 return imm_value;
198 }
199
200 std::string GetSecondaryRegisterName(const mips64::GpuRegister& reg) OVERRIDE {
201 CHECK(secondary_register_names_.find(reg) != secondary_register_names_.end());
202 return secondary_register_names_[reg];
203 }
204
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700205 std::string RepeatInsn(size_t count, const std::string& insn) {
206 std::string result;
207 for (; count != 0u; --count) {
208 result += insn;
209 }
210 return result;
211 }
212
213 void BranchCondOneRegHelper(void (mips64::Mips64Assembler::*f)(mips64::GpuRegister,
214 mips64::Mips64Label*),
Andreas Gampe2e965ac2016-11-03 17:24:15 -0700215 const std::string& instr_name) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700216 mips64::Mips64Label label;
217 (Base::GetAssembler()->*f)(mips64::A0, &label);
218 constexpr size_t kAdduCount1 = 63;
219 for (size_t i = 0; i != kAdduCount1; ++i) {
220 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
221 }
222 __ Bind(&label);
223 constexpr size_t kAdduCount2 = 64;
224 for (size_t i = 0; i != kAdduCount2; ++i) {
225 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
226 }
227 (Base::GetAssembler()->*f)(mips64::A1, &label);
228
229 std::string expected =
230 ".set noreorder\n" +
231 instr_name + " $a0, 1f\n"
232 "nop\n" +
233 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
234 "1:\n" +
235 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
236 instr_name + " $a1, 1b\n"
237 "nop\n";
238 DriverStr(expected, instr_name);
239 }
240
241 void BranchCondTwoRegsHelper(void (mips64::Mips64Assembler::*f)(mips64::GpuRegister,
242 mips64::GpuRegister,
243 mips64::Mips64Label*),
Andreas Gampe2e965ac2016-11-03 17:24:15 -0700244 const std::string& instr_name) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700245 mips64::Mips64Label label;
246 (Base::GetAssembler()->*f)(mips64::A0, mips64::A1, &label);
247 constexpr size_t kAdduCount1 = 63;
248 for (size_t i = 0; i != kAdduCount1; ++i) {
249 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
250 }
251 __ Bind(&label);
252 constexpr size_t kAdduCount2 = 64;
253 for (size_t i = 0; i != kAdduCount2; ++i) {
254 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
255 }
256 (Base::GetAssembler()->*f)(mips64::A2, mips64::A3, &label);
257
258 std::string expected =
259 ".set noreorder\n" +
260 instr_name + " $a0, $a1, 1f\n"
261 "nop\n" +
262 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
263 "1:\n" +
264 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
265 instr_name + " $a2, $a3, 1b\n"
266 "nop\n";
267 DriverStr(expected, instr_name);
268 }
269
Chris Larsendbce0d72015-09-17 13:34:00 -0700270 private:
271 std::vector<mips64::GpuRegister*> registers_;
272 std::map<mips64::GpuRegister, std::string, MIPS64CpuRegisterCompare> secondary_register_names_;
273
274 std::vector<mips64::FpuRegister*> fp_registers_;
275};
276
277
278TEST_F(AssemblerMIPS64Test, Toolchain) {
279 EXPECT_TRUE(CheckTools());
280}
281
Chris Larsendbce0d72015-09-17 13:34:00 -0700282///////////////////
283// FP Operations //
284///////////////////
285
286TEST_F(AssemblerMIPS64Test, SqrtS) {
287 DriverStr(RepeatFF(&mips64::Mips64Assembler::SqrtS, "sqrt.s ${reg1}, ${reg2}"), "sqrt.s");
288}
289
290TEST_F(AssemblerMIPS64Test, SqrtD) {
291 DriverStr(RepeatFF(&mips64::Mips64Assembler::SqrtD, "sqrt.d ${reg1}, ${reg2}"), "sqrt.d");
292}
293
294TEST_F(AssemblerMIPS64Test, AbsS) {
295 DriverStr(RepeatFF(&mips64::Mips64Assembler::AbsS, "abs.s ${reg1}, ${reg2}"), "abs.s");
296}
297
298TEST_F(AssemblerMIPS64Test, AbsD) {
299 DriverStr(RepeatFF(&mips64::Mips64Assembler::AbsD, "abs.d ${reg1}, ${reg2}"), "abs.d");
300}
301
Chris Larsen51417632015-10-02 13:24:25 -0700302TEST_F(AssemblerMIPS64Test, MovS) {
303 DriverStr(RepeatFF(&mips64::Mips64Assembler::MovS, "mov.s ${reg1}, ${reg2}"), "mov.s");
304}
305
306TEST_F(AssemblerMIPS64Test, MovD) {
307 DriverStr(RepeatFF(&mips64::Mips64Assembler::MovD, "mov.d ${reg1}, ${reg2}"), "mov.d");
308}
309
310TEST_F(AssemblerMIPS64Test, NegS) {
311 DriverStr(RepeatFF(&mips64::Mips64Assembler::NegS, "neg.s ${reg1}, ${reg2}"), "neg.s");
312}
313
314TEST_F(AssemblerMIPS64Test, NegD) {
315 DriverStr(RepeatFF(&mips64::Mips64Assembler::NegD, "neg.d ${reg1}, ${reg2}"), "neg.d");
316}
317
Chris Larsendbce0d72015-09-17 13:34:00 -0700318TEST_F(AssemblerMIPS64Test, RoundLS) {
319 DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundLS, "round.l.s ${reg1}, ${reg2}"), "round.l.s");
320}
321
322TEST_F(AssemblerMIPS64Test, RoundLD) {
323 DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundLD, "round.l.d ${reg1}, ${reg2}"), "round.l.d");
324}
325
326TEST_F(AssemblerMIPS64Test, RoundWS) {
327 DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundWS, "round.w.s ${reg1}, ${reg2}"), "round.w.s");
328}
329
330TEST_F(AssemblerMIPS64Test, RoundWD) {
331 DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundWD, "round.w.d ${reg1}, ${reg2}"), "round.w.d");
332}
333
334TEST_F(AssemblerMIPS64Test, CeilLS) {
335 DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilLS, "ceil.l.s ${reg1}, ${reg2}"), "ceil.l.s");
336}
337
338TEST_F(AssemblerMIPS64Test, CeilLD) {
339 DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilLD, "ceil.l.d ${reg1}, ${reg2}"), "ceil.l.d");
340}
341
342TEST_F(AssemblerMIPS64Test, CeilWS) {
343 DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilWS, "ceil.w.s ${reg1}, ${reg2}"), "ceil.w.s");
344}
345
346TEST_F(AssemblerMIPS64Test, CeilWD) {
347 DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilWD, "ceil.w.d ${reg1}, ${reg2}"), "ceil.w.d");
348}
349
350TEST_F(AssemblerMIPS64Test, FloorLS) {
351 DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorLS, "floor.l.s ${reg1}, ${reg2}"), "floor.l.s");
352}
353
354TEST_F(AssemblerMIPS64Test, FloorLD) {
355 DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorLD, "floor.l.d ${reg1}, ${reg2}"), "floor.l.d");
356}
357
358TEST_F(AssemblerMIPS64Test, FloorWS) {
359 DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorWS, "floor.w.s ${reg1}, ${reg2}"), "floor.w.s");
360}
361
362TEST_F(AssemblerMIPS64Test, FloorWD) {
363 DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorWD, "floor.w.d ${reg1}, ${reg2}"), "floor.w.d");
364}
365
366TEST_F(AssemblerMIPS64Test, SelS) {
367 DriverStr(RepeatFFF(&mips64::Mips64Assembler::SelS, "sel.s ${reg1}, ${reg2}, ${reg3}"), "sel.s");
368}
369
370TEST_F(AssemblerMIPS64Test, SelD) {
371 DriverStr(RepeatFFF(&mips64::Mips64Assembler::SelD, "sel.d ${reg1}, ${reg2}, ${reg3}"), "sel.d");
372}
373
374TEST_F(AssemblerMIPS64Test, RintS) {
375 DriverStr(RepeatFF(&mips64::Mips64Assembler::RintS, "rint.s ${reg1}, ${reg2}"), "rint.s");
376}
377
378TEST_F(AssemblerMIPS64Test, RintD) {
379 DriverStr(RepeatFF(&mips64::Mips64Assembler::RintD, "rint.d ${reg1}, ${reg2}"), "rint.d");
380}
381
382TEST_F(AssemblerMIPS64Test, ClassS) {
383 DriverStr(RepeatFF(&mips64::Mips64Assembler::ClassS, "class.s ${reg1}, ${reg2}"), "class.s");
384}
385
386TEST_F(AssemblerMIPS64Test, ClassD) {
387 DriverStr(RepeatFF(&mips64::Mips64Assembler::ClassD, "class.d ${reg1}, ${reg2}"), "class.d");
388}
389
390TEST_F(AssemblerMIPS64Test, MinS) {
391 DriverStr(RepeatFFF(&mips64::Mips64Assembler::MinS, "min.s ${reg1}, ${reg2}, ${reg3}"), "min.s");
392}
393
394TEST_F(AssemblerMIPS64Test, MinD) {
395 DriverStr(RepeatFFF(&mips64::Mips64Assembler::MinD, "min.d ${reg1}, ${reg2}, ${reg3}"), "min.d");
396}
397
398TEST_F(AssemblerMIPS64Test, MaxS) {
399 DriverStr(RepeatFFF(&mips64::Mips64Assembler::MaxS, "max.s ${reg1}, ${reg2}, ${reg3}"), "max.s");
400}
401
402TEST_F(AssemblerMIPS64Test, MaxD) {
403 DriverStr(RepeatFFF(&mips64::Mips64Assembler::MaxD, "max.d ${reg1}, ${reg2}, ${reg3}"), "max.d");
404}
405
Alexey Frunze299a9392015-12-08 16:08:02 -0800406TEST_F(AssemblerMIPS64Test, CmpUnS) {
407 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUnS, "cmp.un.s ${reg1}, ${reg2}, ${reg3}"),
408 "cmp.un.s");
409}
410
411TEST_F(AssemblerMIPS64Test, CmpEqS) {
412 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpEqS, "cmp.eq.s ${reg1}, ${reg2}, ${reg3}"),
413 "cmp.eq.s");
414}
415
416TEST_F(AssemblerMIPS64Test, CmpUeqS) {
417 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUeqS, "cmp.ueq.s ${reg1}, ${reg2}, ${reg3}"),
418 "cmp.ueq.s");
419}
420
421TEST_F(AssemblerMIPS64Test, CmpLtS) {
422 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLtS, "cmp.lt.s ${reg1}, ${reg2}, ${reg3}"),
423 "cmp.lt.s");
424}
425
426TEST_F(AssemblerMIPS64Test, CmpUltS) {
427 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUltS, "cmp.ult.s ${reg1}, ${reg2}, ${reg3}"),
428 "cmp.ult.s");
429}
430
431TEST_F(AssemblerMIPS64Test, CmpLeS) {
432 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLeS, "cmp.le.s ${reg1}, ${reg2}, ${reg3}"),
433 "cmp.le.s");
434}
435
436TEST_F(AssemblerMIPS64Test, CmpUleS) {
437 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUleS, "cmp.ule.s ${reg1}, ${reg2}, ${reg3}"),
438 "cmp.ule.s");
439}
440
441TEST_F(AssemblerMIPS64Test, CmpOrS) {
442 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpOrS, "cmp.or.s ${reg1}, ${reg2}, ${reg3}"),
443 "cmp.or.s");
444}
445
446TEST_F(AssemblerMIPS64Test, CmpUneS) {
447 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUneS, "cmp.une.s ${reg1}, ${reg2}, ${reg3}"),
448 "cmp.une.s");
449}
450
451TEST_F(AssemblerMIPS64Test, CmpNeS) {
452 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpNeS, "cmp.ne.s ${reg1}, ${reg2}, ${reg3}"),
453 "cmp.ne.s");
454}
455
456TEST_F(AssemblerMIPS64Test, CmpUnD) {
457 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUnD, "cmp.un.d ${reg1}, ${reg2}, ${reg3}"),
458 "cmp.un.d");
459}
460
461TEST_F(AssemblerMIPS64Test, CmpEqD) {
462 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpEqD, "cmp.eq.d ${reg1}, ${reg2}, ${reg3}"),
463 "cmp.eq.d");
464}
465
466TEST_F(AssemblerMIPS64Test, CmpUeqD) {
467 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUeqD, "cmp.ueq.d ${reg1}, ${reg2}, ${reg3}"),
468 "cmp.ueq.d");
469}
470
471TEST_F(AssemblerMIPS64Test, CmpLtD) {
472 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLtD, "cmp.lt.d ${reg1}, ${reg2}, ${reg3}"),
473 "cmp.lt.d");
474}
475
476TEST_F(AssemblerMIPS64Test, CmpUltD) {
477 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUltD, "cmp.ult.d ${reg1}, ${reg2}, ${reg3}"),
478 "cmp.ult.d");
479}
480
481TEST_F(AssemblerMIPS64Test, CmpLeD) {
482 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLeD, "cmp.le.d ${reg1}, ${reg2}, ${reg3}"),
483 "cmp.le.d");
484}
485
486TEST_F(AssemblerMIPS64Test, CmpUleD) {
487 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUleD, "cmp.ule.d ${reg1}, ${reg2}, ${reg3}"),
488 "cmp.ule.d");
489}
490
491TEST_F(AssemblerMIPS64Test, CmpOrD) {
492 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpOrD, "cmp.or.d ${reg1}, ${reg2}, ${reg3}"),
493 "cmp.or.d");
494}
495
496TEST_F(AssemblerMIPS64Test, CmpUneD) {
497 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUneD, "cmp.une.d ${reg1}, ${reg2}, ${reg3}"),
498 "cmp.une.d");
499}
500
501TEST_F(AssemblerMIPS64Test, CmpNeD) {
502 DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpNeD, "cmp.ne.d ${reg1}, ${reg2}, ${reg3}"),
503 "cmp.ne.d");
504}
505
Chris Larsendbce0d72015-09-17 13:34:00 -0700506TEST_F(AssemblerMIPS64Test, CvtDL) {
507 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtdl, "cvt.d.l ${reg1}, ${reg2}"), "cvt.d.l");
508}
509
Chris Larsen51417632015-10-02 13:24:25 -0700510TEST_F(AssemblerMIPS64Test, CvtDS) {
511 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtds, "cvt.d.s ${reg1}, ${reg2}"), "cvt.d.s");
512}
513
514TEST_F(AssemblerMIPS64Test, CvtDW) {
515 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtdw, "cvt.d.w ${reg1}, ${reg2}"), "cvt.d.w");
516}
517
518TEST_F(AssemblerMIPS64Test, CvtSL) {
519 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsl, "cvt.s.l ${reg1}, ${reg2}"), "cvt.s.l");
520}
521
522TEST_F(AssemblerMIPS64Test, CvtSD) {
523 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsd, "cvt.s.d ${reg1}, ${reg2}"), "cvt.s.d");
524}
525
526TEST_F(AssemblerMIPS64Test, CvtSW) {
527 DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsw, "cvt.s.w ${reg1}, ${reg2}"), "cvt.s.w");
528}
529
Alexey Frunzebaf60b72015-12-22 15:15:03 -0800530TEST_F(AssemblerMIPS64Test, TruncWS) {
531 DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncWS, "trunc.w.s ${reg1}, ${reg2}"), "trunc.w.s");
532}
533
534TEST_F(AssemblerMIPS64Test, TruncWD) {
535 DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncWD, "trunc.w.d ${reg1}, ${reg2}"), "trunc.w.d");
536}
537
538TEST_F(AssemblerMIPS64Test, TruncLS) {
539 DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncLS, "trunc.l.s ${reg1}, ${reg2}"), "trunc.l.s");
540}
541
542TEST_F(AssemblerMIPS64Test, TruncLD) {
543 DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncLD, "trunc.l.d ${reg1}, ${reg2}"), "trunc.l.d");
544}
545
Lazar Trsicd9672662015-09-03 17:33:01 +0200546TEST_F(AssemblerMIPS64Test, Mfc1) {
547 DriverStr(RepeatRF(&mips64::Mips64Assembler::Mfc1, "mfc1 ${reg1}, ${reg2}"), "Mfc1");
548}
549
550TEST_F(AssemblerMIPS64Test, Mfhc1) {
551 DriverStr(RepeatRF(&mips64::Mips64Assembler::Mfhc1, "mfhc1 ${reg1}, ${reg2}"), "Mfhc1");
552}
553
554TEST_F(AssemblerMIPS64Test, Mtc1) {
555 DriverStr(RepeatRF(&mips64::Mips64Assembler::Mtc1, "mtc1 ${reg1}, ${reg2}"), "Mtc1");
556}
557
558TEST_F(AssemblerMIPS64Test, Mthc1) {
559 DriverStr(RepeatRF(&mips64::Mips64Assembler::Mthc1, "mthc1 ${reg1}, ${reg2}"), "Mthc1");
560}
561
562TEST_F(AssemblerMIPS64Test, Dmfc1) {
563 DriverStr(RepeatRF(&mips64::Mips64Assembler::Dmfc1, "dmfc1 ${reg1}, ${reg2}"), "Dmfc1");
564}
565
566TEST_F(AssemblerMIPS64Test, Dmtc1) {
567 DriverStr(RepeatRF(&mips64::Mips64Assembler::Dmtc1, "dmtc1 ${reg1}, ${reg2}"), "Dmtc1");
568}
569
Chris Larsen51417632015-10-02 13:24:25 -0700570////////////////
571// CALL / JMP //
572////////////////
573
574TEST_F(AssemblerMIPS64Test, Jalr) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700575 DriverStr(".set noreorder\n" +
576 RepeatRRNoDupes(&mips64::Mips64Assembler::Jalr, "jalr ${reg1}, ${reg2}"), "jalr");
577}
578
Alexey Frunze19f6c692016-11-30 19:19:55 -0800579TEST_F(AssemblerMIPS64Test, Balc) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700580 mips64::Mips64Label label1, label2;
Alexey Frunze19f6c692016-11-30 19:19:55 -0800581 __ Balc(&label1);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700582 constexpr size_t kAdduCount1 = 63;
583 for (size_t i = 0; i != kAdduCount1; ++i) {
584 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
585 }
586 __ Bind(&label1);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800587 __ Balc(&label2);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700588 constexpr size_t kAdduCount2 = 64;
589 for (size_t i = 0; i != kAdduCount2; ++i) {
590 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
591 }
592 __ Bind(&label2);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800593 __ Balc(&label1);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700594
595 std::string expected =
596 ".set noreorder\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800597 "balc 1f\n" +
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700598 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
599 "1:\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800600 "balc 2f\n" +
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700601 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
602 "2:\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800603 "balc 1b\n";
604 DriverStr(expected, "Balc");
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700605}
606
Alexey Frunze19f6c692016-11-30 19:19:55 -0800607TEST_F(AssemblerMIPS64Test, LongBalc) {
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700608 mips64::Mips64Label label1, label2;
Alexey Frunze19f6c692016-11-30 19:19:55 -0800609 __ Balc(&label1);
610 constexpr uint32_t kNopCount1 = (1u << 25) + 1;
611 for (uint32_t i = 0; i != kNopCount1; ++i) {
612 __ Nop();
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700613 }
614 __ Bind(&label1);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800615 __ Balc(&label2);
616 constexpr uint32_t kNopCount2 = (1u << 25) + 1;
617 for (uint32_t i = 0; i != kNopCount2; ++i) {
618 __ Nop();
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700619 }
620 __ Bind(&label2);
Alexey Frunze19f6c692016-11-30 19:19:55 -0800621 __ Balc(&label1);
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700622
Alexey Frunze19f6c692016-11-30 19:19:55 -0800623 uint32_t offset_forward1 = 2 + kNopCount1; // 2: account for auipc and jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700624 offset_forward1 <<= 2;
Alexey Frunze19f6c692016-11-30 19:19:55 -0800625 offset_forward1 += (offset_forward1 & 0x8000) << 1; // Account for sign extension in jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700626
Alexey Frunze19f6c692016-11-30 19:19:55 -0800627 uint32_t offset_forward2 = 2 + kNopCount2; // 2: account for auipc and jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700628 offset_forward2 <<= 2;
Alexey Frunze19f6c692016-11-30 19:19:55 -0800629 offset_forward2 += (offset_forward2 & 0x8000) << 1; // Account for sign extension in jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700630
Alexey Frunze19f6c692016-11-30 19:19:55 -0800631 uint32_t offset_back = -(2 + kNopCount2); // 2: account for auipc and jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700632 offset_back <<= 2;
Alexey Frunze19f6c692016-11-30 19:19:55 -0800633 offset_back += (offset_back & 0x8000) << 1; // Account for sign extension in jialc.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700634
Alexey Frunze19f6c692016-11-30 19:19:55 -0800635 // Note, we're using the ".fill" directive to tell the assembler to generate many NOPs
636 // instead of generating them ourselves in the source code. This saves a few minutes
637 // of test time.
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700638 std::ostringstream oss;
639 oss <<
640 ".set noreorder\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800641 "auipc $at, 0x" << std::hex << High16Bits(offset_forward1) << "\n"
642 "jialc $at, 0x" << std::hex << Low16Bits(offset_forward1) << "\n"
643 ".fill 0x" << std::hex << kNopCount1 << " , 4, 0\n"
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700644 "1:\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800645 "auipc $at, 0x" << std::hex << High16Bits(offset_forward2) << "\n"
646 "jialc $at, 0x" << std::hex << Low16Bits(offset_forward2) << "\n"
647 ".fill 0x" << std::hex << kNopCount2 << " , 4, 0\n"
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700648 "2:\n"
Alexey Frunze19f6c692016-11-30 19:19:55 -0800649 "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
650 "jialc $at, 0x" << std::hex << Low16Bits(offset_back) << "\n";
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700651 std::string expected = oss.str();
Alexey Frunze19f6c692016-11-30 19:19:55 -0800652 DriverStr(expected, "LongBalc");
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700653}
654
655TEST_F(AssemblerMIPS64Test, Bc) {
656 mips64::Mips64Label label1, label2;
657 __ Bc(&label1);
658 constexpr size_t kAdduCount1 = 63;
659 for (size_t i = 0; i != kAdduCount1; ++i) {
660 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
661 }
662 __ Bind(&label1);
663 __ Bc(&label2);
664 constexpr size_t kAdduCount2 = 64;
665 for (size_t i = 0; i != kAdduCount2; ++i) {
666 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
667 }
668 __ Bind(&label2);
669 __ Bc(&label1);
670
671 std::string expected =
672 ".set noreorder\n"
673 "bc 1f\n" +
674 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
675 "1:\n"
676 "bc 2f\n" +
677 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
678 "2:\n"
679 "bc 1b\n";
680 DriverStr(expected, "Bc");
681}
682
683TEST_F(AssemblerMIPS64Test, Beqzc) {
684 BranchCondOneRegHelper(&mips64::Mips64Assembler::Beqzc, "Beqzc");
685}
686
687TEST_F(AssemblerMIPS64Test, Bnezc) {
688 BranchCondOneRegHelper(&mips64::Mips64Assembler::Bnezc, "Bnezc");
689}
690
691TEST_F(AssemblerMIPS64Test, Bltzc) {
692 BranchCondOneRegHelper(&mips64::Mips64Assembler::Bltzc, "Bltzc");
693}
694
695TEST_F(AssemblerMIPS64Test, Bgezc) {
696 BranchCondOneRegHelper(&mips64::Mips64Assembler::Bgezc, "Bgezc");
697}
698
699TEST_F(AssemblerMIPS64Test, Blezc) {
700 BranchCondOneRegHelper(&mips64::Mips64Assembler::Blezc, "Blezc");
701}
702
703TEST_F(AssemblerMIPS64Test, Bgtzc) {
704 BranchCondOneRegHelper(&mips64::Mips64Assembler::Bgtzc, "Bgtzc");
705}
706
707TEST_F(AssemblerMIPS64Test, Beqc) {
708 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Beqc, "Beqc");
709}
710
711TEST_F(AssemblerMIPS64Test, Bnec) {
712 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bnec, "Bnec");
713}
714
715TEST_F(AssemblerMIPS64Test, Bltc) {
716 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bltc, "Bltc");
717}
718
719TEST_F(AssemblerMIPS64Test, Bgec) {
720 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bgec, "Bgec");
721}
722
723TEST_F(AssemblerMIPS64Test, Bltuc) {
724 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bltuc, "Bltuc");
725}
726
727TEST_F(AssemblerMIPS64Test, Bgeuc) {
728 BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bgeuc, "Bgeuc");
729}
730
Alexey Frunze299a9392015-12-08 16:08:02 -0800731TEST_F(AssemblerMIPS64Test, Bc1eqz) {
732 mips64::Mips64Label label;
733 __ Bc1eqz(mips64::F0, &label);
734 constexpr size_t kAdduCount1 = 63;
735 for (size_t i = 0; i != kAdduCount1; ++i) {
736 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
737 }
738 __ Bind(&label);
739 constexpr size_t kAdduCount2 = 64;
740 for (size_t i = 0; i != kAdduCount2; ++i) {
741 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
742 }
743 __ Bc1eqz(mips64::F31, &label);
744
745 std::string expected =
746 ".set noreorder\n"
747 "bc1eqz $f0, 1f\n"
748 "nop\n" +
749 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
750 "1:\n" +
751 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
752 "bc1eqz $f31, 1b\n"
753 "nop\n";
754 DriverStr(expected, "Bc1eqz");
755}
756
757TEST_F(AssemblerMIPS64Test, Bc1nez) {
758 mips64::Mips64Label label;
759 __ Bc1nez(mips64::F0, &label);
760 constexpr size_t kAdduCount1 = 63;
761 for (size_t i = 0; i != kAdduCount1; ++i) {
762 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
763 }
764 __ Bind(&label);
765 constexpr size_t kAdduCount2 = 64;
766 for (size_t i = 0; i != kAdduCount2; ++i) {
767 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
768 }
769 __ Bc1nez(mips64::F31, &label);
770
771 std::string expected =
772 ".set noreorder\n"
773 "bc1nez $f0, 1f\n"
774 "nop\n" +
775 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") +
776 "1:\n" +
777 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") +
778 "bc1nez $f31, 1b\n"
779 "nop\n";
780 DriverStr(expected, "Bc1nez");
781}
782
Alexey Frunzea0e87b02015-09-24 22:57:20 -0700783TEST_F(AssemblerMIPS64Test, LongBeqc) {
784 mips64::Mips64Label label;
785 __ Beqc(mips64::A0, mips64::A1, &label);
786 constexpr uint32_t kAdduCount1 = (1u << 15) + 1;
787 for (uint32_t i = 0; i != kAdduCount1; ++i) {
788 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
789 }
790 __ Bind(&label);
791 constexpr uint32_t kAdduCount2 = (1u << 15) + 1;
792 for (uint32_t i = 0; i != kAdduCount2; ++i) {
793 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
794 }
795 __ Beqc(mips64::A2, mips64::A3, &label);
796
797 uint32_t offset_forward = 2 + kAdduCount1; // 2: account for auipc and jic.
798 offset_forward <<= 2;
799 offset_forward += (offset_forward & 0x8000) << 1; // Account for sign extension in jic.
800
801 uint32_t offset_back = -(kAdduCount2 + 1); // 1: account for bnec.
802 offset_back <<= 2;
803 offset_back += (offset_back & 0x8000) << 1; // Account for sign extension in jic.
804
805 std::ostringstream oss;
806 oss <<
807 ".set noreorder\n"
808 "bnec $a0, $a1, 1f\n"
809 "auipc $at, 0x" << std::hex << High16Bits(offset_forward) << "\n"
810 "jic $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n"
811 "1:\n" <<
812 RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") <<
813 "2:\n" <<
814 RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") <<
815 "bnec $a2, $a3, 3f\n"
816 "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n"
817 "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n"
818 "3:\n";
819 std::string expected = oss.str();
820 DriverStr(expected, "LongBeqc");
Chris Larsen51417632015-10-02 13:24:25 -0700821}
822
Chris Larsendbce0d72015-09-17 13:34:00 -0700823//////////
824// MISC //
825//////////
826
Alexey Frunze19f6c692016-11-30 19:19:55 -0800827TEST_F(AssemblerMIPS64Test, Lwpc) {
828 // Lwpc() takes an unsigned 19-bit immediate, while the GNU assembler needs a signed offset,
829 // hence the sign extension from bit 18 with `imm - ((imm & 0x40000) << 1)`.
830 // The GNU assembler also wants the offset to be a multiple of 4, which it will shift right
831 // by 2 positions when encoding, hence `<< 2` to compensate for that shift.
832 // We capture the value of the immediate with `.set imm, {imm}` because the value is needed
833 // twice for the sign extension, but `{imm}` is substituted only once.
834 const char* code = ".set imm, {imm}\nlw ${reg}, ((imm - ((imm & 0x40000) << 1)) << 2)($pc)";
835 DriverStr(RepeatRIb(&mips64::Mips64Assembler::Lwpc, 19, code), "Lwpc");
836}
837
838TEST_F(AssemblerMIPS64Test, Lwupc) {
839 // The comment for the Lwpc test applies here as well.
840 const char* code = ".set imm, {imm}\nlwu ${reg}, ((imm - ((imm & 0x40000) << 1)) << 2)($pc)";
841 DriverStr(RepeatRIb(&mips64::Mips64Assembler::Lwupc, 19, code), "Lwupc");
842}
843
844TEST_F(AssemblerMIPS64Test, Ldpc) {
845 // The comment for the Lwpc test applies here as well.
846 const char* code = ".set imm, {imm}\nld ${reg}, ((imm - ((imm & 0x20000) << 1)) << 3)($pc)";
847 DriverStr(RepeatRIb(&mips64::Mips64Assembler::Ldpc, 18, code), "Ldpc");
848}
849
850TEST_F(AssemblerMIPS64Test, LoadFarthestNearLabelAddress) {
851 mips64::Mips64Label label;
852 __ LoadLabelAddress(mips64::V0, &label);
853 constexpr uint32_t kAdduCount = 0x3FFDE;
854 for (uint32_t i = 0; i != kAdduCount; ++i) {
855 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
856 }
857 __ Bind(&label);
858
859 std::string expected =
860 "lapc $v0, 1f\n" +
861 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
862 "1:\n";
863 DriverStr(expected, "LoadFarthestNearLabelAddress");
864 EXPECT_EQ(__ GetLabelLocation(&label), (1 + kAdduCount) * 4);
865}
866
867TEST_F(AssemblerMIPS64Test, LoadNearestFarLabelAddress) {
868 mips64::Mips64Label label;
869 __ LoadLabelAddress(mips64::V0, &label);
870 constexpr uint32_t kAdduCount = 0x3FFDF;
871 for (uint32_t i = 0; i != kAdduCount; ++i) {
872 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
873 }
874 __ Bind(&label);
875
876 std::string expected =
877 "1:\n"
878 "auipc $at, %hi(2f - 1b)\n"
879 "addiu $v0, $at, %lo(2f - 1b)\n" +
880 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
881 "2:\n";
882 DriverStr(expected, "LoadNearestFarLabelAddress");
883 EXPECT_EQ(__ GetLabelLocation(&label), (2 + kAdduCount) * 4);
884}
885
886TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteral) {
887 mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
888 __ LoadLiteral(mips64::V0, mips64::kLoadWord, literal);
889 constexpr uint32_t kAdduCount = 0x3FFDE;
890 for (uint32_t i = 0; i != kAdduCount; ++i) {
891 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
892 }
893
894 std::string expected =
895 "lwpc $v0, 1f\n" +
896 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
897 "1:\n"
898 ".word 0x12345678\n";
899 DriverStr(expected, "LoadFarthestNearLiteral");
900 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4);
901}
902
903TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteral) {
904 mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
905 __ LoadLiteral(mips64::V0, mips64::kLoadWord, literal);
906 constexpr uint32_t kAdduCount = 0x3FFDF;
907 for (uint32_t i = 0; i != kAdduCount; ++i) {
908 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
909 }
910
911 std::string expected =
912 "1:\n"
913 "auipc $at, %hi(2f - 1b)\n"
914 "lw $v0, %lo(2f - 1b)($at)\n" +
915 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
916 "2:\n"
917 ".word 0x12345678\n";
918 DriverStr(expected, "LoadNearestFarLiteral");
919 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4);
920}
921
922TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteralUnsigned) {
923 mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
924 __ LoadLiteral(mips64::V0, mips64::kLoadUnsignedWord, literal);
925 constexpr uint32_t kAdduCount = 0x3FFDE;
926 for (uint32_t i = 0; i != kAdduCount; ++i) {
927 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
928 }
929
930 std::string expected =
931 "lwupc $v0, 1f\n" +
932 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
933 "1:\n"
934 ".word 0x12345678\n";
935 DriverStr(expected, "LoadFarthestNearLiteralUnsigned");
936 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4);
937}
938
939TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteralUnsigned) {
940 mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678);
941 __ LoadLiteral(mips64::V0, mips64::kLoadUnsignedWord, literal);
942 constexpr uint32_t kAdduCount = 0x3FFDF;
943 for (uint32_t i = 0; i != kAdduCount; ++i) {
944 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
945 }
946
947 std::string expected =
948 "1:\n"
949 "auipc $at, %hi(2f - 1b)\n"
950 "lwu $v0, %lo(2f - 1b)($at)\n" +
951 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
952 "2:\n"
953 ".word 0x12345678\n";
954 DriverStr(expected, "LoadNearestFarLiteralUnsigned");
955 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4);
956}
957
958TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteralLong) {
959 mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF));
960 __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal);
961 constexpr uint32_t kAdduCount = 0x3FFDD;
962 for (uint32_t i = 0; i != kAdduCount; ++i) {
963 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
964 }
965
966 std::string expected =
967 "ldpc $v0, 1f\n" +
968 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
969 "1:\n"
970 ".dword 0x0123456789ABCDEF\n";
971 DriverStr(expected, "LoadFarthestNearLiteralLong");
972 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4);
973}
974
975TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteralLong) {
976 mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF));
977 __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal);
978 constexpr uint32_t kAdduCount = 0x3FFDE;
979 for (uint32_t i = 0; i != kAdduCount; ++i) {
980 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
981 }
982
983 std::string expected =
984 "1:\n"
985 "auipc $at, %hi(2f - 1b)\n"
986 "ld $v0, %lo(2f - 1b)($at)\n" +
987 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
988 "2:\n"
989 ".dword 0x0123456789ABCDEF\n";
990 DriverStr(expected, "LoadNearestFarLiteralLong");
991 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4);
992}
993
994TEST_F(AssemblerMIPS64Test, LongLiteralAlignmentNop) {
995 mips64::Literal* literal1 = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF));
996 mips64::Literal* literal2 = __ NewLiteral<uint64_t>(UINT64_C(0x5555555555555555));
997 mips64::Literal* literal3 = __ NewLiteral<uint64_t>(UINT64_C(0xAAAAAAAAAAAAAAAA));
998 __ LoadLiteral(mips64::A1, mips64::kLoadDoubleword, literal1);
999 __ LoadLiteral(mips64::A2, mips64::kLoadDoubleword, literal2);
1000 __ LoadLiteral(mips64::A3, mips64::kLoadDoubleword, literal3);
1001 __ LoadLabelAddress(mips64::V0, literal1->GetLabel());
1002 __ LoadLabelAddress(mips64::V1, literal2->GetLabel());
1003 // A nop will be inserted here before the 64-bit literals.
1004
1005 std::string expected =
1006 "ldpc $a1, 1f\n"
1007 // The GNU assembler incorrectly requires the ldpc instruction to be located
1008 // at an address that's a multiple of 8. TODO: Remove this workaround if/when
1009 // the assembler is fixed.
1010 // "ldpc $a2, 2f\n"
1011 ".word 0xECD80004\n"
1012 "ldpc $a3, 3f\n"
1013 "lapc $v0, 1f\n"
1014 "lapc $v1, 2f\n"
1015 "nop\n"
1016 "1:\n"
1017 ".dword 0x0123456789ABCDEF\n"
1018 "2:\n"
1019 ".dword 0x5555555555555555\n"
1020 "3:\n"
1021 ".dword 0xAAAAAAAAAAAAAAAA\n";
1022 DriverStr(expected, "LongLiteralAlignmentNop");
1023 EXPECT_EQ(__ GetLabelLocation(literal1->GetLabel()), 6 * 4u);
1024 EXPECT_EQ(__ GetLabelLocation(literal2->GetLabel()), 8 * 4u);
1025 EXPECT_EQ(__ GetLabelLocation(literal3->GetLabel()), 10 * 4u);
1026}
1027
1028TEST_F(AssemblerMIPS64Test, LongLiteralAlignmentNoNop) {
1029 mips64::Literal* literal1 = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF));
1030 mips64::Literal* literal2 = __ NewLiteral<uint64_t>(UINT64_C(0x5555555555555555));
1031 __ LoadLiteral(mips64::A1, mips64::kLoadDoubleword, literal1);
1032 __ LoadLiteral(mips64::A2, mips64::kLoadDoubleword, literal2);
1033 __ LoadLabelAddress(mips64::V0, literal1->GetLabel());
1034 __ LoadLabelAddress(mips64::V1, literal2->GetLabel());
1035
1036 std::string expected =
1037 "ldpc $a1, 1f\n"
1038 // The GNU assembler incorrectly requires the ldpc instruction to be located
1039 // at an address that's a multiple of 8. TODO: Remove this workaround if/when
1040 // the assembler is fixed.
1041 // "ldpc $a2, 2f\n"
1042 ".word 0xECD80003\n"
1043 "lapc $v0, 1f\n"
1044 "lapc $v1, 2f\n"
1045 "1:\n"
1046 ".dword 0x0123456789ABCDEF\n"
1047 "2:\n"
1048 ".dword 0x5555555555555555\n";
1049 DriverStr(expected, "LongLiteralAlignmentNoNop");
1050 EXPECT_EQ(__ GetLabelLocation(literal1->GetLabel()), 4 * 4u);
1051 EXPECT_EQ(__ GetLabelLocation(literal2->GetLabel()), 6 * 4u);
1052}
1053
1054TEST_F(AssemblerMIPS64Test, FarLongLiteralAlignmentNop) {
1055 mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF));
1056 __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal);
1057 __ LoadLabelAddress(mips64::V1, literal->GetLabel());
1058 constexpr uint32_t kAdduCount = 0x3FFDF;
1059 for (uint32_t i = 0; i != kAdduCount; ++i) {
1060 __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO);
1061 }
1062 // A nop will be inserted here before the 64-bit literal.
1063
1064 std::string expected =
1065 "1:\n"
1066 "auipc $at, %hi(3f - 1b)\n"
1067 "ld $v0, %lo(3f - 1b)($at)\n"
1068 "2:\n"
1069 "auipc $at, %hi(3f - 2b)\n"
1070 "addiu $v1, $at, %lo(3f - 2b)\n" +
1071 RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") +
1072 "nop\n"
1073 "3:\n"
1074 ".dword 0x0123456789ABCDEF\n";
1075 DriverStr(expected, "FarLongLiteralAlignmentNop");
1076 EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (5 + kAdduCount) * 4);
1077}
1078
Chris Larsendbce0d72015-09-17 13:34:00 -07001079TEST_F(AssemblerMIPS64Test, Bitswap) {
1080 DriverStr(RepeatRR(&mips64::Mips64Assembler::Bitswap, "bitswap ${reg1}, ${reg2}"), "bitswap");
1081}
1082
1083TEST_F(AssemblerMIPS64Test, Dbitswap) {
1084 DriverStr(RepeatRR(&mips64::Mips64Assembler::Dbitswap, "dbitswap ${reg1}, ${reg2}"), "dbitswap");
1085}
1086
Chris Larsen51417632015-10-02 13:24:25 -07001087TEST_F(AssemblerMIPS64Test, Seb) {
1088 DriverStr(RepeatRR(&mips64::Mips64Assembler::Seb, "seb ${reg1}, ${reg2}"), "seb");
1089}
1090
1091TEST_F(AssemblerMIPS64Test, Seh) {
1092 DriverStr(RepeatRR(&mips64::Mips64Assembler::Seh, "seh ${reg1}, ${reg2}"), "seh");
1093}
1094
Chris Larsendbce0d72015-09-17 13:34:00 -07001095TEST_F(AssemblerMIPS64Test, Dsbh) {
1096 DriverStr(RepeatRR(&mips64::Mips64Assembler::Dsbh, "dsbh ${reg1}, ${reg2}"), "dsbh");
1097}
1098
1099TEST_F(AssemblerMIPS64Test, Dshd) {
1100 DriverStr(RepeatRR(&mips64::Mips64Assembler::Dshd, "dshd ${reg1}, ${reg2}"), "dshd");
1101}
1102
Lazar Trsicd9672662015-09-03 17:33:01 +02001103TEST_F(AssemblerMIPS64Test, Dext) {
1104 std::vector<mips64::GpuRegister*> reg1_registers = GetRegisters();
1105 std::vector<mips64::GpuRegister*> reg2_registers = GetRegisters();
1106 WarnOnCombinations(reg1_registers.size() * reg2_registers.size() * 33 * 16);
1107 std::ostringstream expected;
1108 for (mips64::GpuRegister* reg1 : reg1_registers) {
1109 for (mips64::GpuRegister* reg2 : reg2_registers) {
1110 for (int32_t pos = 0; pos < 32; pos++) {
1111 for (int32_t size = 1; size <= 32; size++) {
1112 __ Dext(*reg1, *reg2, pos, size);
1113 expected << "dext $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n";
1114 }
1115 }
1116 }
1117 }
1118
1119 DriverStr(expected.str(), "Dext");
1120}
1121
1122TEST_F(AssemblerMIPS64Test, Dinsu) {
1123 std::vector<mips64::GpuRegister*> reg1_registers = GetRegisters();
1124 std::vector<mips64::GpuRegister*> reg2_registers = GetRegisters();
1125 WarnOnCombinations(reg1_registers.size() * reg2_registers.size() * 33 * 16);
1126 std::ostringstream expected;
1127 for (mips64::GpuRegister* reg1 : reg1_registers) {
1128 for (mips64::GpuRegister* reg2 : reg2_registers) {
1129 for (int32_t pos = 32; pos < 64; pos++) {
1130 for (int32_t size = 1; pos + size <= 64; size++) {
1131 __ Dinsu(*reg1, *reg2, pos, size);
1132 expected << "dinsu $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n";
1133 }
1134 }
1135 }
1136 }
1137
1138 DriverStr(expected.str(), "Dinsu");
1139}
1140
Chris Larsendbce0d72015-09-17 13:34:00 -07001141TEST_F(AssemblerMIPS64Test, Wsbh) {
1142 DriverStr(RepeatRR(&mips64::Mips64Assembler::Wsbh, "wsbh ${reg1}, ${reg2}"), "wsbh");
1143}
1144
Chris Larsen51417632015-10-02 13:24:25 -07001145TEST_F(AssemblerMIPS64Test, Sll) {
1146 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sll, 5, "sll ${reg1}, ${reg2}, {imm}"), "sll");
1147}
1148
1149TEST_F(AssemblerMIPS64Test, Srl) {
1150 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Srl, 5, "srl ${reg1}, ${reg2}, {imm}"), "srl");
1151}
1152
Chris Larsen98a73e12015-10-19 14:17:16 -07001153TEST_F(AssemblerMIPS64Test, Rotr) {
1154 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Rotr, 5, "rotr ${reg1}, ${reg2}, {imm}"), "rotr");
1155}
1156
Chris Larsen51417632015-10-02 13:24:25 -07001157TEST_F(AssemblerMIPS64Test, Sra) {
1158 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sra, 5, "sra ${reg1}, ${reg2}, {imm}"), "sra");
1159}
1160
Chris Larsen98a73e12015-10-19 14:17:16 -07001161TEST_F(AssemblerMIPS64Test, Sllv) {
1162 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Sllv, "sllv ${reg1}, ${reg2}, ${reg3}"), "sllv");
1163}
1164
1165TEST_F(AssemblerMIPS64Test, Srlv) {
1166 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Srlv, "srlv ${reg1}, ${reg2}, ${reg3}"), "srlv");
1167}
1168
1169TEST_F(AssemblerMIPS64Test, Rotrv) {
1170 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Rotrv, "rotrv ${reg1}, ${reg2}, ${reg3}"), "rotrv");
1171}
1172
1173TEST_F(AssemblerMIPS64Test, Srav) {
1174 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Srav, "srav ${reg1}, ${reg2}, ${reg3}"), "srav");
1175}
1176
Chris Larsen51417632015-10-02 13:24:25 -07001177TEST_F(AssemblerMIPS64Test, Dsll) {
1178 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsll, 5, "dsll ${reg1}, ${reg2}, {imm}"), "dsll");
1179}
1180
1181TEST_F(AssemblerMIPS64Test, Dsrl) {
1182 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsrl, 5, "dsrl ${reg1}, ${reg2}, {imm}"), "dsrl");
1183}
1184
Chris Larsen98a73e12015-10-19 14:17:16 -07001185TEST_F(AssemblerMIPS64Test, Drotr) {
1186 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Drotr, 5, "drotr ${reg1}, ${reg2}, {imm}"),
1187 "drotr");
1188}
1189
Chris Larsen51417632015-10-02 13:24:25 -07001190TEST_F(AssemblerMIPS64Test, Dsra) {
1191 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsra, 5, "dsra ${reg1}, ${reg2}, {imm}"), "dsra");
1192}
1193
1194TEST_F(AssemblerMIPS64Test, Dsll32) {
Chris Larsen98a73e12015-10-19 14:17:16 -07001195 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsll32, 5, "dsll32 ${reg1}, ${reg2}, {imm}"),
1196 "dsll32");
Chris Larsen51417632015-10-02 13:24:25 -07001197}
1198
1199TEST_F(AssemblerMIPS64Test, Dsrl32) {
Chris Larsen98a73e12015-10-19 14:17:16 -07001200 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsrl32, 5, "dsrl32 ${reg1}, ${reg2}, {imm}"),
1201 "dsrl32");
1202}
1203
1204TEST_F(AssemblerMIPS64Test, Drotr32) {
1205 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Drotr32, 5, "drotr32 ${reg1}, ${reg2}, {imm}"),
1206 "drotr32");
Chris Larsen51417632015-10-02 13:24:25 -07001207}
1208
1209TEST_F(AssemblerMIPS64Test, Dsra32) {
Chris Larsen98a73e12015-10-19 14:17:16 -07001210 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsra32, 5, "dsra32 ${reg1}, ${reg2}, {imm}"),
1211 "dsra32");
Chris Larsen51417632015-10-02 13:24:25 -07001212}
1213
Chris Larsendbce0d72015-09-17 13:34:00 -07001214TEST_F(AssemblerMIPS64Test, Sc) {
1215 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sc, -9, "sc ${reg1}, {imm}(${reg2})"), "sc");
1216}
1217
1218TEST_F(AssemblerMIPS64Test, Scd) {
1219 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Scd, -9, "scd ${reg1}, {imm}(${reg2})"), "scd");
1220}
1221
1222TEST_F(AssemblerMIPS64Test, Ll) {
1223 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Ll, -9, "ll ${reg1}, {imm}(${reg2})"), "ll");
1224}
1225
1226TEST_F(AssemblerMIPS64Test, Lld) {
1227 DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lld, -9, "lld ${reg1}, {imm}(${reg2})"), "lld");
1228}
1229
Chris Larsendbce0d72015-09-17 13:34:00 -07001230TEST_F(AssemblerMIPS64Test, Seleqz) {
1231 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Seleqz, "seleqz ${reg1}, ${reg2}, ${reg3}"),
1232 "seleqz");
1233}
1234
1235TEST_F(AssemblerMIPS64Test, Selnez) {
1236 DriverStr(RepeatRRR(&mips64::Mips64Assembler::Selnez, "selnez ${reg1}, ${reg2}, ${reg3}"),
1237 "selnez");
1238}
1239
1240TEST_F(AssemblerMIPS64Test, Clz) {
1241 DriverStr(RepeatRR(&mips64::Mips64Assembler::Clz, "clz ${reg1}, ${reg2}"), "clz");
1242}
1243
1244TEST_F(AssemblerMIPS64Test, Clo) {
1245 DriverStr(RepeatRR(&mips64::Mips64Assembler::Clo, "clo ${reg1}, ${reg2}"), "clo");
1246}
1247
1248TEST_F(AssemblerMIPS64Test, Dclz) {
1249 DriverStr(RepeatRR(&mips64::Mips64Assembler::Dclz, "dclz ${reg1}, ${reg2}"), "dclz");
1250}
1251
1252TEST_F(AssemblerMIPS64Test, Dclo) {
1253 DriverStr(RepeatRR(&mips64::Mips64Assembler::Dclo, "dclo ${reg1}, ${reg2}"), "dclo");
1254}
1255
Lazar Trsicd9672662015-09-03 17:33:01 +02001256TEST_F(AssemblerMIPS64Test, LoadFromOffset) {
1257 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A0, 0);
1258 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0);
1259 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 1);
1260 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 256);
1261 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 1000);
1262 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x7FFF);
1263 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x8000);
1264 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x8001);
1265 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x10000);
1266 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x12345678);
1267 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, -256);
1268 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, -32768);
1269 __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0xABCDEF00);
1270
1271 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A0, 0);
1272 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0);
1273 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 1);
1274 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 256);
1275 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 1000);
1276 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x7FFF);
1277 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x8000);
1278 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x8001);
1279 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x10000);
1280 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x12345678);
1281 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, -256);
1282 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, -32768);
1283 __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0xABCDEF00);
1284
1285 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A0, 0);
1286 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0);
1287 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 2);
1288 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 256);
1289 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 1000);
1290 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x7FFE);
1291 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x8000);
1292 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x8002);
1293 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x10000);
1294 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x12345678);
1295 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, -256);
1296 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, -32768);
1297 __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0xABCDEF00);
1298
1299 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A0, 0);
1300 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0);
1301 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 2);
1302 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 256);
1303 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 1000);
1304 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x7FFE);
1305 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x8000);
1306 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x8002);
1307 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x10000);
1308 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x12345678);
1309 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, -256);
1310 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, -32768);
1311 __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0xABCDEF00);
1312
1313 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A0, 0);
1314 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0);
1315 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 4);
1316 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 256);
1317 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 1000);
1318 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x7FFC);
1319 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x8000);
1320 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x8004);
1321 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x10000);
1322 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x12345678);
1323 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, -256);
1324 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, -32768);
1325 __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0xABCDEF00);
1326
1327 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A0, 0);
1328 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0);
1329 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 4);
1330 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 256);
1331 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 1000);
1332 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x7FFC);
1333 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x8000);
1334 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x8004);
1335 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x10000);
1336 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x12345678);
1337 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, -256);
1338 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, -32768);
1339 __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0xABCDEF00);
1340
1341 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A0, 0);
1342 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0);
1343 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 4);
1344 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 256);
1345 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 1000);
1346 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x7FFC);
1347 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x8000);
1348 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x8004);
1349 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x10000);
1350 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x12345678);
1351 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, -256);
1352 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, -32768);
1353 __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0xABCDEF00);
1354
1355 const char* expected =
1356 "lb $a0, 0($a0)\n"
1357 "lb $a0, 0($a1)\n"
1358 "lb $a0, 1($a1)\n"
1359 "lb $a0, 256($a1)\n"
1360 "lb $a0, 1000($a1)\n"
1361 "lb $a0, 0x7FFF($a1)\n"
1362 "ori $at, $zero, 0x8000\n"
1363 "daddu $at, $at, $a1\n"
1364 "lb $a0, 0($at)\n"
1365 "ori $at, $zero, 0x8000\n"
1366 "daddu $at, $at, $a1\n"
1367 "lb $a0, 1($at)\n"
1368 "lui $at, 1\n"
1369 "daddu $at, $at, $a1\n"
1370 "lb $a0, 0($at)\n"
1371 "lui $at, 0x1234\n"
1372 "ori $at, 0x5678\n"
1373 "daddu $at, $at, $a1\n"
1374 "lb $a0, 0($at)\n"
1375 "lb $a0, -256($a1)\n"
1376 "lb $a0, -32768($a1)\n"
1377 "lui $at, 0xABCD\n"
1378 "ori $at, 0xEF00\n"
1379 "daddu $at, $at, $a1\n"
1380 "lb $a0, 0($at)\n"
1381
1382 "lbu $a0, 0($a0)\n"
1383 "lbu $a0, 0($a1)\n"
1384 "lbu $a0, 1($a1)\n"
1385 "lbu $a0, 256($a1)\n"
1386 "lbu $a0, 1000($a1)\n"
1387 "lbu $a0, 0x7FFF($a1)\n"
1388 "ori $at, $zero, 0x8000\n"
1389 "daddu $at, $at, $a1\n"
1390 "lbu $a0, 0($at)\n"
1391 "ori $at, $zero, 0x8000\n"
1392 "daddu $at, $at, $a1\n"
1393 "lbu $a0, 1($at)\n"
1394 "lui $at, 1\n"
1395 "daddu $at, $at, $a1\n"
1396 "lbu $a0, 0($at)\n"
1397 "lui $at, 0x1234\n"
1398 "ori $at, 0x5678\n"
1399 "daddu $at, $at, $a1\n"
1400 "lbu $a0, 0($at)\n"
1401 "lbu $a0, -256($a1)\n"
1402 "lbu $a0, -32768($a1)\n"
1403 "lui $at, 0xABCD\n"
1404 "ori $at, 0xEF00\n"
1405 "daddu $at, $at, $a1\n"
1406 "lbu $a0, 0($at)\n"
1407
1408 "lh $a0, 0($a0)\n"
1409 "lh $a0, 0($a1)\n"
1410 "lh $a0, 2($a1)\n"
1411 "lh $a0, 256($a1)\n"
1412 "lh $a0, 1000($a1)\n"
1413 "lh $a0, 0x7FFE($a1)\n"
1414 "ori $at, $zero, 0x8000\n"
1415 "daddu $at, $at, $a1\n"
1416 "lh $a0, 0($at)\n"
1417 "ori $at, $zero, 0x8000\n"
1418 "daddu $at, $at, $a1\n"
1419 "lh $a0, 2($at)\n"
1420 "lui $at, 1\n"
1421 "daddu $at, $at, $a1\n"
1422 "lh $a0, 0($at)\n"
1423 "lui $at, 0x1234\n"
1424 "ori $at, 0x5678\n"
1425 "daddu $at, $at, $a1\n"
1426 "lh $a0, 0($at)\n"
1427 "lh $a0, -256($a1)\n"
1428 "lh $a0, -32768($a1)\n"
1429 "lui $at, 0xABCD\n"
1430 "ori $at, 0xEF00\n"
1431 "daddu $at, $at, $a1\n"
1432 "lh $a0, 0($at)\n"
1433
1434 "lhu $a0, 0($a0)\n"
1435 "lhu $a0, 0($a1)\n"
1436 "lhu $a0, 2($a1)\n"
1437 "lhu $a0, 256($a1)\n"
1438 "lhu $a0, 1000($a1)\n"
1439 "lhu $a0, 0x7FFE($a1)\n"
1440 "ori $at, $zero, 0x8000\n"
1441 "daddu $at, $at, $a1\n"
1442 "lhu $a0, 0($at)\n"
1443 "ori $at, $zero, 0x8000\n"
1444 "daddu $at, $at, $a1\n"
1445 "lhu $a0, 2($at)\n"
1446 "lui $at, 1\n"
1447 "daddu $at, $at, $a1\n"
1448 "lhu $a0, 0($at)\n"
1449 "lui $at, 0x1234\n"
1450 "ori $at, 0x5678\n"
1451 "daddu $at, $at, $a1\n"
1452 "lhu $a0, 0($at)\n"
1453 "lhu $a0, -256($a1)\n"
1454 "lhu $a0, -32768($a1)\n"
1455 "lui $at, 0xABCD\n"
1456 "ori $at, 0xEF00\n"
1457 "daddu $at, $at, $a1\n"
1458 "lhu $a0, 0($at)\n"
1459
1460 "lw $a0, 0($a0)\n"
1461 "lw $a0, 0($a1)\n"
1462 "lw $a0, 4($a1)\n"
1463 "lw $a0, 256($a1)\n"
1464 "lw $a0, 1000($a1)\n"
1465 "lw $a0, 0x7FFC($a1)\n"
1466 "ori $at, $zero, 0x8000\n"
1467 "daddu $at, $at, $a1\n"
1468 "lw $a0, 0($at)\n"
1469 "ori $at, $zero, 0x8000\n"
1470 "daddu $at, $at, $a1\n"
1471 "lw $a0, 4($at)\n"
1472 "lui $at, 1\n"
1473 "daddu $at, $at, $a1\n"
1474 "lw $a0, 0($at)\n"
1475 "lui $at, 0x1234\n"
1476 "ori $at, 0x5678\n"
1477 "daddu $at, $at, $a1\n"
1478 "lw $a0, 0($at)\n"
1479 "lw $a0, -256($a1)\n"
1480 "lw $a0, -32768($a1)\n"
1481 "lui $at, 0xABCD\n"
1482 "ori $at, 0xEF00\n"
1483 "daddu $at, $at, $a1\n"
1484 "lw $a0, 0($at)\n"
1485
1486 "lwu $a0, 0($a0)\n"
1487 "lwu $a0, 0($a1)\n"
1488 "lwu $a0, 4($a1)\n"
1489 "lwu $a0, 256($a1)\n"
1490 "lwu $a0, 1000($a1)\n"
1491 "lwu $a0, 0x7FFC($a1)\n"
1492 "ori $at, $zero, 0x8000\n"
1493 "daddu $at, $at, $a1\n"
1494 "lwu $a0, 0($at)\n"
1495 "ori $at, $zero, 0x8000\n"
1496 "daddu $at, $at, $a1\n"
1497 "lwu $a0, 4($at)\n"
1498 "lui $at, 1\n"
1499 "daddu $at, $at, $a1\n"
1500 "lwu $a0, 0($at)\n"
1501 "lui $at, 0x1234\n"
1502 "ori $at, 0x5678\n"
1503 "daddu $at, $at, $a1\n"
1504 "lwu $a0, 0($at)\n"
1505 "lwu $a0, -256($a1)\n"
1506 "lwu $a0, -32768($a1)\n"
1507 "lui $at, 0xABCD\n"
1508 "ori $at, 0xEF00\n"
1509 "daddu $at, $at, $a1\n"
1510 "lwu $a0, 0($at)\n"
1511
1512 "ld $a0, 0($a0)\n"
1513 "ld $a0, 0($a1)\n"
1514 "lwu $a0, 4($a1)\n"
1515 "lwu $t3, 8($a1)\n"
1516 "dins $a0, $t3, 32, 32\n"
1517 "ld $a0, 256($a1)\n"
1518 "ld $a0, 1000($a1)\n"
1519 "ori $at, $zero, 0x7FF8\n"
1520 "daddu $at, $at, $a1\n"
1521 "lwu $a0, 4($at)\n"
1522 "lwu $t3, 8($at)\n"
1523 "dins $a0, $t3, 32, 32\n"
1524 "ori $at, $zero, 0x8000\n"
1525 "daddu $at, $at, $a1\n"
1526 "ld $a0, 0($at)\n"
1527 "ori $at, $zero, 0x8000\n"
1528 "daddu $at, $at, $a1\n"
1529 "lwu $a0, 4($at)\n"
1530 "lwu $t3, 8($at)\n"
1531 "dins $a0, $t3, 32, 32\n"
1532 "lui $at, 1\n"
1533 "daddu $at, $at, $a1\n"
1534 "ld $a0, 0($at)\n"
1535 "lui $at, 0x1234\n"
1536 "ori $at, 0x5678\n"
1537 "daddu $at, $at, $a1\n"
1538 "ld $a0, 0($at)\n"
1539 "ld $a0, -256($a1)\n"
1540 "ld $a0, -32768($a1)\n"
1541 "lui $at, 0xABCD\n"
1542 "ori $at, 0xEF00\n"
1543 "daddu $at, $at, $a1\n"
1544 "ld $a0, 0($at)\n";
1545 DriverStr(expected, "LoadFromOffset");
1546}
1547
1548TEST_F(AssemblerMIPS64Test, LoadFpuFromOffset) {
1549 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0);
1550 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 4);
1551 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 256);
1552 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x7FFC);
1553 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x8000);
1554 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x8004);
1555 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x10000);
1556 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x12345678);
1557 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, -256);
1558 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, -32768);
1559 __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0xABCDEF00);
1560
1561 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0);
1562 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 4);
1563 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 256);
1564 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x7FFC);
1565 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x8000);
1566 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x8004);
1567 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x10000);
1568 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x12345678);
1569 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, -256);
1570 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, -32768);
1571 __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0xABCDEF00);
1572
1573 const char* expected =
1574 "lwc1 $f0, 0($a0)\n"
1575 "lwc1 $f0, 4($a0)\n"
1576 "lwc1 $f0, 256($a0)\n"
1577 "lwc1 $f0, 0x7FFC($a0)\n"
1578 "ori $at, $zero, 0x8000\n"
1579 "daddu $at, $at, $a0\n"
1580 "lwc1 $f0, 0($at)\n"
1581 "ori $at, $zero, 0x8000\n"
1582 "daddu $at, $at, $a0\n"
1583 "lwc1 $f0, 4($at)\n"
1584 "lui $at, 1\n"
1585 "daddu $at, $at, $a0\n"
1586 "lwc1 $f0, 0($at)\n"
1587 "lui $at, 0x1234\n"
1588 "ori $at, 0x5678\n"
1589 "daddu $at, $at, $a0\n"
1590 "lwc1 $f0, 0($at)\n"
1591 "lwc1 $f0, -256($a0)\n"
1592 "lwc1 $f0, -32768($a0)\n"
1593 "lui $at, 0xABCD\n"
1594 "ori $at, 0xEF00\n"
1595 "daddu $at, $at, $a0\n"
1596 "lwc1 $f0, 0($at)\n"
1597
1598 "ldc1 $f0, 0($a0)\n"
1599 "lwc1 $f0, 4($a0)\n"
1600 "lw $t3, 8($a0)\n"
1601 "mthc1 $t3, $f0\n"
1602 "ldc1 $f0, 256($a0)\n"
1603 "ori $at, $zero, 0x7FF8\n"
1604 "daddu $at, $at, $a0\n"
1605 "lwc1 $f0, 4($at)\n"
1606 "lw $t3, 8($at)\n"
1607 "mthc1 $t3, $f0\n"
1608 "ori $at, $zero, 0x8000\n"
1609 "daddu $at, $at, $a0\n"
1610 "ldc1 $f0, 0($at)\n"
1611 "ori $at, $zero, 0x8000\n"
1612 "daddu $at, $at, $a0\n"
1613 "lwc1 $f0, 4($at)\n"
1614 "lw $t3, 8($at)\n"
1615 "mthc1 $t3, $f0\n"
1616 "lui $at, 1\n"
1617 "daddu $at, $at, $a0\n"
1618 "ldc1 $f0, 0($at)\n"
1619 "lui $at, 0x1234\n"
1620 "ori $at, 0x5678\n"
1621 "daddu $at, $at, $a0\n"
1622 "ldc1 $f0, 0($at)\n"
1623 "ldc1 $f0, -256($a0)\n"
1624 "ldc1 $f0, -32768($a0)\n"
1625 "lui $at, 0xABCD\n"
1626 "ori $at, 0xEF00\n"
1627 "daddu $at, $at, $a0\n"
1628 "ldc1 $f0, 0($at)\n";
1629 DriverStr(expected, "LoadFpuFromOffset");
1630}
1631
1632TEST_F(AssemblerMIPS64Test, StoreToOffset) {
1633 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A0, 0);
1634 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0);
1635 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 1);
1636 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 256);
1637 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 1000);
1638 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x7FFF);
1639 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x8000);
1640 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x8001);
1641 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x10000);
1642 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x12345678);
1643 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, -256);
1644 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, -32768);
1645 __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0xABCDEF00);
1646
1647 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A0, 0);
1648 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0);
1649 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 2);
1650 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 256);
1651 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 1000);
1652 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x7FFE);
1653 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x8000);
1654 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x8002);
1655 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x10000);
1656 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x12345678);
1657 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, -256);
1658 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, -32768);
1659 __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0xABCDEF00);
1660
1661 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A0, 0);
1662 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0);
1663 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 4);
1664 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 256);
1665 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 1000);
1666 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x7FFC);
1667 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x8000);
1668 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x8004);
1669 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x10000);
1670 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x12345678);
1671 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, -256);
1672 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, -32768);
1673 __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0xABCDEF00);
1674
1675 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A0, 0);
1676 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0);
1677 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 4);
1678 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 256);
1679 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 1000);
1680 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x7FFC);
1681 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x8000);
1682 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x8004);
1683 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x10000);
1684 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x12345678);
1685 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, -256);
1686 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, -32768);
1687 __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0xABCDEF00);
1688
1689 const char* expected =
1690 "sb $a0, 0($a0)\n"
1691 "sb $a0, 0($a1)\n"
1692 "sb $a0, 1($a1)\n"
1693 "sb $a0, 256($a1)\n"
1694 "sb $a0, 1000($a1)\n"
1695 "sb $a0, 0x7FFF($a1)\n"
1696 "ori $at, $zero, 0x8000\n"
1697 "daddu $at, $at, $a1\n"
1698 "sb $a0, 0($at)\n"
1699 "ori $at, $zero, 0x8000\n"
1700 "daddu $at, $at, $a1\n"
1701 "sb $a0, 1($at)\n"
1702 "lui $at, 1\n"
1703 "daddu $at, $at, $a1\n"
1704 "sb $a0, 0($at)\n"
1705 "lui $at, 0x1234\n"
1706 "ori $at, 0x5678\n"
1707 "daddu $at, $at, $a1\n"
1708 "sb $a0, 0($at)\n"
1709 "sb $a0, -256($a1)\n"
1710 "sb $a0, -32768($a1)\n"
1711 "lui $at, 0xABCD\n"
1712 "ori $at, 0xEF00\n"
1713 "daddu $at, $at, $a1\n"
1714 "sb $a0, 0($at)\n"
1715
1716 "sh $a0, 0($a0)\n"
1717 "sh $a0, 0($a1)\n"
1718 "sh $a0, 2($a1)\n"
1719 "sh $a0, 256($a1)\n"
1720 "sh $a0, 1000($a1)\n"
1721 "sh $a0, 0x7FFE($a1)\n"
1722 "ori $at, $zero, 0x8000\n"
1723 "daddu $at, $at, $a1\n"
1724 "sh $a0, 0($at)\n"
1725 "ori $at, $zero, 0x8000\n"
1726 "daddu $at, $at, $a1\n"
1727 "sh $a0, 2($at)\n"
1728 "lui $at, 1\n"
1729 "daddu $at, $at, $a1\n"
1730 "sh $a0, 0($at)\n"
1731 "lui $at, 0x1234\n"
1732 "ori $at, 0x5678\n"
1733 "daddu $at, $at, $a1\n"
1734 "sh $a0, 0($at)\n"
1735 "sh $a0, -256($a1)\n"
1736 "sh $a0, -32768($a1)\n"
1737 "lui $at, 0xABCD\n"
1738 "ori $at, 0xEF00\n"
1739 "daddu $at, $at, $a1\n"
1740 "sh $a0, 0($at)\n"
1741
1742 "sw $a0, 0($a0)\n"
1743 "sw $a0, 0($a1)\n"
1744 "sw $a0, 4($a1)\n"
1745 "sw $a0, 256($a1)\n"
1746 "sw $a0, 1000($a1)\n"
1747 "sw $a0, 0x7FFC($a1)\n"
1748 "ori $at, $zero, 0x8000\n"
1749 "daddu $at, $at, $a1\n"
1750 "sw $a0, 0($at)\n"
1751 "ori $at, $zero, 0x8000\n"
1752 "daddu $at, $at, $a1\n"
1753 "sw $a0, 4($at)\n"
1754 "lui $at, 1\n"
1755 "daddu $at, $at, $a1\n"
1756 "sw $a0, 0($at)\n"
1757 "lui $at, 0x1234\n"
1758 "ori $at, 0x5678\n"
1759 "daddu $at, $at, $a1\n"
1760 "sw $a0, 0($at)\n"
1761 "sw $a0, -256($a1)\n"
1762 "sw $a0, -32768($a1)\n"
1763 "lui $at, 0xABCD\n"
1764 "ori $at, 0xEF00\n"
1765 "daddu $at, $at, $a1\n"
1766 "sw $a0, 0($at)\n"
1767
1768 "sd $a0, 0($a0)\n"
1769 "sd $a0, 0($a1)\n"
1770 "sw $a0, 4($a1)\n"
1771 "dsrl32 $t3, $a0, 0\n"
1772 "sw $t3, 8($a1)\n"
1773 "sd $a0, 256($a1)\n"
1774 "sd $a0, 1000($a1)\n"
1775 "ori $at, $zero, 0x7FF8\n"
1776 "daddu $at, $at, $a1\n"
1777 "sw $a0, 4($at)\n"
1778 "dsrl32 $t3, $a0, 0\n"
1779 "sw $t3, 8($at)\n"
1780 "ori $at, $zero, 0x8000\n"
1781 "daddu $at, $at, $a1\n"
1782 "sd $a0, 0($at)\n"
1783 "ori $at, $zero, 0x8000\n"
1784 "daddu $at, $at, $a1\n"
1785 "sw $a0, 4($at)\n"
1786 "dsrl32 $t3, $a0, 0\n"
1787 "sw $t3, 8($at)\n"
1788 "lui $at, 1\n"
1789 "daddu $at, $at, $a1\n"
1790 "sd $a0, 0($at)\n"
1791 "lui $at, 0x1234\n"
1792 "ori $at, 0x5678\n"
1793 "daddu $at, $at, $a1\n"
1794 "sd $a0, 0($at)\n"
1795 "sd $a0, -256($a1)\n"
1796 "sd $a0, -32768($a1)\n"
1797 "lui $at, 0xABCD\n"
1798 "ori $at, 0xEF00\n"
1799 "daddu $at, $at, $a1\n"
1800 "sd $a0, 0($at)\n";
1801 DriverStr(expected, "StoreToOffset");
1802}
1803
1804TEST_F(AssemblerMIPS64Test, StoreFpuToOffset) {
1805 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0);
1806 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 4);
1807 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 256);
1808 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x7FFC);
1809 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x8000);
1810 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x8004);
1811 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x10000);
1812 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x12345678);
1813 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, -256);
1814 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, -32768);
1815 __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0xABCDEF00);
1816
1817 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0);
1818 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 4);
1819 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 256);
1820 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x7FFC);
1821 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x8000);
1822 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x8004);
1823 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x10000);
1824 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x12345678);
1825 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, -256);
1826 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, -32768);
1827 __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0xABCDEF00);
1828
1829 const char* expected =
1830 "swc1 $f0, 0($a0)\n"
1831 "swc1 $f0, 4($a0)\n"
1832 "swc1 $f0, 256($a0)\n"
1833 "swc1 $f0, 0x7FFC($a0)\n"
1834 "ori $at, $zero, 0x8000\n"
1835 "daddu $at, $at, $a0\n"
1836 "swc1 $f0, 0($at)\n"
1837 "ori $at, $zero, 0x8000\n"
1838 "daddu $at, $at, $a0\n"
1839 "swc1 $f0, 4($at)\n"
1840 "lui $at, 1\n"
1841 "daddu $at, $at, $a0\n"
1842 "swc1 $f0, 0($at)\n"
1843 "lui $at, 0x1234\n"
1844 "ori $at, 0x5678\n"
1845 "daddu $at, $at, $a0\n"
1846 "swc1 $f0, 0($at)\n"
1847 "swc1 $f0, -256($a0)\n"
1848 "swc1 $f0, -32768($a0)\n"
1849 "lui $at, 0xABCD\n"
1850 "ori $at, 0xEF00\n"
1851 "daddu $at, $at, $a0\n"
1852 "swc1 $f0, 0($at)\n"
1853
1854 "sdc1 $f0, 0($a0)\n"
1855 "mfhc1 $t3, $f0\n"
1856 "swc1 $f0, 4($a0)\n"
1857 "sw $t3, 8($a0)\n"
1858 "sdc1 $f0, 256($a0)\n"
1859 "ori $at, $zero, 0x7FF8\n"
1860 "daddu $at, $at, $a0\n"
1861 "mfhc1 $t3, $f0\n"
1862 "swc1 $f0, 4($at)\n"
1863 "sw $t3, 8($at)\n"
1864 "ori $at, $zero, 0x8000\n"
1865 "daddu $at, $at, $a0\n"
1866 "sdc1 $f0, 0($at)\n"
1867 "ori $at, $zero, 0x8000\n"
1868 "daddu $at, $at, $a0\n"
1869 "mfhc1 $t3, $f0\n"
1870 "swc1 $f0, 4($at)\n"
1871 "sw $t3, 8($at)\n"
1872 "lui $at, 1\n"
1873 "daddu $at, $at, $a0\n"
1874 "sdc1 $f0, 0($at)\n"
1875 "lui $at, 0x1234\n"
1876 "ori $at, 0x5678\n"
1877 "daddu $at, $at, $a0\n"
1878 "sdc1 $f0, 0($at)\n"
1879 "sdc1 $f0, -256($a0)\n"
1880 "sdc1 $f0, -32768($a0)\n"
1881 "lui $at, 0xABCD\n"
1882 "ori $at, 0xEF00\n"
1883 "daddu $at, $at, $a0\n"
1884 "sdc1 $f0, 0($at)\n";
1885 DriverStr(expected, "StoreFpuToOffset");
1886}
1887
Chris Larsenc733dca2016-05-13 16:11:47 -07001888///////////////////////
1889// Loading Constants //
1890///////////////////////
1891
1892TEST_F(AssemblerMIPS64Test, LoadConst32) {
1893 // IsUint<16>(value)
1894 __ LoadConst32(mips64::V0, 0);
1895 __ LoadConst32(mips64::V0, 65535);
1896 // IsInt<16>(value)
1897 __ LoadConst32(mips64::V0, -1);
1898 __ LoadConst32(mips64::V0, -32768);
1899 // Everything else
1900 __ LoadConst32(mips64::V0, 65536);
1901 __ LoadConst32(mips64::V0, 65537);
1902 __ LoadConst32(mips64::V0, 2147483647);
1903 __ LoadConst32(mips64::V0, -32769);
1904 __ LoadConst32(mips64::V0, -65536);
1905 __ LoadConst32(mips64::V0, -65537);
1906 __ LoadConst32(mips64::V0, -2147483647);
1907 __ LoadConst32(mips64::V0, -2147483648);
1908
1909 const char* expected =
1910 // IsUint<16>(value)
1911 "ori $v0, $zero, 0\n" // __ LoadConst32(mips64::V0, 0);
1912 "ori $v0, $zero, 65535\n" // __ LoadConst32(mips64::V0, 65535);
1913 // IsInt<16>(value)
1914 "addiu $v0, $zero, -1\n" // __ LoadConst32(mips64::V0, -1);
1915 "addiu $v0, $zero, -32768\n" // __ LoadConst32(mips64::V0, -32768);
1916 // Everything else
1917 "lui $v0, 1\n" // __ LoadConst32(mips64::V0, 65536);
1918 "lui $v0, 1\n" // __ LoadConst32(mips64::V0, 65537);
1919 "ori $v0, 1\n" // "
1920 "lui $v0, 32767\n" // __ LoadConst32(mips64::V0, 2147483647);
1921 "ori $v0, 65535\n" // "
1922 "lui $v0, 65535\n" // __ LoadConst32(mips64::V0, -32769);
1923 "ori $v0, 32767\n" // "
1924 "lui $v0, 65535\n" // __ LoadConst32(mips64::V0, -65536);
1925 "lui $v0, 65534\n" // __ LoadConst32(mips64::V0, -65537);
1926 "ori $v0, 65535\n" // "
1927 "lui $v0, 32768\n" // __ LoadConst32(mips64::V0, -2147483647);
1928 "ori $v0, 1\n" // "
1929 "lui $v0, 32768\n"; // __ LoadConst32(mips64::V0, -2147483648);
1930 DriverStr(expected, "LoadConst32");
1931}
1932
1933static uint64_t SignExtend16To64(uint16_t n) {
1934 return static_cast<int16_t>(n);
1935}
1936
1937// The art::mips64::Mips64Assembler::LoadConst64() method uses a template
1938// to minimize the number of instructions needed to load a 64-bit constant
1939// value into a register. The template calls various methods which emit
1940// MIPS machine instructions. This struct (class) uses the same template
1941// but overrides the definitions of the methods which emit MIPS instructions
1942// to use methods which simulate the operation of the corresponding MIPS
1943// instructions. After invoking LoadConst64() the target register should
1944// contain the same 64-bit value as was input to LoadConst64(). If the
1945// simulated register doesn't contain the correct value then there is probably
1946// an error in the template function.
1947struct LoadConst64Tester {
1948 LoadConst64Tester() {
1949 // Initialize all of the registers for simulation to zero.
1950 for (int r = 0; r < 32; r++) {
1951 regs_[r] = 0;
1952 }
1953 // Clear all of the path flags.
1954 loadconst64_paths_ = art::mips64::kLoadConst64PathZero;
1955 }
1956 void Addiu(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) {
1957 regs_[rd] = static_cast<int32_t>(regs_[rs] + SignExtend16To64(c));
1958 }
1959 void Daddiu(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) {
1960 regs_[rd] = regs_[rs] + SignExtend16To64(c);
1961 }
1962 void Dahi(mips64::GpuRegister rd, uint16_t c) {
1963 regs_[rd] += SignExtend16To64(c) << 32;
1964 }
1965 void Dati(mips64::GpuRegister rd, uint16_t c) {
1966 regs_[rd] += SignExtend16To64(c) << 48;
1967 }
1968 void Dinsu(mips64::GpuRegister rt, mips64::GpuRegister rs, int pos, int size) {
1969 CHECK(IsUint<5>(pos - 32)) << pos;
1970 CHECK(IsUint<5>(size - 1)) << size;
1971 CHECK(IsUint<5>(pos + size - 33)) << pos << " + " << size;
1972 uint64_t src_mask = (UINT64_C(1) << size) - 1;
1973 uint64_t dsk_mask = ~(src_mask << pos);
1974
1975 regs_[rt] = (regs_[rt] & dsk_mask) | ((regs_[rs] & src_mask) << pos);
1976 }
1977 void Dsll(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) {
1978 regs_[rd] = regs_[rt] << (shamt & 0x1f);
1979 }
1980 void Dsll32(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) {
1981 regs_[rd] = regs_[rt] << (32 + (shamt & 0x1f));
1982 }
1983 void Dsrl(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) {
1984 regs_[rd] = regs_[rt] >> (shamt & 0x1f);
1985 }
1986 void Dsrl32(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) {
1987 regs_[rd] = regs_[rt] >> (32 + (shamt & 0x1f));
1988 }
1989 void Lui(mips64::GpuRegister rd, uint16_t c) {
1990 regs_[rd] = SignExtend16To64(c) << 16;
1991 }
1992 void Ori(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) {
1993 regs_[rd] = regs_[rs] | c;
1994 }
1995 void LoadConst32(mips64::GpuRegister rd, int32_t c) {
1996 CHECK_NE(rd, 0);
1997 mips64::TemplateLoadConst32<LoadConst64Tester>(this, rd, c);
1998 CHECK_EQ(regs_[rd], static_cast<uint64_t>(c));
1999 }
2000 void LoadConst64(mips64::GpuRegister rd, int64_t c) {
2001 CHECK_NE(rd, 0);
2002 mips64::TemplateLoadConst64<LoadConst64Tester>(this, rd, c);
2003 CHECK_EQ(regs_[rd], static_cast<uint64_t>(c));
2004 }
2005 uint64_t regs_[32];
2006
2007 // Getter function for loadconst64_paths_.
2008 int GetPathsCovered() {
2009 return loadconst64_paths_;
2010 }
2011
2012 void RecordLoadConst64Path(int value) {
2013 loadconst64_paths_ |= value;
2014 }
2015
2016 private:
2017 // This variable holds a bitmask to tell us which paths were taken
2018 // through the template function which loads 64-bit values.
2019 int loadconst64_paths_;
2020};
2021
2022TEST_F(AssemblerMIPS64Test, LoadConst64) {
2023 const uint16_t imms[] = {
2024 0, 1, 2, 3, 4, 0x33, 0x66, 0x55, 0x99, 0xaa, 0xcc, 0xff, 0x5500, 0x5555,
2025 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, 0x8000, 0x8001, 0x8002, 0x8003, 0x8004,
2026 0xaaaa, 0xfffc, 0xfffd, 0xfffe, 0xffff
2027 };
2028 unsigned d0, d1, d2, d3;
2029 LoadConst64Tester tester;
2030
2031 union {
2032 int64_t v64;
2033 uint16_t v16[4];
2034 } u;
2035
2036 for (d3 = 0; d3 < sizeof imms / sizeof imms[0]; d3++) {
2037 u.v16[3] = imms[d3];
2038
2039 for (d2 = 0; d2 < sizeof imms / sizeof imms[0]; d2++) {
2040 u.v16[2] = imms[d2];
2041
2042 for (d1 = 0; d1 < sizeof imms / sizeof imms[0]; d1++) {
2043 u.v16[1] = imms[d1];
2044
2045 for (d0 = 0; d0 < sizeof imms / sizeof imms[0]; d0++) {
2046 u.v16[0] = imms[d0];
2047
2048 tester.LoadConst64(mips64::V0, u.v64);
2049 }
2050 }
2051 }
2052 }
2053
2054 // Verify that we tested all paths through the "load 64-bit value"
2055 // function template.
2056 EXPECT_EQ(tester.GetPathsCovered(), art::mips64::kLoadConst64PathAllPaths);
2057}
2058
Lazar Trsicd9672662015-09-03 17:33:01 +02002059#undef __
2060
Chris Larsendbce0d72015-09-17 13:34:00 -07002061} // namespace art