Vladimir Marko | b4536b7 | 2015-11-24 13:45:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_NODES_ARM_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_NODES_ARM_H_ |
| 19 | |
| 20 | namespace art { |
| 21 | |
Vladimir Marko | fcb503c | 2016-05-18 12:48:17 +0100 | [diff] [blame] | 22 | class HArmDexCacheArraysBase FINAL : public HExpression<0> { |
Vladimir Marko | b4536b7 | 2015-11-24 13:45:23 +0000 | [diff] [blame] | 23 | public: |
| 24 | explicit HArmDexCacheArraysBase(const DexFile& dex_file) |
| 25 | : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc), |
| 26 | dex_file_(&dex_file), |
| 27 | element_offset_(static_cast<size_t>(-1)) { } |
| 28 | |
David Brazdil | d6c205e | 2016-06-07 14:20:52 +0100 | [diff] [blame] | 29 | bool CanBeMoved() const OVERRIDE { return true; } |
| 30 | |
Vladimir Marko | b4536b7 | 2015-11-24 13:45:23 +0000 | [diff] [blame] | 31 | void UpdateElementOffset(size_t element_offset) { |
| 32 | // Use the lowest offset from the requested elements so that all offsets from |
| 33 | // this base are non-negative because our assemblers emit negative-offset loads |
| 34 | // as a sequence of two or more instructions. (However, positive offsets beyond |
| 35 | // 4KiB also require two or more instructions, so this simple heuristic could |
| 36 | // be improved for cases where there is a dense cluster of elements far from |
| 37 | // the lowest offset. This is expected to be rare enough though, so we choose |
| 38 | // not to spend compile time on elaborate calculations.) |
| 39 | element_offset_ = std::min(element_offset_, element_offset); |
| 40 | } |
| 41 | |
| 42 | const DexFile& GetDexFile() const { |
| 43 | return *dex_file_; |
| 44 | } |
| 45 | |
| 46 | size_t GetElementOffset() const { |
| 47 | return element_offset_; |
| 48 | } |
| 49 | |
| 50 | DECLARE_INSTRUCTION(ArmDexCacheArraysBase); |
| 51 | |
| 52 | private: |
| 53 | const DexFile* dex_file_; |
| 54 | size_t element_offset_; |
| 55 | |
| 56 | DISALLOW_COPY_AND_ASSIGN(HArmDexCacheArraysBase); |
| 57 | }; |
| 58 | |
| 59 | } // namespace art |
| 60 | |
| 61 | #endif // ART_COMPILER_OPTIMIZING_NODES_ARM_H_ |