CIRCT 24.0.0git
Loading...
Searching...
No Matches
LowerAnnotations.cpp File Reference
#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/Passes.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Support/Debug.h"
#include "mlir/IR/Diagnostics.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "circt/Dialect/FIRRTL/Passes.h.inc"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotationRecords.h.inc"
Include dependency graph for LowerAnnotations.cpp:

Go to the source code of this file.

Namespaces

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

Macros

#define DEBUG_TYPE   "firrtl-lower-annotations"
#define GEN_PASS_DEF_LOWERFIRRTLANNOTATIONS
#define GET_ANNOTATION_RECORD_LIST

Functions

static ArrayAttr getAnnotationsFrom (Operation *op)
 Get annotations or an empty set of annotations.
static ArrayAttr appendArrayAttr (ArrayAttr array, Attribute a)
 Construct the annotation array with a new thing appended.
static ArrayAttr replaceArrayAttrElement (ArrayAttr array, size_t elem, Attribute newVal)
 Update an ArrayAttribute by replacing one entry.
static void addAnnotation (AnnoTarget ref, unsigned fieldIdx, ArrayRef< NamedAttribute > anno)
 Apply a new annotation to a resolved target.
static FlatSymbolRefAttr buildNLA (const AnnoPathValue &target, ApplyState &state)
 Make an anchor for a non-local annotation.
static FlatSymbolRefAttr scatterNonLocalPath (const AnnoPathValue &target, ApplyState &state)
 Scatter breadcrumb annotations corresponding to non-local annotations along the instance path.
static std::optional< AnnoPathValue > noResolve (DictionaryAttr anno, ApplyState &state)
 Always resolve to the circuit, ignoring the annotation.
static std::optional< AnnoPathValue > stdResolveImpl (StringRef rawPath, ApplyState &state)
 Implementation of standard resolution.
LogicalResult drop (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 Just drop the annotation.
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 applyBodyTypeLoweringAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
static LogicalResult applyModulePrefixAnno (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.
static LogicalResult applyOutputDirAnno (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
static LogicalResult convertToFullResetAnnotation (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 Convert from FullAsyncResetAnnotation to FullResetAnnotation.
static LogicalResult convertToExcludeFromFullResetAnnotation (const AnnoPathValue &target, DictionaryAttr anno, ApplyState &state)
 Convert from IgnoreFullAsyncResetAnnotation to ExcludeFromFullResetAnnotation.
LogicalResult circt::firrtl::registerAnnotationRecord (StringRef annoClass, AnnoRecord annoRecord, const std::function< void(llvm::Twine)> &errorHandler={})
 Register external annotation records.
static const AnnoRecord * getAnnotationHandler (StringRef annoStr, bool ignoreAnnotationUnknown)
 Lookup a record for a given annotation class.

Variables

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

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "firrtl-lower-annotations"

Definition at line 34 of file LowerAnnotations.cpp.

◆ GEN_PASS_DEF_LOWERFIRRTLANNOTATIONS

#define GEN_PASS_DEF_LOWERFIRRTLANNOTATIONS

Definition at line 38 of file LowerAnnotations.cpp.

◆ GET_ANNOTATION_RECORD_LIST

#define GET_ANNOTATION_RECORD_LIST

Function Documentation

◆ addAnnotation()

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

◆ appendArrayAttr()

ArrayAttr appendArrayAttr ( ArrayAttr array,
Attribute a )
static

Construct the annotation array with a new thing appended.

Definition at line 55 of file LowerAnnotations.cpp.

Referenced by addAnnotation().

◆ applyAttributeAnnotation()

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

◆ applyBodyTypeLoweringAnno()

◆ applyConventionAnno()

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

◆ applyDUTAnno()

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

◆ applyLoadMemoryAnno()

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

◆ applyModulePrefixAnno()

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

◆ applyOutputDirAnno()

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

◆ buildNLA()

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

◆ convertToExcludeFromFullResetAnnotation()

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

Convert from IgnoreFullAsyncResetAnnotation to ExcludeFromFullResetAnnotation.

Definition at line 556 of file LowerAnnotations.cpp.

References circt::firrtl::applyWithoutTarget(), context, circt::firrtl::AnnoTarget::getOp(), and circt::firrtl::AnnoPathValue::ref.

◆ convertToFullResetAnnotation()

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

Convert from FullAsyncResetAnnotation to FullResetAnnotation.

Definition at line 535 of file LowerAnnotations.cpp.

References circt::firrtl::applyWithoutTarget(), context, circt::firrtl::AnnoTarget::getOp(), and circt::firrtl::AnnoPathValue::ref.

◆ 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 233 of file LowerAnnotations.cpp.

References success().

◆ getAnnotationHandler()

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 621 of file LowerAnnotations.cpp.

References circt::firrtl::annotationRecords.

◆ getAnnotationsFrom()

ArrayAttr getAnnotationsFrom ( Operation * op)
static

Get annotations or an empty set of annotations.

Definition at line 48 of file LowerAnnotations.cpp.

References circt::firrtl::getAnnotationAttrName().

Referenced by addAnnotation().

◆ noResolve()

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

Always resolve to the circuit, ignoring the annotation.

Definition at line 144 of file LowerAnnotations.cpp.

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

◆ parseConvention()

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

Definition at line 266 of file LowerAnnotations.cpp.

Referenced by applyBodyTypeLoweringAnno(), and applyConventionAnno().

◆ replaceArrayAttrElement()

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

Update an ArrayAttribute by replacing one entry.

Definition at line 64 of file LowerAnnotations.cpp.

Referenced by addAnnotation().

◆ scatterNonLocalPath()

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 132 of file LowerAnnotations.cpp.

References buildNLA().

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

◆ stdResolveImpl()

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