OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_MACHINE_TYPE_H_ | 5 #ifndef V8_MACHINE_TYPE_H_ |
6 #define V8_MACHINE_TYPE_H_ | 6 #define V8_MACHINE_TYPE_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 static MachineType RepSimd128() { | 152 static MachineType RepSimd128() { |
153 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); | 153 return MachineType(MachineRepresentation::kSimd128, MachineSemantic::kNone); |
154 } | 154 } |
155 static MachineType RepTagged() { | 155 static MachineType RepTagged() { |
156 return MachineType(MachineRepresentation::kTagged, MachineSemantic::kNone); | 156 return MachineType(MachineRepresentation::kTagged, MachineSemantic::kNone); |
157 } | 157 } |
158 static MachineType RepBit() { | 158 static MachineType RepBit() { |
159 return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); | 159 return MachineType(MachineRepresentation::kBit, MachineSemantic::kNone); |
160 } | 160 } |
161 | 161 |
| 162 static MachineType TypeForRepresentation(MachineRepresentation& rep, |
| 163 bool isSigned = true) { |
| 164 switch (rep) { |
| 165 case MachineRepresentation::kNone: |
| 166 return MachineType::None(); |
| 167 case MachineRepresentation::kBit: |
| 168 return MachineType::Bool(); |
| 169 case MachineRepresentation::kWord8: |
| 170 return isSigned ? MachineType::Int8() : MachineType::Uint8(); |
| 171 case MachineRepresentation::kWord16: |
| 172 return isSigned ? MachineType::Int16() : MachineType::Uint16(); |
| 173 case MachineRepresentation::kWord32: |
| 174 return isSigned ? MachineType::Int32() : MachineType::Uint32(); |
| 175 case MachineRepresentation::kWord64: |
| 176 return isSigned ? MachineType::Int64() : MachineType::Uint64(); |
| 177 case MachineRepresentation::kFloat32: |
| 178 return MachineType::Float32(); |
| 179 case MachineRepresentation::kFloat64: |
| 180 return MachineType::Float64(); |
| 181 case MachineRepresentation::kSimd128: |
| 182 return MachineType::Simd128(); |
| 183 case MachineRepresentation::kTagged: |
| 184 return MachineType::AnyTagged(); |
| 185 default: |
| 186 UNREACHABLE(); |
| 187 return MachineType::None(); |
| 188 } |
| 189 } |
| 190 |
162 private: | 191 private: |
163 MachineRepresentation representation_; | 192 MachineRepresentation representation_; |
164 MachineSemantic semantic_; | 193 MachineSemantic semantic_; |
165 }; | 194 }; |
166 | 195 |
167 V8_INLINE size_t hash_value(MachineRepresentation rep) { | 196 V8_INLINE size_t hash_value(MachineRepresentation rep) { |
168 return static_cast<size_t>(rep); | 197 return static_cast<size_t>(rep); |
169 } | 198 } |
170 | 199 |
171 V8_INLINE size_t hash_value(MachineType type) { | 200 V8_INLINE size_t hash_value(MachineType type) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 UNREACHABLE(); | 236 UNREACHABLE(); |
208 return -1; | 237 return -1; |
209 } | 238 } |
210 | 239 |
211 typedef Signature<MachineType> MachineSignature; | 240 typedef Signature<MachineType> MachineSignature; |
212 | 241 |
213 } // namespace internal | 242 } // namespace internal |
214 } // namespace v8 | 243 } // namespace v8 |
215 | 244 |
216 #endif // V8_MACHINE_TYPE_H_ | 245 #endif // V8_MACHINE_TYPE_H_ |
OLD | NEW |