Add support for vector types.

- Add vector types to the type table.

- Add support for parsing vector types in llvm2ice.

- Legalize undef vector values to zero. Test that undef vector values are lowered correctly.

BUG=none
R=jvoung@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/353553004
diff --git a/src/IceTypes.cpp b/src/IceTypes.cpp
index 84cf410..515be2d 100644
--- a/src/IceTypes.cpp
+++ b/src/IceTypes.cpp
@@ -21,10 +21,12 @@
 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 @@
   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) {