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 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 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.
 
template<typename OpTy >
static Value convertRealMathTwoBI (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 two arguments.
 
static LogicalResult emitScanAssignments (Context &context, const Context::ScanStringResult &result, Location loc)
 
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 3286 of file Expressions.cpp.

References assert(), and context.

◆ convertRealMathTwoBI()

template<typename OpTy >
static Value convertRealMathTwoBI ( 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 two arguments.

Definition at line 3300 of file Expressions.cpp.

References assert(), context, and circt::moore::f64.

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

◆ emitScanAssignments()

static LogicalResult emitScanAssignments ( Context context,
const Context::ScanStringResult &  result,
Location  loc 
)
static

Definition at line 3314 of file Expressions.cpp.

References context.

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

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

◆ getTimeScaleInFemtoseconds()

static uint64_t getTimeScaleInFemtoseconds ( Context context)
static

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

Definition at line 111 of file Expressions.cpp.

References assert(), and context.

Referenced by circt::ImportVerilog::Context::materializeConversion(), circt::ImportVerilog::Context::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 134 of file Expressions.cpp.

References context.

◆ 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 3027 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 3065 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 154 of file Expressions.cpp.

References context.