CIRCT  19.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
InferWidths.cpp File Reference
#include "PassDetails.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/Passes.h"
#include "circt/Support/Debug.h"
#include "circt/Support/FieldRef.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
Include dependency graph for InferWidths.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< InternedSlot< T > >
 

Namespaces

 mlir
 
 llvm
 

Macros

#define DEBUG_TYPE   "infer-widths"
 
#define EXPR_NAMES(x)    Root##x, Var##x, Derived##x, Id##x, Known##x, Add##x, Pow##x, Max##x, Min##x
 
#define EXPR_KINDS   EXPR_NAMES()
 
#define EXPR_CLASSES   EXPR_NAMES(Expr)
 

Typedefs

using ExprSolution = std::pair< std::optional< int32_t >, bool >
 

Functions

static void diagnoseUninferredType (InFlightDiagnostic &diag, Type t, Twine str)
 
static FieldRef getRefForIST (const hw::InnerSymTarget &ist)
 Get FieldRef pointing to the specified inner symbol target, which must be valid. More...
 
static uint64_t convertFieldIDToOurVersion (uint64_t fieldID, FIRRTLType type)
 Calculate the "InferWidths-fieldID" equivalent for the given fieldID + type. More...
 
template<typename T , typename std::enable_if< std::is_base_of< Expr, T >::value, int >::type = 0>
llvm::raw_ostream & operator<< (llvm::raw_ostream &os, const T &e)
 Allow rvalue refs to Expr and subclasses to be printed to streams. More...
 
template<typename T , typename std::enable_if< std::is_base_of< Expr, T >::value, int >::type = 0>
llvm::hash_code mlir::hash_value (const T &e)
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &os, const LinIneq &l)
 
static ExprSolution computeUnary (ExprSolution arg, llvm::function_ref< int32_t(int32_t)> operation)
 
static ExprSolution computeBinary (ExprSolution lhs, ExprSolution rhs, llvm::function_ref< int32_t(int32_t, int32_t)> operation)
 
static ExprSolution solveExpr (Expr *expr, SmallPtrSetImpl< Expr * > &seenVars, unsigned defaultWorklistSize)
 Compute the value of a constraint expr. More...
 
static bool hasUninferredWidth (Type type)
 Check if a type contains any FIRRTL type with uninferred widths. More...
 
static FIRRTLBaseType resizeType (FIRRTLBaseType type, uint32_t newWidth)
 Resize a uint, sint, or analog type to a specific width. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "infer-widths"

Definition at line 34 of file InferWidths.cpp.

◆ EXPR_CLASSES

#define EXPR_CLASSES   EXPR_NAMES(Expr)

Definition at line 130 of file InferWidths.cpp.

◆ EXPR_KINDS

#define EXPR_KINDS   EXPR_NAMES()

Definition at line 129 of file InferWidths.cpp.

◆ EXPR_NAMES

#define EXPR_NAMES (   x)     Root##x, Var##x, Derived##x, Id##x, Known##x, Add##x, Pow##x, Max##x, Min##x

Definition at line 127 of file InferWidths.cpp.

Typedef Documentation

◆ ExprSolution

using ExprSolution = std::pair<std::optional<int32_t>, bool>

Definition at line 837 of file InferWidths.cpp.

Function Documentation

◆ computeBinary()

static ExprSolution computeBinary ( ExprSolution  lhs,
ExprSolution  rhs,
llvm::function_ref< int32_t(int32_t, int32_t)>  operation 
)
static

Definition at line 847 of file InferWidths.cpp.

Referenced by solveExpr().

◆ computeUnary()

static ExprSolution computeUnary ( ExprSolution  arg,
llvm::function_ref< int32_t(int32_t)>  operation 
)
static

Definition at line 840 of file InferWidths.cpp.

Referenced by solveExpr().

◆ convertFieldIDToOurVersion()

static uint64_t convertFieldIDToOurVersion ( uint64_t  fieldID,
FIRRTLType  type 
)
static

Calculate the "InferWidths-fieldID" equivalent for the given fieldID + type.

Definition at line 82 of file InferWidths.cpp.

References circt::hw::FieldIdImpl::getSubTypeByFieldID().

◆ diagnoseUninferredType()

static void diagnoseUninferredType ( InFlightDiagnostic &  diag,
Type  t,
Twine  str 
)
static

Definition at line 46 of file InferWidths.cpp.

◆ getRefForIST()

static FieldRef getRefForIST ( const hw::InnerSymTarget &  ist)
static

Get FieldRef pointing to the specified inner symbol target, which must be valid.

Returns null FieldRef if target points to something with no value, such as a port of an external module.

Definition at line 66 of file InferWidths.cpp.

References assert().

◆ hasUninferredWidth()

static bool hasUninferredWidth ( Type  type)
static

Check if a type contains any FIRRTL type with uninferred widths.

Definition at line 1303 of file InferWidths.cpp.

◆ operator<<() [1/2]

llvm::raw_ostream& operator<< ( llvm::raw_ostream &  os,
const LinIneq &  l 
)
inline

Definition at line 734 of file InferWidths.cpp.

◆ operator<<() [2/2]

template<typename T , typename std::enable_if< std::is_base_of< Expr, T >::value, int >::type = 0>
llvm::raw_ostream& operator<< ( llvm::raw_ostream &  os,
const T &  e 
)
inline

Allow rvalue refs to Expr and subclasses to be printed to streams.

Definition at line 112 of file InferWidths.cpp.

◆ resizeType()

static FIRRTLBaseType resizeType ( FIRRTLBaseType  type,
uint32_t  newWidth 
)
static

Resize a uint, sint, or analog type to a specific width.

Definition at line 2177 of file InferWidths.cpp.

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

◆ solveExpr()

static ExprSolution solveExpr ( Expr *  expr,
SmallPtrSetImpl< Expr * > &  seenVars,
unsigned  defaultWorklistSize 
)
static

Compute the value of a constraint expr.

seenVars is used as a recursion breaker. Recursive variables are treated as zero. Returns the computed value and a boolean indicating whether a recursion was detected. This may be used to memoize the result of expressions in case they were not involved in a cycle (which may alter their value from the perspective of a variable).

Definition at line 864 of file InferWidths.cpp.

References computeBinary(), and computeUnary().