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/base/flags.h" | |
8 #include "src/compiler/machine-type.h" | 9 #include "src/compiler/machine-type.h" |
9 | 10 |
10 namespace v8 { | 11 namespace v8 { |
11 namespace internal { | 12 namespace internal { |
12 namespace compiler { | 13 namespace compiler { |
13 | 14 |
14 // Forward declarations. | 15 // Forward declarations. |
15 struct MachineOperatorBuilderImpl; | 16 struct MachineOperatorBuilderImpl; |
16 class Operator; | 17 class Operator; |
17 | 18 |
(...skipping 26 matching lines...) Expand all Loading... | |
44 | 45 |
45 bool operator==(StoreRepresentation, StoreRepresentation); | 46 bool operator==(StoreRepresentation, StoreRepresentation); |
46 bool operator!=(StoreRepresentation, StoreRepresentation); | 47 bool operator!=(StoreRepresentation, StoreRepresentation); |
47 | 48 |
48 size_t hash_value(StoreRepresentation); | 49 size_t hash_value(StoreRepresentation); |
49 | 50 |
50 std::ostream& operator<<(std::ostream&, StoreRepresentation); | 51 std::ostream& operator<<(std::ostream&, StoreRepresentation); |
51 | 52 |
52 StoreRepresentation const& StoreRepresentationOf(Operator const*); | 53 StoreRepresentation const& StoreRepresentationOf(Operator const*); |
53 | 54 |
54 | |
55 // Interface for building machine-level operators. These operators are | 55 // Interface for building machine-level operators. These operators are |
56 // machine-level but machine-independent and thus define a language suitable | 56 // machine-level but machine-independent and thus define a language suitable |
57 // for generating code to run on architectures such as ia32, x64, arm, etc. | 57 // for generating code to run on architectures such as ia32, x64, arm, etc. |
58 class MachineOperatorBuilder FINAL { | 58 class MachineOperatorBuilder FINAL { |
59 public: | 59 public: |
60 explicit MachineOperatorBuilder(MachineType word = kMachPtr); | 60 // Flags that specify which operations are available. This is useful |
61 // for operations that are unsupported by some back-ends. | |
62 enum Flag : unsigned int { | |
Benedikt Meurer
2014/10/23 11:04:57
enum class Flag : unsigned {...}
sigurds
2014/10/23 11:15:56
Done. Had to intro a static_cast in flags.h.
| |
63 kNoFlags = 0, | |
64 kFloat64Floor = 1 << 0, | |
65 kFloat64Ceil = 1 << 1, | |
66 kFloat64Truncate = 1 << 2, | |
67 kFloat64RoundTiesAway = 1 << 3 | |
68 }; | |
69 typedef base::Flags<Flag, unsigned int> Flags; | |
Benedikt Meurer
2014/10/23 11:04:57
s,unsigned int,unsigned,
sigurds
2014/10/23 11:15:56
Done.
| |
70 | |
71 explicit MachineOperatorBuilder(MachineType word = kMachPtr, | |
72 Flags supportedOperators = kNoFlags); | |
61 | 73 |
62 const Operator* Word32And(); | 74 const Operator* Word32And(); |
63 const Operator* Word32Or(); | 75 const Operator* Word32Or(); |
64 const Operator* Word32Xor(); | 76 const Operator* Word32Xor(); |
65 const Operator* Word32Shl(); | 77 const Operator* Word32Shl(); |
66 const Operator* Word32Shr(); | 78 const Operator* Word32Shr(); |
67 const Operator* Word32Sar(); | 79 const Operator* Word32Sar(); |
68 const Operator* Word32Ror(); | 80 const Operator* Word32Ror(); |
69 const Operator* Word32Equal(); | 81 const Operator* Word32Equal(); |
70 | 82 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
128 const Operator* Float64Mul(); | 140 const Operator* Float64Mul(); |
129 const Operator* Float64Div(); | 141 const Operator* Float64Div(); |
130 const Operator* Float64Mod(); | 142 const Operator* Float64Mod(); |
131 const Operator* Float64Sqrt(); | 143 const Operator* Float64Sqrt(); |
132 | 144 |
133 // Floating point comparisons complying to IEEE 754. | 145 // Floating point comparisons complying to IEEE 754. |
134 const Operator* Float64Equal(); | 146 const Operator* Float64Equal(); |
135 const Operator* Float64LessThan(); | 147 const Operator* Float64LessThan(); |
136 const Operator* Float64LessThanOrEqual(); | 148 const Operator* Float64LessThanOrEqual(); |
137 | 149 |
150 // Floating point rounding. | |
151 const Operator* Float64Floor(); | |
152 const Operator* Float64Ceil(); | |
153 const Operator* Float64RoundTruncate(); | |
154 const Operator* Float64RoundTiesAway(); | |
155 bool HasFloat64Floor() { return flags_ & kFloat64Floor; } | |
156 bool HasFloat64Ceil() { return flags_ & kFloat64Ceil; } | |
157 bool HasFloat64RoundTruncate() { return flags_ & kFloat64Truncate; } | |
158 bool HasFloat64RoundTiesAway() { return flags_ & kFloat64RoundTiesAway; } | |
159 | |
138 // load [base + index] | 160 // load [base + index] |
139 const Operator* Load(LoadRepresentation rep); | 161 const Operator* Load(LoadRepresentation rep); |
140 | 162 |
141 // store [base + index], value | 163 // store [base + index], value |
142 const Operator* Store(StoreRepresentation rep); | 164 const Operator* Store(StoreRepresentation rep); |
143 | 165 |
144 // Access to the machine stack. | 166 // Access to the machine stack. |
145 const Operator* LoadStackPointer(); | 167 const Operator* LoadStackPointer(); |
146 | 168 |
147 // Target machine word-size assumed by this builder. | 169 // Target machine word-size assumed by this builder. |
(...skipping 26 matching lines...) Expand all Loading... | |
174 const Operator* Prefix##Suffix() { \ | 196 const Operator* Prefix##Suffix() { \ |
175 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ | 197 return Is32() ? Prefix##32##Suffix() : Prefix##64##Suffix(); \ |
176 } | 198 } |
177 PSEUDO_OP_LIST(PSEUDO_OP) | 199 PSEUDO_OP_LIST(PSEUDO_OP) |
178 #undef PSEUDO_OP | 200 #undef PSEUDO_OP |
179 #undef PSEUDO_OP_LIST | 201 #undef PSEUDO_OP_LIST |
180 | 202 |
181 private: | 203 private: |
182 const MachineOperatorBuilderImpl& impl_; | 204 const MachineOperatorBuilderImpl& impl_; |
183 const MachineType word_; | 205 const MachineType word_; |
206 const Flags flags_; | |
184 }; | 207 }; |
185 | 208 |
209 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | |
210 | |
186 } // namespace compiler | 211 } // namespace compiler |
187 } // namespace internal | 212 } // namespace internal |
188 } // namespace v8 | 213 } // namespace v8 |
189 | 214 |
190 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 215 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
OLD | NEW |