[mlir][NFC] Replace references to Identifier with StringAttr
This is part of the replacement of Identifier with StringAttr. Differential Revision: https://reviews.llvm.org/D113953
This commit is contained in:
parent
e7568b68da
commit
195730a650
|
@ -102,7 +102,7 @@ conceptually a collection of key-value pairs called data layout specification
|
|||
_entries_. Data layout specification attributes implement the
|
||||
`DataLayoutSpecInterface`, described below. Each entry is itself an attribute
|
||||
that implements the `DataLayoutEntryInterface`. Entries have a key, either a
|
||||
`Type` or an `Identifier`, and a value. Keys are used to associate entries with
|
||||
`Type` or a `StringAttr`, and a value. Keys are used to associate entries with
|
||||
specific types or dialects: when handling a data layout properties request, a
|
||||
type or a dialect can only see the specification entries relevant to them and
|
||||
must go through the supplied `DataLayout` object for any recursive query. This
|
||||
|
|
|
@ -327,7 +327,7 @@ operations by overriding the `getRegisteredInterfaceForOp` method :
|
|||
|
||||
```c++
|
||||
void *TestDialect::getRegisteredInterfaceForOp(TypeID typeID,
|
||||
Identifier opName) {
|
||||
StringAttr opName) {
|
||||
if (typeID == TypeID::get<ExampleOpInterface>()) {
|
||||
if (isSupported(opName))
|
||||
return fallbackExampleOpInterface;
|
||||
|
|
|
@ -137,7 +137,7 @@ struct MetadataLatticeValue {
|
|||
|
||||
/// Our value represents the combined metadata, which is originally a
|
||||
/// DictionaryAttr, so we use a map.
|
||||
DenseMap<Identifier, Attribute> metadata;
|
||||
DenseMap<StringAttr, Attribute> metadata;
|
||||
};
|
||||
```
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ private:
|
|||
|
||||
/// Helper conversion for a Toy AST location to an MLIR location.
|
||||
mlir::Location loc(Location loc) {
|
||||
return mlir::FileLineColLoc::get(builder.getIdentifier(*loc.file), loc.line,
|
||||
return mlir::FileLineColLoc::get(builder.getStringAttr(*loc.file), loc.line,
|
||||
loc.col);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "mlir/CAPI/Wrap.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ def AffineMapAccessInterface : OpInterface<"AffineMapAccessInterface"> {
|
|||
ConcreteOp op = cast<ConcreteOp>(this->getOperation());
|
||||
assert(memref == op.getMemRef() &&
|
||||
"Expected memref argument to match memref operand");
|
||||
return {Identifier::get(op.getMapAttrName(), op.getContext()),
|
||||
return {StringAttr::get(op.getContext(), op.getMapAttrName()),
|
||||
op.getAffineMapAttr()};
|
||||
}]
|
||||
>,
|
||||
|
|
|
@ -188,14 +188,14 @@ public:
|
|||
/// Returns the AffineMapAttr associated with 'memref'.
|
||||
NamedAttribute getAffineMapAttrForMemRef(Value memref) {
|
||||
if (memref == getSrcMemRef())
|
||||
return {Identifier::get(getSrcMapAttrName(), getContext()),
|
||||
return {StringAttr::get(getContext(), getSrcMapAttrName()),
|
||||
getSrcMapAttr()};
|
||||
if (memref == getDstMemRef())
|
||||
return {Identifier::get(getDstMapAttrName(), getContext()),
|
||||
return {StringAttr::get(getContext(), getDstMapAttrName()),
|
||||
getDstMapAttr()};
|
||||
assert(memref == getTagMemRef() &&
|
||||
"DmaStartOp expected source, destination or tag memref");
|
||||
return {Identifier::get(getTagMapAttrName(), getContext()),
|
||||
return {StringAttr::get(getContext(), getTagMapAttrName()),
|
||||
getTagMapAttr()};
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ public:
|
|||
/// associated with 'memref'.
|
||||
NamedAttribute getAffineMapAttrForMemRef(Value memref) {
|
||||
assert(memref == getTagMemRef());
|
||||
return {Identifier::get(getTagMapAttrName(), getContext()),
|
||||
return {StringAttr::get(getContext(), getTagMapAttrName()),
|
||||
getTagMapAttr()};
|
||||
}
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ def AffineForOp : Affine_Op<"for",
|
|||
void setStep(int64_t step) {
|
||||
assert(step > 0 && "step has to be a positive integer constant");
|
||||
auto *context = getLowerBoundMap().getContext();
|
||||
(*this)->setAttr(Identifier::get(getStepAttrName(), context),
|
||||
(*this)->setAttr(StringAttr::get(context, getStepAttrName()),
|
||||
IntegerAttr::get(IndexType::get(context), step));
|
||||
}
|
||||
|
||||
|
@ -815,7 +815,7 @@ def AffinePrefetchOp : Affine_Op<"prefetch",
|
|||
NamedAttribute getAffineMapAttrForMemRef(Value mref) {
|
||||
assert(mref == memref() &&
|
||||
"Expected mref argument to match memref operand");
|
||||
return {Identifier::get(getMapAttrName(), getContext()),
|
||||
return {StringAttr::get(getContext(), getMapAttrName()),
|
||||
getAffineMapAttr()};
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
constexpr const static llvm::StringLiteral kAttrKeyword = "dl_entry";
|
||||
|
||||
/// Returns the entry with the given key and value.
|
||||
static DataLayoutEntryAttr get(Identifier key, Attribute value);
|
||||
static DataLayoutEntryAttr get(StringAttr key, Attribute value);
|
||||
static DataLayoutEntryAttr get(Type key, Attribute value);
|
||||
|
||||
/// Returns the key of this entry.
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "mlir/Dialect/Utils/StaticValueUtils.h"
|
||||
#include "mlir/Dialect/Vector/VectorTransforms.h"
|
||||
#include "mlir/Dialect/X86Vector/Transforms.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/PatternMatch.h"
|
||||
#include "mlir/Transforms/Bufferize.h"
|
||||
#include "llvm/ADT/SmallBitVector.h"
|
||||
|
@ -426,12 +425,12 @@ struct LinalgTransformationFilter {
|
|||
using FilterFunction = std::function<LogicalResult(Operation *)>;
|
||||
|
||||
explicit LinalgTransformationFilter(
|
||||
ArrayRef<Identifier> matchDisjunction = {},
|
||||
Optional<Identifier> replacement = None);
|
||||
ArrayRef<StringAttr> matchDisjunction = {},
|
||||
Optional<StringAttr> replacement = None);
|
||||
|
||||
explicit LinalgTransformationFilter(
|
||||
FilterFunction f, ArrayRef<Identifier> matchDisjunction = {},
|
||||
Optional<Identifier> replacement = None);
|
||||
FilterFunction f, ArrayRef<StringAttr> matchDisjunction = {},
|
||||
Optional<StringAttr> replacement = None);
|
||||
|
||||
LinalgTransformationFilter(LinalgTransformationFilter &&) = default;
|
||||
LinalgTransformationFilter(const LinalgTransformationFilter &) = default;
|
||||
|
@ -456,8 +455,8 @@ struct LinalgTransformationFilter {
|
|||
|
||||
private:
|
||||
SmallVector<FilterFunction> filters;
|
||||
SmallVector<Identifier> matchDisjunction;
|
||||
Optional<Identifier> replacement;
|
||||
SmallVector<StringAttr> matchDisjunction;
|
||||
Optional<StringAttr> replacement;
|
||||
/// When set to true, if the attribute is not set, it will be treated as
|
||||
/// a match. Default is false.
|
||||
bool matchByDefault;
|
||||
|
|
|
@ -136,10 +136,10 @@ inline ::llvm::hash_code hash_value(Attribute arg) {
|
|||
// NamedAttribute
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
/// NamedAttribute is combination of a name, represented by an Identifier, and a
|
||||
/// NamedAttribute is combination of a name, represented by a StringAttr, and a
|
||||
/// value, represented by an Attribute. The attribute pointer should always be
|
||||
/// non-null.
|
||||
using NamedAttribute = std::pair<Identifier, Attribute>;
|
||||
using NamedAttribute = std::pair<StringAttr, Attribute>;
|
||||
|
||||
bool operator<(const NamedAttribute &lhs, const NamedAttribute &rhs);
|
||||
bool operator<(const NamedAttribute &lhs, StringRef rhs);
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
|
||||
MLIRContext *getContext() const { return context; }
|
||||
|
||||
Identifier getIdentifier(const Twine &str);
|
||||
StringAttr getIdentifier(const Twine &str);
|
||||
|
||||
// Locations.
|
||||
Location getUnknownLoc();
|
||||
|
|
|
@ -379,15 +379,15 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary", [
|
|||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute get(StringRef name) const;
|
||||
Attribute get(Identifier name) const;
|
||||
Attribute get(StringAttr name) const;
|
||||
|
||||
/// Return the specified named attribute if present, None otherwise.
|
||||
Optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
Optional<NamedAttribute> getNamed(Identifier name) const;
|
||||
Optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
|
||||
/// Return whether the specified attribute is present.
|
||||
bool contains(StringRef name) const;
|
||||
bool contains(Identifier name) const;
|
||||
bool contains(StringAttr name) const;
|
||||
|
||||
/// Support range iteration.
|
||||
using iterator = llvm::ArrayRef<NamedAttribute>::iterator;
|
||||
|
@ -641,11 +641,11 @@ def Builtin_OpaqueAttr : Builtin_Attr<"Opaque"> {
|
|||
#dialect<"opaque attribute data">
|
||||
```
|
||||
}];
|
||||
let parameters = (ins "Identifier":$dialectNamespace,
|
||||
let parameters = (ins "StringAttr":$dialectNamespace,
|
||||
StringRefParameter<"">:$attrData,
|
||||
AttributeSelfTypeParameter<"">:$type);
|
||||
let builders = [
|
||||
AttrBuilderWithInferredContext<(ins "Identifier":$dialect,
|
||||
AttrBuilderWithInferredContext<(ins "StringAttr":$dialect,
|
||||
"StringRef":$attrData,
|
||||
"Type":$type), [{
|
||||
return $_get(dialect.getContext(), dialect, attrData, type);
|
||||
|
@ -688,11 +688,11 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr<
|
|||
|
||||
// TODO: Provide a way to avoid copying content of large opaque
|
||||
// tensors This will likely require a new reference attribute kind.
|
||||
let parameters = (ins "Identifier":$dialect,
|
||||
let parameters = (ins "StringAttr":$dialect,
|
||||
StringRefParameter<"">:$value,
|
||||
AttributeSelfTypeParameter<"", "ShapedType">:$type);
|
||||
let builders = [
|
||||
AttrBuilderWithInferredContext<(ins "Identifier":$dialect,
|
||||
AttrBuilderWithInferredContext<(ins "StringAttr":$dialect,
|
||||
"ShapedType":$type,
|
||||
"StringRef":$value), [{
|
||||
return $_get(dialect.getContext(), dialect, value, type);
|
||||
|
@ -701,7 +701,7 @@ def Builtin_OpaqueElementsAttr : Builtin_Attr<
|
|||
"ShapedType":$type,
|
||||
"StringRef":$value), [{
|
||||
MLIRContext *ctxt = dialect->getContext();
|
||||
Identifier dialectName = Identifier::get(dialect->getNamespace(), ctxt);
|
||||
StringAttr dialectName = StringAttr::get(ctxt, dialect->getNamespace());
|
||||
return $_get(ctxt, dialectName, value, type);
|
||||
}]>
|
||||
];
|
||||
|
|
|
@ -81,10 +81,10 @@ def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> {
|
|||
loc("mysource.cc":10:8)
|
||||
```
|
||||
}];
|
||||
let parameters = (ins "Identifier":$filename, "unsigned":$line,
|
||||
let parameters = (ins "StringAttr":$filename, "unsigned":$line,
|
||||
"unsigned":$column);
|
||||
let builders = [
|
||||
AttrBuilderWithInferredContext<(ins "Identifier":$filename,
|
||||
AttrBuilderWithInferredContext<(ins "StringAttr":$filename,
|
||||
"unsigned":$line,
|
||||
"unsigned":$column), [{
|
||||
return $_get(filename.getContext(), filename, line, column);
|
||||
|
@ -92,7 +92,7 @@ def FileLineColLoc : Builtin_LocationAttr<"FileLineColLoc"> {
|
|||
AttrBuilder<(ins "StringRef":$filename, "unsigned":$line,
|
||||
"unsigned":$column), [{
|
||||
return $_get($_ctxt,
|
||||
Identifier::get(filename.empty() ? "-" : filename, $_ctxt),
|
||||
StringAttr::get($_ctxt, filename.empty() ? "-" : filename),
|
||||
line, column);
|
||||
}]>
|
||||
];
|
||||
|
@ -161,13 +161,13 @@ def NameLoc : Builtin_LocationAttr<"NameLoc"> {
|
|||
loc("CSE"("mysource.cc":10:8))
|
||||
```
|
||||
}];
|
||||
let parameters = (ins "Identifier":$name, "Location":$childLoc);
|
||||
let parameters = (ins "StringAttr":$name, "Location":$childLoc);
|
||||
let builders = [
|
||||
AttrBuilderWithInferredContext<(ins "Identifier":$name,
|
||||
AttrBuilderWithInferredContext<(ins "StringAttr":$name,
|
||||
"Location":$childLoc), [{
|
||||
return $_get(name.getContext(), name, childLoc);
|
||||
}]>,
|
||||
AttrBuilderWithInferredContext<(ins "Identifier":$name), [{
|
||||
AttrBuilderWithInferredContext<(ins "StringAttr":$name), [{
|
||||
return $_get(name.getContext(), name,
|
||||
UnknownLoc::get(name.getContext()));
|
||||
}]>
|
||||
|
|
|
@ -25,9 +25,6 @@ class IntegerType;
|
|||
class StringAttr;
|
||||
class TypeRange;
|
||||
|
||||
// TODO: Remove this when all usages have been replaced with StringAttr.
|
||||
using Identifier = StringAttr;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// FloatType
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -600,13 +600,13 @@ def Builtin_Opaque : Builtin_Type<"Opaque"> {
|
|||
```
|
||||
}];
|
||||
let parameters = (ins
|
||||
"Identifier":$dialectNamespace,
|
||||
"StringAttr":$dialectNamespace,
|
||||
StringRefParameter<"">:$typeData
|
||||
);
|
||||
|
||||
let builders = [
|
||||
TypeBuilderWithInferredContext<(ins
|
||||
"Identifier":$dialectNamespace, CArg<"StringRef", "{}">:$typeData
|
||||
"StringAttr":$dialectNamespace, CArg<"StringRef", "{}">:$typeData
|
||||
), [{
|
||||
return $_get(dialectNamespace.getContext(), dialectNamespace, typeData);
|
||||
}]>
|
||||
|
|
|
@ -396,7 +396,7 @@ public:
|
|||
|
||||
/// Return the specified attribute, if present, for the argument at 'index',
|
||||
/// null otherwise.
|
||||
Attribute getArgAttr(unsigned index, Identifier name) {
|
||||
Attribute getArgAttr(unsigned index, StringAttr name) {
|
||||
auto argDict = getArgAttrDict(index);
|
||||
return argDict ? argDict.get(name) : nullptr;
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ public:
|
|||
}
|
||||
|
||||
template <typename AttrClass>
|
||||
AttrClass getArgAttrOfType(unsigned index, Identifier name) {
|
||||
AttrClass getArgAttrOfType(unsigned index, StringAttr name) {
|
||||
return getArgAttr(index, name).template dyn_cast_or_null<AttrClass>();
|
||||
}
|
||||
template <typename AttrClass>
|
||||
|
@ -436,19 +436,19 @@ public:
|
|||
|
||||
/// 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 setArgAttr(unsigned index, Identifier name, Attribute value);
|
||||
void setArgAttr(unsigned index, StringAttr name, Attribute value);
|
||||
void setArgAttr(unsigned index, StringRef name, Attribute value) {
|
||||
setArgAttr(index, Identifier::get(name, this->getOperation()->getContext()),
|
||||
setArgAttr(index, StringAttr::get(this->getOperation()->getContext(), name),
|
||||
value);
|
||||
}
|
||||
|
||||
/// Remove the attribute 'name' from the argument at 'index'. Return the
|
||||
/// attribute that was erased, or nullptr if there was no attribute with such
|
||||
/// name.
|
||||
Attribute removeArgAttr(unsigned index, Identifier name);
|
||||
Attribute removeArgAttr(unsigned index, StringAttr name);
|
||||
Attribute removeArgAttr(unsigned index, StringRef name) {
|
||||
return removeArgAttr(
|
||||
index, Identifier::get(name, this->getOperation()->getContext()));
|
||||
index, StringAttr::get(this->getOperation()->getContext(), name));
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -485,7 +485,7 @@ public:
|
|||
|
||||
/// Return the specified attribute, if present, for the result at 'index',
|
||||
/// null otherwise.
|
||||
Attribute getResultAttr(unsigned index, Identifier name) {
|
||||
Attribute getResultAttr(unsigned index, StringAttr name) {
|
||||
auto argDict = getResultAttrDict(index);
|
||||
return argDict ? argDict.get(name) : nullptr;
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ public:
|
|||
}
|
||||
|
||||
template <typename AttrClass>
|
||||
AttrClass getResultAttrOfType(unsigned index, Identifier name) {
|
||||
AttrClass getResultAttrOfType(unsigned index, StringAttr name) {
|
||||
return getResultAttr(index, name).template dyn_cast_or_null<AttrClass>();
|
||||
}
|
||||
template <typename AttrClass>
|
||||
|
@ -525,17 +525,17 @@ public:
|
|||
|
||||
/// 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 setResultAttr(unsigned index, Identifier name, Attribute value);
|
||||
void setResultAttr(unsigned index, StringAttr name, Attribute value);
|
||||
void setResultAttr(unsigned index, StringRef name, Attribute value) {
|
||||
setResultAttr(index,
|
||||
Identifier::get(name, this->getOperation()->getContext()),
|
||||
StringAttr::get(this->getOperation()->getContext(), name),
|
||||
value);
|
||||
}
|
||||
|
||||
/// Remove the attribute 'name' from the result at 'index'. Return the
|
||||
/// attribute that was erased, or nullptr if there was no attribute with such
|
||||
/// name.
|
||||
Attribute removeResultAttr(unsigned index, Identifier name);
|
||||
Attribute removeResultAttr(unsigned index, StringAttr name);
|
||||
|
||||
protected:
|
||||
/// Returns the dictionary attribute corresponding to the argument at 'index'.
|
||||
|
@ -718,7 +718,7 @@ void FunctionLike<ConcreteType>::setArgAttrs(unsigned index,
|
|||
/// 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.
|
||||
template <typename ConcreteType>
|
||||
void FunctionLike<ConcreteType>::setArgAttr(unsigned index, Identifier name,
|
||||
void FunctionLike<ConcreteType>::setArgAttr(unsigned index, StringAttr name,
|
||||
Attribute value) {
|
||||
NamedAttrList attributes(getArgAttrDict(index));
|
||||
Attribute oldValue = attributes.set(name, value);
|
||||
|
@ -731,7 +731,7 @@ void FunctionLike<ConcreteType>::setArgAttr(unsigned index, Identifier name,
|
|||
/// Remove the attribute 'name' from the argument at 'index'.
|
||||
template <typename ConcreteType>
|
||||
Attribute FunctionLike<ConcreteType>::removeArgAttr(unsigned index,
|
||||
Identifier name) {
|
||||
StringAttr name) {
|
||||
// Build an attribute list and remove the attribute at 'name'.
|
||||
NamedAttrList attributes(getArgAttrDict(index));
|
||||
Attribute removedAttr = attributes.erase(name);
|
||||
|
@ -770,7 +770,7 @@ void FunctionLike<ConcreteType>::setResultAttrs(unsigned index,
|
|||
/// 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.
|
||||
template <typename ConcreteType>
|
||||
void FunctionLike<ConcreteType>::setResultAttr(unsigned index, Identifier name,
|
||||
void FunctionLike<ConcreteType>::setResultAttr(unsigned index, StringAttr name,
|
||||
Attribute value) {
|
||||
NamedAttrList attributes(getResultAttrDict(index));
|
||||
Attribute oldAttr = attributes.set(name, value);
|
||||
|
@ -783,7 +783,7 @@ void FunctionLike<ConcreteType>::setResultAttr(unsigned index, Identifier name,
|
|||
/// Remove the attribute 'name' from the result at 'index'.
|
||||
template <typename ConcreteType>
|
||||
Attribute FunctionLike<ConcreteType>::removeResultAttr(unsigned index,
|
||||
Identifier name) {
|
||||
StringAttr name) {
|
||||
// Build an attribute list and remove the attribute at 'name'.
|
||||
NamedAttrList attributes(getResultAttrDict(index));
|
||||
Attribute removedAttr = attributes.erase(name);
|
||||
|
|
|
@ -549,7 +549,7 @@ class OpaqueType<string dialect, string name, string summary>
|
|||
: Type<CPred<"isOpaqueTypeWithName($_self, \""#dialect#"\", \""#name#"\")">,
|
||||
summary, "::mlir::OpaqueType">,
|
||||
BuildableType<"::mlir::OpaqueType::get("
|
||||
"$_builder.getIdentifier(\"" # dialect # "\"), \""
|
||||
"$_builder.getStringAttr(\"" # dialect # "\"), \""
|
||||
# name # "\")">;
|
||||
|
||||
// Function Type
|
||||
|
|
|
@ -320,19 +320,21 @@ public:
|
|||
}
|
||||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute getAttr(Identifier name) { return attrs.get(name); }
|
||||
Attribute getAttr(StringAttr name) { return attrs.get(name); }
|
||||
Attribute getAttr(StringRef name) { return attrs.get(name); }
|
||||
|
||||
template <typename AttrClass> AttrClass getAttrOfType(Identifier name) {
|
||||
template <typename AttrClass>
|
||||
AttrClass getAttrOfType(StringAttr name) {
|
||||
return getAttr(name).dyn_cast_or_null<AttrClass>();
|
||||
}
|
||||
template <typename AttrClass> AttrClass getAttrOfType(StringRef name) {
|
||||
template <typename AttrClass>
|
||||
AttrClass getAttrOfType(StringRef name) {
|
||||
return getAttr(name).dyn_cast_or_null<AttrClass>();
|
||||
}
|
||||
|
||||
/// Return true if the operation has an attribute with the provided name,
|
||||
/// false otherwise.
|
||||
bool hasAttr(Identifier name) { return attrs.contains(name); }
|
||||
bool hasAttr(StringAttr name) { return attrs.contains(name); }
|
||||
bool hasAttr(StringRef name) { return attrs.contains(name); }
|
||||
template <typename AttrClass, typename NameT>
|
||||
bool hasAttrOfType(NameT &&name) {
|
||||
|
@ -342,19 +344,19 @@ public:
|
|||
|
||||
/// 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 setAttr(Identifier name, Attribute value) {
|
||||
void setAttr(StringAttr name, Attribute value) {
|
||||
NamedAttrList attributes(attrs);
|
||||
if (attributes.set(name, value) != value)
|
||||
attrs = attributes.getDictionary(getContext());
|
||||
}
|
||||
void setAttr(StringRef name, Attribute value) {
|
||||
setAttr(Identifier::get(name, getContext()), value);
|
||||
setAttr(StringAttr::get(getContext(), name), value);
|
||||
}
|
||||
|
||||
/// Remove the attribute with the specified name if it exists. Return the
|
||||
/// attribute that was erased, or nullptr if there was no attribute with such
|
||||
/// name.
|
||||
Attribute removeAttr(Identifier name) {
|
||||
Attribute removeAttr(StringAttr name) {
|
||||
NamedAttrList attributes(attrs);
|
||||
Attribute removedAttr = attributes.erase(name);
|
||||
if (removedAttr)
|
||||
|
@ -362,7 +364,7 @@ public:
|
|||
return removedAttr;
|
||||
}
|
||||
Attribute removeAttr(StringRef name) {
|
||||
return removeAttr(Identifier::get(name, getContext()));
|
||||
return removeAttr(StringAttr::get(getContext(), name));
|
||||
}
|
||||
|
||||
/// A utility iterator that filters out non-dialect attributes.
|
||||
|
|
|
@ -14,9 +14,8 @@
|
|||
#ifndef MLIR_IR_OPERATION_SUPPORT_H
|
||||
#define MLIR_IR_OPERATION_SUPPORT_H
|
||||
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/BlockSupport.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/Location.h"
|
||||
#include "mlir/IR/TypeRange.h"
|
||||
#include "mlir/IR/Types.h"
|
||||
|
@ -82,7 +81,7 @@ public:
|
|||
llvm::unique_function<LogicalResult(Operation *) const>;
|
||||
|
||||
/// This is the name of the operation.
|
||||
const Identifier name;
|
||||
const StringAttr name;
|
||||
|
||||
/// This is the dialect that this operation belongs to.
|
||||
Dialect &dialect;
|
||||
|
@ -207,7 +206,7 @@ public:
|
|||
/// greatly simplifying the cost and complexity of attribute usage produced by
|
||||
/// the generator.
|
||||
///
|
||||
ArrayRef<Identifier> getAttributeNames() const { return attributeNames; }
|
||||
ArrayRef<StringAttr> getAttributeNames() const { return attributeNames; }
|
||||
|
||||
private:
|
||||
AbstractOperation(StringRef name, Dialect &dialect, TypeID typeID,
|
||||
|
@ -217,7 +216,7 @@ private:
|
|||
FoldHookFn &&foldHook,
|
||||
GetCanonicalizationPatternsFn &&getCanonicalizationPatterns,
|
||||
detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait,
|
||||
ArrayRef<Identifier> attrNames);
|
||||
ArrayRef<StringAttr> attrNames);
|
||||
|
||||
/// Give Op access to lookupMutable.
|
||||
template <typename ConcreteType, template <typename T> class... Traits>
|
||||
|
@ -242,7 +241,7 @@ private:
|
|||
/// A list of attribute names registered to this operation in identifier form.
|
||||
/// This allows for operation classes to use identifiers for attribute
|
||||
/// lookup/creation/etc., as opposed to strings.
|
||||
ArrayRef<Identifier> attributeNames;
|
||||
ArrayRef<StringAttr> attributeNames;
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -288,12 +287,12 @@ std::pair<IteratorT, bool> findAttrSorted(IteratorT first, IteratorT last,
|
|||
return {first, false};
|
||||
}
|
||||
|
||||
/// Identifier lookups on large attribute lists will switch to string binary
|
||||
/// StringAttr lookups on large attribute lists will switch to string binary
|
||||
/// search. String binary searches become significantly faster than linear scans
|
||||
/// with the identifier when the attribute list becomes very large.
|
||||
template <typename IteratorT>
|
||||
std::pair<IteratorT, bool> findAttrSorted(IteratorT first, IteratorT last,
|
||||
Identifier name) {
|
||||
StringAttr name) {
|
||||
constexpr unsigned kSmallAttributeList = 16;
|
||||
if (std::distance(first, last) > kSmallAttributeList)
|
||||
return findAttrSorted(first, last, name.strref());
|
||||
|
@ -332,7 +331,7 @@ public:
|
|||
void append(StringRef name, Attribute attr);
|
||||
|
||||
/// Add an attribute with the specified name.
|
||||
void append(Identifier name, Attribute attr) {
|
||||
void append(StringAttr name, Attribute attr) {
|
||||
append(NamedAttribute(name, attr));
|
||||
}
|
||||
|
||||
|
@ -384,24 +383,24 @@ public:
|
|||
ArrayRef<NamedAttribute> getAttrs() const;
|
||||
|
||||
/// Return the specified attribute if present, null otherwise.
|
||||
Attribute get(Identifier name) const;
|
||||
Attribute get(StringAttr name) const;
|
||||
Attribute get(StringRef name) const;
|
||||
|
||||
/// Return the specified named attribute if present, None otherwise.
|
||||
Optional<NamedAttribute> getNamed(StringRef name) const;
|
||||
Optional<NamedAttribute> getNamed(Identifier name) const;
|
||||
Optional<NamedAttribute> getNamed(StringAttr name) const;
|
||||
|
||||
/// 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.
|
||||
/// Returns the previous attribute value of `name`, or null if no
|
||||
/// attribute previously existed with `name`.
|
||||
Attribute set(Identifier name, Attribute value);
|
||||
Attribute set(StringAttr name, Attribute value);
|
||||
Attribute set(StringRef name, Attribute value);
|
||||
|
||||
/// Erase the attribute with the given name from the list. Return the
|
||||
/// attribute that was erased, or nullptr if there was no attribute with such
|
||||
/// name.
|
||||
Attribute erase(Identifier name);
|
||||
Attribute erase(StringAttr name);
|
||||
Attribute erase(StringRef name);
|
||||
|
||||
iterator begin() { return attrs.begin(); }
|
||||
|
@ -443,7 +442,7 @@ private:
|
|||
class OperationName {
|
||||
public:
|
||||
using RepresentationUnion =
|
||||
PointerUnion<Identifier, const AbstractOperation *>;
|
||||
PointerUnion<StringAttr, const AbstractOperation *>;
|
||||
|
||||
OperationName(AbstractOperation *op) : representation(op) {}
|
||||
OperationName(StringRef name, MLIRContext *context);
|
||||
|
@ -456,7 +455,7 @@ public:
|
|||
Dialect *getDialect() const {
|
||||
if (const auto *abstractOp = getAbstractOperation())
|
||||
return &abstractOp->dialect;
|
||||
return representation.get<Identifier>().getReferencedDialect();
|
||||
return representation.get<StringAttr>().getReferencedDialect();
|
||||
}
|
||||
|
||||
/// Return the operation name with dialect name stripped, if it has one.
|
||||
|
@ -466,7 +465,7 @@ public:
|
|||
StringRef getStringRef() const;
|
||||
|
||||
/// Return the name of this operation as an identifier. This always succeeds.
|
||||
Identifier getIdentifier() const;
|
||||
StringAttr getIdentifier() const;
|
||||
|
||||
/// If this operation has a registered operation description, return it.
|
||||
/// Otherwise return null.
|
||||
|
@ -549,11 +548,11 @@ public:
|
|||
|
||||
/// Add an attribute with the specified name.
|
||||
void addAttribute(StringRef name, Attribute attr) {
|
||||
addAttribute(Identifier::get(name, getContext()), attr);
|
||||
addAttribute(StringAttr::get(getContext(), name), attr);
|
||||
}
|
||||
|
||||
/// Add an attribute with the specified name.
|
||||
void addAttribute(Identifier name, Attribute attr) {
|
||||
void addAttribute(StringAttr name, Attribute attr) {
|
||||
attributes.append(name, attr);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
namespace mlir {
|
||||
class DataLayout;
|
||||
class DataLayoutEntryInterface;
|
||||
using DataLayoutEntryKey = llvm::PointerUnion<Type, Identifier>;
|
||||
using DataLayoutEntryKey = llvm::PointerUnion<Type, StringAttr>;
|
||||
// Using explicit SmallVector size because we cannot infer the size from the
|
||||
// forward declaration, and we need the typedef in the actual declaration.
|
||||
using DataLayoutEntryList = llvm::SmallVector<DataLayoutEntryInterface, 4>;
|
||||
|
@ -65,7 +65,7 @@ DataLayoutEntryList filterEntriesForType(DataLayoutEntryListRef entries,
|
|||
/// Given a list of data layout entries, returns the entry that has the given
|
||||
/// identifier as key, if such an entry exists in the list.
|
||||
DataLayoutEntryInterface
|
||||
filterEntryForIdentifier(DataLayoutEntryListRef entries, Identifier id);
|
||||
filterEntryForIdentifier(DataLayoutEntryListRef entries, StringAttr id);
|
||||
|
||||
/// Verifies that the operation implementing the data layout interface, or a
|
||||
/// module operation, is valid. This calls the verifier of the spec attribute
|
||||
|
|
|
@ -126,7 +126,7 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface"> {
|
|||
"present.",
|
||||
/*retTy=*/"::mlir::DataLayoutEntryInterface",
|
||||
/*methodName=*/"getSpecForIdentifier",
|
||||
/*args=*/(ins "::mlir::Identifier":$identifier),
|
||||
/*args=*/(ins "::mlir::StringAttr":$identifier),
|
||||
/*methodBody=*/"",
|
||||
/*defaultImplementation=*/[{
|
||||
return ::mlir::detail::filterEntryForIdentifier($_attr.getEntries(),
|
||||
|
@ -159,7 +159,7 @@ def DataLayoutSpecInterface : AttrInterface<"DataLayoutSpecInterface"> {
|
|||
/// method directly.
|
||||
void bucketEntriesByType(
|
||||
::llvm::DenseMap<::mlir::TypeID, ::mlir::DataLayoutEntryList> &types,
|
||||
::llvm::DenseMap<::mlir::Identifier,
|
||||
::llvm::DenseMap<::mlir::StringAttr,
|
||||
::mlir::DataLayoutEntryInterface> &ids);
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef MLIR_PASS_PASSINSTRUMENTATION_H_
|
||||
#define MLIR_PASS_PASSINSTRUMENTATION_H_
|
||||
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/Support/LLVM.h"
|
||||
#include "mlir/Support/TypeID.h"
|
||||
|
||||
|
@ -43,13 +43,13 @@ public:
|
|||
/// A callback to run before a pass pipeline is executed. This function takes
|
||||
/// the name of the operation type being operated on, and information related
|
||||
/// to the parent that spawned this pipeline.
|
||||
virtual void runBeforePipeline(Identifier name,
|
||||
virtual void runBeforePipeline(StringAttr name,
|
||||
const PipelineParentInfo &parentInfo) {}
|
||||
|
||||
/// A callback to run after a pass pipeline has executed. This function takes
|
||||
/// the name of the operation type being operated on, and information related
|
||||
/// to the parent that spawned this pipeline.
|
||||
virtual void runAfterPipeline(Identifier name,
|
||||
virtual void runAfterPipeline(StringAttr name,
|
||||
const PipelineParentInfo &parentInfo) {}
|
||||
|
||||
/// A callback to run before a pass is executed. This function takes a pointer
|
||||
|
@ -90,12 +90,12 @@ public:
|
|||
|
||||
/// See PassInstrumentation::runBeforePipeline for details.
|
||||
void
|
||||
runBeforePipeline(Identifier name,
|
||||
runBeforePipeline(StringAttr name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo);
|
||||
|
||||
/// See PassInstrumentation::runAfterPipeline for details.
|
||||
void
|
||||
runAfterPipeline(Identifier name,
|
||||
runAfterPipeline(StringAttr name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo);
|
||||
|
||||
/// See PassInstrumentation::runBeforePass for details.
|
||||
|
|
|
@ -34,9 +34,6 @@ class PassInstrumentation;
|
|||
class PassInstrumentor;
|
||||
class StringAttr;
|
||||
|
||||
// TODO: Remove this when all usages have been replaced with StringAttr.
|
||||
using Identifier = StringAttr;
|
||||
|
||||
namespace detail {
|
||||
struct OpPassManagerImpl;
|
||||
class OpToOpPassAdaptor;
|
||||
|
@ -54,7 +51,7 @@ struct PassExecutionState;
|
|||
class OpPassManager {
|
||||
public:
|
||||
enum class Nesting { Implicit, Explicit };
|
||||
OpPassManager(Identifier name, Nesting nesting = Nesting::Explicit);
|
||||
OpPassManager(StringAttr name, Nesting nesting = Nesting::Explicit);
|
||||
OpPassManager(StringRef name, Nesting nesting = Nesting::Explicit);
|
||||
OpPassManager(OpPassManager &&rhs);
|
||||
OpPassManager(const OpPassManager &rhs);
|
||||
|
@ -78,7 +75,7 @@ public:
|
|||
|
||||
/// Nest a new operation pass manager for the given operation kind under this
|
||||
/// pass manager.
|
||||
OpPassManager &nest(Identifier nestedName);
|
||||
OpPassManager &nest(StringAttr nestedName);
|
||||
OpPassManager &nest(StringRef nestedName);
|
||||
template <typename OpT> OpPassManager &nest() {
|
||||
return nest(OpT::getOperationName());
|
||||
|
@ -101,7 +98,7 @@ public:
|
|||
size_t size() const;
|
||||
|
||||
/// Return the operation name that this pass manager operates on.
|
||||
Identifier getOpName(MLIRContext &context) const;
|
||||
StringAttr getOpName(MLIRContext &context) const;
|
||||
|
||||
/// Return the operation name that this pass manager operates on.
|
||||
StringRef getOpName() const;
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
#ifndef MLIR_TARGET_LLVMIR_LLVMTRANSLATIONINTERFACE_H
|
||||
#define MLIR_TARGET_LLVMIR_LLVMTRANSLATIONINTERFACE_H
|
||||
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/DialectInterface.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/Support/LogicalResult.h"
|
||||
|
||||
namespace llvm {
|
||||
|
|
|
@ -165,7 +165,7 @@ MlirAttribute mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace,
|
|||
intptr_t dataLength, const char *data,
|
||||
MlirType type) {
|
||||
return wrap(
|
||||
OpaqueAttr::get(Identifier::get(unwrap(dialectNamespace), unwrap(ctx)),
|
||||
OpaqueAttr::get(StringAttr::get(unwrap(ctx), unwrap(dialectNamespace)),
|
||||
StringRef(data, dataLength), unwrap(type)));
|
||||
}
|
||||
|
||||
|
|
|
@ -145,9 +145,9 @@ MlirLocation mlirLocationNameGet(MlirContext context, MlirStringRef name,
|
|||
MlirLocation childLoc) {
|
||||
if (mlirLocationIsNull(childLoc))
|
||||
return wrap(
|
||||
Location(NameLoc::get(Identifier::get(unwrap(name), unwrap(context)))));
|
||||
Location(NameLoc::get(StringAttr::get(unwrap(context), unwrap(name)))));
|
||||
return wrap(Location(NameLoc::get(
|
||||
Identifier::get(unwrap(name), unwrap(context)), unwrap(childLoc))));
|
||||
StringAttr::get(unwrap(context), unwrap(name)), unwrap(childLoc))));
|
||||
}
|
||||
|
||||
MlirLocation mlirLocationUnknownGet(MlirContext context) {
|
||||
|
@ -753,7 +753,7 @@ MlirNamedAttribute mlirNamedAttributeGet(MlirIdentifier name,
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
MlirIdentifier mlirIdentifierGet(MlirContext context, MlirStringRef str) {
|
||||
return wrap(Identifier::get(unwrap(str), unwrap(context)));
|
||||
return wrap(StringAttr::get(unwrap(context), unwrap(str)));
|
||||
}
|
||||
|
||||
MlirContext mlirIdentifierGetContext(MlirIdentifier ident) {
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace mlir {
|
|||
|
||||
struct GPUFuncOpLowering : ConvertOpToLLVMPattern<gpu::GPUFuncOp> {
|
||||
GPUFuncOpLowering(LLVMTypeConverter &converter, unsigned allocaAddrSpace,
|
||||
Identifier kernelAttributeName)
|
||||
StringAttr kernelAttributeName)
|
||||
: ConvertOpToLLVMPattern<gpu::GPUFuncOp>(converter),
|
||||
allocaAddrSpace(allocaAddrSpace),
|
||||
kernelAttributeName(kernelAttributeName) {}
|
||||
|
@ -30,7 +30,7 @@ private:
|
|||
unsigned allocaAddrSpace;
|
||||
|
||||
/// The attribute name to use instead of `gpu.kernel`.
|
||||
Identifier kernelAttributeName;
|
||||
StringAttr kernelAttributeName;
|
||||
};
|
||||
|
||||
struct GPUReturnOpLowering : public ConvertOpToLLVMPattern<gpu::ReturnOp> {
|
||||
|
|
|
@ -192,8 +192,8 @@ void mlir::populateGpuToNVVMConversionPatterns(LLVMTypeConverter &converter,
|
|||
// memory space and does not support `alloca`s with addrspace(5).
|
||||
patterns.add<GPUFuncOpLowering>(
|
||||
converter, /*allocaAddrSpace=*/0,
|
||||
Identifier::get(NVVM::NVVMDialect::getKernelFuncAttrName(),
|
||||
&converter.getContext()));
|
||||
StringAttr::get(&converter.getContext(),
|
||||
NVVM::NVVMDialect::getKernelFuncAttrName()));
|
||||
|
||||
patterns.add<OpToFuncCallLowering<math::AbsOp>>(converter, "__nv_fabsf",
|
||||
"__nv_fabs");
|
||||
|
|
|
@ -117,8 +117,8 @@ void mlir::populateGpuToROCDLConversionPatterns(LLVMTypeConverter &converter,
|
|||
GPUReturnOpLowering>(converter);
|
||||
patterns.add<GPUFuncOpLowering>(
|
||||
converter, /*allocaAddrSpace=*/5,
|
||||
Identifier::get(ROCDL::ROCDLDialect::getKernelFuncAttrName(),
|
||||
&converter.getContext()));
|
||||
StringAttr::get(&converter.getContext(),
|
||||
ROCDL::ROCDLDialect::getKernelFuncAttrName()));
|
||||
patterns.add<OpToFuncCallLowering<math::AbsOp>>(converter, "__ocml_fabs_f32",
|
||||
"__ocml_fabs_f64");
|
||||
patterns.add<OpToFuncCallLowering<math::AtanOp>>(converter, "__ocml_atan_f32",
|
||||
|
|
|
@ -296,8 +296,8 @@ LogicalResult GPUFuncOpConversion::matchAndRewrite(
|
|||
funcOp, *getTypeConverter(), rewriter, entryPointAttr, argABI);
|
||||
if (!newFuncOp)
|
||||
return failure();
|
||||
newFuncOp->removeAttr(Identifier::get(
|
||||
gpu::GPUDialect::getKernelFuncAttrName(), rewriter.getContext()));
|
||||
newFuncOp->removeAttr(
|
||||
rewriter.getStringAttr(gpu::GPUDialect::getKernelFuncAttrName()));
|
||||
return success();
|
||||
}
|
||||
|
||||
|
|
|
@ -164,12 +164,12 @@ private:
|
|||
/// A position describing an attribute of an operation.
|
||||
struct AttributePosition
|
||||
: public PredicateBase<AttributePosition, Position,
|
||||
std::pair<OperationPosition *, Identifier>,
|
||||
std::pair<OperationPosition *, StringAttr>,
|
||||
Predicates::AttributePos> {
|
||||
explicit AttributePosition(const KeyTy &key);
|
||||
|
||||
/// Returns the attribute name of this position.
|
||||
Identifier getName() const { return key.second; }
|
||||
StringAttr getName() const { return key.second; }
|
||||
};
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -487,7 +487,7 @@ public:
|
|||
|
||||
/// Returns an attribute position for an attribute of the given operation.
|
||||
Position *getAttribute(OperationPosition *p, StringRef name) {
|
||||
return AttributePosition::get(uniquer, p, Identifier::get(name, ctx));
|
||||
return AttributePosition::get(uniquer, p, StringAttr::get(ctx, name));
|
||||
}
|
||||
|
||||
/// Returns an operand position for an operand of the given operation.
|
||||
|
|
|
@ -35,7 +35,7 @@ struct SimplifyAffineStructures
|
|||
/// Utility to simplify an affine attribute and update its entry in the parent
|
||||
/// operation if necessary.
|
||||
template <typename AttributeT>
|
||||
void simplifyAndUpdateAttribute(Operation *op, Identifier name,
|
||||
void simplifyAndUpdateAttribute(Operation *op, StringAttr name,
|
||||
AttributeT attr) {
|
||||
auto &simplified = simplifiedAttributes[attr];
|
||||
if (simplified == attr)
|
||||
|
|
|
@ -88,7 +88,7 @@ static AffineIfOp hoistAffineIfOp(AffineIfOp ifOp, Operation *hoistOverOp) {
|
|||
Operation *hoistOverOpClone = nullptr;
|
||||
// We use this unique name to identify/find `ifOp`'s clone in the else
|
||||
// version.
|
||||
Identifier idForIfOp = b.getIdentifier("__mlir_if_hoisting");
|
||||
StringAttr idForIfOp = b.getStringAttr("__mlir_if_hoisting");
|
||||
operandMap.clear();
|
||||
b.setInsertionPointAfter(hoistOverOp);
|
||||
// We'll set an attribute to identify this op in a clone of this sub-tree.
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
} // namespace impl
|
||||
} // namespace mlir
|
||||
|
||||
DataLayoutEntryAttr DataLayoutEntryAttr::get(Identifier key, Attribute value) {
|
||||
DataLayoutEntryAttr DataLayoutEntryAttr::get(StringAttr key, Attribute value) {
|
||||
return Base::get(key.getContext(), key, value);
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ DataLayoutEntryAttr DataLayoutEntryAttr::parse(AsmParser &parser) {
|
|||
return {};
|
||||
|
||||
return type ? get(type, value)
|
||||
: get(parser.getBuilder().getIdentifier(identifier), value);
|
||||
: get(parser.getBuilder().getStringAttr(identifier), value);
|
||||
}
|
||||
|
||||
void DataLayoutEntryAttr::print(AsmPrinter &os) const {
|
||||
|
@ -97,7 +97,7 @@ void DataLayoutEntryAttr::print(AsmPrinter &os) const {
|
|||
if (auto type = getKey().dyn_cast<Type>())
|
||||
os << type;
|
||||
else
|
||||
os << "\"" << getKey().get<Identifier>().strref() << "\"";
|
||||
os << "\"" << getKey().get<StringAttr>().strref() << "\"";
|
||||
os << ", " << getValue() << ">";
|
||||
}
|
||||
|
||||
|
@ -146,13 +146,13 @@ LogicalResult
|
|||
DataLayoutSpecAttr::verify(function_ref<InFlightDiagnostic()> emitError,
|
||||
ArrayRef<DataLayoutEntryInterface> entries) {
|
||||
DenseSet<Type> types;
|
||||
DenseSet<Identifier> ids;
|
||||
DenseSet<StringAttr> ids;
|
||||
for (DataLayoutEntryInterface entry : entries) {
|
||||
if (auto type = entry.getKey().dyn_cast<Type>()) {
|
||||
if (!types.insert(type).second)
|
||||
return emitError() << "repeated layout entry key: " << type;
|
||||
} else {
|
||||
auto id = entry.getKey().get<Identifier>();
|
||||
auto id = entry.getKey().get<StringAttr>();
|
||||
if (!ids.insert(id).second)
|
||||
return emitError() << "repeated layout entry key: " << id.getValue();
|
||||
}
|
||||
|
@ -191,13 +191,13 @@ overwriteDuplicateEntries(SmallVectorImpl<DataLayoutEntryInterface> &oldEntries,
|
|||
static LogicalResult
|
||||
combineOneSpec(DataLayoutSpecInterface spec,
|
||||
DenseMap<TypeID, DataLayoutEntryList> &entriesForType,
|
||||
DenseMap<Identifier, DataLayoutEntryInterface> &entriesForID) {
|
||||
DenseMap<StringAttr, DataLayoutEntryInterface> &entriesForID) {
|
||||
// A missing spec should be fine.
|
||||
if (!spec)
|
||||
return success();
|
||||
|
||||
DenseMap<TypeID, DataLayoutEntryList> newEntriesForType;
|
||||
DenseMap<Identifier, DataLayoutEntryInterface> newEntriesForID;
|
||||
DenseMap<StringAttr, DataLayoutEntryInterface> newEntriesForID;
|
||||
spec.bucketEntriesByType(newEntriesForType, newEntriesForID);
|
||||
|
||||
// Try overwriting the old entries with the new ones.
|
||||
|
@ -220,7 +220,7 @@ combineOneSpec(DataLayoutSpecInterface spec,
|
|||
}
|
||||
|
||||
for (const auto &kvp : newEntriesForID) {
|
||||
Identifier id = kvp.second.getKey().get<Identifier>();
|
||||
StringAttr id = kvp.second.getKey().get<StringAttr>();
|
||||
Dialect *dialect = id.getReferencedDialect();
|
||||
if (!entriesForID.count(id)) {
|
||||
entriesForID[id] = kvp.second;
|
||||
|
@ -253,7 +253,7 @@ DataLayoutSpecAttr::combineWith(ArrayRef<DataLayoutSpecInterface> specs) const {
|
|||
|
||||
// Combine all specs in order, with `this` being the last one.
|
||||
DenseMap<TypeID, DataLayoutEntryList> entriesForType;
|
||||
DenseMap<Identifier, DataLayoutEntryInterface> entriesForID;
|
||||
DenseMap<StringAttr, DataLayoutEntryInterface> entriesForID;
|
||||
for (DataLayoutSpecInterface spec : specs)
|
||||
if (failed(combineOneSpec(spec, entriesForType, entriesForID)))
|
||||
return nullptr;
|
||||
|
@ -320,7 +320,7 @@ public:
|
|||
|
||||
LogicalResult verifyEntry(DataLayoutEntryInterface entry,
|
||||
Location loc) const final {
|
||||
StringRef entryName = entry.getKey().get<Identifier>().strref();
|
||||
StringRef entryName = entry.getKey().get<StringAttr>().strref();
|
||||
if (entryName == DLTIDialect::kDataLayoutEndiannessKey) {
|
||||
auto value = entry.getValue().dyn_cast<StringAttr>();
|
||||
if (value &&
|
||||
|
|
|
@ -35,12 +35,12 @@ void mlir::linalg::CodegenStrategy::configurePassPipeline(
|
|||
const std::unique_ptr<Transformation> &t =
|
||||
transformationSequence[stepCount];
|
||||
std::string currentStr = std::to_string(stepCount);
|
||||
auto currentState = Identifier::get(currentStr, context);
|
||||
auto currentState = StringAttr::get(context, currentStr);
|
||||
std::string nextStr = std::to_string(stepCount + 1);
|
||||
auto nextState = Identifier::get(nextStr, context);
|
||||
auto nextState = StringAttr::get(context, nextStr);
|
||||
auto filter = (currentState.str() == std::to_string(0))
|
||||
? linalg::LinalgTransformationFilter(
|
||||
t->filter, ArrayRef<Identifier>{}, nextState)
|
||||
t->filter, ArrayRef<StringAttr>{}, nextState)
|
||||
: linalg::LinalgTransformationFilter(
|
||||
t->filter, currentState, nextState);
|
||||
t->addToPassPipeline(pm, filter);
|
||||
|
|
|
@ -447,8 +447,8 @@ public:
|
|||
auto *ctx = patterns.getContext();
|
||||
patterns.add<LinalgTilingPattern<OpTy>>(
|
||||
ctx, options,
|
||||
LinalgTransformationFilter(ArrayRef<Identifier>{},
|
||||
Identifier::get("tiled", ctx)));
|
||||
LinalgTransformationFilter(ArrayRef<StringAttr>{},
|
||||
StringAttr::get(ctx, "tiled")));
|
||||
RewritePatternList<OpTypes...>::insert(patterns, options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -49,13 +49,13 @@ const StringLiteral mlir::linalg::LinalgTransforms::kLinalgTransformMarker =
|
|||
"__internal_linalg_transform__";
|
||||
|
||||
mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
|
||||
ArrayRef<Identifier> matchDisjunction, Optional<Identifier> replacement)
|
||||
ArrayRef<StringAttr> matchDisjunction, Optional<StringAttr> replacement)
|
||||
: matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
|
||||
replacement(replacement), matchByDefault(false) {}
|
||||
|
||||
mlir::linalg::LinalgTransformationFilter::LinalgTransformationFilter(
|
||||
FilterFunction f, ArrayRef<Identifier> matchDisjunction,
|
||||
Optional<Identifier> replacement)
|
||||
FilterFunction f, ArrayRef<StringAttr> matchDisjunction,
|
||||
Optional<StringAttr> replacement)
|
||||
: filters(),
|
||||
matchDisjunction(matchDisjunction.begin(), matchDisjunction.end()),
|
||||
replacement(replacement), matchByDefault(false) {
|
||||
|
@ -101,10 +101,10 @@ void mlir::linalg::LinalgTransformationFilter::
|
|||
Operation *op) const {
|
||||
if (replacement.hasValue())
|
||||
op->setAttr(LinalgTransforms::kLinalgTransformMarker,
|
||||
rewriter.getStringAttr(replacement.getValue().strref()));
|
||||
replacement.getValue());
|
||||
else
|
||||
op->removeAttr(Identifier::get(LinalgTransforms::kLinalgTransformMarker,
|
||||
rewriter.getContext()));
|
||||
op->removeAttr(
|
||||
rewriter.getStringAttr(LinalgTransforms::kLinalgTransformMarker));
|
||||
}
|
||||
|
||||
LinalgTilingOptions &
|
||||
|
|
|
@ -1171,13 +1171,13 @@ static void populateVectorizationPatterns(
|
|||
constexpr static StringRef kPromotedMarker = "PROMOTED";
|
||||
tilingPatterns.add<LinalgTilingPattern<ConvOp>>(
|
||||
context, LinalgTilingOptions().setTileSizes(tileSizes),
|
||||
LinalgTransformationFilter(ArrayRef<Identifier>{},
|
||||
Identifier::get(kTiledMarker, context)));
|
||||
LinalgTransformationFilter(ArrayRef<StringAttr>{},
|
||||
StringAttr::get(kTiledMarker, context)));
|
||||
|
||||
promotionPatterns.add<LinalgPromotionPattern<ConvOp>>(
|
||||
context, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true),
|
||||
LinalgTransformationFilter(Identifier::get(kTiledMarker, context),
|
||||
Identifier::get(kPromotedMarker, context)));
|
||||
LinalgTransformationFilter(StringAttr::get(kTiledMarker, context),
|
||||
StringAttr::get(kPromotedMarker, context)));
|
||||
|
||||
SmallVector<bool, 4> mask(N);
|
||||
int offset = tileSizes.size() - N;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
#include "mlir/Dialect/SPIRV/IR/SPIRVDialect.h"
|
||||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ LogicalResult ShapeDialect::verifyOperationAttribute(Operation *op,
|
|||
if (auto arr = attribute.second.dyn_cast<ArrayAttr>()) {
|
||||
// Verify all entries are function libraries and mappings in libraries
|
||||
// refer to unique ops.
|
||||
DenseSet<Identifier> key;
|
||||
DenseSet<StringAttr> key;
|
||||
for (auto it : arr) {
|
||||
if (!it.isa<SymbolRefAttr>())
|
||||
return op->emitError(
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
#include "mlir/IR/AffineMap.h"
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/IntegerSet.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/Support/StorageUniquer.h"
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
|
||||
using namespace mlir;
|
||||
|
||||
Identifier Builder::getIdentifier(const Twine &str) {
|
||||
return Identifier::get(str, context);
|
||||
StringAttr Builder::getIdentifier(const Twine &str) {
|
||||
return getStringAttr(str);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -83,7 +83,7 @@ NoneType Builder::getNoneType() { return NoneType::get(context); }
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
NamedAttribute Builder::getNamedAttr(StringRef name, Attribute val) {
|
||||
return NamedAttribute(getIdentifier(name), val);
|
||||
return NamedAttribute(getStringAttr(name), val);
|
||||
}
|
||||
|
||||
UnitAttr Builder::getUnitAttr() { return UnitAttr::get(context); }
|
||||
|
|
|
@ -188,7 +188,7 @@ Attribute DictionaryAttr::get(StringRef name) const {
|
|||
auto it = impl::findAttrSorted(begin(), end(), name);
|
||||
return it.second ? it.first->second : Attribute();
|
||||
}
|
||||
Attribute DictionaryAttr::get(Identifier name) const {
|
||||
Attribute DictionaryAttr::get(StringAttr name) const {
|
||||
auto it = impl::findAttrSorted(begin(), end(), name);
|
||||
return it.second ? it.first->second : Attribute();
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ Optional<NamedAttribute> DictionaryAttr::getNamed(StringRef name) const {
|
|||
auto it = impl::findAttrSorted(begin(), end(), name);
|
||||
return it.second ? *it.first : Optional<NamedAttribute>();
|
||||
}
|
||||
Optional<NamedAttribute> DictionaryAttr::getNamed(Identifier name) const {
|
||||
Optional<NamedAttribute> DictionaryAttr::getNamed(StringAttr name) const {
|
||||
auto it = impl::findAttrSorted(begin(), end(), name);
|
||||
return it.second ? *it.first : Optional<NamedAttribute>();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ Optional<NamedAttribute> DictionaryAttr::getNamed(Identifier name) const {
|
|||
bool DictionaryAttr::contains(StringRef name) const {
|
||||
return impl::findAttrSorted(begin(), end(), name).second;
|
||||
}
|
||||
bool DictionaryAttr::contains(Identifier name) const {
|
||||
bool DictionaryAttr::contains(StringAttr name) const {
|
||||
return impl::findAttrSorted(begin(), end(), name).second;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ bool BoolAttr::classof(Attribute attr) {
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
LogicalResult OpaqueAttr::verify(function_ref<InFlightDiagnostic()> emitError,
|
||||
Identifier dialect, StringRef attrData,
|
||||
StringAttr dialect, StringRef attrData,
|
||||
Type type) {
|
||||
if (!Dialect::isValidNamespace(dialect.strref()))
|
||||
return emitError() << "invalid dialect namespace '" << dialect << "'";
|
||||
|
@ -1247,7 +1247,7 @@ bool OpaqueElementsAttr::decode(ElementsAttr &result) {
|
|||
|
||||
LogicalResult
|
||||
OpaqueElementsAttr::verify(function_ref<InFlightDiagnostic()> emitError,
|
||||
Identifier dialect, StringRef value,
|
||||
StringAttr dialect, StringRef value,
|
||||
ShapedType type) {
|
||||
if (!Dialect::isValidNamespace(dialect.strref()))
|
||||
return emitError() << "invalid dialect namespace '" << dialect << "'";
|
||||
|
|
|
@ -153,7 +153,7 @@ static LogicalResult verify(FuncOp op) {
|
|||
/// from this function to dest.
|
||||
void FuncOp::cloneInto(FuncOp dest, BlockAndValueMapping &mapper) {
|
||||
// Add the attributes of this function to dest.
|
||||
llvm::MapVector<Identifier, Attribute> newAttrs;
|
||||
llvm::MapVector<StringAttr, Attribute> newAttrs;
|
||||
for (const auto &attr : dest->getAttrs())
|
||||
newAttrs.insert(attr);
|
||||
for (const auto &attr : (*this)->getAttrs())
|
||||
|
|
|
@ -251,7 +251,7 @@ void FunctionType::walkImmediateSubElements(
|
|||
|
||||
/// Verify the construction of an opaque type.
|
||||
LogicalResult OpaqueType::verify(function_ref<InFlightDiagnostic()> emitError,
|
||||
Identifier dialect, StringRef typeData) {
|
||||
StringAttr dialect, StringRef typeData) {
|
||||
if (!Dialect::isValidNamespace(dialect.strref()))
|
||||
return emitError() << "invalid dialect namespace '" << dialect << "'";
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ Attribute Dialect::parseAttribute(DialectAsmParser &parser, Type type) const {
|
|||
Type Dialect::parseType(DialectAsmParser &parser) const {
|
||||
// If this dialect allows unknown types, then represent this with OpaqueType.
|
||||
if (allowsUnknownTypes()) {
|
||||
Identifier ns = Identifier::get(getNamespace(), getContext());
|
||||
StringAttr ns = StringAttr::get(getContext(), getNamespace());
|
||||
return OpaqueType::get(ns, parser.getFullSymbolSpec());
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "mlir/IR/Location.h"
|
||||
#include "mlir/IR/BuiltinDialect.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/Visitors.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/TypeSwitch.h"
|
||||
|
|
|
@ -772,14 +772,14 @@ void AbstractOperation::insert(
|
|||
"context");
|
||||
|
||||
// Register the attribute names of this operation.
|
||||
MutableArrayRef<Identifier> cachedAttrNames;
|
||||
MutableArrayRef<StringAttr> cachedAttrNames;
|
||||
if (!attrNames.empty()) {
|
||||
cachedAttrNames = MutableArrayRef<Identifier>(
|
||||
impl.abstractDialectSymbolAllocator.Allocate<Identifier>(
|
||||
cachedAttrNames = MutableArrayRef<StringAttr>(
|
||||
impl.abstractDialectSymbolAllocator.Allocate<StringAttr>(
|
||||
attrNames.size()),
|
||||
attrNames.size());
|
||||
for (unsigned i : llvm::seq<unsigned>(0, attrNames.size()))
|
||||
new (&cachedAttrNames[i]) Identifier(Identifier::get(attrNames[i], ctx));
|
||||
new (&cachedAttrNames[i]) StringAttr(StringAttr::get(ctx, attrNames[i]));
|
||||
}
|
||||
|
||||
// Register the information for this operation.
|
||||
|
@ -801,8 +801,8 @@ AbstractOperation::AbstractOperation(
|
|||
VerifyInvariantsFn &&verifyInvariants, FoldHookFn &&foldHook,
|
||||
GetCanonicalizationPatternsFn &&getCanonicalizationPatterns,
|
||||
detail::InterfaceMap &&interfaceMap, HasTraitFn &&hasTrait,
|
||||
ArrayRef<Identifier> attrNames)
|
||||
: name(Identifier::get(name, dialect.getContext())), dialect(dialect),
|
||||
ArrayRef<StringAttr> attrNames)
|
||||
: name(StringAttr::get(dialect.getContext(), name)), dialect(dialect),
|
||||
typeID(typeID), interfaceMap(std::move(interfaceMap)),
|
||||
foldHookFn(std::move(foldHook)),
|
||||
getCanonicalizationPatternsFn(std::move(getCanonicalizationPatterns)),
|
||||
|
|
|
@ -30,7 +30,7 @@ OperationName::OperationName(StringRef name, MLIRContext *context) {
|
|||
if (auto *op = AbstractOperation::lookup(name, context))
|
||||
representation = op;
|
||||
else
|
||||
representation = Identifier::get(name, context);
|
||||
representation = StringAttr::get(name, context);
|
||||
}
|
||||
|
||||
/// Return the name of the dialect this operation is registered to.
|
||||
|
@ -51,10 +51,10 @@ StringRef OperationName::getStringRef() const {
|
|||
}
|
||||
|
||||
/// Return the name of this operation as an identifier. This always succeeds.
|
||||
Identifier OperationName::getIdentifier() const {
|
||||
StringAttr OperationName::getIdentifier() const {
|
||||
if (auto *op = representation.dyn_cast<const AbstractOperation *>())
|
||||
return op->name;
|
||||
return representation.get<Identifier>();
|
||||
return representation.get<StringAttr>();
|
||||
}
|
||||
|
||||
OperationName OperationName::getFromOpaquePointer(const void *pointer) {
|
||||
|
|
|
@ -62,7 +62,7 @@ DictionaryAttr NamedAttrList::getDictionary(MLIRContext *context) const {
|
|||
|
||||
/// Add an attribute with the specified name.
|
||||
void NamedAttrList::append(StringRef name, Attribute attr) {
|
||||
append(Identifier::get(name, attr.getContext()), attr);
|
||||
append(StringAttr::get(attr.getContext(), name), attr);
|
||||
}
|
||||
|
||||
/// Replaces the attributes with new list of attributes.
|
||||
|
@ -86,7 +86,7 @@ Attribute NamedAttrList::get(StringRef name) const {
|
|||
auto it = findAttr(*this, name);
|
||||
return it.second ? it.first->second : Attribute();
|
||||
}
|
||||
Attribute NamedAttrList::get(Identifier name) const {
|
||||
Attribute NamedAttrList::get(StringAttr name) const {
|
||||
auto it = findAttr(*this, name);
|
||||
return it.second ? it.first->second : Attribute();
|
||||
}
|
||||
|
@ -96,14 +96,14 @@ Optional<NamedAttribute> NamedAttrList::getNamed(StringRef name) const {
|
|||
auto it = findAttr(*this, name);
|
||||
return it.second ? *it.first : Optional<NamedAttribute>();
|
||||
}
|
||||
Optional<NamedAttribute> NamedAttrList::getNamed(Identifier name) const {
|
||||
Optional<NamedAttribute> NamedAttrList::getNamed(StringAttr name) const {
|
||||
auto it = findAttr(*this, name);
|
||||
return it.second ? *it.first : Optional<NamedAttribute>();
|
||||
}
|
||||
|
||||
/// 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.
|
||||
Attribute NamedAttrList::set(Identifier name, Attribute value) {
|
||||
Attribute NamedAttrList::set(StringAttr name, Attribute value) {
|
||||
assert(value && "attributes may never be null");
|
||||
|
||||
// Look for an existing attribute with the given name, and set its value
|
||||
|
@ -131,7 +131,7 @@ Attribute NamedAttrList::set(Identifier name, Attribute value) {
|
|||
|
||||
Attribute NamedAttrList::set(StringRef name, Attribute value) {
|
||||
assert(value && "attributes may never be null");
|
||||
return set(mlir::Identifier::get(name, value.getContext()), value);
|
||||
return set(mlir::StringAttr::get(value.getContext(), name), value);
|
||||
}
|
||||
|
||||
Attribute
|
||||
|
@ -143,7 +143,7 @@ NamedAttrList::eraseImpl(SmallVectorImpl<NamedAttribute>::iterator it) {
|
|||
return attr;
|
||||
}
|
||||
|
||||
Attribute NamedAttrList::erase(Identifier name) {
|
||||
Attribute NamedAttrList::erase(StringAttr name) {
|
||||
auto it = findAttr(*this, name);
|
||||
return it.second ? eraseImpl(it.first) : Attribute();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ static bool isPotentiallyUnknownSymbolTable(Operation *op) {
|
|||
static StringAttr getNameIfSymbol(Operation *op) {
|
||||
return op->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName());
|
||||
}
|
||||
static StringAttr getNameIfSymbol(Operation *op, Identifier symbolAttrNameId) {
|
||||
static StringAttr getNameIfSymbol(Operation *op, StringAttr symbolAttrNameId) {
|
||||
return op->getAttrOfType<StringAttr>(symbolAttrNameId);
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,8 @@ collectValidReferencesFor(Operation *symbol, StringAttr symbolName,
|
|||
|
||||
// Collect references until 'symbolTableOp' reaches 'within'.
|
||||
SmallVector<FlatSymbolRefAttr, 1> nestedRefs(1, leafRef);
|
||||
Identifier symbolNameId =
|
||||
Identifier::get(SymbolTable::getSymbolAttrName(), ctx);
|
||||
StringAttr symbolNameId =
|
||||
StringAttr::get(ctx, SymbolTable::getSymbolAttrName());
|
||||
do {
|
||||
// Each parent of 'symbol' should define a symbol table.
|
||||
if (!symbolTableOp->hasTrait<OpTrait::SymbolTable>())
|
||||
|
@ -111,8 +111,8 @@ SymbolTable::SymbolTable(Operation *symbolTableOp)
|
|||
assert(llvm::hasSingleElement(symbolTableOp->getRegion(0)) &&
|
||||
"expected operation to have a single block");
|
||||
|
||||
Identifier symbolNameId = Identifier::get(SymbolTable::getSymbolAttrName(),
|
||||
symbolTableOp->getContext());
|
||||
StringAttr symbolNameId = StringAttr::get(symbolTableOp->getContext(),
|
||||
SymbolTable::getSymbolAttrName());
|
||||
for (auto &op : symbolTableOp->getRegion(0).front()) {
|
||||
StringAttr name = getNameIfSymbol(&op, symbolNameId);
|
||||
if (!name)
|
||||
|
@ -235,7 +235,7 @@ void SymbolTable::setSymbolVisibility(Operation *symbol, Visibility vis) {
|
|||
// If the visibility is public, just drop the attribute as this is the
|
||||
// default.
|
||||
if (vis == Visibility::Public) {
|
||||
symbol->removeAttr(Identifier::get(getVisibilityAttrName(), ctx));
|
||||
symbol->removeAttr(StringAttr::get(ctx, getVisibilityAttrName()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -305,8 +305,8 @@ Operation *SymbolTable::lookupSymbolIn(Operation *symbolTableOp,
|
|||
return nullptr;
|
||||
|
||||
// Look for a symbol with the given name.
|
||||
Identifier symbolNameId = Identifier::get(SymbolTable::getSymbolAttrName(),
|
||||
symbolTableOp->getContext());
|
||||
StringAttr symbolNameId = StringAttr::get(symbolTableOp->getContext(),
|
||||
SymbolTable::getSymbolAttrName());
|
||||
for (auto &op : region.front())
|
||||
if (getNameIfSymbol(&op, symbolNameId) == symbol)
|
||||
return &op;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include "mlir/IR/AffineMap.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "mlir/IR/OperationSupport.h"
|
||||
#include "mlir/IR/TypeRange.h"
|
||||
|
|
|
@ -147,11 +147,11 @@ mlir::detail::filterEntriesForType(DataLayoutEntryListRef entries,
|
|||
|
||||
DataLayoutEntryInterface
|
||||
mlir::detail::filterEntryForIdentifier(DataLayoutEntryListRef entries,
|
||||
Identifier id) {
|
||||
StringAttr id) {
|
||||
const auto *it = llvm::find_if(entries, [id](DataLayoutEntryInterface entry) {
|
||||
if (!entry.getKey().is<Identifier>())
|
||||
if (!entry.getKey().is<StringAttr>())
|
||||
return false;
|
||||
return entry.getKey().get<Identifier>() == id;
|
||||
return entry.getKey().get<StringAttr>() == id;
|
||||
});
|
||||
return it == entries.end() ? DataLayoutEntryInterface() : *it;
|
||||
}
|
||||
|
@ -384,12 +384,12 @@ unsigned mlir::DataLayout::getTypePreferredAlignment(Type t) const {
|
|||
|
||||
void DataLayoutSpecInterface::bucketEntriesByType(
|
||||
DenseMap<TypeID, DataLayoutEntryList> &types,
|
||||
DenseMap<Identifier, DataLayoutEntryInterface> &ids) {
|
||||
DenseMap<StringAttr, DataLayoutEntryInterface> &ids) {
|
||||
for (DataLayoutEntryInterface entry : getEntries()) {
|
||||
if (auto type = entry.getKey().dyn_cast<Type>())
|
||||
types[type.getTypeID()].push_back(entry);
|
||||
else
|
||||
ids[entry.getKey().get<Identifier>()] = entry;
|
||||
ids[entry.getKey().get<StringAttr>()] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ LogicalResult mlir::detail::verifyDataLayoutSpec(DataLayoutSpecInterface spec,
|
|||
// Second, dispatch verifications of entry groups to types or dialects they
|
||||
// are are associated with.
|
||||
DenseMap<TypeID, DataLayoutEntryList> types;
|
||||
DenseMap<Identifier, DataLayoutEntryInterface> ids;
|
||||
DenseMap<StringAttr, DataLayoutEntryInterface> ids;
|
||||
spec.bucketEntriesByType(types, ids);
|
||||
|
||||
for (const auto &kvp : types) {
|
||||
|
@ -430,7 +430,7 @@ LogicalResult mlir::detail::verifyDataLayoutSpec(DataLayoutSpecInterface spec,
|
|||
}
|
||||
|
||||
for (const auto &kvp : ids) {
|
||||
Identifier identifier = kvp.second.getKey().get<Identifier>();
|
||||
StringAttr identifier = kvp.second.getKey().get<StringAttr>();
|
||||
Dialect *dialect = identifier.getReferencedDialect();
|
||||
|
||||
// Ignore attributes that belong to an unknown dialect, the dialect may
|
||||
|
|
|
@ -260,15 +260,15 @@ OptionalParseResult Parser::parseOptionalAttribute(StringAttr &attribute,
|
|||
/// attribute-entry ::= (bare-id | string-literal) `=` attribute-value
|
||||
///
|
||||
ParseResult Parser::parseAttributeDict(NamedAttrList &attributes) {
|
||||
llvm::SmallDenseSet<Identifier> seenKeys;
|
||||
llvm::SmallDenseSet<StringAttr> seenKeys;
|
||||
auto parseElt = [&]() -> ParseResult {
|
||||
// The name of an attribute can either be a bare identifier, or a string.
|
||||
Optional<Identifier> nameId;
|
||||
Optional<StringAttr> nameId;
|
||||
if (getToken().is(Token::string))
|
||||
nameId = builder.getIdentifier(getToken().getStringValue());
|
||||
nameId = builder.getStringAttr(getToken().getStringValue());
|
||||
else if (getToken().isAny(Token::bare_identifier, Token::inttype) ||
|
||||
getToken().isKeyword())
|
||||
nameId = builder.getIdentifier(getTokenSpelling());
|
||||
nameId = builder.getStringAttr(getTokenSpelling());
|
||||
else
|
||||
return emitError("expected attribute name");
|
||||
if (!seenKeys.insert(*nameId).second)
|
||||
|
@ -856,7 +856,7 @@ Attribute Parser::parseOpaqueElementsAttr(Type attrType) {
|
|||
std::string data;
|
||||
if (parseElementAttrHexValues(*this, hexTok, data))
|
||||
return nullptr;
|
||||
return OpaqueElementsAttr::get(builder.getIdentifier(name), type, data);
|
||||
return OpaqueElementsAttr::get(builder.getStringAttr(name), type, data);
|
||||
}
|
||||
|
||||
/// Shaped type for elements attribute.
|
||||
|
|
|
@ -258,7 +258,7 @@ Attribute Parser::parseExtendedAttr(Type type) {
|
|||
// Otherwise, form a new opaque attribute.
|
||||
return OpaqueAttr::getChecked(
|
||||
[&] { return emitError(loc); },
|
||||
Identifier::get(dialectName, state.context), symbolData,
|
||||
StringAttr::get(state.context, dialectName), symbolData,
|
||||
attrType ? attrType : NoneType::get(state.context));
|
||||
});
|
||||
|
||||
|
@ -297,7 +297,7 @@ Type Parser::parseExtendedType() {
|
|||
// Otherwise, form a new opaque type.
|
||||
return OpaqueType::getChecked(
|
||||
[&] { return emitError(loc); },
|
||||
Identifier::get(dialectName, state.context), symbolData);
|
||||
StringAttr::get(state.context, dialectName), symbolData);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
#include "Lexer.h"
|
||||
#include "mlir/IR/Diagnostics.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "mlir/IR/Location.h"
|
||||
#include "mlir/IR/MLIRContext.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
|
|
@ -137,14 +137,14 @@ ParseResult Parser::parseNameOrFileLineColLocation(LocationAttr &loc) {
|
|||
if (childLoc.isa<NameLoc>())
|
||||
return emitError(childSourceLoc,
|
||||
"child of NameLoc cannot be another NameLoc");
|
||||
loc = NameLoc::get(Identifier::get(str, ctx), childLoc);
|
||||
loc = NameLoc::get(StringAttr::get(ctx, str), childLoc);
|
||||
|
||||
// Parse the closing ')'.
|
||||
if (parseToken(Token::r_paren,
|
||||
"expected ')' after child location of NameLoc"))
|
||||
return failure();
|
||||
} else {
|
||||
loc = NameLoc::get(Identifier::get(str, ctx));
|
||||
loc = NameLoc::get(StringAttr::get(ctx, str));
|
||||
}
|
||||
|
||||
return success();
|
||||
|
|
|
@ -80,7 +80,7 @@ void Pass::printAsTextualPipeline(raw_ostream &os) {
|
|||
namespace mlir {
|
||||
namespace detail {
|
||||
struct OpPassManagerImpl {
|
||||
OpPassManagerImpl(Identifier identifier, OpPassManager::Nesting nesting)
|
||||
OpPassManagerImpl(StringAttr identifier, OpPassManager::Nesting nesting)
|
||||
: name(identifier.str()), identifier(identifier),
|
||||
initializationGeneration(0), nesting(nesting) {}
|
||||
OpPassManagerImpl(StringRef name, OpPassManager::Nesting nesting)
|
||||
|
@ -91,7 +91,7 @@ struct OpPassManagerImpl {
|
|||
|
||||
/// Nest a new operation pass manager for the given operation kind under this
|
||||
/// pass manager.
|
||||
OpPassManager &nest(Identifier nestedName);
|
||||
OpPassManager &nest(StringAttr nestedName);
|
||||
OpPassManager &nest(StringRef nestedName);
|
||||
|
||||
/// Add the given pass to this pass manager. If this pass has a concrete
|
||||
|
@ -107,9 +107,9 @@ struct OpPassManagerImpl {
|
|||
void coalesceAdjacentAdaptorPasses();
|
||||
|
||||
/// Return the operation name of this pass manager as an identifier.
|
||||
Identifier getOpName(MLIRContext &context) {
|
||||
StringAttr getOpName(MLIRContext &context) {
|
||||
if (!identifier)
|
||||
identifier = Identifier::get(name, &context);
|
||||
identifier = StringAttr::get(name, &context);
|
||||
return *identifier;
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ struct OpPassManagerImpl {
|
|||
|
||||
/// The cached identifier (internalized in the context) for the name of the
|
||||
/// operation that passes of this pass manager operate on.
|
||||
Optional<Identifier> identifier;
|
||||
Optional<StringAttr> identifier;
|
||||
|
||||
/// The set of passes to run as part of this pass manager.
|
||||
std::vector<std::unique_ptr<Pass>> passes;
|
||||
|
@ -141,7 +141,7 @@ void OpPassManagerImpl::mergeInto(OpPassManagerImpl &rhs) {
|
|||
passes.clear();
|
||||
}
|
||||
|
||||
OpPassManager &OpPassManagerImpl::nest(Identifier nestedName) {
|
||||
OpPassManager &OpPassManagerImpl::nest(StringAttr nestedName) {
|
||||
OpPassManager nested(nestedName, nesting);
|
||||
auto *adaptor = new OpToOpPassAdaptor(std::move(nested));
|
||||
addPass(std::unique_ptr<Pass>(adaptor));
|
||||
|
@ -219,7 +219,7 @@ void OpPassManagerImpl::coalesceAdjacentAdaptorPasses() {
|
|||
// OpPassManager
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
OpPassManager::OpPassManager(Identifier name, Nesting nesting)
|
||||
OpPassManager::OpPassManager(StringAttr name, Nesting nesting)
|
||||
: impl(new OpPassManagerImpl(name, nesting)) {}
|
||||
OpPassManager::OpPassManager(StringRef name, Nesting nesting)
|
||||
: impl(new OpPassManagerImpl(name, nesting)) {}
|
||||
|
@ -254,7 +254,7 @@ OpPassManager::const_pass_iterator OpPassManager::end() const {
|
|||
|
||||
/// Nest a new operation pass manager for the given operation kind under this
|
||||
/// pass manager.
|
||||
OpPassManager &OpPassManager::nest(Identifier nestedName) {
|
||||
OpPassManager &OpPassManager::nest(StringAttr nestedName) {
|
||||
return impl->nest(nestedName);
|
||||
}
|
||||
OpPassManager &OpPassManager::nest(StringRef nestedName) {
|
||||
|
@ -279,7 +279,7 @@ OpPassManagerImpl &OpPassManager::getImpl() { return *impl; }
|
|||
StringRef OpPassManager::getOpName() const { return impl->name; }
|
||||
|
||||
/// Return the operation name that this pass manager operates on.
|
||||
Identifier OpPassManager::getOpName(MLIRContext &context) const {
|
||||
StringAttr OpPassManager::getOpName(MLIRContext &context) const {
|
||||
return impl->getOpName(context);
|
||||
}
|
||||
|
||||
|
@ -468,7 +468,7 @@ static OpPassManager *findPassManagerFor(MutableArrayRef<OpPassManager> mgrs,
|
|||
/// Find an operation pass manager that can operate on an operation of the given
|
||||
/// type, or nullptr if one does not exist.
|
||||
static OpPassManager *findPassManagerFor(MutableArrayRef<OpPassManager> mgrs,
|
||||
Identifier name,
|
||||
StringAttr name,
|
||||
MLIRContext &context) {
|
||||
auto it = llvm::find_if(
|
||||
mgrs, [&](OpPassManager &mgr) { return mgr.getOpName(context) == name; });
|
||||
|
@ -630,7 +630,7 @@ void OpToOpPassAdaptor::runOnOperationAsyncImpl(bool verifyPasses) {
|
|||
|
||||
PassManager::PassManager(MLIRContext *ctx, Nesting nesting,
|
||||
StringRef operationName)
|
||||
: OpPassManager(Identifier::get(operationName, ctx), nesting), context(ctx),
|
||||
: OpPassManager(StringAttr::get(ctx, operationName), nesting), context(ctx),
|
||||
initializationKey(DenseMapInfo<llvm::hash_code>::getTombstoneKey()),
|
||||
passTiming(false), verifyPasses(true) {}
|
||||
|
||||
|
@ -794,7 +794,7 @@ PassInstrumentor::~PassInstrumentor() {}
|
|||
|
||||
/// See PassInstrumentation::runBeforePipeline for details.
|
||||
void PassInstrumentor::runBeforePipeline(
|
||||
Identifier name,
|
||||
StringAttr name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo) {
|
||||
llvm::sys::SmartScopedLock<true> instrumentationLock(impl->mutex);
|
||||
for (auto &instr : impl->instrumentations)
|
||||
|
@ -803,7 +803,7 @@ void PassInstrumentor::runBeforePipeline(
|
|||
|
||||
/// See PassInstrumentation::runAfterPipeline for details.
|
||||
void PassInstrumentor::runAfterPipeline(
|
||||
Identifier name,
|
||||
StringAttr name,
|
||||
const PassInstrumentation::PipelineParentInfo &parentInfo) {
|
||||
llvm::sys::SmartScopedLock<true> instrumentationLock(impl->mutex);
|
||||
for (auto &instr : llvm::reverse(impl->instrumentations))
|
||||
|
|
|
@ -52,7 +52,7 @@ struct PassTiming : public PassInstrumentation {
|
|||
// Pipeline
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
void runBeforePipeline(Identifier name,
|
||||
void runBeforePipeline(StringAttr name,
|
||||
const PipelineParentInfo &parentInfo) override {
|
||||
auto tid = llvm::get_threadid();
|
||||
auto &activeTimers = activeThreadTimers[tid];
|
||||
|
@ -73,7 +73,7 @@ struct PassTiming : public PassInstrumentation {
|
|||
}));
|
||||
}
|
||||
|
||||
void runAfterPipeline(Identifier, const PipelineParentInfo &) override {
|
||||
void runAfterPipeline(StringAttr, const PipelineParentInfo &) override {
|
||||
auto &activeTimers = activeThreadTimers[llvm::get_threadid()];
|
||||
assert(!activeTimers.empty() && "expected active timer");
|
||||
activeTimers.pop_back();
|
||||
|
|
|
@ -721,11 +721,8 @@ void Generator::generate(pdl_interp::CreateOperationOp op,
|
|||
// Add the attributes.
|
||||
OperandRange attributes = op.attributes();
|
||||
writer.append(static_cast<ByteCodeField>(attributes.size()));
|
||||
for (auto it : llvm::zip(op.attributeNames(), op.attributes())) {
|
||||
writer.append(
|
||||
Identifier::get(std::get<0>(it).cast<StringAttr>().getValue(), ctx),
|
||||
std::get<1>(it));
|
||||
}
|
||||
for (auto it : llvm::zip(op.attributeNames(), op.attributes()))
|
||||
writer.append(std::get<0>(it), std::get<1>(it));
|
||||
writer.appendPDLValueList(op.types());
|
||||
}
|
||||
void Generator::generate(pdl_interp::CreateTypeOp op, ByteCodeWriter &writer) {
|
||||
|
@ -745,7 +742,7 @@ void Generator::generate(pdl_interp::FinalizeOp op, ByteCodeWriter &writer) {
|
|||
void Generator::generate(pdl_interp::GetAttributeOp op,
|
||||
ByteCodeWriter &writer) {
|
||||
writer.append(OpCode::GetAttribute, op.attribute(), op.operation(),
|
||||
Identifier::get(op.name(), ctx));
|
||||
op.nameAttr());
|
||||
}
|
||||
void Generator::generate(pdl_interp::GetAttributeTypeOp op,
|
||||
ByteCodeWriter &writer) {
|
||||
|
@ -1307,7 +1304,7 @@ void ByteCodeExecutor::executeCreateOperation(PatternRewriter &rewriter,
|
|||
OperationState state(mainRewriteLoc, read<OperationName>());
|
||||
readValueList(state.operands);
|
||||
for (unsigned i = 0, e = read(); i != e; ++i) {
|
||||
Identifier name = read<Identifier>();
|
||||
StringAttr name = read<StringAttr>();
|
||||
if (Attribute attr = read<Attribute>())
|
||||
state.addAttribute(name, attr);
|
||||
}
|
||||
|
@ -1364,7 +1361,7 @@ void ByteCodeExecutor::executeGetAttribute() {
|
|||
LLVM_DEBUG(llvm::dbgs() << "Executing GetAttribute:\n");
|
||||
unsigned memIndex = read();
|
||||
Operation *op = read<Operation *>();
|
||||
Identifier attrName = read<Identifier>();
|
||||
StringAttr attrName = read<StringAttr>();
|
||||
Attribute attr = op->getAttr(attrName);
|
||||
|
||||
LLVM_DEBUG(llvm::dbgs() << " * Operation: " << *op << "\n"
|
||||
|
|
|
@ -168,7 +168,7 @@ private:
|
|||
/// A vector containing pointers to uniqued data. The storage is intentionally
|
||||
/// opaque such that we can store a wide range of data types. The types of
|
||||
/// data stored here include:
|
||||
/// * Attribute, Identifier, OperationName, Type
|
||||
/// * Attribute, OperationName, Type
|
||||
std::vector<const void *> uniquedData;
|
||||
|
||||
/// A vector containing the generated bytecode for the matcher.
|
||||
|
|
|
@ -803,7 +803,7 @@ LogicalResult Importer::processFunction(llvm::Function *f) {
|
|||
convertLinkageFromLLVM(f->getLinkage()));
|
||||
|
||||
if (FlatSymbolRefAttr personality = getPersonalityAsAttr(f))
|
||||
fop->setAttr(b.getIdentifier("personality"), personality);
|
||||
fop->setAttr(b.getStringAttr("personality"), personality);
|
||||
else if (f->hasPersonalityFn())
|
||||
emitWarning(UnknownLoc::get(context),
|
||||
"could not deduce personality, skipping it");
|
||||
|
|
|
@ -227,7 +227,7 @@ LogicalResult spirv::Deserializer::processDecoration(ArrayRef<uint32_t> words) {
|
|||
return emitError(unknownLoc, "invalid Decoration code : ") << words[1];
|
||||
}
|
||||
auto attrName = llvm::convertToSnakeFromCamelCase(decorationName);
|
||||
auto symbol = opBuilder.getIdentifier(attrName);
|
||||
auto symbol = opBuilder.getStringAttr(attrName);
|
||||
switch (static_cast<spirv::Decoration>(words[1])) {
|
||||
case spirv::Decoration::DescriptorSet:
|
||||
case spirv::Decoration::Binding:
|
||||
|
@ -1964,7 +1964,7 @@ Location spirv::Deserializer::createFileLineColLoc(OpBuilder opBuilder) {
|
|||
auto fileName = debugInfoMap.lookup(debugLine->fileID).str();
|
||||
if (fileName.empty())
|
||||
fileName = "<unknown>";
|
||||
return FileLineColLoc::get(opBuilder.getIdentifier(fileName), debugLine->line,
|
||||
return FileLineColLoc::get(opBuilder.getStringAttr(fileName), debugLine->line,
|
||||
debugLine->col);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,12 +30,12 @@ static void generateLocationsFromIR(raw_ostream &os, StringRef fileName,
|
|||
op->print(os, state, flags);
|
||||
|
||||
Builder builder(op->getContext());
|
||||
Optional<Identifier> tagIdentifier;
|
||||
Optional<StringAttr> tagIdentifier;
|
||||
if (!tag.empty())
|
||||
tagIdentifier = builder.getIdentifier(tag);
|
||||
tagIdentifier = builder.getStringAttr(tag);
|
||||
|
||||
// Walk and generate new locations for each of the operations.
|
||||
Identifier file = builder.getIdentifier(fileName);
|
||||
StringAttr file = builder.getStringAttr(fileName);
|
||||
op->walk([&](Operation *opIt) {
|
||||
// Check to see if this operation has a mapped location. Some operations may
|
||||
// be elided from the printed form, e.g. the body terminators of some region
|
||||
|
|
|
@ -58,8 +58,8 @@ void TestLinalgDistribution::runOnFunction() {
|
|||
populateLinalgDistributeTiledLoopPattern(
|
||||
distributeTiledLoopsPatterns, getDistributionOptions(),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>{},
|
||||
{Identifier::get("distributed", funcOp.getContext())})
|
||||
ArrayRef<StringAttr>{},
|
||||
{StringAttr::get("distributed", funcOp.getContext())})
|
||||
.addFilter([](Operation *op) {
|
||||
return success(!op->getParentOfType<linalg::TiledLoopOp>());
|
||||
}));
|
||||
|
|
|
@ -31,81 +31,81 @@ static void fillFusionPatterns(MLIRContext *context,
|
|||
LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({2}),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("basic_fusion", context),
|
||||
Identifier::get("after_basic_fusion", context)),
|
||||
StringAttr::get(context, "basic_fusion"),
|
||||
StringAttr::get(context, "after_basic_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_basic_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_basic_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_basic_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_basic_fusion_original")));
|
||||
|
||||
patterns.add<LinalgTileAndFusePattern<MatmulOp>>(
|
||||
context, dependenceGraph,
|
||||
LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({0}),
|
||||
LinalgTransformationFilter(Identifier::get("lhs_fusion", context),
|
||||
Identifier::get("after_lhs_fusion", context)),
|
||||
LinalgTransformationFilter(StringAttr::get(context, "lhs_fusion"),
|
||||
StringAttr::get(context, "after_lhs_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_lhs_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_lhs_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_lhs_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_lhs_fusion_original")));
|
||||
|
||||
patterns.add<LinalgTileAndFusePattern<MatmulOp>>(
|
||||
context, dependenceGraph,
|
||||
LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({2}),
|
||||
LinalgTransformationFilter(Identifier::get("out_fusion", context),
|
||||
Identifier::get("after_out_fusion", context)),
|
||||
LinalgTransformationFilter(StringAttr::get(context, "out_fusion"),
|
||||
StringAttr::get(context, "after_out_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_out_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_out_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_out_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_out_fusion_original")));
|
||||
|
||||
patterns.add<LinalgTileAndFusePattern<MatmulOp>>(
|
||||
context, dependenceGraph,
|
||||
LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({1}),
|
||||
LinalgTransformationFilter(Identifier::get("rhs_fusion", context),
|
||||
Identifier::get("after_rhs_fusion", context)),
|
||||
LinalgTransformationFilter(StringAttr::get(context, "rhs_fusion"),
|
||||
StringAttr::get(context, "after_rhs_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_rhs_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_rhs_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_rhs_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_rhs_fusion_original")));
|
||||
|
||||
patterns.add<LinalgTileAndFusePattern<MatmulOp>>(
|
||||
context, dependenceGraph,
|
||||
LinalgTilingOptions().setTileSizes({32, 64, 16}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({0, 2}),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("two_operand_fusion", context),
|
||||
Identifier::get("after_two_operand_fusion", context)),
|
||||
StringAttr::get(context, "two_operand_fusion"),
|
||||
StringAttr::get(context, "after_two_operand_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_two_operand_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_two_operand_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_two_operand_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_two_operand_fusion_original")));
|
||||
|
||||
patterns.add<LinalgTileAndFusePattern<GenericOp>>(
|
||||
context, dependenceGraph,
|
||||
LinalgTilingOptions().setTileSizes({32, 64}).setLoopType(LoopType),
|
||||
LinalgFusionOptions().setIndicesToFuse({0, 1}),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("transpose_fusion", context),
|
||||
Identifier::get("after_transpose_fusion", context)),
|
||||
StringAttr::get(context, "transpose_fusion"),
|
||||
StringAttr::get(context, "after_transpose_fusion")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_transpose_fusion_producer", context)),
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_transpose_fusion_producer")),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>(),
|
||||
Identifier::get("after_transpose_fusion_original", context)));
|
||||
ArrayRef<StringAttr>(),
|
||||
StringAttr::get(context, "after_transpose_fusion_original")));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
|
@ -145,35 +145,35 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
//===--------------------------------------------------------------------===//
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({2000, 3000, 4000}),
|
||||
LinalgTransformationFilter(Identifier::get("MEM", ctx),
|
||||
Identifier::get("L3", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "MEM"),
|
||||
StringAttr::get(ctx, "L3")));
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({200, 300, 400}),
|
||||
LinalgTransformationFilter(Identifier::get("L3", ctx),
|
||||
Identifier::get("L2", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L3"),
|
||||
StringAttr::get(ctx, "L2")));
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({20, 30, 40}),
|
||||
LinalgTransformationFilter(Identifier::get("L2", ctx),
|
||||
Identifier::get("L1", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L2"),
|
||||
StringAttr::get(ctx, "L1")));
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({2, 3, 4}),
|
||||
LinalgTransformationFilter(Identifier::get("L1", ctx),
|
||||
Identifier::get("REG", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L1"),
|
||||
StringAttr::get(ctx, "REG")));
|
||||
|
||||
patterns.add<LinalgTilingPattern<MatvecOp>>(
|
||||
ctx,
|
||||
LinalgTilingOptions().setTileSizes({5, 6}).setLoopType(
|
||||
LinalgTilingLoopType::ParallelLoops),
|
||||
LinalgTransformationFilter(ArrayRef<Identifier>{},
|
||||
Identifier::get("L1", ctx)));
|
||||
LinalgTransformationFilter(ArrayRef<StringAttr>{},
|
||||
StringAttr::get(ctx, "L1")));
|
||||
|
||||
patterns.add<LinalgTilingPattern<DotOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes(8000),
|
||||
LinalgTransformationFilter(
|
||||
ArrayRef<Identifier>{Identifier::get("MEM", ctx),
|
||||
Identifier::get("L3", ctx),
|
||||
Identifier::get("L2", ctx)},
|
||||
Identifier::get("REG", ctx)));
|
||||
ArrayRef<StringAttr>{StringAttr::get(ctx, "MEM"),
|
||||
StringAttr::get(ctx, "L3"),
|
||||
StringAttr::get(ctx, "L2")},
|
||||
StringAttr::get(ctx, "REG")));
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Linalg tiling and permutation patterns.
|
||||
|
@ -183,24 +183,24 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
LinalgTilingOptions()
|
||||
.setTileSizes({2000, 3000, 4000})
|
||||
.setInterchange({1, 2, 0}),
|
||||
LinalgTransformationFilter(Identifier::get("__with_perm__", ctx),
|
||||
Identifier::get("L2__with_perm__", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "__with_perm__"),
|
||||
StringAttr::get(ctx, "L2__with_perm__")));
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx,
|
||||
LinalgTilingOptions()
|
||||
.setTileSizes({200, 300, 400})
|
||||
.setInterchange({1, 0, 2}),
|
||||
LinalgTransformationFilter(Identifier::get("L2__with_perm__", ctx),
|
||||
Identifier::get("L1__with_perm__", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L2__with_perm__"),
|
||||
StringAttr::get(ctx, "L1__with_perm__")));
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({20, 30, 40}),
|
||||
LinalgTransformationFilter(Identifier::get("L1__with_perm__", ctx),
|
||||
Identifier::get("REG__with_perm__", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L1__with_perm__"),
|
||||
StringAttr::get(ctx, "REG__with_perm__")));
|
||||
|
||||
patterns.add<LinalgTilingPattern<MatvecOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({5, 6}).setInterchange({1, 0}),
|
||||
LinalgTransformationFilter(Identifier::get("__with_perm__", ctx),
|
||||
Identifier::get("L1__with_perm__", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "__with_perm__"),
|
||||
StringAttr::get(ctx, "L1__with_perm__")));
|
||||
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx,
|
||||
|
@ -209,8 +209,8 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
.setInterchange({1, 2, 0})
|
||||
.setLoopType(LinalgTilingLoopType::ParallelLoops),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("par__with_perm__", ctx),
|
||||
Identifier::get("after_par__with_perm__", ctx)));
|
||||
StringAttr::get(ctx, "par__with_perm__"),
|
||||
StringAttr::get(ctx, "after_par__with_perm__")));
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Linalg to loops patterns.
|
||||
|
@ -218,7 +218,7 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
patterns.add<LinalgLoweringPattern<DotOp>>(
|
||||
ctx,
|
||||
/*loweringType=*/LinalgLoweringType::Loops,
|
||||
LinalgTransformationFilter(Identifier::get("REG", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "REG")));
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Linalg distribution patterns.
|
||||
|
@ -229,7 +229,7 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
// Linalg to vector contraction patterns.
|
||||
//===--------------------------------------------------------------------===//
|
||||
patterns.add<LinalgVectorizationPattern>(
|
||||
ctx, LinalgTransformationFilter(Identifier::get("VECTORIZE", ctx))
|
||||
ctx, LinalgTransformationFilter(StringAttr::get(ctx, "VECTORIZE"))
|
||||
.addOpFilter<MatmulOp, FillOp, CopyOp, GenericOp>());
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -238,24 +238,24 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
patterns.add<GenericOpInterchangePattern>(
|
||||
ctx,
|
||||
/*interchangeVector=*/ArrayRef<unsigned>{1, 2, 0},
|
||||
LinalgTransformationFilter(ArrayRef<Identifier>{},
|
||||
Identifier::get("PERMUTED", ctx)));
|
||||
LinalgTransformationFilter(ArrayRef<StringAttr>{},
|
||||
StringAttr::get(ctx, "PERMUTED")));
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Linalg subview operands promotion.
|
||||
//===--------------------------------------------------------------------===//
|
||||
patterns.add<LinalgPromotionPattern<MatmulOp>>(
|
||||
ctx, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true),
|
||||
LinalgTransformationFilter(Identifier::get("_promote_views_", ctx),
|
||||
Identifier::get("_views_promoted_", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "_promote_views_"),
|
||||
StringAttr::get(ctx, "_views_promoted_")));
|
||||
patterns.add<LinalgPromotionPattern<MatmulOp>>(
|
||||
ctx,
|
||||
LinalgPromotionOptions()
|
||||
.setOperandsToPromote({0})
|
||||
.setUseFullTileBuffersByDefault(true),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("_promote_first_view_", ctx),
|
||||
Identifier::get("_first_view_promoted_", ctx)));
|
||||
StringAttr::get(ctx, "_promote_first_view_"),
|
||||
StringAttr::get(ctx, "_first_view_promoted_")));
|
||||
patterns.add<LinalgPromotionPattern<FillOp>>(
|
||||
ctx,
|
||||
LinalgPromotionOptions()
|
||||
|
@ -263,8 +263,8 @@ static void applyPatterns(FuncOp funcOp) {
|
|||
.setUseFullTileBuffers({false, true})
|
||||
.setAlignment(32),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("_promote_views_aligned_", ctx),
|
||||
Identifier::get("_views_aligned_promoted_", ctx)));
|
||||
StringAttr::get(ctx, "_promote_views_aligned_"),
|
||||
StringAttr::get(ctx, "_views_aligned_promoted_")));
|
||||
|
||||
(void)applyPatternsAndFoldGreedily(funcOp, std::move(patterns));
|
||||
|
||||
|
@ -284,20 +284,20 @@ static void fillL1TilingAndMatmulToVectorPatterns(
|
|||
LinalgTilingOptions()
|
||||
.setTileSizes({8, 12, 16})
|
||||
.setInterchange({1, 0, 2}),
|
||||
LinalgTransformationFilter(Identifier::get(startMarker, ctx),
|
||||
Identifier::get("L1", ctx))));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, startMarker),
|
||||
StringAttr::get(ctx, "L1"))));
|
||||
|
||||
patternsVector.emplace_back(
|
||||
ctx,
|
||||
std::make_unique<LinalgPromotionPattern<MatmulOp>>(
|
||||
ctx, LinalgPromotionOptions().setUseFullTileBuffersByDefault(true),
|
||||
LinalgTransformationFilter(Identifier::get("L1", ctx),
|
||||
Identifier::get("VEC", ctx))));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "L1"),
|
||||
StringAttr::get(ctx, "VEC"))));
|
||||
|
||||
patternsVector.emplace_back(
|
||||
ctx, std::make_unique<LinalgVectorizationPattern>(
|
||||
MatmulOp::getOperationName(), ctx, LinalgVectorizationOptions(),
|
||||
LinalgTransformationFilter(Identifier::get("VEC", ctx))));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "VEC"))));
|
||||
patternsVector.back().add<LinalgVectorizationPattern>(
|
||||
ctx, LinalgTransformationFilter().addFilter(
|
||||
[](Operation *op) { return success(isa<FillOp, CopyOp>(op)); }));
|
||||
|
@ -346,8 +346,8 @@ static void fillPromotionCallBackPatterns(MLIRContext *ctx,
|
|||
RewritePatternSet &patterns) {
|
||||
patterns.add<LinalgTilingPattern<MatmulOp>>(
|
||||
ctx, LinalgTilingOptions().setTileSizes({16, 16, 16}),
|
||||
LinalgTransformationFilter(Identifier::get("START", ctx),
|
||||
Identifier::get("PROMOTE", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "START"),
|
||||
StringAttr::get(ctx, "PROMOTE")));
|
||||
patterns.add<LinalgPromotionPattern<MatmulOp>>(
|
||||
ctx,
|
||||
LinalgPromotionOptions()
|
||||
|
@ -361,7 +361,7 @@ static void fillPromotionCallBackPatterns(MLIRContext *ctx,
|
|||
[](OpBuilder &b, Value src, Value dst) -> LogicalResult {
|
||||
return copyCallBackFn(b, src, dst, true);
|
||||
}),
|
||||
LinalgTransformationFilter(Identifier::get("PROMOTE", ctx)));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "PROMOTE")));
|
||||
}
|
||||
|
||||
template <typename IdOp, typename NProcsOp>
|
||||
|
@ -394,8 +394,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsEqNiters),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute1", context),
|
||||
Identifier::get("after_distribute1", context)));
|
||||
StringAttr::get(context, "distribute1"),
|
||||
StringAttr::get(context, "after_distribute1")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -411,8 +411,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsGeNiters),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute2", context),
|
||||
Identifier::get("after_distribute2", context)));
|
||||
StringAttr::get(context, "distribute2"),
|
||||
StringAttr::get(context, "after_distribute2")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -428,8 +428,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsDefault),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute3", context),
|
||||
Identifier::get("after_distribute3", context)));
|
||||
StringAttr::get(context, "distribute3"),
|
||||
StringAttr::get(context, "after_distribute3")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -445,8 +445,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsMixed1),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute4", context),
|
||||
Identifier::get("after_distribute4", context)));
|
||||
StringAttr::get(context, "distribute4"),
|
||||
StringAttr::get(context, "after_distribute4")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -462,8 +462,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsMixed2),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute5", context),
|
||||
Identifier::get("after_distribute5", context)));
|
||||
StringAttr::get(context, "distribute5"),
|
||||
StringAttr::get(context, "after_distribute5")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -480,8 +480,8 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
.setLoopType(LinalgTilingLoopType::ParallelLoops)
|
||||
.setDistributionOptions(cyclicNprocsMixed3),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("distribute6", context),
|
||||
Identifier::get("after_distribute6", context)));
|
||||
StringAttr::get(context, "distribute6"),
|
||||
StringAttr::get(context, "after_distribute6")));
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -495,10 +495,10 @@ static void fillTileAndDistributePatterns(MLIRContext *context,
|
|||
LinalgTilingOptions()
|
||||
.setTileSizes({8, 8, 4})
|
||||
.setLoopType(LinalgTilingLoopType::Loops)
|
||||
.setDistributionOptions(cyclicNprocsEqNiters),
|
||||
.setDistributionOptions(cyclicNprocsEqNiters),
|
||||
LinalgTransformationFilter(
|
||||
Identifier::get("tensors_distribute1", context),
|
||||
Identifier::get("tensors_after_distribute1", context)));
|
||||
StringAttr::get(context, "tensors_distribute1"),
|
||||
StringAttr::get(context, "tensors_after_distribute1")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,8 +517,8 @@ applyMatmulToVectorPatterns(FuncOp funcOp,
|
|||
LinalgTilingOptions()
|
||||
.setTileSizes({768, 264, 768})
|
||||
.setInterchange({1, 2, 0}),
|
||||
LinalgTransformationFilter(Identifier::get("START", ctx),
|
||||
Identifier::get("L2", ctx))));
|
||||
LinalgTransformationFilter(StringAttr::get(ctx, "START"),
|
||||
StringAttr::get(ctx, "L2"))));
|
||||
fillL1TilingAndMatmulToVectorPatterns(funcOp, "L2", stage1Patterns);
|
||||
}
|
||||
{
|
||||
|
@ -598,7 +598,7 @@ static void applyTilePattern(FuncOp funcOp, std::string loopType,
|
|||
tilingPattern.add<linalg::LinalgTilingPattern<linalg::MatmulOp>,
|
||||
linalg::LinalgTilingPattern<linalg::GenericOp>>(
|
||||
context, linalgTilingOptions,
|
||||
linalg::LinalgTransformationFilter(Identifier::get("tile", context)));
|
||||
linalg::LinalgTransformationFilter(StringAttr::get(context, "tile")));
|
||||
(void)applyPatternsAndFoldGreedily(funcOp, std::move(tilingPattern));
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ void ReportShapeFnPass::runOnOperation() {
|
|||
auto module = getOperation();
|
||||
|
||||
// Report the shape function available to refine the op.
|
||||
auto shapeFnId = Identifier::get("shape.function", &getContext());
|
||||
auto shapeFnId = StringAttr::get(&getContext(), "shape.function");
|
||||
auto remarkShapeFn = [&](shape::FunctionLibraryOp shapeFnLib, Operation *op) {
|
||||
if (op->hasTrait<OpTrait::IsTerminator>())
|
||||
return true;
|
||||
|
|
|
@ -963,7 +963,7 @@ static ParseResult parseStringAttrPrettyNameOp(OpAsmParser &parser,
|
|||
}
|
||||
|
||||
auto namesAttr = parser.getBuilder().getStrArrayAttr(names);
|
||||
result.attributes.push_back({Identifier::get("names", context), namesAttr});
|
||||
result.attributes.push_back({StringAttr::get(context, "names"), namesAttr});
|
||||
return success();
|
||||
}
|
||||
|
||||
|
|
|
@ -43,19 +43,19 @@ def AOp : NS_Op<"a_op", []> {
|
|||
// DECL-SAME: {::llvm::StringRef("aAttr"), ::llvm::StringRef("bAttr"), ::llvm::StringRef("cAttr")};
|
||||
// DECL-NEXT: return ::llvm::makeArrayRef(attrNames);
|
||||
|
||||
// DECL: ::mlir::Identifier aAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr aAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(0);
|
||||
// DECL: ::mlir::Identifier aAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr aAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 0);
|
||||
|
||||
// DECL: ::mlir::Identifier bAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr bAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(1);
|
||||
// DECL: ::mlir::Identifier bAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr bAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 1);
|
||||
|
||||
// DECL: ::mlir::Identifier cAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr cAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(2);
|
||||
// DECL: ::mlir::Identifier cAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr cAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 2);
|
||||
|
||||
// DEF-LABEL: AOp definitions
|
||||
|
@ -157,19 +157,19 @@ def AgetOp : Op<Test2_Dialect, "a_get_op", []> {
|
|||
// DECL-SAME: {::llvm::StringRef("aAttr"), ::llvm::StringRef("bAttr"), ::llvm::StringRef("cAttr")};
|
||||
// DECL-NEXT: return ::llvm::makeArrayRef(attrNames);
|
||||
|
||||
// DECL: ::mlir::Identifier getAAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr getAAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(0);
|
||||
// DECL: ::mlir::Identifier getAAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr getAAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 0);
|
||||
|
||||
// DECL: ::mlir::Identifier getBAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr getBAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(1);
|
||||
// DECL: ::mlir::Identifier getBAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr getBAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 1);
|
||||
|
||||
// DECL: ::mlir::Identifier getCAttrAttrName()
|
||||
// DECL: ::mlir::StringAttr getCAttrAttrName()
|
||||
// DECL-NEXT: return getAttributeNameForIndex(2);
|
||||
// DECL: ::mlir::Identifier getCAttrAttrName(::mlir::OperationName name)
|
||||
// DECL: ::mlir::StringAttr getCAttrAttrName(::mlir::OperationName name)
|
||||
// DECL-NEXT: return getAttributeNameForIndex(name, 2);
|
||||
|
||||
// DEF-LABEL: AgetOp definitions
|
||||
|
|
|
@ -1092,7 +1092,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
genContext.setLoc(NameLoc::get(
|
||||
Identifier::get(opConfig.metadata->cppClassName, &mlirContext)));
|
||||
StringAttr::get(&mlirContext, opConfig.metadata->cppClassName)));
|
||||
if (failed(generateOp(opConfig, genContext))) {
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -655,7 +655,7 @@ void OpEmitter::genAttrNameGetters() {
|
|||
// Emit the getAttributeNameForIndex methods.
|
||||
{
|
||||
auto *method = opClass.addInlineMethod<Method::MP_Private>(
|
||||
"::mlir::Identifier", "getAttributeNameForIndex",
|
||||
"::mlir::StringAttr", "getAttributeNameForIndex",
|
||||
MethodParameter("unsigned", "index"));
|
||||
ERROR_IF_PRUNED(method, "getAttributeNameForIndex", op);
|
||||
method->body()
|
||||
|
@ -663,7 +663,7 @@ void OpEmitter::genAttrNameGetters() {
|
|||
}
|
||||
{
|
||||
auto *method = opClass.addStaticInlineMethod<Method::MP_Private>(
|
||||
"::mlir::Identifier", "getAttributeNameForIndex",
|
||||
"::mlir::StringAttr", "getAttributeNameForIndex",
|
||||
MethodParameter("::mlir::OperationName", "name"),
|
||||
MethodParameter("unsigned", "index"));
|
||||
ERROR_IF_PRUNED(method, "getAttributeNameForIndex", op);
|
||||
|
@ -683,7 +683,7 @@ void OpEmitter::genAttrNameGetters() {
|
|||
// Generate the non-static variant.
|
||||
{
|
||||
auto *method =
|
||||
opClass.addInlineMethod("::mlir::Identifier", methodName);
|
||||
opClass.addInlineMethod("::mlir::StringAttr", methodName);
|
||||
ERROR_IF_PRUNED(method, methodName, op);
|
||||
method->body()
|
||||
<< llvm::formatv(attrNameMethodBody, attrIt.second).str();
|
||||
|
@ -692,7 +692,7 @@ void OpEmitter::genAttrNameGetters() {
|
|||
// Generate the static variant.
|
||||
{
|
||||
auto *method = opClass.addStaticInlineMethod(
|
||||
"::mlir::Identifier", methodName,
|
||||
"::mlir::StringAttr", methodName,
|
||||
MethodParameter("::mlir::OperationName", "name"));
|
||||
ERROR_IF_PRUNED(method, methodName, op);
|
||||
method->body() << llvm::formatv(attrNameMethodBody,
|
||||
|
|
|
@ -1145,7 +1145,7 @@ std::string PatternEmitter::handleLocationDirective(DagNode tree) {
|
|||
if (tree.getNumArgs() == 1) {
|
||||
DagLeaf leaf = tree.getArgAsLeaf(0);
|
||||
if (leaf.isStringAttr())
|
||||
return formatv("::mlir::NameLoc::get(rewriter.getIdentifier(\"{0}\"))",
|
||||
return formatv("::mlir::NameLoc::get(rewriter.getStringAttr(\"{0}\"))",
|
||||
leaf.getStringAttr())
|
||||
.str();
|
||||
return lookUpArgLoc(0);
|
||||
|
@ -1607,7 +1607,7 @@ void PatternEmitter::createAggregateLocalVarsForOpArgs(
|
|||
|
||||
const char *addAttrCmd =
|
||||
"if (auto tmpAttr = {1}) {\n"
|
||||
" tblgen_attrs.emplace_back(rewriter.getIdentifier(\"{0}\"), "
|
||||
" tblgen_attrs.emplace_back(rewriter.getStringAttr(\"{0}\"), "
|
||||
"tmpAttr);\n}\n";
|
||||
for (int argIndex = 0, e = resultOp.getNumArgs(); argIndex < e; ++argIndex) {
|
||||
if (resultOp.getArg(argIndex).is<NamedAttribute *>()) {
|
||||
|
|
|
@ -131,13 +131,13 @@ static void emitFactoryDef(llvm::StringRef structName,
|
|||
|
||||
const char *getFieldInfo = R"(
|
||||
assert({0});
|
||||
auto {0}_id = ::mlir::Identifier::get("{0}", context);
|
||||
auto {0}_id = ::mlir::StringAttr::get(context, "{0}");
|
||||
fields.emplace_back({0}_id, {0});
|
||||
)";
|
||||
|
||||
const char *getFieldInfoOptional = R"(
|
||||
if ({0}) {
|
||||
auto {0}_id = ::mlir::Identifier::get("{0}", context);
|
||||
auto {0}_id = ::mlir::StringAttr::get(context, "{0}");
|
||||
fields.emplace_back({0}_id, {0});
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include "mlir/IR/BuiltinAttributes.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace mlir;
|
||||
|
@ -152,7 +151,7 @@ TEST(DenseSplatTest, StringSplat) {
|
|||
MLIRContext context;
|
||||
context.allowUnregisteredDialects();
|
||||
Type stringType =
|
||||
OpaqueType::get(Identifier::get("test", &context), "string");
|
||||
OpaqueType::get(StringAttr::get(&context, "test"), "string");
|
||||
StringRef value = "test-string";
|
||||
testSplat(stringType, value);
|
||||
}
|
||||
|
@ -161,7 +160,7 @@ TEST(DenseSplatTest, StringAttrSplat) {
|
|||
MLIRContext context;
|
||||
context.allowUnregisteredDialects();
|
||||
Type stringType =
|
||||
OpaqueType::get(Identifier::get("test", &context), "string");
|
||||
OpaqueType::get(StringAttr::get(&context, "test"), "string");
|
||||
Attribute stringAttr = StringAttr::get("test-string", stringType);
|
||||
testSplat(stringType, stringAttr);
|
||||
}
|
||||
|
@ -211,7 +210,7 @@ TEST(SparseElementsAttrTest, GetZero) {
|
|||
|
||||
IntegerType intTy = IntegerType::get(&context, 32);
|
||||
FloatType floatTy = FloatType::getF32(&context);
|
||||
Type stringTy = OpaqueType::get(Identifier::get("test", &context), "string");
|
||||
Type stringTy = OpaqueType::get(StringAttr::get(&context, "test"), "string");
|
||||
|
||||
ShapedType tensorI32 = RankedTensorType::get({2, 2}, intTy);
|
||||
ShapedType tensorF32 = RankedTensorType::get({2, 2}, floatTy);
|
||||
|
|
|
@ -237,10 +237,10 @@ TEST(NamedAttrListTest, TestAppendAssign) {
|
|||
|
||||
{
|
||||
auto it = attrs.begin();
|
||||
EXPECT_EQ(it->first, b.getIdentifier("foo"));
|
||||
EXPECT_EQ(it->first, b.getStringAttr("foo"));
|
||||
EXPECT_EQ(it->second, b.getStringAttr("bar"));
|
||||
++it;
|
||||
EXPECT_EQ(it->first, b.getIdentifier("baz"));
|
||||
EXPECT_EQ(it->first, b.getStringAttr("baz"));
|
||||
EXPECT_EQ(it->second, b.getStringAttr("boo"));
|
||||
}
|
||||
|
||||
|
@ -261,10 +261,10 @@ TEST(NamedAttrListTest, TestAppendAssign) {
|
|||
|
||||
{
|
||||
auto it = attrs.begin();
|
||||
EXPECT_EQ(it->first, b.getIdentifier("foo"));
|
||||
EXPECT_EQ(it->first, b.getStringAttr("foo"));
|
||||
EXPECT_EQ(it->second, b.getStringAttr("f"));
|
||||
++it;
|
||||
EXPECT_EQ(it->first, b.getIdentifier("zoo"));
|
||||
EXPECT_EQ(it->first, b.getStringAttr("zoo"));
|
||||
EXPECT_EQ(it->second, b.getStringAttr("z"));
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Dialect.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include <vector>
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
#include "mlir/IR/Attributes.h"
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinTypes.h"
|
||||
#include "mlir/IR/Identifier.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
@ -62,7 +61,7 @@ TEST(StructsGenTest, ClassofExtraFalse) {
|
|||
expectedValues.end());
|
||||
|
||||
// Add an extra NamedAttribute.
|
||||
auto wrongId = mlir::Identifier::get("wrong", &context);
|
||||
auto wrongId = mlir::StringAttr::get(&context, "wrong");
|
||||
auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second);
|
||||
newValues.push_back(wrongAttr);
|
||||
|
||||
|
@ -83,8 +82,8 @@ TEST(StructsGenTest, ClassofBadNameFalse) {
|
|||
llvm::SmallVector<mlir::NamedAttribute, 4> newValues(
|
||||
expectedValues.begin() + 1, expectedValues.end());
|
||||
|
||||
// Add a copy of the first attribute with the wrong Identifier.
|
||||
auto wrongId = mlir::Identifier::get("wrong", &context);
|
||||
// Add a copy of the first attribute with the wrong name.
|
||||
auto wrongId = mlir::StringAttr::get(&context, "wrong");
|
||||
auto wrongAttr = mlir::NamedAttribute(wrongId, expectedValues[0].second);
|
||||
newValues.push_back(wrongAttr);
|
||||
|
||||
|
@ -109,7 +108,7 @@ TEST(StructsGenTest, ClassofBadTypeFalse) {
|
|||
auto elementsType = mlir::RankedTensorType::get({3}, i64Type);
|
||||
auto elementsAttr =
|
||||
mlir::DenseIntElementsAttr::get(elementsType, ArrayRef<int64_t>{1, 2, 3});
|
||||
mlir::Identifier id = expectedValues.back().first;
|
||||
mlir::StringAttr id = expectedValues.back().first;
|
||||
auto wrongAttr = mlir::NamedAttribute(id, elementsAttr);
|
||||
newValues.push_back(wrongAttr);
|
||||
|
||||
|
|
|
@ -3,20 +3,6 @@
|
|||
import gdb.printing
|
||||
|
||||
|
||||
class IdentifierPrinter:
|
||||
"""Prints an mlir::Identifier instance."""
|
||||
|
||||
def __init__(self, val):
|
||||
self.entry = val['entry']
|
||||
|
||||
def to_string(self):
|
||||
ptr = (self.entry + 1).cast(gdb.lookup_type('char').pointer())
|
||||
return ptr.string(length=self.entry['keyLength'])
|
||||
|
||||
def display_hint(self):
|
||||
return 'string'
|
||||
|
||||
|
||||
class StoragePrinter:
|
||||
"""Prints bases of a struct and its fields."""
|
||||
|
||||
|
@ -159,8 +145,6 @@ def get_attr_or_type_printer(val, get_type_id):
|
|||
|
||||
pp = gdb.printing.RegexpCollectionPrettyPrinter('MLIRSupport')
|
||||
|
||||
pp.add_printer('mlir::Identifier', '^mlir::Identifier$', IdentifierPrinter)
|
||||
|
||||
# Printers for types deriving from AttributeStorage or TypeStorage.
|
||||
pp.add_printer('mlir::detail::FusedLocationStorage',
|
||||
'^mlir::detail::FusedLocationStorage',
|
||||
|
|
Loading…
Reference in New Issue