CIRCT 23.0.0git
Loading...
Searching...
No Matches
Functions
Expressions.cpp File Reference
#include "ImportVerilogInternals.h"
#include "circt/Dialect/Moore/MooreOps.h"
#include "circt/Dialect/Moore/MooreTypes.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 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

◆ 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 3184 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 27 of file Expressions.cpp.

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

◆ 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 42 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 88 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 111 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 2887 of file Expressions.cpp.

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

Referenced by 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 2925 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 2963 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 131 of file Expressions.cpp.

References context.