CIRCT 24.0.0git
Loading...
Searching...
No Matches
SVOps.cpp File Reference
#include "circt/Dialect/SV/SVOps.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/Emit/EmitOps.h"
#include "circt/Dialect/HW/CustomDirectiveImpl.h"
#include "circt/Dialect/HW/HWAttributes.h"
#include "circt/Dialect/HW/HWOps.h"
#include "circt/Dialect/HW/HWSymCache.h"
#include "circt/Dialect/HW/HWTypes.h"
#include "circt/Dialect/HW/ModuleImplementation.h"
#include "circt/Dialect/SV/SVAttributes.h"
#include "circt/Dialect/SV/SVTypes.h"
#include "circt/Support/CustomDirectiveImpl.h"
#include "circt/Support/ProceduralRegionTrait.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/Matchers.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/Interfaces/FunctionImplementation.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/TypeSwitch.h"
#include <optional>
#include "circt/Dialect/SV/SV.cpp.inc"
Include dependency graph for SVOps.cpp:

Go to the source code of this file.

Namespaces

namespace  AssertPropertyLikeOp

Macros

#define GET_OP_CLASSES

Functions

static Operation * lookupSymbolInNested (Operation *symbolTableOp, StringRef symbol)
 Returns the operation registered with the given symbol name with the regions of 'symbolTableOp'.
static LogicalResult verifyMacroIdentSymbolUses (Operation *op, FlatSymbolRefAttr attr, SymbolTableCollection &symbolTable)
 Verifies symbols referenced by macro identifiers.
template<typename Package>
static LogicalResult verifyPackage (Package package)
static LogicalResult verifyVerbatimSymbols (Operation *op, ArrayAttr symbols, hw::InnerRefNamespace &ns)
 Helper function to verify inner refs in symbols array for verbatim ops.
static LogicalResult verifyVerbatimFlatSymbolRefs (Operation *op, ArrayAttr symbols, SymbolTableCollection &symbolTable)
 Helper function to verify flat symbol refs in symbols array for verbatim ops.
static void getVerbatimExprAsmResultNames (Operation *op, function_ref< void(Value, StringRef)> setNameFn)
 Get the asm name for sv.verbatim.expr and sv.verbatim.expr.se.
static MacroDeclOp getReferencedMacro (const hw::HWSymbolCache *cache, Operation *op, FlatSymbolRefAttr macroName)
static ParseResult parseImplicitVarInitType (OpAsmParser &p, Type varType, std::optional< OpAsmParser::UnresolvedOperand > &initValue, Type &initType)
static void printImplicitVarInitType (OpAsmPrinter &p, Operation *op, Type varType, Value initValue, Type initType)
static ParseResult parseImplicitInitType (OpAsmParser &p, mlir::Type regType, std::optional< OpAsmParser::UnresolvedOperand > &initValue, mlir::Type &initType)
static void printImplicitInitType (OpAsmPrinter &p, Operation *op, mlir::Type regType, mlir::Value initValue, mlir::Type initType)
template<class Op>
static LogicalResult canonicalizeIfDefLike (Op op, PatternRewriter &rewriter)
static void replaceOpWithRegion (PatternRewriter &rewriter, Operation *op, Region &region)
 Replaces the given op with the contents of the given single-block region.
static ParseResult parseEventList (OpAsmParser &p, Attribute &eventsAttr, SmallVectorImpl< OpAsmParser::UnresolvedOperand > &clocksOperands)
static void printEventList (OpAsmPrinter &p, AlwaysOp op, ArrayAttr portsAttr, OperandRange operands)
static SmallVector< CasePatternBit > getPatternBitsForValue (const APInt &value)
static ParseResult parseSVHandleAssignmentTypes (OpAsmParser &parser, Type &destType, Type &srcType)
 Parse the assignment type suffix.
static void printSVHandleAssignmentTypes (OpAsmPrinter &printer, Operation *, Type destType, Type srcType)
template<typename AssignTy>
static LogicalResult mergeNeiboringAssignments (AssignTy op, PatternRewriter &rewriter)
static ParseResult parseModportStructs (OpAsmParser &parser, ArrayAttr &portsAttr)
static void printModportStructs (OpAsmPrinter &p, Operation *, ArrayAttr portsAttr)
ParseResult parseIfaceTypeAndSignal (OpAsmParser &p, Type &ifaceTy, FlatSymbolRefAttr &signalName)
void printIfaceTypeAndSignal (OpAsmPrinter &p, Operation *op, Type type, FlatSymbolRefAttr signalName)
LogicalResult verifySignalExists (Value ifaceVal, FlatSymbolRefAttr signalName)
static void buildWire (OpBuilder &builder, OperationState &odsState, Type resultType, StringAttr name, hw::InnerSymAttr innerSym)
static Type getElementTypeOfWidth (Type type, int32_t width)
template<class Op>
static Op findInstanceSymbolInBlock (StringAttr name, Block *body)
 Instances must be at the top level of the hw.module (or within a `ifdef).
ParseResult parseXMRPath (::mlir::OpAsmParser &parser, ArrayAttr &pathAttr, StringAttr &terminalAttr)
void printXMRPath (OpAsmPrinter &p, XMROp op, ArrayAttr pathAttr, StringAttr terminalAttr)
static LogicalResult eraseIfZeroOrNotZero (Operation *op, Value value, PatternRewriter &rewriter, bool eraseIfZero)
template<class Op, bool EraseIfZero = false>
static LogicalResult canonicalizeImmediateVerifOp (Op op, PatternRewriter &rewriter)
template<class Op, bool EraseIfZero = false>
static LogicalResult canonicalizeConcurrentVerifOp (Op op, PatternRewriter &rewriter)
bool parseCaseRegions (OpAsmParser &p, ArrayAttr &patternsArray, ArrayAttr &caseNamesArray, SmallVectorImpl< std::unique_ptr< Region > > &caseRegions)
 Parse cases formatted like: case (pattern, "name") { ... }.
void printCaseRegions (OpAsmPrinter &p, Operation *, ArrayAttr patternsArray, ArrayAttr namesArray, MutableArrayRef< Region > caseRegions)
 Print cases formatted like: case (pattern, "name") { ... }.
static ParseResult parseTypedAttrWithFallback (OpAsmParser &parser, TypedAttr &result, Type type)
static ParseResult parseGenerateFor (OpAsmParser &parser, TypedAttr &lowerBound, TypedAttr &upperBound, TypedAttr &step, StringAttr &inductionVarName, StringAttr &genBlockName, Region &body)
static void printGenerateFor (OpAsmPrinter &p, Operation *op, TypedAttr lowerBound, TypedAttr upperBound, TypedAttr step, StringAttr inductionVarName, StringAttr genBlockName, Region &body)
static Value getExplicitlyReturnedValueImpl (sv::FuncOp op, mlir::Operation::result_range results)
static LogicalResult AssertPropertyLikeOp::verify (Value clock, bool eventExists, mlir::Location loc)

Macro Definition Documentation

◆ GET_OP_CLASSES

#define GET_OP_CLASSES

Definition at line 3175 of file SVOps.cpp.

Function Documentation

◆ buildWire()

void buildWire ( OpBuilder & builder,
OperationState & odsState,
Type resultType,
StringAttr name,
hw::InnerSymAttr innerSym )
static

Definition at line 1863 of file SVOps.cpp.

◆ canonicalizeConcurrentVerifOp()

template<class Op, bool EraseIfZero = false>
LogicalResult canonicalizeConcurrentVerifOp ( Op op,
PatternRewriter & rewriter )
static

Definition at line 2597 of file SVOps.cpp.

References eraseIfZeroOrNotZero().

◆ canonicalizeIfDefLike()

template<class Op>
LogicalResult canonicalizeIfDefLike ( Op op,
PatternRewriter & rewriter )
static

Definition at line 583 of file SVOps.cpp.

References failure(), and success().

◆ canonicalizeImmediateVerifOp()

template<class Op, bool EraseIfZero = false>
LogicalResult canonicalizeImmediateVerifOp ( Op op,
PatternRewriter & rewriter )
static

Definition at line 2576 of file SVOps.cpp.

References eraseIfZeroOrNotZero().

◆ eraseIfZeroOrNotZero()

LogicalResult eraseIfZeroOrNotZero ( Operation * op,
Value value,
PatternRewriter & rewriter,
bool eraseIfZero )
static

Definition at line 2563 of file SVOps.cpp.

References failure(), and success().

◆ findInstanceSymbolInBlock()

template<class Op>
Op findInstanceSymbolInBlock ( StringAttr name,
Block * body )
static

Instances must be at the top level of the hw.module (or within a `ifdef).

Definition at line 2109 of file SVOps.cpp.

References findInstanceSymbolInBlock().

Referenced by findInstanceSymbolInBlock().

◆ getElementTypeOfWidth()

Type getElementTypeOfWidth ( Type type,
int32_t width )
static

◆ getExplicitlyReturnedValueImpl()

Value getExplicitlyReturnedValueImpl ( sv::FuncOp op,
mlir::Operation::result_range results )
static

Definition at line 3078 of file SVOps.cpp.

◆ getPatternBitsForValue()

SmallVector< CasePatternBit > getPatternBitsForValue ( const APInt & value)
static

Definition at line 980 of file SVOps.cpp.

Referenced by circt::sv::CaseBitPattern::CaseBitPattern().

◆ getReferencedMacro()

MacroDeclOp getReferencedMacro ( const hw::HWSymbolCache * cache,
Operation * op,
FlatSymbolRefAttr macroName )
static

Definition at line 230 of file SVOps.cpp.

◆ getVerbatimExprAsmResultNames()

void getVerbatimExprAsmResultNames ( Operation * op,
function_ref< void(Value, StringRef)> setNameFn )
static

Get the asm name for sv.verbatim.expr and sv.verbatim.expr.se.

Definition at line 171 of file SVOps.cpp.

◆ lookupSymbolInNested()

Operation * lookupSymbolInNested ( Operation * symbolTableOp,
StringRef symbol )
static

Returns the operation registered with the given symbol name with the regions of 'symbolTableOp'.

recurse through nested regions which don't contain the symboltable trait. Returns nullptr if no valid symbol was found.

Definition at line 63 of file SVOps.cpp.

References lookupSymbolInNested().

Referenced by lookupSymbolInNested().

◆ mergeNeiboringAssignments()

template<typename AssignTy>
LogicalResult mergeNeiboringAssignments ( AssignTy op,
PatternRewriter & rewriter )
static

Definition at line 1557 of file SVOps.cpp.

References hw.ArraySliceOp::create(), failure(), and success().

◆ parseCaseRegions()

bool parseCaseRegions ( OpAsmParser & p,
ArrayAttr & patternsArray,
ArrayAttr & caseNamesArray,
SmallVectorImpl< std::unique_ptr< Region > > & caseRegions )

Parse cases formatted like: case (pattern, "name") { ... }.

Definition at line 2624 of file SVOps.cpp.

◆ parseEventList()

ParseResult parseEventList ( OpAsmParser & p,
Attribute & eventsAttr,
SmallVectorImpl< OpAsmParser::UnresolvedOperand > & clocksOperands )
static

Definition at line 815 of file SVOps.cpp.

References failure(), and success().

◆ parseGenerateFor()

ParseResult parseGenerateFor ( OpAsmParser & parser,
TypedAttr & lowerBound,
TypedAttr & upperBound,
TypedAttr & step,
StringAttr & inductionVarName,
StringAttr & genBlockName,
Region & body )
static

Definition at line 2720 of file SVOps.cpp.

References failure(), isdigit, and parseTypedAttrWithFallback().

◆ parseIfaceTypeAndSignal()

ParseResult parseIfaceTypeAndSignal ( OpAsmParser & p,
Type & ifaceTy,
FlatSymbolRefAttr & signalName )

Definition at line 1801 of file SVOps.cpp.

References failure(), and success().

◆ parseImplicitInitType()

ParseResult parseImplicitInitType ( OpAsmParser & p,
mlir::Type regType,
std::optional< OpAsmParser::UnresolvedOperand > & initValue,
mlir::Type & initType )
static

Definition at line 435 of file SVOps.cpp.

References success().

◆ parseImplicitVarInitType()

ParseResult parseImplicitVarInitType ( OpAsmParser & p,
Type varType,
std::optional< OpAsmParser::UnresolvedOperand > & initValue,
Type & initType )
static

Definition at line 387 of file SVOps.cpp.

References success().

◆ parseModportStructs()

ParseResult parseModportStructs ( OpAsmParser & parser,
ArrayAttr & portsAttr )
static

Definition at line 1645 of file SVOps.cpp.

References context, failure(), and success().

◆ parseSVHandleAssignmentTypes()

ParseResult parseSVHandleAssignmentTypes ( OpAsmParser & parser,
Type & destType,
Type & srcType )
static

Parse the assignment type suffix.

The legacy form gives only the source element type and implies an inout destination. We need to supply an extended form for both the destination handle type and source type since we extend support for multiple handle types. TOOD: This shall be removed once migrated from.

Definition at line 1441 of file SVOps.cpp.

References failure(), and success().

◆ parseTypedAttrWithFallback()

ParseResult parseTypedAttrWithFallback ( OpAsmParser & parser,
TypedAttr & result,
Type type )
static

Definition at line 2691 of file SVOps.cpp.

References failure(), and success().

Referenced by parseGenerateFor().

◆ parseXMRPath()

ParseResult parseXMRPath ( ::mlir::OpAsmParser & parser,
ArrayAttr & pathAttr,
StringAttr & terminalAttr )

Definition at line 2508 of file SVOps.cpp.

References failure(), and success().

◆ printCaseRegions()

void printCaseRegions ( OpAsmPrinter & p,
Operation * ,
ArrayAttr patternsArray,
ArrayAttr namesArray,
MutableArrayRef< Region > caseRegions )

Print cases formatted like: case (pattern, "name") { ... }.

Definition at line 2649 of file SVOps.cpp.

References assert().

◆ printEventList()

void printEventList ( OpAsmPrinter & p,
AlwaysOp op,
ArrayAttr portsAttr,
OperandRange operands )
static

Definition at line 846 of file SVOps.cpp.

◆ printGenerateFor()

void printGenerateFor ( OpAsmPrinter & p,
Operation * op,
TypedAttr lowerBound,
TypedAttr upperBound,
TypedAttr step,
StringAttr inductionVarName,
StringAttr genBlockName,
Region & body )
static

Definition at line 2772 of file SVOps.cpp.

◆ printIfaceTypeAndSignal()

void printIfaceTypeAndSignal ( OpAsmPrinter & p,
Operation * op,
Type type,
FlatSymbolRefAttr signalName )

Definition at line 1814 of file SVOps.cpp.

References assert().

◆ printImplicitInitType()

void printImplicitInitType ( OpAsmPrinter & p,
Operation * op,
mlir::Type regType,
mlir::Value initValue,
mlir::Type initType )
static

Definition at line 449 of file SVOps.cpp.

◆ printImplicitVarInitType()

void printImplicitVarInitType ( OpAsmPrinter & p,
Operation * op,
Type varType,
Value initValue,
Type initType )
static

Definition at line 402 of file SVOps.cpp.

◆ printModportStructs()

void printModportStructs ( OpAsmPrinter & p,
Operation * ,
ArrayAttr portsAttr )
static

Definition at line 1672 of file SVOps.cpp.

◆ printSVHandleAssignmentTypes()

void printSVHandleAssignmentTypes ( OpAsmPrinter & printer,
Operation * ,
Type destType,
Type srcType )
static

Definition at line 1458 of file SVOps.cpp.

◆ printXMRPath()

void printXMRPath ( OpAsmPrinter & p,
XMROp op,
ArrayAttr pathAttr,
StringAttr terminalAttr )

Definition at line 2533 of file SVOps.cpp.

◆ replaceOpWithRegion()

void replaceOpWithRegion ( PatternRewriter & rewriter,
Operation * op,
Region & region )
static

Replaces the given op with the contents of the given single-block region.

Definition at line 714 of file SVOps.cpp.

References assert().

◆ verifyMacroIdentSymbolUses()

LogicalResult verifyMacroIdentSymbolUses ( Operation * op,
FlatSymbolRefAttr attr,
SymbolTableCollection & symbolTable )
static

Verifies symbols referenced by macro identifiers.

Definition at line 86 of file SVOps.cpp.

References success().

◆ verifyPackage()

template<typename Package>
LogicalResult verifyPackage ( Package package)
static

Definition at line 101 of file SVOps.cpp.

References success().

◆ verifySignalExists()

LogicalResult verifySignalExists ( Value ifaceVal,
FlatSymbolRefAttr signalName )

Definition at line 1823 of file SVOps.cpp.

References failure(), and success().

◆ verifyVerbatimFlatSymbolRefs()

LogicalResult verifyVerbatimFlatSymbolRefs ( Operation * op,
ArrayAttr symbols,
SymbolTableCollection & symbolTable )
static

Helper function to verify flat symbol refs in symbols array for verbatim ops.

Definition at line 143 of file SVOps.cpp.

References success().

◆ verifyVerbatimSymbols()

LogicalResult verifyVerbatimSymbols ( Operation * op,
ArrayAttr symbols,
hw::InnerRefNamespace & ns )
static

Helper function to verify inner refs in symbols array for verbatim ops.

Definition at line 127 of file SVOps.cpp.

References success().