MLIR  20.0.0git
Classes | Namespaces | Macros | Functions
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/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/MathExtras.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

 mlir
 Include the generated interface declarations.
 
 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. More...
 
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. More...
 
static std::string keyToStr (DataLayoutEntryKey key)
 Convert pointer-union keys to strings. More...
 
template<class T >
static void printAngleBracketedEntries (AsmPrinter &os, T &&entries)
 Pretty-print entries, each in key = value format, separated by commas. More...
 
static LogicalResult verifyEntries (function_ref< InFlightDiagnostic()> emitError, ArrayRef< DataLayoutEntryInterface > entries, bool allowTypes=true)
 Verify entries, with the option to disallow types as keys. More...
 
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. More...
 
static LogicalResult combineOneSpec (DataLayoutSpecInterface spec, DenseMap< TypeID, DataLayoutEntryList > &entriesForType, DenseMap< StringAttr, DataLayoutEntryInterface > &entriesForID)
 Combines a data layout spec into the given lists of entries organized by type class and identifier, overwriting them if necessary. More...
 
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. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "dlti"

Definition at line 30 of file DLTI.cpp.

◆ GET_ATTRDEF_CLASSES

#define GET_ATTRDEF_CLASSES

Definition at line 27 of file DLTI.cpp.

◆ GET_ATTRDEF_LIST

#define GET_ATTRDEF_LIST

Function Documentation

◆ combineOneSpec()

static LogicalResult combineOneSpec ( DataLayoutSpecInterface  spec,
DenseMap< TypeID, DataLayoutEntryList > &  entriesForType,
DenseMap< 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 297 of file DLTI.cpp.

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

◆ getClosestQueryable()

static 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 496 of file DLTI.cpp.

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

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

◆ keyToStr()

static std::string keyToStr ( DataLayoutEntryKey  key)
static

Convert pointer-union keys to strings.

Definition at line 113 of file DLTI.cpp.

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

◆ overwriteDuplicateEntries()

static 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 272 of file DLTI.cpp.

Referenced by combineOneSpec().

◆ parseAngleBracketedEntries()

template<class Attr >
static 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 89 of file DLTI.cpp.

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

◆ parseKeyValuePair()

static 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 40 of file DLTI.cpp.

References mlir::AsmParser::emitError(), mlir::get(), 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().

◆ printAngleBracketedEntries()

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

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

Definition at line 123 of file DLTI.cpp.

References keyToStr().

◆ verifyEntries()

static 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 136 of file DLTI.cpp.

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