From: Nate Begeman Date: Fri, 18 Apr 2008 23:10:10 +0000 (+0000) Subject: OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=213541a68a3e137d11d2cefb612c6cdb410d7e8e;p=clang OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49942 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 1d9e0af730..dfe117053c 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -169,9 +169,10 @@ public: /// the specified element type and size. VectorType must be a built-in type. QualType getVectorType(QualType VectorType, unsigned NumElts); - /// getOCUVectorType - Return the unique reference to an OCU vector type of - /// the specified element type and size. VectorType must be a built-in type. - QualType getOCUVectorType(QualType VectorType, unsigned NumElts); + /// getExtVectorType - Return the unique reference to an extended vector type + /// of the specified element type and size. VectorType must be a built-in + /// type. + QualType getExtVectorType(QualType VectorType, unsigned NumElts); /// getFunctionTypeNoProto - Return a K&R style C function type like 'int()'. /// diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 4819e218e7..6bd5bbcbd5 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -691,11 +691,11 @@ public: static MemberExpr* CreateImpl(llvm::Deserializer& D, ASTContext& C); }; -/// OCUVectorElementExpr - This represents access to specific elements of a +/// ExtVectorElementExpr - This represents access to specific elements of a /// vector, and may occur on the left hand side or right hand side. For example -/// the following is legal: "V.xy = V.zw" if V is a 4 element ocu vector. +/// the following is legal: "V.xy = V.zw" if V is a 4 element extended vector. /// -class OCUVectorElementExpr : public Expr { +class ExtVectorElementExpr : public Expr { Expr *Base; IdentifierInfo &Accessor; SourceLocation AccessorLoc; @@ -705,9 +705,9 @@ public: Color, // rgba Texture // stpq }; - OCUVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor, + ExtVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor, SourceLocation loc) - : Expr(OCUVectorElementExprClass, ty), + : Expr(ExtVectorElementExprClass, ty), Base(base), Accessor(accessor), AccessorLoc(loc) {} const Expr *getBase() const { return Base; } @@ -743,9 +743,9 @@ public: } static bool classof(const Stmt *T) { - return T->getStmtClass() == OCUVectorElementExprClass; + return T->getStmtClass() == ExtVectorElementExprClass; } - static bool classof(const OCUVectorElementExpr *) { return true; } + static bool classof(const ExtVectorElementExpr *) { return true; } // Iterators virtual child_iterator child_begin(); diff --git a/include/clang/AST/StmtNodes.def b/include/clang/AST/StmtNodes.def index e3f0273308..0df573b57b 100644 --- a/include/clang/AST/StmtNodes.def +++ b/include/clang/AST/StmtNodes.def @@ -77,7 +77,7 @@ STMT(47, CompoundAssignOperator, BinaryOperator) STMT(48, ConditionalOperator , Expr) STMT(49, ImplicitCastExpr , Expr) STMT(50, CompoundLiteralExpr , Expr) -STMT(51, OCUVectorElementExpr , Expr) +STMT(51, ExtVectorElementExpr , Expr) STMT(52, InitListExpr , Expr) STMT(53, VAArgExpr , Expr) diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index 8b5ed4ce63..313c243c4f 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -50,7 +50,7 @@ namespace clang { class ComplexType; class TagType; class FunctionType; - class OCUVectorType; + class ExtVectorType; class BuiltinType; class ObjCInterfaceType; class ObjCQualifiedIdType; @@ -223,7 +223,7 @@ public: enum TypeClass { Builtin, Complex, Pointer, Reference, ConstantArray, VariableArray, IncompleteArray, - Vector, OCUVector, + Vector, ExtVector, FunctionNoProto, FunctionProto, TypeName, Tagged, ASQual, ObjCInterface, ObjCQualifiedInterface, @@ -320,7 +320,7 @@ public: bool isUnionType() const; bool isComplexIntegerType() const; // GCC _Complex integer type. bool isVectorType() const; // GCC vector type. - bool isOCUVectorType() const; // OCU vector type. + bool isExtVectorType() const; // Extended vector type. bool isObjCInterfaceType() const; // NSString or NSString bool isObjCQualifiedInterfaceType() const; // NSString bool isObjCQualifiedIdType() const; // id @@ -343,7 +343,7 @@ public: const VectorType *getAsVectorType() const; // GCC vector type. const ComplexType *getAsComplexType() const; const ComplexType *getAsComplexIntegerType() const; // GCC complex int type. - const OCUVectorType *getAsOCUVectorType() const; // OCU vector type. + const ExtVectorType *getAsExtVectorType() const; // Extended vector type. const ObjCInterfaceType *getAsObjCInterfaceType() const; const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const; const ObjCQualifiedIdType *getAsObjCQualifiedIdType() const; @@ -758,19 +758,19 @@ public: ID.AddInteger(TypeClass); } static bool classof(const Type *T) { - return T->getTypeClass() == Vector || T->getTypeClass() == OCUVector; + return T->getTypeClass() == Vector || T->getTypeClass() == ExtVector; } static bool classof(const VectorType *) { return true; } }; -/// OCUVectorType - Extended vector type. This type is created using -/// __attribute__((ocu_vector_type(n)), where "n" is the number of elements. -/// Unlike vector_size, ocu_vector_type is only allowed on typedef's. This +/// ExtVectorType - Extended vector type. This type is created using +/// __attribute__((ext_vector_type(n)), where "n" is the number of elements. +/// Unlike vector_size, ext_vector_type is only allowed on typedef's. This /// class enables syntactic extensions, like Vector Components for accessing /// points, colors, and textures (modeled after OpenGL Shading Language). -class OCUVectorType : public VectorType { - OCUVectorType(QualType vecType, unsigned nElements, QualType canonType) : - VectorType(OCUVector, vecType, nElements, canonType) {} +class ExtVectorType : public VectorType { + ExtVectorType(QualType vecType, unsigned nElements, QualType canonType) : + VectorType(ExtVector, vecType, nElements, canonType) {} friend class ASTContext; // ASTContext creates these. public: static int getPointAccessorIdx(char c) { @@ -815,9 +815,9 @@ public: virtual void getAsStringInternal(std::string &InnerString) const; static bool classof(const Type *T) { - return T->getTypeClass() == OCUVector; + return T->getTypeClass() == ExtVector; } - static bool classof(const OCUVectorType *) { return true; } + static bool classof(const ExtVectorType *) { return true; } }; /// FunctionType - C99 6.7.5.3 - Function Declarators. This is the common base @@ -1225,8 +1225,8 @@ inline bool Type::isAnyComplexType() const { inline bool Type::isVectorType() const { return isa(CanonicalType.getUnqualifiedType()); } -inline bool Type::isOCUVectorType() const { - return isa(CanonicalType.getUnqualifiedType()); +inline bool Type::isExtVectorType() const { + return isa(CanonicalType.getUnqualifiedType()); } inline bool Type::isObjCInterfaceType() const { return isa(CanonicalType); diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index f8dc4d1629..8fdf716aea 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -594,13 +594,13 @@ DIAG(err_attribute_zero_size, ERROR, "zero vector size") DIAG(err_typecheck_vector_not_convertable, ERROR, "can't convert between vector values of different size ('%0' and '%1')") -DIAG(err_typecheck_ocu_vector_not_typedef, ERROR, - "ocu_vector_type only applies to types, not variables") -DIAG(err_ocuvector_component_exceeds_length, ERROR, +DIAG(err_typecheck_ext_vector_not_typedef, ERROR, + "ext_vector_type only applies to types, not variables") +DIAG(err_ext_vector_component_exceeds_length, ERROR, "vector component access exceeds type '%0'") -DIAG(err_ocuvector_component_name_illegal, ERROR, +DIAG(err_ext_vector_component_name_illegal, ERROR, "illegal vector component name '%0'") -DIAG(err_ocuvector_component_access, ERROR, +DIAG(err_ext_vector_component_access, ERROR, "vector component access limited to variables") DIAG(err_attribute_address_space_not_int, ERROR, "address space attribute requires an integer constant") diff --git a/include/clang/Parse/AttributeList.h b/include/clang/Parse/AttributeList.h index a8057d96d8..c71f8ff1f8 100644 --- a/include/clang/Parse/AttributeList.h +++ b/include/clang/Parse/AttributeList.h @@ -44,7 +44,7 @@ public: enum Kind { UnknownAttribute, AT_vector_size, - AT_ocu_vector_type, + AT_ext_vector_type, AT_address_space, AT_aligned, AT_packed, diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 7220ce4f9f..8fd088a305 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -200,7 +200,7 @@ ASTContext::getTypeInfo(QualType T) { Align = EltInfo.second; break; } - case Type::OCUVector: + case Type::ExtVector: case Type::Vector: { std::pair EltInfo = getTypeInfo(cast(T)->getElementType()); @@ -678,17 +678,17 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts) { return QualType(New, 0); } -/// getOCUVectorType - Return the unique reference to an OCU vector type of +/// getExtVectorType - Return the unique reference to an extended vector type of /// the specified element type and size. VectorType must be a built-in type. -QualType ASTContext::getOCUVectorType(QualType vecType, unsigned NumElts) { +QualType ASTContext::getExtVectorType(QualType vecType, unsigned NumElts) { BuiltinType *baseType; baseType = dyn_cast(getCanonicalType(vecType).getTypePtr()); - assert(baseType != 0 && "getOCUVectorType(): Expecting a built-in type"); + assert(baseType != 0 && "getExtVectorType(): Expecting a built-in type"); // Check if we've already instantiated a vector of this type. llvm::FoldingSetNodeID ID; - VectorType::Profile(ID, vecType, NumElts, Type::OCUVector); + VectorType::Profile(ID, vecType, NumElts, Type::ExtVector); void *InsertPos = 0; if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(VTP, 0); @@ -697,13 +697,13 @@ QualType ASTContext::getOCUVectorType(QualType vecType, unsigned NumElts) { // so fill in the canonical type field. QualType Canonical; if (!vecType->isCanonical()) { - Canonical = getOCUVectorType(getCanonicalType(vecType), NumElts); + Canonical = getExtVectorType(getCanonicalType(vecType), NumElts); // 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!"); } - OCUVectorType *New = new OCUVectorType(vecType, NumElts, Canonical); + ExtVectorType *New = new ExtVectorType(vecType, NumElts, Canonical); VectorTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, 0); @@ -1646,9 +1646,9 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) { if (RHSClass == Type::VariableArray || RHSClass == Type::IncompleteArray) RHSClass = Type::ConstantArray; - // Canonicalize OCUVector -> Vector. - if (LHSClass == Type::OCUVector) LHSClass = Type::Vector; - if (RHSClass == Type::OCUVector) RHSClass = Type::Vector; + // Canonicalize ExtVector -> Vector. + if (LHSClass == Type::ExtVector) LHSClass = Type::Vector; + if (RHSClass == Type::ExtVector) RHSClass = Type::Vector; // Consider qualified interfaces and interfaces the same. if (LHSClass == Type::ObjCQualifiedInterface) LHSClass = Type::ObjCInterface; diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 35bea75045..264ef7b0e8 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -396,8 +396,8 @@ Expr::isLvalueResult Expr::isLvalue() const { return cast(this)->getSubExpr()->isLvalue(); case CompoundLiteralExprClass: // C99 6.5.2.5p5 return LV_Valid; - case OCUVectorElementExprClass: - if (cast(this)->containsDuplicateElements()) + case ExtVectorElementExprClass: + if (cast(this)->containsDuplicateElements()) return LV_DuplicateVectorComponents; return LV_Valid; case ObjCIvarRefExprClass: // ObjC instance variables are lvalues. @@ -1037,29 +1037,29 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const { return isIntegerConstantExpr(Val, Ctx, 0, true) && Val == 0; } -unsigned OCUVectorElementExpr::getNumElements() const { +unsigned ExtVectorElementExpr::getNumElements() const { return strlen(Accessor.getName()); } /// getComponentType - Determine whether the components of this access are /// "point" "color" or "texture" elements. -OCUVectorElementExpr::ElementType -OCUVectorElementExpr::getElementType() const { +ExtVectorElementExpr::ElementType +ExtVectorElementExpr::getElementType() const { // derive the component type, no need to waste space. const char *compStr = Accessor.getName(); - if (OCUVectorType::getPointAccessorIdx(*compStr) != -1) return Point; - if (OCUVectorType::getColorAccessorIdx(*compStr) != -1) return Color; + if (ExtVectorType::getPointAccessorIdx(*compStr) != -1) return Point; + if (ExtVectorType::getColorAccessorIdx(*compStr) != -1) return Color; - assert(OCUVectorType::getTextureAccessorIdx(*compStr) != -1 && + assert(ExtVectorType::getTextureAccessorIdx(*compStr) != -1 && "getComponentType(): Illegal accessor"); return Texture; } /// containsDuplicateElements - Return true if any element access is /// repeated. -bool OCUVectorElementExpr::containsDuplicateElements() const { +bool ExtVectorElementExpr::containsDuplicateElements() const { const char *compStr = Accessor.getName(); unsigned length = strlen(compStr); @@ -1073,7 +1073,7 @@ bool OCUVectorElementExpr::containsDuplicateElements() const { } /// getEncodedElementAccess - We encode fields with two bits per component. -unsigned OCUVectorElementExpr::getEncodedElementAccess() const { +unsigned ExtVectorElementExpr::getEncodedElementAccess() const { const char *compStr = Accessor.getName(); unsigned length = getNumElements(); @@ -1081,7 +1081,7 @@ unsigned OCUVectorElementExpr::getEncodedElementAccess() const { while (length--) { Result <<= 2; - int Idx = OCUVectorType::getAccessorIdx(compStr[length]); + int Idx = ExtVectorType::getAccessorIdx(compStr[length]); assert(Idx != -1 && "Invalid accessor letter"); Result |= Idx; } @@ -1268,11 +1268,11 @@ Stmt::child_iterator MemberExpr::child_end() { return reinterpret_cast(&Base)+1; } -// OCUVectorElementExpr -Stmt::child_iterator OCUVectorElementExpr::child_begin() { +// ExtVectorElementExpr +Stmt::child_iterator ExtVectorElementExpr::child_begin() { return reinterpret_cast(&Base); } -Stmt::child_iterator OCUVectorElementExpr::child_end() { +Stmt::child_iterator ExtVectorElementExpr::child_end() { return reinterpret_cast(&Base)+1; } diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp index 52eb91e4bf..798ea84677 100644 --- a/lib/AST/StmtDumper.cpp +++ b/lib/AST/StmtDumper.cpp @@ -124,7 +124,7 @@ namespace { void VisitUnaryOperator(UnaryOperator *Node); void VisitSizeOfAlignOfTypeExpr(SizeOfAlignOfTypeExpr *Node); void VisitMemberExpr(MemberExpr *Node); - void VisitOCUVectorElementExpr(OCUVectorElementExpr *Node); + void VisitExtVectorElementExpr(ExtVectorElementExpr *Node); void VisitBinaryOperator(BinaryOperator *Node); void VisitCompoundAssignOperator(CompoundAssignOperator *Node); void VisitAddrLabelExpr(AddrLabelExpr *Node); @@ -377,7 +377,7 @@ void StmtDumper::VisitMemberExpr(MemberExpr *Node) { fprintf(F, " %s%s %p", Node->isArrow() ? "->" : ".", Node->getMemberDecl()->getName(), (void*)Node->getMemberDecl()); } -void StmtDumper::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) { +void StmtDumper::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) { DumpExpr(Node); fprintf(F, " %s", Node->getAccessor().getName()); } diff --git a/lib/AST/StmtPrinter.cpp b/lib/AST/StmtPrinter.cpp index 2ff7f79c2d..f838633171 100644 --- a/lib/AST/StmtPrinter.cpp +++ b/lib/AST/StmtPrinter.cpp @@ -676,7 +676,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) { assert(Field && "MemberExpr should alway reference a field!"); OS << Field->getName(); } -void StmtPrinter::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) { +void StmtPrinter::VisitExtVectorElementExpr(ExtVectorElementExpr *Node) { PrintExpr(Node->getBase()); OS << "."; OS << Node->getAccessor().getName(); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 5040b95e09..741d59bc76 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -416,22 +416,22 @@ const VectorType *Type::getAsVectorType() const { return getDesugaredType()->getAsVectorType(); } -const OCUVectorType *Type::getAsOCUVectorType() const { +const ExtVectorType *Type::getAsExtVectorType() const { // Are we directly an OpenCU vector type? - if (const OCUVectorType *VTy = dyn_cast(this)) + if (const ExtVectorType *VTy = dyn_cast(this)) return VTy; // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { + if (!isa(CanonicalType)) { // Look through type qualifiers - if (isa(CanonicalType.getUnqualifiedType())) - return CanonicalType.getUnqualifiedType()->getAsOCUVectorType(); + if (isa(CanonicalType.getUnqualifiedType())) + return CanonicalType.getUnqualifiedType()->getAsExtVectorType(); return 0; } - // If this is a typedef for an ocuvector type, strip the typedef off without - // losing all typedef information. - return getDesugaredType()->getAsOCUVectorType(); + // If this is a typedef for an extended vector type, strip the typedef off + // without losing all typedef information. + return getDesugaredType()->getAsExtVectorType(); } const ObjCInterfaceType *Type::getAsObjCInterfaceType() const { @@ -903,8 +903,8 @@ void VectorType::getAsStringInternal(std::string &S) const { ElementType.getAsStringInternal(S); } -void OCUVectorType::getAsStringInternal(std::string &S) const { - S += " __attribute__((ocu_vector_type("; +void ExtVectorType::getAsStringInternal(std::string &S) const { + S += " __attribute__((ext_vector_type("; S += llvm::utostr_32(NumElements); S += ")))"; ElementType.getAsStringInternal(S); diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 5714f3cde9..3c1ab740b2 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -103,8 +103,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { return EmitUnaryOpLValue(cast(E)); case Expr::ArraySubscriptExprClass: return EmitArraySubscriptExpr(cast(E)); - case Expr::OCUVectorElementExprClass: - return EmitOCUVectorElementExpr(cast(E)); + case Expr::ExtVectorElementExprClass: + return EmitExtVectorElementExpr(cast(E)); case Expr::MemberExprClass: return EmitMemberExpr(cast(E)); } } @@ -143,8 +143,8 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) { // If this is a reference to a subset of the elements of a vector, either // shuffle the input or extract/insert them as appropriate. - if (LV.isOCUVectorElt()) - return EmitLoadOfOCUElementLValue(LV, ExprType); + if (LV.isExtVectorElt()) + return EmitLoadOfExtVectorElementLValue(LV, ExprType); if (LV.isBitfield()) return EmitLoadOfBitfieldLValue(LV, ExprType); @@ -178,17 +178,17 @@ RValue CodeGenFunction::EmitLoadOfBitfieldLValue(LValue LV, // If this is a reference to a subset of the elements of a vector, either // shuffle the input or extract/insert them as appropriate. -RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV, - QualType ExprType) { - llvm::Value *Vec = Builder.CreateLoad(LV.getOCUVectorAddr(), "tmp"); +RValue CodeGenFunction::EmitLoadOfExtVectorElementLValue(LValue LV, + QualType ExprType) { + llvm::Value *Vec = Builder.CreateLoad(LV.getExtVectorAddr(), "tmp"); - unsigned EncFields = LV.getOCUVectorElts(); + unsigned EncFields = LV.getExtVectorElts(); // If the result of the expression is a non-vector type, we must be // extracting a single element. Just codegen as an extractelement. const VectorType *ExprVT = ExprType->getAsVectorType(); if (!ExprVT) { - unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields); + unsigned InIdx = ExtVectorElementExpr::getAccessedFieldNo(0, EncFields); llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx); return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp")); } @@ -202,7 +202,7 @@ RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV, if (NumResultElts == NumSourceElts) { llvm::SmallVector Mask; for (unsigned i = 0; i != NumResultElts; ++i) { - unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields); + unsigned InIdx = ExtVectorElementExpr::getAccessedFieldNo(i, EncFields); Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx)); } @@ -218,7 +218,7 @@ RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV, // Extract/Insert each element of the result. for (unsigned i = 0; i != NumResultElts; ++i) { - unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields); + unsigned InIdx = ExtVectorElementExpr::getAccessedFieldNo(i, EncFields); llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx); Elt = Builder.CreateExtractElement(Vec, Elt, "tmp"); @@ -247,9 +247,10 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst, return; } - // If this is an update of elements of a vector, insert them as appropriate. - if (Dst.isOCUVectorElt()) - return EmitStoreThroughOCUComponentLValue(Src, Dst, Ty); + // If this is an update of extended vector elements, insert them as + // appropriate. + if (Dst.isExtVectorElt()) + return EmitStoreThroughExtVectorComponentLValue(Src, Dst, Ty); if (Dst.isBitfield()) return EmitStoreThroughBitfieldLValue(Src, Dst, Ty); @@ -304,13 +305,14 @@ void CodeGenFunction::EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, Builder.CreateStore(NewVal, Ptr); } -void CodeGenFunction::EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, - QualType Ty) { +void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src, + LValue Dst, + QualType Ty) { // This access turns into a read/modify/write of the vector. Load the input // value now. - llvm::Value *Vec = Builder.CreateLoad(Dst.getOCUVectorAddr(), "tmp"); + llvm::Value *Vec = Builder.CreateLoad(Dst.getExtVectorAddr(), "tmp"); // FIXME: Volatility. - unsigned EncFields = Dst.getOCUVectorElts(); + unsigned EncFields = Dst.getExtVectorElts(); llvm::Value *SrcVal = Src.getScalarVal(); @@ -322,18 +324,18 @@ void CodeGenFunction::EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, i); Elt = Builder.CreateExtractElement(SrcVal, Elt, "tmp"); - unsigned Idx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields); + unsigned Idx = ExtVectorElementExpr::getAccessedFieldNo(i, EncFields); llvm::Value *OutIdx = llvm::ConstantInt::get(llvm::Type::Int32Ty, Idx); Vec = Builder.CreateInsertElement(Vec, Elt, OutIdx, "tmp"); } } else { // If the Src is a scalar (not a vector) it must be updating one element. - unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields); + unsigned InIdx = ExtVectorElementExpr::getAccessedFieldNo(0, EncFields); llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx); Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp"); } - Builder.CreateStore(Vec, Dst.getOCUVectorAddr()); + Builder.CreateStore(Vec, Dst.getExtVectorAddr()); } @@ -455,12 +457,12 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) { } LValue CodeGenFunction:: -EmitOCUVectorElementExpr(const OCUVectorElementExpr *E) { +EmitExtVectorElementExpr(const ExtVectorElementExpr *E) { // Emit the base vector as an l-value. LValue Base = EmitLValue(E->getBase()); assert(Base.isSimple() && "Can only subscript lvalue vectors here!"); - return LValue::MakeOCUVectorElt(Base.getAddress(), + return LValue::MakeExtVectorElt(Base.getAddress(), E->getEncodedElementAccess()); } diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp index a6bd604bbc..8abccda9d7 100644 --- a/lib/CodeGen/CGExprScalar.cpp +++ b/lib/CodeGen/CGExprScalar.cpp @@ -128,7 +128,7 @@ public: Value *VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) { return EmitLoadOfLValue(E);} Value *VisitArraySubscriptExpr(ArraySubscriptExpr *E); Value *VisitMemberExpr(Expr *E) { return EmitLoadOfLValue(E); } - Value *VisitOCUVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); } + Value *VisitExtVectorElementExpr(Expr *E) { return EmitLoadOfLValue(E); } Value *VisitStringLiteral(Expr *E) { return EmitLValue(E).getAddress(); } Value *VisitPreDefinedExpr(Expr *E) { return EmitLValue(E).getAddress(); } @@ -379,8 +379,8 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType, return Builder.CreatePtrToInt(Src, DstTy, "conv"); } - // A scalar source can be splatted to an OCU vector of the same element type - if (DstType->isOCUVectorType() && !isa(SrcType) && + // A scalar can be splatted to an extended vector of the same element type + if (DstType->isExtVectorType() && !isa(SrcType) && cast(DstTy)->getElementType() == Src->getType()) return CGF.EmitVector(&Src, DstType->getAsVectorType()->getNumElements(), true); diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index f40a0fad00..d9e2820e8e 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -62,7 +62,7 @@ namespace clang { class BinaryOperator; class CompoundAssignOperator; class ArraySubscriptExpr; - class OCUVectorElementExpr; + class ExtVectorElementExpr; class ConditionalOperator; class ChooseExpr; class PreDefinedExpr; @@ -155,14 +155,14 @@ class LValue { Simple, // This is a normal l-value, use getAddress(). VectorElt, // This is a vector element l-value (V[i]), use getVector* BitField, // This is a bitfield l-value, use getBitfield*. - OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp + ExtVectorElt // This is an extended vector subset, use getExtVectorComp } LVType; llvm::Value *V; union { llvm::Value *VectorIdx; // Index into a vector subscript: V[i] - unsigned VectorElts; // Encoded OCUVector element subset: V.xyx + unsigned VectorElts; // Encoded ExtVector element subset: V.xyx struct { unsigned short StartBit; unsigned short Size; @@ -173,17 +173,17 @@ public: bool isSimple() const { return LVType == Simple; } bool isVectorElt() const { return LVType == VectorElt; } bool isBitfield() const { return LVType == BitField; } - bool isOCUVectorElt() const { return LVType == OCUVectorElt; } + bool isExtVectorElt() const { return LVType == ExtVectorElt; } // simple lvalue llvm::Value *getAddress() const { assert(isSimple()); return V; } // vector elt lvalue llvm::Value *getVectorAddr() const { assert(isVectorElt()); return V; } llvm::Value *getVectorIdx() const { assert(isVectorElt()); return VectorIdx; } - // ocu vector elements. - llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; } - unsigned getOCUVectorElts() const { - assert(isOCUVectorElt()); + // extended vector elements. + llvm::Value *getExtVectorAddr() const { assert(isExtVectorElt()); return V; } + unsigned getExtVectorElts() const { + assert(isExtVectorElt()); return VectorElts; } // bitfield lvalue @@ -216,9 +216,9 @@ public: return R; } - static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) { + static LValue MakeExtVectorElt(llvm::Value *Vec, unsigned Elements) { LValue R; - R.LVType = OCUVectorElt; + R.LVType = ExtVectorElt; R.V = Vec; R.VectorElts = Elements; return R; @@ -405,7 +405,7 @@ public: /// this method emits the address of the lvalue, then loads the result as an /// rvalue, returning the rvalue. RValue EmitLoadOfLValue(LValue V, QualType LVType); - RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType); + RValue EmitLoadOfExtVectorElementLValue(LValue V, QualType LVType); RValue EmitLoadOfBitfieldLValue(LValue LV, QualType ExprType); @@ -413,7 +413,8 @@ public: /// lvalue, where both are guaranteed to the have the same type, and that type /// is 'Ty'. void EmitStoreThroughLValue(RValue Src, LValue Dst, QualType Ty); - void EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst, QualType Ty); + void EmitStoreThroughExtVectorComponentLValue(RValue Src, LValue Dst, + QualType Ty); void EmitStoreThroughBitfieldLValue(RValue Src, LValue Dst, QualType Ty); // Note: only availabe for agg return types @@ -424,7 +425,7 @@ public: LValue EmitPreDefinedLValue(const PreDefinedExpr *E); LValue EmitUnaryOpLValue(const UnaryOperator *E); LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E); - LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E); + LValue EmitExtVectorElementExpr(const ExtVectorElementExpr *E); LValue EmitMemberExpr(const MemberExpr *E); LValue EmitLValueForField(llvm::Value* Base, FieldDecl* Field, diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index 2fcdb1530f..a7f6670cb6 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -258,7 +258,7 @@ const llvm::Type *CodeGenTypes::ConvertNewType(QualType T) { const llvm::Type *EltTy = ConvertTypeRecursive(A.getElementType()); return llvm::ArrayType::get(EltTy, A.getSize().getZExtValue()); } - case Type::OCUVector: + case Type::ExtVector: case Type::Vector: { const VectorType &VT = cast(Ty); return llvm::VectorType::get(ConvertTypeRecursive(VT.getElementType()), diff --git a/lib/Parse/AttributeList.cpp b/lib/Parse/AttributeList.cpp index 0ff9447d2e..c764085caa 100644 --- a/lib/Parse/AttributeList.cpp +++ b/lib/Parse/AttributeList.cpp @@ -88,7 +88,7 @@ AttributeList::Kind AttributeList::getKind(const IdentifierInfo *Name) { if (!memcmp(Str, "address_space", 13)) return AT_address_space; break; case 15: - if (!memcmp(Str, "ocu_vector_type", 15)) return AT_ocu_vector_type; + if (!memcmp(Str, "ext_vector_type", 15)) return AT_ext_vector_type; break; case 18: if (!memcmp(Str, "warn_unused_result", 18)) return AT_warn_unused_result; diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h index 9d60093ca9..6d6a26d95d 100644 --- a/lib/Sema/Sema.h +++ b/lib/Sema/Sema.h @@ -51,7 +51,7 @@ namespace clang { class ArrayType; class LabelStmt; class SwitchStmt; - class OCUVectorType; + class ExtVectorType; class TypedefDecl; class ObjCInterfaceDecl; class ObjCCompatibleAliasDecl; @@ -85,10 +85,10 @@ class Sema : public Action { llvm::SmallVector SwitchStack; - /// OCUVectorDecls - This is a list all the OCU vector types. This allows - /// us to associate a raw vector type with one of the OCU type names. + /// ExtVectorDecls - This is a list all the extended vector types. This allows + /// us to associate a raw vector type with one of the ext_vector type names. /// This is only necessary for issuing pretty diagnostics. - llvm::SmallVector OCUVectorDecls; + llvm::SmallVector ExtVectorDecls; /// ObjCImplementations - Keep track of all of the classes with /// @implementation's, so that we can emit errors on duplicates. @@ -307,7 +307,7 @@ private: // for the variable, measured in bytes. If curType and rawAttr are well // formed, this routine will return a new vector type. QualType HandleVectorTypeAttribute(QualType curType, AttributeList *rawAttr); - void HandleOCUVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr); + void HandleExtVectorTypeAttribute(TypedefDecl *d, AttributeList *rawAttr); void HandleAlignedAttribute(Decl *d, AttributeList *rawAttr); void HandlePackedAttribute(Decl *d, AttributeList *rawAttr); @@ -821,7 +821,7 @@ private: QualType CheckRealImagOperand(Expr *&Op, SourceLocation OpLoc); /// type checking primary expressions. - QualType CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, + QualType CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, IdentifierInfo &Comp, SourceLocation CmpLoc); /// type checking declaration initializers (C99 6.7.8) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index e51b7974ae..eec8ce5d0a 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1928,12 +1928,12 @@ void Sema::HandleDeclAttribute(Decl *New, AttributeList *Attr) { tDecl->setUnderlyingType(newType); } break; - case AttributeList::AT_ocu_vector_type: + case AttributeList::AT_ext_vector_type: if (TypedefDecl *tDecl = dyn_cast(New)) - HandleOCUVectorTypeAttribute(tDecl, Attr); + HandleExtVectorTypeAttribute(tDecl, Attr); else Diag(Attr->getLoc(), - diag::err_typecheck_ocu_vector_not_typedef); + diag::err_typecheck_ext_vector_not_typedef); break; case AttributeList::AT_address_space: if (TypedefDecl *tDecl = dyn_cast(New)) { @@ -2009,7 +2009,7 @@ void Sema::HandleDeclAttributes(Decl *New, AttributeList *declspec_prefix, } } -void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl, +void Sema::HandleExtVectorTypeAttribute(TypedefDecl *tDecl, AttributeList *rawAttr) { QualType curType = tDecl->getUnderlyingType(); // check the attribute arguments. @@ -2022,7 +2022,7 @@ void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl, llvm::APSInt vecSize(32); if (!sizeExpr->isIntegerConstantExpr(vecSize, Context)) { Diag(rawAttr->getLoc(), diag::err_attribute_argument_not_int, - "ocu_vector_type", sizeExpr->getSourceRange()); + "ext_vector_type", sizeExpr->getSourceRange()); return; } // unlike gcc's vector_size attribute, we do not allow vectors to be defined @@ -2043,9 +2043,9 @@ void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl, return; } // Instantiate/Install the vector type, the number of elements is > 0. - tDecl->setUnderlyingType(Context.getOCUVectorType(curType, vectorSize)); + tDecl->setUnderlyingType(Context.getExtVectorType(curType, vectorSize)); // Remember this typedef decl, we will need it later for diagnostics. - OCUVectorDecls.push_back(tDecl); + ExtVectorDecls.push_back(tDecl); } QualType Sema::HandleVectorTypeAttribute(QualType curType, diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index fa3a188332..fd02443d80 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -429,7 +429,7 @@ ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc, // Component access limited to variables (reject vec4.rg[1]). if (!isa(BaseExpr) && !isa(BaseExpr)) - return Diag(LLoc, diag::err_ocuvector_component_access, + return Diag(LLoc, diag::err_ext_vector_component_access, SourceRange(LLoc, RLoc)); // FIXME: need to deal with const... ResultType = VTy->getElementType(); @@ -455,14 +455,14 @@ ActOnArraySubscriptExpr(ExprTy *Base, SourceLocation LLoc, } QualType Sema:: -CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, +CheckExtVectorComponent(QualType baseType, SourceLocation OpLoc, IdentifierInfo &CompName, SourceLocation CompLoc) { - const OCUVectorType *vecType = baseType->getAsOCUVectorType(); + const ExtVectorType *vecType = baseType->getAsExtVectorType(); // The vector accessor can't exceed the number of elements. const char *compStr = CompName.getName(); if (strlen(compStr) > vecType->getNumElements()) { - Diag(OpLoc, diag::err_ocuvector_component_exceeds_length, + Diag(OpLoc, diag::err_ext_vector_component_exceeds_length, baseType.getAsString(), SourceRange(CompLoc)); return QualType(); } @@ -484,7 +484,7 @@ CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, if (*compStr) { // We didn't get to the end of the string. This means the component names // didn't come from the same set *or* we encountered an illegal name. - Diag(OpLoc, diag::err_ocuvector_component_name_illegal, + Diag(OpLoc, diag::err_ext_vector_component_name_illegal, std::string(compStr,compStr+1), SourceRange(CompLoc)); return QualType(); } @@ -499,7 +499,7 @@ CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, if (*compStr) { // We didn't get to the end of the string. This means a component accessor // exceeds the number of elements in the vector. - Diag(OpLoc, diag::err_ocuvector_component_exceeds_length, + Diag(OpLoc, diag::err_ext_vector_component_exceeds_length, baseType.getAsString(), SourceRange(CompLoc)); return QualType(); } @@ -510,12 +510,12 @@ CheckOCUVectorComponent(QualType baseType, SourceLocation OpLoc, if (CompSize == 1) return vecType->getElementType(); - QualType VT = Context.getOCUVectorType(vecType->getElementType(), CompSize); + QualType VT = Context.getExtVectorType(vecType->getElementType(), CompSize); // Now look up the TypeDefDecl from the vector type. Without this, - // diagostics look bad. We want OCU vector types to appear built-in. - for (unsigned i = 0, E = OCUVectorDecls.size(); i != E; ++i) { - if (OCUVectorDecls[i]->getUnderlyingType() == VT) - return Context.getTypedefType(OCUVectorDecls[i]); + // diagostics look bad. We want extended vector types to appear built-in. + for (unsigned i = 0, E = ExtVectorDecls.size(); i != E; ++i) { + if (ExtVectorDecls[i]->getUnderlyingType() == VT) + return Context.getTypedefType(ExtVectorDecls[i]); } return VT; // should never get here (a typedef type should always be found). } @@ -540,7 +540,7 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, return Diag(OpLoc, diag::err_typecheck_member_reference_arrow, SourceRange(MemberLoc)); } - // The base type is either a record or an OCUVectorType. + // The base type is either a record or an ExtVectorType. if (const RecordType *RTy = BaseType->getAsRecordType()) { RecordDecl *RDecl = RTy->getDecl(); if (RTy->isIncompleteType()) @@ -561,15 +561,15 @@ ActOnMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc, return new MemberExpr(BaseExpr, OpKind==tok::arrow, MemberDecl, MemberLoc, MemberType); - } else if (BaseType->isOCUVectorType() && OpKind == tok::period) { + } else if (BaseType->isExtVectorType() && OpKind == tok::period) { // Component access limited to variables (reject vec4.rg.g). if (!isa(BaseExpr) && !isa(BaseExpr)) - return Diag(OpLoc, diag::err_ocuvector_component_access, + return Diag(OpLoc, diag::err_ext_vector_component_access, SourceRange(MemberLoc)); - QualType ret = CheckOCUVectorComponent(BaseType, OpLoc, Member, MemberLoc); + QualType ret = CheckExtVectorComponent(BaseType, OpLoc, Member, MemberLoc); if (ret.isNull()) return true; - return new OCUVectorElementExpr(ret, BaseExpr, Member, MemberLoc); + return new ExtVectorElementExpr(ret, BaseExpr, Member, MemberLoc); } else if (BaseType->isObjCInterfaceType()) { ObjCInterfaceDecl *IFace; if (isa(BaseType.getCanonicalType())) @@ -1208,8 +1208,8 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) { } if (isa(lhsType) || isa(rhsType)) { - // For OCUVector, allow vector splats; float -> - if (const OCUVectorType *LV = dyn_cast(lhsType)) { + // For ExtVector, allow vector splats; float -> + if (const ExtVectorType *LV = dyn_cast(lhsType)) { if (LV->getElementType().getTypePtr() == rhsType.getTypePtr()) return Compatible; } @@ -1310,9 +1310,9 @@ inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex, if (lhsType == rhsType) return lhsType; - // if the lhs is an ocu vector and the rhs is a scalar of the same type, + // if the lhs is an extended vector and the rhs is a scalar of the same type, // promote the rhs to the vector type. - if (const OCUVectorType *V = lhsType->getAsOCUVectorType()) { + if (const ExtVectorType *V = lhsType->getAsExtVectorType()) { if (V->getElementType().getCanonicalType().getTypePtr() == rhsType.getCanonicalType().getTypePtr()) { ImpCastExprToType(rex, lhsType); @@ -1320,9 +1320,9 @@ inline QualType Sema::CheckVectorOperands(SourceLocation loc, Expr *&lex, } } - // if the rhs is an ocu vector and the lhs is a scalar of the same type, + // if the rhs is an extended vector and the lhs is a scalar of the same type, // promote the lhs to the vector type. - if (const OCUVectorType *V = rhsType->getAsOCUVectorType()) { + if (const ExtVectorType *V = rhsType->getAsExtVectorType()) { if (V->getElementType().getCanonicalType().getTypePtr() == lhsType.getCanonicalType().getTypePtr()) { ImpCastExprToType(lex, rhsType); diff --git a/test/CodeGen/ocu-vector.c b/test/CodeGen/ocu-vector.c index cffef339ee..3313b127f0 100644 --- a/test/CodeGen/ocu-vector.c +++ b/test/CodeGen/ocu-vector.c @@ -1,7 +1,7 @@ // RUN: clang -emit-llvm %s -typedef __attribute__(( ocu_vector_type(4) )) float float4; -typedef __attribute__(( ocu_vector_type(2) )) float float2; +typedef __attribute__(( ext_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(2) )) float float2; float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 }; diff --git a/test/Parser/ocu_vector_components.c b/test/Parser/ocu_vector_components.c index 06084174af..01e007b744 100644 --- a/test/Parser/ocu_vector_components.c +++ b/test/Parser/ocu_vector_components.c @@ -1,8 +1,8 @@ // RUN: clang -fsyntax-only -verify %s -typedef __attribute__(( ocu_vector_type(2) )) float float2; -typedef __attribute__(( ocu_vector_type(3) )) float float3; -typedef __attribute__(( ocu_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(2) )) float float2; +typedef __attribute__(( ext_vector_type(3) )) float float3; +typedef __attribute__(( ext_vector_type(4) )) float float4; static void test() { float2 vec2, vec2_2; diff --git a/test/Sema/vector-init.c b/test/Sema/vector-init.c index 5436cbac8c..1e2ba012c8 100644 --- a/test/Sema/vector-init.c +++ b/test/Sema/vector-init.c @@ -1,5 +1,5 @@ // RUN: clang %s -verify -fsyntax-only -typedef __attribute__(( ocu_vector_type(4) )) float float4; +typedef __attribute__(( ext_vector_type(4) )) float float4; float4 foo = (float4){ 1.0, 2.0, 3.0, 4.0 };