blob: 0b3a84d3d3cc4dea499bfa329706ff2417f8fbe9 [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,
David Brazdilb3e773e2016-01-26 11:28:37 +000039 HConstant* constant)
40 : HExpression(constant->GetType(), SideEffects::None(), kNoDexPc) {
Mark Mendell0616ae02015-04-17 12:49:27 -040041 SetRawInputAt(0, method_base);
42 SetRawInputAt(1, constant);
43 }
44
Mark Mendell0616ae02015-04-17 12:49:27 -040045 HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
46 return InputAt(0)->AsX86ComputeBaseMethodAddress();
47 }
48
49 HConstant* GetConstant() const {
50 return InputAt(1)->AsConstant();
51 }
52
53 DECLARE_INSTRUCTION(X86LoadFromConstantTable);
54
55 private:
Mark Mendell0616ae02015-04-17 12:49:27 -040056 DISALLOW_COPY_AND_ASSIGN(HX86LoadFromConstantTable);
57};
58
Mark P Mendell2f10a5f2016-01-25 14:47:50 +000059// Version of HNeg with access to the constant table for FP types.
60class HX86FPNeg : public HExpression<2> {
61 public:
62 HX86FPNeg(Primitive::Type result_type,
63 HInstruction* input,
64 HX86ComputeBaseMethodAddress* method_base,
65 uint32_t dex_pc)
66 : HExpression(result_type, SideEffects::None(), dex_pc) {
67 DCHECK(Primitive::IsFloatingPointType(result_type));
68 SetRawInputAt(0, input);
69 SetRawInputAt(1, method_base);
70 }
71
72 DECLARE_INSTRUCTION(X86FPNeg);
73
74 private:
75 DISALLOW_COPY_AND_ASSIGN(HX86FPNeg);
76};
77
Mark Mendell805b3b52015-09-18 14:10:29 -040078// X86 version of HPackedSwitch that holds a pointer to the base method address.
79class HX86PackedSwitch : public HTemplateInstruction<2> {
80 public:
81 HX86PackedSwitch(int32_t start_value,
82 int32_t num_entries,
83 HInstruction* input,
84 HX86ComputeBaseMethodAddress* method_base,
85 uint32_t dex_pc)
86 : HTemplateInstruction(SideEffects::None(), dex_pc),
87 start_value_(start_value),
88 num_entries_(num_entries) {
89 SetRawInputAt(0, input);
90 SetRawInputAt(1, method_base);
91 }
92
93 bool IsControlFlow() const OVERRIDE { return true; }
94
95 int32_t GetStartValue() const { return start_value_; }
96
97 int32_t GetNumEntries() const { return num_entries_; }
98
99 HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
100 return InputAt(1)->AsX86ComputeBaseMethodAddress();
101 }
102
103 HBasicBlock* GetDefaultBlock() const {
104 // Last entry is the default block.
105 return GetBlock()->GetSuccessors()[num_entries_];
106 }
107
108 DECLARE_INSTRUCTION(X86PackedSwitch);
109
110 private:
111 const int32_t start_value_;
112 const int32_t num_entries_;
113
114 DISALLOW_COPY_AND_ASSIGN(HX86PackedSwitch);
115};
116
Mark Mendell0616ae02015-04-17 12:49:27 -0400117} // namespace art
118
119#endif // ART_COMPILER_OPTIMIZING_NODES_X86_H_