CIRCT  19.0.0git
Namespaces | Macros | Functions | Variables
LowerAnnotations.cpp File Reference
#include "PassDetails.h"
#include "circt/Dialect/FIRRTL/AnnotationDetails.h"
#include "circt/Dialect/FIRRTL/CHIRRTLDialect.h"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotationHelper.h"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotations.h"
#include "circt/Dialect/FIRRTL/FIRRTLAttributes.h"
#include "circt/Dialect/FIRRTL/FIRRTLInstanceGraph.h"
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/FIRRTLVisitors.h"
#include "circt/Dialect/FIRRTL/Namespace.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Support/Debug.h"
#include "mlir/IR/Diagnostics.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
Include dependency graph for LowerAnnotations.cpp:

Go to the source code of this file.

Namespaces

 circt
 The InstanceGraph op interface, see InstanceGraphInterface.td for more details.
 
 circt::firrtl
 

Macros

#define DEBUG_TYPE   "lower-annos"
 

Functions

static ArrayAttr getAnnotationsFrom (Operation *op)
 Get annotations or an empty set of annotations. More...
 
static ArrayAttr appendArrayAttr (ArrayAttr array, Attribute a)
 Construct the annotation array with a new thing appended. More...
 
static ArrayAttr replaceArrayAttrElement (ArrayAttr array, size_t elem, Attribute newVal)
 Update an ArrayAttribute by replacing one entry. More...
 
static void addAnnotation (AnnoTarget ref, unsigned fieldIdx, ArrayRef< NamedAttribute > anno)
 Apply a new annotation to a resolved target. More...
 
static FlatSymbolRefAttr buildNLA (const AnnoPathValue &target, ApplyState &state)
 Make an anchor for a non-local annotation. More...
 
static FlatSymbolRefAttr scatterNonLocalPath (const AnnoPathValue &target, ApplyState &state)
 Scatter breadcrumb annotations corresponding to non-local annotations along the instance path. More...
 
static std::optional< AnnoPathValuenoResolve (DictionaryAttr anno, ApplyState &state)
 Always resolve to the circuit, ignoring the annotation. More...
 
static std::optional< AnnoPathValuestdResolveImpl (StringRef rawPath, ApplyState &state)
 Implementation of standard resolution. More...
 
LogicalResult drop (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 Just drop the annotation. More...
 
static LogicalResult applyDUTAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 
static std::optional< Convention > parseConvention (llvm::StringRef str)
 
static LogicalResult applyConventionAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 
static LogicalResult applyAttributeAnnotation (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 
template<bool isInline>
static LogicalResult applyLoadMemoryAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 Update a memory op with attributes about memory file loading. More...
 
static LogicalResult applyOutputDirAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 
LogicalResult circt::firrtl::registerAnnotationRecord (StringRef annoClass, AnnoRecord annoRecord, const std::function< void(llvm::Twine)> &errorHandler={})
 Register external annotation records. More...
 
static const AnnoRecordgetAnnotationHandler (StringRef annoStr, bool ignoreAnnotationUnknown)
 Lookup a record for a given annotation class. More...
 

Variables

static AnnoRecord circt::firrtl::NoTargetAnnotation
 Resolution and application of a "firrtl.annotations.NoTargetAnnotation". More...
 
static llvm::StringMap< AnnoRecordcirct::firrtl::annotationRecords
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lower-annos"

Definition at line 39 of file LowerAnnotations.cpp.

Function Documentation

◆ addAnnotation()

static void addAnnotation ( AnnoTarget  ref,
unsigned  fieldIdx,
ArrayRef< NamedAttribute >  anno 
)
static

◆ appendArrayAttr()

static ArrayAttr appendArrayAttr ( ArrayAttr  array,
Attribute  a 
)
static

Construct the annotation array with a new thing appended.

Definition at line 53 of file LowerAnnotations.cpp.

References circt::calyx::direction::get().

Referenced by addAnnotation().

◆ applyAttributeAnnotation()

static LogicalResult applyAttributeAnnotation ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)
static

◆ applyConventionAnno()

static LogicalResult applyConventionAnno ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)
static

◆ applyDUTAnno()

static LogicalResult applyDUTAnno ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)
static

◆ applyLoadMemoryAnno()

template<bool isInline>
static LogicalResult applyLoadMemoryAnno ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)
static

◆ applyOutputDirAnno()

static LogicalResult applyOutputDirAnno ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)
static

◆ buildNLA()

static FlatSymbolRefAttr buildNLA ( const AnnoPathValue target,
ApplyState state 
)
static

◆ drop()

LogicalResult drop ( const AnnoPathValue target,
DictionaryAttr  anno,
ApplyState state 
)

Just drop the annotation.

This is intended for Annotations which are known, but can be safely ignored.

Definition at line 231 of file LowerAnnotations.cpp.

◆ getAnnotationHandler()

static const AnnoRecord* getAnnotationHandler ( StringRef  annoStr,
bool  ignoreAnnotationUnknown 
)
static

Lookup a record for a given annotation class.

Optionally, returns the record for "circuit.missing" if the record doesn't exist.

Definition at line 566 of file LowerAnnotations.cpp.

References circt::firrtl::annotationRecords.

◆ getAnnotationsFrom()

static ArrayAttr getAnnotationsFrom ( Operation *  op)
static

Get annotations or an empty set of annotations.

Definition at line 46 of file LowerAnnotations.cpp.

References circt::calyx::direction::get(), and circt::firrtl::getAnnotationAttrName().

Referenced by addAnnotation().

◆ noResolve()

static std::optional<AnnoPathValue> noResolve ( DictionaryAttr  anno,
ApplyState state 
)
static

Always resolve to the circuit, ignoring the annotation.

Definition at line 142 of file LowerAnnotations.cpp.

References circt::firrtl::ApplyState::circuit.

◆ parseConvention()

static std::optional<Convention> parseConvention ( llvm::StringRef  str)
static

Definition at line 263 of file LowerAnnotations.cpp.

Referenced by applyConventionAnno().

◆ replaceArrayAttrElement()

static ArrayAttr replaceArrayAttrElement ( ArrayAttr  array,
size_t  elem,
Attribute  newVal 
)
static

Update an ArrayAttribute by replacing one entry.

Definition at line 62 of file LowerAnnotations.cpp.

References circt::calyx::direction::get().

Referenced by addAnnotation().

◆ scatterNonLocalPath()

static FlatSymbolRefAttr scatterNonLocalPath ( const AnnoPathValue target,
ApplyState state 
)
static

Scatter breadcrumb annotations corresponding to non-local annotations along the instance path.

Returns symbol name used to anchor annotations to path.

Definition at line 130 of file LowerAnnotations.cpp.

References buildNLA().

Referenced by circt::firrtl::applyWithoutTargetImpl().

◆ stdResolveImpl()

static std::optional<AnnoPathValue> stdResolveImpl ( StringRef  rawPath,
ApplyState state 
)
static