Line data Source code
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 0 : bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2) {
12 0 : if (rep1 == rep2) return true;
13 0 : switch (rep1) {
14 : case MachineRepresentation::kTaggedSigned: // Fall through.
15 : case MachineRepresentation::kTaggedPointer:
16 0 : return rep2 == MachineRepresentation::kTagged;
17 : case MachineRepresentation::kCompressedSigned: // Fall through.
18 : case MachineRepresentation::kCompressedPointer:
19 0 : return rep2 == MachineRepresentation::kCompressed;
20 : default:
21 : return false;
22 : }
23 : }
24 :
25 962490 : std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
26 1520842 : return os << MachineReprToString(rep);
27 : }
28 :
29 1521648 : const char* MachineReprToString(MachineRepresentation rep) {
30 1521648 : switch (rep) {
31 : case MachineRepresentation::kNone:
32 : return "kMachNone";
33 : case MachineRepresentation::kBit:
34 67 : return "kRepBit";
35 : case MachineRepresentation::kWord8:
36 166549 : return "kRepWord8";
37 : case MachineRepresentation::kWord16:
38 166549 : return "kRepWord16";
39 : case MachineRepresentation::kWord32:
40 472045 : return "kRepWord32";
41 : case MachineRepresentation::kWord64:
42 438268 : return "kRepWord64";
43 : case MachineRepresentation::kFloat32:
44 98883 : return "kRepFloat32";
45 : case MachineRepresentation::kFloat64:
46 92717 : return "kRepFloat64";
47 : case MachineRepresentation::kSimd128:
48 0 : return "kRepSimd128";
49 : case MachineRepresentation::kTaggedSigned:
50 0 : return "kRepTaggedSigned";
51 : case MachineRepresentation::kTaggedPointer:
52 0 : return "kRepTaggedPointer";
53 : case MachineRepresentation::kTagged:
54 86570 : return "kRepTagged";
55 : case MachineRepresentation::kCompressedSigned:
56 0 : return "kRepCompressedSigned";
57 : case MachineRepresentation::kCompressedPointer:
58 0 : return "kRepCompressedPointer";
59 : case MachineRepresentation::kCompressed:
60 0 : return "kRepCompressed";
61 : }
62 0 : UNREACHABLE();
63 : }
64 :
65 527490 : std::ostream& operator<<(std::ostream& os, MachineSemantic type) {
66 527490 : switch (type) {
67 : case MachineSemantic::kNone:
68 0 : return os << "kMachNone";
69 : case MachineSemantic::kBool:
70 0 : return os << "kTypeBool";
71 : case MachineSemantic::kInt32:
72 175731 : return os << "kTypeInt32";
73 : case MachineSemantic::kUint32:
74 172648 : return os << "kTypeUint32";
75 : case MachineSemantic::kInt64:
76 36996 : return os << "kTypeInt64";
77 : case MachineSemantic::kUint64:
78 37188 : return os << "kTypeUint64";
79 : case MachineSemantic::kNumber:
80 67826 : return os << "kTypeNumber";
81 : case MachineSemantic::kAny:
82 37101 : return os << "kTypeAny";
83 : }
84 0 : UNREACHABLE();
85 : }
86 :
87 :
88 558352 : std::ostream& operator<<(std::ostream& os, MachineType type) {
89 558352 : if (type == MachineType::None()) {
90 : return os;
91 558352 : } else if (type.representation() == MachineRepresentation::kNone) {
92 0 : return os << type.semantic();
93 558352 : } else if (type.semantic() == MachineSemantic::kNone) {
94 30862 : return os << type.representation();
95 : } else {
96 527490 : return os << type.representation() << "|" << type.semantic();
97 : }
98 : return os;
99 : }
100 :
101 : } // namespace internal
102 : } // namespace v8
|