CIRCT  19.0.0git
Macros | Functions | Variables
LowerToHW.cpp File Reference
#include "../PassDetail.h"
#include "circt/Conversion/FIRRTLToHW.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/Emit/EmitOps.h"
#include "circt/Dialect/FIRRTL/AnnotationDetails.h"
#include "circt/Dialect/FIRRTL/FIRRTLAnnotations.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/FIRRTLVisitors.h"
#include "circt/Dialect/FIRRTL/NLATable.h"
#include "circt/Dialect/FIRRTL/Namespace.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/HW/InnerSymbolNamespace.h"
#include "circt/Dialect/LTL/LTLOps.h"
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/Seq/SeqOps.h"
#include "circt/Dialect/Sim/SimOps.h"
#include "circt/Dialect/Verif/VerifOps.h"
#include "circt/Support/BackedgeBuilder.h"
#include "circt/Support/Namespace.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/ImplicitLocOpBuilder.h"
#include "mlir/IR/Threading.h"
#include "mlir/Pass/Pass.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Mutex.h"
#include "llvm/Support/Parallel.h"
Include dependency graph for LowerToHW.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "lower-to-hw"
 

Functions

static bool isZeroBitFIRRTLType (Type type)
 Return true if the specified type is a sized FIRRTL type (Int or Analog) with zero bits. More...
 
static Value getSingleNonInstanceOperand (AttachOp op)
 
static LogicalResult verifyOpLegality (Operation *op)
 This verifies that the target operation has been lowered to a legal operation. More...
 
static IntType getWidestIntType (Type t1, Type t2)
 Given two FIRRTL integer types, return the widest one. More...
 
static Value castToFIRRTLType (Value val, Type type, ImplicitLocOpBuilder &builder)
 Cast a value to a desired target type. More...
 
static Value castFromFIRRTLType (Value val, Type type, ImplicitLocOpBuilder &builder)
 Cast from a FIRRTL type (potentially with a flip) to a standard type. More...
 
static void moveVerifAnno (ModuleOp top, AnnotationSet &annos, StringRef annoClass, StringRef attrBase)
 Move a ExtractTestCode related annotation from annotations to an attribute. More...
 
static unsigned getBitWidthFromVectorSize (unsigned size)
 
static void tryCopyName (Operation *dst, Operation *src)
 
static ArrayAttr getHWParameters (FExtModuleOp module, bool ignoreValues)
 Map the parameter specifier on the specified extmodule into the HWModule representation for parameters. More...
 
static Value tryEliminatingAttachesToAnalogValue (Value value, Operation *insertPoint)
 Given a value of analog type, check to see the only use of it is an attach. More...
 
static Value tryEliminatingConnectsToValue (Value flipValue, Operation *insertPoint, CircuitLoweringState &loweringState)
 Given a value of flip type, check to see if all of the uses of it are connects. More...
 
static SmallVector< SubfieldOp > getAllFieldAccesses (Value structValue, StringRef field)
 
static LogicalResult handleZeroBit (Value failedOperand, std::function< LogicalResult()> fn)
 Zero bit operands end up looking like failures from getLoweredValue. More...
 
template<typename... Args>
static Operation * buildImmediateVerifOp (ImplicitLocOpBuilder &builder, StringRef opName, Args &&...args)
 Helper function to build an immediate assert operation based on the original FIRRTL operation name. More...
 
template<typename... Args>
static Operation * buildConcurrentVerifOp (ImplicitLocOpBuilder &builder, StringRef opName, Args &&...args)
 Helper function to build a concurrent assert operation based on the original FIRRTL operation name. More...
 

Variables

static const char moduleHierarchyFileAttrName [] = "firrtl.moduleHierarchyFile"
 Attribute that indicates that the module hierarchy starting at the annotated module should be dumped to a file. More...
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "lower-to-hw"

Definition at line 49 of file LowerToHW.cpp.

Function Documentation

◆ buildConcurrentVerifOp()

template<typename... Args>
static Operation* buildConcurrentVerifOp ( ImplicitLocOpBuilder &  builder,
StringRef  opName,
Args &&...  args 
)
static

Helper function to build a concurrent assert operation based on the original FIRRTL operation name.

This reduces code duplication in lowerVerificationStatement.

Definition at line 4381 of file LowerToHW.cpp.

References builder.

◆ buildImmediateVerifOp()

template<typename... Args>
static Operation* buildImmediateVerifOp ( ImplicitLocOpBuilder &  builder,
StringRef  opName,
Args &&...  args 
)
static

Helper function to build an immediate assert operation based on the original FIRRTL operation name.

This reduces code duplication in lowerVerificationStatement.

Definition at line 4366 of file LowerToHW.cpp.

References builder.

◆ castFromFIRRTLType()

static Value castFromFIRRTLType ( Value  val,
Type  type,
ImplicitLocOpBuilder &  builder 
)
static

Cast from a FIRRTL type (potentially with a flip) to a standard type.

Definition at line 144 of file LowerToHW.cpp.

References builder.

Referenced by tryEliminatingAttachesToAnalogValue(), and tryEliminatingConnectsToValue().

◆ castToFIRRTLType()

static Value castToFIRRTLType ( Value  val,
Type  type,
ImplicitLocOpBuilder &  builder 
)
static

Cast a value to a desired target type.

This will insert struct casts and unrealized conversion casts as necessary.

Definition at line 130 of file LowerToHW.cpp.

References builder.

◆ getAllFieldAccesses()

static SmallVector<SubfieldOp> getAllFieldAccesses ( Value  structValue,
StringRef  field 
)
static

Definition at line 1265 of file LowerToHW.cpp.

References assert().

◆ getBitWidthFromVectorSize()

static unsigned getBitWidthFromVectorSize ( unsigned  size)
static

Definition at line 191 of file LowerToHW.cpp.

◆ getHWParameters()

static ArrayAttr getHWParameters ( FExtModuleOp  module,
bool  ignoreValues 
)
static

Map the parameter specifier on the specified extmodule into the HWModule representation for parameters.

If ignoreValues is true, all the values are dropped.

Definition at line 919 of file LowerToHW.cpp.

References builder, and circt::calyx::direction::get().

◆ getSingleNonInstanceOperand()

static Value getSingleNonInstanceOperand ( AttachOp  op)
static

Definition at line 68 of file LowerToHW.cpp.

References isZeroBitFIRRTLType().

◆ getWidestIntType()

static IntType getWidestIntType ( Type  t1,
Type  t2 
)
static

Given two FIRRTL integer types, return the widest one.

Definition at line 123 of file LowerToHW.cpp.

◆ handleZeroBit()

static LogicalResult handleZeroBit ( Value  failedOperand,
std::function< LogicalResult()>  fn 
)
static

Zero bit operands end up looking like failures from getLoweredValue.

This helper function invokes the closure specified if the operand was actually zero bit, or returns failure() if it was some other kind of failure.

Definition at line 1973 of file LowerToHW.cpp.

References assert(), and isZeroBitFIRRTLType().

◆ isZeroBitFIRRTLType()

static bool isZeroBitFIRRTLType ( Type  type)
static

Return true if the specified type is a sized FIRRTL type (Int or Analog) with zero bits.

Definition at line 61 of file LowerToHW.cpp.

Referenced by getSingleNonInstanceOperand(), and handleZeroBit().

◆ moveVerifAnno()

static void moveVerifAnno ( ModuleOp  top,
AnnotationSet annos,
StringRef  annoClass,
StringRef  attrBase 
)
static

Move a ExtractTestCode related annotation from annotations to an attribute.

Definition at line 165 of file LowerToHW.cpp.

References circt::calyx::direction::get(), and circt::firrtl::AnnotationSet::getAnnotation().

◆ tryCopyName()

static void tryCopyName ( Operation *  dst,
Operation *  src 
)
static

Definition at line 197 of file LowerToHW.cpp.

◆ tryEliminatingAttachesToAnalogValue()

static Value tryEliminatingAttachesToAnalogValue ( Value  value,
Operation *  insertPoint 
)
static

Given a value of analog type, check to see the only use of it is an attach.

If so, remove the attach and return the value being attached to it, converted to an HW inout type. If this isn't a situation we can handle, just return null.

Definition at line 1144 of file LowerToHW.cpp.

References builder, castFromFIRRTLType(), circt::calyx::direction::get(), and circt::firrtl::lowerType().

Referenced by tryEliminatingConnectsToValue().

◆ tryEliminatingConnectsToValue()

static Value tryEliminatingConnectsToValue ( Value  flipValue,
Operation *  insertPoint,
CircuitLoweringState &  loweringState 
)
static

Given a value of flip type, check to see if all of the uses of it are connects.

If so, remove the connects and return the value being connected to it, converted to an HW type. If this isn't a situation we can handle, just return null.

This can happen when there are no connects to the value. The 'mergePoint' location is where a 'hw.merge' operation should be inserted if needed.

Definition at line 1181 of file LowerToHW.cpp.

References assert(), builder, castFromFIRRTLType(), and tryEliminatingAttachesToAnalogValue().

◆ verifyOpLegality()

static LogicalResult verifyOpLegality ( Operation *  op)
static

This verifies that the target operation has been lowered to a legal operation.

This checks that the operation recursively has no FIRRTL operations or types.

Definition at line 86 of file LowerToHW.cpp.

Variable Documentation

◆ moduleHierarchyFileAttrName

const char moduleHierarchyFileAttrName[] = "firrtl.moduleHierarchyFile"
static

Attribute that indicates that the module hierarchy starting at the annotated module should be dumped to a file.

Definition at line 57 of file LowerToHW.cpp.