blob: 556217bf748d0f40115849dd4dfd956e06d4f7d7 [file] [log] [blame]
Mark Mendell0616ae02015-04-17 12:49:27 -04001/*
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_X86_H_
18#define ART_COMPILER_OPTIMIZING_NODES_X86_H_
19
20namespace art {
21
22// Compute the address of the method for X86 Constant area support.
23class HX86ComputeBaseMethodAddress : public HExpression<0> {
24 public:
25 // Treat the value as an int32_t, but it is really a 32 bit native pointer.
Calin Juravle154746b2015-10-06 15:46:54 +010026 HX86ComputeBaseMethodAddress()
27 : HExpression(Primitive::kPrimInt, SideEffects::None(), kNoDexPc) {}
Mark Mendell0616ae02015-04-17 12:49:27 -040028
29 DECLARE_INSTRUCTION(X86ComputeBaseMethodAddress);
30
31 private:
32 DISALLOW_COPY_AND_ASSIGN(HX86ComputeBaseMethodAddress);
33};
34
35// Load a constant value from the constant table.
36class HX86LoadFromConstantTable : public HExpression<2> {
37 public:
38 HX86LoadFromConstantTable(HX86ComputeBaseMethodAddress* method_base,
39 HConstant* constant,
40 bool needs_materialization = true)
Calin Juravle154746b2015-10-06 15:46:54 +010041 : HExpression(constant->GetType(), SideEffects::None(), kNoDexPc),
Mark Mendell0616ae02015-04-17 12:49:27 -040042 needs_materialization_(needs_materialization) {
43 SetRawInputAt(0, method_base);
44 SetRawInputAt(1, constant);
45 }
46
47 bool NeedsMaterialization() const { return needs_materialization_; }
48
49 HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
50 return InputAt(0)->AsX86ComputeBaseMethodAddress();
51 }
52
53 HConstant* GetConstant() const {
54 return InputAt(1)->AsConstant();
55 }
56
57 DECLARE_INSTRUCTION(X86LoadFromConstantTable);
58
59 private:
60 const bool needs_materialization_;
61
62 DISALLOW_COPY_AND_ASSIGN(HX86LoadFromConstantTable);
63};
64
Mark Mendell805b3b52015-09-18 14:10:29 -040065// X86 version of HPackedSwitch that holds a pointer to the base method address.
66class HX86PackedSwitch : public HTemplateInstruction<2> {
67 public:
68 HX86PackedSwitch(int32_t start_value,
69 int32_t num_entries,
70 HInstruction* input,
71 HX86ComputeBaseMethodAddress* method_base,
72 uint32_t dex_pc)
73 : HTemplateInstruction(SideEffects::None(), dex_pc),
74 start_value_(start_value),
75 num_entries_(num_entries) {
76 SetRawInputAt(0, input);
77 SetRawInputAt(1, method_base);
78 }
79
80 bool IsControlFlow() const OVERRIDE { return true; }
81
82 int32_t GetStartValue() const { return start_value_; }
83
84 int32_t GetNumEntries() const { return num_entries_; }
85
86 HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
87 return InputAt(1)->AsX86ComputeBaseMethodAddress();
88 }
89
90 HBasicBlock* GetDefaultBlock() const {
91 // Last entry is the default block.
92 return GetBlock()->GetSuccessors()[num_entries_];
93 }
94
95 DECLARE_INSTRUCTION(X86PackedSwitch);
96
97 private:
98 const int32_t start_value_;
99 const int32_t num_entries_;
100
101 DISALLOW_COPY_AND_ASSIGN(HX86PackedSwitch);
102};
103
Mark Mendell0616ae02015-04-17 12:49:27 -0400104} // namespace art
105
106#endif // ART_COMPILER_OPTIMIZING_NODES_X86_H_