CIRCT  20.0.0git
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
circt::om::Evaluator Struct Reference

An Evaluator, which is constructed with an IR module and can instantiate Objects. More...

#include <Evaluator.h>

Collaboration diagram for circt::om::Evaluator:
Collaboration graph
[legend]

Public Types

using ActualParameters = SmallVectorImpl< std::shared_ptr< evaluator::EvaluatorValue > > *
 
using ObjectKey = std::pair< Value, ActualParameters >
 

Public Member Functions

 Evaluator (ModuleOp mod)
 Construct an Evaluator with an IR module. More...
 
FailureOr< evaluator::EvaluatorValuePtrinstantiate (StringAttr className, ArrayRef< EvaluatorValuePtr > actualParams)
 Instantiate an Object with its class name and actual parameters. More...
 
mlir::ModuleOp getModule ()
 Get the Module this Evaluator is built from. More...
 
FailureOr< evaluator::EvaluatorValuePtrgetPartiallyEvaluatedValue (Type type, Location loc)
 

Private Member Functions

bool isFullyEvaluated (Value value, ActualParameters key)
 
bool isFullyEvaluated (ObjectKey key)
 
FailureOr< EvaluatorValuePtrgetOrCreateValue (Value value, ActualParameters actualParams, Location loc)
 
FailureOr< EvaluatorValuePtrallocateObjectInstance (StringAttr clasName, ActualParameters actualParams)
 
FailureOr< EvaluatorValuePtrevaluateValue (Value value, ActualParameters actualParams, Location loc)
 Evaluate a Value in a Class body according to the small expression grammar described in the rationale document. More...
 
FailureOr< EvaluatorValuePtrevaluateParameter (BlockArgument formalParam, ActualParameters actualParams, Location loc)
 Evaluator dispatch functions for the small expression grammar. More...
 
FailureOr< EvaluatorValuePtrevaluateConstant (ConstantOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for constants. More...
 
FailureOr< EvaluatorValuePtrevaluateIntegerBinaryArithmetic (IntegerBinaryArithmeticOp op, ActualParameters actualParams, Location loc)
 
FailureOr< EvaluatorValuePtrevaluateObjectInstance (StringAttr className, ActualParameters actualParams, Location loc, ObjectKey instanceKey={})
 Instantiate an Object with its class name and actual parameters. More...
 
FailureOr< EvaluatorValuePtrevaluateObjectInstance (ObjectOp op, ActualParameters actualParams)
 Evaluator dispatch function for Object instances. More...
 
FailureOr< EvaluatorValuePtrevaluateObjectField (ObjectFieldOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for Object fields. More...
 
FailureOr< EvaluatorValuePtrevaluateListCreate (ListCreateOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for List creation. More...
 
FailureOr< EvaluatorValuePtrevaluateListConcat (ListConcatOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for List concatenation. More...
 
FailureOr< EvaluatorValuePtrevaluateTupleCreate (TupleCreateOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for Tuple creation. More...
 
FailureOr< EvaluatorValuePtrevaluateTupleGet (TupleGetOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for List creation. More...
 
FailureOr< evaluator::EvaluatorValuePtrevaluateMapCreate (MapCreateOp op, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for Map creation. More...
 
FailureOr< evaluator::EvaluatorValuePtrevaluateBasePathCreate (FrozenBasePathCreateOp op, ActualParameters actualParams, Location loc)
 
FailureOr< evaluator::EvaluatorValuePtrevaluatePathCreate (FrozenPathCreateOp op, ActualParameters actualParams, Location loc)
 
FailureOr< evaluator::EvaluatorValuePtrevaluateEmptyPath (FrozenEmptyPathOp op, ActualParameters actualParams, Location loc)
 
FailureOr< ActualParameterscreateParametersFromOperands (ValueRange range, ActualParameters actualParams, Location loc)
 Evaluator dispatch function for Object instances. More...
 

Private Attributes

SymbolTable symbolTable
 The symbol table for the IR module the Evaluator was constructed with. More...
 
SmallVector< std::unique_ptr< SmallVector< std::shared_ptr< evaluator::EvaluatorValue > > > > actualParametersBuffers
 This uniquely stores vectors that represent parameters. More...
 
std::queue< ObjectKeyworklist
 A worklist that tracks values which needs to be fully evaluated. More...
 
DenseMap< ObjectKey, std::shared_ptr< evaluator::EvaluatorValue > > objects
 Evaluator value storage. More...
 

Detailed Description

An Evaluator, which is constructed with an IR module and can instantiate Objects.

Further refinement is expected.

Definition at line 420 of file Evaluator.h.

Member Typedef Documentation

◆ ActualParameters

using circt::om::Evaluator::ActualParameters = SmallVectorImpl<std::shared_ptr<evaluator::EvaluatorValue> > *

Definition at line 434 of file Evaluator.h.

◆ ObjectKey

Definition at line 437 of file Evaluator.h.

Constructor & Destructor Documentation

◆ Evaluator()

circt::om::Evaluator::Evaluator ( ModuleOp  mod)

Construct an Evaluator with an IR module.

Definition at line 26 of file Evaluator.cpp.

Member Function Documentation

◆ allocateObjectInstance()

FailureOr<EvaluatorValuePtr> circt::om::Evaluator::allocateObjectInstance ( StringAttr  clasName,
ActualParameters  actualParams 
)
private

◆ createParametersFromOperands()

FailureOr< circt::om::Evaluator::ActualParameters > circt::om::Evaluator::createParametersFromOperands ( ValueRange  range,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for Object instances.

Definition at line 496 of file Evaluator.cpp.

◆ evaluateBasePathCreate()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateBasePathCreate ( FrozenBasePathCreateOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Definition at line 693 of file Evaluator.cpp.

◆ evaluateConstant()

FailureOr< circt::om::evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateConstant ( ConstantOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for constants.

Definition at line 408 of file Evaluator.cpp.

◆ evaluateEmptyPath()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateEmptyPath ( FrozenEmptyPathOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Definition at line 726 of file Evaluator.cpp.

◆ evaluateIntegerBinaryArithmetic()

FailureOr< EvaluatorValuePtr > circt::om::Evaluator::evaluateIntegerBinaryArithmetic ( IntegerBinaryArithmeticOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

◆ evaluateListConcat()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateListConcat ( ListConcatOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for List concatenation.

Definition at line 594 of file Evaluator.cpp.

References circt::om::evaluator::ListValue::getElements().

◆ evaluateListCreate()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateListCreate ( ListCreateOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for List creation.

Definition at line 571 of file Evaluator.cpp.

◆ evaluateMapCreate()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateMapCreate ( MapCreateOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for Map creation.

Definition at line 664 of file Evaluator.cpp.

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

◆ evaluateObjectField()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateObjectField ( ObjectFieldOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for Object fields.

Definition at line 532 of file Evaluator.cpp.

◆ evaluateObjectInstance() [1/2]

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateObjectInstance ( ObjectOp  op,
ActualParameters  actualParams 
)
private

Evaluator dispatch function for Object instances.

Definition at line 516 of file Evaluator.cpp.

◆ evaluateObjectInstance() [2/2]

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateObjectInstance ( StringAttr  className,
ActualParameters  actualParams,
Location  loc,
ObjectKey  instanceKey = {} 
)
private

Instantiate an Object with its class name and actual parameters.

Definition at line 191 of file Evaluator.cpp.

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

◆ evaluateParameter()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateParameter ( BlockArgument  formalParam,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch functions for the small expression grammar.

Evaluator dispatch function for parameters.

Definition at line 399 of file Evaluator.cpp.

◆ evaluatePathCreate()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluatePathCreate ( FrozenPathCreateOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Definition at line 710 of file Evaluator.cpp.

◆ evaluateTupleCreate()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateTupleCreate ( TupleCreateOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for Tuple creation.

Definition at line 633 of file Evaluator.cpp.

◆ evaluateTupleGet()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateTupleGet ( TupleGetOp  op,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluator dispatch function for List creation.

Definition at line 652 of file Evaluator.cpp.

◆ evaluateValue()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::evaluateValue ( Value  value,
ActualParameters  actualParams,
Location  loc 
)
private

Evaluate a Value in a Class body according to the small expression grammar described in the rationale document.

The actual parameters are the values supplied at the current instantiation of the Class being evaluated.

Definition at line 336 of file Evaluator.cpp.

◆ getModule()

ModuleOp circt::om::Evaluator::getModule ( )

Get the Module this Evaluator is built from.

Definition at line 29 of file Evaluator.cpp.

◆ getOrCreateValue()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::getOrCreateValue ( Value  value,
ActualParameters  actualParams,
Location  loc 
)
private

Definition at line 108 of file Evaluator.cpp.

References circt::om::evaluator::PathValue::getEmptyPath().

◆ getPartiallyEvaluatedValue()

FailureOr< evaluator::EvaluatorValuePtr > circt::om::Evaluator::getPartiallyEvaluatedValue ( Type  type,
Location  loc 
)

Definition at line 72 of file Evaluator.cpp.

◆ instantiate()

FailureOr< std::shared_ptr< evaluator::EvaluatorValue > > circt::om::Evaluator::instantiate ( StringAttr  className,
ArrayRef< EvaluatorValuePtr actualParams 
)

Instantiate an Object with its class name and actual parameters.

Definition at line 291 of file Evaluator.cpp.

Referenced by omEvaluatorInstantiate().

◆ isFullyEvaluated() [1/2]

bool circt::om::Evaluator::isFullyEvaluated ( ObjectKey  key)
inlineprivate

Definition at line 444 of file Evaluator.h.

References objects.

◆ isFullyEvaluated() [2/2]

bool circt::om::Evaluator::isFullyEvaluated ( Value  value,
ActualParameters  key 
)
inlineprivate

Definition at line 440 of file Evaluator.h.

Member Data Documentation

◆ actualParametersBuffers

SmallVector< std::unique_ptr<SmallVector<std::shared_ptr<evaluator::EvaluatorValue> > > > circt::om::Evaluator::actualParametersBuffers
private

This uniquely stores vectors that represent parameters.

Definition at line 516 of file Evaluator.h.

◆ objects

DenseMap<ObjectKey, std::shared_ptr<evaluator::EvaluatorValue> > circt::om::Evaluator::objects
private

Evaluator value storage.

Return an evaluator value for the given instantiation context (a pair of Value and parameters).

Definition at line 523 of file Evaluator.h.

Referenced by isFullyEvaluated().

◆ symbolTable

SymbolTable circt::om::Evaluator::symbolTable
private

The symbol table for the IR module the Evaluator was constructed with.

Used to look up class definitions.

Definition at line 511 of file Evaluator.h.

◆ worklist

std::queue<ObjectKey> circt::om::Evaluator::worklist
private

A worklist that tracks values which needs to be fully evaluated.

Definition at line 519 of file Evaluator.h.


The documentation for this struct was generated from the following files: