|
LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
Common interface for constant parameter-like symbol operations that can be defined within a TemplateOp. More...
Classes | |
| struct | AccessPath |
| A concrete subtree of one execution's storage. More... | |
| class | ApplyMapOpGenericAdaptorBase |
| class | CleanupBase |
| Shared state for post-instantiation cleanup helpers. More... | |
| class | ConstraintBindings |
| Bind scalar leaves without constructing a shadow array or POD object. More... | |
| class | ConstraintScalarFacts |
| Evaluate scalar dependencies of structural decisions, assertions, and constant arithmetic. More... | |
| class | ConstraintStorage |
| Resolve concrete components and signal provenance directly from original SSA. More... | |
| class | ConstReadOpGenericAdaptorBase |
| struct | DiscoveryAggregate |
| Scalar contents and concrete array shapes, including nested aggregate roots. More... | |
| class | DiscoveryStorage |
| Track only local constant aggregate contents. More... | |
| struct | DiscoveryValue |
| A scalar constant or a local aggregate identity. Missing leaves are unknown. More... | |
| class | EmptyLegalityCheckCallback |
| class | FromEraseSet |
| Removes parameterized definitions whose instantiated replacements now cover every remaining use. More... | |
| struct | InstantiationLayout |
| Groups the information needed after concrete parameters have been chosen to decide how to name a new instantiated template and how to rewrite the remaining argument list at the use site. More... | |
| class | LegalityCheckCallback |
| struct | RolledCallTargets |
| A rolled method call and the concrete specializations it may target. More... | |
| struct | StorageDescription |
| Transient description derived from immutable storage accesses, not an environment. More... | |
| class | StructSpecializationDiscovery |
| Determine which concrete struct definitions are needed when instantiating a struct or free function with the supplied template arguments. More... | |
| struct | StructSpecializationRequest |
| A struct type that the caller must instantiate, paired with the source use that needs it. More... | |
| class | TemplateExprOpGenericAdaptorBase |
| class | TemplateOpGenericAdaptorBase |
| class | TemplateParamOpGenericAdaptorBase |
| struct | TemplateSymbolBindingOpInterfaceInterfaceTraits |
| struct | TemplateSymbolBindingOpInterfaceTrait |
| class | TemplateTypeConverter |
| Substitute known template bindings in function types and inference candidates. More... | |
| struct | TypeVarTypeStorage |
| class | UnifiableCastOpGenericAdaptorBase |
| class | YieldOpGenericAdaptorBase |
Typedefs | |
| using | BoundValue = std::variant<mlir::Value, AccessPath> |
| Scalar expressions are SSA; aggregates are paths, never emitted allocations. | |
| using | Environment = llvm::DenseMap<mlir::Value, BoundValue> |
| using | DiscoveryLeaves = llvm::DenseMap<mlir::ArrayAttr, mlir::Attribute> |
| Sparse known scalar leaves of a local aggregate, indexed by record/array paths. | |
Functions | |
| mlir::LogicalResult | constraintError (mlir::Operation *site, const llvm::Twine &message) |
| Emit the common diagnostic prefix for constraint expansion and storage helpers. | |
| bool | isInvariantTrueCondition (mlir::Value condition) |
| Prove a Boolean condition true without any loop-carried bindings. | |
| mlir::LogicalResult | evaluateScalarOperation (mlir::Operation *op, llvm::ArrayRef< mlir::Attribute > operands, llvm::SmallVectorImpl< mlir::OpFoldResult > &results) |
| Evaluate a scalar operation using caller-supplied operand constants. | |
| FailureOr< InstantiationLayout > | buildInstantiationLayout (TemplateOp parentTemplate, ArrayAttr callParams, const DenseMap< Attribute, Attribute > ¶mNameToConcrete) |
| void | setInstantiationNamePattern (TemplateOp templateOp, ArrayAttr namePattern) |
| std::string | buildOpaqueInstantiationName (StringRef baseName, ArrayRef< Attribute > concreteAttrs) |
| mlir::ConversionTarget | newBaseTarget (mlir::MLIRContext *ctx) |
| Return a new ConversionTarget allowing all LLZK-required dialects. | |
| bool | isErasableDefinition (mlir::Operation *op) |
| Return true iff op is a cleanup candidate. | |
| array::ArrayType | flattenInstantiatedArrayType (array::ArrayType inputTy, mlir::Type convertedElemTy) |
| Merge nested array dimensions produced by replacing an array element type. | |
| component::StructType | getStructTypeWithParams (mlir::SymbolRefAttr nameRef, mlir::ArrayAttr params) |
| Build a struct type while representing an empty parameter list as absent. | |
| component::StructType | getStructTypeWithParams (mlir::SymbolRefAttr nameRef, mlir::MLIRContext *ctx, mlir::ArrayRef< mlir::Attribute > params) |
| Build a struct type while representing an empty parameter list as absent. | |
| mlir::FailureOr< InstantiationLayout > | buildInstantiationLayout (TemplateOp parentTemplate, mlir::ArrayAttr callParams, const llvm::DenseMap< mlir::Attribute, mlir::Attribute > ¶mNameToConcrete) |
| Derive the instantiated template name, remaining explicit parameters, and refined literal pattern. | |
| void | setInstantiationNamePattern (TemplateOp templateOp, mlir::ArrayAttr namePattern) |
| Clear inherited pattern state from a fully concrete template, or attach refined chunks before a partial template is inserted into a symbol table. | |
| std::string | buildOpaqueInstantiationName (llvm::StringRef baseName, llvm::ArrayRef< mlir::Attribute > concreteAttrs) |
| Append concrete attributes to an opaque physical base name without interpreting its bytes. | |
| template<typename... AdditionalOpClasses, typename... AdditionalChecks> | |
| mlir::ConversionTarget | newConverterDefinedTarget (mlir::TypeConverter &tyConv, mlir::MLIRContext *ctx, AdditionalChecks &&...checks) |
| Return a new ConversionTarget allowing all LLZK-required dialects and defining Op legality based on the given TypeConverter for Ops listed in both type aliases of OpClassesWithStructTypes and in AdditionalOpClasses. | |
| template<typename... AdditionalOpClasses, typename... AdditionalChecks> | |
| mlir::ConversionTarget | newConverterDefinedTargetWithCallback (mlir::TypeConverter &tyConv, mlir::MLIRContext *ctx, LegalityCheckCallback &cb, AdditionalChecks &&...checks) |
| Return a new ConversionTarget allowing all LLZK-required dialects and defining Op legality based on the given TypeConverter for Ops listed in both type aliases of OpClassesWithStructTypes and in AdditionalOpClasses. | |
| mlir::FailureOr< mlir::Attribute > | resolveConstReadBinding (ConstReadOp read, mlir::Attribute binding, mlir::Type readType) |
| Materialize a binding with the resolved read type for evaluation or cloning. | |
| void | reportDelayedDiagnostics (Operation *site, SmallVector< Diagnostic > &&diagnostics) |
| FailureOr< ArrayAttr > | rebaseTemplateParams (SymbolTableCollection &tables, ArrayAttr templateParams, Operation *lookupFrom, ModuleOp destinationRoot, Operation *requestSite) |
| void | convertCalleesInPlace (Operation *op, const DenseMap< Attribute, Attribute > ¶mNameToValue) |
| void | evaluateTemplateExprs (TemplateOp templateOp, DenseMap< Attribute, Attribute > ¶mNameToConcrete) |
| Evaluate all TemplateExprOps in templateOp that can be computed from the currently-known concrete param values in paramNameToConcrete, and add their results to the map. | |
| std::optional< Attribute > | inferUnifiedParam (const UnificationMap &unifyResult, SymbolRefAttr paramName) |
| Return the callee-side unification-derived value for a template parameter, if any. | |
| LogicalResult | substituteStructBody (StructDefOp newStruct, StructType typeAtDef, const DenseMap< Attribute, Attribute > ¶mNameToConcrete, SmallVector< Diagnostic > &diagnostics) |
| LogicalResult | substituteFunctionBody (FuncDefOp newFunc, const DenseMap< Attribute, Attribute > ¶mNameToConcrete, SmallVector< Diagnostic > &delayedDiagnostics) |
| mlir::FailureOr< mlir::ArrayAttr > | rebaseTemplateParams (mlir::SymbolTableCollection &tables, mlir::ArrayAttr templateParams, mlir::Operation *lookupFrom, mlir::ModuleOp destinationRoot, mlir::Operation *requestSite) |
Re-spell struct types nested in templateParams for destinationRoot, resolving their current names from lookupFrom. | |
| void | reportDelayedDiagnostics (mlir::Operation *site, llvm::SmallVector< mlir::Diagnostic > &&diagnostics) |
| Report diagnostics emitted while substituting a clone, preserving notes and moving notes with unknown locations to the instantiation site. | |
| void | convertCalleesInPlace (mlir::Operation *op, const llvm::DenseMap< mlir::Attribute, mlir::Attribute > &bindings) |
| Rewrite callees rooted at a type parameter using that parameter's struct binding. | |
| void | evaluateTemplateExprs (TemplateOp templateOp, llvm::DenseMap< mlir::Attribute, mlir::Attribute > &bindings) |
| Add foldable template-expression results to bindings in declaration order. | |
| std::optional< mlir::Attribute > | inferUnifiedParam (const UnificationMap &unifyResult, mlir::SymbolRefAttr paramName) |
| Return the callee-side unification-derived value for a template parameter, if any. | |
| mlir::LogicalResult | substituteStructBody (component::StructDefOp clone, component::StructType originalType, const llvm::DenseMap< mlir::Attribute, mlir::Attribute > &bindings, llvm::SmallVector< mlir::Diagnostic > &diagnostics) |
| Substitute bindings and self-type references in an already inserted struct clone. | |
| mlir::LogicalResult | substituteFunctionBody (function::FuncDefOp clone, const llvm::DenseMap< mlir::Attribute, mlir::Attribute > &bindings, llvm::SmallVector< mlir::Diagnostic > &diagnostics) |
| Substitute bindings in a function clone, including constants and array accesses. | |
Variables | |
| constexpr llvm::StringLiteral | CONSTRAINT_DIAGNOSTIC_PREFIX = "llzk-flatten-constraints: " |
| Identify expansion diagnostics separately from IR verifier errors. | |
Common interface for constant parameter-like symbol operations that can be defined within a TemplateOp.
| using llzk::polymorphic::detail::BoundValue = std::variant<mlir::Value, AccessPath> |
Scalar expressions are SSA; aggregates are paths, never emitted allocations.
Definition at line 35 of file ConstraintBindings.h.
| using llzk::polymorphic::detail::DiscoveryLeaves = llvm::DenseMap<mlir::ArrayAttr, mlir::Attribute> |
Sparse known scalar leaves of a local aggregate, indexed by record/array paths.
Definition at line 21 of file DiscoveryStorage.h.
| using llzk::polymorphic::detail::Environment = llvm::DenseMap<mlir::Value, BoundValue> |
Definition at line 36 of file ConstraintBindings.h.
| FailureOr< InstantiationLayout > llzk::polymorphic::detail::buildInstantiationLayout | ( | TemplateOp | parentTemplate, |
| ArrayAttr | callParams, | ||
| const DenseMap< Attribute, Attribute > & | paramNameToConcrete ) |
Definition at line 45 of file SharedImpl.cpp.
| mlir::FailureOr< InstantiationLayout > llzk::polymorphic::detail::buildInstantiationLayout | ( | TemplateOp | parentTemplate, |
| mlir::ArrayAttr | callParams, | ||
| const llvm::DenseMap< mlir::Attribute, mlir::Attribute > & | paramNameToConcrete ) |
Derive the instantiated template name, remaining explicit parameters, and refined literal pattern.
A malformed pattern is rejected even though TemplateOp verification normally runs before a transform; this keeps the owner boundary safe for programmatically built IR too.
| std::string llzk::polymorphic::detail::buildOpaqueInstantiationName | ( | llvm::StringRef | baseName, |
| llvm::ArrayRef< mlir::Attribute > | concreteAttrs ) |
Append concrete attributes to an opaque physical base name without interpreting its bytes.
| std::string llzk::polymorphic::detail::buildOpaqueInstantiationName | ( | StringRef | baseName, |
| ArrayRef< Attribute > | concreteAttrs ) |
Definition at line 160 of file SharedImpl.cpp.
|
inline |
Emit the common diagnostic prefix for constraint expansion and storage helpers.
Definition at line 23 of file ConstraintDiagnostics.h.
| void llzk::polymorphic::detail::convertCalleesInPlace | ( | mlir::Operation * | op, |
| const llvm::DenseMap< mlir::Attribute, mlir::Attribute > & | bindings ) |
Rewrite callees rooted at a type parameter using that parameter's struct binding.
Other callees and explicit call arguments are left unchanged.
| void llzk::polymorphic::detail::convertCalleesInPlace | ( | Operation * | op, |
| const DenseMap< Attribute, Attribute > & | paramNameToValue ) |
Definition at line 614 of file TemplateInstantiation.cpp.
|
inline |
Evaluate a scalar operation using caller-supplied operand constants.
Discovery supplies template/iteration bindings; flattening supplies SSA facts. Cast fold hooks preserve their range checks and overflow semantics. Fold hooks run on a disposable clone so evaluation never rewrites source IR.
Definition at line 26 of file ScalarEvaluation.h.
| void llzk::polymorphic::detail::evaluateTemplateExprs | ( | TemplateOp | templateOp, |
| DenseMap< Attribute, Attribute > & | paramNameToConcrete ) |
Evaluate all TemplateExprOps in templateOp that can be computed from the currently-known concrete param values in paramNameToConcrete, and add their results to the map.
Exprs whose operands are not all concrete are silently skipped (partial instantiation).
Definition at line 623 of file TemplateInstantiation.cpp.
| void llzk::polymorphic::detail::evaluateTemplateExprs | ( | TemplateOp | templateOp, |
| llvm::DenseMap< mlir::Attribute, mlir::Attribute > & | bindings ) |
Add foldable template-expression results to bindings in declaration order.
Expressions with unresolved operands are skipped to allow partial instantiation.
| array::ArrayType llzk::polymorphic::detail::flattenInstantiatedArrayType | ( | array::ArrayType | inputTy, |
| mlir::Type | convertedElemTy ) |
Merge nested array dimensions produced by replacing an array element type.
If array<4 x !poly.tvar<@T>> is rewritten with @T -> array<8 x index>, the canonical aggregate shape should become array<4,8 x index> rather than an array whose element type is another array because the latter is not allowed in LLZK IR.
|
inline |
Build a struct type while representing an empty parameter list as absent.
Definition at line 117 of file SharedImpl.h.
|
inline |
Build a struct type while representing an empty parameter list as absent.
Definition at line 123 of file SharedImpl.h.
| std::optional< mlir::Attribute > llzk::polymorphic::detail::inferUnifiedParam | ( | const UnificationMap & | unifyResult, |
| mlir::SymbolRefAttr | paramName ) |
Return the callee-side unification-derived value for a template parameter, if any.
| std::optional< Attribute > llzk::polymorphic::detail::inferUnifiedParam | ( | const UnificationMap & | unifyResult, |
| SymbolRefAttr | paramName ) |
Return the callee-side unification-derived value for a template parameter, if any.
Definition at line 649 of file TemplateInstantiation.cpp.
| bool llzk::polymorphic::detail::isErasableDefinition | ( | mlir::Operation * | op | ) |
Return true iff op is a cleanup candidate.
|
inline |
Prove a Boolean condition true without any loop-carried bindings.
Such a condition cannot become false on a later iteration, unlike a true first test.
Definition at line 99 of file ConstraintScalarFacts.h.
| mlir::ConversionTarget llzk::polymorphic::detail::newBaseTarget | ( | mlir::MLIRContext * | ctx | ) |
Return a new ConversionTarget allowing all LLZK-required dialects.
| mlir::ConversionTarget llzk::polymorphic::detail::newConverterDefinedTarget | ( | mlir::TypeConverter & | tyConv, |
| mlir::MLIRContext * | ctx, | ||
| AdditionalChecks &&... | checks ) |
Return a new ConversionTarget allowing all LLZK-required dialects and defining Op legality based on the given TypeConverter for Ops listed in both type aliases of OpClassesWithStructTypes and in AdditionalOpClasses.
Additional legality checks can be included for certain ops that will run along with the default check. For an op to be considered legal all checks (default plus additional checks if any) must return true.
Definition at line 178 of file SharedImpl.h.
| mlir::ConversionTarget llzk::polymorphic::detail::newConverterDefinedTargetWithCallback | ( | mlir::TypeConverter & | tyConv, |
| mlir::MLIRContext * | ctx, | ||
| LegalityCheckCallback & | cb, | ||
| AdditionalChecks &&... | checks ) |
Return a new ConversionTarget allowing all LLZK-required dialects and defining Op legality based on the given TypeConverter for Ops listed in both type aliases of OpClassesWithStructTypes and in AdditionalOpClasses.
Additional legality checks can be included for certain ops that will run along with the default check. For an op to be considered legal all checks (default plus additional checks if any) must return true.
Definition at line 193 of file SharedImpl.h.
| mlir::FailureOr< mlir::ArrayAttr > llzk::polymorphic::detail::rebaseTemplateParams | ( | mlir::SymbolTableCollection & | tables, |
| mlir::ArrayAttr | templateParams, | ||
| mlir::Operation * | lookupFrom, | ||
| mlir::ModuleOp | destinationRoot, | ||
| mlir::Operation * | requestSite ) |
Re-spell struct types nested in templateParams for destinationRoot, resolving their current names from lookupFrom.
Numeric and other value parameters are preserved. A null list becomes an empty list. Reports inaccessible type parameters and unsupported includes at requestSite, where instantiation was requested, so moving bindings does not move their diagnostics into a clone.
| FailureOr< ArrayAttr > llzk::polymorphic::detail::rebaseTemplateParams | ( | SymbolTableCollection & | tables, |
| ArrayAttr | templateParams, | ||
| Operation * | lookupFrom, | ||
| ModuleOp | destinationRoot, | ||
| Operation * | requestSite ) |
Definition at line 495 of file TemplateInstantiation.cpp.
| void llzk::polymorphic::detail::reportDelayedDiagnostics | ( | mlir::Operation * | site, |
| llvm::SmallVector< mlir::Diagnostic > && | diagnostics ) |
Report diagnostics emitted while substituting a clone, preserving notes and moving notes with unknown locations to the instantiation site.
| void llzk::polymorphic::detail::reportDelayedDiagnostics | ( | Operation * | site, |
| SmallVector< Diagnostic > && | diagnostics ) |
Definition at line 482 of file TemplateInstantiation.cpp.
| mlir::FailureOr< mlir::Attribute > llzk::polymorphic::detail::resolveConstReadBinding | ( | ConstReadOp | read, |
| mlir::Attribute | binding, | ||
| mlir::Type | readType ) |
Materialize a binding with the resolved read type for evaluation or cloning.
Unknown bindings remain unknown. Felt bindings require an exact type match. Integer-to-i1 reads require zero or one; integer-to-felt reads reduce values with a known modulus and reject negative values without one.
| void llzk::polymorphic::detail::setInstantiationNamePattern | ( | TemplateOp | templateOp, |
| ArrayAttr | namePattern ) |
Definition at line 152 of file SharedImpl.cpp.
| void llzk::polymorphic::detail::setInstantiationNamePattern | ( | TemplateOp | templateOp, |
| mlir::ArrayAttr | namePattern ) |
Clear inherited pattern state from a fully concrete template, or attach refined chunks before a partial template is inserted into a symbol table.
| LogicalResult llzk::polymorphic::detail::substituteFunctionBody | ( | FuncDefOp | newFunc, |
| const DenseMap< Attribute, Attribute > & | paramNameToConcrete, | ||
| SmallVector< Diagnostic > & | delayedDiagnostics ) |
Definition at line 675 of file TemplateInstantiation.cpp.
| mlir::LogicalResult llzk::polymorphic::detail::substituteFunctionBody | ( | function::FuncDefOp | clone, |
| const llvm::DenseMap< mlir::Attribute, mlir::Attribute > & | bindings, | ||
| llvm::SmallVector< mlir::Diagnostic > & | diagnostics ) |
Substitute bindings in a function clone, including constants and array accesses.
Append materialization warnings without reporting them. The caller must report them and verify nested call targets after applying its own symbol rewrites. Does not clone, insert symbols, infer parameters, inline calls or unroll loops.
| mlir::LogicalResult llzk::polymorphic::detail::substituteStructBody | ( | component::StructDefOp | clone, |
| component::StructType | originalType, | ||
| const llvm::DenseMap< mlir::Attribute, mlir::Attribute > & | bindings, | ||
| llvm::SmallVector< mlir::Diagnostic > & | diagnostics ) |
Substitute bindings and self-type references in an already inserted struct clone.
Append materialization warnings for the caller to report at each instantiation site. Does not clone, insert symbols, infer parameters, inline calls or unroll loops.
| LogicalResult llzk::polymorphic::detail::substituteStructBody | ( | StructDefOp | newStruct, |
| StructType | typeAtDef, | ||
| const DenseMap< Attribute, Attribute > & | paramNameToConcrete, | ||
| SmallVector< Diagnostic > & | diagnostics ) |
Definition at line 654 of file TemplateInstantiation.cpp.
|
inlineconstexpr |
Identify expansion diagnostics separately from IR verifier errors.
Definition at line 20 of file ConstraintDiagnostics.h.