/// getVectorType - Return the unique reference to a vector type of
/// the specified element type and size. VectorType must be a built-in type.
QualType getVectorType(QualType VectorType, unsigned NumElts,
- VectorType::AltiVecSpecific AltiVecSpec);
+ VectorType::VectorKind VecKind);
/// getExtVectorType - Return the unique reference to an extended vector type
/// of the specified element type and size. VectorType must be a built-in
unsigned : NumTypeBits;
- /// AltiVecSpec - AltiVec-specific vector information, used
- /// to differentiate things like 'pixel'.
- unsigned AltiVecSpec : 2;
+ /// VecKind - The kind of vector, either a generic vector type or some
+ /// target-specific vector type such as for AltiVec or Neon.
+ unsigned VecKind : 2;
/// NumElements - The number of elements in the vector.
unsigned NumElements : 30 - NumTypeBits;
/// client is responsible for converting the size into the number of elements.
class VectorType : public Type, public llvm::FoldingSetNode {
public:
- enum AltiVecSpecific {
- NotAltiVec, // is not AltiVec vector
- AltiVec, // is AltiVec vector
- Pixel, // is AltiVec 'vector Pixel'
- Bool // is AltiVec 'vector bool ...'
+ enum VectorKind {
+ GenericVector, // not a target-specific vector type
+ AltiVecVector, // is AltiVec vector
+ AltiVecPixel, // is AltiVec 'vector Pixel'
+ AltiVecBool, // is AltiVec 'vector bool ...'
+ NeonVector // is ARM Neon vector
};
protected:
/// ElementType - The element type of the vector.
QualType ElementType;
VectorType(QualType vecType, unsigned nElements, QualType canonType,
- AltiVecSpecific altiVecSpec) :
+ VectorKind vecKind) :
Type(Vector, canonType, vecType->isDependentType(),
vecType->isVariablyModifiedType()), ElementType(vecType) {
- VectorTypeBits.AltiVecSpec = altiVecSpec;
+ VectorTypeBits.VecKind = vecKind;
VectorTypeBits.NumElements = nElements;
}
VectorType(TypeClass tc, QualType vecType, unsigned nElements,
- QualType canonType, AltiVecSpecific altiVecSpec)
+ QualType canonType, VectorKind vecKind)
: Type(tc, canonType, vecType->isDependentType(),
vecType->isVariablyModifiedType()), ElementType(vecType) {
- VectorTypeBits.AltiVecSpec = altiVecSpec;
+ VectorTypeBits.VecKind = vecKind;
VectorTypeBits.NumElements = nElements;
}
friend class ASTContext; // ASTContext creates these.
bool isSugared() const { return false; }
QualType desugar() const { return QualType(this, 0); }
- AltiVecSpecific getAltiVecSpecific() const {
- return AltiVecSpecific(VectorTypeBits.AltiVecSpec);
+ VectorKind getVectorKind() const {
+ return VectorKind(VectorTypeBits.VecKind);
}
void Profile(llvm::FoldingSetNodeID &ID) {
Profile(ID, getElementType(), getNumElements(),
- getTypeClass(), getAltiVecSpecific());
+ getTypeClass(), getVectorKind());
}
static void Profile(llvm::FoldingSetNodeID &ID, QualType ElementType,
unsigned NumElements, TypeClass TypeClass,
- AltiVecSpecific AltiVecSpec) {
+ VectorKind VecKind) {
ID.AddPointer(ElementType.getAsOpaquePtr());
ID.AddInteger(NumElements);
ID.AddInteger(TypeClass);
- ID.AddInteger(AltiVecSpec);
+ ID.AddInteger(VecKind);
}
static bool classof(const Type *T) {
/// points, colors, and textures (modeled after OpenGL Shading Language).
class ExtVectorType : public VectorType {
ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) :
- VectorType(ExtVector, vecType, nElements, canonType, NotAltiVec) {}
+ VectorType(ExtVector, vecType, nElements, canonType, GenericVector) {}
friend class ASTContext; // ASTContext creates these.
public:
static int getPointAccessorIdx(char c) {
/// getVectorType - Return the unique reference to a vector type of
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
- VectorType::AltiVecSpecific AltiVecSpec) {
+ VectorType::VectorKind VecKind) {
BuiltinType *BaseType;
BaseType = dyn_cast<BuiltinType>(getCanonicalType(vecType).getTypePtr());
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
- VectorType::Profile(ID, vecType, NumElts, Type::Vector, AltiVecSpec);
+ VectorType::Profile(ID, vecType, NumElts, Type::Vector, VecKind);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
QualType Canonical;
if (!vecType.isCanonical()) {
Canonical = getVectorType(getCanonicalType(vecType), NumElts,
- VectorType::NotAltiVec);
+ VectorType::GenericVector);
// Get the new insert position for the node we care about.
VectorType *NewIP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos);
assert(NewIP == 0 && "Shouldn't be in the map!"); NewIP = NewIP;
}
VectorType *New = new (*this, TypeAlignment)
- VectorType(vecType, NumElts, Canonical, AltiVecSpec);
+ VectorType(vecType, NumElts, Canonical, VecKind);
VectorTypes.InsertNode(New, InsertPos);
Types.push_back(New);
return QualType(New, 0);
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
VectorType::Profile(ID, vecType, NumElts, Type::ExtVector,
- VectorType::NotAltiVec);
+ VectorType::GenericVector);
void *InsertPos = 0;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
// AltiVec vectors types are identical to equivalent GCC vector types
const VectorType *First = FirstVec->getAs<VectorType>();
const VectorType *Second = SecondVec->getAs<VectorType>();
- if ((((First->getAltiVecSpecific() == VectorType::AltiVec) &&
- (Second->getAltiVecSpecific() == VectorType::NotAltiVec)) ||
- ((First->getAltiVecSpecific() == VectorType::NotAltiVec) &&
- (Second->getAltiVecSpecific() == VectorType::AltiVec))) &&
+ if ((((First->getVectorKind() == VectorType::AltiVecVector) &&
+ (Second->getVectorKind() == VectorType::GenericVector)) ||
+ ((First->getVectorKind() == VectorType::GenericVector) &&
+ (Second->getVectorKind() == VectorType::AltiVecVector))) &&
hasSameType(First->getElementType(), Second->getElementType()) &&
(First->getNumElements() == Second->getNumElements()))
return true;
// Turn <4 x signed int> -> <4 x unsigned int>
if (const VectorType *VTy = T->getAs<VectorType>())
return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
- VTy->getNumElements(), VTy->getAltiVecSpecific());
+ VTy->getNumElements(), VTy->getVectorKind());
// For enums, we return the unsigned version of the base type.
if (const EnumType *ETy = T->getAs<EnumType>())
// TODO: No way to make AltiVec vectors in builtins yet.
Type = Context.getVectorType(ElementType, NumElements,
- VectorType::NotAltiVec);
+ VectorType::GenericVector);
break;
}
case 'X': {
return false;
if (Vec1->getNumElements() != Vec2->getNumElements())
return false;
- if (Vec1->getAltiVecSpecific() != Vec2->getAltiVecSpecific())
+ if (Vec1->getVectorKind() != Vec2->getVectorKind())
return false;
break;
}
return Importer.getToContext().getVectorType(ToElementType,
T->getNumElements(),
- T->getAltiVecSpecific());
+ T->getVectorKind());
}
QualType ASTNodeImporter::VisitExtVectorType(ExtVectorType *T) {
}
void TypePrinter::PrintVector(const VectorType *T, std::string &S) {
- if (T->getAltiVecSpecific() != VectorType::NotAltiVec) {
- if (T->getAltiVecSpecific() == VectorType::Pixel)
+ if (T->getVectorKind() != VectorType::GenericVector) {
+ if (T->getVectorKind() == VectorType::AltiVecPixel)
S = "__vector __pixel " + S;
else {
Print(T->getElementType(), S);
- S = ((T->getAltiVecSpecific() == VectorType::Bool)
+ S = ((T->getVectorKind() == VectorType::AltiVecBool)
? "__vector __bool " : "__vector ") + S;
}
} else {
// ::= p # AltiVec vector pixel
void CXXNameMangler::mangleType(const VectorType *T) {
Out << "Dv" << T->getNumElements() << '_';
- if (T->getAltiVecSpecific() == VectorType::Pixel)
+ if (T->getVectorKind() == VectorType::AltiVecPixel)
Out << 'p';
- else if (T->getAltiVecSpecific() == VectorType::Bool)
+ else if (T->getVectorKind() == VectorType::AltiVecBool)
Out << 'b';
else
mangleType(T->getElementType());
} else if (numElements != numResElements) {
QualType eltType = LHSType->getAs<VectorType>()->getElementType();
resType = Context.getVectorType(eltType, numResElements,
- VectorType::NotAltiVec);
+ VectorType::GenericVector);
}
}
VecType = SemaRef.Context.getExtVectorType(elementType, numIElts);
else
VecType = SemaRef.Context.getVectorType(elementType, numIElts,
- IVT->getAltiVecSpecific());
+ IVT->getVectorKind());
CheckSubElementType(ElementEntity, IList, VecType, Index,
StructuredList, StructuredIndex);
numEltsInit += numIElts;
} else if (DS.isTypeAltiVecVector()) {
unsigned typeSize = static_cast<unsigned>(Context.getTypeSize(Result));
assert(typeSize > 0 && "type size for vector must be greater than 0 bits");
- VectorType::AltiVecSpecific AltiVecSpec = VectorType::AltiVec;
+ VectorType::VectorKind VecKind = VectorType::AltiVecVector;
if (DS.isTypeAltiVecPixel())
- AltiVecSpec = VectorType::Pixel;
+ VecKind = VectorType::AltiVecPixel;
else if (DS.isTypeAltiVecBool())
- AltiVecSpec = VectorType::Bool;
- Result = Context.getVectorType(Result, 128/typeSize, AltiVecSpec);
+ VecKind = VectorType::AltiVecBool;
+ Result = Context.getVectorType(Result, 128/typeSize, VecKind);
}
// FIXME: Imaginary.
// Success! Instantiate the vector type, the number of elements is > 0, and
// not required to be a power of 2, unlike GCC.
CurType = S.Context.getVectorType(CurType, vectorSize/typeSize,
- VectorType::NotAltiVec);
+ VectorType::GenericVector);
}
void ProcessTypeAttributeList(Sema &S, QualType &Result,
/// By default, performs semantic analysis when building the vector type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
- VectorType::AltiVecSpecific AltiVecSpec);
+ VectorType::VectorKind VecKind);
/// \brief Build a new extended vector type given the element type and
/// number of elements.
if (getDerived().AlwaysRebuild() ||
ElementType != T->getElementType()) {
Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
- T->getAltiVecSpecific());
+ T->getVectorKind());
if (Result.isNull())
return QualType();
}
template<typename Derived>
QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
- unsigned NumElements,
- VectorType::AltiVecSpecific AltiVecSpec) {
+ unsigned NumElements,
+ VectorType::VectorKind VecKind) {
// FIXME: semantic checking!
- return SemaRef.Context.getVectorType(ElementType, NumElements, AltiVecSpec);
+ return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
}
template<typename Derived>
QualType ElementType = GetType(Record[0]);
unsigned NumElements = Record[1];
- unsigned AltiVecSpec = Record[2];
+ unsigned VecKind = Record[2];
return Context->getVectorType(ElementType, NumElements,
- (VectorType::AltiVecSpecific)AltiVecSpec);
+ (VectorType::VectorKind)VecKind);
}
case TYPE_EXT_VECTOR: {
void ASTTypeWriter::VisitVectorType(const VectorType *T) {
Writer.AddTypeRef(T->getElementType(), Record);
Record.push_back(T->getNumElements());
- Record.push_back(T->getAltiVecSpecific());
+ Record.push_back(T->getVectorKind());
Code = TYPE_VECTOR;
}