Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [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_mips.h" |
| 18 | |
| 19 | #include <map> |
| 20 | |
| 21 | #include "base/stl_util.h" |
| 22 | #include "utils/assembler_test.h" |
| 23 | |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 24 | #define __ GetAssembler()-> |
| 25 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 26 | namespace art { |
| 27 | |
| 28 | struct MIPSCpuRegisterCompare { |
| 29 | bool operator()(const mips::Register& a, const mips::Register& b) const { |
| 30 | return a < b; |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | class AssemblerMIPSTest : public AssemblerTest<mips::MipsAssembler, |
Aart Bik | caa31e7 | 2017-09-14 17:08:50 -0700 | [diff] [blame] | 35 | mips::MipsLabel, |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 36 | mips::Register, |
| 37 | mips::FRegister, |
| 38 | uint32_t> { |
| 39 | public: |
Andreas Gampe | c55bb39 | 2018-09-21 00:02:02 +0000 | [diff] [blame^] | 40 | using Base = AssemblerTest<mips::MipsAssembler, |
| 41 | mips::MipsLabel, |
| 42 | mips::Register, |
| 43 | mips::FRegister, |
| 44 | uint32_t>; |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 45 | |
Vladimir Marko | 9a6ca9f | 2018-05-04 13:06:55 +0100 | [diff] [blame] | 46 | // These tests were taking too long, so we hide the DriverStr() from AssemblerTest<> |
| 47 | // and reimplement it without the verification against `assembly_string`. b/73903608 |
| 48 | void DriverStr(const std::string& assembly_string ATTRIBUTE_UNUSED, |
| 49 | const std::string& test_name ATTRIBUTE_UNUSED) { |
| 50 | GetAssembler()->FinalizeCode(); |
| 51 | std::vector<uint8_t> data(GetAssembler()->CodeSize()); |
| 52 | MemoryRegion code(data.data(), data.size()); |
| 53 | GetAssembler()->FinalizeInstructions(code); |
| 54 | } |
| 55 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 56 | protected: |
| 57 | // Get the typically used name for this architecture, e.g., aarch64, x86-64, ... |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 58 | std::string GetArchitectureString() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 59 | return "mips"; |
| 60 | } |
| 61 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 62 | std::string GetAssemblerParameters() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 63 | return " --no-warn -32 -march=mips32r2"; |
| 64 | } |
| 65 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 66 | std::string GetDisassembleParameters() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 67 | return " -D -bbinary -mmips:isa32r2"; |
| 68 | } |
| 69 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 70 | void SetUpHelpers() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 71 | if (registers_.size() == 0) { |
| 72 | registers_.push_back(new mips::Register(mips::ZERO)); |
| 73 | registers_.push_back(new mips::Register(mips::AT)); |
| 74 | registers_.push_back(new mips::Register(mips::V0)); |
| 75 | registers_.push_back(new mips::Register(mips::V1)); |
| 76 | registers_.push_back(new mips::Register(mips::A0)); |
| 77 | registers_.push_back(new mips::Register(mips::A1)); |
| 78 | registers_.push_back(new mips::Register(mips::A2)); |
| 79 | registers_.push_back(new mips::Register(mips::A3)); |
| 80 | registers_.push_back(new mips::Register(mips::T0)); |
| 81 | registers_.push_back(new mips::Register(mips::T1)); |
| 82 | registers_.push_back(new mips::Register(mips::T2)); |
| 83 | registers_.push_back(new mips::Register(mips::T3)); |
| 84 | registers_.push_back(new mips::Register(mips::T4)); |
| 85 | registers_.push_back(new mips::Register(mips::T5)); |
| 86 | registers_.push_back(new mips::Register(mips::T6)); |
| 87 | registers_.push_back(new mips::Register(mips::T7)); |
| 88 | registers_.push_back(new mips::Register(mips::S0)); |
| 89 | registers_.push_back(new mips::Register(mips::S1)); |
| 90 | registers_.push_back(new mips::Register(mips::S2)); |
| 91 | registers_.push_back(new mips::Register(mips::S3)); |
| 92 | registers_.push_back(new mips::Register(mips::S4)); |
| 93 | registers_.push_back(new mips::Register(mips::S5)); |
| 94 | registers_.push_back(new mips::Register(mips::S6)); |
| 95 | registers_.push_back(new mips::Register(mips::S7)); |
| 96 | registers_.push_back(new mips::Register(mips::T8)); |
| 97 | registers_.push_back(new mips::Register(mips::T9)); |
| 98 | registers_.push_back(new mips::Register(mips::K0)); |
| 99 | registers_.push_back(new mips::Register(mips::K1)); |
| 100 | registers_.push_back(new mips::Register(mips::GP)); |
| 101 | registers_.push_back(new mips::Register(mips::SP)); |
| 102 | registers_.push_back(new mips::Register(mips::FP)); |
| 103 | registers_.push_back(new mips::Register(mips::RA)); |
| 104 | |
| 105 | secondary_register_names_.emplace(mips::Register(mips::ZERO), "zero"); |
| 106 | secondary_register_names_.emplace(mips::Register(mips::AT), "at"); |
| 107 | secondary_register_names_.emplace(mips::Register(mips::V0), "v0"); |
| 108 | secondary_register_names_.emplace(mips::Register(mips::V1), "v1"); |
| 109 | secondary_register_names_.emplace(mips::Register(mips::A0), "a0"); |
| 110 | secondary_register_names_.emplace(mips::Register(mips::A1), "a1"); |
| 111 | secondary_register_names_.emplace(mips::Register(mips::A2), "a2"); |
| 112 | secondary_register_names_.emplace(mips::Register(mips::A3), "a3"); |
| 113 | secondary_register_names_.emplace(mips::Register(mips::T0), "t0"); |
| 114 | secondary_register_names_.emplace(mips::Register(mips::T1), "t1"); |
| 115 | secondary_register_names_.emplace(mips::Register(mips::T2), "t2"); |
| 116 | secondary_register_names_.emplace(mips::Register(mips::T3), "t3"); |
| 117 | secondary_register_names_.emplace(mips::Register(mips::T4), "t4"); |
| 118 | secondary_register_names_.emplace(mips::Register(mips::T5), "t5"); |
| 119 | secondary_register_names_.emplace(mips::Register(mips::T6), "t6"); |
| 120 | secondary_register_names_.emplace(mips::Register(mips::T7), "t7"); |
| 121 | secondary_register_names_.emplace(mips::Register(mips::S0), "s0"); |
| 122 | secondary_register_names_.emplace(mips::Register(mips::S1), "s1"); |
| 123 | secondary_register_names_.emplace(mips::Register(mips::S2), "s2"); |
| 124 | secondary_register_names_.emplace(mips::Register(mips::S3), "s3"); |
| 125 | secondary_register_names_.emplace(mips::Register(mips::S4), "s4"); |
| 126 | secondary_register_names_.emplace(mips::Register(mips::S5), "s5"); |
| 127 | secondary_register_names_.emplace(mips::Register(mips::S6), "s6"); |
| 128 | secondary_register_names_.emplace(mips::Register(mips::S7), "s7"); |
| 129 | secondary_register_names_.emplace(mips::Register(mips::T8), "t8"); |
| 130 | secondary_register_names_.emplace(mips::Register(mips::T9), "t9"); |
| 131 | secondary_register_names_.emplace(mips::Register(mips::K0), "k0"); |
| 132 | secondary_register_names_.emplace(mips::Register(mips::K1), "k1"); |
| 133 | secondary_register_names_.emplace(mips::Register(mips::GP), "gp"); |
| 134 | secondary_register_names_.emplace(mips::Register(mips::SP), "sp"); |
| 135 | secondary_register_names_.emplace(mips::Register(mips::FP), "fp"); |
| 136 | secondary_register_names_.emplace(mips::Register(mips::RA), "ra"); |
| 137 | |
| 138 | fp_registers_.push_back(new mips::FRegister(mips::F0)); |
| 139 | fp_registers_.push_back(new mips::FRegister(mips::F1)); |
| 140 | fp_registers_.push_back(new mips::FRegister(mips::F2)); |
| 141 | fp_registers_.push_back(new mips::FRegister(mips::F3)); |
| 142 | fp_registers_.push_back(new mips::FRegister(mips::F4)); |
| 143 | fp_registers_.push_back(new mips::FRegister(mips::F5)); |
| 144 | fp_registers_.push_back(new mips::FRegister(mips::F6)); |
| 145 | fp_registers_.push_back(new mips::FRegister(mips::F7)); |
| 146 | fp_registers_.push_back(new mips::FRegister(mips::F8)); |
| 147 | fp_registers_.push_back(new mips::FRegister(mips::F9)); |
| 148 | fp_registers_.push_back(new mips::FRegister(mips::F10)); |
| 149 | fp_registers_.push_back(new mips::FRegister(mips::F11)); |
| 150 | fp_registers_.push_back(new mips::FRegister(mips::F12)); |
| 151 | fp_registers_.push_back(new mips::FRegister(mips::F13)); |
| 152 | fp_registers_.push_back(new mips::FRegister(mips::F14)); |
| 153 | fp_registers_.push_back(new mips::FRegister(mips::F15)); |
| 154 | fp_registers_.push_back(new mips::FRegister(mips::F16)); |
| 155 | fp_registers_.push_back(new mips::FRegister(mips::F17)); |
| 156 | fp_registers_.push_back(new mips::FRegister(mips::F18)); |
| 157 | fp_registers_.push_back(new mips::FRegister(mips::F19)); |
| 158 | fp_registers_.push_back(new mips::FRegister(mips::F20)); |
| 159 | fp_registers_.push_back(new mips::FRegister(mips::F21)); |
| 160 | fp_registers_.push_back(new mips::FRegister(mips::F22)); |
| 161 | fp_registers_.push_back(new mips::FRegister(mips::F23)); |
| 162 | fp_registers_.push_back(new mips::FRegister(mips::F24)); |
| 163 | fp_registers_.push_back(new mips::FRegister(mips::F25)); |
| 164 | fp_registers_.push_back(new mips::FRegister(mips::F26)); |
| 165 | fp_registers_.push_back(new mips::FRegister(mips::F27)); |
| 166 | fp_registers_.push_back(new mips::FRegister(mips::F28)); |
| 167 | fp_registers_.push_back(new mips::FRegister(mips::F29)); |
| 168 | fp_registers_.push_back(new mips::FRegister(mips::F30)); |
| 169 | fp_registers_.push_back(new mips::FRegister(mips::F31)); |
| 170 | } |
| 171 | } |
| 172 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 173 | void TearDown() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 174 | AssemblerTest::TearDown(); |
| 175 | STLDeleteElements(®isters_); |
| 176 | STLDeleteElements(&fp_registers_); |
| 177 | } |
| 178 | |
Andreas Gampe | fa6a1b0 | 2018-09-07 08:11:55 -0700 | [diff] [blame] | 179 | std::vector<mips::MipsLabel> GetAddresses() override { |
Aart Bik | caa31e7 | 2017-09-14 17:08:50 -0700 | [diff] [blame] | 180 | UNIMPLEMENTED(FATAL) << "Feature not implemented yet"; |
| 181 | UNREACHABLE(); |
| 182 | } |
| 183 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 184 | std::vector<mips::Register*> GetRegisters() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 185 | return registers_; |
| 186 | } |
| 187 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 188 | std::vector<mips::FRegister*> GetFPRegisters() override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 189 | return fp_registers_; |
| 190 | } |
| 191 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 192 | uint32_t CreateImmediate(int64_t imm_value) override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 193 | return imm_value; |
| 194 | } |
| 195 | |
Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 196 | std::string GetSecondaryRegisterName(const mips::Register& reg) override { |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 197 | CHECK(secondary_register_names_.find(reg) != secondary_register_names_.end()); |
| 198 | return secondary_register_names_[reg]; |
| 199 | } |
| 200 | |
| 201 | std::string RepeatInsn(size_t count, const std::string& insn) { |
| 202 | std::string result; |
| 203 | for (; count != 0u; --count) { |
| 204 | result += insn; |
| 205 | } |
| 206 | return result; |
| 207 | } |
| 208 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 209 | void BranchHelper(void (mips::MipsAssembler::*f)(mips::MipsLabel*, |
| 210 | bool), |
| 211 | const std::string& instr_name, |
| 212 | bool is_bare = false) { |
| 213 | __ SetReorder(false); |
| 214 | mips::MipsLabel label1, label2; |
| 215 | (Base::GetAssembler()->*f)(&label1, is_bare); |
| 216 | constexpr size_t kAdduCount1 = 63; |
| 217 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 218 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 219 | } |
| 220 | __ Bind(&label1); |
| 221 | (Base::GetAssembler()->*f)(&label2, is_bare); |
| 222 | constexpr size_t kAdduCount2 = 64; |
| 223 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 224 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 225 | } |
| 226 | __ Bind(&label2); |
| 227 | (Base::GetAssembler()->*f)(&label1, is_bare); |
| 228 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 229 | |
| 230 | std::string expected = |
| 231 | ".set noreorder\n" + |
| 232 | instr_name + " 1f\n" + |
| 233 | (is_bare ? "" : "nop\n") + |
| 234 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 235 | "1:\n" + |
| 236 | instr_name + " 2f\n" + |
| 237 | (is_bare ? "" : "nop\n") + |
| 238 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 239 | "2:\n" + |
| 240 | instr_name + " 1b\n" + |
| 241 | (is_bare ? "" : "nop\n") + |
| 242 | "addu $zero, $zero, $zero\n"; |
| 243 | DriverStr(expected, instr_name); |
| 244 | } |
| 245 | |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 246 | void BranchCondOneRegHelper(void (mips::MipsAssembler::*f)(mips::Register, |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 247 | mips::MipsLabel*, |
| 248 | bool), |
| 249 | const std::string& instr_name, |
| 250 | bool is_bare = false) { |
| 251 | __ SetReorder(false); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 252 | mips::MipsLabel label; |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 253 | (Base::GetAssembler()->*f)(mips::A0, &label, is_bare); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 254 | constexpr size_t kAdduCount1 = 63; |
| 255 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 256 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 257 | } |
| 258 | __ Bind(&label); |
| 259 | constexpr size_t kAdduCount2 = 64; |
| 260 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 261 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 262 | } |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 263 | (Base::GetAssembler()->*f)(mips::A1, &label, is_bare); |
| 264 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 265 | |
| 266 | std::string expected = |
| 267 | ".set noreorder\n" + |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 268 | instr_name + " $a0, 1f\n" + |
| 269 | (is_bare ? "" : "nop\n") + |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 270 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 271 | "1:\n" + |
| 272 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 273 | instr_name + " $a1, 1b\n" + |
| 274 | (is_bare ? "" : "nop\n") + |
| 275 | "addu $zero, $zero, $zero\n"; |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 276 | DriverStr(expected, instr_name); |
| 277 | } |
| 278 | |
| 279 | void BranchCondTwoRegsHelper(void (mips::MipsAssembler::*f)(mips::Register, |
| 280 | mips::Register, |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 281 | mips::MipsLabel*, |
| 282 | bool), |
| 283 | const std::string& instr_name, |
| 284 | bool is_bare = false) { |
| 285 | __ SetReorder(false); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 286 | mips::MipsLabel label; |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 287 | (Base::GetAssembler()->*f)(mips::A0, mips::A1, &label, is_bare); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 288 | constexpr size_t kAdduCount1 = 63; |
| 289 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 290 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 291 | } |
| 292 | __ Bind(&label); |
| 293 | constexpr size_t kAdduCount2 = 64; |
| 294 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 295 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 296 | } |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 297 | (Base::GetAssembler()->*f)(mips::A2, mips::A3, &label, is_bare); |
| 298 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 299 | |
| 300 | std::string expected = |
| 301 | ".set noreorder\n" + |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 302 | instr_name + " $a0, $a1, 1f\n" + |
| 303 | (is_bare ? "" : "nop\n") + |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 304 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 305 | "1:\n" + |
| 306 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 307 | instr_name + " $a2, $a3, 1b\n" + |
| 308 | (is_bare ? "" : "nop\n") + |
| 309 | "addu $zero, $zero, $zero\n"; |
| 310 | DriverStr(expected, instr_name); |
| 311 | } |
| 312 | |
| 313 | void BranchFpuCondCodeHelper(void (mips::MipsAssembler::*f)(int, |
| 314 | mips::MipsLabel*, |
| 315 | bool), |
| 316 | const std::string& instr_name, |
| 317 | bool is_bare = false) { |
| 318 | __ SetReorder(false); |
| 319 | mips::MipsLabel label; |
| 320 | (Base::GetAssembler()->*f)(0, &label, is_bare); |
| 321 | constexpr size_t kAdduCount1 = 63; |
| 322 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 323 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 324 | } |
| 325 | __ Bind(&label); |
| 326 | constexpr size_t kAdduCount2 = 64; |
| 327 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 328 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 329 | } |
| 330 | (Base::GetAssembler()->*f)(7, &label, is_bare); |
| 331 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 332 | |
| 333 | std::string expected = |
| 334 | ".set noreorder\n" + |
| 335 | instr_name + " $fcc0, 1f\n" + |
| 336 | (is_bare ? "" : "nop\n") + |
| 337 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 338 | "1:\n" + |
| 339 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 340 | instr_name + " $fcc7, 1b\n" + |
| 341 | (is_bare ? "" : "nop\n") + |
| 342 | "addu $zero, $zero, $zero\n"; |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 343 | DriverStr(expected, instr_name); |
| 344 | } |
| 345 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 346 | private: |
| 347 | std::vector<mips::Register*> registers_; |
| 348 | std::map<mips::Register, std::string, MIPSCpuRegisterCompare> secondary_register_names_; |
| 349 | |
| 350 | std::vector<mips::FRegister*> fp_registers_; |
| 351 | }; |
| 352 | |
| 353 | |
| 354 | TEST_F(AssemblerMIPSTest, Toolchain) { |
| 355 | EXPECT_TRUE(CheckTools()); |
| 356 | } |
| 357 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 358 | TEST_F(AssemblerMIPSTest, Addu) { |
| 359 | DriverStr(RepeatRRR(&mips::MipsAssembler::Addu, "addu ${reg1}, ${reg2}, ${reg3}"), "Addu"); |
| 360 | } |
| 361 | |
| 362 | TEST_F(AssemblerMIPSTest, Addiu) { |
| 363 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Addiu, -16, "addiu ${reg1}, ${reg2}, {imm}"), "Addiu"); |
| 364 | } |
| 365 | |
| 366 | TEST_F(AssemblerMIPSTest, Subu) { |
| 367 | DriverStr(RepeatRRR(&mips::MipsAssembler::Subu, "subu ${reg1}, ${reg2}, ${reg3}"), "Subu"); |
| 368 | } |
| 369 | |
| 370 | TEST_F(AssemblerMIPSTest, MultR2) { |
| 371 | DriverStr(RepeatRR(&mips::MipsAssembler::MultR2, "mult ${reg1}, ${reg2}"), "MultR2"); |
| 372 | } |
| 373 | |
| 374 | TEST_F(AssemblerMIPSTest, MultuR2) { |
| 375 | DriverStr(RepeatRR(&mips::MipsAssembler::MultuR2, "multu ${reg1}, ${reg2}"), "MultuR2"); |
| 376 | } |
| 377 | |
| 378 | TEST_F(AssemblerMIPSTest, DivR2Basic) { |
| 379 | DriverStr(RepeatRR(&mips::MipsAssembler::DivR2, "div $zero, ${reg1}, ${reg2}"), "DivR2Basic"); |
| 380 | } |
| 381 | |
| 382 | TEST_F(AssemblerMIPSTest, DivuR2Basic) { |
| 383 | DriverStr(RepeatRR(&mips::MipsAssembler::DivuR2, "divu $zero, ${reg1}, ${reg2}"), "DivuR2Basic"); |
| 384 | } |
| 385 | |
| 386 | TEST_F(AssemblerMIPSTest, MulR2) { |
| 387 | DriverStr(RepeatRRR(&mips::MipsAssembler::MulR2, "mul ${reg1}, ${reg2}, ${reg3}"), "MulR2"); |
| 388 | } |
| 389 | |
| 390 | TEST_F(AssemblerMIPSTest, DivR2) { |
| 391 | DriverStr(RepeatRRR(&mips::MipsAssembler::DivR2, "div $zero, ${reg2}, ${reg3}\nmflo ${reg1}"), |
| 392 | "DivR2"); |
| 393 | } |
| 394 | |
| 395 | TEST_F(AssemblerMIPSTest, ModR2) { |
| 396 | DriverStr(RepeatRRR(&mips::MipsAssembler::ModR2, "div $zero, ${reg2}, ${reg3}\nmfhi ${reg1}"), |
| 397 | "ModR2"); |
| 398 | } |
| 399 | |
| 400 | TEST_F(AssemblerMIPSTest, DivuR2) { |
| 401 | DriverStr(RepeatRRR(&mips::MipsAssembler::DivuR2, "divu $zero, ${reg2}, ${reg3}\nmflo ${reg1}"), |
| 402 | "DivuR2"); |
| 403 | } |
| 404 | |
| 405 | TEST_F(AssemblerMIPSTest, ModuR2) { |
| 406 | DriverStr(RepeatRRR(&mips::MipsAssembler::ModuR2, "divu $zero, ${reg2}, ${reg3}\nmfhi ${reg1}"), |
| 407 | "ModuR2"); |
| 408 | } |
| 409 | |
| 410 | TEST_F(AssemblerMIPSTest, And) { |
| 411 | DriverStr(RepeatRRR(&mips::MipsAssembler::And, "and ${reg1}, ${reg2}, ${reg3}"), "And"); |
| 412 | } |
| 413 | |
| 414 | TEST_F(AssemblerMIPSTest, Andi) { |
| 415 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Andi, 16, "andi ${reg1}, ${reg2}, {imm}"), "Andi"); |
| 416 | } |
| 417 | |
| 418 | TEST_F(AssemblerMIPSTest, Or) { |
| 419 | DriverStr(RepeatRRR(&mips::MipsAssembler::Or, "or ${reg1}, ${reg2}, ${reg3}"), "Or"); |
| 420 | } |
| 421 | |
| 422 | TEST_F(AssemblerMIPSTest, Ori) { |
| 423 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Ori, 16, "ori ${reg1}, ${reg2}, {imm}"), "Ori"); |
| 424 | } |
| 425 | |
| 426 | TEST_F(AssemblerMIPSTest, Xor) { |
| 427 | DriverStr(RepeatRRR(&mips::MipsAssembler::Xor, "xor ${reg1}, ${reg2}, ${reg3}"), "Xor"); |
| 428 | } |
| 429 | |
| 430 | TEST_F(AssemblerMIPSTest, Xori) { |
| 431 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Xori, 16, "xori ${reg1}, ${reg2}, {imm}"), "Xori"); |
| 432 | } |
| 433 | |
| 434 | TEST_F(AssemblerMIPSTest, Nor) { |
| 435 | DriverStr(RepeatRRR(&mips::MipsAssembler::Nor, "nor ${reg1}, ${reg2}, ${reg3}"), "Nor"); |
| 436 | } |
| 437 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 438 | ////////// |
| 439 | // MISC // |
| 440 | ////////// |
| 441 | |
| 442 | TEST_F(AssemblerMIPSTest, Movz) { |
| 443 | DriverStr(RepeatRRR(&mips::MipsAssembler::Movz, "movz ${reg1}, ${reg2}, ${reg3}"), "Movz"); |
| 444 | } |
| 445 | |
| 446 | TEST_F(AssemblerMIPSTest, Movn) { |
| 447 | DriverStr(RepeatRRR(&mips::MipsAssembler::Movn, "movn ${reg1}, ${reg2}, ${reg3}"), "Movn"); |
| 448 | } |
| 449 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 450 | TEST_F(AssemblerMIPSTest, Seb) { |
| 451 | DriverStr(RepeatRR(&mips::MipsAssembler::Seb, "seb ${reg1}, ${reg2}"), "Seb"); |
| 452 | } |
| 453 | |
| 454 | TEST_F(AssemblerMIPSTest, Seh) { |
| 455 | DriverStr(RepeatRR(&mips::MipsAssembler::Seh, "seh ${reg1}, ${reg2}"), "Seh"); |
| 456 | } |
| 457 | |
| 458 | TEST_F(AssemblerMIPSTest, Sll) { |
| 459 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sll, 5, "sll ${reg1}, ${reg2}, {imm}"), "Sll"); |
| 460 | } |
| 461 | |
| 462 | TEST_F(AssemblerMIPSTest, Srl) { |
| 463 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Srl, 5, "srl ${reg1}, ${reg2}, {imm}"), "Srl"); |
| 464 | } |
| 465 | |
| 466 | TEST_F(AssemblerMIPSTest, Sra) { |
| 467 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sra, 5, "sra ${reg1}, ${reg2}, {imm}"), "Sra"); |
| 468 | } |
| 469 | |
| 470 | TEST_F(AssemblerMIPSTest, Sllv) { |
| 471 | DriverStr(RepeatRRR(&mips::MipsAssembler::Sllv, "sllv ${reg1}, ${reg2}, ${reg3}"), "Sllv"); |
| 472 | } |
| 473 | |
| 474 | TEST_F(AssemblerMIPSTest, Srlv) { |
| 475 | DriverStr(RepeatRRR(&mips::MipsAssembler::Srlv, "srlv ${reg1}, ${reg2}, ${reg3}"), "Srlv"); |
| 476 | } |
| 477 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 478 | TEST_F(AssemblerMIPSTest, Rotrv) { |
| 479 | DriverStr(RepeatRRR(&mips::MipsAssembler::Rotrv, "rotrv ${reg1}, ${reg2}, ${reg3}"), "rotrv"); |
| 480 | } |
| 481 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 482 | TEST_F(AssemblerMIPSTest, Srav) { |
| 483 | DriverStr(RepeatRRR(&mips::MipsAssembler::Srav, "srav ${reg1}, ${reg2}, ${reg3}"), "Srav"); |
| 484 | } |
| 485 | |
Alexey Frunze | 5c7aed3 | 2015-11-25 19:41:54 -0800 | [diff] [blame] | 486 | TEST_F(AssemblerMIPSTest, Ins) { |
| 487 | std::vector<mips::Register*> regs = GetRegisters(); |
| 488 | WarnOnCombinations(regs.size() * regs.size() * 33 * 16); |
| 489 | std::string expected; |
| 490 | for (mips::Register* reg1 : regs) { |
| 491 | for (mips::Register* reg2 : regs) { |
| 492 | for (int32_t pos = 0; pos < 32; pos++) { |
| 493 | for (int32_t size = 1; pos + size <= 32; size++) { |
| 494 | __ Ins(*reg1, *reg2, pos, size); |
| 495 | std::ostringstream instr; |
| 496 | instr << "ins $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n"; |
| 497 | expected += instr.str(); |
| 498 | } |
| 499 | } |
| 500 | } |
| 501 | } |
| 502 | DriverStr(expected, "Ins"); |
| 503 | } |
| 504 | |
| 505 | TEST_F(AssemblerMIPSTest, Ext) { |
| 506 | std::vector<mips::Register*> regs = GetRegisters(); |
| 507 | WarnOnCombinations(regs.size() * regs.size() * 33 * 16); |
| 508 | std::string expected; |
| 509 | for (mips::Register* reg1 : regs) { |
| 510 | for (mips::Register* reg2 : regs) { |
| 511 | for (int32_t pos = 0; pos < 32; pos++) { |
| 512 | for (int32_t size = 1; pos + size <= 32; size++) { |
| 513 | __ Ext(*reg1, *reg2, pos, size); |
| 514 | std::ostringstream instr; |
| 515 | instr << "ext $" << *reg1 << ", $" << *reg2 << ", " << pos << ", " << size << "\n"; |
| 516 | expected += instr.str(); |
| 517 | } |
| 518 | } |
| 519 | } |
| 520 | } |
| 521 | DriverStr(expected, "Ext"); |
| 522 | } |
| 523 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 524 | TEST_F(AssemblerMIPSTest, ClzR2) { |
| 525 | DriverStr(RepeatRR(&mips::MipsAssembler::ClzR2, "clz ${reg1}, ${reg2}"), "clzR2"); |
| 526 | } |
| 527 | |
| 528 | TEST_F(AssemblerMIPSTest, CloR2) { |
| 529 | DriverStr(RepeatRR(&mips::MipsAssembler::CloR2, "clo ${reg1}, ${reg2}"), "cloR2"); |
| 530 | } |
| 531 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 532 | TEST_F(AssemblerMIPSTest, Lb) { |
| 533 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lb, -16, "lb ${reg1}, {imm}(${reg2})"), "Lb"); |
| 534 | } |
| 535 | |
| 536 | TEST_F(AssemblerMIPSTest, Lh) { |
| 537 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lh, -16, "lh ${reg1}, {imm}(${reg2})"), "Lh"); |
| 538 | } |
| 539 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 540 | TEST_F(AssemblerMIPSTest, Lwl) { |
| 541 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lwl, -16, "lwl ${reg1}, {imm}(${reg2})"), "Lwl"); |
| 542 | } |
| 543 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 544 | TEST_F(AssemblerMIPSTest, Lw) { |
| 545 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lw, -16, "lw ${reg1}, {imm}(${reg2})"), "Lw"); |
| 546 | } |
| 547 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 548 | TEST_F(AssemblerMIPSTest, Lwr) { |
| 549 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lwr, -16, "lwr ${reg1}, {imm}(${reg2})"), "Lwr"); |
| 550 | } |
| 551 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 552 | TEST_F(AssemblerMIPSTest, Lbu) { |
| 553 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lbu, -16, "lbu ${reg1}, {imm}(${reg2})"), "Lbu"); |
| 554 | } |
| 555 | |
| 556 | TEST_F(AssemblerMIPSTest, Lhu) { |
| 557 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Lhu, -16, "lhu ${reg1}, {imm}(${reg2})"), "Lhu"); |
| 558 | } |
| 559 | |
| 560 | TEST_F(AssemblerMIPSTest, Lui) { |
| 561 | DriverStr(RepeatRIb(&mips::MipsAssembler::Lui, 16, "lui ${reg}, {imm}"), "Lui"); |
| 562 | } |
| 563 | |
| 564 | TEST_F(AssemblerMIPSTest, Mfhi) { |
| 565 | DriverStr(RepeatR(&mips::MipsAssembler::Mfhi, "mfhi ${reg}"), "Mfhi"); |
| 566 | } |
| 567 | |
| 568 | TEST_F(AssemblerMIPSTest, Mflo) { |
| 569 | DriverStr(RepeatR(&mips::MipsAssembler::Mflo, "mflo ${reg}"), "Mflo"); |
| 570 | } |
| 571 | |
| 572 | TEST_F(AssemblerMIPSTest, Sb) { |
| 573 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sb, -16, "sb ${reg1}, {imm}(${reg2})"), "Sb"); |
| 574 | } |
| 575 | |
| 576 | TEST_F(AssemblerMIPSTest, Sh) { |
| 577 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sh, -16, "sh ${reg1}, {imm}(${reg2})"), "Sh"); |
| 578 | } |
| 579 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 580 | TEST_F(AssemblerMIPSTest, Swl) { |
| 581 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Swl, -16, "swl ${reg1}, {imm}(${reg2})"), "Swl"); |
| 582 | } |
| 583 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 584 | TEST_F(AssemblerMIPSTest, Sw) { |
| 585 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sw, -16, "sw ${reg1}, {imm}(${reg2})"), "Sw"); |
| 586 | } |
| 587 | |
Chris Larsen | 3acee73 | 2015-11-18 13:31:08 -0800 | [diff] [blame] | 588 | TEST_F(AssemblerMIPSTest, Swr) { |
| 589 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Swr, -16, "swr ${reg1}, {imm}(${reg2})"), "Swr"); |
| 590 | } |
| 591 | |
Alexey Frunze | 51aff3a | 2016-03-17 17:21:45 -0700 | [diff] [blame] | 592 | TEST_F(AssemblerMIPSTest, LlR2) { |
| 593 | DriverStr(RepeatRRIb(&mips::MipsAssembler::LlR2, -16, "ll ${reg1}, {imm}(${reg2})"), "LlR2"); |
| 594 | } |
| 595 | |
| 596 | TEST_F(AssemblerMIPSTest, ScR2) { |
| 597 | DriverStr(RepeatRRIb(&mips::MipsAssembler::ScR2, -16, "sc ${reg1}, {imm}(${reg2})"), "ScR2"); |
| 598 | } |
| 599 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 600 | TEST_F(AssemblerMIPSTest, Slt) { |
| 601 | DriverStr(RepeatRRR(&mips::MipsAssembler::Slt, "slt ${reg1}, ${reg2}, ${reg3}"), "Slt"); |
| 602 | } |
| 603 | |
| 604 | TEST_F(AssemblerMIPSTest, Sltu) { |
| 605 | DriverStr(RepeatRRR(&mips::MipsAssembler::Sltu, "sltu ${reg1}, ${reg2}, ${reg3}"), "Sltu"); |
| 606 | } |
| 607 | |
| 608 | TEST_F(AssemblerMIPSTest, Slti) { |
| 609 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Slti, -16, "slti ${reg1}, ${reg2}, {imm}"), "Slti"); |
| 610 | } |
| 611 | |
| 612 | TEST_F(AssemblerMIPSTest, Sltiu) { |
| 613 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Sltiu, -16, "sltiu ${reg1}, ${reg2}, {imm}"), "Sltiu"); |
| 614 | } |
| 615 | |
| 616 | TEST_F(AssemblerMIPSTest, AddS) { |
| 617 | DriverStr(RepeatFFF(&mips::MipsAssembler::AddS, "add.s ${reg1}, ${reg2}, ${reg3}"), "AddS"); |
| 618 | } |
| 619 | |
| 620 | TEST_F(AssemblerMIPSTest, AddD) { |
| 621 | DriverStr(RepeatFFF(&mips::MipsAssembler::AddD, "add.d ${reg1}, ${reg2}, ${reg3}"), "AddD"); |
| 622 | } |
| 623 | |
| 624 | TEST_F(AssemblerMIPSTest, SubS) { |
| 625 | DriverStr(RepeatFFF(&mips::MipsAssembler::SubS, "sub.s ${reg1}, ${reg2}, ${reg3}"), "SubS"); |
| 626 | } |
| 627 | |
| 628 | TEST_F(AssemblerMIPSTest, SubD) { |
| 629 | DriverStr(RepeatFFF(&mips::MipsAssembler::SubD, "sub.d ${reg1}, ${reg2}, ${reg3}"), "SubD"); |
| 630 | } |
| 631 | |
| 632 | TEST_F(AssemblerMIPSTest, MulS) { |
| 633 | DriverStr(RepeatFFF(&mips::MipsAssembler::MulS, "mul.s ${reg1}, ${reg2}, ${reg3}"), "MulS"); |
| 634 | } |
| 635 | |
| 636 | TEST_F(AssemblerMIPSTest, MulD) { |
| 637 | DriverStr(RepeatFFF(&mips::MipsAssembler::MulD, "mul.d ${reg1}, ${reg2}, ${reg3}"), "MulD"); |
| 638 | } |
| 639 | |
| 640 | TEST_F(AssemblerMIPSTest, DivS) { |
| 641 | DriverStr(RepeatFFF(&mips::MipsAssembler::DivS, "div.s ${reg1}, ${reg2}, ${reg3}"), "DivS"); |
| 642 | } |
| 643 | |
| 644 | TEST_F(AssemblerMIPSTest, DivD) { |
| 645 | DriverStr(RepeatFFF(&mips::MipsAssembler::DivD, "div.d ${reg1}, ${reg2}, ${reg3}"), "DivD"); |
| 646 | } |
| 647 | |
| 648 | TEST_F(AssemblerMIPSTest, MovS) { |
| 649 | DriverStr(RepeatFF(&mips::MipsAssembler::MovS, "mov.s ${reg1}, ${reg2}"), "MovS"); |
| 650 | } |
| 651 | |
| 652 | TEST_F(AssemblerMIPSTest, MovD) { |
| 653 | DriverStr(RepeatFF(&mips::MipsAssembler::MovD, "mov.d ${reg1}, ${reg2}"), "MovD"); |
| 654 | } |
| 655 | |
| 656 | TEST_F(AssemblerMIPSTest, NegS) { |
| 657 | DriverStr(RepeatFF(&mips::MipsAssembler::NegS, "neg.s ${reg1}, ${reg2}"), "NegS"); |
| 658 | } |
| 659 | |
| 660 | TEST_F(AssemblerMIPSTest, NegD) { |
| 661 | DriverStr(RepeatFF(&mips::MipsAssembler::NegD, "neg.d ${reg1}, ${reg2}"), "NegD"); |
| 662 | } |
| 663 | |
Chris Larsen | f09d532 | 2016-04-22 12:06:34 -0700 | [diff] [blame] | 664 | TEST_F(AssemblerMIPSTest, FloorWS) { |
| 665 | DriverStr(RepeatFF(&mips::MipsAssembler::FloorWS, "floor.w.s ${reg1}, ${reg2}"), "floor.w.s"); |
| 666 | } |
| 667 | |
| 668 | TEST_F(AssemblerMIPSTest, FloorWD) { |
| 669 | DriverStr(RepeatFF(&mips::MipsAssembler::FloorWD, "floor.w.d ${reg1}, ${reg2}"), "floor.w.d"); |
| 670 | } |
| 671 | |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 672 | TEST_F(AssemblerMIPSTest, CunS) { |
| 673 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CunS, 3, "c.un.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 674 | "CunS"); |
| 675 | } |
| 676 | |
| 677 | TEST_F(AssemblerMIPSTest, CeqS) { |
| 678 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CeqS, 3, "c.eq.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 679 | "CeqS"); |
| 680 | } |
| 681 | |
| 682 | TEST_F(AssemblerMIPSTest, CueqS) { |
| 683 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CueqS, 3, "c.ueq.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 684 | "CueqS"); |
| 685 | } |
| 686 | |
| 687 | TEST_F(AssemblerMIPSTest, ColtS) { |
| 688 | DriverStr(RepeatIbFF(&mips::MipsAssembler::ColtS, 3, "c.olt.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 689 | "ColtS"); |
| 690 | } |
| 691 | |
| 692 | TEST_F(AssemblerMIPSTest, CultS) { |
| 693 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CultS, 3, "c.ult.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 694 | "CultS"); |
| 695 | } |
| 696 | |
| 697 | TEST_F(AssemblerMIPSTest, ColeS) { |
| 698 | DriverStr(RepeatIbFF(&mips::MipsAssembler::ColeS, 3, "c.ole.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 699 | "ColeS"); |
| 700 | } |
| 701 | |
| 702 | TEST_F(AssemblerMIPSTest, CuleS) { |
| 703 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CuleS, 3, "c.ule.s $fcc{imm}, ${reg1}, ${reg2}"), |
| 704 | "CuleS"); |
| 705 | } |
| 706 | |
| 707 | TEST_F(AssemblerMIPSTest, CunD) { |
| 708 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CunD, 3, "c.un.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 709 | "CunD"); |
| 710 | } |
| 711 | |
| 712 | TEST_F(AssemblerMIPSTest, CeqD) { |
| 713 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CeqD, 3, "c.eq.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 714 | "CeqD"); |
| 715 | } |
| 716 | |
| 717 | TEST_F(AssemblerMIPSTest, CueqD) { |
| 718 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CueqD, 3, "c.ueq.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 719 | "CueqD"); |
| 720 | } |
| 721 | |
| 722 | TEST_F(AssemblerMIPSTest, ColtD) { |
| 723 | DriverStr(RepeatIbFF(&mips::MipsAssembler::ColtD, 3, "c.olt.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 724 | "ColtD"); |
| 725 | } |
| 726 | |
| 727 | TEST_F(AssemblerMIPSTest, CultD) { |
| 728 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CultD, 3, "c.ult.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 729 | "CultD"); |
| 730 | } |
| 731 | |
| 732 | TEST_F(AssemblerMIPSTest, ColeD) { |
| 733 | DriverStr(RepeatIbFF(&mips::MipsAssembler::ColeD, 3, "c.ole.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 734 | "ColeD"); |
| 735 | } |
| 736 | |
| 737 | TEST_F(AssemblerMIPSTest, CuleD) { |
| 738 | DriverStr(RepeatIbFF(&mips::MipsAssembler::CuleD, 3, "c.ule.d $fcc{imm}, ${reg1}, ${reg2}"), |
| 739 | "CuleD"); |
| 740 | } |
| 741 | |
| 742 | TEST_F(AssemblerMIPSTest, Movf) { |
| 743 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Movf, 3, "movf ${reg1}, ${reg2}, $fcc{imm}"), "Movf"); |
| 744 | } |
| 745 | |
| 746 | TEST_F(AssemblerMIPSTest, Movt) { |
| 747 | DriverStr(RepeatRRIb(&mips::MipsAssembler::Movt, 3, "movt ${reg1}, ${reg2}, $fcc{imm}"), "Movt"); |
| 748 | } |
| 749 | |
Alexey Frunze | a8aaf5a | 2016-06-27 14:48:20 -0700 | [diff] [blame] | 750 | TEST_F(AssemblerMIPSTest, MovfS) { |
| 751 | DriverStr(RepeatFFIb(&mips::MipsAssembler::MovfS, 3, "movf.s ${reg1}, ${reg2}, $fcc{imm}"), |
| 752 | "MovfS"); |
| 753 | } |
| 754 | |
| 755 | TEST_F(AssemblerMIPSTest, MovfD) { |
| 756 | DriverStr(RepeatFFIb(&mips::MipsAssembler::MovfD, 3, "movf.d ${reg1}, ${reg2}, $fcc{imm}"), |
| 757 | "MovfD"); |
| 758 | } |
| 759 | |
| 760 | TEST_F(AssemblerMIPSTest, MovtS) { |
| 761 | DriverStr(RepeatFFIb(&mips::MipsAssembler::MovtS, 3, "movt.s ${reg1}, ${reg2}, $fcc{imm}"), |
| 762 | "MovtS"); |
| 763 | } |
| 764 | |
| 765 | TEST_F(AssemblerMIPSTest, MovtD) { |
| 766 | DriverStr(RepeatFFIb(&mips::MipsAssembler::MovtD, 3, "movt.d ${reg1}, ${reg2}, $fcc{imm}"), |
| 767 | "MovtD"); |
| 768 | } |
| 769 | |
Alexey Frunze | 674b9ee | 2016-09-20 14:54:15 -0700 | [diff] [blame] | 770 | TEST_F(AssemblerMIPSTest, MovzS) { |
| 771 | DriverStr(RepeatFFR(&mips::MipsAssembler::MovzS, "movz.s ${reg1}, ${reg2}, ${reg3}"), "MovzS"); |
| 772 | } |
| 773 | |
| 774 | TEST_F(AssemblerMIPSTest, MovzD) { |
| 775 | DriverStr(RepeatFFR(&mips::MipsAssembler::MovzD, "movz.d ${reg1}, ${reg2}, ${reg3}"), "MovzD"); |
| 776 | } |
| 777 | |
| 778 | TEST_F(AssemblerMIPSTest, MovnS) { |
| 779 | DriverStr(RepeatFFR(&mips::MipsAssembler::MovnS, "movn.s ${reg1}, ${reg2}, ${reg3}"), "MovnS"); |
| 780 | } |
| 781 | |
| 782 | TEST_F(AssemblerMIPSTest, MovnD) { |
| 783 | DriverStr(RepeatFFR(&mips::MipsAssembler::MovnD, "movn.d ${reg1}, ${reg2}, ${reg3}"), "MovnD"); |
| 784 | } |
| 785 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 786 | TEST_F(AssemblerMIPSTest, CvtSW) { |
| 787 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtsw, "cvt.s.w ${reg1}, ${reg2}"), "CvtSW"); |
| 788 | } |
| 789 | |
| 790 | TEST_F(AssemblerMIPSTest, CvtDW) { |
| 791 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtdw, "cvt.d.w ${reg1}, ${reg2}"), "CvtDW"); |
| 792 | } |
| 793 | |
Alexey Frunze | baf60b7 | 2015-12-22 15:15:03 -0800 | [diff] [blame] | 794 | TEST_F(AssemblerMIPSTest, CvtSL) { |
| 795 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtsl, "cvt.s.l ${reg1}, ${reg2}"), "CvtSL"); |
| 796 | } |
| 797 | |
| 798 | TEST_F(AssemblerMIPSTest, CvtDL) { |
| 799 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtdl, "cvt.d.l ${reg1}, ${reg2}"), "CvtDL"); |
| 800 | } |
| 801 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 802 | TEST_F(AssemblerMIPSTest, CvtSD) { |
| 803 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtsd, "cvt.s.d ${reg1}, ${reg2}"), "CvtSD"); |
| 804 | } |
| 805 | |
| 806 | TEST_F(AssemblerMIPSTest, CvtDS) { |
| 807 | DriverStr(RepeatFF(&mips::MipsAssembler::Cvtds, "cvt.d.s ${reg1}, ${reg2}"), "CvtDS"); |
| 808 | } |
| 809 | |
Alexey Frunze | baf60b7 | 2015-12-22 15:15:03 -0800 | [diff] [blame] | 810 | TEST_F(AssemblerMIPSTest, TruncWS) { |
| 811 | DriverStr(RepeatFF(&mips::MipsAssembler::TruncWS, "trunc.w.s ${reg1}, ${reg2}"), "TruncWS"); |
| 812 | } |
| 813 | |
| 814 | TEST_F(AssemblerMIPSTest, TruncWD) { |
| 815 | DriverStr(RepeatFF(&mips::MipsAssembler::TruncWD, "trunc.w.d ${reg1}, ${reg2}"), "TruncWD"); |
| 816 | } |
| 817 | |
| 818 | TEST_F(AssemblerMIPSTest, TruncLS) { |
| 819 | DriverStr(RepeatFF(&mips::MipsAssembler::TruncLS, "trunc.l.s ${reg1}, ${reg2}"), "TruncLS"); |
| 820 | } |
| 821 | |
| 822 | TEST_F(AssemblerMIPSTest, TruncLD) { |
| 823 | DriverStr(RepeatFF(&mips::MipsAssembler::TruncLD, "trunc.l.d ${reg1}, ${reg2}"), "TruncLD"); |
| 824 | } |
| 825 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 826 | TEST_F(AssemblerMIPSTest, Mfc1) { |
| 827 | DriverStr(RepeatRF(&mips::MipsAssembler::Mfc1, "mfc1 ${reg1}, ${reg2}"), "Mfc1"); |
| 828 | } |
| 829 | |
| 830 | TEST_F(AssemblerMIPSTest, Mtc1) { |
| 831 | DriverStr(RepeatRF(&mips::MipsAssembler::Mtc1, "mtc1 ${reg1}, ${reg2}"), "Mtc1"); |
| 832 | } |
| 833 | |
| 834 | TEST_F(AssemblerMIPSTest, Mfhc1) { |
| 835 | DriverStr(RepeatRF(&mips::MipsAssembler::Mfhc1, "mfhc1 ${reg1}, ${reg2}"), "Mfhc1"); |
| 836 | } |
| 837 | |
| 838 | TEST_F(AssemblerMIPSTest, Mthc1) { |
| 839 | DriverStr(RepeatRF(&mips::MipsAssembler::Mthc1, "mthc1 ${reg1}, ${reg2}"), "Mthc1"); |
| 840 | } |
| 841 | |
| 842 | TEST_F(AssemblerMIPSTest, Lwc1) { |
| 843 | DriverStr(RepeatFRIb(&mips::MipsAssembler::Lwc1, -16, "lwc1 ${reg1}, {imm}(${reg2})"), "Lwc1"); |
| 844 | } |
| 845 | |
| 846 | TEST_F(AssemblerMIPSTest, Ldc1) { |
| 847 | DriverStr(RepeatFRIb(&mips::MipsAssembler::Ldc1, -16, "ldc1 ${reg1}, {imm}(${reg2})"), "Ldc1"); |
| 848 | } |
| 849 | |
| 850 | TEST_F(AssemblerMIPSTest, Swc1) { |
| 851 | DriverStr(RepeatFRIb(&mips::MipsAssembler::Swc1, -16, "swc1 ${reg1}, {imm}(${reg2})"), "Swc1"); |
| 852 | } |
| 853 | |
| 854 | TEST_F(AssemblerMIPSTest, Sdc1) { |
| 855 | DriverStr(RepeatFRIb(&mips::MipsAssembler::Sdc1, -16, "sdc1 ${reg1}, {imm}(${reg2})"), "Sdc1"); |
| 856 | } |
| 857 | |
| 858 | TEST_F(AssemblerMIPSTest, Move) { |
| 859 | DriverStr(RepeatRR(&mips::MipsAssembler::Move, "or ${reg1}, ${reg2}, $zero"), "Move"); |
| 860 | } |
| 861 | |
| 862 | TEST_F(AssemblerMIPSTest, Clear) { |
| 863 | DriverStr(RepeatR(&mips::MipsAssembler::Clear, "or ${reg}, $zero, $zero"), "Clear"); |
| 864 | } |
| 865 | |
| 866 | TEST_F(AssemblerMIPSTest, Not) { |
| 867 | DriverStr(RepeatRR(&mips::MipsAssembler::Not, "nor ${reg1}, ${reg2}, $zero"), "Not"); |
| 868 | } |
| 869 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 870 | TEST_F(AssemblerMIPSTest, Addiu32) { |
| 871 | __ Addiu32(mips::A1, mips::A2, -0x8000); |
| 872 | __ Addiu32(mips::A1, mips::A2, +0); |
| 873 | __ Addiu32(mips::A1, mips::A2, +0x7FFF); |
| 874 | __ Addiu32(mips::A1, mips::A2, -0x10000); |
| 875 | __ Addiu32(mips::A1, mips::A2, -0x8001); |
| 876 | __ Addiu32(mips::A1, mips::A2, +0x8000); |
| 877 | __ Addiu32(mips::A1, mips::A2, +0xFFFE); |
| 878 | __ Addiu32(mips::A1, mips::A2, -0x10001); |
| 879 | __ Addiu32(mips::A1, mips::A2, +0xFFFF); |
| 880 | __ Addiu32(mips::A1, mips::A2, +0x10000); |
| 881 | __ Addiu32(mips::A1, mips::A2, +0x10001); |
| 882 | __ Addiu32(mips::A1, mips::A2, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 883 | |
| 884 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 885 | "addiu $a1, $a2, -0x8000\n" |
| 886 | "addiu $a1, $a2, 0\n" |
| 887 | "addiu $a1, $a2, 0x7FFF\n" |
| 888 | "addiu $at, $a2, -0x8000\n" |
| 889 | "addiu $a1, $at, -0x8000\n" |
| 890 | "addiu $at, $a2, -0x8000\n" |
| 891 | "addiu $a1, $at, -1\n" |
| 892 | "addiu $at, $a2, 0x7FFF\n" |
| 893 | "addiu $a1, $at, 1\n" |
| 894 | "addiu $at, $a2, 0x7FFF\n" |
| 895 | "addiu $a1, $at, 0x7FFF\n" |
| 896 | "lui $at, 0xFFFE\n" |
| 897 | "ori $at, $at, 0xFFFF\n" |
| 898 | "addu $a1, $a2, $at\n" |
| 899 | "ori $at, $zero, 0xFFFF\n" |
| 900 | "addu $a1, $a2, $at\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 901 | "lui $at, 1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 902 | "addu $a1, $a2, $at\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 903 | "lui $at, 1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 904 | "ori $at, $at, 1\n" |
| 905 | "addu $a1, $a2, $at\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 906 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 907 | "ori $at, $at, 0x5678\n" |
| 908 | "addu $a1, $a2, $at\n"; |
| 909 | DriverStr(expected, "Addiu32"); |
| 910 | } |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 911 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 912 | TEST_F(AssemblerMIPSTest, LoadFromOffset) { |
| 913 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x8000); |
| 914 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0); |
| 915 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x7FF8); |
| 916 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x7FFB); |
| 917 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x7FFC); |
| 918 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x7FFF); |
| 919 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0xFFF0); |
| 920 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x8008); |
| 921 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x8001); |
| 922 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x8000); |
| 923 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0xFFF0); |
| 924 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x17FE8); |
| 925 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x0FFF8); |
| 926 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x0FFF1); |
| 927 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x0FFF1); |
| 928 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x0FFF8); |
| 929 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x17FE8); |
| 930 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x17FF0); |
| 931 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, -0x17FE9); |
| 932 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x17FE9); |
| 933 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x17FF0); |
| 934 | __ LoadFromOffset(mips::kLoadSignedByte, mips::A3, mips::A1, +0x12345678); |
| 935 | |
| 936 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x8000); |
| 937 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0); |
| 938 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x7FF8); |
| 939 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x7FFB); |
| 940 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x7FFC); |
| 941 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x7FFF); |
| 942 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0xFFF0); |
| 943 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x8008); |
| 944 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x8001); |
| 945 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x8000); |
| 946 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0xFFF0); |
| 947 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x17FE8); |
| 948 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x0FFF8); |
| 949 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x0FFF1); |
| 950 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x0FFF1); |
| 951 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x0FFF8); |
| 952 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x17FE8); |
| 953 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x17FF0); |
| 954 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, -0x17FE9); |
| 955 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x17FE9); |
| 956 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x17FF0); |
| 957 | __ LoadFromOffset(mips::kLoadUnsignedByte, mips::A3, mips::A1, +0x12345678); |
| 958 | |
| 959 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x8000); |
| 960 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0); |
| 961 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x7FF8); |
| 962 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x7FFB); |
| 963 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x7FFC); |
| 964 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x7FFF); |
| 965 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0xFFF0); |
| 966 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x8008); |
| 967 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x8001); |
| 968 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x8000); |
| 969 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0xFFF0); |
| 970 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x17FE8); |
| 971 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x0FFF8); |
| 972 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x0FFF1); |
| 973 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x0FFF1); |
| 974 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x0FFF8); |
| 975 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x17FE8); |
| 976 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x17FF0); |
| 977 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, -0x17FE9); |
| 978 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x17FE9); |
| 979 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x17FF0); |
| 980 | __ LoadFromOffset(mips::kLoadSignedHalfword, mips::A3, mips::A1, +0x12345678); |
| 981 | |
| 982 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x8000); |
| 983 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0); |
| 984 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x7FF8); |
| 985 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x7FFB); |
| 986 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x7FFC); |
| 987 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x7FFF); |
| 988 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0xFFF0); |
| 989 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x8008); |
| 990 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x8001); |
| 991 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x8000); |
| 992 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0xFFF0); |
| 993 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x17FE8); |
| 994 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x0FFF8); |
| 995 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x0FFF1); |
| 996 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x0FFF1); |
| 997 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x0FFF8); |
| 998 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x17FE8); |
| 999 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x17FF0); |
| 1000 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, -0x17FE9); |
| 1001 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x17FE9); |
| 1002 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x17FF0); |
| 1003 | __ LoadFromOffset(mips::kLoadUnsignedHalfword, mips::A3, mips::A1, +0x12345678); |
| 1004 | |
| 1005 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x8000); |
| 1006 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0); |
| 1007 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x7FF8); |
| 1008 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x7FFB); |
| 1009 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x7FFC); |
| 1010 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x7FFF); |
| 1011 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0xFFF0); |
| 1012 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x8008); |
| 1013 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x8001); |
| 1014 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x8000); |
| 1015 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0xFFF0); |
| 1016 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x17FE8); |
| 1017 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x0FFF8); |
| 1018 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x0FFF1); |
| 1019 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x0FFF1); |
| 1020 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x0FFF8); |
| 1021 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x17FE8); |
| 1022 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x17FF0); |
| 1023 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, -0x17FE9); |
| 1024 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x17FE9); |
| 1025 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x17FF0); |
| 1026 | __ LoadFromOffset(mips::kLoadWord, mips::A3, mips::A1, +0x12345678); |
| 1027 | |
| 1028 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x8000); |
| 1029 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0); |
| 1030 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x7FF8); |
| 1031 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x7FFB); |
| 1032 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x7FFC); |
| 1033 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x7FFF); |
| 1034 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0xFFF0); |
| 1035 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x8008); |
| 1036 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x8001); |
| 1037 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x8000); |
| 1038 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0xFFF0); |
| 1039 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x17FE8); |
| 1040 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x0FFF8); |
| 1041 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x0FFF1); |
| 1042 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x0FFF1); |
| 1043 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x0FFF8); |
| 1044 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x17FE8); |
| 1045 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x17FF0); |
| 1046 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, -0x17FE9); |
| 1047 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x17FE9); |
| 1048 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x17FF0); |
| 1049 | __ LoadFromOffset(mips::kLoadDoubleword, mips::A0, mips::A2, +0x12345678); |
| 1050 | |
| 1051 | const char* expected = |
| 1052 | "lb $a3, -0x8000($a1)\n" |
| 1053 | "lb $a3, 0($a1)\n" |
| 1054 | "lb $a3, 0x7FF8($a1)\n" |
| 1055 | "lb $a3, 0x7FFB($a1)\n" |
| 1056 | "lb $a3, 0x7FFC($a1)\n" |
| 1057 | "lb $a3, 0x7FFF($a1)\n" |
| 1058 | "addiu $at, $a1, -0x7FF8\n" |
| 1059 | "lb $a3, -0x7FF8($at)\n" |
| 1060 | "addiu $at, $a1, -0x7FF8\n" |
| 1061 | "lb $a3, -0x10($at)\n" |
| 1062 | "addiu $at, $a1, -0x7FF8\n" |
| 1063 | "lb $a3, -9($at)\n" |
| 1064 | "addiu $at, $a1, 0x7FF8\n" |
| 1065 | "lb $a3, 8($at)\n" |
| 1066 | "addiu $at, $a1, 0x7FF8\n" |
| 1067 | "lb $a3, 0x7FF8($at)\n" |
| 1068 | "addiu $at, $a1, -0x7FF8\n" |
| 1069 | "addiu $at, $at, -0x7FF8\n" |
| 1070 | "lb $a3, -0x7FF8($at)\n" |
| 1071 | "addiu $at, $a1, -0x7FF8\n" |
| 1072 | "addiu $at, $at, -0x7FF8\n" |
| 1073 | "lb $a3, -8($at)\n" |
| 1074 | "addiu $at, $a1, -0x7FF8\n" |
| 1075 | "addiu $at, $at, -0x7FF8\n" |
| 1076 | "lb $a3, -1($at)\n" |
| 1077 | "addiu $at, $a1, 0x7FF8\n" |
| 1078 | "addiu $at, $at, 0x7FF8\n" |
| 1079 | "lb $a3, 1($at)\n" |
| 1080 | "addiu $at, $a1, 0x7FF8\n" |
| 1081 | "addiu $at, $at, 0x7FF8\n" |
| 1082 | "lb $a3, 8($at)\n" |
| 1083 | "addiu $at, $a1, 0x7FF8\n" |
| 1084 | "addiu $at, $at, 0x7FF8\n" |
| 1085 | "lb $a3, 0x7FF8($at)\n" |
| 1086 | "lui $at, 0xFFFE\n" |
| 1087 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1088 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1089 | "lb $a3, 0($at)\n" |
| 1090 | "lui $at, 0xFFFE\n" |
| 1091 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1092 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1093 | "lb $a3, 7($at)\n" |
| 1094 | "lui $at, 0x1\n" |
| 1095 | "ori $at, $at, 0x7FE8\n" |
| 1096 | "addu $at, $at, $a1\n" |
| 1097 | "lb $a3, 1($at)\n" |
| 1098 | "lui $at, 0x1\n" |
| 1099 | "ori $at, $at, 0x7FF0\n" |
| 1100 | "addu $at, $at, $a1\n" |
| 1101 | "lb $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1102 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1103 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1104 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1105 | "lb $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1106 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1107 | "lbu $a3, -0x8000($a1)\n" |
| 1108 | "lbu $a3, 0($a1)\n" |
| 1109 | "lbu $a3, 0x7FF8($a1)\n" |
| 1110 | "lbu $a3, 0x7FFB($a1)\n" |
| 1111 | "lbu $a3, 0x7FFC($a1)\n" |
| 1112 | "lbu $a3, 0x7FFF($a1)\n" |
| 1113 | "addiu $at, $a1, -0x7FF8\n" |
| 1114 | "lbu $a3, -0x7FF8($at)\n" |
| 1115 | "addiu $at, $a1, -0x7FF8\n" |
| 1116 | "lbu $a3, -0x10($at)\n" |
| 1117 | "addiu $at, $a1, -0x7FF8\n" |
| 1118 | "lbu $a3, -9($at)\n" |
| 1119 | "addiu $at, $a1, 0x7FF8\n" |
| 1120 | "lbu $a3, 8($at)\n" |
| 1121 | "addiu $at, $a1, 0x7FF8\n" |
| 1122 | "lbu $a3, 0x7FF8($at)\n" |
| 1123 | "addiu $at, $a1, -0x7FF8\n" |
| 1124 | "addiu $at, $at, -0x7FF8\n" |
| 1125 | "lbu $a3, -0x7FF8($at)\n" |
| 1126 | "addiu $at, $a1, -0x7FF8\n" |
| 1127 | "addiu $at, $at, -0x7FF8\n" |
| 1128 | "lbu $a3, -8($at)\n" |
| 1129 | "addiu $at, $a1, -0x7FF8\n" |
| 1130 | "addiu $at, $at, -0x7FF8\n" |
| 1131 | "lbu $a3, -1($at)\n" |
| 1132 | "addiu $at, $a1, 0x7FF8\n" |
| 1133 | "addiu $at, $at, 0x7FF8\n" |
| 1134 | "lbu $a3, 1($at)\n" |
| 1135 | "addiu $at, $a1, 0x7FF8\n" |
| 1136 | "addiu $at, $at, 0x7FF8\n" |
| 1137 | "lbu $a3, 8($at)\n" |
| 1138 | "addiu $at, $a1, 0x7FF8\n" |
| 1139 | "addiu $at, $at, 0x7FF8\n" |
| 1140 | "lbu $a3, 0x7FF8($at)\n" |
| 1141 | "lui $at, 0xFFFE\n" |
| 1142 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1143 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1144 | "lbu $a3, 0($at)\n" |
| 1145 | "lui $at, 0xFFFE\n" |
| 1146 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1147 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1148 | "lbu $a3, 7($at)\n" |
| 1149 | "lui $at, 0x1\n" |
| 1150 | "ori $at, $at, 0x7FE8\n" |
| 1151 | "addu $at, $at, $a1\n" |
| 1152 | "lbu $a3, 1($at)\n" |
| 1153 | "lui $at, 0x1\n" |
| 1154 | "ori $at, $at, 0x7FF0\n" |
| 1155 | "addu $at, $at, $a1\n" |
| 1156 | "lbu $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1157 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1158 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1159 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1160 | "lbu $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1161 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1162 | "lh $a3, -0x8000($a1)\n" |
| 1163 | "lh $a3, 0($a1)\n" |
| 1164 | "lh $a3, 0x7FF8($a1)\n" |
| 1165 | "lh $a3, 0x7FFB($a1)\n" |
| 1166 | "lh $a3, 0x7FFC($a1)\n" |
| 1167 | "lh $a3, 0x7FFF($a1)\n" |
| 1168 | "addiu $at, $a1, -0x7FF8\n" |
| 1169 | "lh $a3, -0x7FF8($at)\n" |
| 1170 | "addiu $at, $a1, -0x7FF8\n" |
| 1171 | "lh $a3, -0x10($at)\n" |
| 1172 | "addiu $at, $a1, -0x7FF8\n" |
| 1173 | "lh $a3, -9($at)\n" |
| 1174 | "addiu $at, $a1, 0x7FF8\n" |
| 1175 | "lh $a3, 8($at)\n" |
| 1176 | "addiu $at, $a1, 0x7FF8\n" |
| 1177 | "lh $a3, 0x7FF8($at)\n" |
| 1178 | "addiu $at, $a1, -0x7FF8\n" |
| 1179 | "addiu $at, $at, -0x7FF8\n" |
| 1180 | "lh $a3, -0x7FF8($at)\n" |
| 1181 | "addiu $at, $a1, -0x7FF8\n" |
| 1182 | "addiu $at, $at, -0x7FF8\n" |
| 1183 | "lh $a3, -8($at)\n" |
| 1184 | "addiu $at, $a1, -0x7FF8\n" |
| 1185 | "addiu $at, $at, -0x7FF8\n" |
| 1186 | "lh $a3, -1($at)\n" |
| 1187 | "addiu $at, $a1, 0x7FF8\n" |
| 1188 | "addiu $at, $at, 0x7FF8\n" |
| 1189 | "lh $a3, 1($at)\n" |
| 1190 | "addiu $at, $a1, 0x7FF8\n" |
| 1191 | "addiu $at, $at, 0x7FF8\n" |
| 1192 | "lh $a3, 8($at)\n" |
| 1193 | "addiu $at, $a1, 0x7FF8\n" |
| 1194 | "addiu $at, $at, 0x7FF8\n" |
| 1195 | "lh $a3, 0x7FF8($at)\n" |
| 1196 | "lui $at, 0xFFFE\n" |
| 1197 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1198 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1199 | "lh $a3, 0($at)\n" |
| 1200 | "lui $at, 0xFFFE\n" |
| 1201 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1202 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1203 | "lh $a3, 7($at)\n" |
| 1204 | "lui $at, 0x1\n" |
| 1205 | "ori $at, $at, 0x7FE8\n" |
| 1206 | "addu $at, $at, $a1\n" |
| 1207 | "lh $a3, 1($at)\n" |
| 1208 | "lui $at, 0x1\n" |
| 1209 | "ori $at, $at, 0x7FF0\n" |
| 1210 | "addu $at, $at, $a1\n" |
| 1211 | "lh $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1212 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1213 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1214 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1215 | "lh $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1216 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1217 | "lhu $a3, -0x8000($a1)\n" |
| 1218 | "lhu $a3, 0($a1)\n" |
| 1219 | "lhu $a3, 0x7FF8($a1)\n" |
| 1220 | "lhu $a3, 0x7FFB($a1)\n" |
| 1221 | "lhu $a3, 0x7FFC($a1)\n" |
| 1222 | "lhu $a3, 0x7FFF($a1)\n" |
| 1223 | "addiu $at, $a1, -0x7FF8\n" |
| 1224 | "lhu $a3, -0x7FF8($at)\n" |
| 1225 | "addiu $at, $a1, -0x7FF8\n" |
| 1226 | "lhu $a3, -0x10($at)\n" |
| 1227 | "addiu $at, $a1, -0x7FF8\n" |
| 1228 | "lhu $a3, -9($at)\n" |
| 1229 | "addiu $at, $a1, 0x7FF8\n" |
| 1230 | "lhu $a3, 8($at)\n" |
| 1231 | "addiu $at, $a1, 0x7FF8\n" |
| 1232 | "lhu $a3, 0x7FF8($at)\n" |
| 1233 | "addiu $at, $a1, -0x7FF8\n" |
| 1234 | "addiu $at, $at, -0x7FF8\n" |
| 1235 | "lhu $a3, -0x7FF8($at)\n" |
| 1236 | "addiu $at, $a1, -0x7FF8\n" |
| 1237 | "addiu $at, $at, -0x7FF8\n" |
| 1238 | "lhu $a3, -8($at)\n" |
| 1239 | "addiu $at, $a1, -0x7FF8\n" |
| 1240 | "addiu $at, $at, -0x7FF8\n" |
| 1241 | "lhu $a3, -1($at)\n" |
| 1242 | "addiu $at, $a1, 0x7FF8\n" |
| 1243 | "addiu $at, $at, 0x7FF8\n" |
| 1244 | "lhu $a3, 1($at)\n" |
| 1245 | "addiu $at, $a1, 0x7FF8\n" |
| 1246 | "addiu $at, $at, 0x7FF8\n" |
| 1247 | "lhu $a3, 8($at)\n" |
| 1248 | "addiu $at, $a1, 0x7FF8\n" |
| 1249 | "addiu $at, $at, 0x7FF8\n" |
| 1250 | "lhu $a3, 0x7FF8($at)\n" |
| 1251 | "lui $at, 0xFFFE\n" |
| 1252 | "ori $at, $at, 0x8010\n" |
| 1253 | "addu $at, $at, $a1\n" |
| 1254 | "lhu $a3, 0($at)\n" |
| 1255 | "lui $at, 0xFFFE\n" |
| 1256 | "ori $at, $at, 0x8010\n" |
| 1257 | "addu $at, $at, $a1\n" |
| 1258 | "lhu $a3, 7($at)\n" |
| 1259 | "lui $at, 0x1\n" |
| 1260 | "ori $at, $at, 0x7FE8\n" |
| 1261 | "addu $at, $at, $a1\n" |
| 1262 | "lhu $a3, 1($at)\n" |
| 1263 | "lui $at, 0x1\n" |
| 1264 | "ori $at, $at, 0x7FF0\n" |
| 1265 | "addu $at, $at, $a1\n" |
| 1266 | "lhu $a3, 0($at)\n" |
| 1267 | "lui $at, 0x1234\n" |
| 1268 | "ori $at, $at, 0x5678\n" |
| 1269 | "addu $at, $at, $a1\n" |
| 1270 | "lhu $a3, 0($at)\n" |
| 1271 | |
| 1272 | "lw $a3, -0x8000($a1)\n" |
| 1273 | "lw $a3, 0($a1)\n" |
| 1274 | "lw $a3, 0x7FF8($a1)\n" |
| 1275 | "lw $a3, 0x7FFB($a1)\n" |
| 1276 | "lw $a3, 0x7FFC($a1)\n" |
| 1277 | "lw $a3, 0x7FFF($a1)\n" |
| 1278 | "addiu $at, $a1, -0x7FF8\n" |
| 1279 | "lw $a3, -0x7FF8($at)\n" |
| 1280 | "addiu $at, $a1, -0x7FF8\n" |
| 1281 | "lw $a3, -0x10($at)\n" |
| 1282 | "addiu $at, $a1, -0x7FF8\n" |
| 1283 | "lw $a3, -9($at)\n" |
| 1284 | "addiu $at, $a1, 0x7FF8\n" |
| 1285 | "lw $a3, 8($at)\n" |
| 1286 | "addiu $at, $a1, 0x7FF8\n" |
| 1287 | "lw $a3, 0x7FF8($at)\n" |
| 1288 | "addiu $at, $a1, -0x7FF8\n" |
| 1289 | "addiu $at, $at, -0x7FF8\n" |
| 1290 | "lw $a3, -0x7FF8($at)\n" |
| 1291 | "addiu $at, $a1, -0x7FF8\n" |
| 1292 | "addiu $at, $at, -0x7FF8\n" |
| 1293 | "lw $a3, -8($at)\n" |
| 1294 | "addiu $at, $a1, -0x7FF8\n" |
| 1295 | "addiu $at, $at, -0x7FF8\n" |
| 1296 | "lw $a3, -1($at)\n" |
| 1297 | "addiu $at, $a1, 0x7FF8\n" |
| 1298 | "addiu $at, $at, 0x7FF8\n" |
| 1299 | "lw $a3, 1($at)\n" |
| 1300 | "addiu $at, $a1, 0x7FF8\n" |
| 1301 | "addiu $at, $at, 0x7FF8\n" |
| 1302 | "lw $a3, 8($at)\n" |
| 1303 | "addiu $at, $a1, 0x7FF8\n" |
| 1304 | "addiu $at, $at, 0x7FF8\n" |
| 1305 | "lw $a3, 0x7FF8($at)\n" |
| 1306 | "lui $at, 0xFFFE\n" |
| 1307 | "ori $at, $at, 0x8010\n" |
| 1308 | "addu $at, $at, $a1\n" |
| 1309 | "lw $a3, 0($at)\n" |
| 1310 | "lui $at, 0xFFFE\n" |
| 1311 | "ori $at, $at, 0x8010\n" |
| 1312 | "addu $at, $at, $a1\n" |
| 1313 | "lw $a3, 7($at)\n" |
| 1314 | "lui $at, 0x1\n" |
| 1315 | "ori $at, $at, 0x7FE8\n" |
| 1316 | "addu $at, $at, $a1\n" |
| 1317 | "lw $a3, 1($at)\n" |
| 1318 | "lui $at, 0x1\n" |
| 1319 | "ori $at, $at, 0x7FF0\n" |
| 1320 | "addu $at, $at, $a1\n" |
| 1321 | "lw $a3, 0($at)\n" |
| 1322 | "lui $at, 0x1234\n" |
| 1323 | "ori $at, $at, 0x5678\n" |
| 1324 | "addu $at, $at, $a1\n" |
| 1325 | "lw $a3, 0($at)\n" |
| 1326 | |
| 1327 | "lw $a0, -0x8000($a2)\n" |
| 1328 | "lw $a1, -0x7FFC($a2)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1329 | "lw $a0, 0($a2)\n" |
| 1330 | "lw $a1, 4($a2)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1331 | "lw $a0, 0x7FF8($a2)\n" |
| 1332 | "lw $a1, 0x7FFC($a2)\n" |
| 1333 | "lw $a0, 0x7FFB($a2)\n" |
| 1334 | "lw $a1, 0x7FFF($a2)\n" |
| 1335 | "addiu $at, $a2, 0x7FF8\n" |
| 1336 | "lw $a0, 4($at)\n" |
| 1337 | "lw $a1, 8($at)\n" |
| 1338 | "addiu $at, $a2, 0x7FF8\n" |
| 1339 | "lw $a0, 7($at)\n" |
| 1340 | "lw $a1, 11($at)\n" |
| 1341 | "addiu $at, $a2, -0x7FF8\n" |
| 1342 | "lw $a0, -0x7FF8($at)\n" |
| 1343 | "lw $a1, -0x7FF4($at)\n" |
| 1344 | "addiu $at, $a2, -0x7FF8\n" |
| 1345 | "lw $a0, -0x10($at)\n" |
| 1346 | "lw $a1, -0xC($at)\n" |
| 1347 | "addiu $at, $a2, -0x7FF8\n" |
| 1348 | "lw $a0, -9($at)\n" |
| 1349 | "lw $a1, -5($at)\n" |
| 1350 | "addiu $at, $a2, 0x7FF8\n" |
| 1351 | "lw $a0, 8($at)\n" |
| 1352 | "lw $a1, 12($at)\n" |
| 1353 | "addiu $at, $a2, 0x7FF8\n" |
| 1354 | "lw $a0, 0x7FF8($at)\n" |
| 1355 | "lw $a1, 0x7FFC($at)\n" |
| 1356 | "addiu $at, $a2, -0x7FF8\n" |
| 1357 | "addiu $at, $at, -0x7FF8\n" |
| 1358 | "lw $a0, -0x7FF8($at)\n" |
| 1359 | "lw $a1, -0x7FF4($at)\n" |
| 1360 | "addiu $at, $a2, -0x7FF8\n" |
| 1361 | "addiu $at, $at, -0x7FF8\n" |
| 1362 | "lw $a0, -8($at)\n" |
| 1363 | "lw $a1, -4($at)\n" |
| 1364 | "addiu $at, $a2, -0x7FF8\n" |
| 1365 | "addiu $at, $at, -0x7FF8\n" |
| 1366 | "lw $a0, -1($at)\n" |
| 1367 | "lw $a1, 3($at)\n" |
| 1368 | "addiu $at, $a2, 0x7FF8\n" |
| 1369 | "addiu $at, $at, 0x7FF8\n" |
| 1370 | "lw $a0, 1($at)\n" |
| 1371 | "lw $a1, 5($at)\n" |
| 1372 | "addiu $at, $a2, 0x7FF8\n" |
| 1373 | "addiu $at, $at, 0x7FF8\n" |
| 1374 | "lw $a0, 8($at)\n" |
| 1375 | "lw $a1, 12($at)\n" |
| 1376 | "addiu $at, $a2, 0x7FF8\n" |
| 1377 | "addiu $at, $at, 0x7FF8\n" |
| 1378 | "lw $a0, 0x7FF8($at)\n" |
| 1379 | "lw $a1, 0x7FFC($at)\n" |
| 1380 | "lui $at, 0xFFFE\n" |
| 1381 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1382 | "addu $at, $at, $a2\n" |
| 1383 | "lw $a0, 0($at)\n" |
| 1384 | "lw $a1, 4($at)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1385 | "lui $at, 0xFFFE\n" |
| 1386 | "ori $at, $at, 0x8010\n" |
| 1387 | "addu $at, $at, $a2\n" |
| 1388 | "lw $a0, 7($at)\n" |
| 1389 | "lw $a1, 11($at)\n" |
| 1390 | "lui $at, 0x1\n" |
| 1391 | "ori $at, $at, 0x7FE8\n" |
| 1392 | "addu $at, $at, $a2\n" |
| 1393 | "lw $a0, 1($at)\n" |
| 1394 | "lw $a1, 5($at)\n" |
| 1395 | "lui $at, 0x1\n" |
| 1396 | "ori $at, $at, 0x7FF0\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1397 | "addu $at, $at, $a2\n" |
| 1398 | "lw $a0, 0($at)\n" |
| 1399 | "lw $a1, 4($at)\n" |
| 1400 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1401 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1402 | "addu $at, $at, $a2\n" |
| 1403 | "lw $a0, 0($at)\n" |
| 1404 | "lw $a1, 4($at)\n"; |
| 1405 | DriverStr(expected, "LoadFromOffset"); |
| 1406 | } |
| 1407 | |
| 1408 | TEST_F(AssemblerMIPSTest, LoadSFromOffset) { |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1409 | __ LoadSFromOffset(mips::F2, mips::A0, -0x8000); |
| 1410 | __ LoadSFromOffset(mips::F2, mips::A0, +0); |
| 1411 | __ LoadSFromOffset(mips::F2, mips::A0, +0x7FF8); |
| 1412 | __ LoadSFromOffset(mips::F2, mips::A0, +0x7FFB); |
| 1413 | __ LoadSFromOffset(mips::F2, mips::A0, +0x7FFC); |
| 1414 | __ LoadSFromOffset(mips::F2, mips::A0, +0x7FFF); |
| 1415 | __ LoadSFromOffset(mips::F2, mips::A0, -0xFFF0); |
| 1416 | __ LoadSFromOffset(mips::F2, mips::A0, -0x8008); |
| 1417 | __ LoadSFromOffset(mips::F2, mips::A0, -0x8001); |
| 1418 | __ LoadSFromOffset(mips::F2, mips::A0, +0x8000); |
| 1419 | __ LoadSFromOffset(mips::F2, mips::A0, +0xFFF0); |
| 1420 | __ LoadSFromOffset(mips::F2, mips::A0, -0x17FE8); |
| 1421 | __ LoadSFromOffset(mips::F2, mips::A0, -0x0FFF8); |
| 1422 | __ LoadSFromOffset(mips::F2, mips::A0, -0x0FFF1); |
| 1423 | __ LoadSFromOffset(mips::F2, mips::A0, +0x0FFF1); |
| 1424 | __ LoadSFromOffset(mips::F2, mips::A0, +0x0FFF8); |
| 1425 | __ LoadSFromOffset(mips::F2, mips::A0, +0x17FE8); |
| 1426 | __ LoadSFromOffset(mips::F2, mips::A0, -0x17FF0); |
| 1427 | __ LoadSFromOffset(mips::F2, mips::A0, -0x17FE9); |
| 1428 | __ LoadSFromOffset(mips::F2, mips::A0, +0x17FE9); |
| 1429 | __ LoadSFromOffset(mips::F2, mips::A0, +0x17FF0); |
| 1430 | __ LoadSFromOffset(mips::F2, mips::A0, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1431 | |
| 1432 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1433 | "lwc1 $f2, -0x8000($a0)\n" |
| 1434 | "lwc1 $f2, 0($a0)\n" |
| 1435 | "lwc1 $f2, 0x7FF8($a0)\n" |
| 1436 | "lwc1 $f2, 0x7FFB($a0)\n" |
| 1437 | "lwc1 $f2, 0x7FFC($a0)\n" |
| 1438 | "lwc1 $f2, 0x7FFF($a0)\n" |
| 1439 | "addiu $at, $a0, -0x7FF8\n" |
| 1440 | "lwc1 $f2, -0x7FF8($at)\n" |
| 1441 | "addiu $at, $a0, -0x7FF8\n" |
| 1442 | "lwc1 $f2, -0x10($at)\n" |
| 1443 | "addiu $at, $a0, -0x7FF8\n" |
| 1444 | "lwc1 $f2, -9($at)\n" |
| 1445 | "addiu $at, $a0, 0x7FF8\n" |
| 1446 | "lwc1 $f2, 8($at)\n" |
| 1447 | "addiu $at, $a0, 0x7FF8\n" |
| 1448 | "lwc1 $f2, 0x7FF8($at)\n" |
| 1449 | "addiu $at, $a0, -0x7FF8\n" |
| 1450 | "addiu $at, $at, -0x7FF8\n" |
| 1451 | "lwc1 $f2, -0x7FF8($at)\n" |
| 1452 | "addiu $at, $a0, -0x7FF8\n" |
| 1453 | "addiu $at, $at, -0x7FF8\n" |
| 1454 | "lwc1 $f2, -8($at)\n" |
| 1455 | "addiu $at, $a0, -0x7FF8\n" |
| 1456 | "addiu $at, $at, -0x7FF8\n" |
| 1457 | "lwc1 $f2, -1($at)\n" |
| 1458 | "addiu $at, $a0, 0x7FF8\n" |
| 1459 | "addiu $at, $at, 0x7FF8\n" |
| 1460 | "lwc1 $f2, 1($at)\n" |
| 1461 | "addiu $at, $a0, 0x7FF8\n" |
| 1462 | "addiu $at, $at, 0x7FF8\n" |
| 1463 | "lwc1 $f2, 8($at)\n" |
| 1464 | "addiu $at, $a0, 0x7FF8\n" |
| 1465 | "addiu $at, $at, 0x7FF8\n" |
| 1466 | "lwc1 $f2, 0x7FF8($at)\n" |
| 1467 | "lui $at, 0xFFFE\n" |
| 1468 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1469 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1470 | "lwc1 $f2, 0($at)\n" |
| 1471 | "lui $at, 0xFFFE\n" |
| 1472 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1473 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1474 | "lwc1 $f2, 7($at)\n" |
| 1475 | "lui $at, 0x1\n" |
| 1476 | "ori $at, $at, 0x7FE8\n" |
| 1477 | "addu $at, $at, $a0\n" |
| 1478 | "lwc1 $f2, 1($at)\n" |
| 1479 | "lui $at, 0x1\n" |
| 1480 | "ori $at, $at, 0x7FF0\n" |
| 1481 | "addu $at, $at, $a0\n" |
| 1482 | "lwc1 $f2, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1483 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1484 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1485 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1486 | "lwc1 $f2, 0($at)\n"; |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1487 | DriverStr(expected, "LoadSFromOffset"); |
| 1488 | } |
| 1489 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1490 | TEST_F(AssemblerMIPSTest, LoadDFromOffset) { |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1491 | __ LoadDFromOffset(mips::F0, mips::A0, -0x8000); |
| 1492 | __ LoadDFromOffset(mips::F0, mips::A0, +0); |
| 1493 | __ LoadDFromOffset(mips::F0, mips::A0, +0x7FF8); |
| 1494 | __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFB); |
| 1495 | __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFC); |
| 1496 | __ LoadDFromOffset(mips::F0, mips::A0, +0x7FFF); |
| 1497 | __ LoadDFromOffset(mips::F0, mips::A0, -0xFFF0); |
| 1498 | __ LoadDFromOffset(mips::F0, mips::A0, -0x8008); |
| 1499 | __ LoadDFromOffset(mips::F0, mips::A0, -0x8001); |
| 1500 | __ LoadDFromOffset(mips::F0, mips::A0, +0x8000); |
| 1501 | __ LoadDFromOffset(mips::F0, mips::A0, +0xFFF0); |
| 1502 | __ LoadDFromOffset(mips::F0, mips::A0, -0x17FE8); |
| 1503 | __ LoadDFromOffset(mips::F0, mips::A0, -0x0FFF8); |
| 1504 | __ LoadDFromOffset(mips::F0, mips::A0, -0x0FFF1); |
| 1505 | __ LoadDFromOffset(mips::F0, mips::A0, +0x0FFF1); |
| 1506 | __ LoadDFromOffset(mips::F0, mips::A0, +0x0FFF8); |
| 1507 | __ LoadDFromOffset(mips::F0, mips::A0, +0x17FE8); |
| 1508 | __ LoadDFromOffset(mips::F0, mips::A0, -0x17FF0); |
| 1509 | __ LoadDFromOffset(mips::F0, mips::A0, -0x17FE9); |
| 1510 | __ LoadDFromOffset(mips::F0, mips::A0, +0x17FE9); |
| 1511 | __ LoadDFromOffset(mips::F0, mips::A0, +0x17FF0); |
| 1512 | __ LoadDFromOffset(mips::F0, mips::A0, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1513 | |
| 1514 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1515 | "ldc1 $f0, -0x8000($a0)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1516 | "ldc1 $f0, 0($a0)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1517 | "ldc1 $f0, 0x7FF8($a0)\n" |
| 1518 | "lwc1 $f0, 0x7FFB($a0)\n" |
| 1519 | "lwc1 $f1, 0x7FFF($a0)\n" |
| 1520 | "addiu $at, $a0, 0x7FF8\n" |
| 1521 | "lwc1 $f0, 4($at)\n" |
| 1522 | "lwc1 $f1, 8($at)\n" |
| 1523 | "addiu $at, $a0, 0x7FF8\n" |
| 1524 | "lwc1 $f0, 7($at)\n" |
| 1525 | "lwc1 $f1, 11($at)\n" |
| 1526 | "addiu $at, $a0, -0x7FF8\n" |
| 1527 | "ldc1 $f0, -0x7FF8($at)\n" |
| 1528 | "addiu $at, $a0, -0x7FF8\n" |
| 1529 | "ldc1 $f0, -0x10($at)\n" |
| 1530 | "addiu $at, $a0, -0x7FF8\n" |
| 1531 | "lwc1 $f0, -9($at)\n" |
| 1532 | "lwc1 $f1, -5($at)\n" |
| 1533 | "addiu $at, $a0, 0x7FF8\n" |
| 1534 | "ldc1 $f0, 8($at)\n" |
| 1535 | "addiu $at, $a0, 0x7FF8\n" |
| 1536 | "ldc1 $f0, 0x7FF8($at)\n" |
| 1537 | "addiu $at, $a0, -0x7FF8\n" |
| 1538 | "addiu $at, $at, -0x7FF8\n" |
| 1539 | "ldc1 $f0, -0x7FF8($at)\n" |
| 1540 | "addiu $at, $a0, -0x7FF8\n" |
| 1541 | "addiu $at, $at, -0x7FF8\n" |
| 1542 | "ldc1 $f0, -8($at)\n" |
| 1543 | "addiu $at, $a0, -0x7FF8\n" |
| 1544 | "addiu $at, $at, -0x7FF8\n" |
| 1545 | "lwc1 $f0, -1($at)\n" |
| 1546 | "lwc1 $f1, 3($at)\n" |
| 1547 | "addiu $at, $a0, 0x7FF8\n" |
| 1548 | "addiu $at, $at, 0x7FF8\n" |
| 1549 | "lwc1 $f0, 1($at)\n" |
| 1550 | "lwc1 $f1, 5($at)\n" |
| 1551 | "addiu $at, $a0, 0x7FF8\n" |
| 1552 | "addiu $at, $at, 0x7FF8\n" |
| 1553 | "ldc1 $f0, 8($at)\n" |
| 1554 | "addiu $at, $a0, 0x7FF8\n" |
| 1555 | "addiu $at, $at, 0x7FF8\n" |
| 1556 | "ldc1 $f0, 0x7FF8($at)\n" |
| 1557 | "lui $at, 0xFFFE\n" |
| 1558 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1559 | "addu $at, $at, $a0\n" |
| 1560 | "ldc1 $f0, 0($at)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1561 | "lui $at, 0xFFFE\n" |
| 1562 | "ori $at, $at, 0x8010\n" |
| 1563 | "addu $at, $at, $a0\n" |
| 1564 | "lwc1 $f0, 7($at)\n" |
| 1565 | "lwc1 $f1, 11($at)\n" |
| 1566 | "lui $at, 0x1\n" |
| 1567 | "ori $at, $at, 0x7FE8\n" |
| 1568 | "addu $at, $at, $a0\n" |
| 1569 | "lwc1 $f0, 1($at)\n" |
| 1570 | "lwc1 $f1, 5($at)\n" |
| 1571 | "lui $at, 0x1\n" |
| 1572 | "ori $at, $at, 0x7FF0\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1573 | "addu $at, $at, $a0\n" |
| 1574 | "ldc1 $f0, 0($at)\n" |
| 1575 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1576 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1577 | "addu $at, $at, $a0\n" |
| 1578 | "ldc1 $f0, 0($at)\n"; |
| 1579 | DriverStr(expected, "LoadDFromOffset"); |
| 1580 | } |
| 1581 | |
| 1582 | TEST_F(AssemblerMIPSTest, StoreToOffset) { |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1583 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x8000); |
| 1584 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0); |
| 1585 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x7FF8); |
| 1586 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x7FFB); |
| 1587 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x7FFC); |
| 1588 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x7FFF); |
| 1589 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0xFFF0); |
| 1590 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x8008); |
| 1591 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x8001); |
| 1592 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x8000); |
| 1593 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0xFFF0); |
| 1594 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x17FE8); |
| 1595 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x0FFF8); |
| 1596 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x0FFF1); |
| 1597 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x0FFF1); |
| 1598 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x0FFF8); |
| 1599 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x17FE8); |
| 1600 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x17FF0); |
| 1601 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, -0x17FE9); |
| 1602 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x17FE9); |
| 1603 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x17FF0); |
| 1604 | __ StoreToOffset(mips::kStoreByte, mips::A3, mips::A1, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1605 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1606 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x8000); |
| 1607 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0); |
| 1608 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x7FF8); |
| 1609 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x7FFB); |
| 1610 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x7FFC); |
| 1611 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x7FFF); |
| 1612 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0xFFF0); |
| 1613 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x8008); |
| 1614 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x8001); |
| 1615 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x8000); |
| 1616 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0xFFF0); |
| 1617 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x17FE8); |
| 1618 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x0FFF8); |
| 1619 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x0FFF1); |
| 1620 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x0FFF1); |
| 1621 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x0FFF8); |
| 1622 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x17FE8); |
| 1623 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x17FF0); |
| 1624 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, -0x17FE9); |
| 1625 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x17FE9); |
| 1626 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x17FF0); |
| 1627 | __ StoreToOffset(mips::kStoreHalfword, mips::A3, mips::A1, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1628 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1629 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x8000); |
| 1630 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0); |
| 1631 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x7FF8); |
| 1632 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x7FFB); |
| 1633 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x7FFC); |
| 1634 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x7FFF); |
| 1635 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0xFFF0); |
| 1636 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x8008); |
| 1637 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x8001); |
| 1638 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x8000); |
| 1639 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0xFFF0); |
| 1640 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x17FE8); |
| 1641 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x0FFF8); |
| 1642 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x0FFF1); |
| 1643 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x0FFF1); |
| 1644 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x0FFF8); |
| 1645 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x17FE8); |
| 1646 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x17FF0); |
| 1647 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, -0x17FE9); |
| 1648 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x17FE9); |
| 1649 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x17FF0); |
| 1650 | __ StoreToOffset(mips::kStoreWord, mips::A3, mips::A1, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1651 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1652 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x8000); |
| 1653 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0); |
| 1654 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x7FF8); |
| 1655 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x7FFB); |
| 1656 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x7FFC); |
| 1657 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x7FFF); |
| 1658 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0xFFF0); |
| 1659 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x8008); |
| 1660 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x8001); |
| 1661 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x8000); |
| 1662 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0xFFF0); |
| 1663 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x17FE8); |
| 1664 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x0FFF8); |
| 1665 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x0FFF1); |
| 1666 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x0FFF1); |
| 1667 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x0FFF8); |
| 1668 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x17FE8); |
| 1669 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x17FF0); |
| 1670 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, -0x17FE9); |
| 1671 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x17FE9); |
| 1672 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x17FF0); |
| 1673 | __ StoreToOffset(mips::kStoreDoubleword, mips::A0, mips::A2, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1674 | |
| 1675 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1676 | "sb $a3, -0x8000($a1)\n" |
| 1677 | "sb $a3, 0($a1)\n" |
| 1678 | "sb $a3, 0x7FF8($a1)\n" |
| 1679 | "sb $a3, 0x7FFB($a1)\n" |
| 1680 | "sb $a3, 0x7FFC($a1)\n" |
| 1681 | "sb $a3, 0x7FFF($a1)\n" |
| 1682 | "addiu $at, $a1, -0x7FF8\n" |
| 1683 | "sb $a3, -0x7FF8($at)\n" |
| 1684 | "addiu $at, $a1, -0x7FF8\n" |
| 1685 | "sb $a3, -0x10($at)\n" |
| 1686 | "addiu $at, $a1, -0x7FF8\n" |
| 1687 | "sb $a3, -9($at)\n" |
| 1688 | "addiu $at, $a1, 0x7FF8\n" |
| 1689 | "sb $a3, 8($at)\n" |
| 1690 | "addiu $at, $a1, 0x7FF8\n" |
| 1691 | "sb $a3, 0x7FF8($at)\n" |
| 1692 | "addiu $at, $a1, -0x7FF8\n" |
| 1693 | "addiu $at, $at, -0x7FF8\n" |
| 1694 | "sb $a3, -0x7FF8($at)\n" |
| 1695 | "addiu $at, $a1, -0x7FF8\n" |
| 1696 | "addiu $at, $at, -0x7FF8\n" |
| 1697 | "sb $a3, -8($at)\n" |
| 1698 | "addiu $at, $a1, -0x7FF8\n" |
| 1699 | "addiu $at, $at, -0x7FF8\n" |
| 1700 | "sb $a3, -1($at)\n" |
| 1701 | "addiu $at, $a1, 0x7FF8\n" |
| 1702 | "addiu $at, $at, 0x7FF8\n" |
| 1703 | "sb $a3, 1($at)\n" |
| 1704 | "addiu $at, $a1, 0x7FF8\n" |
| 1705 | "addiu $at, $at, 0x7FF8\n" |
| 1706 | "sb $a3, 8($at)\n" |
| 1707 | "addiu $at, $a1, 0x7FF8\n" |
| 1708 | "addiu $at, $at, 0x7FF8\n" |
| 1709 | "sb $a3, 0x7FF8($at)\n" |
| 1710 | "lui $at, 0xFFFE\n" |
| 1711 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1712 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1713 | "sb $a3, 0($at)\n" |
| 1714 | "lui $at, 0xFFFE\n" |
| 1715 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1716 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1717 | "sb $a3, 7($at)\n" |
| 1718 | "lui $at, 0x1\n" |
| 1719 | "ori $at, $at, 0x7FE8\n" |
| 1720 | "addu $at, $at, $a1\n" |
| 1721 | "sb $a3, 1($at)\n" |
| 1722 | "lui $at, 0x1\n" |
| 1723 | "ori $at, $at, 0x7FF0\n" |
| 1724 | "addu $at, $at, $a1\n" |
| 1725 | "sb $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1726 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1727 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1728 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1729 | "sb $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1730 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1731 | "sh $a3, -0x8000($a1)\n" |
| 1732 | "sh $a3, 0($a1)\n" |
| 1733 | "sh $a3, 0x7FF8($a1)\n" |
| 1734 | "sh $a3, 0x7FFB($a1)\n" |
| 1735 | "sh $a3, 0x7FFC($a1)\n" |
| 1736 | "sh $a3, 0x7FFF($a1)\n" |
| 1737 | "addiu $at, $a1, -0x7FF8\n" |
| 1738 | "sh $a3, -0x7FF8($at)\n" |
| 1739 | "addiu $at, $a1, -0x7FF8\n" |
| 1740 | "sh $a3, -0x10($at)\n" |
| 1741 | "addiu $at, $a1, -0x7FF8\n" |
| 1742 | "sh $a3, -9($at)\n" |
| 1743 | "addiu $at, $a1, 0x7FF8\n" |
| 1744 | "sh $a3, 8($at)\n" |
| 1745 | "addiu $at, $a1, 0x7FF8\n" |
| 1746 | "sh $a3, 0x7FF8($at)\n" |
| 1747 | "addiu $at, $a1, -0x7FF8\n" |
| 1748 | "addiu $at, $at, -0x7FF8\n" |
| 1749 | "sh $a3, -0x7FF8($at)\n" |
| 1750 | "addiu $at, $a1, -0x7FF8\n" |
| 1751 | "addiu $at, $at, -0x7FF8\n" |
| 1752 | "sh $a3, -8($at)\n" |
| 1753 | "addiu $at, $a1, -0x7FF8\n" |
| 1754 | "addiu $at, $at, -0x7FF8\n" |
| 1755 | "sh $a3, -1($at)\n" |
| 1756 | "addiu $at, $a1, 0x7FF8\n" |
| 1757 | "addiu $at, $at, 0x7FF8\n" |
| 1758 | "sh $a3, 1($at)\n" |
| 1759 | "addiu $at, $a1, 0x7FF8\n" |
| 1760 | "addiu $at, $at, 0x7FF8\n" |
| 1761 | "sh $a3, 8($at)\n" |
| 1762 | "addiu $at, $a1, 0x7FF8\n" |
| 1763 | "addiu $at, $at, 0x7FF8\n" |
| 1764 | "sh $a3, 0x7FF8($at)\n" |
| 1765 | "lui $at, 0xFFFE\n" |
| 1766 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1767 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1768 | "sh $a3, 0($at)\n" |
| 1769 | "lui $at, 0xFFFE\n" |
| 1770 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1771 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1772 | "sh $a3, 7($at)\n" |
| 1773 | "lui $at, 0x1\n" |
| 1774 | "ori $at, $at, 0x7FE8\n" |
| 1775 | "addu $at, $at, $a1\n" |
| 1776 | "sh $a3, 1($at)\n" |
| 1777 | "lui $at, 0x1\n" |
| 1778 | "ori $at, $at, 0x7FF0\n" |
| 1779 | "addu $at, $at, $a1\n" |
| 1780 | "sh $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1781 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1782 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1783 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1784 | "sh $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1785 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1786 | "sw $a3, -0x8000($a1)\n" |
| 1787 | "sw $a3, 0($a1)\n" |
| 1788 | "sw $a3, 0x7FF8($a1)\n" |
| 1789 | "sw $a3, 0x7FFB($a1)\n" |
| 1790 | "sw $a3, 0x7FFC($a1)\n" |
| 1791 | "sw $a3, 0x7FFF($a1)\n" |
| 1792 | "addiu $at, $a1, -0x7FF8\n" |
| 1793 | "sw $a3, -0x7FF8($at)\n" |
| 1794 | "addiu $at, $a1, -0x7FF8\n" |
| 1795 | "sw $a3, -0x10($at)\n" |
| 1796 | "addiu $at, $a1, -0x7FF8\n" |
| 1797 | "sw $a3, -9($at)\n" |
| 1798 | "addiu $at, $a1, 0x7FF8\n" |
| 1799 | "sw $a3, 8($at)\n" |
| 1800 | "addiu $at, $a1, 0x7FF8\n" |
| 1801 | "sw $a3, 0x7FF8($at)\n" |
| 1802 | "addiu $at, $a1, -0x7FF8\n" |
| 1803 | "addiu $at, $at, -0x7FF8\n" |
| 1804 | "sw $a3, -0x7FF8($at)\n" |
| 1805 | "addiu $at, $a1, -0x7FF8\n" |
| 1806 | "addiu $at, $at, -0x7FF8\n" |
| 1807 | "sw $a3, -8($at)\n" |
| 1808 | "addiu $at, $a1, -0x7FF8\n" |
| 1809 | "addiu $at, $at, -0x7FF8\n" |
| 1810 | "sw $a3, -1($at)\n" |
| 1811 | "addiu $at, $a1, 0x7FF8\n" |
| 1812 | "addiu $at, $at, 0x7FF8\n" |
| 1813 | "sw $a3, 1($at)\n" |
| 1814 | "addiu $at, $a1, 0x7FF8\n" |
| 1815 | "addiu $at, $at, 0x7FF8\n" |
| 1816 | "sw $a3, 8($at)\n" |
| 1817 | "addiu $at, $a1, 0x7FF8\n" |
| 1818 | "addiu $at, $at, 0x7FF8\n" |
| 1819 | "sw $a3, 0x7FF8($at)\n" |
| 1820 | "lui $at, 0xFFFE\n" |
| 1821 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1822 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1823 | "sw $a3, 0($at)\n" |
| 1824 | "lui $at, 0xFFFE\n" |
| 1825 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1826 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1827 | "sw $a3, 7($at)\n" |
| 1828 | "lui $at, 0x1\n" |
| 1829 | "ori $at, $at, 0x7FE8\n" |
| 1830 | "addu $at, $at, $a1\n" |
| 1831 | "sw $a3, 1($at)\n" |
| 1832 | "lui $at, 0x1\n" |
| 1833 | "ori $at, $at, 0x7FF0\n" |
| 1834 | "addu $at, $at, $a1\n" |
| 1835 | "sw $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1836 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1837 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1838 | "addu $at, $at, $a1\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1839 | "sw $a3, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1840 | |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1841 | "sw $a0, -0x8000($a2)\n" |
| 1842 | "sw $a1, -0x7FFC($a2)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1843 | "sw $a0, 0($a2)\n" |
| 1844 | "sw $a1, 4($a2)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1845 | "sw $a0, 0x7FF8($a2)\n" |
| 1846 | "sw $a1, 0x7FFC($a2)\n" |
| 1847 | "sw $a0, 0x7FFB($a2)\n" |
| 1848 | "sw $a1, 0x7FFF($a2)\n" |
| 1849 | "addiu $at, $a2, 0x7FF8\n" |
| 1850 | "sw $a0, 4($at)\n" |
| 1851 | "sw $a1, 8($at)\n" |
| 1852 | "addiu $at, $a2, 0x7FF8\n" |
| 1853 | "sw $a0, 7($at)\n" |
| 1854 | "sw $a1, 11($at)\n" |
| 1855 | "addiu $at, $a2, -0x7FF8\n" |
| 1856 | "sw $a0, -0x7FF8($at)\n" |
| 1857 | "sw $a1, -0x7FF4($at)\n" |
| 1858 | "addiu $at, $a2, -0x7FF8\n" |
| 1859 | "sw $a0, -0x10($at)\n" |
| 1860 | "sw $a1, -0xC($at)\n" |
| 1861 | "addiu $at, $a2, -0x7FF8\n" |
| 1862 | "sw $a0, -9($at)\n" |
| 1863 | "sw $a1, -5($at)\n" |
| 1864 | "addiu $at, $a2, 0x7FF8\n" |
| 1865 | "sw $a0, 8($at)\n" |
| 1866 | "sw $a1, 12($at)\n" |
| 1867 | "addiu $at, $a2, 0x7FF8\n" |
| 1868 | "sw $a0, 0x7FF8($at)\n" |
| 1869 | "sw $a1, 0x7FFC($at)\n" |
| 1870 | "addiu $at, $a2, -0x7FF8\n" |
| 1871 | "addiu $at, $at, -0x7FF8\n" |
| 1872 | "sw $a0, -0x7FF8($at)\n" |
| 1873 | "sw $a1, -0x7FF4($at)\n" |
| 1874 | "addiu $at, $a2, -0x7FF8\n" |
| 1875 | "addiu $at, $at, -0x7FF8\n" |
| 1876 | "sw $a0, -8($at)\n" |
| 1877 | "sw $a1, -4($at)\n" |
| 1878 | "addiu $at, $a2, -0x7FF8\n" |
| 1879 | "addiu $at, $at, -0x7FF8\n" |
| 1880 | "sw $a0, -1($at)\n" |
| 1881 | "sw $a1, 3($at)\n" |
| 1882 | "addiu $at, $a2, 0x7FF8\n" |
| 1883 | "addiu $at, $at, 0x7FF8\n" |
| 1884 | "sw $a0, 1($at)\n" |
| 1885 | "sw $a1, 5($at)\n" |
| 1886 | "addiu $at, $a2, 0x7FF8\n" |
| 1887 | "addiu $at, $at, 0x7FF8\n" |
| 1888 | "sw $a0, 8($at)\n" |
| 1889 | "sw $a1, 12($at)\n" |
| 1890 | "addiu $at, $a2, 0x7FF8\n" |
| 1891 | "addiu $at, $at, 0x7FF8\n" |
| 1892 | "sw $a0, 0x7FF8($at)\n" |
| 1893 | "sw $a1, 0x7FFC($at)\n" |
| 1894 | "lui $at, 0xFFFE\n" |
| 1895 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1896 | "addu $at, $at, $a2\n" |
| 1897 | "sw $a0, 0($at)\n" |
| 1898 | "sw $a1, 4($at)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1899 | "lui $at, 0xFFFE\n" |
| 1900 | "ori $at, $at, 0x8010\n" |
| 1901 | "addu $at, $at, $a2\n" |
| 1902 | "sw $a0, 7($at)\n" |
| 1903 | "sw $a1, 11($at)\n" |
| 1904 | "lui $at, 0x1\n" |
| 1905 | "ori $at, $at, 0x7FE8\n" |
| 1906 | "addu $at, $at, $a2\n" |
| 1907 | "sw $a0, 1($at)\n" |
| 1908 | "sw $a1, 5($at)\n" |
| 1909 | "lui $at, 0x1\n" |
| 1910 | "ori $at, $at, 0x7FF0\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1911 | "addu $at, $at, $a2\n" |
| 1912 | "sw $a0, 0($at)\n" |
| 1913 | "sw $a1, 4($at)\n" |
| 1914 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1915 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1916 | "addu $at, $at, $a2\n" |
| 1917 | "sw $a0, 0($at)\n" |
| 1918 | "sw $a1, 4($at)\n"; |
| 1919 | DriverStr(expected, "StoreToOffset"); |
| 1920 | } |
| 1921 | |
| 1922 | TEST_F(AssemblerMIPSTest, StoreSToOffset) { |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1923 | __ StoreSToOffset(mips::F2, mips::A0, -0x8000); |
| 1924 | __ StoreSToOffset(mips::F2, mips::A0, +0); |
| 1925 | __ StoreSToOffset(mips::F2, mips::A0, +0x7FF8); |
| 1926 | __ StoreSToOffset(mips::F2, mips::A0, +0x7FFB); |
| 1927 | __ StoreSToOffset(mips::F2, mips::A0, +0x7FFC); |
| 1928 | __ StoreSToOffset(mips::F2, mips::A0, +0x7FFF); |
| 1929 | __ StoreSToOffset(mips::F2, mips::A0, -0xFFF0); |
| 1930 | __ StoreSToOffset(mips::F2, mips::A0, -0x8008); |
| 1931 | __ StoreSToOffset(mips::F2, mips::A0, -0x8001); |
| 1932 | __ StoreSToOffset(mips::F2, mips::A0, +0x8000); |
| 1933 | __ StoreSToOffset(mips::F2, mips::A0, +0xFFF0); |
| 1934 | __ StoreSToOffset(mips::F2, mips::A0, -0x17FE8); |
| 1935 | __ StoreSToOffset(mips::F2, mips::A0, -0x0FFF8); |
| 1936 | __ StoreSToOffset(mips::F2, mips::A0, -0x0FFF1); |
| 1937 | __ StoreSToOffset(mips::F2, mips::A0, +0x0FFF1); |
| 1938 | __ StoreSToOffset(mips::F2, mips::A0, +0x0FFF8); |
| 1939 | __ StoreSToOffset(mips::F2, mips::A0, +0x17FE8); |
| 1940 | __ StoreSToOffset(mips::F2, mips::A0, -0x17FF0); |
| 1941 | __ StoreSToOffset(mips::F2, mips::A0, -0x17FE9); |
| 1942 | __ StoreSToOffset(mips::F2, mips::A0, +0x17FE9); |
| 1943 | __ StoreSToOffset(mips::F2, mips::A0, +0x17FF0); |
| 1944 | __ StoreSToOffset(mips::F2, mips::A0, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1945 | |
| 1946 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1947 | "swc1 $f2, -0x8000($a0)\n" |
| 1948 | "swc1 $f2, 0($a0)\n" |
| 1949 | "swc1 $f2, 0x7FF8($a0)\n" |
| 1950 | "swc1 $f2, 0x7FFB($a0)\n" |
| 1951 | "swc1 $f2, 0x7FFC($a0)\n" |
| 1952 | "swc1 $f2, 0x7FFF($a0)\n" |
| 1953 | "addiu $at, $a0, -0x7FF8\n" |
| 1954 | "swc1 $f2, -0x7FF8($at)\n" |
| 1955 | "addiu $at, $a0, -0x7FF8\n" |
| 1956 | "swc1 $f2, -0x10($at)\n" |
| 1957 | "addiu $at, $a0, -0x7FF8\n" |
| 1958 | "swc1 $f2, -9($at)\n" |
| 1959 | "addiu $at, $a0, 0x7FF8\n" |
| 1960 | "swc1 $f2, 8($at)\n" |
| 1961 | "addiu $at, $a0, 0x7FF8\n" |
| 1962 | "swc1 $f2, 0x7FF8($at)\n" |
| 1963 | "addiu $at, $a0, -0x7FF8\n" |
| 1964 | "addiu $at, $at, -0x7FF8\n" |
| 1965 | "swc1 $f2, -0x7FF8($at)\n" |
| 1966 | "addiu $at, $a0, -0x7FF8\n" |
| 1967 | "addiu $at, $at, -0x7FF8\n" |
| 1968 | "swc1 $f2, -8($at)\n" |
| 1969 | "addiu $at, $a0, -0x7FF8\n" |
| 1970 | "addiu $at, $at, -0x7FF8\n" |
| 1971 | "swc1 $f2, -1($at)\n" |
| 1972 | "addiu $at, $a0, 0x7FF8\n" |
| 1973 | "addiu $at, $at, 0x7FF8\n" |
| 1974 | "swc1 $f2, 1($at)\n" |
| 1975 | "addiu $at, $a0, 0x7FF8\n" |
| 1976 | "addiu $at, $at, 0x7FF8\n" |
| 1977 | "swc1 $f2, 8($at)\n" |
| 1978 | "addiu $at, $a0, 0x7FF8\n" |
| 1979 | "addiu $at, $at, 0x7FF8\n" |
| 1980 | "swc1 $f2, 0x7FF8($at)\n" |
| 1981 | "lui $at, 0xFFFE\n" |
| 1982 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1983 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1984 | "swc1 $f2, 0($at)\n" |
| 1985 | "lui $at, 0xFFFE\n" |
| 1986 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1987 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1988 | "swc1 $f2, 7($at)\n" |
| 1989 | "lui $at, 0x1\n" |
| 1990 | "ori $at, $at, 0x7FE8\n" |
| 1991 | "addu $at, $at, $a0\n" |
| 1992 | "swc1 $f2, 1($at)\n" |
| 1993 | "lui $at, 0x1\n" |
| 1994 | "ori $at, $at, 0x7FF0\n" |
| 1995 | "addu $at, $at, $a0\n" |
| 1996 | "swc1 $f2, 0($at)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1997 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 1998 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 1999 | "addu $at, $at, $a0\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2000 | "swc1 $f2, 0($at)\n"; |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2001 | DriverStr(expected, "StoreSToOffset"); |
| 2002 | } |
| 2003 | |
| 2004 | TEST_F(AssemblerMIPSTest, StoreDToOffset) { |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2005 | __ StoreDToOffset(mips::F0, mips::A0, -0x8000); |
| 2006 | __ StoreDToOffset(mips::F0, mips::A0, +0); |
| 2007 | __ StoreDToOffset(mips::F0, mips::A0, +0x7FF8); |
| 2008 | __ StoreDToOffset(mips::F0, mips::A0, +0x7FFB); |
| 2009 | __ StoreDToOffset(mips::F0, mips::A0, +0x7FFC); |
| 2010 | __ StoreDToOffset(mips::F0, mips::A0, +0x7FFF); |
| 2011 | __ StoreDToOffset(mips::F0, mips::A0, -0xFFF0); |
| 2012 | __ StoreDToOffset(mips::F0, mips::A0, -0x8008); |
| 2013 | __ StoreDToOffset(mips::F0, mips::A0, -0x8001); |
| 2014 | __ StoreDToOffset(mips::F0, mips::A0, +0x8000); |
| 2015 | __ StoreDToOffset(mips::F0, mips::A0, +0xFFF0); |
| 2016 | __ StoreDToOffset(mips::F0, mips::A0, -0x17FE8); |
| 2017 | __ StoreDToOffset(mips::F0, mips::A0, -0x0FFF8); |
| 2018 | __ StoreDToOffset(mips::F0, mips::A0, -0x0FFF1); |
| 2019 | __ StoreDToOffset(mips::F0, mips::A0, +0x0FFF1); |
| 2020 | __ StoreDToOffset(mips::F0, mips::A0, +0x0FFF8); |
| 2021 | __ StoreDToOffset(mips::F0, mips::A0, +0x17FE8); |
| 2022 | __ StoreDToOffset(mips::F0, mips::A0, -0x17FF0); |
| 2023 | __ StoreDToOffset(mips::F0, mips::A0, -0x17FE9); |
| 2024 | __ StoreDToOffset(mips::F0, mips::A0, +0x17FE9); |
| 2025 | __ StoreDToOffset(mips::F0, mips::A0, +0x17FF0); |
| 2026 | __ StoreDToOffset(mips::F0, mips::A0, +0x12345678); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2027 | |
| 2028 | const char* expected = |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2029 | "sdc1 $f0, -0x8000($a0)\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2030 | "sdc1 $f0, 0($a0)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2031 | "sdc1 $f0, 0x7FF8($a0)\n" |
| 2032 | "swc1 $f0, 0x7FFB($a0)\n" |
| 2033 | "swc1 $f1, 0x7FFF($a0)\n" |
| 2034 | "addiu $at, $a0, 0x7FF8\n" |
| 2035 | "swc1 $f0, 4($at)\n" |
| 2036 | "swc1 $f1, 8($at)\n" |
| 2037 | "addiu $at, $a0, 0x7FF8\n" |
| 2038 | "swc1 $f0, 7($at)\n" |
| 2039 | "swc1 $f1, 11($at)\n" |
| 2040 | "addiu $at, $a0, -0x7FF8\n" |
| 2041 | "sdc1 $f0, -0x7FF8($at)\n" |
| 2042 | "addiu $at, $a0, -0x7FF8\n" |
| 2043 | "sdc1 $f0, -0x10($at)\n" |
| 2044 | "addiu $at, $a0, -0x7FF8\n" |
| 2045 | "swc1 $f0, -9($at)\n" |
| 2046 | "swc1 $f1, -5($at)\n" |
| 2047 | "addiu $at, $a0, 0x7FF8\n" |
| 2048 | "sdc1 $f0, 8($at)\n" |
| 2049 | "addiu $at, $a0, 0x7FF8\n" |
| 2050 | "sdc1 $f0, 0x7FF8($at)\n" |
| 2051 | "addiu $at, $a0, -0x7FF8\n" |
| 2052 | "addiu $at, $at, -0x7FF8\n" |
| 2053 | "sdc1 $f0, -0x7FF8($at)\n" |
| 2054 | "addiu $at, $a0, -0x7FF8\n" |
| 2055 | "addiu $at, $at, -0x7FF8\n" |
| 2056 | "sdc1 $f0, -8($at)\n" |
| 2057 | "addiu $at, $a0, -0x7FF8\n" |
| 2058 | "addiu $at, $at, -0x7FF8\n" |
| 2059 | "swc1 $f0, -1($at)\n" |
| 2060 | "swc1 $f1, 3($at)\n" |
| 2061 | "addiu $at, $a0, 0x7FF8\n" |
| 2062 | "addiu $at, $at, 0x7FF8\n" |
| 2063 | "swc1 $f0, 1($at)\n" |
| 2064 | "swc1 $f1, 5($at)\n" |
| 2065 | "addiu $at, $a0, 0x7FF8\n" |
| 2066 | "addiu $at, $at, 0x7FF8\n" |
| 2067 | "sdc1 $f0, 8($at)\n" |
| 2068 | "addiu $at, $a0, 0x7FF8\n" |
| 2069 | "addiu $at, $at, 0x7FF8\n" |
| 2070 | "sdc1 $f0, 0x7FF8($at)\n" |
| 2071 | "lui $at, 0xFFFE\n" |
| 2072 | "ori $at, $at, 0x8010\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2073 | "addu $at, $at, $a0\n" |
| 2074 | "sdc1 $f0, 0($at)\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2075 | "lui $at, 0xFFFE\n" |
| 2076 | "ori $at, $at, 0x8010\n" |
| 2077 | "addu $at, $at, $a0\n" |
| 2078 | "swc1 $f0, 7($at)\n" |
| 2079 | "swc1 $f1, 11($at)\n" |
| 2080 | "lui $at, 0x1\n" |
| 2081 | "ori $at, $at, 0x7FE8\n" |
| 2082 | "addu $at, $at, $a0\n" |
| 2083 | "swc1 $f0, 1($at)\n" |
| 2084 | "swc1 $f1, 5($at)\n" |
| 2085 | "lui $at, 0x1\n" |
| 2086 | "ori $at, $at, 0x7FF0\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2087 | "addu $at, $at, $a0\n" |
| 2088 | "sdc1 $f0, 0($at)\n" |
| 2089 | "lui $at, 0x1234\n" |
Alexey Frunze | cad3a4c | 2016-06-07 23:40:37 -0700 | [diff] [blame] | 2090 | "ori $at, $at, 0x5678\n" |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2091 | "addu $at, $at, $a0\n" |
| 2092 | "sdc1 $f0, 0($at)\n"; |
| 2093 | DriverStr(expected, "StoreDToOffset"); |
| 2094 | } |
| 2095 | |
Alexey Frunze | f58b248 | 2016-09-02 22:14:06 -0700 | [diff] [blame] | 2096 | TEST_F(AssemblerMIPSTest, StoreConstToOffset) { |
| 2097 | __ StoreConstToOffset(mips::kStoreByte, 0xFF, mips::A1, +0, mips::T8); |
| 2098 | __ StoreConstToOffset(mips::kStoreHalfword, 0xFFFF, mips::A1, +0, mips::T8); |
| 2099 | __ StoreConstToOffset(mips::kStoreWord, 0x12345678, mips::A1, +0, mips::T8); |
| 2100 | __ StoreConstToOffset(mips::kStoreDoubleword, 0x123456789ABCDEF0, mips::A1, +0, mips::T8); |
| 2101 | |
| 2102 | __ StoreConstToOffset(mips::kStoreByte, 0, mips::A1, +0, mips::T8); |
| 2103 | __ StoreConstToOffset(mips::kStoreHalfword, 0, mips::A1, +0, mips::T8); |
| 2104 | __ StoreConstToOffset(mips::kStoreWord, 0, mips::A1, +0, mips::T8); |
| 2105 | __ StoreConstToOffset(mips::kStoreDoubleword, 0, mips::A1, +0, mips::T8); |
| 2106 | |
| 2107 | __ StoreConstToOffset(mips::kStoreDoubleword, 0x1234567812345678, mips::A1, +0, mips::T8); |
| 2108 | __ StoreConstToOffset(mips::kStoreDoubleword, 0x1234567800000000, mips::A1, +0, mips::T8); |
| 2109 | __ StoreConstToOffset(mips::kStoreDoubleword, 0x0000000012345678, mips::A1, +0, mips::T8); |
| 2110 | |
| 2111 | __ StoreConstToOffset(mips::kStoreWord, 0, mips::T8, +0, mips::T8); |
| 2112 | __ StoreConstToOffset(mips::kStoreWord, 0x12345678, mips::T8, +0, mips::T8); |
| 2113 | |
| 2114 | __ StoreConstToOffset(mips::kStoreWord, 0, mips::A1, -0xFFF0, mips::T8); |
| 2115 | __ StoreConstToOffset(mips::kStoreWord, 0x12345678, mips::A1, +0xFFF0, mips::T8); |
| 2116 | |
| 2117 | __ StoreConstToOffset(mips::kStoreWord, 0, mips::T8, -0xFFF0, mips::T8); |
| 2118 | __ StoreConstToOffset(mips::kStoreWord, 0x12345678, mips::T8, +0xFFF0, mips::T8); |
| 2119 | |
| 2120 | const char* expected = |
| 2121 | "ori $t8, $zero, 0xFF\n" |
| 2122 | "sb $t8, 0($a1)\n" |
| 2123 | "ori $t8, $zero, 0xFFFF\n" |
| 2124 | "sh $t8, 0($a1)\n" |
| 2125 | "lui $t8, 0x1234\n" |
| 2126 | "ori $t8, $t8, 0x5678\n" |
| 2127 | "sw $t8, 0($a1)\n" |
| 2128 | "lui $t8, 0x9ABC\n" |
| 2129 | "ori $t8, $t8, 0xDEF0\n" |
| 2130 | "sw $t8, 0($a1)\n" |
| 2131 | "lui $t8, 0x1234\n" |
| 2132 | "ori $t8, $t8, 0x5678\n" |
| 2133 | "sw $t8, 4($a1)\n" |
| 2134 | |
| 2135 | "sb $zero, 0($a1)\n" |
| 2136 | "sh $zero, 0($a1)\n" |
| 2137 | "sw $zero, 0($a1)\n" |
| 2138 | "sw $zero, 0($a1)\n" |
| 2139 | "sw $zero, 4($a1)\n" |
| 2140 | |
| 2141 | "lui $t8, 0x1234\n" |
| 2142 | "ori $t8, $t8, 0x5678\n" |
| 2143 | "sw $t8, 0($a1)\n" |
| 2144 | "sw $t8, 4($a1)\n" |
| 2145 | "sw $zero, 0($a1)\n" |
| 2146 | "lui $t8, 0x1234\n" |
| 2147 | "ori $t8, $t8, 0x5678\n" |
| 2148 | "sw $t8, 4($a1)\n" |
| 2149 | "lui $t8, 0x1234\n" |
| 2150 | "ori $t8, $t8, 0x5678\n" |
| 2151 | "sw $t8, 0($a1)\n" |
| 2152 | "sw $zero, 4($a1)\n" |
| 2153 | |
| 2154 | "sw $zero, 0($t8)\n" |
| 2155 | "lui $at, 0x1234\n" |
| 2156 | "ori $at, $at, 0x5678\n" |
| 2157 | "sw $at, 0($t8)\n" |
| 2158 | |
| 2159 | "addiu $at, $a1, -0x7FF8\n" |
| 2160 | "sw $zero, -0x7FF8($at)\n" |
| 2161 | "addiu $at, $a1, 0x7FF8\n" |
| 2162 | "lui $t8, 0x1234\n" |
| 2163 | "ori $t8, $t8, 0x5678\n" |
| 2164 | "sw $t8, 0x7FF8($at)\n" |
| 2165 | |
| 2166 | "addiu $at, $t8, -0x7FF8\n" |
| 2167 | "sw $zero, -0x7FF8($at)\n" |
| 2168 | "addiu $at, $t8, 0x7FF8\n" |
| 2169 | "lui $t8, 0x1234\n" |
| 2170 | "ori $t8, $t8, 0x5678\n" |
| 2171 | "sw $t8, 0x7FF8($at)\n"; |
| 2172 | DriverStr(expected, "StoreConstToOffset"); |
| 2173 | } |
| 2174 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2175 | ////////////// |
| 2176 | // BRANCHES // |
| 2177 | ////////////// |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2178 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2179 | TEST_F(AssemblerMIPSTest, B) { |
| 2180 | BranchHelper(&mips::MipsAssembler::B, "B"); |
| 2181 | } |
| 2182 | |
| 2183 | TEST_F(AssemblerMIPSTest, Bal) { |
| 2184 | BranchHelper(&mips::MipsAssembler::Bal, "Bal"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2185 | } |
| 2186 | |
| 2187 | TEST_F(AssemblerMIPSTest, Beq) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2188 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Beq, "Beq"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2189 | } |
| 2190 | |
| 2191 | TEST_F(AssemblerMIPSTest, Bne) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2192 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bne, "Bne"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2193 | } |
| 2194 | |
| 2195 | TEST_F(AssemblerMIPSTest, Beqz) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2196 | BranchCondOneRegHelper(&mips::MipsAssembler::Beqz, "Beqz"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2197 | } |
| 2198 | |
| 2199 | TEST_F(AssemblerMIPSTest, Bnez) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2200 | BranchCondOneRegHelper(&mips::MipsAssembler::Bnez, "Bnez"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2201 | } |
| 2202 | |
| 2203 | TEST_F(AssemblerMIPSTest, Bltz) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2204 | BranchCondOneRegHelper(&mips::MipsAssembler::Bltz, "Bltz"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2205 | } |
| 2206 | |
| 2207 | TEST_F(AssemblerMIPSTest, Bgez) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2208 | BranchCondOneRegHelper(&mips::MipsAssembler::Bgez, "Bgez"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2209 | } |
| 2210 | |
| 2211 | TEST_F(AssemblerMIPSTest, Blez) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2212 | BranchCondOneRegHelper(&mips::MipsAssembler::Blez, "Blez"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2213 | } |
| 2214 | |
| 2215 | TEST_F(AssemblerMIPSTest, Bgtz) { |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2216 | BranchCondOneRegHelper(&mips::MipsAssembler::Bgtz, "Bgtz"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2217 | } |
| 2218 | |
| 2219 | TEST_F(AssemblerMIPSTest, Blt) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2220 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Blt, "Blt"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2221 | } |
| 2222 | |
| 2223 | TEST_F(AssemblerMIPSTest, Bge) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2224 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bge, "Bge"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2225 | } |
| 2226 | |
| 2227 | TEST_F(AssemblerMIPSTest, Bltu) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2228 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltu, "Bltu"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2229 | } |
| 2230 | |
| 2231 | TEST_F(AssemblerMIPSTest, Bgeu) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2232 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeu, "Bgeu"); |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 2233 | } |
| 2234 | |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2235 | TEST_F(AssemblerMIPSTest, Bc1f) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2236 | BranchFpuCondCodeHelper(&mips::MipsAssembler::Bc1f, "Bc1f"); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2237 | } |
| 2238 | |
| 2239 | TEST_F(AssemblerMIPSTest, Bc1t) { |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2240 | BranchFpuCondCodeHelper(&mips::MipsAssembler::Bc1t, "Bc1t"); |
Alexey Frunze | cd7b0ee | 2015-12-03 16:46:38 -0800 | [diff] [blame] | 2241 | } |
| 2242 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2243 | TEST_F(AssemblerMIPSTest, BareB) { |
| 2244 | BranchHelper(&mips::MipsAssembler::B, "B", /* is_bare */ true); |
Chris Larsen | 3add9cb | 2016-04-14 14:01:33 -0700 | [diff] [blame] | 2245 | } |
| 2246 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2247 | TEST_F(AssemblerMIPSTest, BareBal) { |
| 2248 | BranchHelper(&mips::MipsAssembler::Bal, "Bal", /* is_bare */ true); |
Alexey Frunze | 96b6682 | 2016-09-10 02:32:44 -0700 | [diff] [blame] | 2249 | } |
| 2250 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2251 | TEST_F(AssemblerMIPSTest, BareBeq) { |
| 2252 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Beq, "Beq", /* is_bare */ true); |
Alexey Frunze | 96b6682 | 2016-09-10 02:32:44 -0700 | [diff] [blame] | 2253 | } |
| 2254 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2255 | TEST_F(AssemblerMIPSTest, BareBne) { |
| 2256 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bne, "Bne", /* is_bare */ true); |
Alexey Frunze | e3fb245 | 2016-05-10 16:08:05 -0700 | [diff] [blame] | 2257 | } |
| 2258 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2259 | TEST_F(AssemblerMIPSTest, BareBeqz) { |
| 2260 | BranchCondOneRegHelper(&mips::MipsAssembler::Beqz, "Beqz", /* is_bare */ true); |
| 2261 | } |
Alexey Frunze | e3fb245 | 2016-05-10 16:08:05 -0700 | [diff] [blame] | 2262 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2263 | TEST_F(AssemblerMIPSTest, BareBnez) { |
| 2264 | BranchCondOneRegHelper(&mips::MipsAssembler::Bnez, "Bnez", /* is_bare */ true); |
| 2265 | } |
| 2266 | |
| 2267 | TEST_F(AssemblerMIPSTest, BareBltz) { |
| 2268 | BranchCondOneRegHelper(&mips::MipsAssembler::Bltz, "Bltz", /* is_bare */ true); |
| 2269 | } |
| 2270 | |
| 2271 | TEST_F(AssemblerMIPSTest, BareBgez) { |
| 2272 | BranchCondOneRegHelper(&mips::MipsAssembler::Bgez, "Bgez", /* is_bare */ true); |
| 2273 | } |
| 2274 | |
| 2275 | TEST_F(AssemblerMIPSTest, BareBlez) { |
| 2276 | BranchCondOneRegHelper(&mips::MipsAssembler::Blez, "Blez", /* is_bare */ true); |
| 2277 | } |
| 2278 | |
| 2279 | TEST_F(AssemblerMIPSTest, BareBgtz) { |
| 2280 | BranchCondOneRegHelper(&mips::MipsAssembler::Bgtz, "Bgtz", /* is_bare */ true); |
| 2281 | } |
| 2282 | |
| 2283 | TEST_F(AssemblerMIPSTest, BareBlt) { |
| 2284 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Blt, "Blt", /* is_bare */ true); |
| 2285 | } |
| 2286 | |
| 2287 | TEST_F(AssemblerMIPSTest, BareBge) { |
| 2288 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bge, "Bge", /* is_bare */ true); |
| 2289 | } |
| 2290 | |
| 2291 | TEST_F(AssemblerMIPSTest, BareBltu) { |
| 2292 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bltu, "Bltu", /* is_bare */ true); |
| 2293 | } |
| 2294 | |
| 2295 | TEST_F(AssemblerMIPSTest, BareBgeu) { |
| 2296 | BranchCondTwoRegsHelper(&mips::MipsAssembler::Bgeu, "Bgeu", /* is_bare */ true); |
| 2297 | } |
| 2298 | |
| 2299 | TEST_F(AssemblerMIPSTest, BareBc1f) { |
| 2300 | BranchFpuCondCodeHelper(&mips::MipsAssembler::Bc1f, "Bc1f", /* is_bare */ true); |
| 2301 | } |
| 2302 | |
| 2303 | TEST_F(AssemblerMIPSTest, BareBc1t) { |
| 2304 | BranchFpuCondCodeHelper(&mips::MipsAssembler::Bc1t, "Bc1t", /* is_bare */ true); |
Alexey Frunze | e3fb245 | 2016-05-10 16:08:05 -0700 | [diff] [blame] | 2305 | } |
| 2306 | |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2307 | TEST_F(AssemblerMIPSTest, ImpossibleReordering) { |
| 2308 | mips::MipsLabel label1, label2; |
| 2309 | __ SetReorder(true); |
| 2310 | |
| 2311 | __ B(&label1); // No preceding or target instruction for the delay slot. |
| 2312 | |
| 2313 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2314 | __ Bind(&label1); |
| 2315 | __ B(&label1); // The preceding label prevents moving Addu into the delay slot. |
| 2316 | __ B(&label1); // No preceding or target instruction for the delay slot. |
| 2317 | |
| 2318 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2319 | __ Beqz(mips::T0, &label1); // T0 dependency. |
| 2320 | |
| 2321 | __ Or(mips::T1, mips::T2, mips::T3); |
| 2322 | __ Bne(mips::T2, mips::T1, &label1); // T1 dependency. |
| 2323 | |
| 2324 | __ And(mips::T0, mips::T1, mips::T2); |
| 2325 | __ Blt(mips::T1, mips::T0, &label1); // T0 dependency. |
| 2326 | |
| 2327 | __ Xor(mips::AT, mips::T0, mips::T1); |
| 2328 | __ Bge(mips::T1, mips::T0, &label1); // AT dependency. |
| 2329 | |
| 2330 | __ Subu(mips::T0, mips::T1, mips::AT); |
| 2331 | __ Bltu(mips::T1, mips::T0, &label1); // AT dependency. |
| 2332 | |
| 2333 | __ ColtS(1, mips::F2, mips::F4); |
| 2334 | __ Bc1t(1, &label1); // cc1 dependency. |
| 2335 | |
| 2336 | __ Move(mips::T0, mips::RA); |
| 2337 | __ Bal(&label1); // RA dependency. |
| 2338 | |
| 2339 | __ Lw(mips::RA, mips::T0, 0); |
| 2340 | __ Bal(&label1); // RA dependency. |
| 2341 | |
| 2342 | __ LlR2(mips::T9, mips::T0, 0); |
| 2343 | __ Jalr(mips::T9); // T9 dependency. |
| 2344 | |
| 2345 | __ Sw(mips::RA, mips::T0, 0); |
| 2346 | __ Jalr(mips::T9); // RA dependency. |
| 2347 | |
| 2348 | __ Lw(mips::T1, mips::T0, 0); |
| 2349 | __ Jalr(mips::T1, mips::T9); // T1 dependency. |
| 2350 | |
| 2351 | __ ScR2(mips::T9, mips::T0, 0); |
| 2352 | __ Jr(mips::T9); // T9 dependency. |
| 2353 | |
| 2354 | __ Bind(&label2); |
| 2355 | |
| 2356 | __ Bnez(mips::T0, &label2); // No preceding instruction for the delay slot. |
| 2357 | |
| 2358 | __ Bgeu(mips::T1, mips::T0, &label2); // No preceding instruction for the delay slot. |
| 2359 | |
| 2360 | __ Bc1f(2, &label2); // No preceding instruction for the delay slot. |
| 2361 | |
| 2362 | __ Bal(&label2); // No preceding instruction for the delay slot. |
| 2363 | |
| 2364 | __ Jalr(mips::T9); // No preceding instruction for the delay slot. |
| 2365 | |
| 2366 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2367 | __ CodePosition(); // Drops the delay slot candidate (the last instruction). |
| 2368 | __ Beq(mips::T1, mips::T2, &label2); // No preceding or target instruction for the delay slot. |
| 2369 | |
| 2370 | std::string expected = |
| 2371 | ".set noreorder\n" |
| 2372 | "b 1f\n" |
| 2373 | "nop\n" |
| 2374 | |
| 2375 | "addu $t0, $t1, $t2\n" |
| 2376 | "1:\n" |
| 2377 | "b 1b\n" |
| 2378 | "nop\n" |
| 2379 | "b 1b\n" |
| 2380 | "nop\n" |
| 2381 | |
| 2382 | "addu $t0, $t1, $t2\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2383 | "beqz $t0, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2384 | "nop\n" |
| 2385 | |
| 2386 | "or $t1, $t2, $t3\n" |
| 2387 | "bne $t2, $t1, 1b\n" |
| 2388 | "nop\n" |
| 2389 | |
| 2390 | "and $t0, $t1, $t2\n" |
| 2391 | "slt $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2392 | "bnez $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2393 | "nop\n" |
| 2394 | |
| 2395 | "xor $at, $t0, $t1\n" |
| 2396 | "slt $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2397 | "beqz $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2398 | "nop\n" |
| 2399 | |
| 2400 | "subu $t0, $t1, $at\n" |
| 2401 | "sltu $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2402 | "bnez $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2403 | "nop\n" |
| 2404 | |
| 2405 | "c.olt.s $fcc1, $f2, $f4\n" |
| 2406 | "bc1t $fcc1, 1b\n" |
| 2407 | "nop\n" |
| 2408 | |
| 2409 | "or $t0, $ra, $zero\n" |
| 2410 | "bal 1b\n" |
| 2411 | "nop\n" |
| 2412 | |
| 2413 | "lw $ra, 0($t0)\n" |
| 2414 | "bal 1b\n" |
| 2415 | "nop\n" |
| 2416 | |
| 2417 | "ll $t9, 0($t0)\n" |
| 2418 | "jalr $t9\n" |
| 2419 | "nop\n" |
| 2420 | |
| 2421 | "sw $ra, 0($t0)\n" |
| 2422 | "jalr $t9\n" |
| 2423 | "nop\n" |
| 2424 | |
| 2425 | "lw $t1, 0($t0)\n" |
| 2426 | "jalr $t1, $t9\n" |
| 2427 | "nop\n" |
| 2428 | |
| 2429 | "sc $t9, 0($t0)\n" |
| 2430 | "jalr $zero, $t9\n" |
| 2431 | "nop\n" |
| 2432 | |
| 2433 | "2:\n" |
| 2434 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2435 | "bnez $t0, 2b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2436 | "nop\n" |
| 2437 | |
| 2438 | "sltu $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2439 | "beqz $at, 2b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2440 | "nop\n" |
| 2441 | |
| 2442 | "bc1f $fcc2, 2b\n" |
| 2443 | "nop\n" |
| 2444 | |
| 2445 | "bal 2b\n" |
| 2446 | "nop\n" |
| 2447 | |
| 2448 | "jalr $t9\n" |
| 2449 | "nop\n" |
| 2450 | |
| 2451 | "addu $t0, $t1, $t2\n" |
| 2452 | "beq $t1, $t2, 2b\n" |
| 2453 | "nop\n"; |
| 2454 | DriverStr(expected, "ImpossibleReordering"); |
| 2455 | } |
| 2456 | |
| 2457 | TEST_F(AssemblerMIPSTest, Reordering) { |
| 2458 | mips::MipsLabel label1, label2; |
| 2459 | __ SetReorder(true); |
| 2460 | |
| 2461 | __ Bind(&label1); |
| 2462 | __ Bind(&label2); |
| 2463 | |
| 2464 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2465 | __ Beqz(mips::T1, &label1); |
| 2466 | |
| 2467 | __ Or(mips::T1, mips::T2, mips::T3); |
| 2468 | __ Bne(mips::T2, mips::T3, &label1); |
| 2469 | |
| 2470 | __ And(mips::T0, mips::T1, mips::T2); |
| 2471 | __ Blt(mips::T1, mips::T2, &label1); |
| 2472 | |
| 2473 | __ Xor(mips::T2, mips::T0, mips::T1); |
| 2474 | __ Bge(mips::T1, mips::T0, &label1); |
| 2475 | |
| 2476 | __ Subu(mips::T2, mips::T1, mips::T0); |
| 2477 | __ Bltu(mips::T1, mips::T0, &label1); |
| 2478 | |
| 2479 | __ ColtS(0, mips::F2, mips::F4); |
| 2480 | __ Bc1t(1, &label1); |
| 2481 | |
| 2482 | __ Move(mips::T0, mips::T1); |
| 2483 | __ Bal(&label1); |
| 2484 | |
| 2485 | __ LlR2(mips::T1, mips::T0, 0); |
| 2486 | __ Jalr(mips::T9); |
| 2487 | |
| 2488 | __ ScR2(mips::T1, mips::T0, 0); |
| 2489 | __ Jr(mips::T9); |
| 2490 | |
| 2491 | std::string expected = |
| 2492 | ".set noreorder\n" |
| 2493 | "1:\n" |
| 2494 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2495 | "beqz $t1, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2496 | "addu $t0, $t1, $t2\n" |
| 2497 | |
| 2498 | "bne $t2, $t3, 1b\n" |
| 2499 | "or $t1, $t2, $t3\n" |
| 2500 | |
| 2501 | "slt $at, $t1, $t2\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2502 | "bnez $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2503 | "and $t0, $t1, $t2\n" |
| 2504 | |
| 2505 | "slt $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2506 | "beqz $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2507 | "xor $t2, $t0, $t1\n" |
| 2508 | |
| 2509 | "sltu $at, $t1, $t0\n" |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2510 | "bnez $at, 1b\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2511 | "subu $t2, $t1, $t0\n" |
| 2512 | |
| 2513 | "bc1t $fcc1, 1b\n" |
| 2514 | "c.olt.s $fcc0, $f2, $f4\n" |
| 2515 | |
| 2516 | "bal 1b\n" |
| 2517 | "or $t0, $t1, $zero\n" |
| 2518 | |
| 2519 | "jalr $t9\n" |
| 2520 | "ll $t1, 0($t0)\n" |
| 2521 | |
| 2522 | "jalr $zero, $t9\n" |
| 2523 | "sc $t1, 0($t0)\n"; |
| 2524 | DriverStr(expected, "Reordering"); |
| 2525 | } |
| 2526 | |
| 2527 | TEST_F(AssemblerMIPSTest, AbsorbTargetInstruction) { |
| 2528 | mips::MipsLabel label1, label2, label3, label4, label5, label6; |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2529 | mips::MipsLabel label7, label8, label9, label10, label11, label12, label13; |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2530 | __ SetReorder(true); |
| 2531 | |
| 2532 | __ B(&label1); |
| 2533 | __ Bind(&label1); |
| 2534 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2535 | |
| 2536 | __ Bind(&label2); |
| 2537 | __ Xor(mips::T0, mips::T1, mips::T2); |
| 2538 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2539 | __ Bind(&label3); // Prevents reordering ADDU above with B below. |
| 2540 | __ B(&label2); |
| 2541 | |
| 2542 | __ B(&label4); |
| 2543 | __ Bind(&label4); |
| 2544 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2545 | __ CodePosition(); // Prevents absorbing ADDU above. |
| 2546 | |
| 2547 | __ B(&label5); |
| 2548 | __ Bind(&label5); |
| 2549 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2550 | __ Bind(&label6); |
| 2551 | __ CodePosition(); // Even across Bind(), CodePosition() prevents absorbing the ADDU above. |
| 2552 | |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2553 | __ Nop(); |
| 2554 | __ B(&label7); |
| 2555 | __ Bind(&label7); |
| 2556 | __ Lw(mips::V0, mips::A0, 0x5678); // Possibly patchable instruction, not absorbed. |
| 2557 | |
| 2558 | __ Nop(); |
| 2559 | __ B(&label8); |
| 2560 | __ Bind(&label8); |
| 2561 | __ Sw(mips::V0, mips::A0, 0x5678); // Possibly patchable instruction, not absorbed. |
| 2562 | |
| 2563 | __ Nop(); |
| 2564 | __ B(&label9); |
| 2565 | __ Bind(&label9); |
| 2566 | __ Addiu(mips::V0, mips::A0, 0x5678); // Possibly patchable instruction, not absorbed. |
| 2567 | |
| 2568 | __ Nop(); |
| 2569 | __ B(&label10); |
| 2570 | __ Bind(&label10); |
| 2571 | __ Lw(mips::V0, mips::A0, 0x5680); // Immediate isn't 0x5678, absorbed. |
| 2572 | |
| 2573 | __ Nop(); |
| 2574 | __ B(&label11); |
| 2575 | __ Bind(&label11); |
| 2576 | __ Sw(mips::V0, mips::A0, 0x5680); // Immediate isn't 0x5678, absorbed. |
| 2577 | |
| 2578 | __ Nop(); |
| 2579 | __ B(&label12); |
| 2580 | __ Bind(&label12); |
| 2581 | __ Addiu(mips::V0, mips::A0, 0x5680); // Immediate isn't 0x5678, absorbed. |
| 2582 | |
| 2583 | __ Nop(); |
| 2584 | __ B(&label13); |
| 2585 | __ Bind(&label13); |
| 2586 | __ Andi(mips::V0, mips::A0, 0x5678); // Not one of patchable instructions, absorbed. |
| 2587 | |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2588 | std::string expected = |
| 2589 | ".set noreorder\n" |
| 2590 | "b 1f\n" |
| 2591 | "addu $t0, $t1, $t2\n" |
| 2592 | "addu $t0, $t1, $t2\n" |
| 2593 | "1:\n" |
| 2594 | |
| 2595 | "xor $t0, $t1, $t2\n" |
| 2596 | "2:\n" |
| 2597 | "addu $t0, $t1, $t2\n" |
| 2598 | "b 2b\n" |
| 2599 | "xor $t0, $t1, $t2\n" |
| 2600 | |
| 2601 | "b 4f\n" |
| 2602 | "nop\n" |
| 2603 | "4:\n" |
| 2604 | "addu $t0, $t1, $t2\n" |
| 2605 | |
| 2606 | "b 5f\n" |
| 2607 | "nop\n" |
| 2608 | "5:\n" |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2609 | "addu $t0, $t1, $t2\n" |
| 2610 | |
| 2611 | "nop\n" |
| 2612 | "b 7f\n" |
| 2613 | "nop\n" |
| 2614 | "7:\n" |
| 2615 | "lw $v0, 0x5678($a0)\n" |
| 2616 | |
| 2617 | "nop\n" |
| 2618 | "b 8f\n" |
| 2619 | "nop\n" |
| 2620 | "8:\n" |
| 2621 | "sw $v0, 0x5678($a0)\n" |
| 2622 | |
| 2623 | "nop\n" |
| 2624 | "b 9f\n" |
| 2625 | "nop\n" |
| 2626 | "9:\n" |
| 2627 | "addiu $v0, $a0, 0x5678\n" |
| 2628 | |
| 2629 | "nop\n" |
| 2630 | "b 10f\n" |
| 2631 | "lw $v0, 0x5680($a0)\n" |
| 2632 | "lw $v0, 0x5680($a0)\n" |
| 2633 | "10:\n" |
| 2634 | |
| 2635 | "nop\n" |
| 2636 | "b 11f\n" |
| 2637 | "sw $v0, 0x5680($a0)\n" |
| 2638 | "sw $v0, 0x5680($a0)\n" |
| 2639 | "11:\n" |
| 2640 | |
| 2641 | "nop\n" |
| 2642 | "b 12f\n" |
| 2643 | "addiu $v0, $a0, 0x5680\n" |
| 2644 | "addiu $v0, $a0, 0x5680\n" |
| 2645 | "12:\n" |
| 2646 | |
| 2647 | "nop\n" |
| 2648 | "b 13f\n" |
| 2649 | "andi $v0, $a0, 0x5678\n" |
| 2650 | "andi $v0, $a0, 0x5678\n" |
| 2651 | "13:\n"; |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2652 | DriverStr(expected, "AbsorbTargetInstruction"); |
| 2653 | } |
| 2654 | |
| 2655 | TEST_F(AssemblerMIPSTest, SetReorder) { |
| 2656 | mips::MipsLabel label1, label2, label3, label4, label5, label6; |
| 2657 | |
| 2658 | __ SetReorder(true); |
| 2659 | __ Bind(&label1); |
| 2660 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2661 | __ B(&label1); |
| 2662 | __ B(&label5); |
| 2663 | __ B(&label6); |
| 2664 | |
| 2665 | __ SetReorder(false); |
| 2666 | __ Bind(&label2); |
| 2667 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2668 | __ B(&label2); |
| 2669 | __ B(&label5); |
| 2670 | __ B(&label6); |
| 2671 | |
| 2672 | __ SetReorder(true); |
| 2673 | __ Bind(&label3); |
| 2674 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2675 | __ B(&label3); |
| 2676 | __ B(&label5); |
| 2677 | __ B(&label6); |
| 2678 | |
| 2679 | __ SetReorder(false); |
| 2680 | __ Bind(&label4); |
| 2681 | __ Addu(mips::T0, mips::T1, mips::T2); |
| 2682 | __ B(&label4); |
| 2683 | __ B(&label5); |
| 2684 | __ B(&label6); |
| 2685 | |
| 2686 | __ SetReorder(true); |
| 2687 | __ Bind(&label5); |
| 2688 | __ Subu(mips::T0, mips::T1, mips::T2); |
| 2689 | |
| 2690 | __ SetReorder(false); |
| 2691 | __ Bind(&label6); |
| 2692 | __ Xor(mips::T0, mips::T1, mips::T2); |
| 2693 | |
| 2694 | std::string expected = |
| 2695 | ".set noreorder\n" |
| 2696 | "1:\n" |
| 2697 | "b 1b\n" |
| 2698 | "addu $t0, $t1, $t2\n" |
| 2699 | "b 55f\n" |
| 2700 | "subu $t0, $t1, $t2\n" |
| 2701 | "b 6f\n" |
| 2702 | "nop\n" |
| 2703 | |
| 2704 | "2:\n" |
| 2705 | "addu $t0, $t1, $t2\n" |
| 2706 | "b 2b\n" |
| 2707 | "nop\n" |
| 2708 | "b 5f\n" |
| 2709 | "nop\n" |
| 2710 | "b 6f\n" |
| 2711 | "nop\n" |
| 2712 | |
| 2713 | "3:\n" |
| 2714 | "b 3b\n" |
| 2715 | "addu $t0, $t1, $t2\n" |
| 2716 | "b 55f\n" |
| 2717 | "subu $t0, $t1, $t2\n" |
| 2718 | "b 6f\n" |
| 2719 | "nop\n" |
| 2720 | |
| 2721 | "4:\n" |
| 2722 | "addu $t0, $t1, $t2\n" |
| 2723 | "b 4b\n" |
| 2724 | "nop\n" |
| 2725 | "b 5f\n" |
| 2726 | "nop\n" |
| 2727 | "b 6f\n" |
| 2728 | "nop\n" |
| 2729 | |
| 2730 | "5:\n" |
| 2731 | "subu $t0, $t1, $t2\n" |
| 2732 | "55:\n" |
| 2733 | "6:\n" |
| 2734 | "xor $t0, $t1, $t2\n"; |
| 2735 | DriverStr(expected, "SetReorder"); |
| 2736 | } |
| 2737 | |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2738 | TEST_F(AssemblerMIPSTest, ReorderPatchedInstruction) { |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2739 | __ SetReorder(true); |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2740 | mips::MipsLabel label1, label2; |
| 2741 | mips::MipsLabel patcher_label1, patcher_label2, patcher_label3, patcher_label4, patcher_label5; |
| 2742 | __ Lw(mips::V0, mips::A0, 0x5678, &patcher_label1); |
| 2743 | __ Beq(mips::A0, mips::A1, &label1); |
| 2744 | constexpr uint32_t kAdduCount1 = 63; |
| 2745 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 2746 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2747 | } |
| 2748 | __ Bind(&label1); |
| 2749 | __ Sw(mips::V0, mips::A0, 0x5678, &patcher_label2); |
| 2750 | __ Bltz(mips::V1, &label2); |
| 2751 | constexpr uint32_t kAdduCount2 = 64; |
| 2752 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 2753 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2754 | } |
| 2755 | __ Bind(&label2); |
| 2756 | __ Addiu(mips::V0, mips::A0, 0x5678, &patcher_label3); |
| 2757 | __ B(&label1); |
| 2758 | __ Lw(mips::V0, mips::A0, 0x5678, &patcher_label4); |
| 2759 | __ Jalr(mips::T9); |
| 2760 | __ Sw(mips::V0, mips::A0, 0x5678, &patcher_label5); |
| 2761 | __ Blt(mips::V0, mips::V1, &label2); |
| 2762 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2763 | |
| 2764 | std::string expected = |
| 2765 | ".set noreorder\n" |
| 2766 | "beq $a0, $a1, 1f\n" |
| 2767 | "lw $v0, 0x5678($a0)\n" + |
| 2768 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") + |
| 2769 | "1:\n" |
| 2770 | "bltz $v1, 2f\n" |
| 2771 | "sw $v0, 0x5678($a0)\n" + |
| 2772 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") + |
| 2773 | "2:\n" |
| 2774 | "b 1b\n" |
| 2775 | "addiu $v0, $a0, 0x5678\n" |
| 2776 | "jalr $t9\n" |
| 2777 | "lw $v0, 0x5678($a0)\n" |
| 2778 | "slt $at, $v0, $v1\n" |
| 2779 | "bnez $at, 2b\n" |
| 2780 | "sw $v0, 0x5678($a0)\n" |
| 2781 | "addu $zero, $zero, $zero\n"; |
| 2782 | DriverStr(expected, "ReorderPatchedInstruction"); |
| 2783 | EXPECT_EQ(__ GetLabelLocation(&patcher_label1), 1 * 4u); |
| 2784 | EXPECT_EQ(__ GetLabelLocation(&patcher_label2), (kAdduCount1 + 3) * 4u); |
| 2785 | EXPECT_EQ(__ GetLabelLocation(&patcher_label3), (kAdduCount1 + kAdduCount2 + 5) * 4u); |
| 2786 | EXPECT_EQ(__ GetLabelLocation(&patcher_label4), (kAdduCount1 + kAdduCount2 + 7) * 4u); |
| 2787 | EXPECT_EQ(__ GetLabelLocation(&patcher_label5), (kAdduCount1 + kAdduCount2 + 10) * 4u); |
| 2788 | } |
| 2789 | |
| 2790 | TEST_F(AssemblerMIPSTest, LongBranchReorder) { |
| 2791 | mips::MipsLabel label, patcher_label1, patcher_label2; |
| 2792 | __ SetReorder(true); |
| 2793 | __ Addiu(mips::T0, mips::T1, 0x5678, &patcher_label1); |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2794 | __ B(&label); |
| 2795 | constexpr uint32_t kAdduCount1 = (1u << 15) + 1; |
| 2796 | for (size_t i = 0; i != kAdduCount1; ++i) { |
| 2797 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2798 | } |
| 2799 | __ Bind(&label); |
| 2800 | constexpr uint32_t kAdduCount2 = (1u << 15) + 1; |
| 2801 | for (size_t i = 0; i != kAdduCount2; ++i) { |
| 2802 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2803 | } |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2804 | __ Addiu(mips::T0, mips::T1, 0x5678, &patcher_label2); |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2805 | __ B(&label); |
| 2806 | |
| 2807 | // Account for 5 extra instructions: ori, addu, lw, jalr, addiu. |
| 2808 | uint32_t offset_forward = (kAdduCount1 + 5) * sizeof(uint32_t); |
| 2809 | // Account for 5 extra instructions: subu, addiu, sw, nal, lui. |
Andreas Gampe | 69489fa | 2017-06-08 18:03:25 -0700 | [diff] [blame] | 2810 | uint32_t offset_back = static_cast<uint32_t>(-(kAdduCount1 + 5) * sizeof(uint32_t)); |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2811 | |
| 2812 | std::ostringstream oss; |
| 2813 | oss << |
| 2814 | ".set noreorder\n" |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2815 | "addiu $t0, $t1, 0x5678\n" |
Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 2816 | "addiu $sp, $sp, -16\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2817 | "sw $ra, 0($sp)\n" |
| 2818 | "bltzal $zero, .+4\n" |
| 2819 | "lui $at, 0x" << std::hex << High16Bits(offset_forward) << "\n" |
| 2820 | "ori $at, $at, 0x" << std::hex << Low16Bits(offset_forward) << "\n" |
| 2821 | "addu $at, $at, $ra\n" |
| 2822 | "lw $ra, 0($sp)\n" |
| 2823 | "jalr $zero, $at\n" |
Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 2824 | "addiu $sp, $sp, 16\n" << |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2825 | RepeatInsn(kAdduCount1, "addu $zero, $zero, $zero\n") << |
| 2826 | RepeatInsn(kAdduCount2, "addu $zero, $zero, $zero\n") << |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2827 | "addiu $t0, $t1, 0x5678\n" |
Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 2828 | "addiu $sp, $sp, -16\n" |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2829 | "sw $ra, 0($sp)\n" |
| 2830 | "bltzal $zero, .+4\n" |
| 2831 | "lui $at, 0x" << std::hex << High16Bits(offset_back) << "\n" |
| 2832 | "ori $at, $at, 0x" << std::hex << Low16Bits(offset_back) << "\n" |
| 2833 | "addu $at, $at, $ra\n" |
| 2834 | "lw $ra, 0($sp)\n" |
| 2835 | "jalr $zero, $at\n" |
Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 2836 | "addiu $sp, $sp, 16\n"; |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2837 | std::string expected = oss.str(); |
| 2838 | DriverStr(expected, "LongBranchReorder"); |
Alexey Frunze | a663d9d | 2017-07-31 18:43:18 -0700 | [diff] [blame] | 2839 | EXPECT_EQ(__ GetLabelLocation(&patcher_label1), 0 * 4u); |
| 2840 | EXPECT_EQ(__ GetLabelLocation(&patcher_label2), (kAdduCount1 + kAdduCount2 + 10) * 4u); |
Alexey Frunze | 57eb0f5 | 2016-07-29 22:04:46 -0700 | [diff] [blame] | 2841 | } |
| 2842 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2843 | /////////////////////// |
| 2844 | // Loading Constants // |
| 2845 | /////////////////////// |
| 2846 | |
| 2847 | TEST_F(AssemblerMIPSTest, LoadConst32) { |
| 2848 | // IsUint<16>(value) |
| 2849 | __ LoadConst32(mips::V0, 0); |
| 2850 | __ LoadConst32(mips::V0, 65535); |
| 2851 | // IsInt<16>(value) |
| 2852 | __ LoadConst32(mips::V0, -1); |
| 2853 | __ LoadConst32(mips::V0, -32768); |
| 2854 | // Everything else |
| 2855 | __ LoadConst32(mips::V0, 65536); |
| 2856 | __ LoadConst32(mips::V0, 65537); |
| 2857 | __ LoadConst32(mips::V0, 2147483647); |
| 2858 | __ LoadConst32(mips::V0, -32769); |
| 2859 | __ LoadConst32(mips::V0, -65536); |
| 2860 | __ LoadConst32(mips::V0, -65537); |
| 2861 | __ LoadConst32(mips::V0, -2147483647); |
| 2862 | __ LoadConst32(mips::V0, -2147483648); |
| 2863 | |
| 2864 | const char* expected = |
| 2865 | // IsUint<16>(value) |
| 2866 | "ori $v0, $zero, 0\n" // __ LoadConst32(mips::V0, 0); |
| 2867 | "ori $v0, $zero, 65535\n" // __ LoadConst32(mips::V0, 65535); |
| 2868 | // IsInt<16>(value) |
| 2869 | "addiu $v0, $zero, -1\n" // __ LoadConst32(mips::V0, -1); |
| 2870 | "addiu $v0, $zero, -32768\n" // __ LoadConst32(mips::V0, -32768); |
| 2871 | // Everything else |
| 2872 | "lui $v0, 1\n" // __ LoadConst32(mips::V0, 65536); |
| 2873 | "lui $v0, 1\n" // __ LoadConst32(mips::V0, 65537); |
| 2874 | "ori $v0, 1\n" // " |
| 2875 | "lui $v0, 32767\n" // __ LoadConst32(mips::V0, 2147483647); |
| 2876 | "ori $v0, 65535\n" // " |
| 2877 | "lui $v0, 65535\n" // __ LoadConst32(mips::V0, -32769); |
| 2878 | "ori $v0, 32767\n" // " |
| 2879 | "lui $v0, 65535\n" // __ LoadConst32(mips::V0, -65536); |
| 2880 | "lui $v0, 65534\n" // __ LoadConst32(mips::V0, -65537); |
| 2881 | "ori $v0, 65535\n" // " |
| 2882 | "lui $v0, 32768\n" // __ LoadConst32(mips::V0, -2147483647); |
| 2883 | "ori $v0, 1\n" // " |
| 2884 | "lui $v0, 32768\n"; // __ LoadConst32(mips::V0, -2147483648); |
| 2885 | DriverStr(expected, "LoadConst32"); |
| 2886 | } |
| 2887 | |
| 2888 | TEST_F(AssemblerMIPSTest, LoadFarthestNearLabelAddress) { |
| 2889 | mips::MipsLabel label; |
| 2890 | __ BindPcRelBaseLabel(); |
| 2891 | __ LoadLabelAddress(mips::V0, mips::V1, &label); |
| 2892 | constexpr size_t kAddiuCount = 0x1FDE; |
| 2893 | for (size_t i = 0; i != kAddiuCount; ++i) { |
| 2894 | __ Addiu(mips::A0, mips::A1, 0); |
| 2895 | } |
| 2896 | __ Bind(&label); |
| 2897 | |
| 2898 | std::string expected = |
| 2899 | "1:\n" |
| 2900 | "addiu $v0, $v1, %lo(2f - 1b)\n" + |
| 2901 | RepeatInsn(kAddiuCount, "addiu $a0, $a1, %hi(2f - 1b)\n") + |
| 2902 | "2:\n"; |
| 2903 | DriverStr(expected, "LoadFarthestNearLabelAddress"); |
| 2904 | } |
| 2905 | |
| 2906 | TEST_F(AssemblerMIPSTest, LoadNearestFarLabelAddress) { |
| 2907 | mips::MipsLabel label; |
| 2908 | __ BindPcRelBaseLabel(); |
| 2909 | __ LoadLabelAddress(mips::V0, mips::V1, &label); |
| 2910 | constexpr size_t kAdduCount = 0x1FDF; |
| 2911 | for (size_t i = 0; i != kAdduCount; ++i) { |
| 2912 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2913 | } |
| 2914 | __ Bind(&label); |
| 2915 | |
| 2916 | std::string expected = |
| 2917 | "1:\n" |
| 2918 | "lui $at, %hi(2f - 1b)\n" |
| 2919 | "ori $at, $at, %lo(2f - 1b)\n" |
| 2920 | "addu $v0, $at, $v1\n" + |
| 2921 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 2922 | "2:\n"; |
| 2923 | DriverStr(expected, "LoadNearestFarLabelAddress"); |
| 2924 | } |
| 2925 | |
Alexey Frunze | 3b8c82f | 2017-10-10 23:01:34 -0700 | [diff] [blame] | 2926 | TEST_F(AssemblerMIPSTest, LoadFarthestNearLabelAddressUsingNal) { |
| 2927 | mips::MipsLabel label; |
| 2928 | __ LoadLabelAddress(mips::V0, mips::ZERO, &label); |
| 2929 | constexpr size_t kAddiuCount = 0x1FDE; |
| 2930 | for (size_t i = 0; i != kAddiuCount; ++i) { |
| 2931 | __ Addiu(mips::A0, mips::A1, 0); |
| 2932 | } |
| 2933 | __ Bind(&label); |
| 2934 | |
| 2935 | std::string expected = |
| 2936 | ".set noreorder\n" |
| 2937 | "bltzal $zero, .+4\n" |
| 2938 | "addiu $v0, $ra, %lo(2f - 1f)\n" |
| 2939 | "1:\n" + |
| 2940 | RepeatInsn(kAddiuCount, "addiu $a0, $a1, %hi(2f - 1b)\n") + |
| 2941 | "2:\n"; |
| 2942 | DriverStr(expected, "LoadFarthestNearLabelAddressUsingNal"); |
| 2943 | } |
| 2944 | |
| 2945 | TEST_F(AssemblerMIPSTest, LoadNearestFarLabelAddressUsingNal) { |
| 2946 | mips::MipsLabel label; |
| 2947 | __ LoadLabelAddress(mips::V0, mips::ZERO, &label); |
| 2948 | constexpr size_t kAdduCount = 0x1FDF; |
| 2949 | for (size_t i = 0; i != kAdduCount; ++i) { |
| 2950 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2951 | } |
| 2952 | __ Bind(&label); |
| 2953 | |
| 2954 | std::string expected = |
| 2955 | ".set noreorder\n" |
| 2956 | "bltzal $zero, .+4\n" |
| 2957 | "lui $at, %hi(2f - 1f)\n" |
| 2958 | "1:\n" |
| 2959 | "ori $at, $at, %lo(2f - 1b)\n" |
| 2960 | "addu $v0, $at, $ra\n" + |
| 2961 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 2962 | "2:\n"; |
| 2963 | DriverStr(expected, "LoadNearestFarLabelAddressUsingNal"); |
| 2964 | } |
| 2965 | |
Alexey Frunze | 0cab656 | 2017-07-25 15:19:36 -0700 | [diff] [blame] | 2966 | TEST_F(AssemblerMIPSTest, LoadFarthestNearLiteral) { |
| 2967 | mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 2968 | __ BindPcRelBaseLabel(); |
| 2969 | __ LoadLiteral(mips::V0, mips::V1, literal); |
| 2970 | constexpr size_t kAddiuCount = 0x1FDE; |
| 2971 | for (size_t i = 0; i != kAddiuCount; ++i) { |
| 2972 | __ Addiu(mips::A0, mips::A1, 0); |
| 2973 | } |
| 2974 | |
| 2975 | std::string expected = |
| 2976 | "1:\n" |
| 2977 | "lw $v0, %lo(2f - 1b)($v1)\n" + |
| 2978 | RepeatInsn(kAddiuCount, "addiu $a0, $a1, %hi(2f - 1b)\n") + |
| 2979 | "2:\n" |
| 2980 | ".word 0x12345678\n"; |
| 2981 | DriverStr(expected, "LoadFarthestNearLiteral"); |
| 2982 | } |
| 2983 | |
| 2984 | TEST_F(AssemblerMIPSTest, LoadNearestFarLiteral) { |
| 2985 | mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 2986 | __ BindPcRelBaseLabel(); |
| 2987 | __ LoadLiteral(mips::V0, mips::V1, literal); |
| 2988 | constexpr size_t kAdduCount = 0x1FDF; |
| 2989 | for (size_t i = 0; i != kAdduCount; ++i) { |
| 2990 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 2991 | } |
| 2992 | |
| 2993 | std::string expected = |
| 2994 | "1:\n" |
| 2995 | "lui $at, %hi(2f - 1b)\n" |
| 2996 | "addu $at, $at, $v1\n" |
| 2997 | "lw $v0, %lo(2f - 1b)($at)\n" + |
| 2998 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 2999 | "2:\n" |
| 3000 | ".word 0x12345678\n"; |
| 3001 | DriverStr(expected, "LoadNearestFarLiteral"); |
| 3002 | } |
| 3003 | |
Alexey Frunze | 3b8c82f | 2017-10-10 23:01:34 -0700 | [diff] [blame] | 3004 | TEST_F(AssemblerMIPSTest, LoadFarthestNearLiteralUsingNal) { |
| 3005 | mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 3006 | __ LoadLiteral(mips::V0, mips::ZERO, literal); |
| 3007 | constexpr size_t kAddiuCount = 0x1FDE; |
| 3008 | for (size_t i = 0; i != kAddiuCount; ++i) { |
| 3009 | __ Addiu(mips::A0, mips::A1, 0); |
| 3010 | } |
| 3011 | |
| 3012 | std::string expected = |
| 3013 | ".set noreorder\n" |
| 3014 | "bltzal $zero, .+4\n" |
| 3015 | "lw $v0, %lo(2f - 1f)($ra)\n" |
| 3016 | "1:\n" + |
| 3017 | RepeatInsn(kAddiuCount, "addiu $a0, $a1, %hi(2f - 1b)\n") + |
| 3018 | "2:\n" |
| 3019 | ".word 0x12345678\n"; |
| 3020 | DriverStr(expected, "LoadFarthestNearLiteralUsingNal"); |
| 3021 | } |
| 3022 | |
| 3023 | TEST_F(AssemblerMIPSTest, LoadNearestFarLiteralUsingNal) { |
| 3024 | mips::Literal* literal = __ NewLiteral<uint32_t>(0x12345678); |
| 3025 | __ LoadLiteral(mips::V0, mips::ZERO, literal); |
| 3026 | constexpr size_t kAdduCount = 0x1FDF; |
| 3027 | for (size_t i = 0; i != kAdduCount; ++i) { |
| 3028 | __ Addu(mips::ZERO, mips::ZERO, mips::ZERO); |
| 3029 | } |
| 3030 | |
| 3031 | std::string expected = |
| 3032 | ".set noreorder\n" |
| 3033 | "bltzal $zero, .+4\n" |
| 3034 | "lui $at, %hi(2f - 1f)\n" |
| 3035 | "1:\n" |
| 3036 | "addu $at, $at, $ra\n" |
| 3037 | "lw $v0, %lo(2f - 1b)($at)\n" + |
| 3038 | RepeatInsn(kAdduCount, "addu $zero, $zero, $zero\n") + |
| 3039 | "2:\n" |
| 3040 | ".word 0x12345678\n"; |
| 3041 | DriverStr(expected, "LoadNearestFarLiteralUsingNal"); |
| 3042 | } |
| 3043 | |
Goran Jakovljevic | 8c434dc | 2015-08-26 14:39:44 +0200 | [diff] [blame] | 3044 | #undef __ |
| 3045 | |
| 3046 | } // namespace art |