introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion

llvm-svn: 64681
This commit is contained in:
Chris Lattner 2009-02-16 22:14:05 +00:00
parent f95039cd58
commit b8211f6436
3 changed files with 15 additions and 4 deletions

View File

@ -2086,6 +2086,10 @@ public:
return SourceRange(getBase()->getLocStart(), AccessorLoc);
}
/// isArrow - Return true if the base expression is a pointer to vector,
/// return false if the base expression is a vector.
bool isArrow() const;
static bool classof(const Stmt *T) {
return T->getStmtClass() == ExtVectorElementExprClass;
}

View File

@ -1294,6 +1294,12 @@ bool Expr::isBitField() {
return false;
}
/// isArrow - Return true if the base expression is a pointer to vector,
/// return false if the base expression is a vector.
bool ExtVectorElementExpr::isArrow() const {
return getBase()->getType()->isPointerType();
}
unsigned ExtVectorElementExpr::getNumElements() const {
if (const VectorType *VT = getType()->getAsVectorType())
return VT->getNumElements();

View File

@ -797,12 +797,13 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
LValue Base;
// ExtVectorElementExpr's base can either be a vector or pointer to vector.
if (const PointerType *PT = E->getBase()->getType()->getAsPointerType()) {
llvm::Value *Ptr = EmitScalarExpr(E->getBase());
Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
} else {
if (!E->isArrow()) {
assert(E->getBase()->getType()->isVectorType());
Base = EmitLValue(E->getBase());
} else {
const PointerType *PT = E->getBase()->getType()->getAsPointerType();
llvm::Value *Ptr = EmitScalarExpr(E->getBase());
Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
}
// Encode the element access list into a vector of unsigned indices.