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 return os << MachineReprToString(rep); 13 } 14 15 const char* MachineReprToString(MachineRepresentation rep) { 16 switch (rep) { 17 case MachineRepresentation::kNone: 18 return "kMachNone"; 19 case MachineRepresentation::kBit: 20 return "kRepBit"; 21 case MachineRepresentation::kWord8: 22 return "kRepWord8"; 23 case MachineRepresentation::kWord16: 24 return "kRepWord16"; 25 case MachineRepresentation::kWord32: 26 return "kRepWord32"; 27 case MachineRepresentation::kWord64: 28 return "kRepWord64"; 29 case MachineRepresentation::kFloat32: 30 return "kRepFloat32"; 31 case MachineRepresentation::kFloat64: 32 return "kRepFloat64"; 33 case MachineRepresentation::kSimd128: 34 return "kRepSimd128"; 35 case MachineRepresentation::kSimd1x4: 36 return "kRepSimd1x4"; 37 case MachineRepresentation::kSimd1x8: 38 return "kRepSimd1x8"; 39 case MachineRepresentation::kSimd1x16: 40 return "kRepSimd1x16"; 41 case MachineRepresentation::kTaggedSigned: 42 return "kRepTaggedSigned"; 43 case MachineRepresentation::kTaggedPointer: 44 return "kRepTaggedPointer"; 45 case MachineRepresentation::kTagged: 46 return "kRepTagged"; 47 } 48 UNREACHABLE(); 49 return nullptr; 50 } 51 52 std::ostream& operator<<(std::ostream& os, MachineSemantic type) { 53 switch (type) { 54 case MachineSemantic::kNone: 55 return os << "kMachNone"; 56 case MachineSemantic::kBool: 57 return os << "kTypeBool"; 58 case MachineSemantic::kInt32: 59 return os << "kTypeInt32"; 60 case MachineSemantic::kUint32: 61 return os << "kTypeUint32"; 62 case MachineSemantic::kInt64: 63 return os << "kTypeInt64"; 64 case MachineSemantic::kUint64: 65 return os << "kTypeUint64"; 66 case MachineSemantic::kNumber: 67 return os << "kTypeNumber"; 68 case MachineSemantic::kAny: 69 return os << "kTypeAny"; 70 } 71 UNREACHABLE(); 72 return os; 73 } 74 75 76 std::ostream& operator<<(std::ostream& os, MachineType type) { 77 if (type == MachineType::None()) { 78 return os; 79 } else if (type.representation() == MachineRepresentation::kNone) { 80 return os << type.semantic(); 81 } else if (type.semantic() == MachineSemantic::kNone) { 82 return os << type.representation(); 83 } else { 84 return os << type.representation() << "|" << type.semantic(); 85 } 86 return os; 87 } 88 89 } // namespace internal 90 } // namespace v8 91