CIRCT
18.0.0git
|
This class provides a read-only projection over the MLIR attributes that represent a set of annotations. More...
#include <FIRRTLAnnotations.h>
Public Types | |
using | iterator = AnnotationSetIterator |
Public Member Functions | |
AnnotationSet (MLIRContext *context) | |
Form an empty annotation set. More... | |
AnnotationSet (ArrayRef< Attribute > annotations, MLIRContext *context) | |
Form an annotation set from an array of annotation attributes. More... | |
AnnotationSet (ArrayRef< Annotation > annotations, MLIRContext *context) | |
Form an annotation set from an array of annotations. More... | |
AnnotationSet (ArrayAttr annotations) | |
Form an annotation set with a non-null ArrayAttr. More... | |
AnnotationSet (ArrayAttr annotations, MLIRContext *context) | |
Form an annotation set with a possibly-null ArrayAttr. More... | |
AnnotationSet (Operation *op) | |
Get an annotation set for the specified operation. More... | |
ArrayRef< Attribute > | getArray () const |
Return all the raw annotations that exist. More... | |
ArrayAttr | getArrayAttr () const |
Return this annotation set as an ArrayAttr. More... | |
bool | applyToOperation (Operation *op) const |
Store the annotations in this set in an operation's annotations attribute, overwriting any existing annotations. More... | |
bool | applyToPort (FModuleLike op, size_t portNo) const |
Store the annotations in this set in an operation's portAnnotations attribute, overwriting any existing annotations for this port. More... | |
bool | applyToPort (MemOp op, size_t portNo) const |
bool | applyToAttrList (NamedAttrList &attrs) const |
Store the annotations in this set in a NamedAttrList as an array attribute with the name annotations . More... | |
bool | applyToPortAttrList (NamedAttrList &attrs) const |
Store the annotations in this set in a NamedAttrList as an array attribute with the name firrtl.annotations . More... | |
DictionaryAttr | applyToDictionaryAttr (DictionaryAttr attrs) const |
Insert this annotation set into a DictionaryAttr under the annotations key. More... | |
DictionaryAttr | applyToDictionaryAttr (ArrayRef< NamedAttribute > attrs) const |
DictionaryAttr | applyToPortDictionaryAttr (DictionaryAttr attrs) const |
Insert this annotation set into a DictionaryAttr under the firrtl.annotations key. More... | |
DictionaryAttr | applyToPortDictionaryAttr (ArrayRef< NamedAttribute > attrs) const |
bool | hasAnnotation (StringRef className) const |
Return true if we have an annotation with the specified class name. More... | |
bool | hasAnnotation (StringAttr className) const |
Annotation | getAnnotation (StringRef className) const |
If this annotation set has an annotation with the specified class name, return it. More... | |
Annotation | getAnnotation (StringAttr className) const |
iterator | begin () const |
iterator | end () const |
MLIRContext * | getContext () const |
Return the MLIRContext corresponding to this AnnotationSet. More... | |
bool | hasDontTouch () const |
firrtl.transforms.DontTouchAnnotation More... | |
bool | setDontTouch (bool dontTouch) |
bool | addDontTouch () |
bool | removeDontTouch () |
bool | canBeDeleted () const |
Check if every annotation can be deleted. More... | |
bool | operator== (const AnnotationSet &other) const |
bool | operator!= (const AnnotationSet &other) const |
bool | empty () const |
size_t | size () const |
void | addAnnotations (ArrayRef< Annotation > annotations) |
Add more annotations to this annotation set. More... | |
void | addAnnotations (ArrayRef< Attribute > annotations) |
void | addAnnotations (ArrayAttr annotations) |
bool | removeAnnotation (Annotation anno) |
Remove an annotation from this annotation set. More... | |
bool | removeAnnotation (Attribute anno) |
Remove an annotation from this annotation set. More... | |
bool | removeAnnotation (StringRef className) |
Remove an annotation from this annotation set. More... | |
bool | removeAnnotations (llvm::function_ref< bool(Annotation)> predicate) |
Remove all annotations from this annotation set for which predicate returns true. More... | |
template<typename... Args> | |
bool | removeAnnotationsWithClass (Args... names) |
Remove all annotations with one of the given classes from this annotation set. More... | |
Static Public Member Functions | |
static AnnotationSet | forPort (FModuleLike op, size_t portNo) |
Get an annotation set for the specified port. More... | |
static AnnotationSet | forPort (MemOp op, size_t portNo) |
static AnnotationSet | get (Value v) |
Get an annotation set for the specified value. More... | |
static bool | hasDontTouch (Operation *op) |
static bool | setDontTouch (Operation *op, bool dontTouch) |
static bool | addDontTouch (Operation *op) |
static bool | removeDontTouch (Operation *op) |
static bool | canBeDeleted (Operation *op) |
static bool | removeAnnotations (Operation *op, llvm::function_ref< bool(Annotation)> predicate) |
Remove all annotations from an operation for which predicate returns true. More... | |
static bool | removeAnnotations (Operation *op, StringRef className) |
static bool | removePortAnnotations (Operation *module, llvm::function_ref< bool(unsigned, Annotation)> predicate) |
Remove all port annotations from a module or extmodule for which predicate returns true. More... | |
Private Member Functions | |
bool | hasAnnotationImpl (StringAttr className) const |
bool | hasAnnotationImpl (StringRef className) const |
Annotation | getAnnotationImpl (StringAttr className) const |
Annotation | getAnnotationImpl (StringRef className) const |
Private Attributes | |
ArrayAttr | annotations |
This class provides a read-only projection over the MLIR attributes that represent a set of annotations.
It is intended to make this work less stringly typed and fiddly for clients.
Definition at line 134 of file FIRRTLAnnotations.h.
Definition at line 251 of file FIRRTLAnnotations.h.
|
inlineexplicit |
Form an empty annotation set.
Definition at line 137 of file FIRRTLAnnotations.h.
Referenced by canBeDeleted(), get(), hasDontTouch(), and removePortAnnotations().
|
explicit |
Form an annotation set from an array of annotation attributes.
Definition at line 46 of file FIRRTLAnnotations.cpp.
|
explicit |
Form an annotation set from an array of annotations.
Definition at line 51 of file FIRRTLAnnotations.cpp.
|
inlineexplicit |
Form an annotation set with a non-null ArrayAttr.
Definition at line 148 of file FIRRTLAnnotations.h.
References annotations, and assert().
|
explicit |
Form an annotation set with a possibly-null ArrayAttr.
Definition at line 56 of file FIRRTLAnnotations.cpp.
|
explicit |
Get an annotation set for the specified operation.
Definition at line 60 of file FIRRTLAnnotations.cpp.
void AnnotationSet::addAnnotations | ( | ArrayAttr | annotations | ) |
Definition at line 324 of file FIRRTLAnnotations.cpp.
References annotations, empty(), circt::calyx::direction::get(), and getContext().
void AnnotationSet::addAnnotations | ( | ArrayRef< Annotation > | annotations | ) |
Add more annotations to this annotation set.
Add more annotations to this AttributeSet.
Definition at line 296 of file FIRRTLAnnotations.cpp.
References annotations, circt::calyx::direction::get(), and getContext().
Referenced by addDontTouch(), circt::firrtl::applyGCTView(), and circt::firrtl::applyOMIR().
void AnnotationSet::addAnnotations | ( | ArrayRef< Attribute > | annotations | ) |
Definition at line 308 of file FIRRTLAnnotations.cpp.
References annotations, empty(), circt::calyx::direction::get(), and getContext().
bool AnnotationSet::addDontTouch | ( | ) |
Definition at line 245 of file FIRRTLAnnotations.cpp.
References addAnnotations(), circt::firrtl::dontTouchAnnoClass, circt::calyx::direction::get(), getContext(), and hasDontTouch().
Referenced by addDontTouch(), circt::firrtl::applyGCTDataTaps(), and setDontTouch().
|
static |
Definition at line 269 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and applyToOperation().
bool AnnotationSet::applyToAttrList | ( | NamedAttrList & | attrs | ) | const |
Store the annotations in this set in a NamedAttrList
as an array attribute with the name annotations
.
Overwrites existing annotations. Removes the annotations
attribute if the set is empty. Returns true if the list was modified, false otherwise.
This function is useful if you are in the process of modifying an operation's attributes as a NamedAttrList
, or you are preparing the attributes of a operation yet to be created. In that case applyToAttrList
allows you to set the annotations
attribute in that list to the contents of this set.
Definition at line 132 of file FIRRTLAnnotations.cpp.
References applyToAttrListImpl(), and circt::firrtl::getAnnotationAttrName().
DictionaryAttr AnnotationSet::applyToDictionaryAttr | ( | ArrayRef< NamedAttribute > | attrs | ) | const |
Definition at line 192 of file FIRRTLAnnotations.cpp.
References applyToDictionaryAttrImpl(), and circt::firrtl::getAnnotationAttrName().
DictionaryAttr AnnotationSet::applyToDictionaryAttr | ( | DictionaryAttr | attrs | ) | const |
Insert this annotation set into a DictionaryAttr
under the annotations
key.
Update the attribute dictionary of an operation to contain this annotation set.
Overwrites any existing attribute stored under annotations
. Removes the annotations
attribute in the dictionary if the set is empty. Returns the updated dictionary.
This function is useful if you hold an operation's attributes dictionary and want to set the annotations
key in the dictionary to the contents of this set.
Definition at line 186 of file FIRRTLAnnotations.cpp.
References applyToDictionaryAttrImpl(), and circt::firrtl::getAnnotationAttrName().
bool AnnotationSet::applyToOperation | ( | Operation * | op | ) | const |
Store the annotations in this set in an operation's annotations
attribute, overwriting any existing annotations.
Removes the annotations
attribute if the set is empty. Returns true if the operation was modified, false otherwise.
Definition at line 90 of file FIRRTLAnnotations.cpp.
References circt::firrtl::getAnnotationAttrName(), and getArrayAttr().
Referenced by addDontTouch(), circt::firrtl::applyGCTView(), circt::firrtl::applyOMIR(), removeAnnotations(), removeDontTouch(), and circt::firrtl::OpAnnoTarget::setAnnotations().
bool AnnotationSet::applyToPort | ( | FModuleLike | op, |
size_t | portNo | ||
) | const |
Store the annotations in this set in an operation's portAnnotations
attribute, overwriting any existing annotations for this port.
Returns true if the operation was modified, false otherwise.
Definition at line 112 of file FIRRTLAnnotations.cpp.
References applyToPort().
Referenced by circt::firrtl::PortAnnoTarget::setAnnotations().
bool AnnotationSet::applyToPort | ( | MemOp | op, |
size_t | portNo | ||
) | const |
Definition at line 116 of file FIRRTLAnnotations.cpp.
References applyToPort().
bool AnnotationSet::applyToPortAttrList | ( | NamedAttrList & | attrs | ) | const |
Store the annotations in this set in a NamedAttrList
as an array attribute with the name firrtl.annotations
.
Overwrites existing annotations. Removes the firrtl.annotations
attribute if the set is empty. Returns true if the list was modified, false otherwise.
This function is useful if you are in the process of modifying a port's attributes as a NamedAttrList
, or you are preparing the attributes of a port yet to be created as part of an operation. In that case applyToPortAttrList
allows you to set the firrtl.annotations
attribute in that list to the contents of this set.
Definition at line 138 of file FIRRTLAnnotations.cpp.
References applyToAttrListImpl(), and circt::firrtl::getDialectAnnotationAttrName().
DictionaryAttr AnnotationSet::applyToPortDictionaryAttr | ( | ArrayRef< NamedAttribute > | attrs | ) | const |
Definition at line 205 of file FIRRTLAnnotations.cpp.
References applyToDictionaryAttrImpl(), and circt::firrtl::getDialectAnnotationAttrName().
DictionaryAttr AnnotationSet::applyToPortDictionaryAttr | ( | DictionaryAttr | attrs | ) | const |
Insert this annotation set into a DictionaryAttr
under the firrtl.annotations
key.
Update the attribute dictionary of a port to contain this annotation set.
Overwrites any existing attribute stored under firrtl.annotations
. Removes the firrtl.annotations
attribute in the dictionary if the set is empty. Returns the updated dictionary.
This function is useful if you hold a port's attributes dictionary and want to set the firrtl.annotations
key in the dictionary to the contents of this set.
Definition at line 199 of file FIRRTLAnnotations.cpp.
References applyToDictionaryAttrImpl(), and circt::firrtl::getDialectAnnotationAttrName().
|
inline |
Definition at line 357 of file FIRRTLAnnotations.h.
bool AnnotationSet::canBeDeleted | ( | ) | const |
Check if every annotation can be deleted.
Definition at line 285 of file FIRRTLAnnotations.cpp.
References annotations, and circt::firrtl::Annotation::canBeDeleted().
Referenced by isDeletableDeclaration(), and isDeletableWireOrRegOrNode().
|
static |
Definition at line 291 of file FIRRTLAnnotations.cpp.
References AnnotationSet().
|
inline |
Definition at line 281 of file FIRRTLAnnotations.h.
References annotations.
Referenced by addAnnotations(), applyToAttrListImpl(), applyToDictionaryAttrImpl(), removeAnnotations(), and removePortAnnotations().
|
inline |
Definition at line 360 of file FIRRTLAnnotations.h.
References annotations.
|
static |
Get an annotation set for the specified port.
Definition at line 70 of file FIRRTLAnnotations.cpp.
References forPort().
Referenced by get(), circt::firrtl::PortAnnoTarget::getAnnotations(), getPortImpl(), circt::firrtl::hasDontTouch(), hasDontTouchOrInnerSymOnResult(), and Deduper::mergeAnnotations().
|
static |
Definition at line 74 of file FIRRTLAnnotations.cpp.
References forPort().
|
static |
Get an annotation set for the specified value.
Definition at line 79 of file FIRRTLAnnotations.cpp.
References AnnotationSet(), and forPort().
|
inline |
Definition at line 245 of file FIRRTLAnnotations.h.
References annotations, and getAnnotationImpl().
|
inline |
If this annotation set has an annotation with the specified class name, return it.
Otherwise return a null DictionaryAttr.
Definition at line 240 of file FIRRTLAnnotations.h.
References annotations, and getAnnotationImpl().
Referenced by Equivalence::check(), getPrefixInfo(), and moveVerifAnno().
|
private |
Definition at line 210 of file FIRRTLAnnotations.cpp.
Referenced by getAnnotation(), and hasAnnotationImpl().
|
private |
Definition at line 218 of file FIRRTLAnnotations.cpp.
|
inline |
Return all the raw annotations that exist.
Definition at line 166 of file FIRRTLAnnotations.h.
References annotations.
|
inline |
Return this annotation set as an ArrayAttr.
Definition at line 169 of file FIRRTLAnnotations.h.
References annotations.
Referenced by applyToAttrListImpl(), applyToDictionaryAttrImpl(), applyToOperation(), applyToPort(), removeAnnotations(), and removePortAnnotations().
|
inline |
Return the MLIRContext corresponding to this AnnotationSet.
Definition at line 256 of file FIRRTLAnnotations.h.
References annotations.
Referenced by addAnnotations(), addDontTouch(), applyToDictionaryAttrImpl(), and removeAnnotations().
|
inline |
Definition at line 234 of file FIRRTLAnnotations.h.
References annotations, and hasAnnotationImpl().
|
inline |
Return true if we have an annotation with the specified class name.
Definition at line 231 of file FIRRTLAnnotations.h.
References annotations, and hasAnnotationImpl().
Referenced by Equivalence::check(), and hasDontTouch().
|
private |
Definition at line 226 of file FIRRTLAnnotations.cpp.
References getAnnotationImpl().
Referenced by hasAnnotation().
|
private |
Definition at line 230 of file FIRRTLAnnotations.cpp.
References getAnnotationImpl().
bool AnnotationSet::hasDontTouch | ( | ) | const |
firrtl.transforms.DontTouchAnnotation
Definition at line 234 of file FIRRTLAnnotations.cpp.
References circt::firrtl::dontTouchAnnoClass, and hasAnnotation().
Referenced by addDontTouch(), circt::firrtl::hasDontTouch(), and hasDontTouchOrInnerSymOnResult().
|
static |
Definition at line 258 of file FIRRTLAnnotations.cpp.
References AnnotationSet().
|
inline |
Definition at line 277 of file FIRRTLAnnotations.h.
|
inline |
Definition at line 274 of file FIRRTLAnnotations.h.
References annotations.
bool AnnotationSet::removeAnnotation | ( | Annotation | anno | ) |
Remove an annotation from this annotation set.
Returns true if any were removed, false otherwise.
Definition at line 342 of file FIRRTLAnnotations.cpp.
References removeAnnotations().
Referenced by removeDontTouch().
bool AnnotationSet::removeAnnotation | ( | Attribute | anno | ) |
Remove an annotation from this annotation set.
Returns true if any were removed, false otherwise.
Definition at line 348 of file FIRRTLAnnotations.cpp.
References circt::firrtl::Annotation::getDict(), and removeAnnotations().
bool AnnotationSet::removeAnnotation | ( | StringRef | className | ) |
Remove an annotation from this annotation set.
Returns true if any were removed, false otherwise.
Definition at line 355 of file FIRRTLAnnotations.cpp.
References circt::firrtl::Annotation::getClass(), and removeAnnotations().
bool AnnotationSet::removeAnnotations | ( | llvm::function_ref< bool(Annotation)> | predicate | ) |
Remove all annotations from this annotation set for which predicate
returns true.
The predicate is guaranteed to be called on every annotation, such that this method can be used to partition the set by extracting and removing annotations at the same time. Returns true if any annotations were removed, false otherwise.
Definition at line 362 of file FIRRTLAnnotations.cpp.
References annotations, circt::calyx::direction::get(), getArrayAttr(), and getContext().
Referenced by removeAnnotation(), removeAnnotations(), removeAnnotationsWithClass(), removePortAnnotations(), and ResolveTracesPass::runOnOperation().
|
static |
Remove all annotations from an operation for which predicate
returns true.
The predicate is guaranteed to be called on every annotation, such that this method can be used to partition the set by extracting and removing annotations at the same time. Returns true if any annotations were removed, false otherwise.
Definition at line 394 of file FIRRTLAnnotations.cpp.
References applyToOperation(), empty(), and removeAnnotations().
|
static |
Definition at line 404 of file FIRRTLAnnotations.cpp.
References circt::firrtl::Annotation::getClass(), and removeAnnotations().
|
inline |
Remove all annotations with one of the given classes from this annotation set.
Definition at line 306 of file FIRRTLAnnotations.h.
References circt::firrtl::Annotation::isClass(), and removeAnnotations().
bool AnnotationSet::removeDontTouch | ( | ) |
Definition at line 254 of file FIRRTLAnnotations.cpp.
References circt::firrtl::dontTouchAnnoClass, and removeAnnotation().
Referenced by removeDontTouch(), and setDontTouch().
|
static |
Definition at line 277 of file FIRRTLAnnotations.cpp.
References applyToOperation(), and removeDontTouch().
|
static |
Remove all port annotations from a module or extmodule for which predicate
returns true.
The predicate is guaranteed to be called on every annotation, such that this method can be used to partition a module's port annotations by extracting and removing annotations at the same time. Returns true if any annotations were removed, false otherwise.
Definition at line 411 of file FIRRTLAnnotations.cpp.
References AnnotationSet(), empty(), circt::calyx::direction::get(), getArrayAttr(), and removeAnnotations().
Referenced by ResolveTracesPass::runOnOperation().
bool AnnotationSet::setDontTouch | ( | bool | dontTouch | ) |
Definition at line 238 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and removeDontTouch().
|
static |
Definition at line 262 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and removeDontTouch().
|
inline |
Definition at line 283 of file FIRRTLAnnotations.h.
References annotations.
|
private |
Definition at line 335 of file FIRRTLAnnotations.h.
Referenced by addAnnotations(), AnnotationSet(), canBeDeleted(), empty(), end(), getAnnotation(), getArray(), getArrayAttr(), getContext(), hasAnnotation(), operator==(), removeAnnotations(), and size().