Index: src/IceTypes.cpp |
diff --git a/src/IceTypes.cpp b/src/IceTypes.cpp |
index 515be2d667aee80b3d70d6e295704958bec07961..e61131af88678284f638441acd041eaa4a782f1f 100644 |
--- a/src/IceTypes.cpp |
+++ b/src/IceTypes.cpp |
@@ -24,9 +24,10 @@ const struct { |
size_t TypeNumElements; |
Type TypeElementType; |
const char *DisplayString; |
+ uint32_t TypeFlags; |
} TypeAttributes[] = { |
-#define X(tag, size, align, elts, elty, str) \ |
- { size, align, elts, elty, str } \ |
+#define X(tag, size, align, elts, elty, str, flags) \ |
+ { size, align, elts, elty, str, flags } \ |
, |
ICETYPE_TABLE |
#undef X |
@@ -81,6 +82,30 @@ Type typeElementType(Type Ty) { |
return ElementType; |
} |
+bool isIntegerType(Type Ty) { |
+ bool IsInteger = false; |
+ size_t Index = static_cast<size_t>(Ty); |
+ if (Index < TypeAttributesSize) { |
+ IsInteger = |
+ static_cast<bool>(TypeAttributes[Index].TypeFlags & TypeFlagIsInteger); |
jvoung (off chromium)
2014/07/23 16:10:17
Does this need to be a bitset (w/ Flag & Bit), or
Karl
2014/07/23 20:22:20
I would actually like to convert checks like "isVa
|
+ } else { |
+ llvm_unreachable("Invalid type for typeIsInteger()"); |
+ } |
+ return IsInteger; |
+} |
+ |
+bool isFloatingType(Type Ty) { |
+ bool IsFloating = false; |
+ size_t Index = static_cast<size_t>(Ty); |
+ if (Index < TypeAttributesSize) { |
+ IsFloating = |
+ static_cast<bool>(TypeAttributes[Index].TypeFlags & TypeFlagIsFloating); |
+ } else { |
+ llvm_unreachable("Invalid type for typeIsFloating()"); |
+ } |
+ return IsFloating; |
+} |
+ |
// ======================== Dump routines ======================== // |
template <> Ostream &operator<<(Ostream &Str, const Type &Ty) { |