OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ | 5 #ifndef V8_COMPILER_MACHINE_OPERATOR_H_ |
6 #define V8_COMPILER_MACHINE_OPERATOR_H_ | 6 #define V8_COMPILER_MACHINE_OPERATOR_H_ |
7 | 7 |
8 #include "src/compiler/machine-type.h" | 8 #include "src/compiler/machine-type.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 OStream& operator<<(OStream& os, const StoreRepresentation& rep); | 55 OStream& operator<<(OStream& os, const StoreRepresentation& rep); |
56 | 56 |
57 | 57 |
58 // Interface for building machine-level operators. These operators are | 58 // Interface for building machine-level operators. These operators are |
59 // machine-level but machine-independent and thus define a language suitable | 59 // machine-level but machine-independent and thus define a language suitable |
60 // for generating code to run on architectures such as ia32, x64, arm, etc. | 60 // for generating code to run on architectures such as ia32, x64, arm, etc. |
61 class MachineOperatorBuilder FINAL { | 61 class MachineOperatorBuilder FINAL { |
62 public: | 62 public: |
63 explicit MachineOperatorBuilder(MachineType word = kMachPtr); | 63 explicit MachineOperatorBuilder(MachineType word = kMachPtr); |
64 | 64 |
65 const Operator* Word32And() WARN_UNUSED_RESULT; | 65 const Operator* Word32And() const WARN_UNUSED_RESULT; |
66 const Operator* Word32Or() WARN_UNUSED_RESULT; | 66 const Operator* Word32Or() const WARN_UNUSED_RESULT; |
67 const Operator* Word32Xor() WARN_UNUSED_RESULT; | 67 const Operator* Word32Xor() const WARN_UNUSED_RESULT; |
68 const Operator* Word32Shl() WARN_UNUSED_RESULT; | 68 const Operator* Word32Shl() const WARN_UNUSED_RESULT; |
69 const Operator* Word32Shr() WARN_UNUSED_RESULT; | 69 const Operator* Word32Shr() const WARN_UNUSED_RESULT; |
70 const Operator* Word32Sar() WARN_UNUSED_RESULT; | 70 const Operator* Word32Sar() const WARN_UNUSED_RESULT; |
71 const Operator* Word32Ror() WARN_UNUSED_RESULT; | 71 const Operator* Word32Ror() const WARN_UNUSED_RESULT; |
72 const Operator* Word32Equal() WARN_UNUSED_RESULT; | 72 const Operator* Word32Equal() const WARN_UNUSED_RESULT; |
73 | 73 |
74 const Operator* Word64And() WARN_UNUSED_RESULT; | 74 const Operator* Word64And() const WARN_UNUSED_RESULT; |
75 const Operator* Word64Or() WARN_UNUSED_RESULT; | 75 const Operator* Word64Or() const WARN_UNUSED_RESULT; |
76 const Operator* Word64Xor() WARN_UNUSED_RESULT; | 76 const Operator* Word64Xor() const WARN_UNUSED_RESULT; |
77 const Operator* Word64Shl() WARN_UNUSED_RESULT; | 77 const Operator* Word64Shl() const WARN_UNUSED_RESULT; |
78 const Operator* Word64Shr() WARN_UNUSED_RESULT; | 78 const Operator* Word64Shr() const WARN_UNUSED_RESULT; |
79 const Operator* Word64Sar() WARN_UNUSED_RESULT; | 79 const Operator* Word64Sar() const WARN_UNUSED_RESULT; |
80 const Operator* Word64Ror() WARN_UNUSED_RESULT; | 80 const Operator* Word64Ror() const WARN_UNUSED_RESULT; |
81 const Operator* Word64Equal() WARN_UNUSED_RESULT; | 81 const Operator* Word64Equal() const WARN_UNUSED_RESULT; |
82 | 82 |
83 const Operator* Int32Add() WARN_UNUSED_RESULT; | 83 const Operator* Int32Add() const WARN_UNUSED_RESULT; |
84 const Operator* Int32AddWithOverflow() WARN_UNUSED_RESULT; | 84 const Operator* Int32AddWithOverflow() const WARN_UNUSED_RESULT; |
85 const Operator* Int32Sub() WARN_UNUSED_RESULT; | 85 const Operator* Int32Sub() const WARN_UNUSED_RESULT; |
86 const Operator* Int32SubWithOverflow() WARN_UNUSED_RESULT; | 86 const Operator* Int32SubWithOverflow() const WARN_UNUSED_RESULT; |
87 const Operator* Int32Mul() WARN_UNUSED_RESULT; | 87 const Operator* Int32Mul() const WARN_UNUSED_RESULT; |
88 const Operator* Int32Div() WARN_UNUSED_RESULT; | 88 const Operator* Int32Div() const WARN_UNUSED_RESULT; |
89 const Operator* Int32UDiv() WARN_UNUSED_RESULT; | 89 const Operator* Int32UDiv() const WARN_UNUSED_RESULT; |
90 const Operator* Int32Mod() WARN_UNUSED_RESULT; | 90 const Operator* Int32Mod() const WARN_UNUSED_RESULT; |
91 const Operator* Int32UMod() WARN_UNUSED_RESULT; | 91 const Operator* Int32UMod() const WARN_UNUSED_RESULT; |
92 const Operator* Int32LessThan() WARN_UNUSED_RESULT; | 92 const Operator* Int32LessThan() const WARN_UNUSED_RESULT; |
93 const Operator* Int32LessThanOrEqual() WARN_UNUSED_RESULT; | 93 const Operator* Int32LessThanOrEqual() const WARN_UNUSED_RESULT; |
94 const Operator* Uint32LessThan() WARN_UNUSED_RESULT; | 94 const Operator* Uint32LessThan() const WARN_UNUSED_RESULT; |
95 const Operator* Uint32LessThanOrEqual() WARN_UNUSED_RESULT; | 95 const Operator* Uint32LessThanOrEqual() const WARN_UNUSED_RESULT; |
96 | 96 |
97 const Operator* Int64Add() WARN_UNUSED_RESULT; | 97 const Operator* Int64Add() const WARN_UNUSED_RESULT; |
98 const Operator* Int64Sub() WARN_UNUSED_RESULT; | 98 const Operator* Int64Sub() const WARN_UNUSED_RESULT; |
99 const Operator* Int64Mul() WARN_UNUSED_RESULT; | 99 const Operator* Int64Mul() const WARN_UNUSED_RESULT; |
100 const Operator* Int64Div() WARN_UNUSED_RESULT; | 100 const Operator* Int64Div() const WARN_UNUSED_RESULT; |
101 const Operator* Int64UDiv() WARN_UNUSED_RESULT; | 101 const Operator* Int64UDiv() const WARN_UNUSED_RESULT; |
102 const Operator* Int64Mod() WARN_UNUSED_RESULT; | 102 const Operator* Int64Mod() const WARN_UNUSED_RESULT; |
103 const Operator* Int64UMod() WARN_UNUSED_RESULT; | 103 const Operator* Int64UMod() const WARN_UNUSED_RESULT; |
104 const Operator* Int64LessThan() WARN_UNUSED_RESULT; | 104 const Operator* Int64LessThan() const WARN_UNUSED_RESULT; |
105 const Operator* Int64LessThanOrEqual() WARN_UNUSED_RESULT; | 105 const Operator* Int64LessThanOrEqual() const WARN_UNUSED_RESULT; |
106 | 106 |
107 // Convert representation of integers between float64 and int32/uint32. | 107 // Convert representation of integers between float64 and int32/uint32. |
108 // The precise rounding mode and handling of out of range inputs are *not* | 108 // The precise rounding mode and handling of out of range inputs are *not* |
109 // defined for these operators, since they are intended only for use with | 109 // defined for these operators, since they are intended only for use with |
110 // integers. | 110 // integers. |
111 const Operator* ChangeInt32ToFloat64() WARN_UNUSED_RESULT; | 111 const Operator* ChangeInt32ToFloat64() const WARN_UNUSED_RESULT; |
112 const Operator* ChangeUint32ToFloat64() WARN_UNUSED_RESULT; | 112 const Operator* ChangeUint32ToFloat64() const WARN_UNUSED_RESULT; |
113 const Operator* ChangeFloat64ToInt32() WARN_UNUSED_RESULT; | 113 const Operator* ChangeFloat64ToInt32() const WARN_UNUSED_RESULT; |
114 const Operator* ChangeFloat64ToUint32() WARN_UNUSED_RESULT; | 114 const Operator* ChangeFloat64ToUint32() const WARN_UNUSED_RESULT; |
115 | 115 |
116 // Sign/zero extend int32/uint32 to int64/uint64. | 116 // Sign/zero extend int32/uint32 to int64/uint64. |
117 const Operator* ChangeInt32ToInt64() WARN_UNUSED_RESULT; | 117 const Operator* ChangeInt32ToInt64() const WARN_UNUSED_RESULT; |
118 const Operator* ChangeUint32ToUint64() WARN_UNUSED_RESULT; | 118 const Operator* ChangeUint32ToUint64() const WARN_UNUSED_RESULT; |
119 | 119 |
120 // Truncate double to int32 using JavaScript semantics. | 120 // Truncate double to int32 using JavaScript semantics. |
121 const Operator* TruncateFloat64ToInt32() WARN_UNUSED_RESULT; | 121 const Operator* TruncateFloat64ToInt32() const WARN_UNUSED_RESULT; |
122 | 122 |
123 // Truncate the high order bits and convert the remaining bits to int32. | 123 // Truncate the high order bits and convert the remaining bits to int32. |
124 const Operator* TruncateInt64ToInt32() WARN_UNUSED_RESULT; | 124 const Operator* TruncateInt64ToInt32() const WARN_UNUSED_RESULT; |
125 | 125 |
126 // Floating point operators always operate with IEEE 754 round-to-nearest. | 126 // Floating point operators always operate with IEEE 754 round-to-nearest. |
127 const Operator* Float64Add() WARN_UNUSED_RESULT; | 127 const Operator* Float64Add() const WARN_UNUSED_RESULT; |
128 const Operator* Float64Sub() WARN_UNUSED_RESULT; | 128 const Operator* Float64Sub() const WARN_UNUSED_RESULT; |
129 const Operator* Float64Mul() WARN_UNUSED_RESULT; | 129 const Operator* Float64Mul() const WARN_UNUSED_RESULT; |
130 const Operator* Float64Div() WARN_UNUSED_RESULT; | 130 const Operator* Float64Div() const WARN_UNUSED_RESULT; |
131 const Operator* Float64Mod() WARN_UNUSED_RESULT; | 131 const Operator* Float64Mod() const WARN_UNUSED_RESULT; |
132 | 132 |
133 // Floating point comparisons complying to IEEE 754. | 133 // Floating point comparisons complying to IEEE 754. |
134 const Operator* Float64Equal() WARN_UNUSED_RESULT; | 134 const Operator* Float64Equal() const WARN_UNUSED_RESULT; |
135 const Operator* Float64LessThan() WARN_UNUSED_RESULT; | 135 const Operator* Float64LessThan() const WARN_UNUSED_RESULT; |
136 const Operator* Float64LessThanOrEqual() WARN_UNUSED_RESULT; | 136 const Operator* Float64LessThanOrEqual() const WARN_UNUSED_RESULT; |
137 | 137 |
138 // load [base + index] | 138 // load [base + index] |
139 const Operator* Load(LoadRepresentation rep) WARN_UNUSED_RESULT; | 139 const Operator* Load(LoadRepresentation rep) const WARN_UNUSED_RESULT; |
140 | 140 |
141 // store [base + index], value | 141 // store [base + index], value |
142 const Operator* Store(StoreRepresentation rep) WARN_UNUSED_RESULT; | 142 const Operator* Store(StoreRepresentation rep) const WARN_UNUSED_RESULT; |
143 | 143 |
144 // Target machine word-size assumed by this builder. | 144 // Target machine word-size assumed by this builder. |
145 bool Is32() const { return word() == kRepWord32; } | 145 bool Is32() const { return word() == kRepWord32; } |
146 bool Is64() const { return word() == kRepWord64; } | 146 bool Is64() const { return word() == kRepWord64; } |
147 MachineType word() const { return word_; } | 147 MachineType word() const { return word_; } |
148 | 148 |
149 // Pseudo operators that translate to 32/64-bit operators depending on the | 149 // Pseudo operators that translate to 32/64-bit operators depending on the |
150 // word-size of the target machine assumed by this builder. | 150 // word-size of the target machine assumed by this builder. |
151 #define PSEUDO_OP_LIST(V) \ | 151 #define PSEUDO_OP_LIST(V) \ |
152 V(Word, And) \ | 152 V(Word, And) \ |
153 V(Word, Or) \ | 153 V(Word, Or) \ |
154 V(Word, Xor) \ | 154 V(Word, Xor) \ |
155 V(Word, Shl) \ | 155 V(Word, Shl) \ |
156 V(Word, Shr) \ | 156 V(Word, Shr) \ |
157 V(Word, Sar) \ | 157 V(Word, Sar) \ |
158 V(Word, Ror) \ | 158 V(Word, Ror) \ |
159 V(Word, Equal) \ | 159 V(Word, Equal) \ |
160 V(Int, Add) \ | 160 V(Int, Add) \ |
161 V(Int, Sub) \ | 161 V(Int, Sub) \ |
162 V(Int, Mul) \ | 162 V(Int, Mul) \ |
163 V(Int, Div) \ | 163 V(Int, Div) \ |
164 V(Int, UDiv) \ | 164 V(Int, UDiv) \ |
165 V(Int, Mod) \ | 165 V(Int, Mod) \ |
166 V(Int, UMod) \ | 166 V(Int, UMod) \ |
167 V(Int, LessThan) \ | 167 V(Int, LessThan) \ |
168 V(Int, LessThanOrEqual) | 168 V(Int, LessThanOrEqual) |
169 #define PSEUDO_OP(Prefix, Suffix) \ | 169 #define PSEUDO_OP(Prefix, Suffix) \ |
170 const Operator* Prefix##Suffix() { \ | 170 const Operator* Prefix##Suffix() const { \ |
171 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 171 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
172 } | 172 } |
173 PSEUDO_OP_LIST(PSEUDO_OP) | 173 PSEUDO_OP_LIST(PSEUDO_OP) |
174 #undef PSEUDO_OP | 174 #undef PSEUDO_OP |
175 #undef PSEUDO_OP_LIST | 175 #undef PSEUDO_OP_LIST |
176 | 176 |
177 private: | 177 private: |
178 const MachineOperatorBuilderImpl& impl_; | 178 const MachineOperatorBuilderImpl& impl_; |
179 const MachineType word_; | 179 const MachineType word_; |
180 }; | 180 }; |
181 | 181 |
182 } // namespace compiler | 182 } // namespace compiler |
183 } // namespace internal | 183 } // namespace internal |
184 } // namespace v8 | 184 } // namespace v8 |
185 | 185 |
186 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 186 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |