Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1 | /* |
| 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 Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 27 | #define __ GetAssembler()-> |
| 28 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 29 | namespace art { |
| 30 | |
| 31 | struct MIPS64CpuRegisterCompare { |
| 32 | bool operator()(const mips64::GpuRegister& a, const mips64::GpuRegister& b) const { |
| 33 | return a < b; |
| 34 | } |
| 35 | }; |
| 36 | |
| 37 | class 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 Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 53 | std::string GetAssemblerCmdName() OVERRIDE { |
| 54 | // We assemble and link for MIPS64R6. See GetAssemblerParameters() for details. |
| 55 | return "gcc"; |
| 56 | } |
| 57 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 58 | std::string GetAssemblerParameters() OVERRIDE { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 59 | // 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 Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 73 | } |
| 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(®isters_); |
| 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 Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 205 | 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 Gampe | 2e965ac | 2016-11-03 17:24:15 -0700 | [diff] [blame] | 215 | const std::string& instr_name) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 216 | 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 Gampe | 2e965ac | 2016-11-03 17:24:15 -0700 | [diff] [blame] | 244 | const std::string& instr_name) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 245 | 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 Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 270 | 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 | |
| 278 | TEST_F(AssemblerMIPS64Test, Toolchain) { |
| 279 | EXPECT_TRUE(CheckTools()); |
| 280 | } |
| 281 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 282 | /////////////////// |
| 283 | // FP Operations // |
| 284 | /////////////////// |
| 285 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 286 | TEST_F(AssemblerMIPS64Test, AddS) { |
| 287 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::AddS, "add.s ${reg1}, ${reg2}, ${reg3}"), "add.s"); |
| 288 | } |
| 289 | |
| 290 | TEST_F(AssemblerMIPS64Test, AddD) { |
| 291 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::AddD, "add.d ${reg1}, ${reg2}, ${reg3}"), "add.d"); |
| 292 | } |
| 293 | |
| 294 | TEST_F(AssemblerMIPS64Test, SubS) { |
| 295 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::SubS, "sub.s ${reg1}, ${reg2}, ${reg3}"), "sub.s"); |
| 296 | } |
| 297 | |
| 298 | TEST_F(AssemblerMIPS64Test, SubD) { |
| 299 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::SubD, "sub.d ${reg1}, ${reg2}, ${reg3}"), "sub.d"); |
| 300 | } |
| 301 | |
| 302 | TEST_F(AssemblerMIPS64Test, MulS) { |
| 303 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MulS, "mul.s ${reg1}, ${reg2}, ${reg3}"), "mul.s"); |
| 304 | } |
| 305 | |
| 306 | TEST_F(AssemblerMIPS64Test, MulD) { |
| 307 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MulD, "mul.d ${reg1}, ${reg2}, ${reg3}"), "mul.d"); |
| 308 | } |
| 309 | |
| 310 | TEST_F(AssemblerMIPS64Test, DivS) { |
| 311 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::DivS, "div.s ${reg1}, ${reg2}, ${reg3}"), "div.s"); |
| 312 | } |
| 313 | |
| 314 | TEST_F(AssemblerMIPS64Test, DivD) { |
| 315 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::DivD, "div.d ${reg1}, ${reg2}, ${reg3}"), "div.d"); |
| 316 | } |
| 317 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 318 | TEST_F(AssemblerMIPS64Test, SqrtS) { |
| 319 | DriverStr(RepeatFF(&mips64::Mips64Assembler::SqrtS, "sqrt.s ${reg1}, ${reg2}"), "sqrt.s"); |
| 320 | } |
| 321 | |
| 322 | TEST_F(AssemblerMIPS64Test, SqrtD) { |
| 323 | DriverStr(RepeatFF(&mips64::Mips64Assembler::SqrtD, "sqrt.d ${reg1}, ${reg2}"), "sqrt.d"); |
| 324 | } |
| 325 | |
| 326 | TEST_F(AssemblerMIPS64Test, AbsS) { |
| 327 | DriverStr(RepeatFF(&mips64::Mips64Assembler::AbsS, "abs.s ${reg1}, ${reg2}"), "abs.s"); |
| 328 | } |
| 329 | |
| 330 | TEST_F(AssemblerMIPS64Test, AbsD) { |
| 331 | DriverStr(RepeatFF(&mips64::Mips64Assembler::AbsD, "abs.d ${reg1}, ${reg2}"), "abs.d"); |
| 332 | } |
| 333 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 334 | TEST_F(AssemblerMIPS64Test, MovS) { |
| 335 | DriverStr(RepeatFF(&mips64::Mips64Assembler::MovS, "mov.s ${reg1}, ${reg2}"), "mov.s"); |
| 336 | } |
| 337 | |
| 338 | TEST_F(AssemblerMIPS64Test, MovD) { |
| 339 | DriverStr(RepeatFF(&mips64::Mips64Assembler::MovD, "mov.d ${reg1}, ${reg2}"), "mov.d"); |
| 340 | } |
| 341 | |
| 342 | TEST_F(AssemblerMIPS64Test, NegS) { |
| 343 | DriverStr(RepeatFF(&mips64::Mips64Assembler::NegS, "neg.s ${reg1}, ${reg2}"), "neg.s"); |
| 344 | } |
| 345 | |
| 346 | TEST_F(AssemblerMIPS64Test, NegD) { |
| 347 | DriverStr(RepeatFF(&mips64::Mips64Assembler::NegD, "neg.d ${reg1}, ${reg2}"), "neg.d"); |
| 348 | } |
| 349 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 350 | TEST_F(AssemblerMIPS64Test, RoundLS) { |
| 351 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundLS, "round.l.s ${reg1}, ${reg2}"), "round.l.s"); |
| 352 | } |
| 353 | |
| 354 | TEST_F(AssemblerMIPS64Test, RoundLD) { |
| 355 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundLD, "round.l.d ${reg1}, ${reg2}"), "round.l.d"); |
| 356 | } |
| 357 | |
| 358 | TEST_F(AssemblerMIPS64Test, RoundWS) { |
| 359 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundWS, "round.w.s ${reg1}, ${reg2}"), "round.w.s"); |
| 360 | } |
| 361 | |
| 362 | TEST_F(AssemblerMIPS64Test, RoundWD) { |
| 363 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RoundWD, "round.w.d ${reg1}, ${reg2}"), "round.w.d"); |
| 364 | } |
| 365 | |
| 366 | TEST_F(AssemblerMIPS64Test, CeilLS) { |
| 367 | DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilLS, "ceil.l.s ${reg1}, ${reg2}"), "ceil.l.s"); |
| 368 | } |
| 369 | |
| 370 | TEST_F(AssemblerMIPS64Test, CeilLD) { |
| 371 | DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilLD, "ceil.l.d ${reg1}, ${reg2}"), "ceil.l.d"); |
| 372 | } |
| 373 | |
| 374 | TEST_F(AssemblerMIPS64Test, CeilWS) { |
| 375 | DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilWS, "ceil.w.s ${reg1}, ${reg2}"), "ceil.w.s"); |
| 376 | } |
| 377 | |
| 378 | TEST_F(AssemblerMIPS64Test, CeilWD) { |
| 379 | DriverStr(RepeatFF(&mips64::Mips64Assembler::CeilWD, "ceil.w.d ${reg1}, ${reg2}"), "ceil.w.d"); |
| 380 | } |
| 381 | |
| 382 | TEST_F(AssemblerMIPS64Test, FloorLS) { |
| 383 | DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorLS, "floor.l.s ${reg1}, ${reg2}"), "floor.l.s"); |
| 384 | } |
| 385 | |
| 386 | TEST_F(AssemblerMIPS64Test, FloorLD) { |
| 387 | DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorLD, "floor.l.d ${reg1}, ${reg2}"), "floor.l.d"); |
| 388 | } |
| 389 | |
| 390 | TEST_F(AssemblerMIPS64Test, FloorWS) { |
| 391 | DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorWS, "floor.w.s ${reg1}, ${reg2}"), "floor.w.s"); |
| 392 | } |
| 393 | |
| 394 | TEST_F(AssemblerMIPS64Test, FloorWD) { |
| 395 | DriverStr(RepeatFF(&mips64::Mips64Assembler::FloorWD, "floor.w.d ${reg1}, ${reg2}"), "floor.w.d"); |
| 396 | } |
| 397 | |
| 398 | TEST_F(AssemblerMIPS64Test, SelS) { |
| 399 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::SelS, "sel.s ${reg1}, ${reg2}, ${reg3}"), "sel.s"); |
| 400 | } |
| 401 | |
| 402 | TEST_F(AssemblerMIPS64Test, SelD) { |
| 403 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::SelD, "sel.d ${reg1}, ${reg2}, ${reg3}"), "sel.d"); |
| 404 | } |
| 405 | |
| 406 | TEST_F(AssemblerMIPS64Test, RintS) { |
| 407 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RintS, "rint.s ${reg1}, ${reg2}"), "rint.s"); |
| 408 | } |
| 409 | |
| 410 | TEST_F(AssemblerMIPS64Test, RintD) { |
| 411 | DriverStr(RepeatFF(&mips64::Mips64Assembler::RintD, "rint.d ${reg1}, ${reg2}"), "rint.d"); |
| 412 | } |
| 413 | |
| 414 | TEST_F(AssemblerMIPS64Test, ClassS) { |
| 415 | DriverStr(RepeatFF(&mips64::Mips64Assembler::ClassS, "class.s ${reg1}, ${reg2}"), "class.s"); |
| 416 | } |
| 417 | |
| 418 | TEST_F(AssemblerMIPS64Test, ClassD) { |
| 419 | DriverStr(RepeatFF(&mips64::Mips64Assembler::ClassD, "class.d ${reg1}, ${reg2}"), "class.d"); |
| 420 | } |
| 421 | |
| 422 | TEST_F(AssemblerMIPS64Test, MinS) { |
| 423 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MinS, "min.s ${reg1}, ${reg2}, ${reg3}"), "min.s"); |
| 424 | } |
| 425 | |
| 426 | TEST_F(AssemblerMIPS64Test, MinD) { |
| 427 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MinD, "min.d ${reg1}, ${reg2}, ${reg3}"), "min.d"); |
| 428 | } |
| 429 | |
| 430 | TEST_F(AssemblerMIPS64Test, MaxS) { |
| 431 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MaxS, "max.s ${reg1}, ${reg2}, ${reg3}"), "max.s"); |
| 432 | } |
| 433 | |
| 434 | TEST_F(AssemblerMIPS64Test, MaxD) { |
| 435 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::MaxD, "max.d ${reg1}, ${reg2}, ${reg3}"), "max.d"); |
| 436 | } |
| 437 | |
Alexey Frunze | 299a939 | 2015-12-08 16:08:02 -0800 | [diff] [blame] | 438 | TEST_F(AssemblerMIPS64Test, CmpUnS) { |
| 439 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUnS, "cmp.un.s ${reg1}, ${reg2}, ${reg3}"), |
| 440 | "cmp.un.s"); |
| 441 | } |
| 442 | |
| 443 | TEST_F(AssemblerMIPS64Test, CmpEqS) { |
| 444 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpEqS, "cmp.eq.s ${reg1}, ${reg2}, ${reg3}"), |
| 445 | "cmp.eq.s"); |
| 446 | } |
| 447 | |
| 448 | TEST_F(AssemblerMIPS64Test, CmpUeqS) { |
| 449 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUeqS, "cmp.ueq.s ${reg1}, ${reg2}, ${reg3}"), |
| 450 | "cmp.ueq.s"); |
| 451 | } |
| 452 | |
| 453 | TEST_F(AssemblerMIPS64Test, CmpLtS) { |
| 454 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLtS, "cmp.lt.s ${reg1}, ${reg2}, ${reg3}"), |
| 455 | "cmp.lt.s"); |
| 456 | } |
| 457 | |
| 458 | TEST_F(AssemblerMIPS64Test, CmpUltS) { |
| 459 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUltS, "cmp.ult.s ${reg1}, ${reg2}, ${reg3}"), |
| 460 | "cmp.ult.s"); |
| 461 | } |
| 462 | |
| 463 | TEST_F(AssemblerMIPS64Test, CmpLeS) { |
| 464 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLeS, "cmp.le.s ${reg1}, ${reg2}, ${reg3}"), |
| 465 | "cmp.le.s"); |
| 466 | } |
| 467 | |
| 468 | TEST_F(AssemblerMIPS64Test, CmpUleS) { |
| 469 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUleS, "cmp.ule.s ${reg1}, ${reg2}, ${reg3}"), |
| 470 | "cmp.ule.s"); |
| 471 | } |
| 472 | |
| 473 | TEST_F(AssemblerMIPS64Test, CmpOrS) { |
| 474 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpOrS, "cmp.or.s ${reg1}, ${reg2}, ${reg3}"), |
| 475 | "cmp.or.s"); |
| 476 | } |
| 477 | |
| 478 | TEST_F(AssemblerMIPS64Test, CmpUneS) { |
| 479 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUneS, "cmp.une.s ${reg1}, ${reg2}, ${reg3}"), |
| 480 | "cmp.une.s"); |
| 481 | } |
| 482 | |
| 483 | TEST_F(AssemblerMIPS64Test, CmpNeS) { |
| 484 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpNeS, "cmp.ne.s ${reg1}, ${reg2}, ${reg3}"), |
| 485 | "cmp.ne.s"); |
| 486 | } |
| 487 | |
| 488 | TEST_F(AssemblerMIPS64Test, CmpUnD) { |
| 489 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUnD, "cmp.un.d ${reg1}, ${reg2}, ${reg3}"), |
| 490 | "cmp.un.d"); |
| 491 | } |
| 492 | |
| 493 | TEST_F(AssemblerMIPS64Test, CmpEqD) { |
| 494 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpEqD, "cmp.eq.d ${reg1}, ${reg2}, ${reg3}"), |
| 495 | "cmp.eq.d"); |
| 496 | } |
| 497 | |
| 498 | TEST_F(AssemblerMIPS64Test, CmpUeqD) { |
| 499 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUeqD, "cmp.ueq.d ${reg1}, ${reg2}, ${reg3}"), |
| 500 | "cmp.ueq.d"); |
| 501 | } |
| 502 | |
| 503 | TEST_F(AssemblerMIPS64Test, CmpLtD) { |
| 504 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLtD, "cmp.lt.d ${reg1}, ${reg2}, ${reg3}"), |
| 505 | "cmp.lt.d"); |
| 506 | } |
| 507 | |
| 508 | TEST_F(AssemblerMIPS64Test, CmpUltD) { |
| 509 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUltD, "cmp.ult.d ${reg1}, ${reg2}, ${reg3}"), |
| 510 | "cmp.ult.d"); |
| 511 | } |
| 512 | |
| 513 | TEST_F(AssemblerMIPS64Test, CmpLeD) { |
| 514 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpLeD, "cmp.le.d ${reg1}, ${reg2}, ${reg3}"), |
| 515 | "cmp.le.d"); |
| 516 | } |
| 517 | |
| 518 | TEST_F(AssemblerMIPS64Test, CmpUleD) { |
| 519 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUleD, "cmp.ule.d ${reg1}, ${reg2}, ${reg3}"), |
| 520 | "cmp.ule.d"); |
| 521 | } |
| 522 | |
| 523 | TEST_F(AssemblerMIPS64Test, CmpOrD) { |
| 524 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpOrD, "cmp.or.d ${reg1}, ${reg2}, ${reg3}"), |
| 525 | "cmp.or.d"); |
| 526 | } |
| 527 | |
| 528 | TEST_F(AssemblerMIPS64Test, CmpUneD) { |
| 529 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpUneD, "cmp.une.d ${reg1}, ${reg2}, ${reg3}"), |
| 530 | "cmp.une.d"); |
| 531 | } |
| 532 | |
| 533 | TEST_F(AssemblerMIPS64Test, CmpNeD) { |
| 534 | DriverStr(RepeatFFF(&mips64::Mips64Assembler::CmpNeD, "cmp.ne.d ${reg1}, ${reg2}, ${reg3}"), |
| 535 | "cmp.ne.d"); |
| 536 | } |
| 537 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 538 | TEST_F(AssemblerMIPS64Test, CvtDL) { |
| 539 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtdl, "cvt.d.l ${reg1}, ${reg2}"), "cvt.d.l"); |
| 540 | } |
| 541 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 542 | TEST_F(AssemblerMIPS64Test, CvtDS) { |
| 543 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtds, "cvt.d.s ${reg1}, ${reg2}"), "cvt.d.s"); |
| 544 | } |
| 545 | |
| 546 | TEST_F(AssemblerMIPS64Test, CvtDW) { |
| 547 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtdw, "cvt.d.w ${reg1}, ${reg2}"), "cvt.d.w"); |
| 548 | } |
| 549 | |
| 550 | TEST_F(AssemblerMIPS64Test, CvtSL) { |
| 551 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsl, "cvt.s.l ${reg1}, ${reg2}"), "cvt.s.l"); |
| 552 | } |
| 553 | |
| 554 | TEST_F(AssemblerMIPS64Test, CvtSD) { |
| 555 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsd, "cvt.s.d ${reg1}, ${reg2}"), "cvt.s.d"); |
| 556 | } |
| 557 | |
| 558 | TEST_F(AssemblerMIPS64Test, CvtSW) { |
| 559 | DriverStr(RepeatFF(&mips64::Mips64Assembler::Cvtsw, "cvt.s.w ${reg1}, ${reg2}"), "cvt.s.w"); |
| 560 | } |
| 561 | |
Alexey Frunze | baf60b7 | 2015-12-22 15:15:03 -0800 | [diff] [blame] | 562 | TEST_F(AssemblerMIPS64Test, TruncWS) { |
| 563 | DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncWS, "trunc.w.s ${reg1}, ${reg2}"), "trunc.w.s"); |
| 564 | } |
| 565 | |
| 566 | TEST_F(AssemblerMIPS64Test, TruncWD) { |
| 567 | DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncWD, "trunc.w.d ${reg1}, ${reg2}"), "trunc.w.d"); |
| 568 | } |
| 569 | |
| 570 | TEST_F(AssemblerMIPS64Test, TruncLS) { |
| 571 | DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncLS, "trunc.l.s ${reg1}, ${reg2}"), "trunc.l.s"); |
| 572 | } |
| 573 | |
| 574 | TEST_F(AssemblerMIPS64Test, TruncLD) { |
| 575 | DriverStr(RepeatFF(&mips64::Mips64Assembler::TruncLD, "trunc.l.d ${reg1}, ${reg2}"), "trunc.l.d"); |
| 576 | } |
| 577 | |
Lazar Trsic | d967266 | 2015-09-03 17:33:01 +0200 | [diff] [blame] | 578 | TEST_F(AssemblerMIPS64Test, Mfc1) { |
| 579 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Mfc1, "mfc1 ${reg1}, ${reg2}"), "Mfc1"); |
| 580 | } |
| 581 | |
| 582 | TEST_F(AssemblerMIPS64Test, Mfhc1) { |
| 583 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Mfhc1, "mfhc1 ${reg1}, ${reg2}"), "Mfhc1"); |
| 584 | } |
| 585 | |
| 586 | TEST_F(AssemblerMIPS64Test, Mtc1) { |
| 587 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Mtc1, "mtc1 ${reg1}, ${reg2}"), "Mtc1"); |
| 588 | } |
| 589 | |
| 590 | TEST_F(AssemblerMIPS64Test, Mthc1) { |
| 591 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Mthc1, "mthc1 ${reg1}, ${reg2}"), "Mthc1"); |
| 592 | } |
| 593 | |
| 594 | TEST_F(AssemblerMIPS64Test, Dmfc1) { |
| 595 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Dmfc1, "dmfc1 ${reg1}, ${reg2}"), "Dmfc1"); |
| 596 | } |
| 597 | |
| 598 | TEST_F(AssemblerMIPS64Test, Dmtc1) { |
| 599 | DriverStr(RepeatRF(&mips64::Mips64Assembler::Dmtc1, "dmtc1 ${reg1}, ${reg2}"), "Dmtc1"); |
| 600 | } |
| 601 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 602 | TEST_F(AssemblerMIPS64Test, Lwc1) { |
| 603 | DriverStr(RepeatFRIb(&mips64::Mips64Assembler::Lwc1, -16, "lwc1 ${reg1}, {imm}(${reg2})"), |
| 604 | "lwc1"); |
| 605 | } |
| 606 | |
| 607 | TEST_F(AssemblerMIPS64Test, Ldc1) { |
| 608 | DriverStr(RepeatFRIb(&mips64::Mips64Assembler::Ldc1, -16, "ldc1 ${reg1}, {imm}(${reg2})"), |
| 609 | "ldc1"); |
| 610 | } |
| 611 | |
| 612 | TEST_F(AssemblerMIPS64Test, Swc1) { |
| 613 | DriverStr(RepeatFRIb(&mips64::Mips64Assembler::Swc1, -16, "swc1 ${reg1}, {imm}(${reg2})"), |
| 614 | "swc1"); |
| 615 | } |
| 616 | |
| 617 | TEST_F(AssemblerMIPS64Test, Sdc1) { |
| 618 | DriverStr(RepeatFRIb(&mips64::Mips64Assembler::Sdc1, -16, "sdc1 ${reg1}, {imm}(${reg2})"), |
| 619 | "sdc1"); |
| 620 | } |
| 621 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 622 | //////////////// |
| 623 | // CALL / JMP // |
| 624 | //////////////// |
| 625 | |
| 626 | TEST_F(AssemblerMIPS64Test, Jalr) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 627 | DriverStr(".set noreorder\n" + |
| 628 | RepeatRRNoDupes(&mips64::Mips64Assembler::Jalr, "jalr ${reg1}, ${reg2}"), "jalr"); |
| 629 | } |
| 630 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 631 | TEST_F(AssemblerMIPS64Test, Balc) { |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 632 | mips64::Mips64Label label1, label2; |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 633 | __ Balc(&label1); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 634 | constexpr size_t kAdduCount1 = 63; |
| 635 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 636 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 637 | } |
| 638 | __ Bind(&label1); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 639 | __ Balc(&label2); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 640 | constexpr size_t kAdduCount2 = 64; |
| 641 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 642 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 643 | } |
| 644 | __ Bind(&label2); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 645 | __ Balc(&label1); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 646 | |
| 647 | std::string expected = |
| 648 | ".set noreorder\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 649 | "balc 1f\n" + |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 650 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 651 | "1:\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 652 | "balc 2f\n" + |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 653 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 654 | "2:\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 655 | "balc 1b\n"; |
| 656 | DriverStr(expected, "Balc"); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 657 | } |
| 658 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 659 | TEST_F(AssemblerMIPS64Test, LongBalc) { |
Vladimir Marko | 3607394 | 2016-12-14 14:18:22 +0000 | [diff] [blame] | 660 | constexpr uint32_t kNopCount1 = (1u << 25) + 1; |
| 661 | constexpr uint32_t kNopCount2 = (1u << 25) + 1; |
| 662 | constexpr uint32_t kRequiredCapacity = (kNopCount1 + kNopCount2 + 6u) * 4u; |
| 663 | ASSERT_LT(__ GetBuffer()->Capacity(), kRequiredCapacity); |
| 664 | __ GetBuffer()->ExtendCapacity(kRequiredCapacity); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 665 | mips64::Mips64Label label1, label2; |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 666 | __ Balc(&label1); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 667 | for (uint32_t i = 0; i != kNopCount1; ++i) { |
| 668 | __ Nop(); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 669 | } |
| 670 | __ Bind(&label1); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 671 | __ Balc(&label2); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 672 | for (uint32_t i = 0; i != kNopCount2; ++i) { |
| 673 | __ Nop(); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 674 | } |
| 675 | __ Bind(&label2); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 676 | __ Balc(&label1); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 677 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 678 | uint32_t offset_forward1 = 2 + kNopCount1; // 2: account for auipc and jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 679 | offset_forward1 <<= 2; |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 680 | offset_forward1 += (offset_forward1 & 0x8000) << 1; // Account for sign extension in jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 681 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 682 | uint32_t offset_forward2 = 2 + kNopCount2; // 2: account for auipc and jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 683 | offset_forward2 <<= 2; |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 684 | offset_forward2 += (offset_forward2 & 0x8000) << 1; // Account for sign extension in jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 685 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 686 | uint32_t offset_back = -(2 + kNopCount2); // 2: account for auipc and jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 687 | offset_back <<= 2; |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 688 | offset_back += (offset_back & 0x8000) << 1; // Account for sign extension in jialc. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 689 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 690 | // Note, we're using the ".fill" directive to tell the assembler to generate many NOPs |
| 691 | // instead of generating them ourselves in the source code. This saves a few minutes |
| 692 | // of test time. |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 693 | std::ostringstream oss; |
| 694 | oss << |
| 695 | ".set noreorder\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 696 | "auipc $at, 0x" << std::hex << High16Bits(offset_forward1) << "\n" |
| 697 | "jialc $at, 0x" << std::hex << Low16Bits(offset_forward1) << "\n" |
| 698 | ".fill 0x" << std::hex << kNopCount1 << " , 4, 0\n" |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 699 | "1:\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 700 | "auipc $at, 0x" << std::hex << High16Bits(offset_forward2) << "\n" |
| 701 | "jialc $at, 0x" << std::hex << Low16Bits(offset_forward2) << "\n" |
| 702 | ".fill 0x" << std::hex << kNopCount2 << " , 4, 0\n" |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 703 | "2:\n" |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 704 | "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n" |
| 705 | "jialc $at, 0x" << std::hex << Low16Bits(offset_back) << "\n"; |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 706 | std::string expected = oss.str(); |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 707 | DriverStr(expected, "LongBalc"); |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 708 | } |
| 709 | |
| 710 | TEST_F(AssemblerMIPS64Test, Bc) { |
| 711 | mips64::Mips64Label label1, label2; |
| 712 | __ Bc(&label1); |
| 713 | constexpr size_t kAdduCount1 = 63; |
| 714 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 715 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 716 | } |
| 717 | __ Bind(&label1); |
| 718 | __ Bc(&label2); |
| 719 | constexpr size_t kAdduCount2 = 64; |
| 720 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 721 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 722 | } |
| 723 | __ Bind(&label2); |
| 724 | __ Bc(&label1); |
| 725 | |
| 726 | std::string expected = |
| 727 | ".set noreorder\n" |
| 728 | "bc 1f\n" + |
| 729 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 730 | "1:\n" |
| 731 | "bc 2f\n" + |
| 732 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 733 | "2:\n" |
| 734 | "bc 1b\n"; |
| 735 | DriverStr(expected, "Bc"); |
| 736 | } |
| 737 | |
| 738 | TEST_F(AssemblerMIPS64Test, Beqzc) { |
| 739 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Beqzc, "Beqzc"); |
| 740 | } |
| 741 | |
| 742 | TEST_F(AssemblerMIPS64Test, Bnezc) { |
| 743 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Bnezc, "Bnezc"); |
| 744 | } |
| 745 | |
| 746 | TEST_F(AssemblerMIPS64Test, Bltzc) { |
| 747 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Bltzc, "Bltzc"); |
| 748 | } |
| 749 | |
| 750 | TEST_F(AssemblerMIPS64Test, Bgezc) { |
| 751 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Bgezc, "Bgezc"); |
| 752 | } |
| 753 | |
| 754 | TEST_F(AssemblerMIPS64Test, Blezc) { |
| 755 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Blezc, "Blezc"); |
| 756 | } |
| 757 | |
| 758 | TEST_F(AssemblerMIPS64Test, Bgtzc) { |
| 759 | BranchCondOneRegHelper(&mips64::Mips64Assembler::Bgtzc, "Bgtzc"); |
| 760 | } |
| 761 | |
| 762 | TEST_F(AssemblerMIPS64Test, Beqc) { |
| 763 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Beqc, "Beqc"); |
| 764 | } |
| 765 | |
| 766 | TEST_F(AssemblerMIPS64Test, Bnec) { |
| 767 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bnec, "Bnec"); |
| 768 | } |
| 769 | |
| 770 | TEST_F(AssemblerMIPS64Test, Bltc) { |
| 771 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bltc, "Bltc"); |
| 772 | } |
| 773 | |
| 774 | TEST_F(AssemblerMIPS64Test, Bgec) { |
| 775 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bgec, "Bgec"); |
| 776 | } |
| 777 | |
| 778 | TEST_F(AssemblerMIPS64Test, Bltuc) { |
| 779 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bltuc, "Bltuc"); |
| 780 | } |
| 781 | |
| 782 | TEST_F(AssemblerMIPS64Test, Bgeuc) { |
| 783 | BranchCondTwoRegsHelper(&mips64::Mips64Assembler::Bgeuc, "Bgeuc"); |
| 784 | } |
| 785 | |
Alexey Frunze | 299a939 | 2015-12-08 16:08:02 -0800 | [diff] [blame] | 786 | TEST_F(AssemblerMIPS64Test, Bc1eqz) { |
| 787 | mips64::Mips64Label label; |
| 788 | __ Bc1eqz(mips64::F0, &label); |
| 789 | constexpr size_t kAdduCount1 = 63; |
| 790 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 791 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 792 | } |
| 793 | __ Bind(&label); |
| 794 | constexpr size_t kAdduCount2 = 64; |
| 795 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 796 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 797 | } |
| 798 | __ Bc1eqz(mips64::F31, &label); |
| 799 | |
| 800 | std::string expected = |
| 801 | ".set noreorder\n" |
| 802 | "bc1eqz $f0, 1f\n" |
| 803 | "nop\n" + |
| 804 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 805 | "1:\n" + |
| 806 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 807 | "bc1eqz $f31, 1b\n" |
| 808 | "nop\n"; |
| 809 | DriverStr(expected, "Bc1eqz"); |
| 810 | } |
| 811 | |
| 812 | TEST_F(AssemblerMIPS64Test, Bc1nez) { |
| 813 | mips64::Mips64Label label; |
| 814 | __ Bc1nez(mips64::F0, &label); |
| 815 | constexpr size_t kAdduCount1 = 63; |
| 816 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 817 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 818 | } |
| 819 | __ Bind(&label); |
| 820 | constexpr size_t kAdduCount2 = 64; |
| 821 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 822 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 823 | } |
| 824 | __ Bc1nez(mips64::F31, &label); |
| 825 | |
| 826 | std::string expected = |
| 827 | ".set noreorder\n" |
| 828 | "bc1nez $f0, 1f\n" |
| 829 | "nop\n" + |
| 830 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 831 | "1:\n" + |
| 832 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 833 | "bc1nez $f31, 1b\n" |
| 834 | "nop\n"; |
| 835 | DriverStr(expected, "Bc1nez"); |
| 836 | } |
| 837 | |
Alexey Frunze | a0e87b0 | 2015-09-24 22:57:20 -0700 | [diff] [blame] | 838 | TEST_F(AssemblerMIPS64Test, LongBeqc) { |
| 839 | mips64::Mips64Label label; |
| 840 | __ Beqc(mips64::A0, mips64::A1, &label); |
| 841 | constexpr uint32_t kAdduCount1 = (1u << 15) + 1; |
| 842 | for (uint32_t i = 0; i != kAdduCount1; ++i) { |
| 843 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 844 | } |
| 845 | __ Bind(&label); |
| 846 | constexpr uint32_t kAdduCount2 = (1u << 15) + 1; |
| 847 | for (uint32_t i = 0; i != kAdduCount2; ++i) { |
| 848 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 849 | } |
| 850 | __ Beqc(mips64::A2, mips64::A3, &label); |
| 851 | |
| 852 | uint32_t offset_forward = 2 + kAdduCount1; // 2: account for auipc and jic. |
| 853 | offset_forward <<= 2; |
| 854 | offset_forward += (offset_forward & 0x8000) << 1; // Account for sign extension in jic. |
| 855 | |
| 856 | uint32_t offset_back = -(kAdduCount2 + 1); // 1: account for bnec. |
| 857 | offset_back <<= 2; |
| 858 | offset_back += (offset_back & 0x8000) << 1; // Account for sign extension in jic. |
| 859 | |
| 860 | std::ostringstream oss; |
| 861 | oss << |
| 862 | ".set noreorder\n" |
| 863 | "bnec $a0, $a1, 1f\n" |
| 864 | "auipc $at, 0x" << std::hex << High16Bits(offset_forward) << "\n" |
| 865 | "jic $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n" |
| 866 | "1:\n" << |
| 867 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") << |
| 868 | "2:\n" << |
| 869 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") << |
| 870 | "bnec $a2, $a3, 3f\n" |
| 871 | "auipc $at, 0x" << std::hex << High16Bits(offset_back) << "\n" |
| 872 | "jic $at, 0x" << std::hex << Low16Bits(offset_back) << "\n" |
| 873 | "3:\n"; |
| 874 | std::string expected = oss.str(); |
| 875 | DriverStr(expected, "LongBeqc"); |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 876 | } |
| 877 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 878 | ////////// |
| 879 | // MISC // |
| 880 | ////////// |
| 881 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 882 | TEST_F(AssemblerMIPS64Test, Lwpc) { |
| 883 | // Lwpc() takes an unsigned 19-bit immediate, while the GNU assembler needs a signed offset, |
| 884 | // hence the sign extension from bit 18 with `imm - ((imm & 0x40000) << 1)`. |
| 885 | // The GNU assembler also wants the offset to be a multiple of 4, which it will shift right |
| 886 | // by 2 positions when encoding, hence `<< 2` to compensate for that shift. |
| 887 | // We capture the value of the immediate with `.set imm, {imm}` because the value is needed |
| 888 | // twice for the sign extension, but `{imm}` is substituted only once. |
| 889 | const char* code = ".set imm, {imm}\nlw ${reg}, ((imm - ((imm & 0x40000) << 1)) << 2)($pc)"; |
| 890 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Lwpc, 19, code), "Lwpc"); |
| 891 | } |
| 892 | |
| 893 | TEST_F(AssemblerMIPS64Test, Lwupc) { |
| 894 | // The comment for the Lwpc test applies here as well. |
| 895 | const char* code = ".set imm, {imm}\nlwu ${reg}, ((imm - ((imm & 0x40000) << 1)) << 2)($pc)"; |
| 896 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Lwupc, 19, code), "Lwupc"); |
| 897 | } |
| 898 | |
| 899 | TEST_F(AssemblerMIPS64Test, Ldpc) { |
| 900 | // The comment for the Lwpc test applies here as well. |
| 901 | const char* code = ".set imm, {imm}\nld ${reg}, ((imm - ((imm & 0x20000) << 1)) << 3)($pc)"; |
| 902 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Ldpc, 18, code), "Ldpc"); |
| 903 | } |
| 904 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 905 | TEST_F(AssemblerMIPS64Test, Auipc) { |
| 906 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Auipc, 16, "auipc ${reg}, {imm}"), "Auipc"); |
| 907 | } |
| 908 | |
| 909 | TEST_F(AssemblerMIPS64Test, Addiupc) { |
| 910 | // The comment from the Lwpc() test applies to this Addiupc() test as well. |
| 911 | const char* code = ".set imm, {imm}\naddiupc ${reg}, (imm - ((imm & 0x40000) << 1)) << 2"; |
| 912 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Addiupc, 19, code), "Addiupc"); |
| 913 | } |
| 914 | |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 915 | TEST_F(AssemblerMIPS64Test, LoadFarthestNearLabelAddress) { |
| 916 | mips64::Mips64Label label; |
| 917 | __ LoadLabelAddress(mips64::V0, &label); |
| 918 | constexpr uint32_t kAdduCount = 0x3FFDE; |
| 919 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 920 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 921 | } |
| 922 | __ Bind(&label); |
| 923 | |
| 924 | std::string expected = |
| 925 | "lapc $v0, 1f\n" + |
| 926 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 927 | "1:\n"; |
| 928 | DriverStr(expected, "LoadFarthestNearLabelAddress"); |
| 929 | EXPECT_EQ(__ GetLabelLocation(&label), (1 + kAdduCount) * 4); |
| 930 | } |
| 931 | |
| 932 | TEST_F(AssemblerMIPS64Test, LoadNearestFarLabelAddress) { |
| 933 | mips64::Mips64Label label; |
| 934 | __ LoadLabelAddress(mips64::V0, &label); |
| 935 | constexpr uint32_t kAdduCount = 0x3FFDF; |
| 936 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 937 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 938 | } |
| 939 | __ Bind(&label); |
| 940 | |
| 941 | std::string expected = |
| 942 | "1:\n" |
| 943 | "auipc $at, %hi(2f - 1b)\n" |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 944 | "daddiu $v0, $at, %lo(2f - 1b)\n" + |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 945 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 946 | "2:\n"; |
| 947 | DriverStr(expected, "LoadNearestFarLabelAddress"); |
| 948 | EXPECT_EQ(__ GetLabelLocation(&label), (2 + kAdduCount) * 4); |
| 949 | } |
| 950 | |
| 951 | TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteral) { |
| 952 | mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 953 | __ LoadLiteral(mips64::V0, mips64::kLoadWord, literal); |
| 954 | constexpr uint32_t kAdduCount = 0x3FFDE; |
| 955 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 956 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 957 | } |
| 958 | |
| 959 | std::string expected = |
| 960 | "lwpc $v0, 1f\n" + |
| 961 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 962 | "1:\n" |
| 963 | ".word 0x12345678\n"; |
| 964 | DriverStr(expected, "LoadFarthestNearLiteral"); |
| 965 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4); |
| 966 | } |
| 967 | |
| 968 | TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteral) { |
| 969 | mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 970 | __ LoadLiteral(mips64::V0, mips64::kLoadWord, literal); |
| 971 | constexpr uint32_t kAdduCount = 0x3FFDF; |
| 972 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 973 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 974 | } |
| 975 | |
| 976 | std::string expected = |
| 977 | "1:\n" |
| 978 | "auipc $at, %hi(2f - 1b)\n" |
| 979 | "lw $v0, %lo(2f - 1b)($at)\n" + |
| 980 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 981 | "2:\n" |
| 982 | ".word 0x12345678\n"; |
| 983 | DriverStr(expected, "LoadNearestFarLiteral"); |
| 984 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4); |
| 985 | } |
| 986 | |
| 987 | TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteralUnsigned) { |
| 988 | mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 989 | __ LoadLiteral(mips64::V0, mips64::kLoadUnsignedWord, literal); |
| 990 | constexpr uint32_t kAdduCount = 0x3FFDE; |
| 991 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 992 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 993 | } |
| 994 | |
| 995 | std::string expected = |
| 996 | "lwupc $v0, 1f\n" + |
| 997 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 998 | "1:\n" |
| 999 | ".word 0x12345678\n"; |
| 1000 | DriverStr(expected, "LoadFarthestNearLiteralUnsigned"); |
| 1001 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4); |
| 1002 | } |
| 1003 | |
| 1004 | TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteralUnsigned) { |
| 1005 | mips64::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 1006 | __ LoadLiteral(mips64::V0, mips64::kLoadUnsignedWord, literal); |
| 1007 | constexpr uint32_t kAdduCount = 0x3FFDF; |
| 1008 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 1009 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 1010 | } |
| 1011 | |
| 1012 | std::string expected = |
| 1013 | "1:\n" |
| 1014 | "auipc $at, %hi(2f - 1b)\n" |
| 1015 | "lwu $v0, %lo(2f - 1b)($at)\n" + |
| 1016 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 1017 | "2:\n" |
| 1018 | ".word 0x12345678\n"; |
| 1019 | DriverStr(expected, "LoadNearestFarLiteralUnsigned"); |
| 1020 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4); |
| 1021 | } |
| 1022 | |
| 1023 | TEST_F(AssemblerMIPS64Test, LoadFarthestNearLiteralLong) { |
| 1024 | mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF)); |
| 1025 | __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal); |
| 1026 | constexpr uint32_t kAdduCount = 0x3FFDD; |
| 1027 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 1028 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 1029 | } |
| 1030 | |
| 1031 | std::string expected = |
| 1032 | "ldpc $v0, 1f\n" + |
| 1033 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 1034 | "1:\n" |
| 1035 | ".dword 0x0123456789ABCDEF\n"; |
| 1036 | DriverStr(expected, "LoadFarthestNearLiteralLong"); |
| 1037 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (1 + kAdduCount) * 4); |
| 1038 | } |
| 1039 | |
| 1040 | TEST_F(AssemblerMIPS64Test, LoadNearestFarLiteralLong) { |
| 1041 | mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF)); |
| 1042 | __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal); |
| 1043 | constexpr uint32_t kAdduCount = 0x3FFDE; |
| 1044 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 1045 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 1046 | } |
| 1047 | |
| 1048 | std::string expected = |
| 1049 | "1:\n" |
| 1050 | "auipc $at, %hi(2f - 1b)\n" |
| 1051 | "ld $v0, %lo(2f - 1b)($at)\n" + |
| 1052 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 1053 | "2:\n" |
| 1054 | ".dword 0x0123456789ABCDEF\n"; |
| 1055 | DriverStr(expected, "LoadNearestFarLiteralLong"); |
| 1056 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (2 + kAdduCount) * 4); |
| 1057 | } |
| 1058 | |
| 1059 | TEST_F(AssemblerMIPS64Test, LongLiteralAlignmentNop) { |
| 1060 | mips64::Literal* literal1 = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF)); |
| 1061 | mips64::Literal* literal2 = __ NewLiteral<uint64_t>(UINT64_C(0x5555555555555555)); |
| 1062 | mips64::Literal* literal3 = __ NewLiteral<uint64_t>(UINT64_C(0xAAAAAAAAAAAAAAAA)); |
| 1063 | __ LoadLiteral(mips64::A1, mips64::kLoadDoubleword, literal1); |
| 1064 | __ LoadLiteral(mips64::A2, mips64::kLoadDoubleword, literal2); |
| 1065 | __ LoadLiteral(mips64::A3, mips64::kLoadDoubleword, literal3); |
| 1066 | __ LoadLabelAddress(mips64::V0, literal1->GetLabel()); |
| 1067 | __ LoadLabelAddress(mips64::V1, literal2->GetLabel()); |
| 1068 | // A nop will be inserted here before the 64-bit literals. |
| 1069 | |
| 1070 | std::string expected = |
| 1071 | "ldpc $a1, 1f\n" |
| 1072 | // The GNU assembler incorrectly requires the ldpc instruction to be located |
| 1073 | // at an address that's a multiple of 8. TODO: Remove this workaround if/when |
| 1074 | // the assembler is fixed. |
| 1075 | // "ldpc $a2, 2f\n" |
| 1076 | ".word 0xECD80004\n" |
| 1077 | "ldpc $a3, 3f\n" |
| 1078 | "lapc $v0, 1f\n" |
| 1079 | "lapc $v1, 2f\n" |
| 1080 | "nop\n" |
| 1081 | "1:\n" |
| 1082 | ".dword 0x0123456789ABCDEF\n" |
| 1083 | "2:\n" |
| 1084 | ".dword 0x5555555555555555\n" |
| 1085 | "3:\n" |
| 1086 | ".dword 0xAAAAAAAAAAAAAAAA\n"; |
| 1087 | DriverStr(expected, "LongLiteralAlignmentNop"); |
| 1088 | EXPECT_EQ(__ GetLabelLocation(literal1->GetLabel()), 6 * 4u); |
| 1089 | EXPECT_EQ(__ GetLabelLocation(literal2->GetLabel()), 8 * 4u); |
| 1090 | EXPECT_EQ(__ GetLabelLocation(literal3->GetLabel()), 10 * 4u); |
| 1091 | } |
| 1092 | |
| 1093 | TEST_F(AssemblerMIPS64Test, LongLiteralAlignmentNoNop) { |
| 1094 | mips64::Literal* literal1 = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF)); |
| 1095 | mips64::Literal* literal2 = __ NewLiteral<uint64_t>(UINT64_C(0x5555555555555555)); |
| 1096 | __ LoadLiteral(mips64::A1, mips64::kLoadDoubleword, literal1); |
| 1097 | __ LoadLiteral(mips64::A2, mips64::kLoadDoubleword, literal2); |
| 1098 | __ LoadLabelAddress(mips64::V0, literal1->GetLabel()); |
| 1099 | __ LoadLabelAddress(mips64::V1, literal2->GetLabel()); |
| 1100 | |
| 1101 | std::string expected = |
| 1102 | "ldpc $a1, 1f\n" |
| 1103 | // The GNU assembler incorrectly requires the ldpc instruction to be located |
| 1104 | // at an address that's a multiple of 8. TODO: Remove this workaround if/when |
| 1105 | // the assembler is fixed. |
| 1106 | // "ldpc $a2, 2f\n" |
| 1107 | ".word 0xECD80003\n" |
| 1108 | "lapc $v0, 1f\n" |
| 1109 | "lapc $v1, 2f\n" |
| 1110 | "1:\n" |
| 1111 | ".dword 0x0123456789ABCDEF\n" |
| 1112 | "2:\n" |
| 1113 | ".dword 0x5555555555555555\n"; |
| 1114 | DriverStr(expected, "LongLiteralAlignmentNoNop"); |
| 1115 | EXPECT_EQ(__ GetLabelLocation(literal1->GetLabel()), 4 * 4u); |
| 1116 | EXPECT_EQ(__ GetLabelLocation(literal2->GetLabel()), 6 * 4u); |
| 1117 | } |
| 1118 | |
| 1119 | TEST_F(AssemblerMIPS64Test, FarLongLiteralAlignmentNop) { |
| 1120 | mips64::Literal* literal = __ NewLiteral<uint64_t>(UINT64_C(0x0123456789ABCDEF)); |
| 1121 | __ LoadLiteral(mips64::V0, mips64::kLoadDoubleword, literal); |
| 1122 | __ LoadLabelAddress(mips64::V1, literal->GetLabel()); |
| 1123 | constexpr uint32_t kAdduCount = 0x3FFDF; |
| 1124 | for (uint32_t i = 0; i != kAdduCount; ++i) { |
| 1125 | __ Addu(mips64::ZERO, mips64::ZERO, mips64::ZERO); |
| 1126 | } |
| 1127 | // A nop will be inserted here before the 64-bit literal. |
| 1128 | |
| 1129 | std::string expected = |
| 1130 | "1:\n" |
| 1131 | "auipc $at, %hi(3f - 1b)\n" |
| 1132 | "ld $v0, %lo(3f - 1b)($at)\n" |
| 1133 | "2:\n" |
| 1134 | "auipc $at, %hi(3f - 2b)\n" |
Alexey Frunze | f63f569 | 2016-12-13 17:43:11 -0800 | [diff] [blame] | 1135 | "daddiu $v1, $at, %lo(3f - 2b)\n" + |
Alexey Frunze | 19f6c69 | 2016-11-30 19:19:55 -0800 | [diff] [blame] | 1136 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 1137 | "nop\n" |
| 1138 | "3:\n" |
| 1139 | ".dword 0x0123456789ABCDEF\n"; |
| 1140 | DriverStr(expected, "FarLongLiteralAlignmentNop"); |
| 1141 | EXPECT_EQ(__ GetLabelLocation(literal->GetLabel()), (5 + kAdduCount) * 4); |
| 1142 | } |
| 1143 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 1144 | TEST_F(AssemblerMIPS64Test, Addu) { |
| 1145 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Addu, "addu ${reg1}, ${reg2}, ${reg3}"), "addu"); |
| 1146 | } |
| 1147 | |
| 1148 | TEST_F(AssemblerMIPS64Test, Addiu) { |
| 1149 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Addiu, -16, "addiu ${reg1}, ${reg2}, {imm}"), |
| 1150 | "addiu"); |
| 1151 | } |
| 1152 | |
| 1153 | TEST_F(AssemblerMIPS64Test, Daddu) { |
| 1154 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Daddu, "daddu ${reg1}, ${reg2}, ${reg3}"), "daddu"); |
| 1155 | } |
| 1156 | |
| 1157 | TEST_F(AssemblerMIPS64Test, Daddiu) { |
| 1158 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Daddiu, -16, "daddiu ${reg1}, ${reg2}, {imm}"), |
| 1159 | "daddiu"); |
| 1160 | } |
| 1161 | |
| 1162 | TEST_F(AssemblerMIPS64Test, Subu) { |
| 1163 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Subu, "subu ${reg1}, ${reg2}, ${reg3}"), "subu"); |
| 1164 | } |
| 1165 | |
| 1166 | TEST_F(AssemblerMIPS64Test, Dsubu) { |
| 1167 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dsubu, "dsubu ${reg1}, ${reg2}, ${reg3}"), "dsubu"); |
| 1168 | } |
| 1169 | |
| 1170 | TEST_F(AssemblerMIPS64Test, MulR6) { |
| 1171 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::MulR6, "mul ${reg1}, ${reg2}, ${reg3}"), "mulR6"); |
| 1172 | } |
| 1173 | |
| 1174 | TEST_F(AssemblerMIPS64Test, DivR6) { |
| 1175 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::DivR6, "div ${reg1}, ${reg2}, ${reg3}"), "divR6"); |
| 1176 | } |
| 1177 | |
| 1178 | TEST_F(AssemblerMIPS64Test, ModR6) { |
| 1179 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::ModR6, "mod ${reg1}, ${reg2}, ${reg3}"), "modR6"); |
| 1180 | } |
| 1181 | |
| 1182 | TEST_F(AssemblerMIPS64Test, DivuR6) { |
| 1183 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::DivuR6, "divu ${reg1}, ${reg2}, ${reg3}"), |
| 1184 | "divuR6"); |
| 1185 | } |
| 1186 | |
| 1187 | TEST_F(AssemblerMIPS64Test, ModuR6) { |
| 1188 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::ModuR6, "modu ${reg1}, ${reg2}, ${reg3}"), |
| 1189 | "moduR6"); |
| 1190 | } |
| 1191 | |
| 1192 | TEST_F(AssemblerMIPS64Test, Dmul) { |
| 1193 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dmul, "dmul ${reg1}, ${reg2}, ${reg3}"), "dmul"); |
| 1194 | } |
| 1195 | |
| 1196 | TEST_F(AssemblerMIPS64Test, Ddiv) { |
| 1197 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Ddiv, "ddiv ${reg1}, ${reg2}, ${reg3}"), "ddiv"); |
| 1198 | } |
| 1199 | |
| 1200 | TEST_F(AssemblerMIPS64Test, Dmod) { |
| 1201 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dmod, "dmod ${reg1}, ${reg2}, ${reg3}"), "dmod"); |
| 1202 | } |
| 1203 | |
| 1204 | TEST_F(AssemblerMIPS64Test, Ddivu) { |
| 1205 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Ddivu, "ddivu ${reg1}, ${reg2}, ${reg3}"), "ddivu"); |
| 1206 | } |
| 1207 | |
| 1208 | TEST_F(AssemblerMIPS64Test, Dmodu) { |
| 1209 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dmodu, "dmodu ${reg1}, ${reg2}, ${reg3}"), "dmodu"); |
| 1210 | } |
| 1211 | |
| 1212 | TEST_F(AssemblerMIPS64Test, And) { |
| 1213 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::And, "and ${reg1}, ${reg2}, ${reg3}"), "and"); |
| 1214 | } |
| 1215 | |
| 1216 | TEST_F(AssemblerMIPS64Test, Andi) { |
| 1217 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Andi, 16, "andi ${reg1}, ${reg2}, {imm}"), "andi"); |
| 1218 | } |
| 1219 | |
| 1220 | TEST_F(AssemblerMIPS64Test, Or) { |
| 1221 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Or, "or ${reg1}, ${reg2}, ${reg3}"), "or"); |
| 1222 | } |
| 1223 | |
| 1224 | TEST_F(AssemblerMIPS64Test, Ori) { |
| 1225 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Ori, 16, "ori ${reg1}, ${reg2}, {imm}"), "ori"); |
| 1226 | } |
| 1227 | |
| 1228 | TEST_F(AssemblerMIPS64Test, Xor) { |
| 1229 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Xor, "xor ${reg1}, ${reg2}, ${reg3}"), "xor"); |
| 1230 | } |
| 1231 | |
| 1232 | TEST_F(AssemblerMIPS64Test, Xori) { |
| 1233 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Xori, 16, "xori ${reg1}, ${reg2}, {imm}"), "xori"); |
| 1234 | } |
| 1235 | |
| 1236 | TEST_F(AssemblerMIPS64Test, Nor) { |
| 1237 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Nor, "nor ${reg1}, ${reg2}, ${reg3}"), "nor"); |
| 1238 | } |
| 1239 | |
| 1240 | TEST_F(AssemblerMIPS64Test, Lb) { |
| 1241 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lb, -16, "lb ${reg1}, {imm}(${reg2})"), "lb"); |
| 1242 | } |
| 1243 | |
| 1244 | TEST_F(AssemblerMIPS64Test, Lh) { |
| 1245 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lh, -16, "lh ${reg1}, {imm}(${reg2})"), "lh"); |
| 1246 | } |
| 1247 | |
| 1248 | TEST_F(AssemblerMIPS64Test, Lw) { |
| 1249 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lw, -16, "lw ${reg1}, {imm}(${reg2})"), "lw"); |
| 1250 | } |
| 1251 | |
| 1252 | TEST_F(AssemblerMIPS64Test, Ld) { |
| 1253 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Ld, -16, "ld ${reg1}, {imm}(${reg2})"), "ld"); |
| 1254 | } |
| 1255 | |
| 1256 | TEST_F(AssemblerMIPS64Test, Lbu) { |
| 1257 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lbu, -16, "lbu ${reg1}, {imm}(${reg2})"), "lbu"); |
| 1258 | } |
| 1259 | |
| 1260 | TEST_F(AssemblerMIPS64Test, Lhu) { |
| 1261 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lhu, -16, "lhu ${reg1}, {imm}(${reg2})"), "lhu"); |
| 1262 | } |
| 1263 | |
| 1264 | TEST_F(AssemblerMIPS64Test, Lwu) { |
| 1265 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lwu, -16, "lwu ${reg1}, {imm}(${reg2})"), "lwu"); |
| 1266 | } |
| 1267 | |
| 1268 | TEST_F(AssemblerMIPS64Test, Lui) { |
| 1269 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Lui, 16, "lui ${reg}, {imm}"), "lui"); |
| 1270 | } |
| 1271 | |
Alexey Frunze | c061de1 | 2017-02-14 13:27:23 -0800 | [diff] [blame^] | 1272 | TEST_F(AssemblerMIPS64Test, Daui) { |
| 1273 | std::vector<mips64::GpuRegister*> reg1_registers = GetRegisters(); |
| 1274 | std::vector<mips64::GpuRegister*> reg2_registers = GetRegisters(); |
| 1275 | reg2_registers.erase(reg2_registers.begin()); // reg2 can't be ZERO, remove it. |
| 1276 | std::vector<int64_t> imms = CreateImmediateValuesBits(/* imm_bits */ 16, /* as_uint */ true); |
| 1277 | WarnOnCombinations(reg1_registers.size() * reg2_registers.size() * imms.size()); |
| 1278 | std::ostringstream expected; |
| 1279 | for (mips64::GpuRegister* reg1 : reg1_registers) { |
| 1280 | for (mips64::GpuRegister* reg2 : reg2_registers) { |
| 1281 | for (int64_t imm : imms) { |
| 1282 | __ Daui(*reg1, *reg2, imm); |
| 1283 | expected << "daui $" << *reg1 << ", $" << *reg2 << ", " << imm << "\n"; |
| 1284 | } |
| 1285 | } |
| 1286 | } |
| 1287 | DriverStr(expected.str(), "daui"); |
| 1288 | } |
| 1289 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 1290 | TEST_F(AssemblerMIPS64Test, Dahi) { |
| 1291 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Dahi, 16, "dahi ${reg}, ${reg}, {imm}"), "dahi"); |
| 1292 | } |
| 1293 | |
| 1294 | TEST_F(AssemblerMIPS64Test, Dati) { |
| 1295 | DriverStr(RepeatRIb(&mips64::Mips64Assembler::Dati, 16, "dati ${reg}, ${reg}, {imm}"), "dati"); |
| 1296 | } |
| 1297 | |
| 1298 | TEST_F(AssemblerMIPS64Test, Sb) { |
| 1299 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sb, -16, "sb ${reg1}, {imm}(${reg2})"), "sb"); |
| 1300 | } |
| 1301 | |
| 1302 | TEST_F(AssemblerMIPS64Test, Sh) { |
| 1303 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sh, -16, "sh ${reg1}, {imm}(${reg2})"), "sh"); |
| 1304 | } |
| 1305 | |
| 1306 | TEST_F(AssemblerMIPS64Test, Sw) { |
| 1307 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sw, -16, "sw ${reg1}, {imm}(${reg2})"), "sw"); |
| 1308 | } |
| 1309 | |
| 1310 | TEST_F(AssemblerMIPS64Test, Sd) { |
| 1311 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sd, -16, "sd ${reg1}, {imm}(${reg2})"), "sd"); |
| 1312 | } |
| 1313 | |
| 1314 | TEST_F(AssemblerMIPS64Test, Slt) { |
| 1315 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Slt, "slt ${reg1}, ${reg2}, ${reg3}"), "slt"); |
| 1316 | } |
| 1317 | |
| 1318 | TEST_F(AssemblerMIPS64Test, Sltu) { |
| 1319 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Sltu, "sltu ${reg1}, ${reg2}, ${reg3}"), "sltu"); |
| 1320 | } |
| 1321 | |
| 1322 | TEST_F(AssemblerMIPS64Test, Slti) { |
| 1323 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Slti, -16, "slti ${reg1}, ${reg2}, {imm}"), |
| 1324 | "slti"); |
| 1325 | } |
| 1326 | |
| 1327 | TEST_F(AssemblerMIPS64Test, Sltiu) { |
| 1328 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sltiu, -16, "sltiu ${reg1}, ${reg2}, {imm}"), |
| 1329 | "sltiu"); |
| 1330 | } |
| 1331 | |
| 1332 | TEST_F(AssemblerMIPS64Test, Move) { |
| 1333 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Move, "or ${reg1}, ${reg2}, $zero"), "move"); |
| 1334 | } |
| 1335 | |
| 1336 | TEST_F(AssemblerMIPS64Test, Clear) { |
| 1337 | DriverStr(RepeatR(&mips64::Mips64Assembler::Clear, "or ${reg}, $zero, $zero"), "clear"); |
| 1338 | } |
| 1339 | |
| 1340 | TEST_F(AssemblerMIPS64Test, Not) { |
| 1341 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Not, "nor ${reg1}, ${reg2}, $zero"), "not"); |
| 1342 | } |
| 1343 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1344 | TEST_F(AssemblerMIPS64Test, Bitswap) { |
| 1345 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Bitswap, "bitswap ${reg1}, ${reg2}"), "bitswap"); |
| 1346 | } |
| 1347 | |
| 1348 | TEST_F(AssemblerMIPS64Test, Dbitswap) { |
| 1349 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Dbitswap, "dbitswap ${reg1}, ${reg2}"), "dbitswap"); |
| 1350 | } |
| 1351 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1352 | TEST_F(AssemblerMIPS64Test, Seb) { |
| 1353 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Seb, "seb ${reg1}, ${reg2}"), "seb"); |
| 1354 | } |
| 1355 | |
| 1356 | TEST_F(AssemblerMIPS64Test, Seh) { |
| 1357 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Seh, "seh ${reg1}, ${reg2}"), "seh"); |
| 1358 | } |
| 1359 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1360 | TEST_F(AssemblerMIPS64Test, Dsbh) { |
| 1361 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Dsbh, "dsbh ${reg1}, ${reg2}"), "dsbh"); |
| 1362 | } |
| 1363 | |
| 1364 | TEST_F(AssemblerMIPS64Test, Dshd) { |
| 1365 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Dshd, "dshd ${reg1}, ${reg2}"), "dshd"); |
| 1366 | } |
| 1367 | |
Lazar Trsic | d967266 | 2015-09-03 17:33:01 +0200 | [diff] [blame] | 1368 | TEST_F(AssemblerMIPS64Test, Dext) { |
| 1369 | std::vector<mips64::GpuRegister*> reg1_registers = GetRegisters(); |
| 1370 | std::vector<mips64::GpuRegister*> reg2_registers = GetRegisters(); |
| 1371 | WarnOnCombinations(reg1_registers.size() * reg2_registers.size() * 33 * 16); |
| 1372 | std::ostringstream expected; |
| 1373 | for (mips64::GpuRegister* reg1 : reg1_registers) { |
| 1374 | for (mips64::GpuRegister* reg2 : reg2_registers) { |
| 1375 | for (int32_t pos = 0; pos < 32; pos++) { |
| 1376 | for (int32_t size = 1; size <= 32; size++) { |
| 1377 | __ Dext(*reg1, *reg2, pos, size); |
| 1378 | expected << "dext $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n"; |
| 1379 | } |
| 1380 | } |
| 1381 | } |
| 1382 | } |
| 1383 | |
| 1384 | DriverStr(expected.str(), "Dext"); |
| 1385 | } |
| 1386 | |
| 1387 | TEST_F(AssemblerMIPS64Test, Dinsu) { |
| 1388 | std::vector<mips64::GpuRegister*> reg1_registers = GetRegisters(); |
| 1389 | std::vector<mips64::GpuRegister*> reg2_registers = GetRegisters(); |
| 1390 | WarnOnCombinations(reg1_registers.size() * reg2_registers.size() * 33 * 16); |
| 1391 | std::ostringstream expected; |
| 1392 | for (mips64::GpuRegister* reg1 : reg1_registers) { |
| 1393 | for (mips64::GpuRegister* reg2 : reg2_registers) { |
| 1394 | for (int32_t pos = 32; pos < 64; pos++) { |
| 1395 | for (int32_t size = 1; pos + size <= 64; size++) { |
| 1396 | __ Dinsu(*reg1, *reg2, pos, size); |
| 1397 | expected << "dinsu $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n"; |
| 1398 | } |
| 1399 | } |
| 1400 | } |
| 1401 | } |
| 1402 | |
| 1403 | DriverStr(expected.str(), "Dinsu"); |
| 1404 | } |
| 1405 | |
Chris Larsen | e366059 | 2016-11-09 11:13:42 -0800 | [diff] [blame] | 1406 | TEST_F(AssemblerMIPS64Test, Lsa) { |
| 1407 | DriverStr(RepeatRRRIb(&mips64::Mips64Assembler::Lsa, |
| 1408 | 2, |
| 1409 | "lsa ${reg1}, ${reg2}, ${reg3}, {imm}", |
| 1410 | 1), |
| 1411 | "lsa"); |
| 1412 | } |
| 1413 | |
| 1414 | TEST_F(AssemblerMIPS64Test, Dlsa) { |
| 1415 | DriverStr(RepeatRRRIb(&mips64::Mips64Assembler::Dlsa, |
| 1416 | 2, |
| 1417 | "dlsa ${reg1}, ${reg2}, ${reg3}, {imm}", |
| 1418 | 1), |
| 1419 | "dlsa"); |
| 1420 | } |
| 1421 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1422 | TEST_F(AssemblerMIPS64Test, Wsbh) { |
| 1423 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Wsbh, "wsbh ${reg1}, ${reg2}"), "wsbh"); |
| 1424 | } |
| 1425 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1426 | TEST_F(AssemblerMIPS64Test, Sll) { |
| 1427 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sll, 5, "sll ${reg1}, ${reg2}, {imm}"), "sll"); |
| 1428 | } |
| 1429 | |
| 1430 | TEST_F(AssemblerMIPS64Test, Srl) { |
| 1431 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Srl, 5, "srl ${reg1}, ${reg2}, {imm}"), "srl"); |
| 1432 | } |
| 1433 | |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1434 | TEST_F(AssemblerMIPS64Test, Rotr) { |
| 1435 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Rotr, 5, "rotr ${reg1}, ${reg2}, {imm}"), "rotr"); |
| 1436 | } |
| 1437 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1438 | TEST_F(AssemblerMIPS64Test, Sra) { |
| 1439 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sra, 5, "sra ${reg1}, ${reg2}, {imm}"), "sra"); |
| 1440 | } |
| 1441 | |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1442 | TEST_F(AssemblerMIPS64Test, Sllv) { |
| 1443 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Sllv, "sllv ${reg1}, ${reg2}, ${reg3}"), "sllv"); |
| 1444 | } |
| 1445 | |
| 1446 | TEST_F(AssemblerMIPS64Test, Srlv) { |
| 1447 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Srlv, "srlv ${reg1}, ${reg2}, ${reg3}"), "srlv"); |
| 1448 | } |
| 1449 | |
| 1450 | TEST_F(AssemblerMIPS64Test, Rotrv) { |
| 1451 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Rotrv, "rotrv ${reg1}, ${reg2}, ${reg3}"), "rotrv"); |
| 1452 | } |
| 1453 | |
| 1454 | TEST_F(AssemblerMIPS64Test, Srav) { |
| 1455 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Srav, "srav ${reg1}, ${reg2}, ${reg3}"), "srav"); |
| 1456 | } |
| 1457 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1458 | TEST_F(AssemblerMIPS64Test, Dsll) { |
| 1459 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsll, 5, "dsll ${reg1}, ${reg2}, {imm}"), "dsll"); |
| 1460 | } |
| 1461 | |
| 1462 | TEST_F(AssemblerMIPS64Test, Dsrl) { |
| 1463 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsrl, 5, "dsrl ${reg1}, ${reg2}, {imm}"), "dsrl"); |
| 1464 | } |
| 1465 | |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1466 | TEST_F(AssemblerMIPS64Test, Drotr) { |
| 1467 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Drotr, 5, "drotr ${reg1}, ${reg2}, {imm}"), |
| 1468 | "drotr"); |
| 1469 | } |
| 1470 | |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1471 | TEST_F(AssemblerMIPS64Test, Dsra) { |
| 1472 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsra, 5, "dsra ${reg1}, ${reg2}, {imm}"), "dsra"); |
| 1473 | } |
| 1474 | |
| 1475 | TEST_F(AssemblerMIPS64Test, Dsll32) { |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1476 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsll32, 5, "dsll32 ${reg1}, ${reg2}, {imm}"), |
| 1477 | "dsll32"); |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1478 | } |
| 1479 | |
| 1480 | TEST_F(AssemblerMIPS64Test, Dsrl32) { |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1481 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsrl32, 5, "dsrl32 ${reg1}, ${reg2}, {imm}"), |
| 1482 | "dsrl32"); |
| 1483 | } |
| 1484 | |
| 1485 | TEST_F(AssemblerMIPS64Test, Drotr32) { |
| 1486 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Drotr32, 5, "drotr32 ${reg1}, ${reg2}, {imm}"), |
| 1487 | "drotr32"); |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1488 | } |
| 1489 | |
| 1490 | TEST_F(AssemblerMIPS64Test, Dsra32) { |
Chris Larsen | 98a73e1 | 2015-10-19 14:17:16 -0700 | [diff] [blame] | 1491 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Dsra32, 5, "dsra32 ${reg1}, ${reg2}, {imm}"), |
| 1492 | "dsra32"); |
Chris Larsen | 5141763 | 2015-10-02 13:24:25 -0700 | [diff] [blame] | 1493 | } |
| 1494 | |
Goran Jakovljevic | 95f2714 | 2017-01-20 11:11:11 +0100 | [diff] [blame] | 1495 | TEST_F(AssemblerMIPS64Test, Dsllv) { |
| 1496 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dsllv, "dsllv ${reg1}, ${reg2}, ${reg3}"), "dsllv"); |
| 1497 | } |
| 1498 | |
| 1499 | TEST_F(AssemblerMIPS64Test, Dsrlv) { |
| 1500 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dsrlv, "dsrlv ${reg1}, ${reg2}, ${reg3}"), "dsrlv"); |
| 1501 | } |
| 1502 | |
| 1503 | TEST_F(AssemblerMIPS64Test, Dsrav) { |
| 1504 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Dsrav, "dsrav ${reg1}, ${reg2}, ${reg3}"), "dsrav"); |
| 1505 | } |
| 1506 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1507 | TEST_F(AssemblerMIPS64Test, Sc) { |
| 1508 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Sc, -9, "sc ${reg1}, {imm}(${reg2})"), "sc"); |
| 1509 | } |
| 1510 | |
| 1511 | TEST_F(AssemblerMIPS64Test, Scd) { |
| 1512 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Scd, -9, "scd ${reg1}, {imm}(${reg2})"), "scd"); |
| 1513 | } |
| 1514 | |
| 1515 | TEST_F(AssemblerMIPS64Test, Ll) { |
| 1516 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Ll, -9, "ll ${reg1}, {imm}(${reg2})"), "ll"); |
| 1517 | } |
| 1518 | |
| 1519 | TEST_F(AssemblerMIPS64Test, Lld) { |
| 1520 | DriverStr(RepeatRRIb(&mips64::Mips64Assembler::Lld, -9, "lld ${reg1}, {imm}(${reg2})"), "lld"); |
| 1521 | } |
| 1522 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 1523 | TEST_F(AssemblerMIPS64Test, Seleqz) { |
| 1524 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Seleqz, "seleqz ${reg1}, ${reg2}, ${reg3}"), |
| 1525 | "seleqz"); |
| 1526 | } |
| 1527 | |
| 1528 | TEST_F(AssemblerMIPS64Test, Selnez) { |
| 1529 | DriverStr(RepeatRRR(&mips64::Mips64Assembler::Selnez, "selnez ${reg1}, ${reg2}, ${reg3}"), |
| 1530 | "selnez"); |
| 1531 | } |
| 1532 | |
| 1533 | TEST_F(AssemblerMIPS64Test, Clz) { |
| 1534 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Clz, "clz ${reg1}, ${reg2}"), "clz"); |
| 1535 | } |
| 1536 | |
| 1537 | TEST_F(AssemblerMIPS64Test, Clo) { |
| 1538 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Clo, "clo ${reg1}, ${reg2}"), "clo"); |
| 1539 | } |
| 1540 | |
| 1541 | TEST_F(AssemblerMIPS64Test, Dclz) { |
| 1542 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Dclz, "dclz ${reg1}, ${reg2}"), "dclz"); |
| 1543 | } |
| 1544 | |
| 1545 | TEST_F(AssemblerMIPS64Test, Dclo) { |
| 1546 | DriverStr(RepeatRR(&mips64::Mips64Assembler::Dclo, "dclo ${reg1}, ${reg2}"), "dclo"); |
| 1547 | } |
| 1548 | |
Lazar Trsic | d967266 | 2015-09-03 17:33:01 +0200 | [diff] [blame] | 1549 | TEST_F(AssemblerMIPS64Test, LoadFromOffset) { |
| 1550 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A0, 0); |
| 1551 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0); |
| 1552 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 1); |
| 1553 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 256); |
| 1554 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 1000); |
| 1555 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x7FFF); |
| 1556 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x8000); |
| 1557 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x8001); |
| 1558 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x10000); |
| 1559 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0x12345678); |
| 1560 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, -256); |
| 1561 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, -32768); |
| 1562 | __ LoadFromOffset(mips64::kLoadSignedByte, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1563 | |
| 1564 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A0, 0); |
| 1565 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0); |
| 1566 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 1); |
| 1567 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 256); |
| 1568 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 1000); |
| 1569 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x7FFF); |
| 1570 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x8000); |
| 1571 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x8001); |
| 1572 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x10000); |
| 1573 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0x12345678); |
| 1574 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, -256); |
| 1575 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, -32768); |
| 1576 | __ LoadFromOffset(mips64::kLoadUnsignedByte, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1577 | |
| 1578 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A0, 0); |
| 1579 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0); |
| 1580 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 2); |
| 1581 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 256); |
| 1582 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 1000); |
| 1583 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x7FFE); |
| 1584 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x8000); |
| 1585 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x8002); |
| 1586 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x10000); |
| 1587 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0x12345678); |
| 1588 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, -256); |
| 1589 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, -32768); |
| 1590 | __ LoadFromOffset(mips64::kLoadSignedHalfword, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1591 | |
| 1592 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A0, 0); |
| 1593 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0); |
| 1594 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 2); |
| 1595 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 256); |
| 1596 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 1000); |
| 1597 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x7FFE); |
| 1598 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x8000); |
| 1599 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x8002); |
| 1600 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x10000); |
| 1601 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0x12345678); |
| 1602 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, -256); |
| 1603 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, -32768); |
| 1604 | __ LoadFromOffset(mips64::kLoadUnsignedHalfword, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1605 | |
| 1606 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A0, 0); |
| 1607 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0); |
| 1608 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 4); |
| 1609 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 256); |
| 1610 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 1000); |
| 1611 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x7FFC); |
| 1612 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x8000); |
| 1613 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x8004); |
| 1614 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x10000); |
| 1615 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0x12345678); |
| 1616 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, -256); |
| 1617 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, -32768); |
| 1618 | __ LoadFromOffset(mips64::kLoadWord, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1619 | |
| 1620 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A0, 0); |
| 1621 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0); |
| 1622 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 4); |
| 1623 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 256); |
| 1624 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 1000); |
| 1625 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x7FFC); |
| 1626 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x8000); |
| 1627 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x8004); |
| 1628 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x10000); |
| 1629 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0x12345678); |
| 1630 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, -256); |
| 1631 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, -32768); |
| 1632 | __ LoadFromOffset(mips64::kLoadUnsignedWord, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1633 | |
| 1634 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A0, 0); |
| 1635 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0); |
| 1636 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 4); |
| 1637 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 256); |
| 1638 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 1000); |
| 1639 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x7FFC); |
| 1640 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x8000); |
| 1641 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x8004); |
| 1642 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x10000); |
| 1643 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0x12345678); |
| 1644 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, -256); |
| 1645 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, -32768); |
| 1646 | __ LoadFromOffset(mips64::kLoadDoubleword, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1647 | |
| 1648 | const char* expected = |
| 1649 | "lb $a0, 0($a0)\n" |
| 1650 | "lb $a0, 0($a1)\n" |
| 1651 | "lb $a0, 1($a1)\n" |
| 1652 | "lb $a0, 256($a1)\n" |
| 1653 | "lb $a0, 1000($a1)\n" |
| 1654 | "lb $a0, 0x7FFF($a1)\n" |
| 1655 | "ori $at, $zero, 0x8000\n" |
| 1656 | "daddu $at, $at, $a1\n" |
| 1657 | "lb $a0, 0($at)\n" |
| 1658 | "ori $at, $zero, 0x8000\n" |
| 1659 | "daddu $at, $at, $a1\n" |
| 1660 | "lb $a0, 1($at)\n" |
| 1661 | "lui $at, 1\n" |
| 1662 | "daddu $at, $at, $a1\n" |
| 1663 | "lb $a0, 0($at)\n" |
| 1664 | "lui $at, 0x1234\n" |
| 1665 | "ori $at, 0x5678\n" |
| 1666 | "daddu $at, $at, $a1\n" |
| 1667 | "lb $a0, 0($at)\n" |
| 1668 | "lb $a0, -256($a1)\n" |
| 1669 | "lb $a0, -32768($a1)\n" |
| 1670 | "lui $at, 0xABCD\n" |
| 1671 | "ori $at, 0xEF00\n" |
| 1672 | "daddu $at, $at, $a1\n" |
| 1673 | "lb $a0, 0($at)\n" |
| 1674 | |
| 1675 | "lbu $a0, 0($a0)\n" |
| 1676 | "lbu $a0, 0($a1)\n" |
| 1677 | "lbu $a0, 1($a1)\n" |
| 1678 | "lbu $a0, 256($a1)\n" |
| 1679 | "lbu $a0, 1000($a1)\n" |
| 1680 | "lbu $a0, 0x7FFF($a1)\n" |
| 1681 | "ori $at, $zero, 0x8000\n" |
| 1682 | "daddu $at, $at, $a1\n" |
| 1683 | "lbu $a0, 0($at)\n" |
| 1684 | "ori $at, $zero, 0x8000\n" |
| 1685 | "daddu $at, $at, $a1\n" |
| 1686 | "lbu $a0, 1($at)\n" |
| 1687 | "lui $at, 1\n" |
| 1688 | "daddu $at, $at, $a1\n" |
| 1689 | "lbu $a0, 0($at)\n" |
| 1690 | "lui $at, 0x1234\n" |
| 1691 | "ori $at, 0x5678\n" |
| 1692 | "daddu $at, $at, $a1\n" |
| 1693 | "lbu $a0, 0($at)\n" |
| 1694 | "lbu $a0, -256($a1)\n" |
| 1695 | "lbu $a0, -32768($a1)\n" |
| 1696 | "lui $at, 0xABCD\n" |
| 1697 | "ori $at, 0xEF00\n" |
| 1698 | "daddu $at, $at, $a1\n" |
| 1699 | "lbu $a0, 0($at)\n" |
| 1700 | |
| 1701 | "lh $a0, 0($a0)\n" |
| 1702 | "lh $a0, 0($a1)\n" |
| 1703 | "lh $a0, 2($a1)\n" |
| 1704 | "lh $a0, 256($a1)\n" |
| 1705 | "lh $a0, 1000($a1)\n" |
| 1706 | "lh $a0, 0x7FFE($a1)\n" |
| 1707 | "ori $at, $zero, 0x8000\n" |
| 1708 | "daddu $at, $at, $a1\n" |
| 1709 | "lh $a0, 0($at)\n" |
| 1710 | "ori $at, $zero, 0x8000\n" |
| 1711 | "daddu $at, $at, $a1\n" |
| 1712 | "lh $a0, 2($at)\n" |
| 1713 | "lui $at, 1\n" |
| 1714 | "daddu $at, $at, $a1\n" |
| 1715 | "lh $a0, 0($at)\n" |
| 1716 | "lui $at, 0x1234\n" |
| 1717 | "ori $at, 0x5678\n" |
| 1718 | "daddu $at, $at, $a1\n" |
| 1719 | "lh $a0, 0($at)\n" |
| 1720 | "lh $a0, -256($a1)\n" |
| 1721 | "lh $a0, -32768($a1)\n" |
| 1722 | "lui $at, 0xABCD\n" |
| 1723 | "ori $at, 0xEF00\n" |
| 1724 | "daddu $at, $at, $a1\n" |
| 1725 | "lh $a0, 0($at)\n" |
| 1726 | |
| 1727 | "lhu $a0, 0($a0)\n" |
| 1728 | "lhu $a0, 0($a1)\n" |
| 1729 | "lhu $a0, 2($a1)\n" |
| 1730 | "lhu $a0, 256($a1)\n" |
| 1731 | "lhu $a0, 1000($a1)\n" |
| 1732 | "lhu $a0, 0x7FFE($a1)\n" |
| 1733 | "ori $at, $zero, 0x8000\n" |
| 1734 | "daddu $at, $at, $a1\n" |
| 1735 | "lhu $a0, 0($at)\n" |
| 1736 | "ori $at, $zero, 0x8000\n" |
| 1737 | "daddu $at, $at, $a1\n" |
| 1738 | "lhu $a0, 2($at)\n" |
| 1739 | "lui $at, 1\n" |
| 1740 | "daddu $at, $at, $a1\n" |
| 1741 | "lhu $a0, 0($at)\n" |
| 1742 | "lui $at, 0x1234\n" |
| 1743 | "ori $at, 0x5678\n" |
| 1744 | "daddu $at, $at, $a1\n" |
| 1745 | "lhu $a0, 0($at)\n" |
| 1746 | "lhu $a0, -256($a1)\n" |
| 1747 | "lhu $a0, -32768($a1)\n" |
| 1748 | "lui $at, 0xABCD\n" |
| 1749 | "ori $at, 0xEF00\n" |
| 1750 | "daddu $at, $at, $a1\n" |
| 1751 | "lhu $a0, 0($at)\n" |
| 1752 | |
| 1753 | "lw $a0, 0($a0)\n" |
| 1754 | "lw $a0, 0($a1)\n" |
| 1755 | "lw $a0, 4($a1)\n" |
| 1756 | "lw $a0, 256($a1)\n" |
| 1757 | "lw $a0, 1000($a1)\n" |
| 1758 | "lw $a0, 0x7FFC($a1)\n" |
| 1759 | "ori $at, $zero, 0x8000\n" |
| 1760 | "daddu $at, $at, $a1\n" |
| 1761 | "lw $a0, 0($at)\n" |
| 1762 | "ori $at, $zero, 0x8000\n" |
| 1763 | "daddu $at, $at, $a1\n" |
| 1764 | "lw $a0, 4($at)\n" |
| 1765 | "lui $at, 1\n" |
| 1766 | "daddu $at, $at, $a1\n" |
| 1767 | "lw $a0, 0($at)\n" |
| 1768 | "lui $at, 0x1234\n" |
| 1769 | "ori $at, 0x5678\n" |
| 1770 | "daddu $at, $at, $a1\n" |
| 1771 | "lw $a0, 0($at)\n" |
| 1772 | "lw $a0, -256($a1)\n" |
| 1773 | "lw $a0, -32768($a1)\n" |
| 1774 | "lui $at, 0xABCD\n" |
| 1775 | "ori $at, 0xEF00\n" |
| 1776 | "daddu $at, $at, $a1\n" |
| 1777 | "lw $a0, 0($at)\n" |
| 1778 | |
| 1779 | "lwu $a0, 0($a0)\n" |
| 1780 | "lwu $a0, 0($a1)\n" |
| 1781 | "lwu $a0, 4($a1)\n" |
| 1782 | "lwu $a0, 256($a1)\n" |
| 1783 | "lwu $a0, 1000($a1)\n" |
| 1784 | "lwu $a0, 0x7FFC($a1)\n" |
| 1785 | "ori $at, $zero, 0x8000\n" |
| 1786 | "daddu $at, $at, $a1\n" |
| 1787 | "lwu $a0, 0($at)\n" |
| 1788 | "ori $at, $zero, 0x8000\n" |
| 1789 | "daddu $at, $at, $a1\n" |
| 1790 | "lwu $a0, 4($at)\n" |
| 1791 | "lui $at, 1\n" |
| 1792 | "daddu $at, $at, $a1\n" |
| 1793 | "lwu $a0, 0($at)\n" |
| 1794 | "lui $at, 0x1234\n" |
| 1795 | "ori $at, 0x5678\n" |
| 1796 | "daddu $at, $at, $a1\n" |
| 1797 | "lwu $a0, 0($at)\n" |
| 1798 | "lwu $a0, -256($a1)\n" |
| 1799 | "lwu $a0, -32768($a1)\n" |
| 1800 | "lui $at, 0xABCD\n" |
| 1801 | "ori $at, 0xEF00\n" |
| 1802 | "daddu $at, $at, $a1\n" |
| 1803 | "lwu $a0, 0($at)\n" |
| 1804 | |
| 1805 | "ld $a0, 0($a0)\n" |
| 1806 | "ld $a0, 0($a1)\n" |
| 1807 | "lwu $a0, 4($a1)\n" |
| 1808 | "lwu $t3, 8($a1)\n" |
| 1809 | "dins $a0, $t3, 32, 32\n" |
| 1810 | "ld $a0, 256($a1)\n" |
| 1811 | "ld $a0, 1000($a1)\n" |
| 1812 | "ori $at, $zero, 0x7FF8\n" |
| 1813 | "daddu $at, $at, $a1\n" |
| 1814 | "lwu $a0, 4($at)\n" |
| 1815 | "lwu $t3, 8($at)\n" |
| 1816 | "dins $a0, $t3, 32, 32\n" |
| 1817 | "ori $at, $zero, 0x8000\n" |
| 1818 | "daddu $at, $at, $a1\n" |
| 1819 | "ld $a0, 0($at)\n" |
| 1820 | "ori $at, $zero, 0x8000\n" |
| 1821 | "daddu $at, $at, $a1\n" |
| 1822 | "lwu $a0, 4($at)\n" |
| 1823 | "lwu $t3, 8($at)\n" |
| 1824 | "dins $a0, $t3, 32, 32\n" |
| 1825 | "lui $at, 1\n" |
| 1826 | "daddu $at, $at, $a1\n" |
| 1827 | "ld $a0, 0($at)\n" |
| 1828 | "lui $at, 0x1234\n" |
| 1829 | "ori $at, 0x5678\n" |
| 1830 | "daddu $at, $at, $a1\n" |
| 1831 | "ld $a0, 0($at)\n" |
| 1832 | "ld $a0, -256($a1)\n" |
| 1833 | "ld $a0, -32768($a1)\n" |
| 1834 | "lui $at, 0xABCD\n" |
| 1835 | "ori $at, 0xEF00\n" |
| 1836 | "daddu $at, $at, $a1\n" |
| 1837 | "ld $a0, 0($at)\n"; |
| 1838 | DriverStr(expected, "LoadFromOffset"); |
| 1839 | } |
| 1840 | |
| 1841 | TEST_F(AssemblerMIPS64Test, LoadFpuFromOffset) { |
| 1842 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0); |
| 1843 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 4); |
| 1844 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 256); |
| 1845 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x7FFC); |
| 1846 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x8000); |
| 1847 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x8004); |
| 1848 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x10000); |
| 1849 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0x12345678); |
| 1850 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, -256); |
| 1851 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, -32768); |
| 1852 | __ LoadFpuFromOffset(mips64::kLoadWord, mips64::F0, mips64::A0, 0xABCDEF00); |
| 1853 | |
| 1854 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0); |
| 1855 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 4); |
| 1856 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 256); |
| 1857 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x7FFC); |
| 1858 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x8000); |
| 1859 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x8004); |
| 1860 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x10000); |
| 1861 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0x12345678); |
| 1862 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, -256); |
| 1863 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, -32768); |
| 1864 | __ LoadFpuFromOffset(mips64::kLoadDoubleword, mips64::F0, mips64::A0, 0xABCDEF00); |
| 1865 | |
| 1866 | const char* expected = |
| 1867 | "lwc1 $f0, 0($a0)\n" |
| 1868 | "lwc1 $f0, 4($a0)\n" |
| 1869 | "lwc1 $f0, 256($a0)\n" |
| 1870 | "lwc1 $f0, 0x7FFC($a0)\n" |
| 1871 | "ori $at, $zero, 0x8000\n" |
| 1872 | "daddu $at, $at, $a0\n" |
| 1873 | "lwc1 $f0, 0($at)\n" |
| 1874 | "ori $at, $zero, 0x8000\n" |
| 1875 | "daddu $at, $at, $a0\n" |
| 1876 | "lwc1 $f0, 4($at)\n" |
| 1877 | "lui $at, 1\n" |
| 1878 | "daddu $at, $at, $a0\n" |
| 1879 | "lwc1 $f0, 0($at)\n" |
| 1880 | "lui $at, 0x1234\n" |
| 1881 | "ori $at, 0x5678\n" |
| 1882 | "daddu $at, $at, $a0\n" |
| 1883 | "lwc1 $f0, 0($at)\n" |
| 1884 | "lwc1 $f0, -256($a0)\n" |
| 1885 | "lwc1 $f0, -32768($a0)\n" |
| 1886 | "lui $at, 0xABCD\n" |
| 1887 | "ori $at, 0xEF00\n" |
| 1888 | "daddu $at, $at, $a0\n" |
| 1889 | "lwc1 $f0, 0($at)\n" |
| 1890 | |
| 1891 | "ldc1 $f0, 0($a0)\n" |
| 1892 | "lwc1 $f0, 4($a0)\n" |
| 1893 | "lw $t3, 8($a0)\n" |
| 1894 | "mthc1 $t3, $f0\n" |
| 1895 | "ldc1 $f0, 256($a0)\n" |
| 1896 | "ori $at, $zero, 0x7FF8\n" |
| 1897 | "daddu $at, $at, $a0\n" |
| 1898 | "lwc1 $f0, 4($at)\n" |
| 1899 | "lw $t3, 8($at)\n" |
| 1900 | "mthc1 $t3, $f0\n" |
| 1901 | "ori $at, $zero, 0x8000\n" |
| 1902 | "daddu $at, $at, $a0\n" |
| 1903 | "ldc1 $f0, 0($at)\n" |
| 1904 | "ori $at, $zero, 0x8000\n" |
| 1905 | "daddu $at, $at, $a0\n" |
| 1906 | "lwc1 $f0, 4($at)\n" |
| 1907 | "lw $t3, 8($at)\n" |
| 1908 | "mthc1 $t3, $f0\n" |
| 1909 | "lui $at, 1\n" |
| 1910 | "daddu $at, $at, $a0\n" |
| 1911 | "ldc1 $f0, 0($at)\n" |
| 1912 | "lui $at, 0x1234\n" |
| 1913 | "ori $at, 0x5678\n" |
| 1914 | "daddu $at, $at, $a0\n" |
| 1915 | "ldc1 $f0, 0($at)\n" |
| 1916 | "ldc1 $f0, -256($a0)\n" |
| 1917 | "ldc1 $f0, -32768($a0)\n" |
| 1918 | "lui $at, 0xABCD\n" |
| 1919 | "ori $at, 0xEF00\n" |
| 1920 | "daddu $at, $at, $a0\n" |
| 1921 | "ldc1 $f0, 0($at)\n"; |
| 1922 | DriverStr(expected, "LoadFpuFromOffset"); |
| 1923 | } |
| 1924 | |
| 1925 | TEST_F(AssemblerMIPS64Test, StoreToOffset) { |
| 1926 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A0, 0); |
| 1927 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0); |
| 1928 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 1); |
| 1929 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 256); |
| 1930 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 1000); |
| 1931 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x7FFF); |
| 1932 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x8000); |
| 1933 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x8001); |
| 1934 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x10000); |
| 1935 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0x12345678); |
| 1936 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, -256); |
| 1937 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, -32768); |
| 1938 | __ StoreToOffset(mips64::kStoreByte, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1939 | |
| 1940 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A0, 0); |
| 1941 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0); |
| 1942 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 2); |
| 1943 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 256); |
| 1944 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 1000); |
| 1945 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x7FFE); |
| 1946 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x8000); |
| 1947 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x8002); |
| 1948 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x10000); |
| 1949 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0x12345678); |
| 1950 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, -256); |
| 1951 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, -32768); |
| 1952 | __ StoreToOffset(mips64::kStoreHalfword, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1953 | |
| 1954 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A0, 0); |
| 1955 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0); |
| 1956 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 4); |
| 1957 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 256); |
| 1958 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 1000); |
| 1959 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x7FFC); |
| 1960 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x8000); |
| 1961 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x8004); |
| 1962 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x10000); |
| 1963 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0x12345678); |
| 1964 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, -256); |
| 1965 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, -32768); |
| 1966 | __ StoreToOffset(mips64::kStoreWord, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1967 | |
| 1968 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A0, 0); |
| 1969 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0); |
| 1970 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 4); |
| 1971 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 256); |
| 1972 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 1000); |
| 1973 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x7FFC); |
| 1974 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x8000); |
| 1975 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x8004); |
| 1976 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x10000); |
| 1977 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0x12345678); |
| 1978 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, -256); |
| 1979 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, -32768); |
| 1980 | __ StoreToOffset(mips64::kStoreDoubleword, mips64::A0, mips64::A1, 0xABCDEF00); |
| 1981 | |
| 1982 | const char* expected = |
| 1983 | "sb $a0, 0($a0)\n" |
| 1984 | "sb $a0, 0($a1)\n" |
| 1985 | "sb $a0, 1($a1)\n" |
| 1986 | "sb $a0, 256($a1)\n" |
| 1987 | "sb $a0, 1000($a1)\n" |
| 1988 | "sb $a0, 0x7FFF($a1)\n" |
| 1989 | "ori $at, $zero, 0x8000\n" |
| 1990 | "daddu $at, $at, $a1\n" |
| 1991 | "sb $a0, 0($at)\n" |
| 1992 | "ori $at, $zero, 0x8000\n" |
| 1993 | "daddu $at, $at, $a1\n" |
| 1994 | "sb $a0, 1($at)\n" |
| 1995 | "lui $at, 1\n" |
| 1996 | "daddu $at, $at, $a1\n" |
| 1997 | "sb $a0, 0($at)\n" |
| 1998 | "lui $at, 0x1234\n" |
| 1999 | "ori $at, 0x5678\n" |
| 2000 | "daddu $at, $at, $a1\n" |
| 2001 | "sb $a0, 0($at)\n" |
| 2002 | "sb $a0, -256($a1)\n" |
| 2003 | "sb $a0, -32768($a1)\n" |
| 2004 | "lui $at, 0xABCD\n" |
| 2005 | "ori $at, 0xEF00\n" |
| 2006 | "daddu $at, $at, $a1\n" |
| 2007 | "sb $a0, 0($at)\n" |
| 2008 | |
| 2009 | "sh $a0, 0($a0)\n" |
| 2010 | "sh $a0, 0($a1)\n" |
| 2011 | "sh $a0, 2($a1)\n" |
| 2012 | "sh $a0, 256($a1)\n" |
| 2013 | "sh $a0, 1000($a1)\n" |
| 2014 | "sh $a0, 0x7FFE($a1)\n" |
| 2015 | "ori $at, $zero, 0x8000\n" |
| 2016 | "daddu $at, $at, $a1\n" |
| 2017 | "sh $a0, 0($at)\n" |
| 2018 | "ori $at, $zero, 0x8000\n" |
| 2019 | "daddu $at, $at, $a1\n" |
| 2020 | "sh $a0, 2($at)\n" |
| 2021 | "lui $at, 1\n" |
| 2022 | "daddu $at, $at, $a1\n" |
| 2023 | "sh $a0, 0($at)\n" |
| 2024 | "lui $at, 0x1234\n" |
| 2025 | "ori $at, 0x5678\n" |
| 2026 | "daddu $at, $at, $a1\n" |
| 2027 | "sh $a0, 0($at)\n" |
| 2028 | "sh $a0, -256($a1)\n" |
| 2029 | "sh $a0, -32768($a1)\n" |
| 2030 | "lui $at, 0xABCD\n" |
| 2031 | "ori $at, 0xEF00\n" |
| 2032 | "daddu $at, $at, $a1\n" |
| 2033 | "sh $a0, 0($at)\n" |
| 2034 | |
| 2035 | "sw $a0, 0($a0)\n" |
| 2036 | "sw $a0, 0($a1)\n" |
| 2037 | "sw $a0, 4($a1)\n" |
| 2038 | "sw $a0, 256($a1)\n" |
| 2039 | "sw $a0, 1000($a1)\n" |
| 2040 | "sw $a0, 0x7FFC($a1)\n" |
| 2041 | "ori $at, $zero, 0x8000\n" |
| 2042 | "daddu $at, $at, $a1\n" |
| 2043 | "sw $a0, 0($at)\n" |
| 2044 | "ori $at, $zero, 0x8000\n" |
| 2045 | "daddu $at, $at, $a1\n" |
| 2046 | "sw $a0, 4($at)\n" |
| 2047 | "lui $at, 1\n" |
| 2048 | "daddu $at, $at, $a1\n" |
| 2049 | "sw $a0, 0($at)\n" |
| 2050 | "lui $at, 0x1234\n" |
| 2051 | "ori $at, 0x5678\n" |
| 2052 | "daddu $at, $at, $a1\n" |
| 2053 | "sw $a0, 0($at)\n" |
| 2054 | "sw $a0, -256($a1)\n" |
| 2055 | "sw $a0, -32768($a1)\n" |
| 2056 | "lui $at, 0xABCD\n" |
| 2057 | "ori $at, 0xEF00\n" |
| 2058 | "daddu $at, $at, $a1\n" |
| 2059 | "sw $a0, 0($at)\n" |
| 2060 | |
| 2061 | "sd $a0, 0($a0)\n" |
| 2062 | "sd $a0, 0($a1)\n" |
| 2063 | "sw $a0, 4($a1)\n" |
| 2064 | "dsrl32 $t3, $a0, 0\n" |
| 2065 | "sw $t3, 8($a1)\n" |
| 2066 | "sd $a0, 256($a1)\n" |
| 2067 | "sd $a0, 1000($a1)\n" |
| 2068 | "ori $at, $zero, 0x7FF8\n" |
| 2069 | "daddu $at, $at, $a1\n" |
| 2070 | "sw $a0, 4($at)\n" |
| 2071 | "dsrl32 $t3, $a0, 0\n" |
| 2072 | "sw $t3, 8($at)\n" |
| 2073 | "ori $at, $zero, 0x8000\n" |
| 2074 | "daddu $at, $at, $a1\n" |
| 2075 | "sd $a0, 0($at)\n" |
| 2076 | "ori $at, $zero, 0x8000\n" |
| 2077 | "daddu $at, $at, $a1\n" |
| 2078 | "sw $a0, 4($at)\n" |
| 2079 | "dsrl32 $t3, $a0, 0\n" |
| 2080 | "sw $t3, 8($at)\n" |
| 2081 | "lui $at, 1\n" |
| 2082 | "daddu $at, $at, $a1\n" |
| 2083 | "sd $a0, 0($at)\n" |
| 2084 | "lui $at, 0x1234\n" |
| 2085 | "ori $at, 0x5678\n" |
| 2086 | "daddu $at, $at, $a1\n" |
| 2087 | "sd $a0, 0($at)\n" |
| 2088 | "sd $a0, -256($a1)\n" |
| 2089 | "sd $a0, -32768($a1)\n" |
| 2090 | "lui $at, 0xABCD\n" |
| 2091 | "ori $at, 0xEF00\n" |
| 2092 | "daddu $at, $at, $a1\n" |
| 2093 | "sd $a0, 0($at)\n"; |
| 2094 | DriverStr(expected, "StoreToOffset"); |
| 2095 | } |
| 2096 | |
| 2097 | TEST_F(AssemblerMIPS64Test, StoreFpuToOffset) { |
| 2098 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0); |
| 2099 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 4); |
| 2100 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 256); |
| 2101 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x7FFC); |
| 2102 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x8000); |
| 2103 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x8004); |
| 2104 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x10000); |
| 2105 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0x12345678); |
| 2106 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, -256); |
| 2107 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, -32768); |
| 2108 | __ StoreFpuToOffset(mips64::kStoreWord, mips64::F0, mips64::A0, 0xABCDEF00); |
| 2109 | |
| 2110 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0); |
| 2111 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 4); |
| 2112 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 256); |
| 2113 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x7FFC); |
| 2114 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x8000); |
| 2115 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x8004); |
| 2116 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x10000); |
| 2117 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0x12345678); |
| 2118 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, -256); |
| 2119 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, -32768); |
| 2120 | __ StoreFpuToOffset(mips64::kStoreDoubleword, mips64::F0, mips64::A0, 0xABCDEF00); |
| 2121 | |
| 2122 | const char* expected = |
| 2123 | "swc1 $f0, 0($a0)\n" |
| 2124 | "swc1 $f0, 4($a0)\n" |
| 2125 | "swc1 $f0, 256($a0)\n" |
| 2126 | "swc1 $f0, 0x7FFC($a0)\n" |
| 2127 | "ori $at, $zero, 0x8000\n" |
| 2128 | "daddu $at, $at, $a0\n" |
| 2129 | "swc1 $f0, 0($at)\n" |
| 2130 | "ori $at, $zero, 0x8000\n" |
| 2131 | "daddu $at, $at, $a0\n" |
| 2132 | "swc1 $f0, 4($at)\n" |
| 2133 | "lui $at, 1\n" |
| 2134 | "daddu $at, $at, $a0\n" |
| 2135 | "swc1 $f0, 0($at)\n" |
| 2136 | "lui $at, 0x1234\n" |
| 2137 | "ori $at, 0x5678\n" |
| 2138 | "daddu $at, $at, $a0\n" |
| 2139 | "swc1 $f0, 0($at)\n" |
| 2140 | "swc1 $f0, -256($a0)\n" |
| 2141 | "swc1 $f0, -32768($a0)\n" |
| 2142 | "lui $at, 0xABCD\n" |
| 2143 | "ori $at, 0xEF00\n" |
| 2144 | "daddu $at, $at, $a0\n" |
| 2145 | "swc1 $f0, 0($at)\n" |
| 2146 | |
| 2147 | "sdc1 $f0, 0($a0)\n" |
| 2148 | "mfhc1 $t3, $f0\n" |
| 2149 | "swc1 $f0, 4($a0)\n" |
| 2150 | "sw $t3, 8($a0)\n" |
| 2151 | "sdc1 $f0, 256($a0)\n" |
| 2152 | "ori $at, $zero, 0x7FF8\n" |
| 2153 | "daddu $at, $at, $a0\n" |
| 2154 | "mfhc1 $t3, $f0\n" |
| 2155 | "swc1 $f0, 4($at)\n" |
| 2156 | "sw $t3, 8($at)\n" |
| 2157 | "ori $at, $zero, 0x8000\n" |
| 2158 | "daddu $at, $at, $a0\n" |
| 2159 | "sdc1 $f0, 0($at)\n" |
| 2160 | "ori $at, $zero, 0x8000\n" |
| 2161 | "daddu $at, $at, $a0\n" |
| 2162 | "mfhc1 $t3, $f0\n" |
| 2163 | "swc1 $f0, 4($at)\n" |
| 2164 | "sw $t3, 8($at)\n" |
| 2165 | "lui $at, 1\n" |
| 2166 | "daddu $at, $at, $a0\n" |
| 2167 | "sdc1 $f0, 0($at)\n" |
| 2168 | "lui $at, 0x1234\n" |
| 2169 | "ori $at, 0x5678\n" |
| 2170 | "daddu $at, $at, $a0\n" |
| 2171 | "sdc1 $f0, 0($at)\n" |
| 2172 | "sdc1 $f0, -256($a0)\n" |
| 2173 | "sdc1 $f0, -32768($a0)\n" |
| 2174 | "lui $at, 0xABCD\n" |
| 2175 | "ori $at, 0xEF00\n" |
| 2176 | "daddu $at, $at, $a0\n" |
| 2177 | "sdc1 $f0, 0($at)\n"; |
| 2178 | DriverStr(expected, "StoreFpuToOffset"); |
| 2179 | } |
| 2180 | |
Alexey Frunze | 0960ac5 | 2016-12-20 17:24:59 -0800 | [diff] [blame] | 2181 | ////////////////////////////// |
| 2182 | // Loading/adding Constants // |
| 2183 | ////////////////////////////// |
Chris Larsen | c733dca | 2016-05-13 16:11:47 -0700 | [diff] [blame] | 2184 | |
| 2185 | TEST_F(AssemblerMIPS64Test, LoadConst32) { |
| 2186 | // IsUint<16>(value) |
| 2187 | __ LoadConst32(mips64::V0, 0); |
| 2188 | __ LoadConst32(mips64::V0, 65535); |
| 2189 | // IsInt<16>(value) |
| 2190 | __ LoadConst32(mips64::V0, -1); |
| 2191 | __ LoadConst32(mips64::V0, -32768); |
| 2192 | // Everything else |
| 2193 | __ LoadConst32(mips64::V0, 65536); |
| 2194 | __ LoadConst32(mips64::V0, 65537); |
| 2195 | __ LoadConst32(mips64::V0, 2147483647); |
| 2196 | __ LoadConst32(mips64::V0, -32769); |
| 2197 | __ LoadConst32(mips64::V0, -65536); |
| 2198 | __ LoadConst32(mips64::V0, -65537); |
| 2199 | __ LoadConst32(mips64::V0, -2147483647); |
| 2200 | __ LoadConst32(mips64::V0, -2147483648); |
| 2201 | |
| 2202 | const char* expected = |
| 2203 | // IsUint<16>(value) |
| 2204 | "ori $v0, $zero, 0\n" // __ LoadConst32(mips64::V0, 0); |
| 2205 | "ori $v0, $zero, 65535\n" // __ LoadConst32(mips64::V0, 65535); |
| 2206 | // IsInt<16>(value) |
| 2207 | "addiu $v0, $zero, -1\n" // __ LoadConst32(mips64::V0, -1); |
| 2208 | "addiu $v0, $zero, -32768\n" // __ LoadConst32(mips64::V0, -32768); |
| 2209 | // Everything else |
| 2210 | "lui $v0, 1\n" // __ LoadConst32(mips64::V0, 65536); |
| 2211 | "lui $v0, 1\n" // __ LoadConst32(mips64::V0, 65537); |
| 2212 | "ori $v0, 1\n" // " |
| 2213 | "lui $v0, 32767\n" // __ LoadConst32(mips64::V0, 2147483647); |
| 2214 | "ori $v0, 65535\n" // " |
| 2215 | "lui $v0, 65535\n" // __ LoadConst32(mips64::V0, -32769); |
| 2216 | "ori $v0, 32767\n" // " |
| 2217 | "lui $v0, 65535\n" // __ LoadConst32(mips64::V0, -65536); |
| 2218 | "lui $v0, 65534\n" // __ LoadConst32(mips64::V0, -65537); |
| 2219 | "ori $v0, 65535\n" // " |
| 2220 | "lui $v0, 32768\n" // __ LoadConst32(mips64::V0, -2147483647); |
| 2221 | "ori $v0, 1\n" // " |
| 2222 | "lui $v0, 32768\n"; // __ LoadConst32(mips64::V0, -2147483648); |
| 2223 | DriverStr(expected, "LoadConst32"); |
| 2224 | } |
| 2225 | |
Alexey Frunze | 0960ac5 | 2016-12-20 17:24:59 -0800 | [diff] [blame] | 2226 | TEST_F(AssemblerMIPS64Test, Addiu32) { |
| 2227 | __ Addiu32(mips64::A1, mips64::A2, -0x8000); |
| 2228 | __ Addiu32(mips64::A1, mips64::A2, +0); |
| 2229 | __ Addiu32(mips64::A1, mips64::A2, +0x7FFF); |
| 2230 | __ Addiu32(mips64::A1, mips64::A2, -0x8001); |
| 2231 | __ Addiu32(mips64::A1, mips64::A2, +0x8000); |
| 2232 | __ Addiu32(mips64::A1, mips64::A2, -0x10000); |
| 2233 | __ Addiu32(mips64::A1, mips64::A2, +0x10000); |
| 2234 | __ Addiu32(mips64::A1, mips64::A2, +0x12345678); |
| 2235 | |
| 2236 | const char* expected = |
| 2237 | "addiu $a1, $a2, -0x8000\n" |
| 2238 | "addiu $a1, $a2, 0\n" |
| 2239 | "addiu $a1, $a2, 0x7FFF\n" |
| 2240 | "aui $a1, $a2, 0xFFFF\n" |
| 2241 | "addiu $a1, $a1, 0x7FFF\n" |
| 2242 | "aui $a1, $a2, 1\n" |
| 2243 | "addiu $a1, $a1, -0x8000\n" |
| 2244 | "aui $a1, $a2, 0xFFFF\n" |
| 2245 | "aui $a1, $a2, 1\n" |
| 2246 | "aui $a1, $a2, 0x1234\n" |
| 2247 | "addiu $a1, $a1, 0x5678\n"; |
| 2248 | DriverStr(expected, "Addiu32"); |
| 2249 | } |
| 2250 | |
Chris Larsen | c733dca | 2016-05-13 16:11:47 -0700 | [diff] [blame] | 2251 | static uint64_t SignExtend16To64(uint16_t n) { |
| 2252 | return static_cast<int16_t>(n); |
| 2253 | } |
| 2254 | |
| 2255 | // The art::mips64::Mips64Assembler::LoadConst64() method uses a template |
| 2256 | // to minimize the number of instructions needed to load a 64-bit constant |
| 2257 | // value into a register. The template calls various methods which emit |
| 2258 | // MIPS machine instructions. This struct (class) uses the same template |
| 2259 | // but overrides the definitions of the methods which emit MIPS instructions |
| 2260 | // to use methods which simulate the operation of the corresponding MIPS |
| 2261 | // instructions. After invoking LoadConst64() the target register should |
| 2262 | // contain the same 64-bit value as was input to LoadConst64(). If the |
| 2263 | // simulated register doesn't contain the correct value then there is probably |
| 2264 | // an error in the template function. |
| 2265 | struct LoadConst64Tester { |
| 2266 | LoadConst64Tester() { |
| 2267 | // Initialize all of the registers for simulation to zero. |
| 2268 | for (int r = 0; r < 32; r++) { |
| 2269 | regs_[r] = 0; |
| 2270 | } |
| 2271 | // Clear all of the path flags. |
| 2272 | loadconst64_paths_ = art::mips64::kLoadConst64PathZero; |
| 2273 | } |
| 2274 | void Addiu(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) { |
| 2275 | regs_[rd] = static_cast<int32_t>(regs_[rs] + SignExtend16To64(c)); |
| 2276 | } |
| 2277 | void Daddiu(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) { |
| 2278 | regs_[rd] = regs_[rs] + SignExtend16To64(c); |
| 2279 | } |
| 2280 | void Dahi(mips64::GpuRegister rd, uint16_t c) { |
| 2281 | regs_[rd] += SignExtend16To64(c) << 32; |
| 2282 | } |
| 2283 | void Dati(mips64::GpuRegister rd, uint16_t c) { |
| 2284 | regs_[rd] += SignExtend16To64(c) << 48; |
| 2285 | } |
| 2286 | void Dinsu(mips64::GpuRegister rt, mips64::GpuRegister rs, int pos, int size) { |
| 2287 | CHECK(IsUint<5>(pos - 32)) << pos; |
| 2288 | CHECK(IsUint<5>(size - 1)) << size; |
| 2289 | CHECK(IsUint<5>(pos + size - 33)) << pos << " + " << size; |
| 2290 | uint64_t src_mask = (UINT64_C(1) << size) - 1; |
| 2291 | uint64_t dsk_mask = ~(src_mask << pos); |
| 2292 | |
| 2293 | regs_[rt] = (regs_[rt] & dsk_mask) | ((regs_[rs] & src_mask) << pos); |
| 2294 | } |
| 2295 | void Dsll(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) { |
| 2296 | regs_[rd] = regs_[rt] << (shamt & 0x1f); |
| 2297 | } |
| 2298 | void Dsll32(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) { |
| 2299 | regs_[rd] = regs_[rt] << (32 + (shamt & 0x1f)); |
| 2300 | } |
| 2301 | void Dsrl(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) { |
| 2302 | regs_[rd] = regs_[rt] >> (shamt & 0x1f); |
| 2303 | } |
| 2304 | void Dsrl32(mips64::GpuRegister rd, mips64::GpuRegister rt, int shamt) { |
| 2305 | regs_[rd] = regs_[rt] >> (32 + (shamt & 0x1f)); |
| 2306 | } |
| 2307 | void Lui(mips64::GpuRegister rd, uint16_t c) { |
| 2308 | regs_[rd] = SignExtend16To64(c) << 16; |
| 2309 | } |
| 2310 | void Ori(mips64::GpuRegister rd, mips64::GpuRegister rs, uint16_t c) { |
| 2311 | regs_[rd] = regs_[rs] | c; |
| 2312 | } |
| 2313 | void LoadConst32(mips64::GpuRegister rd, int32_t c) { |
| 2314 | CHECK_NE(rd, 0); |
| 2315 | mips64::TemplateLoadConst32<LoadConst64Tester>(this, rd, c); |
| 2316 | CHECK_EQ(regs_[rd], static_cast<uint64_t>(c)); |
| 2317 | } |
| 2318 | void LoadConst64(mips64::GpuRegister rd, int64_t c) { |
| 2319 | CHECK_NE(rd, 0); |
| 2320 | mips64::TemplateLoadConst64<LoadConst64Tester>(this, rd, c); |
| 2321 | CHECK_EQ(regs_[rd], static_cast<uint64_t>(c)); |
| 2322 | } |
| 2323 | uint64_t regs_[32]; |
| 2324 | |
| 2325 | // Getter function for loadconst64_paths_. |
| 2326 | int GetPathsCovered() { |
| 2327 | return loadconst64_paths_; |
| 2328 | } |
| 2329 | |
| 2330 | void RecordLoadConst64Path(int value) { |
| 2331 | loadconst64_paths_ |= value; |
| 2332 | } |
| 2333 | |
| 2334 | private: |
| 2335 | // This variable holds a bitmask to tell us which paths were taken |
| 2336 | // through the template function which loads 64-bit values. |
| 2337 | int loadconst64_paths_; |
| 2338 | }; |
| 2339 | |
| 2340 | TEST_F(AssemblerMIPS64Test, LoadConst64) { |
| 2341 | const uint16_t imms[] = { |
| 2342 | 0, 1, 2, 3, 4, 0x33, 0x66, 0x55, 0x99, 0xaa, 0xcc, 0xff, 0x5500, 0x5555, |
| 2343 | 0x7ffc, 0x7ffd, 0x7ffe, 0x7fff, 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, |
| 2344 | 0xaaaa, 0xfffc, 0xfffd, 0xfffe, 0xffff |
| 2345 | }; |
| 2346 | unsigned d0, d1, d2, d3; |
| 2347 | LoadConst64Tester tester; |
| 2348 | |
| 2349 | union { |
| 2350 | int64_t v64; |
| 2351 | uint16_t v16[4]; |
| 2352 | } u; |
| 2353 | |
| 2354 | for (d3 = 0; d3 < sizeof imms / sizeof imms[0]; d3++) { |
| 2355 | u.v16[3] = imms[d3]; |
| 2356 | |
| 2357 | for (d2 = 0; d2 < sizeof imms / sizeof imms[0]; d2++) { |
| 2358 | u.v16[2] = imms[d2]; |
| 2359 | |
| 2360 | for (d1 = 0; d1 < sizeof imms / sizeof imms[0]; d1++) { |
| 2361 | u.v16[1] = imms[d1]; |
| 2362 | |
| 2363 | for (d0 = 0; d0 < sizeof imms / sizeof imms[0]; d0++) { |
| 2364 | u.v16[0] = imms[d0]; |
| 2365 | |
| 2366 | tester.LoadConst64(mips64::V0, u.v64); |
| 2367 | } |
| 2368 | } |
| 2369 | } |
| 2370 | } |
| 2371 | |
| 2372 | // Verify that we tested all paths through the "load 64-bit value" |
| 2373 | // function template. |
| 2374 | EXPECT_EQ(tester.GetPathsCovered(), art::mips64::kLoadConst64PathAllPaths); |
| 2375 | } |
| 2376 | |
Lazar Trsic | d967266 | 2015-09-03 17:33:01 +0200 | [diff] [blame] | 2377 | #undef __ |
| 2378 | |
Chris Larsen | dbce0d7 | 2015-09-17 13:34:00 -0700 | [diff] [blame] | 2379 | } // namespace art |