Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "src/machine-type.h" |
| 6 | #include "src/ostreams.h" |
| 7 | |
| 8 | namespace v8 { |
| 9 | namespace internal { |
| 10 | |
| 11 | std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) { |
| 12 | switch (rep) { |
| 13 | case MachineRepresentation::kNone: |
| 14 | return os << "kMachNone"; |
| 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"; |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 29 | case MachineRepresentation::kSimd128: |
| 30 | return os << "kRepSimd128"; |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 31 | case MachineRepresentation::kTagged: |
| 32 | return os << "kRepTagged"; |
| 33 | } |
| 34 | UNREACHABLE(); |
| 35 | return os; |
| 36 | } |
| 37 | |
| 38 | |
| 39 | std::ostream& operator<<(std::ostream& os, MachineSemantic type) { |
| 40 | switch (type) { |
| 41 | case MachineSemantic::kNone: |
| 42 | return os << "kMachNone"; |
| 43 | case MachineSemantic::kBool: |
| 44 | return os << "kTypeBool"; |
| 45 | case MachineSemantic::kInt32: |
| 46 | return os << "kTypeInt32"; |
| 47 | case MachineSemantic::kUint32: |
| 48 | return os << "kTypeUint32"; |
| 49 | case MachineSemantic::kInt64: |
| 50 | return os << "kTypeInt64"; |
| 51 | case MachineSemantic::kUint64: |
| 52 | return os << "kTypeUint64"; |
| 53 | case MachineSemantic::kNumber: |
| 54 | return os << "kTypeNumber"; |
| 55 | case MachineSemantic::kAny: |
| 56 | return os << "kTypeAny"; |
| 57 | } |
| 58 | UNREACHABLE(); |
| 59 | return os; |
| 60 | } |
| 61 | |
| 62 | |
| 63 | std::ostream& operator<<(std::ostream& os, MachineType type) { |
| 64 | if (type == MachineType::None()) { |
| 65 | return os; |
| 66 | } else if (type.representation() == MachineRepresentation::kNone) { |
| 67 | return os << type.semantic(); |
| 68 | } else if (type.semantic() == MachineSemantic::kNone) { |
| 69 | return os << type.representation(); |
| 70 | } else { |
| 71 | return os << type.representation() << "|" << type.semantic(); |
| 72 | } |
| 73 | return os; |
| 74 | } |
| 75 | |
| 76 | } // namespace internal |
| 77 | } // namespace v8 |