Iain Buclaw avatar Iain Buclaw committed 565248b

Merge more vector support

Comments (0)

Files changed (4)

     {
         case POINTER_TYPE:
         {
+            // Check for char* first. Needs to be done for chars/string.
+            if (TYPE_MAIN_VARIANT(TREE_TYPE(t)) == char_type_node)
+                return Type::tchar->pointerTo();
+
             d = gcc_type_to_d_type(TREE_TYPE(t));
             if (d)
             {
             unsigned sz = tree_low_cst(TYPE_SIZE_UNIT(t), 1);
             bool unsgn = TYPE_UNSIGNED(t);
 
-            // Check for char first. Needs to be done for chars/string.
-            if (TYPE_MAIN_VARIANT(t) == char_type_node)
-                return Type::tchar;
-
             // This search assumes that integer types come before char and bit...
             for (size_t i = 0; i < TMAX; i++)
             {
             }
             break;
         }
+#if V2
         case VECTOR_TYPE:
         {
             d = gcc_type_to_d_type(TREE_TYPE(t));
             }
             break;
         }
+#endif
         case RECORD_TYPE:
         {
             for (size_t i = 0; i < builtin_converted_types.dim; i += 2)
     if (! ctype)
     {
         int nunits = ((TypeSArray *) basetype)->dim->toUInteger();
-        tree inner = TREE_TYPE(basetype->toCtype());
+        tree inner = elementType()->toCtype();
 
         ctype = build_vector_type (inner, nunits);
         layout_type(ctype);
 #define TFLAGSreal      8
 #define TFLAGSimaginary 0x10
 #define TFLAGScomplex   0x20
+#define TFLAGSvector    0x40    // valid for a SIMD vector type
 
     flags = 0;
     switch (ty)
                         break;
 
         case Tint8:     d = Token::toChars(TOKint8);
-                        flags |= TFLAGSintegral;
+                        flags |= TFLAGSintegral | TFLAGSvector;
                         break;
 
         case Tuns8:     d = Token::toChars(TOKuns8);
-                        flags |= TFLAGSintegral | TFLAGSunsigned;
+                        flags |= TFLAGSintegral | TFLAGSunsigned | TFLAGSvector;
                         break;
 
         case Tint16:    d = Token::toChars(TOKint16);
-                        flags |= TFLAGSintegral;
+                        flags |= TFLAGSintegral | TFLAGSvector;
                         break;
 
         case Tuns16:    d = Token::toChars(TOKuns16);
-                        flags |= TFLAGSintegral | TFLAGSunsigned;
+                        flags |= TFLAGSintegral | TFLAGSunsigned | TFLAGSvector;
                         break;
 
         case Tint32:    d = Token::toChars(TOKint32);
-                        flags |= TFLAGSintegral;
+                        flags |= TFLAGSintegral | TFLAGSvector;
                         break;
 
         case Tuns32:    d = Token::toChars(TOKuns32);
-                        flags |= TFLAGSintegral | TFLAGSunsigned;
+                        flags |= TFLAGSintegral | TFLAGSunsigned | TFLAGSvector;
                         break;
 
         case Tfloat32:  d = Token::toChars(TOKfloat32);
-                        flags |= TFLAGSfloating | TFLAGSreal;
+                        flags |= TFLAGSfloating | TFLAGSreal | TFLAGSvector;
                         break;
 
         case Tint64:    d = Token::toChars(TOKint64);
-                        flags |= TFLAGSintegral;
+                        flags |= TFLAGSintegral | TFLAGSvector;
                         break;
 
         case Tuns64:    d = Token::toChars(TOKuns64);
-                        flags |= TFLAGSintegral | TFLAGSunsigned;
+                        flags |= TFLAGSintegral | TFLAGSunsigned | TFLAGSvector;
                         break;
 
         case Tfloat64:  d = Token::toChars(TOKfloat64);
-                        flags |= TFLAGSfloating | TFLAGSreal;
+                        flags |= TFLAGSfloating | TFLAGSreal | TFLAGSvector;
                         break;
 
         case Tfloat80:  d = Token::toChars(TOKfloat80);
     }
     TypeSArray *t = (TypeSArray *)basetype;
     TypeBasic *tb = t->nextOf()->isTypeBasic();
-    if (!tb)
+    if (!tb || !(tb->flags & TFLAGSvector))
     {   error(loc, "base type of __vector must be a static array of an arithmetic type, not %s", t->toChars());
         return terror;
     }
     return merge();
 }
 
+TypeBasic *TypeVector::elementType()
+{
+    assert(basetype->ty == Tsarray);
+    TypeSArray *t = (TypeSArray *)basetype;
+    TypeBasic *tb = t->nextOf()->isTypeBasic();
+    assert(tb);
+    return tb;
+}
+
+
+
 char *TypeVector::toChars()
 {
     return Type::toChars();
     int isunsigned();
     MATCH implicitConvTo(Type *to);
     Expression *defaultInit(Loc loc);
+    TypeBasic *elementType();
     int isZeroInit(Loc loc);
     TypeInfoDeclaration *getTypeInfoDeclaration();
     TypeTuple *toArgTypes();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.