Remove AST dependency on VMCore by switching ExtVectorElementExpr off Constant.
llvm-svn: 51068
This commit is contained in:
parent
bb3aef4ee3
commit
d386215916
|
@ -21,10 +21,9 @@
|
||||||
#include "clang/Basic/IdentifierTable.h"
|
#include "clang/Basic/IdentifierTable.h"
|
||||||
#include "llvm/ADT/APSInt.h"
|
#include "llvm/ADT/APSInt.h"
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class llvm::Constant;
|
|
||||||
|
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class IdentifierInfo;
|
class IdentifierInfo;
|
||||||
class Selector;
|
class Selector;
|
||||||
|
@ -722,12 +721,11 @@ public:
|
||||||
|
|
||||||
/// getEncodedElementAccess - Encode the elements accessed into an llvm
|
/// getEncodedElementAccess - Encode the elements accessed into an llvm
|
||||||
/// aggregate Constant of ConstantInt(s).
|
/// aggregate Constant of ConstantInt(s).
|
||||||
llvm::Constant *getEncodedElementAccess() const;
|
void getEncodedElementAccess(llvm::SmallVectorImpl<unsigned> &Elts) const;
|
||||||
|
|
||||||
/// getAccessedFieldNo - Given an encoded value and a result number, return
|
/// getAccessedFieldNo - Given an encoded value and a result number, return
|
||||||
/// the input field number being accessed.
|
/// the input field number being accessed.
|
||||||
static unsigned getAccessedFieldNo(unsigned Idx,
|
static unsigned getAccessedFieldNo(unsigned Idx, const llvm::Constant *Elts);
|
||||||
const llvm::Constant *Elts);
|
|
||||||
|
|
||||||
virtual SourceRange getSourceRange() const {
|
virtual SourceRange getSourceRange() const {
|
||||||
return SourceRange(getBase()->getLocStart(), AccessorLoc);
|
return SourceRange(getBase()->getLocStart(), AccessorLoc);
|
||||||
|
|
|
@ -1057,9 +1057,9 @@ bool ExtVectorElementExpr::containsDuplicateElements() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// getEncodedElementAccess - We encode the fields as a llvm ConstantArray.
|
/// getEncodedElementAccess - We encode the fields as a llvm ConstantArray.
|
||||||
llvm::Constant *ExtVectorElementExpr::getEncodedElementAccess() const {
|
void ExtVectorElementExpr::getEncodedElementAccess(
|
||||||
|
llvm::SmallVectorImpl<unsigned> &Elts) const {
|
||||||
const char *compStr = Accessor.getName();
|
const char *compStr = Accessor.getName();
|
||||||
llvm::SmallVector<llvm::Constant *, 8> Indices;
|
|
||||||
|
|
||||||
bool isHi = !strcmp(compStr, "hi");
|
bool isHi = !strcmp(compStr, "hi");
|
||||||
bool isLo = !strcmp(compStr, "lo");
|
bool isLo = !strcmp(compStr, "lo");
|
||||||
|
@ -1080,9 +1080,8 @@ llvm::Constant *ExtVectorElementExpr::getEncodedElementAccess() const {
|
||||||
else
|
else
|
||||||
Index = ExtVectorType::getAccessorIdx(compStr[i]);
|
Index = ExtVectorType::getAccessorIdx(compStr[i]);
|
||||||
|
|
||||||
Indices.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, Index));
|
Elts.push_back(Index);
|
||||||
}
|
}
|
||||||
return llvm::ConstantVector::get(&Indices[0], Indices.size());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned
|
unsigned
|
||||||
|
|
|
@ -456,33 +456,42 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E) {
|
||||||
return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"));
|
return LValue::MakeAddr(Builder.CreateGEP(Base, Idx, "arrayidx"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
llvm::Constant *GenerateConstantVector(llvm::SmallVector<unsigned, 4> &Elts) {
|
||||||
|
llvm::SmallVector<llvm::Constant *, 4> CElts;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Elts.size(); i != e; ++i)
|
||||||
|
CElts.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, Elts[i]));
|
||||||
|
|
||||||
|
return llvm::ConstantVector::get(&CElts[0], CElts.size());
|
||||||
|
}
|
||||||
|
|
||||||
LValue CodeGenFunction::
|
LValue CodeGenFunction::
|
||||||
EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
|
EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
|
||||||
// Emit the base vector as an l-value.
|
// Emit the base vector as an l-value.
|
||||||
LValue Base = EmitLValue(E->getBase());
|
LValue Base = EmitLValue(E->getBase());
|
||||||
|
|
||||||
if (Base.isExtVectorElt()) {
|
|
||||||
llvm::Constant *BaseElts = Base.getExtVectorElts();
|
|
||||||
llvm::Constant *ExprElts = E->getEncodedElementAccess();
|
|
||||||
|
|
||||||
llvm::SmallVector<llvm::Constant *, 8> Indices;
|
|
||||||
|
|
||||||
for (unsigned i = 0, e = E->getNumElements(); i != e; ++i) {
|
|
||||||
unsigned Idx = ExtVectorElementExpr::getAccessedFieldNo(i, ExprElts);
|
|
||||||
|
|
||||||
if (isa<llvm::ConstantAggregateZero>(BaseElts))
|
|
||||||
Indices.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
|
|
||||||
else
|
|
||||||
Indices.push_back(cast<llvm::ConstantInt>(BaseElts->getOperand(Idx)));
|
|
||||||
}
|
|
||||||
llvm::Constant *NewElts = llvm::ConstantVector::get(&Indices[0], Indices.size());
|
|
||||||
return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), NewElts);
|
|
||||||
}
|
|
||||||
|
|
||||||
assert(Base.isSimple() && "Can only subscript lvalue vectors here!");
|
|
||||||
|
|
||||||
return LValue::MakeExtVectorElt(Base.getAddress(),
|
// Encode the element access list into a vector of unsigned indices.
|
||||||
E->getEncodedElementAccess());
|
llvm::SmallVector<unsigned, 4> Indices;
|
||||||
|
E->getEncodedElementAccess(Indices);
|
||||||
|
|
||||||
|
if (Base.isSimple()) {
|
||||||
|
llvm::Constant *CV = GenerateConstantVector(Indices);
|
||||||
|
return LValue::MakeExtVectorElt(Base.getAddress(), CV);
|
||||||
|
}
|
||||||
|
assert(Base.isExtVectorElt() && "Can only subscript lvalue vec elts here!");
|
||||||
|
|
||||||
|
llvm::Constant *BaseElts = Base.getExtVectorElts();
|
||||||
|
llvm::SmallVector<llvm::Constant *, 4> CElts;
|
||||||
|
|
||||||
|
for (unsigned i = 0, e = Indices.size(); i != e; ++i) {
|
||||||
|
if (isa<llvm::ConstantAggregateZero>(BaseElts))
|
||||||
|
CElts.push_back(llvm::ConstantInt::get(llvm::Type::Int32Ty, 0));
|
||||||
|
else
|
||||||
|
CElts.push_back(BaseElts->getOperand(Indices[i]));
|
||||||
|
}
|
||||||
|
llvm::Constant *CV = llvm::ConstantVector::get(&CElts[0], CElts.size());
|
||||||
|
return LValue::MakeExtVectorElt(Base.getExtVectorAddr(), CV);
|
||||||
}
|
}
|
||||||
|
|
||||||
LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
|
LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
|
||||||
|
|
Loading…
Reference in New Issue