summaryrefslogtreecommitdiffstats
path: root/mlir/lib/IR/Attributes.cpp
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-06-18 16:41:00 -0700
committerMehdi Amini <joker.eph@gmail.com>2019-06-19 23:07:24 -0700
commit18743a33ac0caf08b69f097383c176a8a653e4f5 (patch)
tree6aa4e3a0b692c3222d086aa57f8fd53694e966f7 /mlir/lib/IR/Attributes.cpp
parent34cb51743d906e8475b44bc603a8f164b5f11f3a (diff)
downloadbcm5719-llvm-18743a33ac0caf08b69f097383c176a8a653e4f5.tar.gz
bcm5719-llvm-18743a33ac0caf08b69f097383c176a8a653e4f5.zip
NFC: Reorder the attribute classes alphabetically to improve readability.
PiperOrigin-RevId: 253894445
Diffstat (limited to 'mlir/lib/IR/Attributes.cpp')
-rw-r--r--mlir/lib/IR/Attributes.cpp214
1 files changed, 107 insertions, 107 deletions
diff --git a/mlir/lib/IR/Attributes.cpp b/mlir/lib/IR/Attributes.cpp
index bbf89958213..ce33508830c 100644
--- a/mlir/lib/IR/Attributes.cpp
+++ b/mlir/lib/IR/Attributes.cpp
@@ -57,41 +57,26 @@ MLIRContext *Attribute::getContext() const { return getType().getContext(); }
Dialect &Attribute::getDialect() const { return impl->getDialect(); }
//===----------------------------------------------------------------------===//
-// OpaqueAttr
+// AffineMapAttr
//===----------------------------------------------------------------------===//
-OpaqueAttr OpaqueAttr::get(Identifier dialect, StringRef attrData,
- MLIRContext *context) {
- return Base::get(context, StandardAttributes::Opaque, dialect, attrData);
-}
-
-OpaqueAttr OpaqueAttr::getChecked(Identifier dialect, StringRef attrData,
- MLIRContext *context, Location location) {
- return Base::getChecked(location, context, StandardAttributes::Opaque,
- dialect, attrData);
+AffineMapAttr AffineMapAttr::get(AffineMap value) {
+ return Base::get(value.getResult(0).getContext(),
+ StandardAttributes::AffineMap, value);
}
-/// Returns the dialect namespace of the opaque attribute.
-Identifier OpaqueAttr::getDialectNamespace() const {
- return getImpl()->dialectNamespace;
-}
+AffineMap AffineMapAttr::getValue() const { return getImpl()->value; }
-/// Returns the raw attribute data of the opaque attribute.
-StringRef OpaqueAttr::getAttrData() const { return getImpl()->attrData; }
+//===----------------------------------------------------------------------===//
+// ArrayAttr
+//===----------------------------------------------------------------------===//
-/// Verify the construction of an opaque attribute.
-LogicalResult OpaqueAttr::verifyConstructionInvariants(
- llvm::Optional<Location> loc, MLIRContext *context, Identifier dialect,
- StringRef attrData) {
- if (!Dialect::isValidNamespace(dialect.strref())) {
- if (loc)
- context->emitError(*loc)
- << "invalid dialect namespace '" << dialect << "'";
- return failure();
- }
- return success();
+ArrayAttr ArrayAttr::get(ArrayRef<Attribute> value, MLIRContext *context) {
+ return Base::get(context, StandardAttributes::Array, value);
}
+ArrayRef<Attribute> ArrayAttr::getValue() const { return getImpl()->value; }
+
//===----------------------------------------------------------------------===//
// BoolAttr
//===----------------------------------------------------------------------===//
@@ -196,27 +181,6 @@ DictionaryAttr::iterator DictionaryAttr::end() const {
size_t DictionaryAttr::size() const { return getValue().size(); }
//===----------------------------------------------------------------------===//
-// IntegerAttr
-//===----------------------------------------------------------------------===//
-
-IntegerAttr IntegerAttr::get(Type type, const APInt &value) {
- return Base::get(type.getContext(), StandardAttributes::Integer, type, value);
-}
-
-IntegerAttr IntegerAttr::get(Type type, int64_t value) {
- // This uses 64 bit APInts by default for index type.
- if (type.isIndex())
- return get(type, APInt(64, value));
-
- auto intType = type.cast<IntegerType>();
- return get(type, APInt(intType.getWidth(), value));
-}
-
-APInt IntegerAttr::getValue() const { return getImpl()->getValue(); }
-
-int64_t IntegerAttr::getInt() const { return getValue().getSExtValue(); }
-
-//===----------------------------------------------------------------------===//
// FloatAttr
//===----------------------------------------------------------------------===//
@@ -287,35 +251,40 @@ FloatAttr::verifyConstructionInvariants(llvm::Optional<Location> loc,
}
//===----------------------------------------------------------------------===//
-// StringAttr
+// FunctionAttr
//===----------------------------------------------------------------------===//
-StringAttr StringAttr::get(StringRef bytes, MLIRContext *context) {
- return Base::get(context, StandardAttributes::String, bytes);
+FunctionAttr FunctionAttr::get(Function *value) {
+ assert(value && "Cannot get FunctionAttr for a null function");
+ return get(value->getName(), value->getContext());
}
-StringRef StringAttr::getValue() const { return getImpl()->value; }
+FunctionAttr FunctionAttr::get(StringRef value, MLIRContext *ctx) {
+ return Base::get(ctx, StandardAttributes::Function, value);
+}
+
+StringRef FunctionAttr::getValue() const { return getImpl()->value; }
//===----------------------------------------------------------------------===//
-// ArrayAttr
+// IntegerAttr
//===----------------------------------------------------------------------===//
-ArrayAttr ArrayAttr::get(ArrayRef<Attribute> value, MLIRContext *context) {
- return Base::get(context, StandardAttributes::Array, value);
+IntegerAttr IntegerAttr::get(Type type, const APInt &value) {
+ return Base::get(type.getContext(), StandardAttributes::Integer, type, value);
}
-ArrayRef<Attribute> ArrayAttr::getValue() const { return getImpl()->value; }
-
-//===----------------------------------------------------------------------===//
-// AffineMapAttr
-//===----------------------------------------------------------------------===//
+IntegerAttr IntegerAttr::get(Type type, int64_t value) {
+ // This uses 64 bit APInts by default for index type.
+ if (type.isIndex())
+ return get(type, APInt(64, value));
-AffineMapAttr AffineMapAttr::get(AffineMap value) {
- return Base::get(value.getResult(0).getContext(),
- StandardAttributes::AffineMap, value);
+ auto intType = type.cast<IntegerType>();
+ return get(type, APInt(intType.getWidth(), value));
}
-AffineMap AffineMapAttr::getValue() const { return getImpl()->value; }
+APInt IntegerAttr::getValue() const { return getImpl()->getValue(); }
+
+int64_t IntegerAttr::getInt() const { return getValue().getSExtValue(); }
//===----------------------------------------------------------------------===//
// IntegerSetAttr
@@ -329,29 +298,60 @@ IntegerSetAttr IntegerSetAttr::get(IntegerSet value) {
IntegerSet IntegerSetAttr::getValue() const { return getImpl()->value; }
//===----------------------------------------------------------------------===//
-// TypeAttr
+// OpaqueAttr
//===----------------------------------------------------------------------===//
-TypeAttr TypeAttr::get(Type value) {
- return Base::get(value.getContext(), StandardAttributes::Type, value);
+OpaqueAttr OpaqueAttr::get(Identifier dialect, StringRef attrData,
+ MLIRContext *context) {
+ return Base::get(context, StandardAttributes::Opaque, dialect, attrData);
}
-Type TypeAttr::getValue() const { return getImpl()->value; }
+OpaqueAttr OpaqueAttr::getChecked(Identifier dialect, StringRef attrData,
+ MLIRContext *context, Location location) {
+ return Base::getChecked(location, context, StandardAttributes::Opaque,
+ dialect, attrData);
+}
+
+/// Returns the dialect namespace of the opaque attribute.
+Identifier OpaqueAttr::getDialectNamespace() const {
+ return getImpl()->dialectNamespace;
+}
+
+/// Returns the raw attribute data of the opaque attribute.
+StringRef OpaqueAttr::getAttrData() const { return getImpl()->attrData; }
+
+/// Verify the construction of an opaque attribute.
+LogicalResult OpaqueAttr::verifyConstructionInvariants(
+ llvm::Optional<Location> loc, MLIRContext *context, Identifier dialect,
+ StringRef attrData) {
+ if (!Dialect::isValidNamespace(dialect.strref())) {
+ if (loc)
+ context->emitError(*loc)
+ << "invalid dialect namespace '" << dialect << "'";
+ return failure();
+ }
+ return success();
+}
//===----------------------------------------------------------------------===//
-// FunctionAttr
+// StringAttr
//===----------------------------------------------------------------------===//
-FunctionAttr FunctionAttr::get(Function *value) {
- assert(value && "Cannot get FunctionAttr for a null function");
- return get(value->getName(), value->getContext());
+StringAttr StringAttr::get(StringRef bytes, MLIRContext *context) {
+ return Base::get(context, StandardAttributes::String, bytes);
}
-FunctionAttr FunctionAttr::get(StringRef value, MLIRContext *ctx) {
- return Base::get(ctx, StandardAttributes::Function, value);
+StringRef StringAttr::getValue() const { return getImpl()->value; }
+
+//===----------------------------------------------------------------------===//
+// TypeAttr
+//===----------------------------------------------------------------------===//
+
+TypeAttr TypeAttr::get(Type value) {
+ return Base::get(value.getContext(), StandardAttributes::Type, value);
}
-StringRef FunctionAttr::getValue() const { return getImpl()->value; }
+Type TypeAttr::getValue() const { return getImpl()->value; }
//===----------------------------------------------------------------------===//
// ElementsAttr
@@ -399,28 +399,6 @@ ElementsAttr ElementsAttr::mapValues(
}
//===----------------------------------------------------------------------===//
-// SplatElementsAttr
-//===----------------------------------------------------------------------===//
-
-SplatElementsAttr SplatElementsAttr::get(ShapedType type, Attribute elt) {
- return DenseElementsAttr::get(type, elt).cast<SplatElementsAttr>();
-}
-
-SplatElementsAttr SplatElementsAttr::mapValues(
- Type newElementType,
- llvm::function_ref<APInt(const APInt &)> mapping) const {
- return DenseElementsAttr::mapValues(newElementType, mapping)
- .cast<SplatElementsAttr>();
-}
-
-SplatElementsAttr SplatElementsAttr::mapValues(
- Type newElementType,
- llvm::function_ref<APInt(const APFloat &)> mapping) const {
- return DenseElementsAttr::mapValues(newElementType, mapping)
- .cast<SplatElementsAttr>();
-}
-
-//===----------------------------------------------------------------------===//
// DenseElementAttr Utilities
//===----------------------------------------------------------------------===//
@@ -787,7 +765,7 @@ DenseElementsAttr DenseElementsAttr::mapValues(
}
//===----------------------------------------------------------------------===//
-// DenseIntElementsAttr
+// DenseFPElementsAttr
//===----------------------------------------------------------------------===//
template <typename Fn, typename Attr>
@@ -820,9 +798,9 @@ static ShapedType mappingHelper(Fn mapping, Attr &attr, ShapedType inType,
return newArrayType;
}
-DenseElementsAttr DenseIntElementsAttr::mapValues(
+DenseElementsAttr DenseFPElementsAttr::mapValues(
Type newElementType,
- llvm::function_ref<APInt(const APInt &)> mapping) const {
+ llvm::function_ref<APInt(const APFloat &)> mapping) const {
llvm::SmallVector<char, 8> elementData;
auto newArrayType =
mappingHelper(mapping, *this, getType(), newElementType, elementData);
@@ -831,18 +809,18 @@ DenseElementsAttr DenseIntElementsAttr::mapValues(
}
/// Method for supporting type inquiry through isa, cast and dyn_cast.
-bool DenseIntElementsAttr::classof(Attribute attr) {
+bool DenseFPElementsAttr::classof(Attribute attr) {
return attr.isa<DenseElementsAttr>() &&
- attr.getType().cast<ShapedType>().getElementType().isa<IntegerType>();
+ attr.getType().cast<ShapedType>().getElementType().isa<FloatType>();
}
//===----------------------------------------------------------------------===//
-// DenseFPElementsAttr
+// DenseIntElementsAttr
//===----------------------------------------------------------------------===//
-DenseElementsAttr DenseFPElementsAttr::mapValues(
+DenseElementsAttr DenseIntElementsAttr::mapValues(
Type newElementType,
- llvm::function_ref<APInt(const APFloat &)> mapping) const {
+ llvm::function_ref<APInt(const APInt &)> mapping) const {
llvm::SmallVector<char, 8> elementData;
auto newArrayType =
mappingHelper(mapping, *this, getType(), newElementType, elementData);
@@ -851,9 +829,9 @@ DenseElementsAttr DenseFPElementsAttr::mapValues(
}
/// Method for supporting type inquiry through isa, cast and dyn_cast.
-bool DenseFPElementsAttr::classof(Attribute attr) {
+bool DenseIntElementsAttr::classof(Attribute attr) {
return attr.isa<DenseElementsAttr>() &&
- attr.getType().cast<ShapedType>().getElementType().isa<FloatType>();
+ attr.getType().cast<ShapedType>().getElementType().isa<IntegerType>();
}
//===----------------------------------------------------------------------===//
@@ -963,6 +941,28 @@ Attribute SparseElementsAttr::getValue(ArrayRef<uint64_t> index) const {
}
//===----------------------------------------------------------------------===//
+// SplatElementsAttr
+//===----------------------------------------------------------------------===//
+
+SplatElementsAttr SplatElementsAttr::get(ShapedType type, Attribute elt) {
+ return DenseElementsAttr::get(type, elt).cast<SplatElementsAttr>();
+}
+
+SplatElementsAttr SplatElementsAttr::mapValues(
+ Type newElementType,
+ llvm::function_ref<APInt(const APInt &)> mapping) const {
+ return DenseElementsAttr::mapValues(newElementType, mapping)
+ .cast<SplatElementsAttr>();
+}
+
+SplatElementsAttr SplatElementsAttr::mapValues(
+ Type newElementType,
+ llvm::function_ref<APInt(const APFloat &)> mapping) const {
+ return DenseElementsAttr::mapValues(newElementType, mapping)
+ .cast<SplatElementsAttr>();
+}
+
+//===----------------------------------------------------------------------===//
// NamedAttributeList
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud