blob: 80e652eaa7e82d15ec0a9ddd53bb46afd97ce968 [file] [log] [blame]
Alexey Frunzee3fb2452016-05-10 16:08:05 -07001/*
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
20namespace art {
21
22// Compute the address of the method for MIPS Constant area support.
23class 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()
Vladimir Marko0ebe0d82017-09-21 22:50:39 +010027 : HExpression(DataType::Type::kInt32, SideEffects::None(), kNoDexPc) {}
Alexey Frunzee3fb2452016-05-10 16:08:05 -070028
29 bool CanBeMoved() const OVERRIDE { return true; }
30
31 DECLARE_INSTRUCTION(MipsComputeBaseMethodAddress);
32
33 private:
34 DISALLOW_COPY_AND_ASSIGN(HMipsComputeBaseMethodAddress);
35};
36
Alexey Frunze96b66822016-09-10 02:32:44 -070037// Mips version of HPackedSwitch that holds a pointer to the base method address.
38class HMipsPackedSwitch FINAL : public HTemplateInstruction<2> {
39 public:
40 HMipsPackedSwitch(int32_t start_value,
41 int32_t num_entries,
42 HInstruction* input,
43 HMipsComputeBaseMethodAddress* method_base,
44 uint32_t dex_pc)
45 : HTemplateInstruction(SideEffects::None(), dex_pc),
46 start_value_(start_value),
47 num_entries_(num_entries) {
48 SetRawInputAt(0, input);
49 SetRawInputAt(1, method_base);
50 }
51
52 bool IsControlFlow() const OVERRIDE { return true; }
53
54 int32_t GetStartValue() const { return start_value_; }
55
56 int32_t GetNumEntries() const { return num_entries_; }
57
58 HBasicBlock* GetDefaultBlock() const {
59 // Last entry is the default block.
60 return GetBlock()->GetSuccessors()[num_entries_];
61 }
62
63 DECLARE_INSTRUCTION(MipsPackedSwitch);
64
65 private:
66 const int32_t start_value_;
67 const int32_t num_entries_;
68
69 DISALLOW_COPY_AND_ASSIGN(HMipsPackedSwitch);
70};
71
Alexey Frunzee3fb2452016-05-10 16:08:05 -070072} // namespace art
73
74#endif // ART_COMPILER_OPTIMIZING_NODES_MIPS_H_