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/machine-type.h" | 5 #include "src/machine-type.h" |
6 #include "src/ostreams.h" | 6 #include "src/ostreams.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
11 #define PRINT(bit) \ | 11 std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) { |
12 if (type & bit) { \ | 12 switch (rep) { |
13 if (before) os << "|"; \ | 13 case MachineRepresentation::kNone: |
14 os << #bit; \ | 14 return os << "kMachNone"; |
15 before = true; \ | 15 case MachineRepresentation::kBit: |
| 16 return os << "kRepBit"; |
| 17 case MachineRepresentation::kWord8: |
| 18 return os << "kRepWord8"; |
| 19 case MachineRepresentation::kWord16: |
| 20 return os << "kRepWord16"; |
| 21 case MachineRepresentation::kWord32: |
| 22 return os << "kRepWord32"; |
| 23 case MachineRepresentation::kWord64: |
| 24 return os << "kRepWord64"; |
| 25 case MachineRepresentation::kFloat32: |
| 26 return os << "kRepFloat32"; |
| 27 case MachineRepresentation::kFloat64: |
| 28 return os << "kRepFloat64"; |
| 29 case MachineRepresentation::kTagged: |
| 30 return os << "kRepTagged"; |
16 } | 31 } |
17 | 32 UNREACHABLE(); |
18 | |
19 std::ostream& operator<<(std::ostream& os, const MachineType& type) { | |
20 bool before = false; | |
21 PRINT(kRepBit); | |
22 PRINT(kRepWord8); | |
23 PRINT(kRepWord16); | |
24 PRINT(kRepWord32); | |
25 PRINT(kRepWord64); | |
26 PRINT(kRepFloat32); | |
27 PRINT(kRepFloat64); | |
28 PRINT(kRepTagged); | |
29 | |
30 PRINT(kTypeBool); | |
31 PRINT(kTypeInt32); | |
32 PRINT(kTypeUint32); | |
33 PRINT(kTypeInt64); | |
34 PRINT(kTypeUint64); | |
35 PRINT(kTypeNumber); | |
36 PRINT(kTypeAny); | |
37 return os; | 33 return os; |
38 } | 34 } |
39 | 35 |
40 | 36 |
41 #undef PRINT | 37 std::ostream& operator<<(std::ostream& os, MachineSemantic type) { |
| 38 switch (type) { |
| 39 case MachineSemantic::kNone: |
| 40 return os << "kMachNone"; |
| 41 case MachineSemantic::kBool: |
| 42 return os << "kTypeBool"; |
| 43 case MachineSemantic::kInt32: |
| 44 return os << "kTypeInt32"; |
| 45 case MachineSemantic::kUint32: |
| 46 return os << "kTypeUint32"; |
| 47 case MachineSemantic::kInt64: |
| 48 return os << "kTypeInt64"; |
| 49 case MachineSemantic::kUint64: |
| 50 return os << "kTypeUint64"; |
| 51 case MachineSemantic::kNumber: |
| 52 return os << "kTypeNumber"; |
| 53 case MachineSemantic::kAny: |
| 54 return os << "kTypeAny"; |
| 55 } |
| 56 UNREACHABLE(); |
| 57 return os; |
| 58 } |
| 59 |
| 60 |
| 61 std::ostream& operator<<(std::ostream& os, MachineType type) { |
| 62 if (type == MachineType::None()) { |
| 63 return os; |
| 64 } else if (type.representation() == MachineRepresentation::kNone) { |
| 65 return os << type.semantic(); |
| 66 } else if (type.semantic() == MachineSemantic::kNone) { |
| 67 return os << type.representation(); |
| 68 } else { |
| 69 return os << type.representation() << "|" << type.semantic(); |
| 70 } |
| 71 return os; |
| 72 } |
42 | 73 |
43 } // namespace internal | 74 } // namespace internal |
44 } // namespace v8 | 75 } // namespace v8 |
OLD | NEW |