| 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 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 std::ostream& operator<<(std::ostream& os, | 15 std::ostream& operator<<(std::ostream& os, WriteBarrierKind kind) { |
| 16 const WriteBarrierKind& write_barrier_kind) { | 16 switch (kind) { |
| 17 switch (write_barrier_kind) { | |
| 18 case kNoWriteBarrier: | 17 case kNoWriteBarrier: |
| 19 return os << "NoWriteBarrier"; | 18 return os << "NoWriteBarrier"; |
| 20 case kFullWriteBarrier: | 19 case kFullWriteBarrier: |
| 21 return os << "FullWriteBarrier"; | 20 return os << "FullWriteBarrier"; |
| 22 } | 21 } |
| 23 UNREACHABLE(); | 22 UNREACHABLE(); |
| 24 return os; | 23 return os; |
| 25 } | 24 } |
| 26 | 25 |
| 27 | 26 |
| 28 std::ostream& operator<<(std::ostream& os, const StoreRepresentation& rep) { | 27 bool operator==(StoreRepresentation lhs, StoreRepresentation rhs) { |
| 28 return lhs.machine_type() == rhs.machine_type() && |
| 29 lhs.write_barrier_kind() == rhs.write_barrier_kind(); |
| 30 } |
| 31 |
| 32 |
| 33 bool operator!=(StoreRepresentation lhs, StoreRepresentation rhs) { |
| 34 return !(lhs == rhs); |
| 35 } |
| 36 |
| 37 |
| 38 size_t hash_value(StoreRepresentation rep) { |
| 39 return base::hash_combine(rep.machine_type(), rep.write_barrier_kind()); |
| 40 } |
| 41 |
| 42 |
| 43 std::ostream& operator<<(std::ostream& os, StoreRepresentation rep) { |
| 29 return os << "(" << rep.machine_type() << " : " << rep.write_barrier_kind() | 44 return os << "(" << rep.machine_type() << " : " << rep.write_barrier_kind() |
| 30 << ")"; | 45 << ")"; |
| 31 } | 46 } |
| 32 | 47 |
| 33 | 48 |
| 34 template <> | |
| 35 struct StaticParameterTraits<StoreRepresentation> { | |
| 36 static std::ostream& PrintTo(std::ostream& os, | |
| 37 const StoreRepresentation& rep) { | |
| 38 return os << rep; | |
| 39 } | |
| 40 static int HashCode(const StoreRepresentation& rep) { | |
| 41 return rep.machine_type() + rep.write_barrier_kind(); | |
| 42 } | |
| 43 static bool Equals(const StoreRepresentation& rep1, | |
| 44 const StoreRepresentation& rep2) { | |
| 45 return rep1 == rep2; | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 | |
| 50 template <> | |
| 51 struct StaticParameterTraits<LoadRepresentation> { | |
| 52 static std::ostream& PrintTo(std::ostream& os, | |
| 53 LoadRepresentation type) { // NOLINT | |
| 54 return os << type; | |
| 55 } | |
| 56 static int HashCode(LoadRepresentation type) { return type; } | |
| 57 static bool Equals(LoadRepresentation lhs, LoadRepresentation rhs) { | |
| 58 return lhs == rhs; | |
| 59 } | |
| 60 }; | |
| 61 | |
| 62 | |
| 63 #define PURE_OP_LIST(V) \ | 49 #define PURE_OP_LIST(V) \ |
| 64 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 1) \ | 50 V(Word32And, Operator::kAssociative | Operator::kCommutative, 2, 1) \ |
| 65 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 1) \ | 51 V(Word32Or, Operator::kAssociative | Operator::kCommutative, 2, 1) \ |
| 66 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 1) \ | 52 V(Word32Xor, Operator::kAssociative | Operator::kCommutative, 2, 1) \ |
| 67 V(Word32Shl, Operator::kNoProperties, 2, 1) \ | 53 V(Word32Shl, Operator::kNoProperties, 2, 1) \ |
| 68 V(Word32Shr, Operator::kNoProperties, 2, 1) \ | 54 V(Word32Shr, Operator::kNoProperties, 2, 1) \ |
| 69 V(Word32Sar, Operator::kNoProperties, 2, 1) \ | 55 V(Word32Sar, Operator::kNoProperties, 2, 1) \ |
| 70 V(Word32Ror, Operator::kNoProperties, 2, 1) \ | 56 V(Word32Ror, Operator::kNoProperties, 2, 1) \ |
| 71 V(Word32Equal, Operator::kCommutative, 2, 1) \ | 57 V(Word32Equal, Operator::kCommutative, 2, 1) \ |
| 72 V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 1) \ | 58 V(Word64And, Operator::kAssociative | Operator::kCommutative, 2, 1) \ |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 default: | 226 default: |
| 241 break; | 227 break; |
| 242 } | 228 } |
| 243 UNREACHABLE(); | 229 UNREACHABLE(); |
| 244 return NULL; | 230 return NULL; |
| 245 } | 231 } |
| 246 | 232 |
| 247 } // namespace compiler | 233 } // namespace compiler |
| 248 } // namespace internal | 234 } // namespace internal |
| 249 } // namespace v8 | 235 } // namespace v8 |
| OLD | NEW |