CIRCT
20.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 | ElementType = Annotation |
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 | 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 | 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... | |
template<typename... Args> | |
static bool | hasAnnotation (Operation *op, Args... args) |
Return true if we have an annotation with the specified class name. 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 | 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 142 of file FIRRTLAnnotations.h.
Definition at line 144 of file FIRRTLAnnotations.h.
Definition at line 227 of file FIRRTLAnnotations.h.
|
inlineexplicit |
Form an empty annotation set.
Definition at line 147 of file FIRRTLAnnotations.h.
Referenced by 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 158 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 223 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 195 of file FIRRTLAnnotations.cpp.
References annotations, circt::calyx::direction::get(), and getContext().
Referenced by addDontTouch(), annosForFieldIDRange(), circt::firrtl::applyGCTView(), and circt::firrtl::createPathRef().
void AnnotationSet::addAnnotations | ( | ArrayRef< Attribute > | annotations | ) |
Definition at line 207 of file FIRRTLAnnotations.cpp.
References annotations, empty(), circt::calyx::direction::get(), and getContext().
bool AnnotationSet::addDontTouch | ( | ) |
Definition at line 155 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 178 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and applyToOperation().
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::createPathRef(), 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 113 of file FIRRTLAnnotations.cpp.
References applyToPort().
Referenced by circt::firrtl::PortAnnoTarget::setAnnotations().
bool AnnotationSet::applyToPort | ( | MemOp | op, |
size_t | portNo | ||
) | const |
Definition at line 117 of file FIRRTLAnnotations.cpp.
References applyToPort().
|
inline |
Definition at line 329 of file FIRRTLAnnotations.h.
|
inline |
Definition at line 253 of file FIRRTLAnnotations.h.
References annotations.
Referenced by addAnnotations(), isDeletableDeclaration(), isDeletableWireOrRegOrNode(), and removePortAnnotations().
|
inline |
Definition at line 332 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(), 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 221 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 216 of file FIRRTLAnnotations.h.
References annotations, and getAnnotationImpl().
Referenced by moveVerifAnno().
|
private |
Definition at line 121 of file FIRRTLAnnotations.cpp.
Referenced by getAnnotation(), and hasAnnotationImpl().
|
private |
Definition at line 129 of file FIRRTLAnnotations.cpp.
|
inline |
Return all the raw annotations that exist.
Definition at line 176 of file FIRRTLAnnotations.h.
References annotations.
|
inline |
Return this annotation set as an ArrayAttr.
Definition at line 179 of file FIRRTLAnnotations.h.
References annotations, and assert().
Referenced by applyToOperation(), applyToPort(), removeAnnotations(), and removePortAnnotations().
|
inline |
Return the MLIRContext corresponding to this AnnotationSet.
Definition at line 232 of file FIRRTLAnnotations.h.
References annotations.
Referenced by addAnnotations(), addDontTouch(), lowerModuleBody(), and removeAnnotations().
|
inlinestatic |
Return true if we have an annotation with the specified class name.
Definition at line 206 of file FIRRTLAnnotations.h.
References annotations, and circt::firrtl::getAnnotationsIfPresent().
|
inline |
Definition at line 200 of file FIRRTLAnnotations.h.
References annotations, and hasAnnotationImpl().
|
inline |
Return true if we have an annotation with the specified class name.
Definition at line 197 of file FIRRTLAnnotations.h.
References annotations, and hasAnnotationImpl().
Referenced by Equivalence::check(), hasDontTouch(), and circt::firrtl::InstanceInfo::InstanceInfo().
|
private |
Definition at line 137 of file FIRRTLAnnotations.cpp.
References getAnnotationImpl().
Referenced by hasAnnotation().
|
private |
Definition at line 141 of file FIRRTLAnnotations.cpp.
References getAnnotationImpl().
bool AnnotationSet::hasDontTouch | ( | ) | const |
firrtl.transforms.DontTouchAnnotation
Definition at line 145 of file FIRRTLAnnotations.cpp.
References circt::firrtl::dontTouchAnnoClass, and hasAnnotation().
Referenced by addDontTouch(), and circt::firrtl::hasDontTouch().
|
static |
Definition at line 168 of file FIRRTLAnnotations.cpp.
References AnnotationSet().
|
inline |
Definition at line 249 of file FIRRTLAnnotations.h.
|
inline |
Definition at line 246 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 241 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 247 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 254 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 261 of file FIRRTLAnnotations.cpp.
References annotations, circt::calyx::direction::get(), getArrayAttr(), and getContext().
Referenced by removeAnnotation(), removeAnnotations(), removeAnnotationsWithClass(), removePortAnnotations(), ResolveTracesPass::runOnOperation(), and SFCCompatPass::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 288 of file FIRRTLAnnotations.cpp.
References applyToOperation(), circt::firrtl::getAnnotationsIfPresent(), and removeAnnotations().
|
static |
Definition at line 302 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 278 of file FIRRTLAnnotations.h.
References circt::firrtl::Annotation::isClass(), and removeAnnotations().
bool AnnotationSet::removeDontTouch | ( | ) |
Definition at line 164 of file FIRRTLAnnotations.cpp.
References circt::firrtl::dontTouchAnnoClass, and removeAnnotation().
Referenced by removeDontTouch(), and setDontTouch().
|
static |
Definition at line 186 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 309 of file FIRRTLAnnotations.cpp.
References AnnotationSet(), empty(), circt::calyx::direction::get(), getArrayAttr(), and removeAnnotations().
Referenced by ResolveTracesPass::runOnOperation(), and SFCCompatPass::runOnOperation().
bool AnnotationSet::setDontTouch | ( | bool | dontTouch | ) |
Definition at line 149 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and removeDontTouch().
|
static |
Definition at line 172 of file FIRRTLAnnotations.cpp.
References addDontTouch(), and removeDontTouch().
|
inline |
Definition at line 255 of file FIRRTLAnnotations.h.
References annotations.
Referenced by esiaccel.types.ArrayType::bit_width(), esiaccel.types.ArrayType::deserialize(), and esiaccel.types.ArrayType::is_valid().
|
private |
Definition at line 307 of file FIRRTLAnnotations.h.
Referenced by addAnnotations(), AnnotationSet(), empty(), end(), getAnnotation(), getArray(), getArrayAttr(), getContext(), hasAnnotation(), operator==(), removeAnnotations(), and size().