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