440 lines
16 KiB
C++
440 lines
16 KiB
C++
/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
|
|
|* *|
|
|
|* AttrDef Definitions *|
|
|
|* *|
|
|
|* Automatically generated file, do not edit! *|
|
|
|* *|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
#ifdef GET_ATTRDEF_LIST
|
|
#undef GET_ATTRDEF_LIST
|
|
|
|
::mlir::DataLayoutEntryAttr,
|
|
::mlir::DataLayoutSpecAttr,
|
|
::mlir::MapAttr,
|
|
::mlir::TargetSystemSpecAttr,
|
|
::mlir::TargetDeviceSpecAttr,
|
|
::mlir::FunctionPointerAlignmentAttr
|
|
|
|
#endif // GET_ATTRDEF_LIST
|
|
|
|
#ifdef GET_ATTRDEF_CLASSES
|
|
#undef GET_ATTRDEF_CLASSES
|
|
|
|
static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
|
|
return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
|
|
.Case(::mlir::DataLayoutEntryAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::DataLayoutEntryAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Case(::mlir::DataLayoutSpecAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::DataLayoutSpecAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Case(::mlir::MapAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::MapAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Case(::mlir::TargetSystemSpecAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::TargetSystemSpecAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Case(::mlir::TargetDeviceSpecAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::TargetDeviceSpecAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Case(::mlir::FunctionPointerAlignmentAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
|
|
value = ::mlir::FunctionPointerAlignmentAttr::parse(parser, type);
|
|
return ::mlir::success(!!value);
|
|
})
|
|
.Default([&](llvm::StringRef keyword, llvm::SMLoc) {
|
|
*mnemonic = keyword;
|
|
return std::nullopt;
|
|
});
|
|
}
|
|
|
|
static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
|
|
return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::DataLayoutEntryAttr>([&](auto t) {
|
|
printer << ::mlir::DataLayoutEntryAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Case<::mlir::DataLayoutSpecAttr>([&](auto t) {
|
|
printer << ::mlir::DataLayoutSpecAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Case<::mlir::MapAttr>([&](auto t) {
|
|
printer << ::mlir::MapAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Case<::mlir::TargetSystemSpecAttr>([&](auto t) {
|
|
printer << ::mlir::TargetSystemSpecAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Case<::mlir::TargetDeviceSpecAttr>([&](auto t) {
|
|
printer << ::mlir::TargetDeviceSpecAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Case<::mlir::FunctionPointerAlignmentAttr>([&](auto t) {
|
|
printer << ::mlir::FunctionPointerAlignmentAttr::getMnemonic();
|
|
t.print(printer);
|
|
return ::mlir::success();
|
|
})
|
|
.Default([](auto) { return ::mlir::failure(); });
|
|
}
|
|
|
|
namespace mlir {
|
|
|
|
DataLayoutEntryAttr DataLayoutEntryAttr::get(::mlir::MLIRContext *context, DataLayoutEntryKey key, Attribute value) {
|
|
return Base::get(context, std::move(key), std::move(value));
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::DataLayoutEntryAttr)
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
struct DataLayoutSpecAttrStorage : public ::mlir::AttributeStorage {
|
|
using KeyTy = std::tuple<::llvm::ArrayRef<DataLayoutEntryInterface>>;
|
|
DataLayoutSpecAttrStorage(::llvm::ArrayRef<DataLayoutEntryInterface> entries) : entries(std::move(entries)) {}
|
|
|
|
KeyTy getAsKey() const {
|
|
return KeyTy(entries);
|
|
}
|
|
|
|
bool operator==(const KeyTy &tblgenKey) const {
|
|
return (entries == std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
|
|
return ::llvm::hash_combine(std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static DataLayoutSpecAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
|
|
auto entries = std::move(std::get<0>(tblgenKey));
|
|
entries = allocator.copyInto(entries);
|
|
return new (allocator.allocate<DataLayoutSpecAttrStorage>()) DataLayoutSpecAttrStorage(std::move(entries));
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> entries;
|
|
};
|
|
|
|
} // namespace detail
|
|
DataLayoutSpecAttr DataLayoutSpecAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::get(context, std::move(entries));
|
|
}
|
|
|
|
DataLayoutSpecAttr DataLayoutSpecAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::getChecked(emitError, context, std::move(entries));
|
|
}
|
|
|
|
::llvm::LogicalResult DataLayoutSpecAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
if (::mlir::failed(verify(emitError, entries)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> DataLayoutSpecAttr::getEntries() const {
|
|
return getImpl()->entries;
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::DataLayoutSpecAttr)
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
struct MapAttrStorage : public ::mlir::AttributeStorage {
|
|
using KeyTy = std::tuple<::llvm::ArrayRef<DataLayoutEntryInterface>>;
|
|
MapAttrStorage(::llvm::ArrayRef<DataLayoutEntryInterface> entries) : entries(std::move(entries)) {}
|
|
|
|
KeyTy getAsKey() const {
|
|
return KeyTy(entries);
|
|
}
|
|
|
|
bool operator==(const KeyTy &tblgenKey) const {
|
|
return (entries == std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
|
|
return ::llvm::hash_combine(std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static MapAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
|
|
auto entries = std::move(std::get<0>(tblgenKey));
|
|
entries = allocator.copyInto(entries);
|
|
return new (allocator.allocate<MapAttrStorage>()) MapAttrStorage(std::move(entries));
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> entries;
|
|
};
|
|
|
|
} // namespace detail
|
|
MapAttr MapAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::get(context, std::move(entries));
|
|
}
|
|
|
|
MapAttr MapAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::getChecked(emitError, context, std::move(entries));
|
|
}
|
|
|
|
::llvm::LogicalResult MapAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
if (::mlir::failed(verify(emitError, entries)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> MapAttr::getEntries() const {
|
|
return getImpl()->entries;
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::MapAttr)
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
struct TargetSystemSpecAttrStorage : public ::mlir::AttributeStorage {
|
|
using KeyTy = std::tuple<::llvm::ArrayRef<DataLayoutEntryInterface>>;
|
|
TargetSystemSpecAttrStorage(::llvm::ArrayRef<DataLayoutEntryInterface> entries) : entries(std::move(entries)) {}
|
|
|
|
KeyTy getAsKey() const {
|
|
return KeyTy(entries);
|
|
}
|
|
|
|
bool operator==(const KeyTy &tblgenKey) const {
|
|
return (entries == std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
|
|
return ::llvm::hash_combine(std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static TargetSystemSpecAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
|
|
auto entries = std::move(std::get<0>(tblgenKey));
|
|
entries = allocator.copyInto(entries);
|
|
return new (allocator.allocate<TargetSystemSpecAttrStorage>()) TargetSystemSpecAttrStorage(std::move(entries));
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> entries;
|
|
};
|
|
|
|
} // namespace detail
|
|
std::optional<TargetDeviceSpecInterface>
|
|
TargetSystemSpecAttr::getDeviceSpecForDeviceID(
|
|
TargetSystemSpecInterface::DeviceID deviceID) {
|
|
for (const auto& entry : getEntries()) {
|
|
if (entry.getKey() == DataLayoutEntryKey(deviceID))
|
|
if (auto deviceSpec =
|
|
::llvm::dyn_cast<TargetDeviceSpecInterface>(entry.getValue()))
|
|
return deviceSpec;
|
|
}
|
|
return std::nullopt;
|
|
}
|
|
TargetSystemSpecAttr TargetSystemSpecAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::get(context, std::move(entries));
|
|
}
|
|
|
|
TargetSystemSpecAttr TargetSystemSpecAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::getChecked(emitError, context, std::move(entries));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetSystemSpecAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
if (::mlir::failed(verify(emitError, entries)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> TargetSystemSpecAttr::getEntries() const {
|
|
return getImpl()->entries;
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::TargetSystemSpecAttr)
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
struct TargetDeviceSpecAttrStorage : public ::mlir::AttributeStorage {
|
|
using KeyTy = std::tuple<::llvm::ArrayRef<DataLayoutEntryInterface>>;
|
|
TargetDeviceSpecAttrStorage(::llvm::ArrayRef<DataLayoutEntryInterface> entries) : entries(std::move(entries)) {}
|
|
|
|
KeyTy getAsKey() const {
|
|
return KeyTy(entries);
|
|
}
|
|
|
|
bool operator==(const KeyTy &tblgenKey) const {
|
|
return (entries == std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
|
|
return ::llvm::hash_combine(std::get<0>(tblgenKey));
|
|
}
|
|
|
|
static TargetDeviceSpecAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
|
|
auto entries = std::move(std::get<0>(tblgenKey));
|
|
entries = allocator.copyInto(entries);
|
|
return new (allocator.allocate<TargetDeviceSpecAttrStorage>()) TargetDeviceSpecAttrStorage(std::move(entries));
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> entries;
|
|
};
|
|
|
|
} // namespace detail
|
|
TargetDeviceSpecAttr TargetDeviceSpecAttr::get(::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::get(context, std::move(entries));
|
|
}
|
|
|
|
TargetDeviceSpecAttr TargetDeviceSpecAttr::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
return Base::getChecked(emitError, context, std::move(entries));
|
|
}
|
|
|
|
::llvm::LogicalResult TargetDeviceSpecAttr::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::llvm::ArrayRef<DataLayoutEntryInterface> entries) {
|
|
if (::mlir::failed(verify(emitError, entries)))
|
|
return ::mlir::failure();
|
|
return ::mlir::success();
|
|
}
|
|
|
|
::llvm::ArrayRef<DataLayoutEntryInterface> TargetDeviceSpecAttr::getEntries() const {
|
|
return getImpl()->entries;
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::TargetDeviceSpecAttr)
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
struct FunctionPointerAlignmentAttrStorage : public ::mlir::AttributeStorage {
|
|
using KeyTy = std::tuple<uint64_t, bool>;
|
|
FunctionPointerAlignmentAttrStorage(uint64_t alignment, bool function_dependent) : alignment(std::move(alignment)), function_dependent(std::move(function_dependent)) {}
|
|
|
|
KeyTy getAsKey() const {
|
|
return KeyTy(alignment, function_dependent);
|
|
}
|
|
|
|
bool operator==(const KeyTy &tblgenKey) const {
|
|
return (alignment == std::get<0>(tblgenKey)) && (function_dependent == std::get<1>(tblgenKey));
|
|
}
|
|
|
|
static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
|
|
return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
|
|
}
|
|
|
|
static FunctionPointerAlignmentAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
|
|
auto alignment = std::move(std::get<0>(tblgenKey));
|
|
auto function_dependent = std::move(std::get<1>(tblgenKey));
|
|
return new (allocator.allocate<FunctionPointerAlignmentAttrStorage>()) FunctionPointerAlignmentAttrStorage(std::move(alignment), std::move(function_dependent));
|
|
}
|
|
|
|
uint64_t alignment;
|
|
bool function_dependent;
|
|
};
|
|
|
|
} // namespace detail
|
|
FunctionPointerAlignmentAttr FunctionPointerAlignmentAttr::get(::mlir::MLIRContext *context, uint64_t alignment, bool function_dependent) {
|
|
return Base::get(context, std::move(alignment), std::move(function_dependent));
|
|
}
|
|
|
|
::mlir::Attribute FunctionPointerAlignmentAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
|
|
::mlir::Builder odsBuilder(odsParser.getContext());
|
|
::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
|
|
(void) odsLoc;
|
|
::mlir::FailureOr<uint64_t> _result_alignment;
|
|
::mlir::FailureOr<bool> _result_function_dependent;
|
|
// Parse literal '<'
|
|
if (odsParser.parseLess()) return {};
|
|
|
|
// Parse variable 'alignment'
|
|
_result_alignment = ::mlir::FieldParser<uint64_t>::parse(odsParser);
|
|
if (::mlir::failed(_result_alignment)) {
|
|
odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse DLTI_FunctionPointerAlignmentAttr parameter 'alignment' which is to be a `uint64_t`");
|
|
return {};
|
|
}
|
|
// Parse literal ','
|
|
if (odsParser.parseComma()) return {};
|
|
// Parse literal 'function_dependent'
|
|
if (odsParser.parseKeyword("function_dependent")) return {};
|
|
// Parse literal '='
|
|
if (odsParser.parseEqual()) return {};
|
|
|
|
// Parse variable 'function_dependent'
|
|
_result_function_dependent = ::mlir::FieldParser<bool>::parse(odsParser);
|
|
if (::mlir::failed(_result_function_dependent)) {
|
|
odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse DLTI_FunctionPointerAlignmentAttr parameter 'function_dependent' which is to be a `bool`");
|
|
return {};
|
|
}
|
|
// Parse literal '>'
|
|
if (odsParser.parseGreater()) return {};
|
|
assert(::mlir::succeeded(_result_alignment));
|
|
assert(::mlir::succeeded(_result_function_dependent));
|
|
return FunctionPointerAlignmentAttr::get(odsParser.getContext(),
|
|
uint64_t((*_result_alignment)),
|
|
bool((*_result_function_dependent)));
|
|
}
|
|
|
|
void FunctionPointerAlignmentAttr::print(::mlir::AsmPrinter &odsPrinter) const {
|
|
::mlir::Builder odsBuilder(getContext());
|
|
odsPrinter << "<";
|
|
odsPrinter.printStrippedAttrOrType(getAlignment());
|
|
odsPrinter << ",";
|
|
odsPrinter << ' ' << "function_dependent";
|
|
odsPrinter << ' ' << "=";
|
|
odsPrinter << ' ';
|
|
odsPrinter.printStrippedAttrOrType(getFunctionDependent());
|
|
odsPrinter << ">";
|
|
}
|
|
|
|
uint64_t FunctionPointerAlignmentAttr::getAlignment() const {
|
|
return getImpl()->alignment;
|
|
}
|
|
|
|
bool FunctionPointerAlignmentAttr::getFunctionDependent() const {
|
|
return getImpl()->function_dependent;
|
|
}
|
|
|
|
|
|
} // namespace mlir
|
|
MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::FunctionPointerAlignmentAttr)
|
|
namespace mlir {
|
|
|
|
|
|
/// Parse an attribute registered to this dialect.
|
|
::mlir::Attribute DLTIDialect::parseAttribute(::mlir::DialectAsmParser &parser,
|
|
::mlir::Type type) const {
|
|
::llvm::SMLoc typeLoc = parser.getCurrentLocation();
|
|
::llvm::StringRef attrTag;
|
|
{
|
|
::mlir::Attribute attr;
|
|
auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
|
|
if (parseResult.has_value())
|
|
return attr;
|
|
}
|
|
|
|
parser.emitError(typeLoc) << "unknown attribute `"
|
|
<< attrTag << "` in dialect `" << getNamespace() << "`";
|
|
return {};
|
|
}
|
|
/// Print an attribute registered to this dialect.
|
|
void DLTIDialect::printAttribute(::mlir::Attribute attr,
|
|
::mlir::DialectAsmPrinter &printer) const {
|
|
if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
|
|
return;
|
|
|
|
}
|
|
|
|
} // namespace mlir
|
|
|
|
#endif // GET_ATTRDEF_CLASSES
|
|
|