CIRCT 23.0.0git
Loading...
Searching...
No Matches
Functions
Expressions.cpp File Reference
#include "ImportVerilogInternals.h"
#include "circt/Dialect/Comb/CombOps.h"
#include "circt/Dialect/Moore/MooreOps.h"
#include "circt/Dialect/Moore/MooreTypes.h"
#include "circt/Support/FVInt.h"
#include "mlir/IR/Operation.h"
#include "mlir/IR/Value.h"
#include "slang/ast/EvalContext.h"
#include "slang/ast/SystemSubroutine.h"
#include "slang/ast/types/AllTypes.h"
#include "slang/syntax/AllSyntax.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/SaveAndRestore.h"
Include dependency graph for Expressions.cpp:

Go to the source code of this file.

Functions

static FVInt convertSVIntToFVInt (const slang::SVInt &svint)
 Convert a Slang SVInt to a CIRCT FVInt.
 
static Value getIsUnknown (OpBuilder &builder, Location loc, Value value, moore::IntType valTy, MLIRContext *ctx)
 Check if a Moore integer value contains any unknown (x/z) bits.
 
static Value coerceToBuiltinInt (OpBuilder &builder, Location loc, Value value, moore::IntType valTy)
 Coerce a Moore integer value to a builtin integer, handling four-valued inputs by first mapping x/z to 0 via LogicToIntOp.
 
static Value getSelectIndex (Context &context, Location loc, Value index, const slang::ConstantRange &range)
 Map an index into an array, with bounds range, to a bit offset of the underlying bit storage.
 
static uint64_t getTimeScaleInFemtoseconds (Context &context)
 Get the currently active timescale as an integer number of femtoseconds.
 
static Value lookupExpandedInterfaceMember (Context &context, const slang::ast::HierarchicalValueExpression &expr)
 Resolve a hierarchical value that refers to a member of an expanded interface instance.
 
static Value visitClassProperty (Context &context, const slang::ast::ClassPropertySymbol &expr)
 
static Value materializePackedToSBVConversion (Context &context, Value value, Location loc, bool fallible)
 Create the necessary operations to convert from a PackedType to the corresponding simple bit vector IntType.
 
static Value materializeSBVToPackedConversion (Context &context, moore::PackedType packedType, Value value, Location loc, bool fallible)
 Create the necessary operations to convert from a simple bit vector IntType to an equivalent PackedType.
 
static mlir::Value maybeUpcastHandle (Context &context, mlir::Value actualHandle, moore::ClassHandleType expectedHandleTy)
 Check whether the actual handle is a subclass of another handle type and return a properly upcast version if so.
 
template<typename OpTy >
static Value convertRealMathBI (Context &context, Location loc, StringRef name, std::span< const slang::ast::Expression *const > args)
 Helper function to convert real math builtin functions that take exactly one argument.
 
static mlir::Operation * resolve (Context &context, mlir::SymbolRefAttr sym)
 

Function Documentation

◆ coerceToBuiltinInt()

static Value coerceToBuiltinInt ( OpBuilder &  builder,
Location  loc,
Value  value,
moore::IntType  valTy 
)
static

Coerce a Moore integer value to a builtin integer, handling four-valued inputs by first mapping x/z to 0 via LogicToIntOp.

Definition at line 58 of file Expressions.cpp.

Referenced by circt::ImportVerilog::Context::convertSystemCall().

◆ convertRealMathBI()

template<typename OpTy >
static Value convertRealMathBI ( Context context,
Location  loc,
StringRef  name,
std::span< const slang::ast::Expression *const >  args 
)
static

Helper function to convert real math builtin functions that take exactly one argument.

Definition at line 3241 of file Expressions.cpp.

References assert(), and context.

◆ convertSVIntToFVInt()

static FVInt convertSVIntToFVInt ( const slang::SVInt &  svint)
static

Convert a Slang SVInt to a CIRCT FVInt.

Definition at line 29 of file Expressions.cpp.

Referenced by circt::ImportVerilog::Context::materializeFixedSizeUnpackedArrayType(), and circt::ImportVerilog::Context::materializeSVInt().

◆ getIsUnknown()

static Value getIsUnknown ( OpBuilder &  builder,
Location  loc,
Value  value,
moore::IntType  valTy,
MLIRContext *  ctx 
)
static

Check if a Moore integer value contains any unknown (x/z) bits.

Returns a Moore i1 result: 1 if any bit is unknown, 0 otherwise.

Definition at line 43 of file Expressions.cpp.

References circt::FVInt::getAllX().

Referenced by circt::ImportVerilog::Context::convertSystemCall().

◆ getSelectIndex()

static Value getSelectIndex ( Context context,
Location  loc,
Value  index,
const slang::ConstantRange &  range 
)
static

Map an index into an array, with bounds range, to a bit offset of the underlying bit storage.

This is a dynamic version of slang::ConstantRange::translateIndex.

Definition at line 68 of file Expressions.cpp.

References context.

◆ getTimeScaleInFemtoseconds()

static uint64_t getTimeScaleInFemtoseconds ( Context context)
static

Get the currently active timescale as an integer number of femtoseconds.

Definition at line 114 of file Expressions.cpp.

References assert(), and context.

Referenced by circt::ImportVerilog::Context::materializeConversion(), materializePackedToSBVConversion(), and materializeSBVToPackedConversion().

◆ lookupExpandedInterfaceMember()

static Value lookupExpandedInterfaceMember ( Context context,
const slang::ast::HierarchicalValueExpression &  expr 
)
static

Resolve a hierarchical value that refers to a member of an expanded interface instance.

Definition at line 137 of file Expressions.cpp.

References context.

◆ materializePackedToSBVConversion()

static Value materializePackedToSBVConversion ( Context context,
Value  value,
Location  loc,
bool  fallible 
)
static

Create the necessary operations to convert from a PackedType to the corresponding simple bit vector IntType.

This will apply special handling to time values, which requires scaling by the local timescale.

Definition at line 2944 of file Expressions.cpp.

References assert(), context, circt::moore::FourValued, getTimeScaleInFemtoseconds(), and circt::moore::isIntType().

Referenced by circt::ImportVerilog::Context::convertSystemCall(), and circt::ImportVerilog::Context::materializeConversion().

◆ materializeSBVToPackedConversion()

static Value materializeSBVToPackedConversion ( Context context,
moore::PackedType  packedType,
Value  value,
Location  loc,
bool  fallible 
)
static

Create the necessary operations to convert from a simple bit vector IntType to an equivalent PackedType.

This will apply special handling to time values, which requires scaling by the local timescale.

Definition at line 2982 of file Expressions.cpp.

References assert(), circt::moore::PackedType::containsTimeType(), context, circt::moore::FourValued, circt::moore::PackedType::getSimpleBitVector(), getTimeScaleInFemtoseconds(), and circt::moore::isIntType().

Referenced by circt::ImportVerilog::Context::materializeConversion().

◆ maybeUpcastHandle()

static mlir::Value maybeUpcastHandle ( Context context,
mlir::Value  actualHandle,
moore::ClassHandleType  expectedHandleTy 
)
static

Check whether the actual handle is a subclass of another handle type and return a properly upcast version if so.

Definition at line 3020 of file Expressions.cpp.

References context.

Referenced by circt::ImportVerilog::Context::materializeConversion().

◆ resolve()

static mlir::Operation * resolve ( Context context,
mlir::SymbolRefAttr  sym 
)
static

◆ visitClassProperty()

static Value visitClassProperty ( Context context,
const slang::ast::ClassPropertySymbol &  expr 
)
static

Definition at line 157 of file Expressions.cpp.

References context.