forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmachine-type.cc
More file actions
117 lines (109 loc) Β· 3.75 KB
/
machine-type.cc
File metadata and controls
117 lines (109 loc) Β· 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "src/codegen/machine-type.h"
#include "src/utils/ostreams.h"
namespace v8 {
namespace internal {
bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2) {
if (rep1 == rep2) return true;
switch (rep1) {
case MachineRepresentation::kTaggedSigned: // Fall through.
case MachineRepresentation::kTaggedPointer:
return rep2 == MachineRepresentation::kTagged;
case MachineRepresentation::kCompressedPointer:
return rep2 == MachineRepresentation::kCompressed;
default:
return false;
}
}
std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
return os << MachineReprToString(rep);
}
const char* MachineReprToString(MachineRepresentation rep) {
switch (rep) {
case MachineRepresentation::kNone:
return "kMachNone";
case MachineRepresentation::kBit:
return "kRepBit";
case MachineRepresentation::kWord8:
return "kRepWord8";
case MachineRepresentation::kWord16:
return "kRepWord16";
case MachineRepresentation::kWord32:
return "kRepWord32";
case MachineRepresentation::kWord64:
return "kRepWord64";
case MachineRepresentation::kFloat16:
return "kRepFloat16";
case MachineRepresentation::kFloat16RawBits:
return "kRepFloat16RawBits";
case MachineRepresentation::kFloat32:
return "kRepFloat32";
case MachineRepresentation::kFloat64:
return "kRepFloat64";
case MachineRepresentation::kSimd128:
return "kRepSimd128";
case MachineRepresentation::kSimd256:
return "kRepSimd256";
case MachineRepresentation::kTaggedSigned:
return "kRepTaggedSigned";
case MachineRepresentation::kTaggedPointer:
return "kRepTaggedPointer";
case MachineRepresentation::kTagged:
return "kRepTagged";
case MachineRepresentation::kCompressedPointer:
return "kRepCompressedPointer";
case MachineRepresentation::kCompressed:
return "kRepCompressed";
case MachineRepresentation::kProtectedPointer:
return "kRepProtectedPointer";
case MachineRepresentation::kIndirectPointer:
return "kRepIndirectPointer";
case MachineRepresentation::kMapWord:
return "kRepMapWord";
case MachineRepresentation::kSandboxedPointer:
return "kRepSandboxedPointer";
}
UNREACHABLE();
}
std::ostream& operator<<(std::ostream& os, MachineSemantic type) {
switch (type) {
case MachineSemantic::kNone:
return os << "kMachNone";
case MachineSemantic::kBool:
return os << "kTypeBool";
case MachineSemantic::kInt32:
return os << "kTypeInt32";
case MachineSemantic::kUint32:
return os << "kTypeUint32";
case MachineSemantic::kInt64:
return os << "kTypeInt64";
case MachineSemantic::kUint64:
return os << "kTypeUint64";
case MachineSemantic::kSignedBigInt64:
return os << "kTypeSignedBigInt64";
case MachineSemantic::kUnsignedBigInt64:
return os << "kTypeUnsignedBigInt64";
case MachineSemantic::kNumber:
return os << "kTypeNumber";
case MachineSemantic::kHoleyFloat64:
return os << "kTypeHoleyFloat64";
case MachineSemantic::kAny:
return os << "kTypeAny";
}
UNREACHABLE();
}
std::ostream& operator<<(std::ostream& os, MachineType type) {
if (type == MachineType::None()) {
return os;
} else if (type.representation() == MachineRepresentation::kNone) {
return os << type.semantic();
} else if (type.semantic() == MachineSemantic::kNone) {
return os << type.representation();
} else {
return os << type.representation() << "|" << type.semantic();
}
}
} // namespace internal
} // namespace v8