5 #include "src/machine-type.h" 6 #include "src/ostreams.h" 11 bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2) {
12 if (rep1 == rep2)
return true;
14 case MachineRepresentation::kTaggedSigned:
15 return rep2 == MachineRepresentation::kTagged;
16 case MachineRepresentation ::kTaggedPointer:
17 return rep2 == MachineRepresentation ::kTagged;
23 std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
24 return os << MachineReprToString(rep);
27 const char* MachineReprToString(MachineRepresentation rep) {
29 case MachineRepresentation::kNone:
31 case MachineRepresentation::kBit:
33 case MachineRepresentation::kWord8:
35 case MachineRepresentation::kWord16:
37 case MachineRepresentation::kWord32:
39 case MachineRepresentation::kWord64:
41 case MachineRepresentation::kFloat32:
43 case MachineRepresentation::kFloat64:
45 case MachineRepresentation::kSimd128:
47 case MachineRepresentation::kTaggedSigned:
48 return "kRepTaggedSigned";
49 case MachineRepresentation::kTaggedPointer:
50 return "kRepTaggedPointer";
51 case MachineRepresentation::kTagged:
57 std::ostream& operator<<(std::ostream& os, MachineSemantic type) {
59 case MachineSemantic::kNone:
60 return os <<
"kMachNone";
61 case MachineSemantic::kBool:
62 return os <<
"kTypeBool";
63 case MachineSemantic::kInt32:
64 return os <<
"kTypeInt32";
65 case MachineSemantic::kUint32:
66 return os <<
"kTypeUint32";
67 case MachineSemantic::kInt64:
68 return os <<
"kTypeInt64";
69 case MachineSemantic::kUint64:
70 return os <<
"kTypeUint64";
71 case MachineSemantic::kNumber:
72 return os <<
"kTypeNumber";
73 case MachineSemantic::kAny:
74 return os <<
"kTypeAny";
80 std::ostream& operator<<(std::ostream& os, MachineType type) {
81 if (type == MachineType::None()) {
83 }
else if (type.representation() == MachineRepresentation::kNone) {
84 return os << type.semantic();
85 }
else if (type.semantic() == MachineSemantic::kNone) {
86 return os << type.representation();
88 return os << type.representation() <<
"|" << type.semantic();