forked from OSchip/llvm-project
introduce and use a new ExtVectorElementExpr::isArrow method, at Eli's suggestion
llvm-svn: 64681
This commit is contained in:
parent
f95039cd58
commit
b8211f6436
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue