mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[Attributor][NFC] Refactor interface
This commit is contained in:
parent
2d214fefe5
commit
dec8fd7748
@ -411,22 +411,6 @@ struct IRPosition {
|
||||
SmallVectorImpl<Attribute> &Attrs,
|
||||
bool IgnoreSubsumingPositions = false) const;
|
||||
|
||||
/// Return the attribute of kind \p AK existing in the IR at this position.
|
||||
Attribute getAttr(Attribute::AttrKind AK) const {
|
||||
if (getPositionKind() == IRP_INVALID || getPositionKind() == IRP_FLOAT)
|
||||
return Attribute();
|
||||
|
||||
AttributeList AttrList;
|
||||
if (ImmutableCallSite ICS = ImmutableCallSite(&getAnchorValue()))
|
||||
AttrList = ICS.getAttributes();
|
||||
else
|
||||
AttrList = getAssociatedFunction()->getAttributes();
|
||||
|
||||
if (AttrList.hasAttribute(getAttrIdx(), AK))
|
||||
return AttrList.getAttribute(getAttrIdx(), AK);
|
||||
return Attribute();
|
||||
}
|
||||
|
||||
/// Remove the attribute of kind \p AKs existing in the IR at this position.
|
||||
void removeAttrs(ArrayRef<Attribute::AttrKind> AKs) const {
|
||||
if (getPositionKind() == IRP_INVALID || getPositionKind() == IRP_FLOAT)
|
||||
@ -481,6 +465,10 @@ private:
|
||||
/// Verify internal invariants.
|
||||
void verify();
|
||||
|
||||
/// Return the attributes of kind \p AK existing in the IR as attribute.
|
||||
bool getAttrsFromIRAttr(Attribute::AttrKind AK,
|
||||
SmallVectorImpl<Attribute> &Attrs) const;
|
||||
|
||||
protected:
|
||||
/// The value this position is anchored at.
|
||||
Value *AnchorVal;
|
||||
|
@ -678,9 +678,10 @@ SubsumingPositionIterator::SubsumingPositionIterator(const IRPosition &IRP) {
|
||||
|
||||
bool IRPosition::hasAttr(ArrayRef<Attribute::AttrKind> AKs,
|
||||
bool IgnoreSubsumingPositions) const {
|
||||
SmallVector<Attribute, 4> Attrs;
|
||||
for (const IRPosition &EquivIRP : SubsumingPositionIterator(*this)) {
|
||||
for (Attribute::AttrKind AK : AKs)
|
||||
if (EquivIRP.getAttr(AK).getKindAsEnum() == AK)
|
||||
if (EquivIRP.getAttrsFromIRAttr(AK, Attrs))
|
||||
return true;
|
||||
// The first position returned by the SubsumingPositionIterator is
|
||||
// always the position itself. If we ignore subsuming positions we
|
||||
@ -695,11 +696,8 @@ void IRPosition::getAttrs(ArrayRef<Attribute::AttrKind> AKs,
|
||||
SmallVectorImpl<Attribute> &Attrs,
|
||||
bool IgnoreSubsumingPositions) const {
|
||||
for (const IRPosition &EquivIRP : SubsumingPositionIterator(*this)) {
|
||||
for (Attribute::AttrKind AK : AKs) {
|
||||
const Attribute &Attr = EquivIRP.getAttr(AK);
|
||||
if (Attr.getKindAsEnum() == AK)
|
||||
Attrs.push_back(Attr);
|
||||
}
|
||||
for (Attribute::AttrKind AK : AKs)
|
||||
EquivIRP.getAttrsFromIRAttr(AK, Attrs);
|
||||
// The first position returned by the SubsumingPositionIterator is
|
||||
// always the position itself. If we ignore subsuming positions we
|
||||
// are done after the first iteration.
|
||||
@ -708,6 +706,24 @@ void IRPosition::getAttrs(ArrayRef<Attribute::AttrKind> AKs,
|
||||
}
|
||||
}
|
||||
|
||||
bool IRPosition::getAttrsFromIRAttr(Attribute::AttrKind AK,
|
||||
SmallVectorImpl<Attribute> &Attrs) const {
|
||||
if (getPositionKind() == IRP_INVALID || getPositionKind() == IRP_FLOAT)
|
||||
return false;
|
||||
|
||||
AttributeList AttrList;
|
||||
if (ImmutableCallSite ICS = ImmutableCallSite(&getAnchorValue()))
|
||||
AttrList = ICS.getAttributes();
|
||||
else
|
||||
AttrList = getAssociatedFunction()->getAttributes();
|
||||
|
||||
bool HasAttr = AttrList.hasAttribute(getAttrIdx(), AK);
|
||||
if (HasAttr)
|
||||
Attrs.push_back(AttrList.getAttribute(getAttrIdx(), AK));
|
||||
return HasAttr;
|
||||
}
|
||||
|
||||
|
||||
void IRPosition::verify() {
|
||||
switch (KindOrArgNo) {
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user