xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
Andreas Gampe | 8cf9cb3 | 2017-07-19 09:28:38 -0700 | [diff] [blame] | 17 | #include "scheduler_arm.h" |
| 18 | |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 19 | #include "arch/arm/instruction_set_features_arm.h" |
| 20 | #include "code_generator_utils.h" |
| 21 | #include "common_arm.h" |
Andreas Gampe | 09659c2 | 2017-09-18 18:23:32 -0700 | [diff] [blame] | 22 | #include "heap_poisoning.h" |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 23 | #include "mirror/array-inl.h" |
Andreas Gampe | 895f922 | 2017-07-05 09:53:32 -0700 | [diff] [blame] | 24 | #include "mirror/string.h" |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 25 | |
Vladimir Marko | 0a51605 | 2019-10-14 13:00:44 +0000 | [diff] [blame] | 26 | namespace art { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 27 | namespace arm { |
| 28 | |
| 29 | using helpers::Int32ConstantFrom; |
| 30 | using helpers::Uint64ConstantFrom; |
| 31 | |
| 32 | void SchedulingLatencyVisitorARM::HandleBinaryOperationLantencies(HBinaryOperation* instr) { |
| 33 | switch (instr->GetResultType()) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 34 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 35 | // HAdd and HSub long operations translate to ADDS+ADC or SUBS+SBC pairs, |
| 36 | // so a bubble (kArmNopLatency) is added to represent the internal carry flag |
| 37 | // dependency inside these pairs. |
| 38 | last_visited_internal_latency_ = kArmIntegerOpLatency + kArmNopLatency; |
| 39 | last_visited_latency_ = kArmIntegerOpLatency; |
| 40 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 41 | case DataType::Type::kFloat32: |
| 42 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 43 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 44 | break; |
| 45 | default: |
| 46 | last_visited_latency_ = kArmIntegerOpLatency; |
| 47 | break; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void SchedulingLatencyVisitorARM::VisitAdd(HAdd* instr) { |
| 52 | HandleBinaryOperationLantencies(instr); |
| 53 | } |
| 54 | |
| 55 | void SchedulingLatencyVisitorARM::VisitSub(HSub* instr) { |
| 56 | HandleBinaryOperationLantencies(instr); |
| 57 | } |
| 58 | |
| 59 | void SchedulingLatencyVisitorARM::VisitMul(HMul* instr) { |
| 60 | switch (instr->GetResultType()) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 61 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 62 | last_visited_internal_latency_ = 3 * kArmMulIntegerLatency; |
| 63 | last_visited_latency_ = kArmIntegerOpLatency; |
| 64 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 65 | case DataType::Type::kFloat32: |
| 66 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 67 | last_visited_latency_ = kArmMulFloatingPointLatency; |
| 68 | break; |
| 69 | default: |
| 70 | last_visited_latency_ = kArmMulIntegerLatency; |
| 71 | break; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | void SchedulingLatencyVisitorARM::HandleBitwiseOperationLantencies(HBinaryOperation* instr) { |
| 76 | switch (instr->GetResultType()) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 77 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 78 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 79 | last_visited_latency_ = kArmIntegerOpLatency; |
| 80 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 81 | case DataType::Type::kFloat32: |
| 82 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 83 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 84 | break; |
| 85 | default: |
| 86 | last_visited_latency_ = kArmIntegerOpLatency; |
| 87 | break; |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | void SchedulingLatencyVisitorARM::VisitAnd(HAnd* instr) { |
| 92 | HandleBitwiseOperationLantencies(instr); |
| 93 | } |
| 94 | |
| 95 | void SchedulingLatencyVisitorARM::VisitOr(HOr* instr) { |
| 96 | HandleBitwiseOperationLantencies(instr); |
| 97 | } |
| 98 | |
| 99 | void SchedulingLatencyVisitorARM::VisitXor(HXor* instr) { |
| 100 | HandleBitwiseOperationLantencies(instr); |
| 101 | } |
| 102 | |
| 103 | void SchedulingLatencyVisitorARM::VisitRor(HRor* instr) { |
| 104 | switch (instr->GetResultType()) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 105 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 106 | last_visited_latency_ = kArmIntegerOpLatency; |
| 107 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 108 | case DataType::Type::kInt64: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 109 | // HandleLongRotate |
| 110 | HInstruction* rhs = instr->GetRight(); |
| 111 | if (rhs->IsConstant()) { |
| 112 | uint64_t rot = Uint64ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance; |
| 113 | if (rot != 0u) { |
| 114 | last_visited_internal_latency_ = 3 * kArmIntegerOpLatency; |
| 115 | last_visited_latency_ = kArmIntegerOpLatency; |
| 116 | } else { |
| 117 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 118 | last_visited_latency_ = kArmIntegerOpLatency; |
| 119 | } |
| 120 | } else { |
| 121 | last_visited_internal_latency_ = 9 * kArmIntegerOpLatency + kArmBranchLatency; |
| 122 | last_visited_latency_ = kArmBranchLatency; |
| 123 | } |
| 124 | break; |
| 125 | } |
| 126 | default: |
| 127 | LOG(FATAL) << "Unexpected operation type " << instr->GetResultType(); |
| 128 | UNREACHABLE(); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | void SchedulingLatencyVisitorARM::HandleShiftLatencies(HBinaryOperation* instr) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 133 | DataType::Type type = instr->GetResultType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 134 | HInstruction* rhs = instr->GetRight(); |
| 135 | switch (type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 136 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 137 | if (!rhs->IsConstant()) { |
| 138 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 139 | } |
| 140 | last_visited_latency_ = kArmIntegerOpLatency; |
| 141 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 142 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 143 | if (!rhs->IsConstant()) { |
| 144 | last_visited_internal_latency_ = 8 * kArmIntegerOpLatency; |
| 145 | } else { |
| 146 | uint32_t shift_value = Int32ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance; |
| 147 | if (shift_value == 1 || shift_value >= 32) { |
| 148 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 149 | } else { |
| 150 | last_visited_internal_latency_ = 2 * kArmIntegerOpLatency; |
| 151 | } |
| 152 | } |
| 153 | last_visited_latency_ = kArmIntegerOpLatency; |
| 154 | break; |
| 155 | default: |
| 156 | LOG(FATAL) << "Unexpected operation type " << type; |
| 157 | UNREACHABLE(); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | void SchedulingLatencyVisitorARM::VisitShl(HShl* instr) { |
| 162 | HandleShiftLatencies(instr); |
| 163 | } |
| 164 | |
| 165 | void SchedulingLatencyVisitorARM::VisitShr(HShr* instr) { |
| 166 | HandleShiftLatencies(instr); |
| 167 | } |
| 168 | |
| 169 | void SchedulingLatencyVisitorARM::VisitUShr(HUShr* instr) { |
| 170 | HandleShiftLatencies(instr); |
| 171 | } |
| 172 | |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 173 | void SchedulingLatencyVisitorARM::HandleGenerateConditionWithZero(IfCondition condition) { |
| 174 | switch (condition) { |
| 175 | case kCondEQ: |
| 176 | case kCondBE: |
| 177 | case kCondNE: |
| 178 | case kCondA: |
| 179 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 180 | last_visited_latency_ = kArmIntegerOpLatency; |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 181 | break; |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 182 | case kCondGE: |
| 183 | // Mvn |
| 184 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 185 | FALLTHROUGH_INTENDED; |
| 186 | case kCondLT: |
| 187 | // Lsr |
| 188 | last_visited_latency_ = kArmIntegerOpLatency; |
| 189 | break; |
| 190 | case kCondAE: |
| 191 | // Trivially true. |
| 192 | // Mov |
| 193 | last_visited_latency_ = kArmIntegerOpLatency; |
| 194 | break; |
| 195 | case kCondB: |
| 196 | // Trivially false. |
| 197 | // Mov |
| 198 | last_visited_latency_ = kArmIntegerOpLatency; |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 199 | break; |
| 200 | default: |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 201 | LOG(FATAL) << "Unexpected condition " << condition; |
| 202 | UNREACHABLE(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 203 | } |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 204 | } |
| 205 | |
| 206 | void SchedulingLatencyVisitorARM::HandleGenerateLongTestConstant(HCondition* condition) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 207 | DCHECK_EQ(condition->GetLeft()->GetType(), DataType::Type::kInt64); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 208 | |
| 209 | IfCondition cond = condition->GetCondition(); |
| 210 | |
| 211 | HInstruction* right = condition->InputAt(1); |
| 212 | |
| 213 | int64_t value = Uint64ConstantFrom(right); |
| 214 | |
| 215 | // Comparisons against 0 are common enough, so codegen has special handling for them. |
| 216 | if (value == 0) { |
| 217 | switch (cond) { |
| 218 | case kCondNE: |
| 219 | case kCondA: |
| 220 | case kCondEQ: |
| 221 | case kCondBE: |
| 222 | // Orrs |
| 223 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 224 | return; |
| 225 | case kCondLT: |
| 226 | case kCondGE: |
| 227 | // Cmp |
| 228 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 229 | return; |
| 230 | case kCondB: |
| 231 | case kCondAE: |
| 232 | // Cmp |
| 233 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 234 | return; |
| 235 | default: |
| 236 | break; |
| 237 | } |
| 238 | } |
| 239 | |
| 240 | switch (cond) { |
| 241 | case kCondEQ: |
| 242 | case kCondNE: |
| 243 | case kCondB: |
| 244 | case kCondBE: |
| 245 | case kCondA: |
| 246 | case kCondAE: { |
| 247 | // Cmp, IT, Cmp |
| 248 | last_visited_internal_latency_ += 3 * kArmIntegerOpLatency; |
| 249 | break; |
| 250 | } |
| 251 | case kCondLE: |
| 252 | case kCondGT: |
| 253 | // Trivially true or false. |
| 254 | if (value == std::numeric_limits<int64_t>::max()) { |
| 255 | // Cmp |
| 256 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 257 | break; |
| 258 | } |
| 259 | FALLTHROUGH_INTENDED; |
| 260 | case kCondGE: |
| 261 | case kCondLT: { |
| 262 | // Cmp, Sbcs |
| 263 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
| 264 | break; |
| 265 | } |
| 266 | default: |
| 267 | LOG(FATAL) << "Unreachable"; |
| 268 | UNREACHABLE(); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | void SchedulingLatencyVisitorARM::HandleGenerateLongTest(HCondition* condition) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 273 | DCHECK_EQ(condition->GetLeft()->GetType(), DataType::Type::kInt64); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 274 | |
| 275 | IfCondition cond = condition->GetCondition(); |
| 276 | |
| 277 | switch (cond) { |
| 278 | case kCondEQ: |
| 279 | case kCondNE: |
| 280 | case kCondB: |
| 281 | case kCondBE: |
| 282 | case kCondA: |
| 283 | case kCondAE: { |
| 284 | // Cmp, IT, Cmp |
| 285 | last_visited_internal_latency_ += 3 * kArmIntegerOpLatency; |
| 286 | break; |
| 287 | } |
| 288 | case kCondLE: |
| 289 | case kCondGT: |
| 290 | case kCondGE: |
| 291 | case kCondLT: { |
| 292 | // Cmp, Sbcs |
| 293 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
| 294 | break; |
| 295 | } |
| 296 | default: |
| 297 | LOG(FATAL) << "Unreachable"; |
| 298 | UNREACHABLE(); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | // The GenerateTest series of function all counted as internal latency. |
| 303 | void SchedulingLatencyVisitorARM::HandleGenerateTest(HCondition* condition) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 304 | const DataType::Type type = condition->GetLeft()->GetType(); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 305 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 306 | if (type == DataType::Type::kInt64) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 307 | condition->InputAt(1)->IsConstant() |
| 308 | ? HandleGenerateLongTestConstant(condition) |
| 309 | : HandleGenerateLongTest(condition); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 310 | } else if (DataType::IsFloatingPointType(type)) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 311 | // GenerateVcmp + Vmrs |
| 312 | last_visited_internal_latency_ += 2 * kArmFloatingPointOpLatency; |
| 313 | } else { |
| 314 | // Cmp |
| 315 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | bool SchedulingLatencyVisitorARM::CanGenerateTest(HCondition* condition) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 320 | if (condition->GetLeft()->GetType() == DataType::Type::kInt64) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 321 | HInstruction* right = condition->InputAt(1); |
| 322 | |
| 323 | if (right->IsConstant()) { |
| 324 | IfCondition c = condition->GetCondition(); |
| 325 | const uint64_t value = Uint64ConstantFrom(right); |
| 326 | |
| 327 | if (c < kCondLT || c > kCondGE) { |
| 328 | if (value != 0) { |
| 329 | return false; |
| 330 | } |
| 331 | } else if (c == kCondLE || c == kCondGT) { |
| 332 | if (value < std::numeric_limits<int64_t>::max() && |
Vladimir Marko | f0a6a1d | 2018-01-08 14:23:56 +0000 | [diff] [blame] | 333 | !codegen_->GetAssembler()->ShifterOperandCanHold( |
| 334 | SBC, High32Bits(value + 1), vixl32::FlagsUpdate::SetFlags)) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 335 | return false; |
| 336 | } |
Vladimir Marko | f0a6a1d | 2018-01-08 14:23:56 +0000 | [diff] [blame] | 337 | } else if (!codegen_->GetAssembler()->ShifterOperandCanHold( |
| 338 | SBC, High32Bits(value), vixl32::FlagsUpdate::SetFlags)) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 339 | return false; |
| 340 | } |
| 341 | } |
| 342 | } |
| 343 | |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | void SchedulingLatencyVisitorARM::HandleGenerateConditionGeneric(HCondition* cond) { |
| 348 | HandleGenerateTest(cond); |
| 349 | |
| 350 | // Unlike codegen pass, we cannot check 'out' register IsLow() here, |
| 351 | // because scheduling is before liveness(location builder) and register allocator, |
| 352 | // so we can only choose to follow one path of codegen by assuming otu.IsLow() is true. |
| 353 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 354 | last_visited_latency_ = kArmIntegerOpLatency; |
| 355 | } |
| 356 | |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 357 | void SchedulingLatencyVisitorARM::HandleGenerateEqualLong(HCondition* cond) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 358 | DCHECK_EQ(cond->GetLeft()->GetType(), DataType::Type::kInt64); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 359 | |
| 360 | IfCondition condition = cond->GetCondition(); |
| 361 | |
| 362 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
| 363 | |
| 364 | if (condition == kCondNE) { |
| 365 | // Orrs, IT, Mov |
| 366 | last_visited_internal_latency_ += 3 * kArmIntegerOpLatency; |
| 367 | } else { |
| 368 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 369 | HandleGenerateConditionWithZero(condition); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | void SchedulingLatencyVisitorARM::HandleGenerateLongComparesAndJumps() { |
| 374 | last_visited_internal_latency_ += 4 * kArmIntegerOpLatency; |
| 375 | last_visited_internal_latency_ += kArmBranchLatency; |
| 376 | } |
| 377 | |
| 378 | void SchedulingLatencyVisitorARM::HandleGenerateConditionLong(HCondition* cond) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 379 | DCHECK_EQ(cond->GetLeft()->GetType(), DataType::Type::kInt64); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 380 | |
| 381 | IfCondition condition = cond->GetCondition(); |
| 382 | HInstruction* right = cond->InputAt(1); |
| 383 | |
| 384 | if (right->IsConstant()) { |
| 385 | // Comparisons against 0 are common enough, so codegen has special handling for them. |
| 386 | if (Uint64ConstantFrom(right) == 0) { |
| 387 | switch (condition) { |
| 388 | case kCondNE: |
| 389 | case kCondA: |
| 390 | case kCondEQ: |
| 391 | case kCondBE: |
| 392 | // Orr |
| 393 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 394 | HandleGenerateConditionWithZero(condition); |
| 395 | return; |
| 396 | case kCondLT: |
| 397 | case kCondGE: |
| 398 | FALLTHROUGH_INTENDED; |
| 399 | case kCondAE: |
| 400 | case kCondB: |
| 401 | HandleGenerateConditionWithZero(condition); |
| 402 | return; |
| 403 | case kCondLE: |
| 404 | case kCondGT: |
| 405 | default: |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | } |
| 410 | |
| 411 | if ((condition == kCondEQ || condition == kCondNE) && |
| 412 | !CanGenerateTest(cond)) { |
| 413 | HandleGenerateEqualLong(cond); |
| 414 | return; |
| 415 | } |
| 416 | |
| 417 | if (CanGenerateTest(cond)) { |
| 418 | HandleGenerateConditionGeneric(cond); |
| 419 | return; |
| 420 | } |
| 421 | |
| 422 | HandleGenerateLongComparesAndJumps(); |
| 423 | |
| 424 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 425 | last_visited_latency_ = kArmBranchLatency;; |
| 426 | } |
| 427 | |
| 428 | void SchedulingLatencyVisitorARM::HandleGenerateConditionIntegralOrNonPrimitive(HCondition* cond) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 429 | const DataType::Type type = cond->GetLeft()->GetType(); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 430 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 431 | DCHECK(DataType::IsIntegralType(type) || type == DataType::Type::kReference) << type; |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 432 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 433 | if (type == DataType::Type::kInt64) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 434 | HandleGenerateConditionLong(cond); |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | IfCondition condition = cond->GetCondition(); |
| 439 | HInstruction* right = cond->InputAt(1); |
| 440 | int64_t value; |
| 441 | |
| 442 | if (right->IsConstant()) { |
| 443 | value = Uint64ConstantFrom(right); |
| 444 | |
| 445 | // Comparisons against 0 are common enough, so codegen has special handling for them. |
| 446 | if (value == 0) { |
| 447 | switch (condition) { |
| 448 | case kCondNE: |
| 449 | case kCondA: |
| 450 | case kCondEQ: |
| 451 | case kCondBE: |
| 452 | case kCondLT: |
| 453 | case kCondGE: |
| 454 | case kCondAE: |
| 455 | case kCondB: |
| 456 | HandleGenerateConditionWithZero(condition); |
| 457 | return; |
| 458 | case kCondLE: |
| 459 | case kCondGT: |
| 460 | default: |
| 461 | break; |
| 462 | } |
| 463 | } |
| 464 | } |
| 465 | |
| 466 | if (condition == kCondEQ || condition == kCondNE) { |
| 467 | if (condition == kCondNE) { |
| 468 | // CMP, IT, MOV.ne |
| 469 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
| 470 | last_visited_latency_ = kArmIntegerOpLatency; |
| 471 | } else { |
| 472 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 473 | HandleGenerateConditionWithZero(condition); |
| 474 | } |
| 475 | return; |
| 476 | } |
| 477 | |
| 478 | HandleGenerateConditionGeneric(cond); |
| 479 | } |
| 480 | |
| 481 | void SchedulingLatencyVisitorARM::HandleCondition(HCondition* cond) { |
| 482 | if (cond->IsEmittedAtUseSite()) { |
| 483 | last_visited_latency_ = 0; |
| 484 | return; |
| 485 | } |
| 486 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 487 | const DataType::Type type = cond->GetLeft()->GetType(); |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 488 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 489 | if (DataType::IsFloatingPointType(type)) { |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 490 | HandleGenerateConditionGeneric(cond); |
| 491 | return; |
| 492 | } |
| 493 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 494 | DCHECK(DataType::IsIntegralType(type) || type == DataType::Type::kReference) << type; |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 495 | |
| 496 | const IfCondition condition = cond->GetCondition(); |
| 497 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 498 | if (type == DataType::Type::kBool && |
| 499 | cond->GetRight()->GetType() == DataType::Type::kBool && |
xueliang.zhong | bf9e21a | 2017-06-15 11:01:11 +0100 | [diff] [blame] | 500 | (condition == kCondEQ || condition == kCondNE)) { |
| 501 | if (condition == kCondEQ) { |
| 502 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 503 | } |
| 504 | last_visited_latency_ = kArmIntegerOpLatency; |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | HandleGenerateConditionIntegralOrNonPrimitive(cond); |
| 509 | } |
| 510 | |
| 511 | void SchedulingLatencyVisitorARM::VisitCondition(HCondition* instr) { |
| 512 | HandleCondition(instr); |
| 513 | } |
| 514 | |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 515 | void SchedulingLatencyVisitorARM::VisitCompare(HCompare* instr) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 516 | DataType::Type type = instr->InputAt(0)->GetType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 517 | switch (type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 518 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 519 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 520 | case DataType::Type::kInt8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 521 | case DataType::Type::kUint16: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 522 | case DataType::Type::kInt16: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 523 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 524 | last_visited_internal_latency_ = 2 * kArmIntegerOpLatency; |
| 525 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 526 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 527 | last_visited_internal_latency_ = 2 * kArmIntegerOpLatency + 3 * kArmBranchLatency; |
| 528 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 529 | case DataType::Type::kFloat32: |
| 530 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 531 | last_visited_internal_latency_ = kArmIntegerOpLatency + 2 * kArmFloatingPointOpLatency; |
| 532 | break; |
| 533 | default: |
| 534 | last_visited_internal_latency_ = 2 * kArmIntegerOpLatency; |
| 535 | break; |
| 536 | } |
| 537 | last_visited_latency_ = kArmIntegerOpLatency; |
| 538 | } |
| 539 | |
| 540 | void SchedulingLatencyVisitorARM::VisitBitwiseNegatedRight(HBitwiseNegatedRight* instruction) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 541 | if (instruction->GetResultType() == DataType::Type::kInt32) { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 542 | last_visited_latency_ = kArmIntegerOpLatency; |
| 543 | } else { |
| 544 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 545 | last_visited_latency_ = kArmIntegerOpLatency; |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | void SchedulingLatencyVisitorARM::HandleGenerateDataProcInstruction(bool internal_latency) { |
| 550 | if (internal_latency) { |
| 551 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 552 | } else { |
| 553 | last_visited_latency_ = kArmDataProcWithShifterOpLatency; |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | void SchedulingLatencyVisitorARM::HandleGenerateDataProc(HDataProcWithShifterOp* instruction) { |
| 558 | const HInstruction::InstructionKind kind = instruction->GetInstrKind(); |
| 559 | if (kind == HInstruction::kAdd) { |
| 560 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 561 | last_visited_latency_ = kArmIntegerOpLatency; |
| 562 | } else if (kind == HInstruction::kSub) { |
| 563 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 564 | last_visited_latency_ = kArmIntegerOpLatency; |
| 565 | } else { |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 566 | HandleGenerateDataProcInstruction(/* internal_latency= */ true); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 567 | HandleGenerateDataProcInstruction(); |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | void SchedulingLatencyVisitorARM::HandleGenerateLongDataProc(HDataProcWithShifterOp* instruction) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 572 | DCHECK_EQ(instruction->GetType(), DataType::Type::kInt64); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 573 | DCHECK(HDataProcWithShifterOp::IsShiftOp(instruction->GetOpKind())); |
| 574 | |
| 575 | const uint32_t shift_value = instruction->GetShiftAmount(); |
| 576 | const HInstruction::InstructionKind kind = instruction->GetInstrKind(); |
| 577 | |
| 578 | if (shift_value >= 32) { |
| 579 | // Different shift types actually generate similar code here, |
| 580 | // no need to differentiate shift types like the codegen pass does, |
| 581 | // which also avoids handling shift types from different ARM backends. |
| 582 | HandleGenerateDataProc(instruction); |
| 583 | } else { |
| 584 | DCHECK_GT(shift_value, 1U); |
| 585 | DCHECK_LT(shift_value, 32U); |
| 586 | |
| 587 | if (kind == HInstruction::kOr || kind == HInstruction::kXor) { |
Andreas Gampe | 3db7068 | 2018-12-26 15:12:03 -0800 | [diff] [blame] | 588 | HandleGenerateDataProcInstruction(/* internal_latency= */ true); |
| 589 | HandleGenerateDataProcInstruction(/* internal_latency= */ true); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 590 | HandleGenerateDataProcInstruction(); |
| 591 | } else { |
| 592 | last_visited_internal_latency_ += 2 * kArmIntegerOpLatency; |
| 593 | HandleGenerateDataProc(instruction); |
| 594 | } |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | void SchedulingLatencyVisitorARM::VisitDataProcWithShifterOp(HDataProcWithShifterOp* instruction) { |
| 599 | const HDataProcWithShifterOp::OpKind op_kind = instruction->GetOpKind(); |
| 600 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 601 | if (instruction->GetType() == DataType::Type::kInt32) { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 602 | HandleGenerateDataProcInstruction(); |
| 603 | } else { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 604 | DCHECK_EQ(instruction->GetType(), DataType::Type::kInt64); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 605 | if (HDataProcWithShifterOp::IsExtensionOp(op_kind)) { |
| 606 | HandleGenerateDataProc(instruction); |
| 607 | } else { |
| 608 | HandleGenerateLongDataProc(instruction); |
| 609 | } |
| 610 | } |
| 611 | } |
| 612 | |
| 613 | void SchedulingLatencyVisitorARM::VisitIntermediateAddress(HIntermediateAddress* ATTRIBUTE_UNUSED) { |
| 614 | // Although the code generated is a simple `add` instruction, we found through empirical results |
| 615 | // that spacing it from its use in memory accesses was beneficial. |
| 616 | last_visited_internal_latency_ = kArmNopLatency; |
| 617 | last_visited_latency_ = kArmIntegerOpLatency; |
| 618 | } |
| 619 | |
Artem Serov | f0fc4c6 | 2017-05-03 15:07:15 +0100 | [diff] [blame] | 620 | void SchedulingLatencyVisitorARM::VisitIntermediateAddressIndex( |
| 621 | HIntermediateAddressIndex* ATTRIBUTE_UNUSED) { |
| 622 | UNIMPLEMENTED(FATAL) << "IntermediateAddressIndex is not implemented for ARM"; |
| 623 | } |
| 624 | |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 625 | void SchedulingLatencyVisitorARM::VisitMultiplyAccumulate(HMultiplyAccumulate* ATTRIBUTE_UNUSED) { |
| 626 | last_visited_latency_ = kArmMulIntegerLatency; |
| 627 | } |
| 628 | |
| 629 | void SchedulingLatencyVisitorARM::VisitArrayGet(HArrayGet* instruction) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 630 | DataType::Type type = instruction->GetType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 631 | const bool maybe_compressed_char_at = |
| 632 | mirror::kUseStringCompression && instruction->IsStringCharAt(); |
| 633 | HInstruction* array_instr = instruction->GetArray(); |
| 634 | bool has_intermediate_address = array_instr->IsIntermediateAddress(); |
| 635 | HInstruction* index = instruction->InputAt(1); |
| 636 | |
| 637 | switch (type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 638 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 639 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 640 | case DataType::Type::kInt8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 641 | case DataType::Type::kUint16: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 642 | case DataType::Type::kInt16: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 643 | case DataType::Type::kInt32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 644 | if (maybe_compressed_char_at) { |
| 645 | last_visited_internal_latency_ += kArmMemoryLoadLatency; |
| 646 | } |
| 647 | if (index->IsConstant()) { |
| 648 | if (maybe_compressed_char_at) { |
| 649 | last_visited_internal_latency_ += |
| 650 | kArmIntegerOpLatency + kArmBranchLatency + kArmMemoryLoadLatency; |
| 651 | last_visited_latency_ = kArmBranchLatency; |
| 652 | } else { |
| 653 | last_visited_latency_ += kArmMemoryLoadLatency; |
| 654 | } |
| 655 | } else { |
| 656 | if (has_intermediate_address) { |
| 657 | } else { |
| 658 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 659 | } |
| 660 | if (maybe_compressed_char_at) { |
| 661 | last_visited_internal_latency_ += |
| 662 | kArmIntegerOpLatency + kArmBranchLatency + kArmMemoryLoadLatency; |
| 663 | last_visited_latency_ = kArmBranchLatency; |
| 664 | } else { |
| 665 | last_visited_latency_ += kArmMemoryLoadLatency; |
| 666 | } |
| 667 | } |
| 668 | break; |
| 669 | } |
| 670 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 671 | case DataType::Type::kReference: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 672 | if (kEmitCompilerReadBarrier && kUseBakerReadBarrier) { |
| 673 | last_visited_latency_ = kArmLoadWithBakerReadBarrierLatency; |
| 674 | } else { |
| 675 | if (index->IsConstant()) { |
| 676 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 677 | } else { |
| 678 | if (has_intermediate_address) { |
| 679 | } else { |
| 680 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 681 | } |
Nicolas Geoffray | e346440 | 2018-08-02 17:38:49 +0100 | [diff] [blame] | 682 | last_visited_latency_ = kArmMemoryLoadLatency; |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 683 | } |
| 684 | } |
| 685 | break; |
| 686 | } |
| 687 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 688 | case DataType::Type::kInt64: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 689 | if (index->IsConstant()) { |
| 690 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 691 | } else { |
| 692 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 693 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 694 | } |
| 695 | break; |
| 696 | } |
| 697 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 698 | case DataType::Type::kFloat32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 699 | if (index->IsConstant()) { |
| 700 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 701 | } else { |
| 702 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 703 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 704 | } |
| 705 | break; |
| 706 | } |
| 707 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 708 | case DataType::Type::kFloat64: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 709 | if (index->IsConstant()) { |
| 710 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 711 | } else { |
| 712 | last_visited_internal_latency_ += kArmIntegerOpLatency; |
| 713 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 714 | } |
| 715 | break; |
| 716 | } |
| 717 | |
| 718 | default: |
| 719 | LOG(FATAL) << "Unreachable type " << type; |
| 720 | UNREACHABLE(); |
| 721 | } |
| 722 | } |
| 723 | |
| 724 | void SchedulingLatencyVisitorARM::VisitArrayLength(HArrayLength* instruction) { |
| 725 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 726 | if (mirror::kUseStringCompression && instruction->IsStringLength()) { |
| 727 | last_visited_internal_latency_ = kArmMemoryLoadLatency; |
| 728 | last_visited_latency_ = kArmIntegerOpLatency; |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | void SchedulingLatencyVisitorARM::VisitArraySet(HArraySet* instruction) { |
| 733 | HInstruction* index = instruction->InputAt(1); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 734 | DataType::Type value_type = instruction->GetComponentType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 735 | HInstruction* array_instr = instruction->GetArray(); |
| 736 | bool has_intermediate_address = array_instr->IsIntermediateAddress(); |
| 737 | |
| 738 | switch (value_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 739 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 740 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 741 | case DataType::Type::kInt8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 742 | case DataType::Type::kUint16: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 743 | case DataType::Type::kInt16: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 744 | case DataType::Type::kInt32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 745 | if (index->IsConstant()) { |
| 746 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 747 | } else { |
| 748 | if (has_intermediate_address) { |
| 749 | } else { |
| 750 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 751 | } |
| 752 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 753 | } |
| 754 | break; |
| 755 | } |
| 756 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 757 | case DataType::Type::kReference: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 758 | if (instruction->InputAt(2)->IsNullConstant()) { |
| 759 | if (index->IsConstant()) { |
| 760 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 761 | } else { |
| 762 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 763 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 764 | } |
| 765 | } else { |
| 766 | // Following the exact instructions of runtime type checks is too complicated, |
| 767 | // just giving it a simple slow latency. |
| 768 | last_visited_latency_ = kArmRuntimeTypeCheckLatency; |
| 769 | } |
| 770 | break; |
| 771 | } |
| 772 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 773 | case DataType::Type::kInt64: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 774 | if (index->IsConstant()) { |
| 775 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 776 | } else { |
| 777 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 778 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 779 | } |
| 780 | break; |
| 781 | } |
| 782 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 783 | case DataType::Type::kFloat32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 784 | if (index->IsConstant()) { |
| 785 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 786 | } else { |
| 787 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 788 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 789 | } |
| 790 | break; |
| 791 | } |
| 792 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 793 | case DataType::Type::kFloat64: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 794 | if (index->IsConstant()) { |
| 795 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 796 | } else { |
| 797 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 798 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 799 | } |
| 800 | break; |
| 801 | } |
| 802 | |
| 803 | default: |
| 804 | LOG(FATAL) << "Unreachable type " << value_type; |
| 805 | UNREACHABLE(); |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | void SchedulingLatencyVisitorARM::VisitBoundsCheck(HBoundsCheck* ATTRIBUTE_UNUSED) { |
| 810 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 811 | // Users do not use any data results. |
| 812 | last_visited_latency_ = 0; |
| 813 | } |
| 814 | |
| 815 | void SchedulingLatencyVisitorARM::HandleDivRemConstantIntegralLatencies(int32_t imm) { |
| 816 | if (imm == 0) { |
| 817 | last_visited_internal_latency_ = 0; |
| 818 | last_visited_latency_ = 0; |
| 819 | } else if (imm == 1 || imm == -1) { |
| 820 | last_visited_latency_ = kArmIntegerOpLatency; |
| 821 | } else if (IsPowerOfTwo(AbsOrMin(imm))) { |
| 822 | last_visited_internal_latency_ = 3 * kArmIntegerOpLatency; |
| 823 | last_visited_latency_ = kArmIntegerOpLatency; |
| 824 | } else { |
| 825 | last_visited_internal_latency_ = kArmMulIntegerLatency + 2 * kArmIntegerOpLatency; |
| 826 | last_visited_latency_ = kArmIntegerOpLatency; |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | void SchedulingLatencyVisitorARM::VisitDiv(HDiv* instruction) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 831 | DataType::Type type = instruction->GetResultType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 832 | switch (type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 833 | case DataType::Type::kInt32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 834 | HInstruction* rhs = instruction->GetRight(); |
| 835 | if (rhs->IsConstant()) { |
| 836 | int32_t imm = Int32ConstantFrom(rhs->AsConstant()); |
| 837 | HandleDivRemConstantIntegralLatencies(imm); |
| 838 | } else { |
| 839 | last_visited_latency_ = kArmDivIntegerLatency; |
| 840 | } |
| 841 | break; |
| 842 | } |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 843 | case DataType::Type::kFloat32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 844 | last_visited_latency_ = kArmDivFloatLatency; |
| 845 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 846 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 847 | last_visited_latency_ = kArmDivDoubleLatency; |
| 848 | break; |
| 849 | default: |
| 850 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 851 | last_visited_latency_ = kArmCallLatency; |
| 852 | break; |
| 853 | } |
| 854 | } |
| 855 | |
Alex Light | 3a73ffb | 2021-01-25 14:11:05 +0000 | [diff] [blame] | 856 | void SchedulingLatencyVisitorARM::VisitPredicatedInstanceFieldGet( |
| 857 | HPredicatedInstanceFieldGet* instruction) { |
| 858 | HandleFieldGetLatencies(instruction, instruction->GetFieldInfo()); |
| 859 | } |
| 860 | |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 861 | void SchedulingLatencyVisitorARM::VisitInstanceFieldGet(HInstanceFieldGet* instruction) { |
| 862 | HandleFieldGetLatencies(instruction, instruction->GetFieldInfo()); |
| 863 | } |
| 864 | |
| 865 | void SchedulingLatencyVisitorARM::VisitInstanceFieldSet(HInstanceFieldSet* instruction) { |
| 866 | HandleFieldSetLatencies(instruction, instruction->GetFieldInfo()); |
| 867 | } |
| 868 | |
| 869 | void SchedulingLatencyVisitorARM::VisitInstanceOf(HInstanceOf* ATTRIBUTE_UNUSED) { |
| 870 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 871 | last_visited_latency_ = kArmIntegerOpLatency; |
| 872 | } |
| 873 | |
| 874 | void SchedulingLatencyVisitorARM::VisitInvoke(HInvoke* ATTRIBUTE_UNUSED) { |
| 875 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 876 | last_visited_latency_ = kArmCallLatency; |
| 877 | } |
| 878 | |
| 879 | void SchedulingLatencyVisitorARM::VisitLoadString(HLoadString* ATTRIBUTE_UNUSED) { |
| 880 | last_visited_internal_latency_ = kArmLoadStringInternalLatency; |
| 881 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 882 | } |
| 883 | |
| 884 | void SchedulingLatencyVisitorARM::VisitNewArray(HNewArray* ATTRIBUTE_UNUSED) { |
| 885 | last_visited_internal_latency_ = kArmIntegerOpLatency + kArmCallInternalLatency; |
| 886 | last_visited_latency_ = kArmCallLatency; |
| 887 | } |
| 888 | |
| 889 | void SchedulingLatencyVisitorARM::VisitNewInstance(HNewInstance* instruction) { |
| 890 | if (instruction->IsStringAlloc()) { |
| 891 | last_visited_internal_latency_ = 2 * kArmMemoryLoadLatency + kArmCallInternalLatency; |
| 892 | } else { |
| 893 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 894 | } |
| 895 | last_visited_latency_ = kArmCallLatency; |
| 896 | } |
| 897 | |
| 898 | void SchedulingLatencyVisitorARM::VisitRem(HRem* instruction) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 899 | DataType::Type type = instruction->GetResultType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 900 | switch (type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 901 | case DataType::Type::kInt32: { |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 902 | HInstruction* rhs = instruction->GetRight(); |
| 903 | if (rhs->IsConstant()) { |
| 904 | int32_t imm = Int32ConstantFrom(rhs->AsConstant()); |
| 905 | HandleDivRemConstantIntegralLatencies(imm); |
| 906 | } else { |
| 907 | last_visited_internal_latency_ = kArmDivIntegerLatency; |
| 908 | last_visited_latency_ = kArmMulIntegerLatency; |
| 909 | } |
| 910 | break; |
| 911 | } |
| 912 | default: |
| 913 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 914 | last_visited_latency_ = kArmCallLatency; |
| 915 | break; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | void SchedulingLatencyVisitorARM::HandleFieldGetLatencies(HInstruction* instruction, |
| 920 | const FieldInfo& field_info) { |
Alex Light | 3a73ffb | 2021-01-25 14:11:05 +0000 | [diff] [blame] | 921 | DCHECK(instruction->IsInstanceFieldGet() || |
| 922 | instruction->IsStaticFieldGet() || |
| 923 | instruction->IsPredicatedInstanceFieldGet()); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 924 | DCHECK(codegen_ != nullptr); |
| 925 | bool is_volatile = field_info.IsVolatile(); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 926 | DataType::Type field_type = field_info.GetFieldType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 927 | bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
| 928 | |
| 929 | switch (field_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 930 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 931 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 932 | case DataType::Type::kInt8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 933 | case DataType::Type::kUint16: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 934 | case DataType::Type::kInt16: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 935 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 936 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 937 | break; |
| 938 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 939 | case DataType::Type::kReference: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 940 | if (kEmitCompilerReadBarrier && kUseBakerReadBarrier) { |
| 941 | last_visited_internal_latency_ = kArmMemoryLoadLatency + kArmIntegerOpLatency; |
| 942 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 943 | } else { |
| 944 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 945 | } |
| 946 | break; |
| 947 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 948 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 949 | if (is_volatile && !atomic_ldrd_strd) { |
| 950 | last_visited_internal_latency_ = kArmMemoryLoadLatency + kArmIntegerOpLatency; |
| 951 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 952 | } else { |
| 953 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 954 | } |
| 955 | break; |
| 956 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 957 | case DataType::Type::kFloat32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 958 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 959 | break; |
| 960 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 961 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 962 | if (is_volatile && !atomic_ldrd_strd) { |
| 963 | last_visited_internal_latency_ = |
| 964 | kArmMemoryLoadLatency + kArmIntegerOpLatency + kArmMemoryLoadLatency; |
| 965 | last_visited_latency_ = kArmIntegerOpLatency; |
| 966 | } else { |
| 967 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 968 | } |
| 969 | break; |
| 970 | |
| 971 | default: |
| 972 | last_visited_latency_ = kArmMemoryLoadLatency; |
| 973 | break; |
| 974 | } |
| 975 | |
| 976 | if (is_volatile) { |
| 977 | last_visited_internal_latency_ += kArmMemoryBarrierLatency; |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | void SchedulingLatencyVisitorARM::HandleFieldSetLatencies(HInstruction* instruction, |
| 982 | const FieldInfo& field_info) { |
| 983 | DCHECK(instruction->IsInstanceFieldSet() || instruction->IsStaticFieldSet()); |
| 984 | DCHECK(codegen_ != nullptr); |
| 985 | bool is_volatile = field_info.IsVolatile(); |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 986 | DataType::Type field_type = field_info.GetFieldType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 987 | bool needs_write_barrier = |
| 988 | CodeGenerator::StoreNeedsWriteBarrier(field_type, instruction->InputAt(1)); |
| 989 | bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); |
| 990 | |
| 991 | switch (field_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 992 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 993 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 994 | case DataType::Type::kInt8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 995 | case DataType::Type::kUint16: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 996 | case DataType::Type::kInt16: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 997 | if (is_volatile) { |
| 998 | last_visited_internal_latency_ = kArmMemoryBarrierLatency + kArmMemoryStoreLatency; |
| 999 | last_visited_latency_ = kArmMemoryBarrierLatency; |
| 1000 | } else { |
| 1001 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1002 | } |
| 1003 | break; |
| 1004 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1005 | case DataType::Type::kInt32: |
| 1006 | case DataType::Type::kReference: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1007 | if (kPoisonHeapReferences && needs_write_barrier) { |
| 1008 | last_visited_internal_latency_ += kArmIntegerOpLatency * 2; |
| 1009 | } |
| 1010 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1011 | break; |
| 1012 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1013 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1014 | if (is_volatile && !atomic_ldrd_strd) { |
| 1015 | last_visited_internal_latency_ = |
| 1016 | kArmIntegerOpLatency + kArmMemoryLoadLatency + kArmMemoryStoreLatency; |
| 1017 | last_visited_latency_ = kArmIntegerOpLatency; |
| 1018 | } else { |
| 1019 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1020 | } |
| 1021 | break; |
| 1022 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1023 | case DataType::Type::kFloat32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1024 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1025 | break; |
| 1026 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1027 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1028 | if (is_volatile && !atomic_ldrd_strd) { |
| 1029 | last_visited_internal_latency_ = kArmIntegerOpLatency + |
| 1030 | kArmIntegerOpLatency + kArmMemoryLoadLatency + kArmMemoryStoreLatency; |
| 1031 | last_visited_latency_ = kArmIntegerOpLatency; |
| 1032 | } else { |
| 1033 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1034 | } |
| 1035 | break; |
| 1036 | |
| 1037 | default: |
| 1038 | last_visited_latency_ = kArmMemoryStoreLatency; |
| 1039 | break; |
| 1040 | } |
| 1041 | } |
| 1042 | |
| 1043 | void SchedulingLatencyVisitorARM::VisitStaticFieldGet(HStaticFieldGet* instruction) { |
| 1044 | HandleFieldGetLatencies(instruction, instruction->GetFieldInfo()); |
| 1045 | } |
| 1046 | |
| 1047 | void SchedulingLatencyVisitorARM::VisitStaticFieldSet(HStaticFieldSet* instruction) { |
| 1048 | HandleFieldSetLatencies(instruction, instruction->GetFieldInfo()); |
| 1049 | } |
| 1050 | |
| 1051 | void SchedulingLatencyVisitorARM::VisitSuspendCheck(HSuspendCheck* instruction) { |
| 1052 | HBasicBlock* block = instruction->GetBlock(); |
| 1053 | DCHECK((block->GetLoopInformation() != nullptr) || |
| 1054 | (block->IsEntryBlock() && instruction->GetNext()->IsGoto())); |
| 1055 | // Users do not use any data results. |
| 1056 | last_visited_latency_ = 0; |
| 1057 | } |
| 1058 | |
| 1059 | void SchedulingLatencyVisitorARM::VisitTypeConversion(HTypeConversion* instr) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1060 | DataType::Type result_type = instr->GetResultType(); |
| 1061 | DataType::Type input_type = instr->GetInputType(); |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1062 | |
| 1063 | switch (result_type) { |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1064 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1065 | case DataType::Type::kInt8: |
| 1066 | case DataType::Type::kUint16: |
| 1067 | case DataType::Type::kInt16: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1068 | last_visited_latency_ = kArmIntegerOpLatency; // SBFX or UBFX |
| 1069 | break; |
| 1070 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1071 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1072 | switch (input_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1073 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1074 | last_visited_latency_ = kArmIntegerOpLatency; // MOV |
| 1075 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1076 | case DataType::Type::kFloat32: |
| 1077 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1078 | last_visited_internal_latency_ = kArmTypeConversionFloatingPointIntegerLatency; |
| 1079 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1080 | break; |
| 1081 | default: |
| 1082 | last_visited_latency_ = kArmIntegerOpLatency; |
| 1083 | break; |
| 1084 | } |
| 1085 | break; |
| 1086 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1087 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1088 | switch (input_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1089 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1090 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1091 | case DataType::Type::kInt8: |
| 1092 | case DataType::Type::kUint16: |
| 1093 | case DataType::Type::kInt16: |
| 1094 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1095 | // MOV and extension |
| 1096 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 1097 | last_visited_latency_ = kArmIntegerOpLatency; |
| 1098 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1099 | case DataType::Type::kFloat32: |
| 1100 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1101 | // invokes runtime |
| 1102 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 1103 | break; |
| 1104 | default: |
| 1105 | last_visited_internal_latency_ = kArmIntegerOpLatency; |
| 1106 | last_visited_latency_ = kArmIntegerOpLatency; |
| 1107 | break; |
| 1108 | } |
| 1109 | break; |
| 1110 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1111 | case DataType::Type::kFloat32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1112 | switch (input_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1113 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1114 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1115 | case DataType::Type::kInt8: |
| 1116 | case DataType::Type::kUint16: |
| 1117 | case DataType::Type::kInt16: |
| 1118 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1119 | last_visited_internal_latency_ = kArmTypeConversionFloatingPointIntegerLatency; |
| 1120 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1121 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1122 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1123 | // invokes runtime |
| 1124 | last_visited_internal_latency_ = kArmCallInternalLatency; |
| 1125 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1126 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1127 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1128 | break; |
| 1129 | default: |
| 1130 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1131 | break; |
| 1132 | } |
| 1133 | break; |
| 1134 | |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1135 | case DataType::Type::kFloat64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1136 | switch (input_type) { |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1137 | case DataType::Type::kBool: |
Vladimir Marko | d5d2f2c | 2017-09-26 12:37:26 +0100 | [diff] [blame] | 1138 | case DataType::Type::kUint8: |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1139 | case DataType::Type::kInt8: |
| 1140 | case DataType::Type::kUint16: |
| 1141 | case DataType::Type::kInt16: |
| 1142 | case DataType::Type::kInt32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1143 | last_visited_internal_latency_ = kArmTypeConversionFloatingPointIntegerLatency; |
| 1144 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1145 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1146 | case DataType::Type::kInt64: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1147 | last_visited_internal_latency_ = 5 * kArmFloatingPointOpLatency; |
| 1148 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1149 | break; |
Vladimir Marko | 0ebe0d8 | 2017-09-21 22:50:39 +0100 | [diff] [blame] | 1150 | case DataType::Type::kFloat32: |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1151 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1152 | break; |
| 1153 | default: |
| 1154 | last_visited_latency_ = kArmFloatingPointOpLatency; |
| 1155 | break; |
| 1156 | } |
| 1157 | break; |
| 1158 | |
| 1159 | default: |
| 1160 | last_visited_latency_ = kArmTypeConversionFloatingPointIntegerLatency; |
| 1161 | break; |
| 1162 | } |
| 1163 | } |
| 1164 | |
xueliang.zhong | f7caf68 | 2017-03-01 16:07:02 +0000 | [diff] [blame] | 1165 | } // namespace arm |
| 1166 | } // namespace art |