forked from OSchip/llvm-project
Rename NamedAttributeList to MutableDictionaryAttr
Makes the relationship and function clearer. Accordingly rename getAttrList to getMutableAttrDict. Differential Revision: https://reviews.llvm.org/D79125
This commit is contained in:
parent
53ff95254d
commit
5439582781
|
@ -680,7 +680,7 @@ def LLVM_LLVMFuncOp
|
|||
OpBuilder<"OpBuilder &builder, OperationState &result, StringRef name, "
|
||||
"LLVMType type, LLVM::Linkage linkage = LLVM::Linkage::External, "
|
||||
"ArrayRef<NamedAttribute> attrs = {}, "
|
||||
"ArrayRef<NamedAttributeList> argAttrs = {}">
|
||||
"ArrayRef<MutableDictionaryAttr> argAttrs = {}">
|
||||
];
|
||||
|
||||
let extraClassDeclaration = [{
|
||||
|
|
|
@ -1476,26 +1476,26 @@ inline ::llvm::hash_code hash_value(Attribute arg) {
|
|||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// NamedAttributeList
|
||||
// MutableDictionaryAttr
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// A NamedAttributeList is a mutable wrapper around a DictionaryAttr. It
|
||||
/// A MutableDictionaryAttr is a mutable wrapper around a DictionaryAttr. It
|
||||
/// provides additional interfaces for adding, removing, replacing attributes
|
||||
/// within a DictionaryAttr.
|
||||
///
|
||||
/// We assume there will be relatively few attributes on a given operation
|
||||
/// (maybe a dozen or so, but not hundreds or thousands) so we use linear
|
||||
/// searches for everything.
|
||||
class NamedAttributeList {
|
||||
class MutableDictionaryAttr {
|
||||
public:
|
||||
NamedAttributeList(DictionaryAttr attrs = nullptr)
|
||||
MutableDictionaryAttr(DictionaryAttr attrs = nullptr)
|
||||
: attrs((attrs && !attrs.empty()) ? attrs : nullptr) {}
|
||||
NamedAttributeList(ArrayRef<NamedAttribute> attributes);
|
||||
MutableDictionaryAttr(ArrayRef<NamedAttribute> attributes);
|
||||
|
||||
bool operator!=(const NamedAttributeList &other) const {
|
||||
bool operator!=(const MutableDictionaryAttr &other) const {
|
||||
return !(*this == other);
|
||||
}
|
||||
bool operator==(const NamedAttributeList &other) const {
|
||||
bool operator==(const MutableDictionaryAttr &other) const {
|
||||
return attrs == other.attrs;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,13 +47,13 @@ public:
|
|||
iterator_range<dialect_attr_iterator> attrs);
|
||||
static FuncOp create(Location location, StringRef name, FunctionType type,
|
||||
ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<NamedAttributeList> argAttrs);
|
||||
ArrayRef<MutableDictionaryAttr> argAttrs);
|
||||
|
||||
static void build(OpBuilder &builder, OperationState &result, StringRef name,
|
||||
FunctionType type, ArrayRef<NamedAttribute> attrs);
|
||||
static void build(OpBuilder &builder, OperationState &result, StringRef name,
|
||||
FunctionType type, ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<NamedAttributeList> argAttrs);
|
||||
ArrayRef<MutableDictionaryAttr> argAttrs);
|
||||
|
||||
/// Operation hooks.
|
||||
static ParseResult parse(OpAsmParser &parser, OperationState &result);
|
||||
|
|
|
@ -243,7 +243,7 @@ public:
|
|||
}
|
||||
|
||||
/// Return all argument attributes of this function.
|
||||
void getAllArgAttrs(SmallVectorImpl<NamedAttributeList> &result) {
|
||||
void getAllArgAttrs(SmallVectorImpl<MutableDictionaryAttr> &result) {
|
||||
for (unsigned i = 0, e = getNumArguments(); i != e; ++i)
|
||||
result.emplace_back(getArgAttrDict(i));
|
||||
}
|
||||
|
@ -270,8 +270,8 @@ public:
|
|||
|
||||
/// Set the attributes held by the argument at 'index'.
|
||||
void setArgAttrs(unsigned index, ArrayRef<NamedAttribute> attributes);
|
||||
void setArgAttrs(unsigned index, NamedAttributeList attributes);
|
||||
void setAllArgAttrs(ArrayRef<NamedAttributeList> attributes) {
|
||||
void setArgAttrs(unsigned index, MutableDictionaryAttr attributes);
|
||||
void setAllArgAttrs(ArrayRef<MutableDictionaryAttr> attributes) {
|
||||
assert(attributes.size() == getNumArguments());
|
||||
for (unsigned i = 0, e = attributes.size(); i != e; ++i)
|
||||
setArgAttrs(i, attributes[i]);
|
||||
|
@ -286,8 +286,8 @@ public:
|
|||
}
|
||||
|
||||
/// Remove the attribute 'name' from the argument at 'index'.
|
||||
NamedAttributeList::RemoveResult removeArgAttr(unsigned index,
|
||||
Identifier name);
|
||||
MutableDictionaryAttr::RemoveResult removeArgAttr(unsigned index,
|
||||
Identifier name);
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Result Attributes
|
||||
|
@ -306,7 +306,7 @@ public:
|
|||
}
|
||||
|
||||
/// Return all result attributes of this function.
|
||||
void getAllResultAttrs(SmallVectorImpl<NamedAttributeList> &result) {
|
||||
void getAllResultAttrs(SmallVectorImpl<MutableDictionaryAttr> &result) {
|
||||
for (unsigned i = 0, e = getNumResults(); i != e; ++i)
|
||||
result.emplace_back(getResultAttrDict(i));
|
||||
}
|
||||
|
@ -333,8 +333,8 @@ public:
|
|||
|
||||
/// Set the attributes held by the result at 'index'.
|
||||
void setResultAttrs(unsigned index, ArrayRef<NamedAttribute> attributes);
|
||||
void setResultAttrs(unsigned index, NamedAttributeList attributes);
|
||||
void setAllResultAttrs(ArrayRef<NamedAttributeList> attributes) {
|
||||
void setResultAttrs(unsigned index, MutableDictionaryAttr attributes);
|
||||
void setAllResultAttrs(ArrayRef<MutableDictionaryAttr> attributes) {
|
||||
assert(attributes.size() == getNumResults());
|
||||
for (unsigned i = 0, e = attributes.size(); i != e; ++i)
|
||||
setResultAttrs(i, attributes[i]);
|
||||
|
@ -350,8 +350,8 @@ public:
|
|||
}
|
||||
|
||||
/// Remove the attribute 'name' from the result at 'index'.
|
||||
NamedAttributeList::RemoveResult removeResultAttr(unsigned index,
|
||||
Identifier name);
|
||||
MutableDictionaryAttr::RemoveResult removeResultAttr(unsigned index,
|
||||
Identifier name);
|
||||
|
||||
protected:
|
||||
/// Returns the attribute entry name for the set of argument attributes at
|
||||
|
@ -514,7 +514,7 @@ void FunctionLike<ConcreteType>::setArgAttrs(
|
|||
|
||||
template <typename ConcreteType>
|
||||
void FunctionLike<ConcreteType>::setArgAttrs(unsigned index,
|
||||
NamedAttributeList attributes) {
|
||||
MutableDictionaryAttr attributes) {
|
||||
assert(index < getNumArguments() && "invalid argument number");
|
||||
SmallString<8> nameOut;
|
||||
if (auto newAttr = attributes.getDictionary())
|
||||
|
@ -529,25 +529,25 @@ template <typename ConcreteType>
|
|||
void FunctionLike<ConcreteType>::setArgAttr(unsigned index, Identifier name,
|
||||
Attribute value) {
|
||||
auto curAttr = getArgAttrDict(index);
|
||||
NamedAttributeList attrList(curAttr);
|
||||
attrList.set(name, value);
|
||||
MutableDictionaryAttr attrDict(curAttr);
|
||||
attrDict.set(name, value);
|
||||
|
||||
// If the attribute changed, then set the new arg attribute list.
|
||||
if (curAttr != attrList.getDictionary())
|
||||
setArgAttrs(index, attrList);
|
||||
if (curAttr != attrDict.getDictionary())
|
||||
setArgAttrs(index, attrDict);
|
||||
}
|
||||
|
||||
/// Remove the attribute 'name' from the argument at 'index'.
|
||||
template <typename ConcreteType>
|
||||
NamedAttributeList::RemoveResult
|
||||
MutableDictionaryAttr::RemoveResult
|
||||
FunctionLike<ConcreteType>::removeArgAttr(unsigned index, Identifier name) {
|
||||
// Build an attribute list and remove the attribute at 'name'.
|
||||
NamedAttributeList attrList(getArgAttrDict(index));
|
||||
auto result = attrList.remove(name);
|
||||
MutableDictionaryAttr attrDict(getArgAttrDict(index));
|
||||
auto result = attrDict.remove(name);
|
||||
|
||||
// If the attribute was removed, then update the argument dictionary.
|
||||
if (result == NamedAttributeList::RemoveResult::Removed)
|
||||
setArgAttrs(index, attrList);
|
||||
if (result == MutableDictionaryAttr::RemoveResult::Removed)
|
||||
setArgAttrs(index, attrDict);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -570,8 +570,8 @@ void FunctionLike<ConcreteType>::setResultAttrs(
|
|||
}
|
||||
|
||||
template <typename ConcreteType>
|
||||
void FunctionLike<ConcreteType>::setResultAttrs(unsigned index,
|
||||
NamedAttributeList attributes) {
|
||||
void FunctionLike<ConcreteType>::setResultAttrs(
|
||||
unsigned index, MutableDictionaryAttr attributes) {
|
||||
assert(index < getNumResults() && "invalid result number");
|
||||
SmallString<8> nameOut;
|
||||
if (auto newAttr = attributes.getDictionary())
|
||||
|
@ -587,25 +587,25 @@ template <typename ConcreteType>
|
|||
void FunctionLike<ConcreteType>::setResultAttr(unsigned index, Identifier name,
|
||||
Attribute value) {
|
||||
auto curAttr = getResultAttrDict(index);
|
||||
NamedAttributeList attrList(curAttr);
|
||||
attrList.set(name, value);
|
||||
MutableDictionaryAttr attrDict(curAttr);
|
||||
attrDict.set(name, value);
|
||||
|
||||
// If the attribute changed, then set the new arg attribute list.
|
||||
if (curAttr != attrList.getDictionary())
|
||||
setResultAttrs(index, attrList);
|
||||
if (curAttr != attrDict.getDictionary())
|
||||
setResultAttrs(index, attrDict);
|
||||
}
|
||||
|
||||
/// Remove the attribute 'name' from the result at 'index'.
|
||||
template <typename ConcreteType>
|
||||
NamedAttributeList::RemoveResult
|
||||
MutableDictionaryAttr::RemoveResult
|
||||
FunctionLike<ConcreteType>::removeResultAttr(unsigned index, Identifier name) {
|
||||
// Build an attribute list and remove the attribute at 'name'.
|
||||
NamedAttributeList attrList(getResultAttrDict(index));
|
||||
auto result = attrList.remove(name);
|
||||
MutableDictionaryAttr attrDict(getResultAttrDict(index));
|
||||
auto result = attrDict.remove(name);
|
||||
|
||||
// If the attribute was removed, then update the result dictionary.
|
||||
if (result == NamedAttributeList::RemoveResult::Removed)
|
||||
setResultAttrs(index, attrList);
|
||||
if (result == MutableDictionaryAttr::RemoveResult::Removed)
|
||||
setResultAttrs(index, attrDict);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ public:
|
|||
void setAttrs(ArrayRef<NamedAttribute> attributes) {
|
||||
state->setAttrs(attributes);
|
||||
}
|
||||
void setAttrs(NamedAttributeList newAttrs) { state->setAttrs(newAttrs); }
|
||||
void setAttrs(MutableDictionaryAttr newAttrs) { state->setAttrs(newAttrs); }
|
||||
|
||||
/// Set the dialect attributes for this operation, and preserve all dependent.
|
||||
template <typename DialectAttrs> void setDialectAttrs(DialectAttrs &&attrs) {
|
||||
|
@ -187,10 +187,10 @@ public:
|
|||
|
||||
/// Remove the attribute with the specified name if it exists. The return
|
||||
/// value indicates whether the attribute was present or not.
|
||||
NamedAttributeList::RemoveResult removeAttr(Identifier name) {
|
||||
MutableDictionaryAttr::RemoveResult removeAttr(Identifier name) {
|
||||
return state->removeAttr(name);
|
||||
}
|
||||
NamedAttributeList::RemoveResult removeAttr(StringRef name) {
|
||||
MutableDictionaryAttr::RemoveResult removeAttr(StringRef name) {
|
||||
return state->removeAttr(Identifier::get(name, getContext()));
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,11 @@ public:
|
|||
ArrayRef<NamedAttribute> attributes,
|
||||
ArrayRef<Block *> successors, unsigned numRegions);
|
||||
|
||||
/// Overload of create that takes an existing NamedAttributeList to avoid
|
||||
/// Overload of create that takes an existing MutableDictionaryAttr to avoid
|
||||
/// unnecessarily uniquing a list of attributes.
|
||||
static Operation *create(Location location, OperationName name,
|
||||
ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
|
||||
NamedAttributeList attributes,
|
||||
MutableDictionaryAttr attributes,
|
||||
ArrayRef<Block *> successors, unsigned numRegions);
|
||||
|
||||
/// Create a new Operation from the fields stored in `state`.
|
||||
|
@ -49,7 +49,7 @@ public:
|
|||
/// Create a new Operation with the specific fields.
|
||||
static Operation *create(Location location, OperationName name,
|
||||
ArrayRef<Type> resultTypes, ArrayRef<Value> operands,
|
||||
NamedAttributeList attributes,
|
||||
MutableDictionaryAttr attributes,
|
||||
ArrayRef<Block *> successors = {},
|
||||
RegionRange regions = {});
|
||||
|
||||
|
@ -280,13 +280,13 @@ public:
|
|||
/// Return all of the attributes on this operation.
|
||||
ArrayRef<NamedAttribute> getAttrs() { return attrs.getAttrs(); }
|
||||
|
||||
/// Return the internal attribute list on this operation.
|
||||
NamedAttributeList &getAttrList() { return attrs; }
|
||||
/// Return mutable container of all the attributes on this operation.
|
||||
MutableDictionaryAttr &getMutableAttrDict() { return attrs; }
|
||||
|
||||
/// Set the attribute list on this operation.
|
||||
/// Using a NamedAttributeList is more efficient as it does not require new
|
||||
/// Set the attribute dictionary on this operation.
|
||||
/// Using a MutableDictionaryAttr is more efficient as it does not require new
|
||||
/// uniquing in the MLIRContext.
|
||||
void setAttrs(NamedAttributeList newAttrs) { attrs = newAttrs; }
|
||||
void setAttrs(MutableDictionaryAttr newAttrs) { attrs = newAttrs; }
|
||||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute getAttr(Identifier name) { return attrs.get(name); }
|
||||
|
@ -309,7 +309,7 @@ public:
|
|||
|
||||
/// Remove the attribute with the specified name if it exists. The return
|
||||
/// value indicates whether the attribute was present or not.
|
||||
NamedAttributeList::RemoveResult removeAttr(Identifier name) {
|
||||
MutableDictionaryAttr::RemoveResult removeAttr(Identifier name) {
|
||||
return attrs.remove(name);
|
||||
}
|
||||
|
||||
|
@ -596,7 +596,7 @@ private:
|
|||
private:
|
||||
Operation(Location location, OperationName name, ArrayRef<Type> resultTypes,
|
||||
unsigned numSuccessors, unsigned numRegions,
|
||||
const NamedAttributeList &attributes, bool hasOperandStorage);
|
||||
const MutableDictionaryAttr &attributes, bool hasOperandStorage);
|
||||
|
||||
// Operations are deleted through the destroy() member because they are
|
||||
// allocated with malloc.
|
||||
|
@ -658,7 +658,7 @@ private:
|
|||
OperationName name;
|
||||
|
||||
/// This holds general named attributes for the operation.
|
||||
NamedAttributeList attrs;
|
||||
MutableDictionaryAttr attrs;
|
||||
|
||||
// allow ilist_traits access to 'block' field.
|
||||
friend struct llvm::ilist_traits<Operation>;
|
||||
|
|
|
@ -179,7 +179,7 @@ void CallGraph::print(raw_ostream &os) const {
|
|||
auto *parentOp = callableRegion->getParentOp();
|
||||
os << "'" << callableRegion->getParentOp()->getName() << "' - Region #"
|
||||
<< callableRegion->getRegionNumber();
|
||||
if (auto attrs = parentOp->getAttrList().getDictionary())
|
||||
if (auto attrs = parentOp->getMutableAttrDict().getDictionary())
|
||||
os << " : " << attrs;
|
||||
};
|
||||
|
||||
|
|
|
@ -1173,7 +1173,7 @@ Block *LLVMFuncOp::addEntryBlock() {
|
|||
void LLVMFuncOp::build(OpBuilder &builder, OperationState &result,
|
||||
StringRef name, LLVMType type, LLVM::Linkage linkage,
|
||||
ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<NamedAttributeList> argAttrs) {
|
||||
ArrayRef<MutableDictionaryAttr> argAttrs) {
|
||||
result.addRegion();
|
||||
result.addAttribute(SymbolTable::getSymbolAttrName(),
|
||||
builder.getStringAttr(name));
|
||||
|
|
|
@ -353,8 +353,8 @@ private:
|
|||
}
|
||||
|
||||
bool isSameAttrList(spirv::StoreOp lhs, spirv::StoreOp rhs) const {
|
||||
return lhs.getOperation()->getAttrList().getDictionary() ==
|
||||
rhs.getOperation()->getAttrList().getDictionary();
|
||||
return lhs.getOperation()->getMutableAttrDict().getDictionary() ==
|
||||
rhs.getOperation()->getMutableAttrDict().getDictionary();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -445,7 +445,7 @@ private:
|
|||
DenseMap<uint32_t, StringRef> nameMap;
|
||||
|
||||
// Result <id> to decorations mapping.
|
||||
DenseMap<uint32_t, NamedAttributeList> decorations;
|
||||
DenseMap<uint32_t, MutableDictionaryAttr> decorations;
|
||||
|
||||
// Result <id> to type decorations.
|
||||
DenseMap<uint32_t, uint32_t> typeDecorations;
|
||||
|
|
|
@ -1160,19 +1160,20 @@ std::vector<ptrdiff_t> SparseElementsAttr::getFlattenedSparseIndices() const {
|
|||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// NamedAttributeList
|
||||
// MutableDictionaryAttr
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
NamedAttributeList::NamedAttributeList(ArrayRef<NamedAttribute> attributes) {
|
||||
MutableDictionaryAttr::MutableDictionaryAttr(
|
||||
ArrayRef<NamedAttribute> attributes) {
|
||||
setAttrs(attributes);
|
||||
}
|
||||
|
||||
ArrayRef<NamedAttribute> NamedAttributeList::getAttrs() const {
|
||||
ArrayRef<NamedAttribute> MutableDictionaryAttr::getAttrs() const {
|
||||
return attrs ? attrs.getValue() : llvm::None;
|
||||
}
|
||||
|
||||
/// Replace the held attributes with ones provided in 'newAttrs'.
|
||||
void NamedAttributeList::setAttrs(ArrayRef<NamedAttribute> attributes) {
|
||||
void MutableDictionaryAttr::setAttrs(ArrayRef<NamedAttribute> attributes) {
|
||||
// Don't create an attribute list if there are no attributes.
|
||||
if (attributes.empty())
|
||||
attrs = nullptr;
|
||||
|
@ -1181,18 +1182,18 @@ void NamedAttributeList::setAttrs(ArrayRef<NamedAttribute> attributes) {
|
|||
}
|
||||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute NamedAttributeList::get(StringRef name) const {
|
||||
Attribute MutableDictionaryAttr::get(StringRef name) const {
|
||||
return attrs ? attrs.get(name) : nullptr;
|
||||
}
|
||||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute NamedAttributeList::get(Identifier name) const {
|
||||
Attribute MutableDictionaryAttr::get(Identifier name) const {
|
||||
return attrs ? attrs.get(name) : nullptr;
|
||||
}
|
||||
|
||||
/// If the an attribute exists with the specified name, change it to the new
|
||||
/// value. Otherwise, add a new attribute with the specified name/value.
|
||||
void NamedAttributeList::set(Identifier name, Attribute value) {
|
||||
void MutableDictionaryAttr::set(Identifier name, Attribute value) {
|
||||
assert(value && "attributes may never be null");
|
||||
|
||||
// Look for an existing value for the given name, and set it in-place.
|
||||
|
@ -1222,7 +1223,7 @@ void NamedAttributeList::set(Identifier name, Attribute value) {
|
|||
|
||||
/// Remove the attribute with the specified name if it exists. The return
|
||||
/// value indicates whether the attribute was present or not.
|
||||
auto NamedAttributeList::remove(Identifier name) -> RemoveResult {
|
||||
auto MutableDictionaryAttr::remove(Identifier name) -> RemoveResult {
|
||||
auto origAttrs = getAttrs();
|
||||
for (unsigned i = 0, e = origAttrs.size(); i != e; ++i) {
|
||||
if (origAttrs[i].first == name) {
|
||||
|
|
|
@ -35,7 +35,7 @@ FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
|
|||
}
|
||||
FuncOp FuncOp::create(Location location, StringRef name, FunctionType type,
|
||||
ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<NamedAttributeList> argAttrs) {
|
||||
ArrayRef<MutableDictionaryAttr> argAttrs) {
|
||||
FuncOp func = create(location, name, type, attrs);
|
||||
func.setAllArgAttrs(argAttrs);
|
||||
return func;
|
||||
|
@ -52,7 +52,7 @@ void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
|
|||
|
||||
void FuncOp::build(OpBuilder &builder, OperationState &result, StringRef name,
|
||||
FunctionType type, ArrayRef<NamedAttribute> attrs,
|
||||
ArrayRef<NamedAttributeList> argAttrs) {
|
||||
ArrayRef<MutableDictionaryAttr> argAttrs) {
|
||||
build(builder, result, name, type, attrs);
|
||||
assert(type.getNumInputs() == argAttrs.size());
|
||||
SmallString<8> argAttrName;
|
||||
|
@ -115,7 +115,7 @@ void FuncOp::eraseArguments(ArrayRef<unsigned> argIndices) {
|
|||
|
||||
// Update the function type and arg attrs.
|
||||
SmallVector<Type, 4> newInputTypes;
|
||||
SmallVector<NamedAttributeList, 4> newArgAttrs;
|
||||
SmallVector<MutableDictionaryAttr, 4> newArgAttrs;
|
||||
for (int i = 0; i < originalNumArgs; i++) {
|
||||
if (shouldEraseArg(i))
|
||||
continue;
|
||||
|
|
|
@ -83,7 +83,7 @@ LogicalResult ModuleOp::verify() {
|
|||
|
||||
// Check that none of the attributes are non-dialect attributes, except for
|
||||
// the symbol related attributes.
|
||||
for (auto attr : getOperation()->getAttrList().getAttrs()) {
|
||||
for (auto attr : getOperation()->getMutableAttrDict().getAttrs()) {
|
||||
if (!attr.first.strref().contains('.') &&
|
||||
!llvm::is_contained(
|
||||
ArrayRef<StringRef>{mlir::SymbolTable::getSymbolAttrName(),
|
||||
|
|
|
@ -65,21 +65,21 @@ Operation *Operation::create(Location location, OperationName name,
|
|||
ArrayRef<Block *> successors,
|
||||
unsigned numRegions) {
|
||||
return create(location, name, resultTypes, operands,
|
||||
NamedAttributeList(attributes), successors, numRegions);
|
||||
MutableDictionaryAttr(attributes), successors, numRegions);
|
||||
}
|
||||
|
||||
/// Create a new Operation from operation state.
|
||||
Operation *Operation::create(const OperationState &state) {
|
||||
return Operation::create(state.location, state.name, state.types,
|
||||
state.operands, NamedAttributeList(state.attributes),
|
||||
state.successors, state.regions);
|
||||
return Operation::create(
|
||||
state.location, state.name, state.types, state.operands,
|
||||
MutableDictionaryAttr(state.attributes), state.successors, state.regions);
|
||||
}
|
||||
|
||||
/// Create a new Operation with the specific fields.
|
||||
Operation *Operation::create(Location location, OperationName name,
|
||||
ArrayRef<Type> resultTypes,
|
||||
ArrayRef<Value> operands,
|
||||
NamedAttributeList attributes,
|
||||
MutableDictionaryAttr attributes,
|
||||
ArrayRef<Block *> successors,
|
||||
RegionRange regions) {
|
||||
unsigned numRegions = regions.size();
|
||||
|
@ -91,12 +91,12 @@ Operation *Operation::create(Location location, OperationName name,
|
|||
return op;
|
||||
}
|
||||
|
||||
/// Overload of create that takes an existing NamedAttributeList to avoid
|
||||
/// Overload of create that takes an existing MutableDictionaryAttr to avoid
|
||||
/// unnecessarily uniquing a list of attributes.
|
||||
Operation *Operation::create(Location location, OperationName name,
|
||||
ArrayRef<Type> resultTypes,
|
||||
ArrayRef<Value> operands,
|
||||
NamedAttributeList attributes,
|
||||
MutableDictionaryAttr attributes,
|
||||
ArrayRef<Block *> successors,
|
||||
unsigned numRegions) {
|
||||
// We only need to allocate additional memory for a subset of results.
|
||||
|
@ -156,7 +156,8 @@ Operation *Operation::create(Location location, OperationName name,
|
|||
|
||||
Operation::Operation(Location location, OperationName name,
|
||||
ArrayRef<Type> resultTypes, unsigned numSuccessors,
|
||||
unsigned numRegions, const NamedAttributeList &attributes,
|
||||
unsigned numRegions,
|
||||
const MutableDictionaryAttr &attributes,
|
||||
bool hasOperandStorage)
|
||||
: location(location), numSuccs(numSuccessors), numRegions(numRegions),
|
||||
hasOperandStorage(hasOperandStorage), hasSingleResult(false), name(name),
|
||||
|
|
|
@ -385,7 +385,7 @@ static WalkResult walkSymbolRefs(
|
|||
Operation *op,
|
||||
function_ref<WalkResult(SymbolTable::SymbolUse, ArrayRef<int>)> callback) {
|
||||
// Check to see if the operation has any attributes.
|
||||
DictionaryAttr attrDict = op->getAttrList().getDictionary();
|
||||
DictionaryAttr attrDict = op->getMutableAttrDict().getDictionary();
|
||||
if (!attrDict)
|
||||
return WalkResult::advance();
|
||||
|
||||
|
@ -803,7 +803,7 @@ replaceAllSymbolUsesImpl(SymbolT symbol, StringRef newSymbol, IRUnitT *limit) {
|
|||
// Generate a new attribute dictionary for the current operation by replacing
|
||||
// references to the old symbol.
|
||||
auto generateNewAttrDict = [&] {
|
||||
auto oldDict = curOp->getAttrList().getDictionary();
|
||||
auto oldDict = curOp->getMutableAttrDict().getDictionary();
|
||||
auto newDict = rebuildAttrAfterRAUW(oldDict, accessChains, /*depth=*/0);
|
||||
return newDict.cast<DictionaryAttr>();
|
||||
};
|
||||
|
|
|
@ -5030,7 +5030,7 @@ ParseResult ModuleParser::parseModule(ModuleOp module) {
|
|||
if (nested && std::next(operations.begin(), 2) == operations.end()) {
|
||||
// Merge the data of the nested module operation into 'module'.
|
||||
module.setLoc(nested.getLoc());
|
||||
module.setAttrs(nested.getOperation()->getAttrList());
|
||||
module.setAttrs(nested.getOperation()->getMutableAttrDict());
|
||||
bodyBlocks.splice(bodyBlocks.end(), nested.getBodyRegion().getBlocks());
|
||||
|
||||
// Erase the original module body.
|
||||
|
|
|
@ -33,8 +33,9 @@ public:
|
|||
// - Operation pointer
|
||||
addDataToHash(hasher, op);
|
||||
// - Attributes
|
||||
addDataToHash(hasher,
|
||||
op->getAttrList().getDictionary().getAsOpaquePointer());
|
||||
addDataToHash(
|
||||
hasher,
|
||||
op->getMutableAttrDict().getDictionary().getAsOpaquePointer());
|
||||
// - Blocks in Regions
|
||||
for (Region ®ion : op->getRegions()) {
|
||||
for (Block &block : region) {
|
||||
|
|
|
@ -36,7 +36,8 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
|
|||
// - Result Types
|
||||
// - Operands
|
||||
return llvm::hash_combine(
|
||||
op->getName(), op->getAttrList().getDictionary(), op->getResultTypes(),
|
||||
op->getName(), op->getMutableAttrDict().getDictionary(),
|
||||
op->getResultTypes(),
|
||||
llvm::hash_combine_range(op->operand_begin(), op->operand_end()));
|
||||
}
|
||||
static bool isEqual(const Operation *lhsC, const Operation *rhsC) {
|
||||
|
@ -56,7 +57,7 @@ struct SimpleOperationInfo : public llvm::DenseMapInfo<Operation *> {
|
|||
lhs->getNumResults() != rhs->getNumResults())
|
||||
return false;
|
||||
// Compare attributes.
|
||||
if (lhs->getAttrList() != rhs->getAttrList())
|
||||
if (lhs->getMutableAttrDict() != rhs->getMutableAttrDict())
|
||||
return false;
|
||||
// Compare operands.
|
||||
if (!std::equal(lhs->operand_begin(), lhs->operand_end(),
|
||||
|
|
|
@ -468,7 +468,7 @@ class OperationTransactionState {
|
|||
public:
|
||||
OperationTransactionState() = default;
|
||||
OperationTransactionState(Operation *op)
|
||||
: op(op), loc(op->getLoc()), attrs(op->getAttrList()),
|
||||
: op(op), loc(op->getLoc()), attrs(op->getMutableAttrDict()),
|
||||
operands(op->operand_begin(), op->operand_end()),
|
||||
successors(op->successor_begin(), op->successor_end()) {}
|
||||
|
||||
|
@ -488,7 +488,7 @@ public:
|
|||
private:
|
||||
Operation *op;
|
||||
LocationAttr loc;
|
||||
NamedAttributeList attrs;
|
||||
MutableDictionaryAttr attrs;
|
||||
SmallVector<Value, 8> operands;
|
||||
SmallVector<Block *, 2> successors;
|
||||
};
|
||||
|
|
|
@ -514,7 +514,7 @@ void SCCPSolver::visitOperation(Operation *op) {
|
|||
// in-place. The constant passed in may not correspond to the real runtime
|
||||
// value, so in-place updates are not allowed.
|
||||
SmallVector<Value, 8> originalOperands(op->getOperands());
|
||||
NamedAttributeList originalAttrs = op->getAttrList();
|
||||
MutableDictionaryAttr originalAttrs = op->getMutableAttrDict();
|
||||
|
||||
// Simulate the result of folding this operation to a constant. If folding
|
||||
// fails or was an in-place fold, mark the results as overdefined.
|
||||
|
|
Loading…
Reference in New Issue