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