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 944449 : std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
24 1492216 : return os << MachineReprToString(rep);
25 : }
26 :
27 1493225 : const char* MachineReprToString(MachineRepresentation rep) {
28 1493225 : switch (rep) {
29 : case MachineRepresentation::kNone:
30 : return "kMachNone";
31 : case MachineRepresentation::kBit:
32 67 : return "kRepBit";
33 : case MachineRepresentation::kWord8:
34 163417 : return "kRepWord8";
35 : case MachineRepresentation::kWord16:
36 163417 : return "kRepWord16";
37 : case MachineRepresentation::kWord32:
38 463151 : return "kRepWord32";
39 : case MachineRepresentation::kWord64:
40 429947 : return "kRepWord64";
41 : case MachineRepresentation::kFloat32:
42 97067 : return "kRepFloat32";
43 : case MachineRepresentation::kFloat64:
44 91091 : 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 85050 : return "kRepTagged";
53 : }
54 0 : UNREACHABLE();
55 : }
56 :
57 517443 : std::ostream& operator<<(std::ostream& os, MachineSemantic type) {
58 517443 : 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 172425 : return os << "kTypeInt32";
65 : case MachineSemantic::kUint32:
66 169400 : return os << "kTypeUint32";
67 : case MachineSemantic::kInt64:
68 36300 : return os << "kTypeInt64";
69 : case MachineSemantic::kUint64:
70 36300 : return os << "kTypeUint64";
71 : case MachineSemantic::kNumber:
72 66568 : return os << "kTypeNumber";
73 : case MachineSemantic::kAny:
74 36450 : return os << "kTypeAny";
75 : }
76 0 : UNREACHABLE();
77 : }
78 :
79 :
80 547767 : std::ostream& operator<<(std::ostream& os, MachineType type) {
81 547767 : if (type == MachineType::None()) {
82 : return os;
83 547767 : } else if (type.representation() == MachineRepresentation::kNone) {
84 0 : return os << type.semantic();
85 547767 : } else if (type.semantic() == MachineSemantic::kNone) {
86 30324 : return os << type.representation();
87 : } else {
88 517443 : return os << type.representation() << "|" << type.semantic();
89 : }
90 : return os;
91 : }
92 :
93 : } // namespace internal
94 : } // namespace v8
|