CIRCT 24.0.0git
Loading...
Searching...
No Matches
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

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

Macros

#define DEBUG_TYPE   "infer-widths"
#define GEN_PASS_DEF_INFERWIDTHS
#define EXPR_NAMES(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.
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.
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.
static bool hasUninferredWidth (Type type)
 Check if a type contains any FIRRTL type with uninferred widths.
static FIRRTLBaseType resizeType (FIRRTLBaseType type, uint32_t newWidth)
 Resize a uint, sint, or analog type to a specific width.

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)
Value:
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 832 of file InferWidths.cpp.

Function Documentation

◆ computeBinary()

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

Definition at line 842 of file InferWidths.cpp.

Referenced by solveExpr().

◆ computeUnary()

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

Definition at line 835 of file InferWidths.cpp.

Referenced by solveExpr().

◆ convertFieldIDToOurVersion()

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()

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

Definition at line 47 of file InferWidths.cpp.

References diagnoseUninferredType(), and circt::firrtl::type_dyn_cast().

Referenced by diagnoseUninferredType().

◆ hasUninferredWidth()

bool hasUninferredWidth ( Type type)
static

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

Definition at line 1280 of file InferWidths.cpp.

◆ operator<<() [1/2]

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

Definition at line 729 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()

FIRRTLBaseType resizeType ( FIRRTLBaseType type,
uint32_t newWidth )
static

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

Definition at line 2134 of file InferWidths.cpp.

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

◆ solveExpr()

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 868 of file InferWidths.cpp.

References computeBinary(), and computeUnary().