OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #include "src/compiler/machine-operator.h" | 5 #include "src/compiler/machine-operator.h" |
6 | 6 |
7 #include "src/base/lazy-instance.h" | 7 #include "src/base/lazy-instance.h" |
8 #include "src/compiler/opcodes.h" | 8 #include "src/compiler/opcodes.h" |
9 #include "src/compiler/operator.h" | 9 #include "src/compiler/operator.h" |
10 | 10 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ | 111 V(ChangeFloat32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ |
112 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ | 112 V(ChangeFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ |
113 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \ | 113 V(ChangeFloat64ToUint32, Operator::kNoProperties, 1, 0, 1) \ |
114 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ | 114 V(ChangeInt32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ |
115 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \ | 115 V(ChangeInt32ToInt64, Operator::kNoProperties, 1, 0, 1) \ |
116 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ | 116 V(ChangeUint32ToFloat64, Operator::kNoProperties, 1, 0, 1) \ |
117 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \ | 117 V(ChangeUint32ToUint64, Operator::kNoProperties, 1, 0, 1) \ |
118 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ | 118 V(TruncateFloat64ToFloat32, Operator::kNoProperties, 1, 0, 1) \ |
119 V(TruncateFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ | 119 V(TruncateFloat64ToInt32, Operator::kNoProperties, 1, 0, 1) \ |
120 V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \ | 120 V(TruncateInt64ToInt32, Operator::kNoProperties, 1, 0, 1) \ |
| 121 V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \ |
121 V(Float32Add, Operator::kCommutative, 2, 0, 1) \ | 122 V(Float32Add, Operator::kCommutative, 2, 0, 1) \ |
122 V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \ | 123 V(Float32Sub, Operator::kNoProperties, 2, 0, 1) \ |
123 V(Float32Mul, Operator::kCommutative, 2, 0, 1) \ | 124 V(Float32Mul, Operator::kCommutative, 2, 0, 1) \ |
124 V(Float32Div, Operator::kNoProperties, 2, 0, 1) \ | 125 V(Float32Div, Operator::kNoProperties, 2, 0, 1) \ |
125 V(Float32Abs, Operator::kNoProperties, 1, 0, 1) \ | |
126 V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \ | 126 V(Float32Sqrt, Operator::kNoProperties, 1, 0, 1) \ |
| 127 V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \ |
127 V(Float64Add, Operator::kCommutative, 2, 0, 1) \ | 128 V(Float64Add, Operator::kCommutative, 2, 0, 1) \ |
128 V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \ | 129 V(Float64Sub, Operator::kNoProperties, 2, 0, 1) \ |
129 V(Float64Mul, Operator::kCommutative, 2, 0, 1) \ | 130 V(Float64Mul, Operator::kCommutative, 2, 0, 1) \ |
130 V(Float64Div, Operator::kNoProperties, 2, 0, 1) \ | 131 V(Float64Div, Operator::kNoProperties, 2, 0, 1) \ |
131 V(Float64Mod, Operator::kNoProperties, 2, 0, 1) \ | 132 V(Float64Mod, Operator::kNoProperties, 2, 0, 1) \ |
132 V(Float64Abs, Operator::kNoProperties, 1, 0, 1) \ | |
133 V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1) \ | 133 V(Float64Sqrt, Operator::kNoProperties, 1, 0, 1) \ |
134 V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1) \ | |
135 V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \ | |
136 V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) \ | |
137 V(Float32Equal, Operator::kCommutative, 2, 0, 1) \ | 134 V(Float32Equal, Operator::kCommutative, 2, 0, 1) \ |
138 V(Float32LessThan, Operator::kNoProperties, 2, 0, 1) \ | 135 V(Float32LessThan, Operator::kNoProperties, 2, 0, 1) \ |
139 V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ | 136 V(Float32LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ |
140 V(Float64Equal, Operator::kCommutative, 2, 0, 1) \ | 137 V(Float64Equal, Operator::kCommutative, 2, 0, 1) \ |
141 V(Float64LessThan, Operator::kNoProperties, 2, 0, 1) \ | 138 V(Float64LessThan, Operator::kNoProperties, 2, 0, 1) \ |
142 V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ | 139 V(Float64LessThanOrEqual, Operator::kNoProperties, 2, 0, 1) \ |
143 V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1) \ | 140 V(Float64ExtractLowWord32, Operator::kNoProperties, 1, 0, 1) \ |
144 V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1) \ | 141 V(Float64ExtractHighWord32, Operator::kNoProperties, 1, 0, 1) \ |
145 V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1) \ | 142 V(Float64InsertLowWord32, Operator::kNoProperties, 2, 0, 1) \ |
146 V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1) \ | 143 V(Float64InsertHighWord32, Operator::kNoProperties, 2, 0, 1) \ |
147 V(Float32Max, Operator::kNoProperties, 2, 0, 1) \ | |
148 V(Float32Min, Operator::kNoProperties, 2, 0, 1) \ | |
149 V(Float64Max, Operator::kNoProperties, 2, 0, 1) \ | |
150 V(Float64Min, Operator::kNoProperties, 2, 0, 1) \ | |
151 V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1) \ | 144 V(LoadStackPointer, Operator::kNoProperties, 0, 0, 1) \ |
152 V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1) | 145 V(LoadFramePointer, Operator::kNoProperties, 0, 0, 1) |
153 | 146 |
| 147 #define PURE_OPTIONAL_OP_LIST(V) \ |
| 148 V(Float32Max, Operator::kNoProperties, 2, 0, 1) \ |
| 149 V(Float32Min, Operator::kNoProperties, 2, 0, 1) \ |
| 150 V(Float64Max, Operator::kNoProperties, 2, 0, 1) \ |
| 151 V(Float64Min, Operator::kNoProperties, 2, 0, 1) \ |
| 152 V(Float64RoundDown, Operator::kNoProperties, 1, 0, 1) \ |
| 153 V(Float64RoundTruncate, Operator::kNoProperties, 1, 0, 1) \ |
| 154 V(Float64RoundTiesAway, Operator::kNoProperties, 1, 0, 1) |
| 155 |
154 | 156 |
155 #define MACHINE_TYPE_LIST(V) \ | 157 #define MACHINE_TYPE_LIST(V) \ |
156 V(MachFloat32) \ | 158 V(MachFloat32) \ |
157 V(MachFloat64) \ | 159 V(MachFloat64) \ |
158 V(MachInt8) \ | 160 V(MachInt8) \ |
159 V(MachUint8) \ | 161 V(MachUint8) \ |
160 V(MachInt16) \ | 162 V(MachInt16) \ |
161 V(MachUint16) \ | 163 V(MachUint16) \ |
162 V(MachInt32) \ | 164 V(MachInt32) \ |
163 V(MachUint32) \ | 165 V(MachUint32) \ |
(...skipping 14 matching lines...) Expand all Loading... |
178 #define PURE(Name, properties, value_input_count, control_input_count, \ | 180 #define PURE(Name, properties, value_input_count, control_input_count, \ |
179 output_count) \ | 181 output_count) \ |
180 struct Name##Operator final : public Operator { \ | 182 struct Name##Operator final : public Operator { \ |
181 Name##Operator() \ | 183 Name##Operator() \ |
182 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ | 184 : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \ |
183 value_input_count, 0, control_input_count, output_count, 0, \ | 185 value_input_count, 0, control_input_count, output_count, 0, \ |
184 0) {} \ | 186 0) {} \ |
185 }; \ | 187 }; \ |
186 Name##Operator k##Name; | 188 Name##Operator k##Name; |
187 PURE_OP_LIST(PURE) | 189 PURE_OP_LIST(PURE) |
| 190 PURE_OPTIONAL_OP_LIST(PURE) |
188 #undef PURE | 191 #undef PURE |
189 | 192 |
190 #define LOAD(Type) \ | 193 #define LOAD(Type) \ |
191 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ | 194 struct Load##Type##Operator final : public Operator1<LoadRepresentation> { \ |
192 Load##Type##Operator() \ | 195 Load##Type##Operator() \ |
193 : Operator1<LoadRepresentation>( \ | 196 : Operator1<LoadRepresentation>( \ |
194 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ | 197 IrOpcode::kLoad, Operator::kNoThrow | Operator::kNoWrite, \ |
195 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \ | 198 "Load", 2, 1, 1, 1, 1, 0, k##Type) {} \ |
196 }; \ | 199 }; \ |
197 struct CheckedLoad##Type##Operator final \ | 200 struct CheckedLoad##Type##Operator final \ |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 DCHECK(word == kRepWord32 || word == kRepWord64); | 252 DCHECK(word == kRepWord32 || word == kRepWord64); |
250 } | 253 } |
251 | 254 |
252 | 255 |
253 #define PURE(Name, properties, value_input_count, control_input_count, \ | 256 #define PURE(Name, properties, value_input_count, control_input_count, \ |
254 output_count) \ | 257 output_count) \ |
255 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } | 258 const Operator* MachineOperatorBuilder::Name() { return &cache_.k##Name; } |
256 PURE_OP_LIST(PURE) | 259 PURE_OP_LIST(PURE) |
257 #undef PURE | 260 #undef PURE |
258 | 261 |
| 262 #define PURE(Name, properties, value_input_count, control_input_count, \ |
| 263 output_count) \ |
| 264 const OptionalOperator MachineOperatorBuilder::Name() { \ |
| 265 return OptionalOperator(flags_ & k##Name ? &cache_.k##Name : nullptr); \ |
| 266 } |
| 267 PURE_OPTIONAL_OP_LIST(PURE) |
| 268 #undef PURE |
259 | 269 |
260 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { | 270 const Operator* MachineOperatorBuilder::Load(LoadRepresentation rep) { |
261 switch (rep) { | 271 switch (rep) { |
262 #define LOAD(Type) \ | 272 #define LOAD(Type) \ |
263 case k##Type: \ | 273 case k##Type: \ |
264 return &cache_.kLoad##Type; | 274 return &cache_.kLoad##Type; |
265 MACHINE_TYPE_LIST(LOAD) | 275 MACHINE_TYPE_LIST(LOAD) |
266 #undef LOAD | 276 #undef LOAD |
267 default: | 277 default: |
268 break; | 278 break; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 } | 339 } |
330 // Uncached. | 340 // Uncached. |
331 return new (zone_) Operator1<CheckedStoreRepresentation>( | 341 return new (zone_) Operator1<CheckedStoreRepresentation>( |
332 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, | 342 IrOpcode::kCheckedStore, Operator::kNoRead | Operator::kNoThrow, |
333 "CheckedStore", 4, 1, 1, 0, 1, 0, rep); | 343 "CheckedStore", 4, 1, 1, 0, 1, 0, rep); |
334 } | 344 } |
335 | 345 |
336 } // namespace compiler | 346 } // namespace compiler |
337 } // namespace internal | 347 } // namespace internal |
338 } // namespace v8 | 348 } // namespace v8 |
OLD | NEW |