CIRCT 20.0.0git
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
InferResets.cpp File Reference
#include "circt/Dialect/FIRRTL/AnnotationDetails.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/Support/Debug.h"
#include "circt/Support/FieldRef.h"
#include "circt/Support/InstanceGraph.h"
#include "circt/Support/InstanceGraphInterface.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
#include "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for InferResets.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< ResetSignal >
 

Namespaces

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

Macros

#define DEBUG_TYPE   "infer-resets"
 
#define GEN_PASS_DEF_INFERRESETS
 

Functions

static std::pair< StringAttr, FModuleOp > getResetNameAndModule (Value reset)
 Return the name and parent module of a reset.
 
static StringAttr getResetName (Value reset)
 Return the name of a reset.
 
bool operator== (const ResetDomain &a, const ResetDomain &b)
 
bool operator!= (const ResetDomain &a, const ResetDomain &b)
 
static Value createZeroValue (ImplicitLocOpBuilder &builder, FIRRTLBaseType type, SmallDenseMap< FIRRTLBaseType, Value > &cache)
 Construct a zero value of the given type using the given builder.
 
static Value createZeroValue (ImplicitLocOpBuilder &builder, FIRRTLBaseType type)
 Construct a null value of the given type using the given builder.
 
static bool insertResetMux (ImplicitLocOpBuilder &builder, Value target, Value reset, Value resetValue)
 Helper function that inserts reset multiplexer into all ConnectOps with the given target.
 
template<typename T >
static T & operator<< (T &os, const ResetKind &kind)
 
static unsigned getMaxFieldID (FIRRTLBaseType type)
 
static unsigned getFieldID (BundleType type, unsigned index)
 
static unsigned getFieldID (FVectorType type)
 
static unsigned getIndexForFieldID (BundleType type, unsigned fieldID)
 
static bool isUselessVec (FIRRTLBaseType oldType, unsigned fieldID)
 
static bool isUselessVec (FieldRef field)
 
static bool getDeclName (Value value, SmallString< 32 > &string)
 
static bool getFieldName (const FieldRef &fieldRef, SmallString< 32 > &string)
 
static bool typeContainsReset (Type type)
 Check whether a type contains a ResetType.
 
static FIRRTLBaseType updateType (FIRRTLBaseType oldType, unsigned fieldID, FIRRTLBaseType fieldType)
 Update the type of a single field within a type.
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "infer-resets"

Definition at line 32 of file InferResets.cpp.

◆ GEN_PASS_DEF_INFERRESETS

#define GEN_PASS_DEF_INFERRESETS

Definition at line 36 of file InferResets.cpp.

Function Documentation

◆ createZeroValue() [1/2]

static Value createZeroValue ( ImplicitLocOpBuilder &  builder,
FIRRTLBaseType  type 
)
static

Construct a null value of the given type using the given builder.

Definition at line 177 of file InferResets.cpp.

References createZeroValue().

◆ createZeroValue() [2/2]

static Value createZeroValue ( ImplicitLocOpBuilder &  builder,
FIRRTLBaseType  type,
SmallDenseMap< FIRRTLBaseType, Value > &  cache 
)
static

Construct a zero value of the given type using the given builder.

Definition at line 120 of file InferResets.cpp.

References circt::firrtl::FIRRTLTypeSwitch< T, ResultT >::Case(), createZeroValue(), circt::firrtl::emitConnect(), and circt::firrtl::FIRRTLBaseType::getConstType().

Referenced by createZeroValue(), and createZeroValue().

◆ getDeclName()

static bool getDeclName ( Value  value,
SmallString< 32 > &  string 
)
static

Definition at line 683 of file InferResets.cpp.

Referenced by getFieldName().

◆ getFieldID() [1/2]

static unsigned getFieldID ( BundleType  type,
unsigned  index 
)
static

Definition at line 627 of file InferResets.cpp.

References assert(), and getMaxFieldID().

Referenced by getFieldName(), isUselessVec(), and updateType().

◆ getFieldID() [2/2]

static unsigned getFieldID ( FVectorType  type)
static

Definition at line 635 of file InferResets.cpp.

◆ getFieldName()

static bool getFieldName ( const FieldRef fieldRef,
SmallString< 32 > &  string 
)
static

◆ getIndexForFieldID()

static unsigned getIndexForFieldID ( BundleType  type,
unsigned  fieldID 
)
static

Definition at line 637 of file InferResets.cpp.

References assert(), and getMaxFieldID().

Referenced by getFieldName(), isUselessVec(), and updateType().

◆ getMaxFieldID()

static unsigned getMaxFieldID ( FIRRTLBaseType  type)
static

◆ getResetName()

static StringAttr getResetName ( Value  reset)
static

Return the name of a reset.

The reset value must either be a module port or a wire/node operation.

Definition at line 72 of file InferResets.cpp.

References getResetNameAndModule().

◆ getResetNameAndModule()

static std::pair< StringAttr, FModuleOp > getResetNameAndModule ( Value  reset)
static

Return the name and parent module of a reset.

The reset value must either be a module port or a wire/node operation.

Definition at line 60 of file InferResets.cpp.

Referenced by getResetName().

◆ insertResetMux()

static bool insertResetMux ( ImplicitLocOpBuilder &  builder,
Value  target,
Value  reset,
Value  resetValue 
)
static

Helper function that inserts reset multiplexer into all ConnectOps with the given target.

Looks through SubfieldOp, SubindexOp, and SubaccessOp, and inserts multiplexers into connects to these subaccesses as well. Modifies the insertion location of the builder. Returns true if the resetValue was used in any way, false otherwise.

Definition at line 188 of file InferResets.cpp.

References insertResetMux().

Referenced by insertResetMux().

◆ isUselessVec() [1/2]

static bool isUselessVec ( FieldRef  field)
static

◆ isUselessVec() [2/2]

static bool isUselessVec ( FIRRTLBaseType  oldType,
unsigned  fieldID 
)
static

Definition at line 651 of file InferResets.cpp.

References assert(), getFieldID(), getIndexForFieldID(), and isUselessVec().

Referenced by isUselessVec(), and isUselessVec().

◆ operator!=()

bool operator!= ( const ResetDomain &  a,
const ResetDomain &  b 
)
inline

Definition at line 115 of file InferResets.cpp.

◆ operator<<()

template<typename T >
static T & operator<< ( T &  os,
const ResetKind &  kind 
)
static

Definition at line 318 of file InferResets.cpp.

◆ operator==()

bool operator== ( const ResetDomain &  a,
const ResetDomain &  b 
)
inline

Definition at line 111 of file InferResets.cpp.

◆ typeContainsReset()

static bool typeContainsReset ( Type  type)
static

Check whether a type contains a ResetType.

Definition at line 746 of file InferResets.cpp.

◆ updateType()

static FIRRTLBaseType updateType ( FIRRTLBaseType  oldType,
unsigned  fieldID,
FIRRTLBaseType  fieldType 
)
static

Update the type of a single field within a type.

Definition at line 1232 of file InferResets.cpp.

References assert(), circt::firrtl::FIRRTLBaseType::getConstType(), getFieldID(), getIndexForFieldID(), circt::firrtl::FIRRTLBaseType::isConst(), and updateType().

Referenced by updateType().