Index: src/machine-type.h |
diff --git a/src/machine-type.h b/src/machine-type.h |
index c72ead527b2d1d9595b89299328895377a7a13a5..f2c3e75f2de2a528925c2ad8be0b4e3b565e23cc 100644 |
--- a/src/machine-type.h |
+++ b/src/machine-type.h |
@@ -159,6 +159,35 @@ class MachineType { |
return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); |
} |
+ static MachineType TypeForRepresentation(MachineRepresentation& rep, |
+ bool isSigned = true) { |
+ switch (rep) { |
+ case MachineRepresentation::kNone: |
+ return MachineType::None(); |
+ case MachineRepresentation::kBit: |
+ return MachineType::Bool(); |
+ case MachineRepresentation::kWord8: |
+ return isSigned ? MachineType::Int8() : MachineType::Uint8(); |
+ case MachineRepresentation::kWord16: |
+ return isSigned ? MachineType::Int16() : MachineType::Uint16(); |
+ case MachineRepresentation::kWord32: |
+ return isSigned ? MachineType::Int32() : MachineType::Uint32(); |
+ case MachineRepresentation::kWord64: |
+ return isSigned ? MachineType::Int64() : MachineType::Uint64(); |
+ case MachineRepresentation::kFloat32: |
+ return MachineType::Float32(); |
+ case MachineRepresentation::kFloat64: |
+ return MachineType::Float64(); |
+ case MachineRepresentation::kSimd128: |
+ return MachineType::Simd128(); |
+ case MachineRepresentation::kTagged: |
+ return MachineType::AnyTagged(); |
+ default: |
+ UNREACHABLE(); |
+ return MachineType::None(); |
+ } |
+ } |
+ |
private: |
MachineRepresentation representation_; |
MachineSemantic semantic_; |