CIRCT  19.0.0git
Classes | Namespaces | Macros | Typedefs | Functions
InferWidths.cpp File Reference
#include "circt/Dialect/FIRRTL/FIRRTLOps.h"
#include "circt/Dialect/FIRRTL/Passes.h"
#include "mlir/Pass/Pass.h"
#include "circt/Dialect/FIRRTL/FIRRTLTypes.h"
#include "circt/Dialect/FIRRTL/FIRRTLUtils.h"
#include "circt/Dialect/FIRRTL/FIRRTLVisitors.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 "circt/Dialect/FIRRTL/Passes.h.inc"
Include dependency graph for InferWidths.cpp:

Go to the source code of this file.

Classes

struct  llvm::DenseMapInfo< InternedSlot< T > >
 

Namespaces

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

Macros

#define DEBUG_TYPE   "infer-widths"
 
#define GEN_PASS_DEF_INFERWIDTHS
 
#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 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 36 of file InferWidths.cpp.

◆ EXPR_CLASSES

#define EXPR_CLASSES   EXPR_NAMES(Expr)

Definition at line 121 of file InferWidths.cpp.

◆ EXPR_KINDS

#define EXPR_KINDS   EXPR_NAMES()

Definition at line 120 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 118 of file InferWidths.cpp.

◆ GEN_PASS_DEF_INFERWIDTHS

#define GEN_PASS_DEF_INFERWIDTHS

Definition at line 40 of file InferWidths.cpp.

Typedef Documentation

◆ ExprSolution

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

Definition at line 828 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 838 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 831 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 73 of file InferWidths.cpp.

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

◆ diagnoseUninferredType()

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

Definition at line 55 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 1294 of file InferWidths.cpp.

◆ operator<<() [1/2]

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

Definition at line 725 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 103 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 2168 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 855 of file InferWidths.cpp.

References computeBinary(), and computeUnary().