CIRCT  18.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
InferResets.cpp File Reference
#include "PassDetails.h"
#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/FieldRef.h"
#include "circt/Support/InstanceGraphInterface.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "llvm/ADT/EquivalenceClasses.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/Support/Debug.h"
Include dependency graph for InferResets.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< ResetSignal >
 

Namespaces

 llvm
 

Macros

#define DEBUG_TYPE   "infer-resets"
 

Typedefs

using InstanceLike = ::circt::igraph::InstanceOpInterface
 An absolute instance path. More...
 
using InstancePathRef = ArrayRef< InstanceLike >
 
using InstancePathVec = SmallVector< InstanceLike >
 

Functions

template<typename T >
static T & operator<< (T &os, InstancePathRef path)
 
static StringRef getTail (InstancePathRef path)
 
bool operator== (const ResetDomain &a, const ResetDomain &b)
 
bool operator!= (const ResetDomain &a, const ResetDomain &b)
 
static std::pair< StringAttr, FModuleOp > getResetNameAndModule (Value reset)
 Return the name and parent module of a reset. More...
 
static StringAttr getResetName (Value reset)
 Return the name of a reset. More...
 
static Value createZeroValue (ImplicitLocOpBuilder &builder, FIRRTLBaseType type, SmallDenseMap< FIRRTLBaseType, Value > &cache)
 Construct a zero value of the given type using the given builder. More...
 
static Value createZeroValue (ImplicitLocOpBuilder &builder, FIRRTLBaseType type)
 Construct a null value of the given type using the given builder. More...
 
static bool insertResetMux (ImplicitLocOpBuilder &builder, Value target, Value reset, Value resetValue)
 Helper function that inserts reset multiplexer into all ConnectOps with the given target. More...
 
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. More...
 
static FIRRTLBaseType updateType (FIRRTLBaseType oldType, unsigned fieldID, FIRRTLBaseType fieldType)
 Update the type of a single field within a type. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "infer-resets"

Definition at line 31 of file InferResets.cpp.

Typedef Documentation

◆ InstanceLike

using InstanceLike = ::circt::igraph::InstanceOpInterface

An absolute instance path.

Definition at line 49 of file InferResets.cpp.

◆ InstancePathRef

using InstancePathRef = ArrayRef<InstanceLike>

Definition at line 50 of file InferResets.cpp.

◆ InstancePathVec

using InstancePathVec = SmallVector<InstanceLike>

Definition at line 51 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 173 of file InferResets.cpp.

References builder, and 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 116 of file InferResets.cpp.

References builder, circt::firrtl::FIRRTLTypeSwitch< T, ResultT >::Case(), circt::calyx::direction::get(), circt::firrtl::FIRRTLBaseType::getConstType(), and value.

Referenced by createZeroValue().

◆ getDeclName()

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

Definition at line 665 of file InferResets.cpp.

References value.

Referenced by getFieldName().

◆ getFieldID() [1/2]

static unsigned getFieldID ( BundleType  type,
unsigned  index 
)
static

Definition at line 609 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 617 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 619 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)
inlinestatic

Return the name of a reset.

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

Definition at line 111 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 98 of file InferResets.cpp.

Referenced by getResetName().

◆ getTail()

static StringRef getTail ( InstancePathRef  path)
static

Definition at line 63 of file InferResets.cpp.

◆ 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 184 of file InferResets.cpp.

References builder, and lec::dbgs().

◆ isUselessVec() [1/2]

static bool isUselessVec ( FieldRef  field)
static

◆ isUselessVec() [2/2]

static bool isUselessVec ( FIRRTLBaseType  oldType,
unsigned  fieldID 
)
static

Definition at line 633 of file InferResets.cpp.

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

Referenced by isUselessVec().

◆ operator!=()

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

Definition at line 92 of file InferResets.cpp.

◆ operator<<() [1/2]

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

Definition at line 305 of file InferResets.cpp.

◆ operator<<() [2/2]

template<typename T >
static T& operator<< ( T &  os,
InstancePathRef  path 
)
static

Definition at line 54 of file InferResets.cpp.

◆ operator==()

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

Definition at line 89 of file InferResets.cpp.

◆ typeContainsReset()

static bool typeContainsReset ( Type  type)
static

Check whether a type contains a ResetType.

Definition at line 728 of file InferResets.cpp.

◆ updateType()

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