MLIR 22.0.0git
DLTI.cpp File Reference
#include "mlir/Dialect/DLTI/DLTI.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinDialect.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Dialect.h"
#include "mlir/IR/DialectImplementation.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "mlir/Dialect/DLTI/DLTIDialect.cpp.inc"
#include "mlir/Dialect/DLTI/DLTIAttrs.cpp.inc"

Go to the source code of this file.

Classes

class  mlir::detail::DataLayoutEntryAttrStorage

Namespaces

namespace  mlir
 Include the generated interface declarations.
namespace  mlir::detail
 AttrTypeReplacer.

Macros

#define GET_ATTRDEF_CLASSES
#define DEBUG_TYPE   "dlti"
#define GET_ATTRDEF_LIST

Functions

static ParseResult parseKeyValuePair (AsmParser &parser, DataLayoutEntryInterface &entry, bool tryType=false)
 Parse an entry which can either be of the form key = value or a #dlti.dl_entry attribute.
template<class Attr>
static Attribute parseAngleBracketedEntries (AsmParser &parser, Type ty, bool tryType=false, bool allowEmpty=false)
 Construct a requested attribute by parsing list of entries occurring within a pair of < and >, optionally allow types as keys and an empty list.
static std::string keyToStr (DataLayoutEntryKey key)
 Convert pointer-union keys to strings.
template<class T>
static void printAngleBracketedEntries (AsmPrinter &os, T &&entries)
 Pretty-print entries, each in key = value format, separated by commas.
static LogicalResult verifyEntries (function_ref< InFlightDiagnostic()> emitError, ArrayRef< DataLayoutEntryInterface > entries, bool allowTypes=true)
 Verify entries, with the option to disallow types as keys.
static void overwriteDuplicateEntries (SmallVectorImpl< DataLayoutEntryInterface > &oldEntries, ArrayRef< DataLayoutEntryInterface > newEntries)
 Given a list of old and a list of new entries, overwrites old entries with new ones if they have matching keys, appends new entries to the old entry list otherwise.
static LogicalResult combineOneSpec (DataLayoutSpecInterface spec, llvm::MapVector< TypeID, DataLayoutEntryList > &entriesForType, llvm::MapVector< StringAttr, DataLayoutEntryInterface > &entriesForID)
 Combines a data layout spec into the given lists of entries organized by type class and identifier, overwriting them if necessary.
static std::pair< DLTIQueryInterface, Operation * > getClosestQueryable (Operation *op)
 Retrieve the first DLTIQueryInterface-implementing attribute that is attached to op or such an attr on as close as possible an ancestor.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dlti"

Definition at line 28 of file DLTI.cpp.

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 25 of file DLTI.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

Function Documentation

◆ combineOneSpec()

LogicalResult combineOneSpec ( DataLayoutSpecInterface spec,
llvm::MapVector< TypeID, DataLayoutEntryList > & entriesForType,
llvm::MapVector< StringAttr, DataLayoutEntryInterface > & entriesForID )
static

Combines a data layout spec into the given lists of entries organized by type class and identifier, overwriting them if necessary.

Fails to combine if the two entries with identical keys are not compatible.

Definition at line 294 of file DLTI.cpp.

References mlir::DataLayoutDialectInterface::defaultCombine(), mlir::Type::getContext(), mlir::Type::getDialect(), mlir::MLIRContext::getLoadedDialect(), overwriteDuplicateEntries(), and success().

◆ getClosestQueryable()

std::pair< DLTIQueryInterface, Operation * > getClosestQueryable ( Operation * op)
static

Retrieve the first DLTIQueryInterface-implementing attribute that is attached to op or such an attr on as close as possible an ancestor.

The op the attribute is attached to is returned as well.

Definition at line 523 of file DLTI.cpp.

References mlir::Operation::getAttrs(), and mlir::Operation::getParentOp().

Referenced by mlir::dlti::query().

◆ keyToStr()

std::string keyToStr ( DataLayoutEntryKey key)
static

Convert pointer-union keys to strings.

Definition at line 111 of file DLTI.cpp.

Referenced by printAngleBracketedEntries(), mlir::dlti::query(), and verifyEntries().

◆ overwriteDuplicateEntries()

void overwriteDuplicateEntries ( SmallVectorImpl< DataLayoutEntryInterface > & oldEntries,
ArrayRef< DataLayoutEntryInterface > newEntries )
static

Given a list of old and a list of new entries, overwrites old entries with new ones if they have matching keys, appends new entries to the old entry list otherwise.

Definition at line 270 of file DLTI.cpp.

Referenced by combineOneSpec().

◆ parseAngleBracketedEntries()

template<class Attr>
Attribute parseAngleBracketedEntries ( AsmParser & parser,
Type ty,
bool tryType = false,
bool allowEmpty = false )
static

Construct a requested attribute by parsing list of entries occurring within a pair of < and >, optionally allow types as keys and an empty list.

The grammar is as follows: bracketed-entry-list ::=< entry-list > entry-list ::= | entry | entry , entry-list entry ::= ((type | quoted-string) = attr) | dl-entry-attr

Definition at line 87 of file DLTI.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getContext(), mlir::AsmParser::getNameLoc(), mlir::AsmParser::LessGreater, and mlir::AsmParser::parseCommaSeparatedList().

◆ parseKeyValuePair()

ParseResult parseKeyValuePair ( AsmParser & parser,
DataLayoutEntryInterface & entry,
bool tryType = false )
static

Parse an entry which can either be of the form key = value or a #dlti.dl_entry attribute.

When tryType=true the key can be a type, otherwise only quoted strings are allowed. The grammar is as follows: entry ::= ((type | quoted-string) = attr) | dl-entry-attr

Definition at line 38 of file DLTI.cpp.

References mlir::AsmParser::emitError(), mlir::AsmParser::getContext(), mlir::AsmParser::getCurrentLocation(), mlir::OptionalParseResult::has_value(), mlir::AsmParser::parseAttribute(), mlir::AsmParser::parseEqual(), mlir::AsmParser::parseOptionalString(), mlir::AsmParser::parseOptionalType(), and mlir::OptionalParseResult::value().

Referenced by parseApplyRegisteredPassOptions().

◆ printAngleBracketedEntries()

template<class T>
void printAngleBracketedEntries ( AsmPrinter & os,
T && entries )
static

Pretty-print entries, each in key = value format, separated by commas.

Definition at line 121 of file DLTI.cpp.

References keyToStr().

◆ verifyEntries()

LogicalResult verifyEntries ( function_ref< InFlightDiagnostic()> emitError,
ArrayRef< DataLayoutEntryInterface > entries,
bool allowTypes = true )
static

Verify entries, with the option to disallow types as keys.

Definition at line 134 of file DLTI.cpp.

References mlir::emitError(), keyToStr(), and success().