2014-08-14 09:19:54 +00:00
|
|
|
// 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.
|
|
|
|
|
2015-12-03 13:33:14 +00:00
|
|
|
#include "src/machine-type.h"
|
2014-08-14 09:19:54 +00:00
|
|
|
#include "src/ostreams.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
2017-08-03 14:27:11 +00:00
|
|
|
bool IsSubtype(MachineRepresentation rep1, MachineRepresentation rep2) {
|
|
|
|
if (rep1 == rep2) return true;
|
|
|
|
switch (rep1) {
|
|
|
|
case MachineRepresentation::kTaggedSigned:
|
|
|
|
return rep2 == MachineRepresentation::kTagged;
|
|
|
|
case MachineRepresentation ::kTaggedPointer:
|
|
|
|
return rep2 == MachineRepresentation ::kTagged;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
std::ostream& operator<<(std::ostream& os, MachineRepresentation rep) {
|
2016-06-29 09:26:40 +00:00
|
|
|
return os << MachineReprToString(rep);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* MachineReprToString(MachineRepresentation rep) {
|
2015-12-10 09:03:30 +00:00
|
|
|
switch (rep) {
|
|
|
|
case MachineRepresentation::kNone:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kMachNone";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kBit:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepBit";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kWord8:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepWord8";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kWord16:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepWord16";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kWord32:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepWord32";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kWord64:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepWord64";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kFloat32:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepFloat32";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kFloat64:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepFloat64";
|
2016-02-17 19:03:43 +00:00
|
|
|
case MachineRepresentation::kSimd128:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepSimd128";
|
2016-08-16 12:41:13 +00:00
|
|
|
case MachineRepresentation::kTaggedSigned:
|
|
|
|
return "kRepTaggedSigned";
|
|
|
|
case MachineRepresentation::kTaggedPointer:
|
|
|
|
return "kRepTaggedPointer";
|
2015-12-10 09:03:30 +00:00
|
|
|
case MachineRepresentation::kTagged:
|
2016-06-29 09:26:40 +00:00
|
|
|
return "kRepTagged";
|
2014-08-14 09:19:54 +00:00
|
|
|
}
|
2015-12-10 09:03:30 +00:00
|
|
|
UNREACHABLE();
|
|
|
|
}
|
2014-08-14 09:19:54 +00:00
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
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::kNumber:
|
|
|
|
return os << "kTypeNumber";
|
|
|
|
case MachineSemantic::kAny:
|
|
|
|
return os << "kTypeAny";
|
|
|
|
}
|
|
|
|
UNREACHABLE();
|
2014-08-14 09:19:54 +00:00
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
|
|
|
|
|
2015-12-10 09:03:30 +00:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
return os;
|
|
|
|
}
|
2014-08-25 10:35:38 +00:00
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|