2018-10-26 06:46:10 +08:00
|
|
|
//===- Attributes.cpp - MLIR Affine Expr Classes --------------------------===//
|
|
|
|
//
|
2020-01-26 11:58:30 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
2019-12-24 01:35:36 +08:00
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-10-26 06:46:10 +08:00
|
|
|
//
|
2019-12-24 01:35:36 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-10-26 06:46:10 +08:00
|
|
|
|
|
|
|
#include "mlir/IR/Attributes.h"
|
2019-02-12 14:51:34 +08:00
|
|
|
#include "mlir/IR/Dialect.h"
|
2018-10-26 06:46:10 +08:00
|
|
|
|
|
|
|
using namespace mlir;
|
|
|
|
using namespace mlir::detail;
|
|
|
|
|
2019-05-03 05:02:57 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Attribute
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-05-07 03:40:43 +08:00
|
|
|
/// Return the context this attribute belongs to.
|
2020-12-18 09:10:12 +08:00
|
|
|
MLIRContext *Attribute::getContext() const { return getDialect().getContext(); }
|
2019-05-07 03:40:43 +08:00
|
|
|
|
2019-05-16 00:10:52 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2020-12-04 09:22:57 +08:00
|
|
|
// NamedAttribute
|
2019-05-16 00:10:52 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2021-11-18 13:23:32 +08:00
|
|
|
NamedAttribute::NamedAttribute(StringAttr name, Attribute value)
|
|
|
|
: name(name), value(value) {
|
|
|
|
assert(name && value && "expected valid attribute name and value");
|
|
|
|
assert(name.size() != 0 && "expected valid attribute name");
|
2020-05-07 04:48:36 +08:00
|
|
|
}
|
2021-11-18 13:23:32 +08:00
|
|
|
|
|
|
|
StringAttr NamedAttribute::getName() const { return name.cast<StringAttr>(); }
|
|
|
|
|
|
|
|
Dialect *NamedAttribute::getNameDialect() const {
|
|
|
|
return getName().getReferencedDialect();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NamedAttribute::setName(StringAttr newName) {
|
|
|
|
assert(name && "expected valid attribute name");
|
|
|
|
name = newName;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NamedAttribute::operator<(const NamedAttribute &rhs) const {
|
|
|
|
return getName().compare(rhs.getName()) < 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool NamedAttribute::operator<(StringRef rhs) const {
|
|
|
|
return getName().getValue().compare(rhs) < 0;
|
2020-05-07 04:48:36 +08:00
|
|
|
}
|