• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
HMipsComputeBaseMethodAddress()26   HMipsComputeBaseMethodAddress()
27       : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {}
28 
CanBeMoved()29   bool CanBeMoved() const OVERRIDE { return true; }
30 
31   DECLARE_INSTRUCTION(MipsComputeBaseMethodAddress);
32 
33  private:
34   DISALLOW_COPY_AND_ASSIGN(HMipsComputeBaseMethodAddress);
35 };
36 
37 // Mips version of HPackedSwitch that holds a pointer to the base method address.
38 class HMipsPackedSwitch FINAL : public HTemplateInstruction<2> {
39  public:
HMipsPackedSwitch(int32_t start_value,int32_t num_entries,HInstruction * input,HMipsComputeBaseMethodAddress * method_base,uint32_t dex_pc)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 
IsControlFlow()52   bool IsControlFlow() const OVERRIDE { return true; }
53 
GetStartValue()54   int32_t GetStartValue() const { return start_value_; }
55 
GetNumEntries()56   int32_t GetNumEntries() const { return num_entries_; }
57 
GetDefaultBlock()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 
72 }  // namespace art
73 
74 #endif  // ART_COMPILER_OPTIMIZING_NODES_MIPS_H_
75