MLIR  16.0.0git
Public Member Functions | Static Public Member Functions | List of all members
mlir::DynamicAttr Class Reference

A dynamic attribute instance. More...

#include "mlir/IR/ExtensibleDialect.h"

+ Inheritance diagram for mlir::DynamicAttr:
+ Collaboration diagram for mlir::DynamicAttr:

Public Member Functions

DynamicAttrDefinitiongetAttrDef ()
 Return the attribute definition of the concrete attribute. More...
 
ArrayRef< AttributegetParams ()
 Return the attribute parameters. More...
 
void print (AsmPrinter &printer)
 Print the dynamic attribute with the format 'attrname' if there is no parameters, or 'attrname<attr (,attr)*>'. More...
 

Static Public Member Functions

static DynamicAttr get (DynamicAttrDefinition *attrDef, ArrayRef< Attribute > params={})
 Return an instance of a dynamic attribute given a dynamic attribute definition and attribute parameters. More...
 
static DynamicAttr getChecked (function_ref< InFlightDiagnostic()> emitError, DynamicAttrDefinition *attrDef, ArrayRef< Attribute > params={})
 Return an instance of a dynamic attribute given a dynamic attribute definition and attribute parameters. More...
 
static bool isa (Attribute attr, DynamicAttrDefinition *attrDef)
 Check if an attribute is a specific dynamic attribute. More...
 
static bool classof (Attribute attr)
 Check if an attribute is a dynamic attribute. More...
 
static ParseResult parse (AsmParser &parser, DynamicAttrDefinition *attrDef, DynamicAttr &parsedAttr)
 Parse the dynamic attribute parameters and construct the attribute. More...
 
- Static Public Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >
static TypeID getTypeID ()
 Return a unique identifier for the concrete type. More...
 
template<typename T >
static bool classof (T val)
 Provide an implementation of 'classof' that compares the type id of the provided value with that of the concrete type. More...
 
static detail::InterfaceMap getInterfaceMap ()
 Returns an interface map for the interfaces registered to this storage user. More...
 
static HasTraitFn getHasTraitFn ()
 Returns the function that returns true if the given Trait ID matches the IDs of any of the traits defined by the storage user. More...
 
template<typename... IfaceModels>
static void attachInterface (MLIRContext &context)
 Attach the given models as implementations of the corresponding interfaces for the concrete storage user class. More...
 
template<typename... Args>
static ConcreteT get (MLIRContext *ctx, Args... args)
 Get or create a new ConcreteT instance within the ctx. More...
 
template<typename... Args>
static ConcreteT getChecked (const Location &loc, Args... args)
 Get or create a new ConcreteT instance within the ctx, defined at the given, potentially unknown, location. More...
 
template<typename... Args>
static ConcreteT getChecked (function_ref< InFlightDiagnostic()> emitErrorFn, MLIRContext *ctx, Args... args)
 Get or create a new ConcreteT instance within the ctx. More...
 
static ConcreteT getFromOpaquePointer (const void *ptr)
 Get an instance of the concrete type from a void pointer. More...
 

Additional Inherited Members

- Public Types inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >
using Base = StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits... >
 Utility declarations for the concrete attribute class. More...
 
using ImplType = StorageT
 
using HasTraitFn = bool(*)(TypeID)
 
- Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >
template<typename... Args>
LogicalResult mutate (Args &&...args)
 Mutate the current storage instance. More...
 
ImplTypegetImpl () const
 Utility for easy access to the storage instance. More...
 
- Static Protected Member Functions inherited from mlir::detail::StorageUserBase< ConcreteT, BaseT, StorageT, UniquerT, Traits >
template<typename... Args>
static LogicalResult verify (Args... args)
 Default implementation that just returns success. More...
 

Detailed Description

A dynamic attribute instance.

This is an attribute whose definition is defined at runtime. It is possible to check if an attribute is a dynamic attribute using my_attr.isa<DynamicAttr>(), and getting the attribute definition of a dynamic attribute using the DynamicAttr::getAttrDef method. All dynamic attributes have the same storage, which is an array of attributes.

Definition at line 144 of file ExtensibleDialect.h.

Member Function Documentation

◆ classof()

bool DynamicAttr::classof ( Attribute  attr)
static

Check if an attribute is a dynamic attribute.

Definition at line 265 of file ExtensibleDialect.cpp.

References mlir::Attribute::hasTrait().

◆ get()

DynamicAttr DynamicAttr::get ( DynamicAttrDefinition attrDef,
ArrayRef< Attribute params = {} 
)
static

Return an instance of a dynamic attribute given a dynamic attribute definition and attribute parameters.

This asserts that the attribute verifier succeeded.

Definition at line 245 of file ExtensibleDialect.cpp.

References mlir::DynamicAttrDefinition::getContext(), and mlir::SelfOwningTypeID::getTypeID().

◆ getAttrDef()

DynamicAttrDefinition * DynamicAttr::getAttrDef ( )

Return the attribute definition of the concrete attribute.

Definition at line 261 of file ExtensibleDialect.cpp.

◆ getChecked()

DynamicAttr DynamicAttr::getChecked ( function_ref< InFlightDiagnostic()>  emitError,
DynamicAttrDefinition attrDef,
ArrayRef< Attribute params = {} 
)
static

Return an instance of a dynamic attribute given a dynamic attribute definition and attribute parameters.

If the parameters provided are invalid, errors are emitted using the provided location and a null object is returned.

Definition at line 253 of file ExtensibleDialect.cpp.

References mlir::emitError(), mlir::failed(), and mlir::DynamicAttrDefinition::verify().

◆ getParams()

ArrayRef< Attribute > DynamicAttr::getParams ( )

Return the attribute parameters.

Definition at line 263 of file ExtensibleDialect.cpp.

◆ isa()

static bool mlir::DynamicAttr::isa ( Attribute  attr,
DynamicAttrDefinition attrDef 
)
inlinestatic

Check if an attribute is a specific dynamic attribute.

Definition at line 172 of file ExtensibleDialect.h.

References mlir::Attribute::getTypeID(), mlir::SelfOwningTypeID::getTypeID(), and print().

◆ parse()

ParseResult DynamicAttr::parse ( AsmParser parser,
DynamicAttrDefinition attrDef,
DynamicAttr parsedAttr 
)
static

Parse the dynamic attribute parameters and construct the attribute.

The parameters are either empty, and nothing is parsed, or they are in the format '<>' or '<attr (,attr)*>'.

Definition at line 269 of file ExtensibleDialect.cpp.

References mlir::failed(), mlir::failure(), mlir::AsmParser::getChecked(), and mlir::success().

Referenced by mlir::ExtensibleDialect::parseOptionalDynamicAttr().

◆ print()

void DynamicAttr::print ( AsmPrinter printer)

Print the dynamic attribute with the format 'attrname' if there is no parameters, or 'attrname<attr (,attr)*>'.

Definition at line 281 of file ExtensibleDialect.cpp.

References mlir::Dialect::getNamespace().


The documentation for this class was generated from the following files: