Example #1
0
const Type *
DeclSpecs::GetBaseType(SourcePos pos) const {
    const Type *retType = baseType;

    if (retType == NULL) {
        Warning(pos, "No type specified in declaration.  Assuming int32.");
        retType = AtomicType::UniformInt32->GetAsUnboundVariabilityType();
    }

    if (vectorSize > 0) {
        const AtomicType *atomicType = CastType<AtomicType>(retType);
        if (atomicType == NULL) {
            Error(pos, "Only atomic types (int, float, ...) are legal for vector "
                  "types.");
            return NULL;
        }
        retType = new VectorType(atomicType, vectorSize);
    }

    retType = lApplyTypeQualifiers(typeQualifiers, retType, pos);
    
    if (soaWidth > 0) {
        const StructType *st = CastType<StructType>(retType);

        if (st == NULL) {
            Error(pos, "Illegal to provide soa<%d> qualifier with non-struct "
                  "type \"%s\".", soaWidth, retType->GetString().c_str());
            return NULL;
        }
        else if (soaWidth <= 0 || (soaWidth & (soaWidth - 1)) != 0) {
            Error(pos, "soa<%d> width illegal.  Value must be positive power "
                  "of two.", soaWidth);
            return NULL;
        }

        if (st->IsUniformType()) {
            Error(pos, "\"uniform\" qualifier and \"soa<%d>\" qualifier can't "
                  "both be used in a type declaration.", soaWidth);
            return NULL;
        }
        else if (st->IsVaryingType()) {
            Error(pos, "\"varying\" qualifier and \"soa<%d>\" qualifier can't "
                  "both be used in a type declaration.", soaWidth);
            return NULL;
        }
        else
            retType = st->GetAsSOAType(soaWidth);

        if (soaWidth < g->target.vectorWidth)
            PerformanceWarning(pos, "soa<%d> width smaller than gang size %d "
                               "currently leads to inefficient code to access "
                               "soa types.", soaWidth, g->target.vectorWidth);
    }
    
    return retType;
}
Example #2
0
const Type *
DeclSpecs::GetBaseType(SourcePos pos) const {
    const Type *bt = baseType;
    if (vectorSize > 0) {
        const AtomicType *atomicType = dynamic_cast<const AtomicType *>(bt);
        if (atomicType == NULL) {
            Error(pos, "Only atomic types (int, float, ...) are legal for vector "
                  "types.");
            return NULL;
        }
        bt = new VectorType(atomicType, vectorSize);
    }

    return lApplyTypeQualifiers(typeQualifiers, bt, pos);
}
Example #3
0
File: decl.cpp Project: mwiebe/ispc
const Type *
DeclSpecs::GetBaseType(SourcePos pos) const {
    const Type *bt = baseType;

    if (bt == NULL) {
        Warning(pos, "No type specified in declaration.  Assuming int32.");
        bt = AtomicType::UnboundInt32;
    }

    if (vectorSize > 0) {
        const AtomicType *atomicType = dynamic_cast<const AtomicType *>(bt);
        if (atomicType == NULL) {
            Error(pos, "Only atomic types (int, float, ...) are legal for vector "
                  "types.");
            return NULL;
        }
        bt = new VectorType(atomicType, vectorSize);
    }

    return lApplyTypeQualifiers(typeQualifiers, bt, pos);
}