Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/IceTypes.h

Issue 613483002: Change some explicit type checks into using helper functions. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: format Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | src/assembler_ia32.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « src/IceTargetLoweringX8632.cpp ('k') | src/assembler_ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698