| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 1 | /* | 
 | 2 |  * Copyright (C) 2016 The Android Open Source Project | 
 | 3 |  * | 
 | 4 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
 | 5 |  * you may not use this file except in compliance with the License. | 
 | 6 |  * You may obtain a copy of the License at | 
 | 7 |  * | 
 | 8 |  *      http://www.apache.org/licenses/LICENSE-2.0 | 
 | 9 |  * | 
 | 10 |  * Unless required by applicable law or agreed to in writing, software | 
 | 11 |  * distributed under the License is distributed on an "AS IS" BASIS, | 
 | 12 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
 | 13 |  * See the License for the specific language governing permissions and | 
 | 14 |  * limitations under the License. | 
 | 15 |  */ | 
 | 16 |  | 
 | 17 | #include "base/arena_allocator.h" | 
 | 18 | #include "code_generator_mips.h" | 
 | 19 | #include "optimizing_unit_test.h" | 
 | 20 | #include "parallel_move_resolver.h" | 
 | 21 | #include "utils/assembler_test_base.h" | 
 | 22 | #include "utils/mips/assembler_mips.h" | 
 | 23 |  | 
 | 24 | #include "gtest/gtest.h" | 
 | 25 |  | 
| Vladimir Marko | 0a51605 | 2019-10-14 13:00:44 +0000 | [diff] [blame^] | 26 | namespace art { | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 27 |  | 
| Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 28 | class EmitSwapMipsTest : public OptimizingUnitTest { | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 29 |  public: | 
| Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 30 |   void SetUp() override { | 
| Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 31 |     instruction_set_ = InstructionSet::kMips; | 
 | 32 |     instruction_set_features_ = MipsInstructionSetFeatures::FromCppDefines(); | 
 | 33 |     OptimizingUnitTest::SetUp(); | 
| Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 34 |     graph_ = CreateGraph(); | 
| Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 35 |     codegen_.reset( | 
 | 36 |         new (graph_->GetAllocator()) mips::CodeGeneratorMIPS(graph_, *compiler_options_)); | 
| Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 37 |     moves_ = new (GetAllocator()) HParallelMove(GetAllocator()); | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 38 |     test_helper_.reset( | 
 | 39 |         new AssemblerTestInfrastructure(GetArchitectureString(), | 
 | 40 |                                         GetAssemblerCmdName(), | 
 | 41 |                                         GetAssemblerParameters(), | 
 | 42 |                                         GetObjdumpCmdName(), | 
 | 43 |                                         GetObjdumpParameters(), | 
 | 44 |                                         GetDisassembleCmdName(), | 
 | 45 |                                         GetDisassembleParameters(), | 
 | 46 |                                         GetAssemblyHeader())); | 
 | 47 |   } | 
 | 48 |  | 
| Roland Levillain | bbc6e7e | 2018-08-24 16:58:47 +0100 | [diff] [blame] | 49 |   void TearDown() override { | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 50 |     test_helper_.reset(); | 
| Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 51 |     codegen_.reset(); | 
 | 52 |     graph_ = nullptr; | 
| Vladimir Marko | ca6fff8 | 2017-10-03 14:49:14 +0100 | [diff] [blame] | 53 |     ResetPoolAndAllocator(); | 
| Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 54 |     OptimizingUnitTest::TearDown(); | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 55 |   } | 
 | 56 |  | 
 | 57 |   // Get the typically used name for this architecture. | 
 | 58 |   std::string GetArchitectureString() { | 
 | 59 |     return "mips"; | 
 | 60 |   } | 
 | 61 |  | 
 | 62 |   // Get the name of the assembler. | 
 | 63 |   std::string GetAssemblerCmdName() { | 
 | 64 |     return "as"; | 
 | 65 |   } | 
 | 66 |  | 
 | 67 |   // Switches to the assembler command. | 
 | 68 |   std::string GetAssemblerParameters() { | 
 | 69 |     return " --no-warn -32 -march=mips32r2"; | 
 | 70 |   } | 
 | 71 |  | 
 | 72 |   // Get the name of the objdump. | 
 | 73 |   std::string GetObjdumpCmdName() { | 
 | 74 |     return "objdump"; | 
 | 75 |   } | 
 | 76 |  | 
 | 77 |   // Switches to the objdump command. | 
 | 78 |   std::string GetObjdumpParameters() { | 
 | 79 |     return " -h"; | 
 | 80 |   } | 
 | 81 |  | 
 | 82 |   // Get the name of the objdump. | 
 | 83 |   std::string GetDisassembleCmdName() { | 
 | 84 |     return "objdump"; | 
 | 85 |   } | 
 | 86 |  | 
 | 87 |   // Switches to the objdump command. | 
 | 88 |   std::string GetDisassembleParameters() { | 
 | 89 |     return " -D -bbinary -mmips:isa32r2"; | 
 | 90 |   } | 
 | 91 |  | 
 | 92 |   // No need for assembly header here. | 
 | 93 |   const char* GetAssemblyHeader() { | 
 | 94 |     return nullptr; | 
 | 95 |   } | 
 | 96 |  | 
| Andreas Gampe | 641a473 | 2017-08-24 13:21:35 -0700 | [diff] [blame] | 97 |   void DriverWrapper(HParallelMove* move, | 
 | 98 |                      const std::string& assembly_text, | 
 | 99 |                      const std::string& test_name) { | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 100 |     codegen_->GetMoveResolver()->EmitNativeCode(move); | 
 | 101 |     assembler_ = codegen_->GetAssembler(); | 
 | 102 |     assembler_->FinalizeCode(); | 
 | 103 |     std::unique_ptr<std::vector<uint8_t>> data(new std::vector<uint8_t>(assembler_->CodeSize())); | 
 | 104 |     MemoryRegion code(&(*data)[0], data->size()); | 
 | 105 |     assembler_->FinalizeInstructions(code); | 
 | 106 |     test_helper_->Driver(*data, assembly_text, test_name); | 
 | 107 |   } | 
 | 108 |  | 
 | 109 |  protected: | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 110 |   HGraph* graph_; | 
 | 111 |   HParallelMove* moves_; | 
| Vladimir Marko | a043111 | 2018-06-25 09:32:54 +0100 | [diff] [blame] | 112 |   std::unique_ptr<mips::CodeGeneratorMIPS> codegen_; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 113 |   mips::MipsAssembler* assembler_; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 114 |   std::unique_ptr<AssemblerTestInfrastructure> test_helper_; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 115 | }; | 
 | 116 |  | 
 | 117 | TEST_F(EmitSwapMipsTest, TwoRegisters) { | 
 | 118 |   moves_->AddMove( | 
 | 119 |       Location::RegisterLocation(4), | 
 | 120 |       Location::RegisterLocation(5), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 121 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 122 |       nullptr); | 
 | 123 |   moves_->AddMove( | 
 | 124 |       Location::RegisterLocation(5), | 
 | 125 |       Location::RegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 126 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 127 |       nullptr); | 
 | 128 |   const char* expected = | 
 | 129 |       "or $t8, $a1, $zero\n" | 
 | 130 |       "or $a1, $a0, $zero\n" | 
 | 131 |       "or $a0, $t8, $zero\n"; | 
 | 132 |   DriverWrapper(moves_, expected, "TwoRegisters"); | 
 | 133 | } | 
 | 134 |  | 
 | 135 | TEST_F(EmitSwapMipsTest, TwoRegisterPairs) { | 
 | 136 |   moves_->AddMove( | 
 | 137 |       Location::RegisterPairLocation(4, 5), | 
 | 138 |       Location::RegisterPairLocation(6, 7), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 139 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 140 |       nullptr); | 
 | 141 |   moves_->AddMove( | 
 | 142 |       Location::RegisterPairLocation(6, 7), | 
 | 143 |       Location::RegisterPairLocation(4, 5), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 144 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 145 |       nullptr); | 
 | 146 |   const char* expected = | 
 | 147 |       "or $t8, $a2, $zero\n" | 
 | 148 |       "or $a2, $a0, $zero\n" | 
 | 149 |       "or $a0, $t8, $zero\n" | 
 | 150 |       "or $t8, $a3, $zero\n" | 
 | 151 |       "or $a3, $a1, $zero\n" | 
 | 152 |       "or $a1, $t8, $zero\n"; | 
 | 153 |   DriverWrapper(moves_, expected, "TwoRegisterPairs"); | 
 | 154 | } | 
 | 155 |  | 
 | 156 | TEST_F(EmitSwapMipsTest, TwoFpuRegistersFloat) { | 
 | 157 |   moves_->AddMove( | 
 | 158 |       Location::FpuRegisterLocation(4), | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 159 |       Location::FpuRegisterLocation(2), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 160 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 161 |       nullptr); | 
 | 162 |   moves_->AddMove( | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 163 |       Location::FpuRegisterLocation(2), | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 164 |       Location::FpuRegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 165 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 166 |       nullptr); | 
 | 167 |   const char* expected = | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 168 |       "mov.s $f6, $f2\n" | 
 | 169 |       "mov.s $f2, $f4\n" | 
 | 170 |       "mov.s $f4, $f6\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 171 |   DriverWrapper(moves_, expected, "TwoFpuRegistersFloat"); | 
 | 172 | } | 
 | 173 |  | 
 | 174 | TEST_F(EmitSwapMipsTest, TwoFpuRegistersDouble) { | 
 | 175 |   moves_->AddMove( | 
 | 176 |       Location::FpuRegisterLocation(4), | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 177 |       Location::FpuRegisterLocation(2), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 178 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 179 |       nullptr); | 
 | 180 |   moves_->AddMove( | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 181 |       Location::FpuRegisterLocation(2), | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 182 |       Location::FpuRegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 183 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 184 |       nullptr); | 
 | 185 |   const char* expected = | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 186 |       "mov.d $f6, $f2\n" | 
 | 187 |       "mov.d $f2, $f4\n" | 
 | 188 |       "mov.d $f4, $f6\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 189 |   DriverWrapper(moves_, expected, "TwoFpuRegistersDouble"); | 
 | 190 | } | 
 | 191 |  | 
 | 192 | TEST_F(EmitSwapMipsTest, RegisterAndFpuRegister) { | 
 | 193 |   moves_->AddMove( | 
 | 194 |       Location::RegisterLocation(4), | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 195 |       Location::FpuRegisterLocation(2), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 196 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 197 |       nullptr); | 
 | 198 |   moves_->AddMove( | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 199 |       Location::FpuRegisterLocation(2), | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 200 |       Location::RegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 201 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 202 |       nullptr); | 
 | 203 |   const char* expected = | 
 | 204 |       "or $t8, $a0, $zero\n" | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 205 |       "mfc1 $a0, $f2\n" | 
 | 206 |       "mtc1 $t8, $f2\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 207 |   DriverWrapper(moves_, expected, "RegisterAndFpuRegister"); | 
 | 208 | } | 
 | 209 |  | 
 | 210 | TEST_F(EmitSwapMipsTest, RegisterPairAndFpuRegister) { | 
 | 211 |   moves_->AddMove( | 
 | 212 |       Location::RegisterPairLocation(4, 5), | 
 | 213 |       Location::FpuRegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 214 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 215 |       nullptr); | 
 | 216 |   moves_->AddMove( | 
 | 217 |       Location::FpuRegisterLocation(4), | 
 | 218 |       Location::RegisterPairLocation(4, 5), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 219 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 220 |       nullptr); | 
 | 221 |   const char* expected = | 
 | 222 |       "mfc1 $t8, $f4\n" | 
 | 223 |       "mfc1 $at, $f5\n" | 
 | 224 |       "mtc1 $a0, $f4\n" | 
 | 225 |       "mtc1 $a1, $f5\n" | 
 | 226 |       "or $a0, $t8, $zero\n" | 
 | 227 |       "or $a1, $at, $zero\n"; | 
 | 228 |   DriverWrapper(moves_, expected, "RegisterPairAndFpuRegister"); | 
 | 229 | } | 
 | 230 |  | 
 | 231 | TEST_F(EmitSwapMipsTest, TwoStackSlots) { | 
 | 232 |   moves_->AddMove( | 
 | 233 |       Location::StackSlot(52), | 
 | 234 |       Location::StackSlot(48), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 235 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 236 |       nullptr); | 
 | 237 |   moves_->AddMove( | 
 | 238 |       Location::StackSlot(48), | 
 | 239 |       Location::StackSlot(52), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 240 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 241 |       nullptr); | 
 | 242 |   const char* expected = | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 243 |       "addiu $sp, $sp, -16\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 244 |       "sw $v0, 0($sp)\n" | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 245 |       "lw $v0, 68($sp)\n" | 
 | 246 |       "lw $t8, 64($sp)\n" | 
 | 247 |       "sw $v0, 64($sp)\n" | 
 | 248 |       "sw $t8, 68($sp)\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 249 |       "lw $v0, 0($sp)\n" | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 250 |       "addiu $sp, $sp, 16\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 251 |   DriverWrapper(moves_, expected, "TwoStackSlots"); | 
 | 252 | } | 
 | 253 |  | 
 | 254 | TEST_F(EmitSwapMipsTest, TwoDoubleStackSlots) { | 
 | 255 |   moves_->AddMove( | 
 | 256 |       Location::DoubleStackSlot(56), | 
 | 257 |       Location::DoubleStackSlot(48), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 258 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 259 |       nullptr); | 
 | 260 |   moves_->AddMove( | 
 | 261 |       Location::DoubleStackSlot(48), | 
 | 262 |       Location::DoubleStackSlot(56), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 263 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 264 |       nullptr); | 
 | 265 |   const char* expected = | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 266 |       "addiu $sp, $sp, -16\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 267 |       "sw $v0, 0($sp)\n" | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 268 |       "lw $v0, 72($sp)\n" | 
 | 269 |       "lw $t8, 64($sp)\n" | 
 | 270 |       "sw $v0, 64($sp)\n" | 
 | 271 |       "sw $t8, 72($sp)\n" | 
 | 272 |       "lw $v0, 76($sp)\n" | 
 | 273 |       "lw $t8, 68($sp)\n" | 
 | 274 |       "sw $v0, 68($sp)\n" | 
 | 275 |       "sw $t8, 76($sp)\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 276 |       "lw $v0, 0($sp)\n" | 
| Chris Larsen | 715f43e | 2017-10-23 11:00:32 -0700 | [diff] [blame] | 277 |       "addiu $sp, $sp, 16\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 278 |   DriverWrapper(moves_, expected, "TwoDoubleStackSlots"); | 
 | 279 | } | 
 | 280 |  | 
 | 281 | TEST_F(EmitSwapMipsTest, RegisterAndStackSlot) { | 
 | 282 |   moves_->AddMove( | 
 | 283 |       Location::RegisterLocation(4), | 
 | 284 |       Location::StackSlot(48), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 285 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 286 |       nullptr); | 
 | 287 |   moves_->AddMove( | 
 | 288 |       Location::StackSlot(48), | 
 | 289 |       Location::RegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 290 |       DataType::Type::kInt32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 291 |       nullptr); | 
 | 292 |   const char* expected = | 
 | 293 |       "or $t8, $a0, $zero\n" | 
 | 294 |       "lw $a0, 48($sp)\n" | 
 | 295 |       "sw $t8, 48($sp)\n"; | 
 | 296 |   DriverWrapper(moves_, expected, "RegisterAndStackSlot"); | 
 | 297 | } | 
 | 298 |  | 
 | 299 | TEST_F(EmitSwapMipsTest, RegisterPairAndDoubleStackSlot) { | 
 | 300 |   moves_->AddMove( | 
 | 301 |       Location::RegisterPairLocation(4, 5), | 
 | 302 |       Location::DoubleStackSlot(32), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 303 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 304 |       nullptr); | 
 | 305 |   moves_->AddMove( | 
 | 306 |       Location::DoubleStackSlot(32), | 
 | 307 |       Location::RegisterPairLocation(4, 5), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 308 |       DataType::Type::kInt64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 309 |       nullptr); | 
 | 310 |   const char* expected = | 
 | 311 |       "or $t8, $a0, $zero\n" | 
 | 312 |       "lw $a0, 32($sp)\n" | 
 | 313 |       "sw $t8, 32($sp)\n" | 
 | 314 |       "or $t8, $a1, $zero\n" | 
 | 315 |       "lw $a1, 36($sp)\n" | 
 | 316 |       "sw $t8, 36($sp)\n"; | 
 | 317 |   DriverWrapper(moves_, expected, "RegisterPairAndDoubleStackSlot"); | 
 | 318 | } | 
 | 319 |  | 
 | 320 | TEST_F(EmitSwapMipsTest, FpuRegisterAndStackSlot) { | 
 | 321 |   moves_->AddMove( | 
 | 322 |       Location::FpuRegisterLocation(4), | 
 | 323 |       Location::StackSlot(48), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 324 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 325 |       nullptr); | 
 | 326 |   moves_->AddMove( | 
 | 327 |       Location::StackSlot(48), | 
 | 328 |       Location::FpuRegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 329 |       DataType::Type::kFloat32, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 330 |       nullptr); | 
 | 331 |   const char* expected = | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 332 |       "mov.s $f6, $f4\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 333 |       "lwc1 $f4, 48($sp)\n" | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 334 |       "swc1 $f6, 48($sp)\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 335 |   DriverWrapper(moves_, expected, "FpuRegisterAndStackSlot"); | 
 | 336 | } | 
 | 337 |  | 
 | 338 | TEST_F(EmitSwapMipsTest, FpuRegisterAndDoubleStackSlot) { | 
 | 339 |   moves_->AddMove( | 
 | 340 |       Location::FpuRegisterLocation(4), | 
 | 341 |       Location::DoubleStackSlot(48), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 342 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 343 |       nullptr); | 
 | 344 |   moves_->AddMove( | 
 | 345 |       Location::DoubleStackSlot(48), | 
 | 346 |       Location::FpuRegisterLocation(4), | 
| Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 347 |       DataType::Type::kFloat64, | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 348 |       nullptr); | 
 | 349 |   const char* expected = | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 350 |       "mov.d $f6, $f4\n" | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 351 |       "ldc1 $f4, 48($sp)\n" | 
| Alexey Frunze | 1b8464d | 2016-11-12 17:22:05 -0800 | [diff] [blame] | 352 |       "sdc1 $f6, 48($sp)\n"; | 
| Goran Jakovljevic | 35dfcaa | 2016-09-22 09:26:01 +0200 | [diff] [blame] | 353 |   DriverWrapper(moves_, expected, "FpuRegisterAndDoubleStackSlot"); | 
 | 354 | } | 
 | 355 |  | 
 | 356 | }  // namespace art |