Chromium Code Reviews| Index: src/IceTypes.h |
| diff --git a/src/IceTypes.h b/src/IceTypes.h |
| index cc782ab59d1c24bdbe59bc9fa6ec5c1503631dce..fdf0454a6cfcc109d393075f70aa4aa081b49aef 100644 |
| --- a/src/IceTypes.h |
| +++ b/src/IceTypes.h |
| @@ -69,6 +69,34 @@ Type getCompareResultType(Type Ty); |
| /// Returns the number of bits in a scalar integer type. |
| SizeT getScalarIntBitWidth(Type Ty); |
| +// Check if a type is byte sized (slight optimization over typeWidthInBytes). |
| +inline bool isByteSizedType(Type Ty) { |
| + bool result = Ty == IceType_i8 || Ty == IceType_i1; |
| + assert(result == (1 == typeWidthInBytes(Ty))); |
| + return result; |
| +} |
| + |
| +// Check if Ty is byte sized and specifically i8. Assert that it's not |
| +// byte sized due to being an i1. |
| +inline bool isByteSizedArithType(Type Ty) { |
| + assert(Ty != IceType_i1); |
| + return Ty == IceType_i8; |
| +} |
| + |
| +// Assuming Ty is either i32 or i64, return true if Ty is i32. |
| +inline bool isInt32Assuming32Or64(Type Ty) { |
|
jvoung (off chromium)
2014/09/27 00:23:39
Hmm different name suggestions welcome
Jim Stichnoth
2014/09/27 00:38:22
I guess my suggestion would be
isI32AssumingI32O
jvoung (off chromium)
2014/09/29 16:10:51
Going with "Asserting" instead of "Assuming"
|
| + bool result = Ty == IceType_i32; |
| + assert(result || Ty == IceType_i64); |
| + return result; |
| +} |
| + |
| +// Assuming Ty is either f32 or f64, return true if Ty is f32. |
| +inline bool isFloat32Assuming32Or64(Type Ty) { |
| + bool result = Ty == IceType_f32; |
| + assert(result || Ty == IceType_f64); |
| + return result; |
| +} |
| + |
| template <typename StreamType> |
| inline StreamType &operator<<(StreamType &Str, const Type &Ty) { |
| Str << typeString(Ty); |