CIRCT  20.0.0git
Namespaces | Macros | Typedefs | Functions
InferWidths.cpp File Reference
#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 "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for InferWidths.cpp:

Go to the source code of this file.

Namespaces

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

Macros

#define DEBUG_TYPE   "infer-widths"
 
#define GEN_PASS_DEF_INFERWIDTHS
 
#define EXPR_NAMES(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 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, std::vector< Frame > &worklist)
 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 28 of file InferWidths.cpp.

◆ EXPR_CLASSES

#define EXPR_CLASSES   EXPR_NAMES(Expr)

Definition at line 113 of file InferWidths.cpp.

◆ EXPR_KINDS

#define EXPR_KINDS   EXPR_NAMES()

Definition at line 112 of file InferWidths.cpp.

◆ EXPR_NAMES

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

Definition at line 110 of file InferWidths.cpp.

◆ GEN_PASS_DEF_INFERWIDTHS

#define GEN_PASS_DEF_INFERWIDTHS

Definition at line 32 of file InferWidths.cpp.

Typedef Documentation

◆ ExprSolution

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

Definition at line 842 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 852 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 845 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 65 of file InferWidths.cpp.

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

◆ diagnoseUninferredType()

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

Definition at line 47 of file InferWidths.cpp.

◆ hasUninferredWidth()

static bool hasUninferredWidth ( Type  type)
static

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

Definition at line 1290 of file InferWidths.cpp.

◆ operator<<() [1/2]

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

Definition at line 739 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 95 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 2138 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,
std::vector< Frame > &  worklist 
)
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 878 of file InferWidths.cpp.

References computeBinary(), and computeUnary().