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

Side by Side 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: rename Created 6 years, 2 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 unified diff | Download patch
OLDNEW
1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===// 1 //===- subzero/src/IceTypes.h - Primitive ICE types -------------*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares a few properties of the primitive types allowed 10 // This file declares a few properties of the primitive types allowed
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 bool isLoadStoreType(Type Ty); 62 bool isLoadStoreType(Type Ty);
63 63
64 /// Returns type generated by applying the compare instructions (icmp and fcmp) 64 /// Returns type generated by applying the compare instructions (icmp and fcmp)
65 /// to arguments of the given type. Returns IceType_void if compare is not 65 /// to arguments of the given type. Returns IceType_void if compare is not
66 /// allowed. 66 /// allowed.
67 Type getCompareResultType(Type Ty); 67 Type getCompareResultType(Type Ty);
68 68
69 /// Returns the number of bits in a scalar integer type. 69 /// Returns the number of bits in a scalar integer type.
70 SizeT getScalarIntBitWidth(Type Ty); 70 SizeT getScalarIntBitWidth(Type Ty);
71 71
72 // Check if a type is byte sized (slight optimization over typeWidthInBytes).
73 inline bool isByteSizedType(Type Ty) {
74 bool result = Ty == IceType_i8 || Ty == IceType_i1;
75 assert(result == (1 == typeWidthInBytes(Ty)));
76 return result;
77 }
78
79 // Check if Ty is byte sized and specifically i8. Assert that it's not
80 // byte sized due to being an i1.
81 inline bool isByteSizedArithType(Type Ty) {
82 assert(Ty != IceType_i1);
83 return Ty == IceType_i8;
84 }
85
86 // Return true if Ty is i32. This asserts that Ty is either i32 or i64.
87 inline bool isInt32Asserting32Or64(Type Ty) {
88 bool result = Ty == IceType_i32;
89 assert(result || Ty == IceType_i64);
90 return result;
91 }
92
93 // Return true if Ty is f32. This asserts that Ty is either f32 or f64.
94 inline bool isFloat32Asserting32Or64(Type Ty) {
95 bool result = Ty == IceType_f32;
96 assert(result || Ty == IceType_f64);
97 return result;
98 }
99
72 template <typename StreamType> 100 template <typename StreamType>
73 inline StreamType &operator<<(StreamType &Str, const Type &Ty) { 101 inline StreamType &operator<<(StreamType &Str, const Type &Ty) {
74 Str << typeString(Ty); 102 Str << typeString(Ty);
75 return Str; 103 return Str;
76 } 104 }
77 105
78 } // end of namespace Ice 106 } // end of namespace Ice
79 107
80 #endif // SUBZERO_SRC_ICETYPES_H 108 #endif // SUBZERO_SRC_ICETYPES_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698