mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
Rename AddrLabel and OCUVectorComponent -> AddrLabelExpr and OCUVectorElementExpr respectively. This is for consistency with other expr nodes end with *Expr.
llvm-svn: 40785
This commit is contained in:
@@ -226,8 +226,8 @@ Expr::isLvalueResult Expr::isLvalue() const {
|
||||
break;
|
||||
case ParenExprClass: // C99 6.5.1p5
|
||||
return cast<ParenExpr>(this)->getSubExpr()->isLvalue();
|
||||
case OCUVectorComponentClass:
|
||||
if (cast<OCUVectorComponent>(this)->containsDuplicateComponents())
|
||||
case OCUVectorElementExprClass:
|
||||
if (cast<OCUVectorElementExpr>(this)->containsDuplicateElements())
|
||||
return LV_DuplicateVectorComponents;
|
||||
return LV_Valid;
|
||||
default:
|
||||
@@ -583,14 +583,15 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const {
|
||||
return isIntegerConstantExpr(Val, Ctx, 0, true) && Val == 0;
|
||||
}
|
||||
|
||||
unsigned OCUVectorComponent::getNumComponents() const {
|
||||
unsigned OCUVectorElementExpr::getNumElements() const {
|
||||
return strlen(Accessor.getName());
|
||||
}
|
||||
|
||||
|
||||
/// getComponentType - Determine whether the components of this access are
|
||||
/// "point" "color" or "texture" elements.
|
||||
OCUVectorComponent::ComponentType OCUVectorComponent::getComponentType() const {
|
||||
OCUVectorElementExpr::ElementType
|
||||
OCUVectorElementExpr::getElementType() const {
|
||||
// derive the component type, no need to waste space.
|
||||
const char *compStr = Accessor.getName();
|
||||
|
||||
@@ -602,9 +603,9 @@ OCUVectorComponent::ComponentType OCUVectorComponent::getComponentType() const {
|
||||
return Texture;
|
||||
}
|
||||
|
||||
/// containsDuplicateComponents - Return true if any element access is
|
||||
/// containsDuplicateElements - Return true if any element access is
|
||||
/// repeated.
|
||||
bool OCUVectorComponent::containsDuplicateComponents() const {
|
||||
bool OCUVectorElementExpr::containsDuplicateElements() const {
|
||||
const char *compStr = Accessor.getName();
|
||||
unsigned length = strlen(compStr);
|
||||
|
||||
@@ -618,9 +619,9 @@ bool OCUVectorComponent::containsDuplicateComponents() const {
|
||||
}
|
||||
|
||||
/// getEncodedElementAccess - We encode fields with two bits per component.
|
||||
unsigned OCUVectorComponent::getEncodedElementAccess() const {
|
||||
unsigned OCUVectorElementExpr::getEncodedElementAccess() const {
|
||||
const char *compStr = Accessor.getName();
|
||||
unsigned length = getNumComponents();
|
||||
unsigned length = getNumElements();
|
||||
|
||||
unsigned Result = 0;
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ void StmtPrinter::VisitMemberExpr(MemberExpr *Node) {
|
||||
assert(Field && "MemberExpr should alway reference a field!");
|
||||
OS << Field->getName();
|
||||
}
|
||||
void StmtPrinter::VisitOCUVectorComponent(OCUVectorComponent *Node) {
|
||||
void StmtPrinter::VisitOCUVectorElementExpr(OCUVectorElementExpr *Node) {
|
||||
PrintExpr(Node->getBase());
|
||||
OS << ".";
|
||||
OS << Node->getAccessor().getName();
|
||||
@@ -471,7 +471,7 @@ void StmtPrinter::VisitConditionalOperator(ConditionalOperator *Node) {
|
||||
|
||||
// GNU extensions.
|
||||
|
||||
void StmtPrinter::VisitAddrLabel(AddrLabel *Node) {
|
||||
void StmtPrinter::VisitAddrLabelExpr(AddrLabelExpr *Node) {
|
||||
OS << "&&" << Node->getLabel()->getName();
|
||||
}
|
||||
|
||||
|
||||
@@ -253,8 +253,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
||||
return EmitUnaryOpLValue(cast<UnaryOperator>(E));
|
||||
case Expr::ArraySubscriptExprClass:
|
||||
return EmitArraySubscriptExpr(cast<ArraySubscriptExpr>(E));
|
||||
case Expr::OCUVectorComponentClass:
|
||||
return EmitOCUVectorComponentExpr(cast<OCUVectorComponent>(E));
|
||||
case Expr::OCUVectorElementExprClass:
|
||||
return EmitOCUVectorElementExpr(cast<OCUVectorElementExpr>(E));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,24 +285,24 @@ 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.isOCUVectorComp())
|
||||
return EmitLoadOfOCUComponentLValue(LV, ExprType);
|
||||
if (LV.isOCUVectorElt())
|
||||
return EmitLoadOfOCUElementLValue(LV, ExprType);
|
||||
|
||||
assert(0 && "Bitfield ref not impl!");
|
||||
}
|
||||
|
||||
// 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::EmitLoadOfOCUComponentLValue(LValue LV,
|
||||
RValue CodeGenFunction::EmitLoadOfOCUElementLValue(LValue LV,
|
||||
QualType ExprType) {
|
||||
llvm::Value *Vec = Builder.CreateLoad(LV.getOCUVectorAddr(), "tmp");
|
||||
|
||||
unsigned EncFields = LV.getOCUVectorComp();
|
||||
unsigned EncFields = LV.getOCUVectorElts();
|
||||
|
||||
// If the result of the expression is a non-vector type, we must be
|
||||
// extracting a single element. Just codegen as an extractelement.
|
||||
if (!isa<VectorType>(ExprType)) {
|
||||
unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(0, EncFields);
|
||||
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields);
|
||||
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
|
||||
return RValue::get(Builder.CreateExtractElement(Vec, Elt, "tmp"));
|
||||
}
|
||||
@@ -316,7 +316,7 @@ RValue CodeGenFunction::EmitLoadOfOCUComponentLValue(LValue LV,
|
||||
if (NumResultElts == NumSourceElts) {
|
||||
llvm::SmallVector<llvm::Constant*, 4> Mask;
|
||||
for (unsigned i = 0; i != NumResultElts; ++i) {
|
||||
unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(i, EncFields);
|
||||
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields);
|
||||
Mask.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx));
|
||||
}
|
||||
|
||||
@@ -332,7 +332,7 @@ RValue CodeGenFunction::EmitLoadOfOCUComponentLValue(LValue LV,
|
||||
|
||||
// Extract/Insert each element of the result.
|
||||
for (unsigned i = 0; i != NumResultElts; ++i) {
|
||||
unsigned InIdx = OCUVectorComponent::getAccessedFieldNo(i, EncFields);
|
||||
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(i, EncFields);
|
||||
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
|
||||
Elt = Builder.CreateExtractElement(Vec, Elt, "tmp");
|
||||
|
||||
@@ -366,7 +366,7 @@ void CodeGenFunction::EmitStoreThroughLValue(RValue Src, LValue Dst,
|
||||
}
|
||||
|
||||
// If this is an update of elements of a vector, insert them as appropriate.
|
||||
if (Dst.isOCUVectorComp())
|
||||
if (Dst.isOCUVectorElt())
|
||||
return EmitStoreThroughOCUComponentLValue(Src, Dst, Ty);
|
||||
|
||||
assert(0 && "FIXME: Don't support store to bitfield yet");
|
||||
@@ -423,7 +423,7 @@ void CodeGenFunction::EmitStoreThroughOCUComponentLValue(RValue Src, LValue Dst,
|
||||
// value now.
|
||||
llvm::Value *Vec = Builder.CreateLoad(Dst.getOCUVectorAddr(), "tmp");
|
||||
// FIXME: Volatility.
|
||||
unsigned EncFields = Dst.getOCUVectorComp();
|
||||
unsigned EncFields = Dst.getOCUVectorElts();
|
||||
|
||||
llvm::Value *SrcVal = Src.getVal();
|
||||
|
||||
@@ -435,13 +435,13 @@ 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 = OCUVectorComponent::getAccessedFieldNo(i, EncFields);
|
||||
unsigned Idx = OCUVectorElementExpr::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 = OCUVectorComponent::getAccessedFieldNo(0, EncFields);
|
||||
unsigned InIdx = OCUVectorElementExpr::getAccessedFieldNo(0, EncFields);
|
||||
llvm::Value *Elt = llvm::ConstantInt::get(llvm::Type::Int32Ty, InIdx);
|
||||
Vec = Builder.CreateInsertElement(Vec, SrcVal, Elt, "tmp");
|
||||
}
|
||||
@@ -570,13 +570,13 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
|
||||
}
|
||||
|
||||
LValue CodeGenFunction::
|
||||
EmitOCUVectorComponentExpr(const OCUVectorComponent *E) {
|
||||
EmitOCUVectorElementExpr(const OCUVectorElementExpr *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::MakeOCUVectorComp(Base.getAddress(),
|
||||
E->getEncodedElementAccess());
|
||||
return LValue::MakeOCUVectorElt(Base.getAddress(),
|
||||
E->getEncodedElementAccess());
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
@@ -601,7 +601,7 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) {
|
||||
return EmitLoadOfLValue(E);
|
||||
case Expr::ArraySubscriptExprClass:
|
||||
return EmitArraySubscriptExprRV(cast<ArraySubscriptExpr>(E));
|
||||
case Expr::OCUVectorComponentClass:
|
||||
case Expr::OCUVectorElementExprClass:
|
||||
return EmitLoadOfLValue(E);
|
||||
case Expr::PreDefinedExprClass:
|
||||
case Expr::StringLiteralClass:
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace clang {
|
||||
class BinaryOperator;
|
||||
class CompoundAssignOperator;
|
||||
class ArraySubscriptExpr;
|
||||
class OCUVectorComponent;
|
||||
class OCUVectorElementExpr;
|
||||
class ConditionalOperator;
|
||||
class PreDefinedExpr;
|
||||
|
||||
@@ -120,31 +120,31 @@ 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*.
|
||||
OCUVectorComp // This is an ocu vector subset, use getOCUVectorComp
|
||||
OCUVectorElt // This is an ocu vector subset, use getOCUVectorComp
|
||||
} LVType;
|
||||
|
||||
llvm::Value *V;
|
||||
|
||||
union {
|
||||
llvm::Value *VectorIdx; // Index into a vector subscript: V[i]
|
||||
unsigned VectorComp; // Encoded OCUVector element subset: V.xyx
|
||||
unsigned VectorElts; // Encoded OCUVector element subset: V.xyx
|
||||
};
|
||||
public:
|
||||
bool isSimple() const { return LVType == Simple; }
|
||||
bool isVectorElt() const { return LVType == VectorElt; }
|
||||
bool isBitfield() const { return LVType == BitField; }
|
||||
bool isOCUVectorComp() const { return LVType == OCUVectorComp; }
|
||||
bool isOCUVectorElt() const { return LVType == OCUVectorElt; }
|
||||
|
||||
// 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 components.
|
||||
llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorComp()); return V; }
|
||||
unsigned getOCUVectorComp() const {
|
||||
assert(isOCUVectorComp());
|
||||
return VectorComp;
|
||||
// ocu vector elements.
|
||||
llvm::Value *getOCUVectorAddr() const { assert(isOCUVectorElt()); return V; }
|
||||
unsigned getOCUVectorElts() const {
|
||||
assert(isOCUVectorElt());
|
||||
return VectorElts;
|
||||
}
|
||||
|
||||
|
||||
@@ -163,11 +163,11 @@ public:
|
||||
return R;
|
||||
}
|
||||
|
||||
static LValue MakeOCUVectorComp(llvm::Value *Vec, unsigned Components) {
|
||||
static LValue MakeOCUVectorElt(llvm::Value *Vec, unsigned Elements) {
|
||||
LValue R;
|
||||
R.LVType = OCUVectorComp;
|
||||
R.LVType = OCUVectorElt;
|
||||
R.V = Vec;
|
||||
R.VectorComp = Components;
|
||||
R.VectorElts = Elements;
|
||||
return R;
|
||||
}
|
||||
};
|
||||
@@ -316,7 +316,7 @@ public:
|
||||
/// rvalue, returning the rvalue.
|
||||
RValue EmitLoadOfLValue(const Expr *E);
|
||||
RValue EmitLoadOfLValue(LValue V, QualType LVType);
|
||||
RValue EmitLoadOfOCUComponentLValue(LValue V, QualType LVType);
|
||||
RValue EmitLoadOfOCUElementLValue(LValue V, QualType LVType);
|
||||
|
||||
|
||||
/// EmitStoreThroughLValue - Store the specified rvalue into the specified
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
LValue EmitPreDefinedLValue(const PreDefinedExpr *E);
|
||||
LValue EmitUnaryOpLValue(const UnaryOperator *E);
|
||||
LValue EmitArraySubscriptExpr(const ArraySubscriptExpr *E);
|
||||
LValue EmitOCUVectorComponentExpr(const OCUVectorComponent *E);
|
||||
LValue EmitOCUVectorElementExpr(const OCUVectorElementExpr *E);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Expression Emission
|
||||
|
||||
@@ -438,7 +438,7 @@ ParseMemberReferenceExpr(ExprTy *Base, SourceLocation OpLoc,
|
||||
QualType ret = CheckOCUVectorComponent(BaseType, OpLoc, Member, MemberLoc);
|
||||
if (ret.isNull())
|
||||
return true;
|
||||
return new OCUVectorComponent(ret, BaseExpr, Member, MemberLoc);
|
||||
return new OCUVectorElementExpr(ret, BaseExpr, Member, MemberLoc);
|
||||
} else
|
||||
return Diag(OpLoc, diag::err_typecheck_member_reference_structUnion,
|
||||
SourceRange(MemberLoc));
|
||||
@@ -1545,8 +1545,8 @@ Sema::ExprResult Sema::ParseAddrLabel(SourceLocation OpLoc,
|
||||
LabelDecl = new LabelStmt(LabLoc, LabelII, 0);
|
||||
|
||||
// Create the AST node. The address of a label always has type 'void*'.
|
||||
return new AddrLabel(OpLoc, LabLoc, LabelDecl,
|
||||
Context.getPointerType(Context.VoidTy));
|
||||
return new AddrLabelExpr(OpLoc, LabLoc, LabelDecl,
|
||||
Context.getPointerType(Context.VoidTy));
|
||||
}
|
||||
|
||||
Sema::ExprResult Sema::ParseStmtExpr(SourceLocation LPLoc, StmtTy *substmt,
|
||||
|
||||
@@ -463,39 +463,40 @@ public:
|
||||
static bool classof(const MemberExpr *) { return true; }
|
||||
};
|
||||
|
||||
/// OCUVectorComponent - This represents access to specific components of a
|
||||
/// OCUVectorElementExpr - 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.
|
||||
///
|
||||
class OCUVectorComponent : public Expr {
|
||||
class OCUVectorElementExpr : public Expr {
|
||||
Expr *Base;
|
||||
IdentifierInfo &Accessor;
|
||||
SourceLocation AccessorLoc;
|
||||
public:
|
||||
enum ComponentType {
|
||||
enum ElementType {
|
||||
Point, // xywz
|
||||
Color, // rgba
|
||||
Texture // uv
|
||||
};
|
||||
OCUVectorComponent(QualType ty, Expr *base, IdentifierInfo &accessor,
|
||||
SourceLocation loc) : Expr(OCUVectorComponentClass, ty),
|
||||
Base(base), Accessor(accessor), AccessorLoc(loc) {}
|
||||
OCUVectorElementExpr(QualType ty, Expr *base, IdentifierInfo &accessor,
|
||||
SourceLocation loc)
|
||||
: Expr(OCUVectorElementExprClass, ty),
|
||||
Base(base), Accessor(accessor), AccessorLoc(loc) {}
|
||||
|
||||
const Expr *getBase() const { return Base; }
|
||||
Expr *getBase() { return Base; }
|
||||
|
||||
IdentifierInfo &getAccessor() const { return Accessor; }
|
||||
|
||||
/// getNumComponents - Get the number of components being selected.
|
||||
unsigned getNumComponents() const;
|
||||
/// getNumElements - Get the number of components being selected.
|
||||
unsigned getNumElements() const;
|
||||
|
||||
/// getComponentType - Determine whether the components of this access are
|
||||
/// getElementType - Determine whether the components of this access are
|
||||
/// "point" "color" or "texture" elements.
|
||||
ComponentType getComponentType() const;
|
||||
ElementType getElementType() const;
|
||||
|
||||
/// containsDuplicateComponents - Return true if any element access is
|
||||
/// containsDuplicateElements - Return true if any element access is
|
||||
/// repeated.
|
||||
bool containsDuplicateComponents() const;
|
||||
bool containsDuplicateElements() const;
|
||||
|
||||
/// getEncodedElementAccess - Encode the elements accessed into a bit vector.
|
||||
/// The encoding currently uses 2-bit bitfields, but clients should use the
|
||||
@@ -514,9 +515,9 @@ public:
|
||||
}
|
||||
virtual void visit(StmtVisitor &Visitor);
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == OCUVectorComponentClass;
|
||||
return T->getStmtClass() == OCUVectorElementExprClass;
|
||||
}
|
||||
static bool classof(const OCUVectorComponent *) { return true; }
|
||||
static bool classof(const OCUVectorElementExpr *) { return true; }
|
||||
};
|
||||
|
||||
/// CompoundLiteralExpr - [C99 6.5.2.5]
|
||||
@@ -699,13 +700,14 @@ public:
|
||||
static bool classof(const ConditionalOperator *) { return true; }
|
||||
};
|
||||
|
||||
/// AddrLabel - The GNU address of label extension, representing &&label.
|
||||
class AddrLabel : public Expr {
|
||||
/// AddrLabelExpr - The GNU address of label extension, representing &&label.
|
||||
class AddrLabelExpr : public Expr {
|
||||
SourceLocation AmpAmpLoc, LabelLoc;
|
||||
LabelStmt *Label;
|
||||
public:
|
||||
AddrLabel(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L, QualType t)
|
||||
: Expr(AddrLabelClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
|
||||
AddrLabelExpr(SourceLocation AALoc, SourceLocation LLoc, LabelStmt *L,
|
||||
QualType t)
|
||||
: Expr(AddrLabelExprClass, t), AmpAmpLoc(AALoc), LabelLoc(LLoc), Label(L) {}
|
||||
|
||||
virtual SourceRange getSourceRange() const {
|
||||
return SourceRange(AmpAmpLoc, LabelLoc);
|
||||
@@ -715,9 +717,9 @@ public:
|
||||
|
||||
virtual void visit(StmtVisitor &Visitor);
|
||||
static bool classof(const Stmt *T) {
|
||||
return T->getStmtClass() == AddrLabelClass;
|
||||
return T->getStmtClass() == AddrLabelExprClass;
|
||||
}
|
||||
static bool classof(const AddrLabel *) { return true; }
|
||||
static bool classof(const AddrLabelExpr *) { return true; }
|
||||
};
|
||||
|
||||
/// StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
|
||||
|
||||
@@ -62,10 +62,10 @@ STMT(45, BinaryOperator , Expr)
|
||||
STMT(46, ConditionalOperator , Expr)
|
||||
STMT(47, ImplicitCastExpr , Expr)
|
||||
STMT(48, CompoundLiteralExpr , Expr)
|
||||
STMT(49, OCUVectorComponent , Expr)
|
||||
STMT(49, OCUVectorElementExpr , Expr)
|
||||
|
||||
// GNU Extensions.
|
||||
STMT(50, AddrLabel , Expr)
|
||||
STMT(50, AddrLabelExpr , Expr)
|
||||
STMT(51, StmtExpr , Expr)
|
||||
STMT(52, TypesCompatibleExpr , Expr)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user