Alexey Frunze | e3fb245 | 2016-05-10 16:08:05 -0700 | [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 | #ifndef ART_COMPILER_OPTIMIZING_NODES_MIPS_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_NODES_MIPS_H_ |
| 19 | |
| 20 | namespace art { |
| 21 | |
| 22 | // Compute the address of the method for MIPS Constant area support. |
| 23 | class HMipsComputeBaseMethodAddress : public HExpression<0> { |
| 24 | public: |
| 25 | // Treat the value as an int32_t, but it is really a 32 bit native pointer. |
| 26 | HMipsComputeBaseMethodAddress() |
| 27 | : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {} |
| 28 | |
| 29 | bool CanBeMoved() const OVERRIDE { return true; } |
| 30 | |
| 31 | DECLARE_INSTRUCTION(MipsComputeBaseMethodAddress); |
| 32 | |
| 33 | private: |
| 34 | DISALLOW_COPY_AND_ASSIGN(HMipsComputeBaseMethodAddress); |
| 35 | }; |
| 36 | |
| 37 | class HMipsDexCacheArraysBase : public HExpression<0> { |
| 38 | public: |
| 39 | explicit HMipsDexCacheArraysBase(const DexFile& dex_file) |
| 40 | : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc), |
| 41 | dex_file_(&dex_file), |
| 42 | element_offset_(static_cast<size_t>(-1)) { } |
| 43 | |
| 44 | bool CanBeMoved() const OVERRIDE { return true; } |
| 45 | |
| 46 | void UpdateElementOffset(size_t element_offset) { |
| 47 | // We'll maximize the range of a single load instruction for dex cache array accesses |
| 48 | // by aligning offset -32768 with the offset of the first used element. |
| 49 | element_offset_ = std::min(element_offset_, element_offset); |
| 50 | } |
| 51 | |
| 52 | const DexFile& GetDexFile() const { |
| 53 | return *dex_file_; |
| 54 | } |
| 55 | |
| 56 | size_t GetElementOffset() const { |
| 57 | return element_offset_; |
| 58 | } |
| 59 | |
| 60 | DECLARE_INSTRUCTION(MipsDexCacheArraysBase); |
| 61 | |
| 62 | private: |
| 63 | const DexFile* dex_file_; |
| 64 | size_t element_offset_; |
| 65 | |
| 66 | DISALLOW_COPY_AND_ASSIGN(HMipsDexCacheArraysBase); |
| 67 | }; |
| 68 | |
| 69 | } // namespace art |
| 70 | |
| 71 | #endif // ART_COMPILER_OPTIMIZING_NODES_MIPS_H_ |