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

Unified Diff: src/IceTypes.cpp

Issue 353553004: Add support for vector types and vector constants. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Print out types in error messages. Created 6 years, 5 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
Index: src/IceTypes.cpp
diff --git a/src/IceTypes.cpp b/src/IceTypes.cpp
index 84cf410fe8c6aaf182d5d282095a4b7229593c11..515be2d667aee80b3d70d6e295704958bec07961 100644
--- a/src/IceTypes.cpp
+++ b/src/IceTypes.cpp
@@ -21,10 +21,12 @@ namespace {
const struct {
size_t TypeWidthInBytes;
size_t TypeAlignInBytes;
+ size_t TypeNumElements;
+ Type TypeElementType;
const char *DisplayString;
} TypeAttributes[] = {
-#define X(tag, size, align, str) \
- { size, align, str } \
+#define X(tag, size, align, elts, elty, str) \
+ { size, align, elts, elty, str } \
,
ICETYPE_TABLE
#undef X
@@ -57,6 +59,28 @@ size_t typeAlignInBytes(Type Ty) {
return Align;
}
+size_t typeNumElements(Type Ty) {
+ size_t NumElements = 0;
+ size_t Index = static_cast<size_t>(Ty);
+ if (Index < TypeAttributesSize) {
+ NumElements = TypeAttributes[Index].TypeNumElements;
+ } else {
+ llvm_unreachable("Invalid type for typeNumElements()");
+ }
+ return NumElements;
+}
+
+Type typeElementType(Type Ty) {
+ Type ElementType = IceType_void;
+ size_t Index = static_cast<size_t>(Ty);
+ if (Index < TypeAttributesSize) {
+ ElementType = TypeAttributes[Index].TypeElementType;
+ } else {
+ llvm_unreachable("Invalid type for typeElementType()");
+ }
+ return ElementType;
+}
+
// ======================== Dump routines ======================== //
template <> Ostream &operator<<(Ostream &Str, const Type &Ty) {
« src/IceTargetLoweringX8632.cpp ('K') | « src/IceTypes.h ('k') | src/IceTypes.def » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698