|
LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
Determine which concrete struct definitions are needed when instantiating a struct or free function with the supplied template arguments. More...
#include <StructSpecializationDiscovery.h>
Public Types | |
| using | Bindings = llvm::DenseMap<mlir::Attribute, mlir::Attribute> |
| using | Requests = llvm::SmallVector<StructSpecializationRequest> |
| using | CallTargets = llvm::SmallVector<RolledCallTargets> |
Public Member Functions | |
| mlir::FailureOr< Bindings > | evaluateBindings (mlir::Operation *source, const Bindings &bindings) const |
| Evaluate enclosing template expressions in declaration order and return an extended copy of bindings for substitution into a concrete clone. | |
| mlir::FailureOr< Requests > | discover (mlir::Operation *source, const Bindings &bindings, llvm::SmallVectorImpl< mlir::Operation * > *visitedOperations=nullptr, CallTargets *callTargets=nullptr) const |
| Return ordered, deduplicated requests for a struct or free-function source, or diagnose an unresolved dependency. | |
Determine which concrete struct definitions are needed when instantiating a struct or free function with the supplied template arguments.
For example, Parent<N> may contain an array of Child instances for 0 <= i < N. Evaluating that range with N = 3 tells the caller to instantiate Child<0>, Child<1>, and Child<2> while leaving the original loop intact.
Template parameters and expressions supply constants to the discovered methods or free-function body. Function arguments without known values remain unknown; intermediate SSA values are computed separately for each function and loop iteration because their values depend on that execution's inputs. Template-expression results are stored in a private copy of bindings so the caller's inputs stay unchanged.
Supported input structure (assuming verified LLZK IR):
Values available for specialization:
Supported type dependencies:
An unresolved required argument or unsupported explored structure is diagnosed. Success describes dependencies of this source instance; the caller must repeat discovery for newly instantiated definitions to obtain the transitive set of specializations.
Results retain source parameterized types, including nested concrete type arguments. Identity, caching, cloning, call retargeting and metadata belong to the caller.
Definition at line 128 of file StructSpecializationDiscovery.h.
| using llzk::polymorphic::detail::StructSpecializationDiscovery::Bindings = llvm::DenseMap<mlir::Attribute, mlir::Attribute> |
Definition at line 130 of file StructSpecializationDiscovery.h.
| using llzk::polymorphic::detail::StructSpecializationDiscovery::CallTargets = llvm::SmallVector<RolledCallTargets> |
Definition at line 132 of file StructSpecializationDiscovery.h.
| using llzk::polymorphic::detail::StructSpecializationDiscovery::Requests = llvm::SmallVector<StructSpecializationRequest> |
Definition at line 131 of file StructSpecializationDiscovery.h.
| FailureOr< StructSpecializationDiscovery::Requests > StructSpecializationDiscovery::discover | ( | mlir::Operation * | source, |
| const Bindings & | bindings, | ||
| llvm::SmallVectorImpl< mlir::Operation * > * | visitedOperations = nullptr, | ||
| CallTargets * | callTargets = nullptr ) const |
Return ordered, deduplicated requests for a struct or free-function source, or diagnose an unresolved dependency.
Self references are omitted; the caller already owns the source instance. When supplied, visitedOperations receives explored operations so callers can retarget uses without inspecting branches excluded by constant conditions. callTargets receives the candidate sets for rolled method arguments.
Definition at line 999 of file StructSpecializationDiscovery.cpp.
| FailureOr< StructSpecializationDiscovery::Bindings > StructSpecializationDiscovery::evaluateBindings | ( | mlir::Operation * | source, |
| const Bindings & | bindings ) const |
Evaluate enclosing template expressions in declaration order and return an extended copy of bindings for substitution into a concrete clone.
Source must be a struct definition or free-function definition.
Definition at line 995 of file StructSpecializationDiscovery.cpp.