| 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/base/flags.h" |
| 9 #include "src/machine-type.h" | 9 #include "src/machine-type.h" |
| 10 | 10 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg | 139 kWord32ReverseBits | kWord64ReverseBits | kFloat32Neg | kFloat64Neg |
| 140 }; | 140 }; |
| 141 typedef base::Flags<Flag, unsigned> Flags; | 141 typedef base::Flags<Flag, unsigned> Flags; |
| 142 | 142 |
| 143 class AlignmentRequirements { | 143 class AlignmentRequirements { |
| 144 public: | 144 public: |
| 145 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; | 145 enum UnalignedAccessSupport { kNoSupport, kSomeSupport, kFullSupport }; |
| 146 | 146 |
| 147 bool IsUnalignedLoadSupported(const MachineType& machineType, | 147 bool IsUnalignedLoadSupported(const MachineType& machineType, |
| 148 uint8_t alignment) const { | 148 uint8_t alignment) const { |
| 149 return IsUnalignedSupported(unalignedLoadSupportedTypes_, machineType, | 149 return IsUnalignedSupported(unalignedLoadUnsupportedTypes_, machineType, |
| 150 alignment); | 150 alignment); |
| 151 } | 151 } |
| 152 | 152 |
| 153 bool IsUnalignedStoreSupported(const MachineType& machineType, | 153 bool IsUnalignedStoreSupported(const MachineType& machineType, |
| 154 uint8_t alignment) const { | 154 uint8_t alignment) const { |
| 155 return IsUnalignedSupported(unalignedStoreSupportedTypes_, machineType, | 155 return IsUnalignedSupported(unalignedStoreUnsupportedTypes_, machineType, |
| 156 alignment); | 156 alignment); |
| 157 } | 157 } |
| 158 | 158 |
| 159 static AlignmentRequirements FullUnalignedAccessSupport() { | 159 static AlignmentRequirements FullUnalignedAccessSupport() { |
| 160 return AlignmentRequirements(kFullSupport); | 160 return AlignmentRequirements(kFullSupport); |
| 161 } | 161 } |
| 162 static AlignmentRequirements NoUnalignedAccessSupport() { | 162 static AlignmentRequirements NoUnalignedAccessSupport() { |
| 163 return AlignmentRequirements(kNoSupport); | 163 return AlignmentRequirements(kNoSupport); |
| 164 } | 164 } |
| 165 static AlignmentRequirements SomeUnalignedAccessSupport( | 165 static AlignmentRequirements SomeUnalignedAccessUnsupported( |
| 166 const Vector<MachineType>& unalignedLoadSupportedTypes, | 166 const Vector<MachineType>& unalignedLoadUnsupportedTypes, |
| 167 const Vector<MachineType>& unalignedStoreSupportedTypes) { | 167 const Vector<MachineType>& unalignedStoreUnsupportedTypes) { |
| 168 return AlignmentRequirements(kSomeSupport, unalignedLoadSupportedTypes, | 168 return AlignmentRequirements(kSomeSupport, unalignedLoadUnsupportedTypes, |
| 169 unalignedStoreSupportedTypes); | 169 unalignedStoreUnsupportedTypes); |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 explicit AlignmentRequirements( | 173 explicit AlignmentRequirements( |
| 174 AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport, | 174 AlignmentRequirements::UnalignedAccessSupport unalignedAccessSupport, |
| 175 Vector<MachineType> unalignedLoadSupportedTypes = | 175 Vector<MachineType> unalignedLoadUnsupportedTypes = |
| 176 Vector<MachineType>(NULL, 0), | 176 Vector<MachineType>(NULL, 0), |
| 177 Vector<MachineType> unalignedStoreSupportedTypes = | 177 Vector<MachineType> unalignedStoreUnsupportedTypes = |
| 178 Vector<MachineType>(NULL, 0)) | 178 Vector<MachineType>(NULL, 0)) |
| 179 : unalignedSupport_(unalignedAccessSupport), | 179 : unalignedSupport_(unalignedAccessSupport), |
| 180 unalignedLoadSupportedTypes_(unalignedLoadSupportedTypes), | 180 unalignedLoadUnsupportedTypes_(unalignedLoadUnsupportedTypes), |
| 181 unalignedStoreSupportedTypes_(unalignedStoreSupportedTypes) {} | 181 unalignedStoreUnsupportedTypes_(unalignedStoreUnsupportedTypes) {} |
| 182 | 182 |
| 183 bool IsUnalignedSupported(const Vector<MachineType>& supported, | 183 bool IsUnalignedSupported(const Vector<MachineType>& unsupported, |
| 184 const MachineType& machineType, | 184 const MachineType& machineType, |
| 185 uint8_t alignment) const { | 185 uint8_t alignment) const { |
| 186 if (unalignedSupport_ == kFullSupport) { | 186 if (unalignedSupport_ == kFullSupport) { |
| 187 return true; | 187 return true; |
| 188 } else if (unalignedSupport_ == kNoSupport) { | 188 } else if (unalignedSupport_ == kNoSupport) { |
| 189 return false; | 189 return false; |
| 190 } else { | 190 } else { |
| 191 for (MachineType m : supported) { | 191 for (MachineType m : unsupported) { |
| 192 if (m == machineType) { | 192 if (m == machineType) { |
| 193 return true; | 193 return false; |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 return false; | 196 return true; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 | 199 |
| 200 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_; | 200 const AlignmentRequirements::UnalignedAccessSupport unalignedSupport_; |
| 201 const Vector<MachineType> unalignedLoadSupportedTypes_; | 201 const Vector<MachineType> unalignedLoadUnsupportedTypes_; |
| 202 const Vector<MachineType> unalignedStoreSupportedTypes_; | 202 const Vector<MachineType> unalignedStoreUnsupportedTypes_; |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 explicit MachineOperatorBuilder( | 205 explicit MachineOperatorBuilder( |
| 206 Zone* zone, | 206 Zone* zone, |
| 207 MachineRepresentation word = MachineType::PointerRepresentation(), | 207 MachineRepresentation word = MachineType::PointerRepresentation(), |
| 208 Flags supportedOperators = kNoFlags, | 208 Flags supportedOperators = kNoFlags, |
| 209 AlignmentRequirements alignmentRequirements = | 209 AlignmentRequirements alignmentRequirements = |
| 210 AlignmentRequirements::FullUnalignedAccessSupport()); | 210 AlignmentRequirements::FullUnalignedAccessSupport()); |
| 211 | 211 |
| 212 const Operator* Comment(const char* msg); | 212 const Operator* Comment(const char* msg); |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 698 }; | 698 }; |
| 699 | 699 |
| 700 | 700 |
| 701 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) | 701 DEFINE_OPERATORS_FOR_FLAGS(MachineOperatorBuilder::Flags) |
| 702 | 702 |
| 703 } // namespace compiler | 703 } // namespace compiler |
| 704 } // namespace internal | 704 } // namespace internal |
| 705 } // namespace v8 | 705 } // namespace v8 |
| 706 | 706 |
| 707 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ | 707 #endif // V8_COMPILER_MACHINE_OPERATOR_H_ |
| OLD | NEW |