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