|
LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
|
#include "llzk/Util/SymbolLookup.h"#include "llzk/Util/TypeHelper.h"#include <mlir/IR/Diagnostics.h>#include <mlir/Interfaces/CallInterfaces.h>#include <llvm/ADT/STLFunctionalExtras.h>#include <cassert>#include <optional>#include <ranges>Go to the source code of this file.
Namespaces | |
| namespace | llzk |
| namespace | llzk::component |
| namespace | llzk::function |
| namespace | llzk::polymorphic |
Functions | |
| void | llzk::eraseEmptyNestedModules (mlir::ModuleOp rootModule) |
| Remove nested builtin modules whose body is empty, preserving the root module. | |
| llvm::SmallVector< mlir::StringRef > | llzk::getNames (mlir::SymbolRefAttr ref) |
| llvm::SmallVector< mlir::FlatSymbolRefAttr > | llzk::getPieces (mlir::SymbolRefAttr ref) |
| mlir::FlatSymbolRefAttr | llzk::getFlatSymbolRefAttr (mlir::MLIRContext *context, const mlir::Twine &twine) |
| Construct a FlatSymbolRefAttr with the given content. | |
| mlir::SymbolRefAttr | llzk::asSymbolRefAttr (mlir::StringAttr root, mlir::SymbolRefAttr tail) |
| Build a SymbolRefAttr that prepends tail with root, i.e., root::tail. | |
| mlir::SymbolRefAttr | llzk::asSymbolRefAttr (llvm::ArrayRef< mlir::FlatSymbolRefAttr > path) |
| Build a SymbolRefAttr from the list of pieces. | |
| mlir::SymbolRefAttr | llzk::asSymbolRefAttr (const std::vector< mlir::FlatSymbolRefAttr > &path) |
| Build a SymbolRefAttr from the list of pieces. | |
| mlir::SymbolRefAttr | llzk::getTailAsSymbolRefAttr (mlir::SymbolRefAttr symbol) |
| Return SymbolRefAttr like the one given but with the root/head element removed. | |
| mlir::SymbolRefAttr | llzk::getPrefixAsSymbolRefAttr (mlir::SymbolRefAttr symbol) |
| Return SymbolRefAttr like the one given but with the leaf/final element removed. | |
| mlir::SymbolRefAttr | llzk::replaceLeaf (mlir::SymbolRefAttr orig, mlir::FlatSymbolRefAttr newLeaf) |
| Return SymbolRefAttr like the one given but with the leaf (final) element replaced. | |
| mlir::SymbolRefAttr | llzk::replaceLeaf (mlir::SymbolRefAttr orig, mlir::StringAttr newLeaf) |
| mlir::SymbolRefAttr | llzk::replaceLeaf (mlir::SymbolRefAttr orig, const mlir::Twine &newLeaf) |
| mlir::SymbolRefAttr | llzk::appendLeaf (mlir::SymbolRefAttr orig, mlir::FlatSymbolRefAttr newLeaf) |
| Return SymbolRefAttr like the one given but with a new leaf (final) element added. | |
| mlir::SymbolRefAttr | llzk::appendLeaf (mlir::SymbolRefAttr orig, mlir::StringAttr newLeaf) |
| mlir::SymbolRefAttr | llzk::appendLeaf (mlir::SymbolRefAttr orig, const mlir::Twine &newLeaf) |
| mlir::SymbolRefAttr | llzk::appendLeafName (mlir::SymbolRefAttr orig, const mlir::Twine &newLeafSuffix) |
| Return SymbolRefAttr like the one given but with the leaf (final) element appended with the given suffix. | |
| mlir::FailureOr< mlir::ModuleOp > | llzk::getRootModule (mlir::Operation *from) |
| Starting at the Operation from, find the nearest ancestor ModuleOp marked with LANG_ATTR_NAME from which symbol lookups are rooted. | |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromRoot (mlir::SymbolOpInterface to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromRoot (component::StructDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromRoot (component::MemberDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromRoot (function::FuncDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathRelativeToAncestor (mlir::SymbolOpInterface symbol, mlir::ModuleOp ancestor, llvm::function_ref< mlir::InFlightDiagnostic()> emitError=nullptr) |
Return symbol's path relative to the supplied ancestor module. | |
| mlir::SymbolRefAttr | llzk::getFullyQualifiedName (mlir::SymbolOpInterface symbol, bool requireParent=true) |
| Return the full name for this symbol from the root module, including any surrounding symbol table names. | |
| mlir::FailureOr< mlir::ModuleOp > | llzk::getTopRootModule (mlir::Operation *from) |
| With include statements, there may be root modules nested within other root modules. | |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromTopRoot (mlir::SymbolOpInterface to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromTopRoot (component::StructDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromTopRoot (component::MemberDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< mlir::SymbolRefAttr > | llzk::getPathFromTopRoot (function::FuncDefOp &to, mlir::ModuleOp *foundRoot=nullptr) |
| mlir::FailureOr< llzk::component::StructType > | llzk::getMainInstanceType (mlir::Operation *lookupFrom) |
| Lookup the StructType of the main instance. | |
| mlir::FailureOr< SymbolLookupResult< llzk::component::StructDefOp > > | llzk::getMainInstanceDef (mlir::SymbolTableCollection &symbolTable, mlir::Operation *lookupFrom) |
| Lookup the StructDefOp of the main instance. | |
| mlir::FailureOr< SymbolLookupResult< component::StructDefOp > > | llzk::getRootStructDef (mlir::SymbolTableCollection &tables, mlir::Operation *lookupFrom, mlir::StringRef symbolPath={}) |
| Resolve symbolPath (MLIR syntax or a bare name), defaulting to llzk.main. | |
| template<typename T> | |
| mlir::FailureOr< SymbolLookupResult< T > > | llzk::resolveCallable (mlir::SymbolTableCollection &symbolTable, mlir::CallOpInterface call) |
| Based on mlir::CallOpInterface::resolveCallable, but using LLZK lookup helpers. | |
| template<typename T> | |
| mlir::FailureOr< SymbolLookupResult< T > > | llzk::resolveCallableSilently (mlir::SymbolTableCollection &symbolTable, mlir::CallOpInterface call) |
| Resolve a callable without emitting a diagnostic for missing top-level symbols. | |
| template<typename T> | |
| mlir::FailureOr< SymbolLookupResult< T > > | llzk::resolveCallable (mlir::CallOpInterface call) |
| mlir::FailureOr< polymorphic::TemplateOp > | llzk::getConstResolutionTemplate (mlir::SymbolTableCollection &tables, mlir::Operation *origin) |
| Return the template scope that should be used to resolve flat constant references from the given origin. | |
| mlir::LogicalResult | llzk::verifyTemplateParamSymbol (mlir::SymbolTableCollection &tables, mlir::SymbolRefAttr symbol, mlir::Operation *origin) |
| Ensure that a SymbolRef template argument resolves to a binding in the enclosing template or to a constant global. | |
| mlir::LogicalResult | llzk::verifyTemplateParamValueCompatibility (mlir::Operation *origin, mlir::Attribute value, polymorphic::TemplateParamOp targetParam) |
| Verify one explicit template argument against its declared parameter restriction. | |
| mlir::LogicalResult | llzk::verifyTemplateParamValuesCompatibility (mlir::Operation *origin, mlir::ArrayAttr explicitParams, llvm::iterator_range< mlir::Region::op_iterator< polymorphic::TemplateParamOp > > targetParamDefs) |
| Verify each explicit template argument against the corresponding declared parameter restriction. | |
| mlir::LogicalResult | llzk::verifyTemplateParamsMatchInferred (mlir::Operation *origin, mlir::ArrayAttr explicitParams, llvm::iterator_range< mlir::Region::op_iterator< polymorphic::TemplateParamOp > > targetParamDefs, const UnificationMap &unifications) |
| Verify that each template parameter value provided in the origin op is consistent with the value inferred for the target TemplateParamOp in the given UnificationMap. | |
| mlir::LogicalResult | llzk::verifyParamOfType (mlir::SymbolTableCollection &tables, mlir::SymbolRefAttr param, mlir::Type structOrArrayType, mlir::Operation *origin, std::optional< mlir::Type > requiredParamType=std::nullopt) |
| Ensure that the given symbol (that is used as a parameter of the given type) can be resolved. | |
| mlir::LogicalResult | llzk::verifyParamsOfType (mlir::SymbolTableCollection &tables, mlir::ArrayRef< mlir::Attribute > tyParams, mlir::Type structOrArrayType, mlir::Operation *origin, std::optional< mlir::Type > requiredParamType=std::nullopt) |
| Ensure that any symbols that appear within the given attributes (that are parameters of the given type) can be resolved. | |
| mlir::FailureOr< component::StructDefOp > | llzk::verifyStructTypeResolution (mlir::SymbolTableCollection &tables, component::StructType ty, mlir::Operation *origin) |
| Ensure that all symbols used within the type can be resolved. | |
| mlir::LogicalResult | llzk::verifyTypeResolution (mlir::SymbolTableCollection &tables, mlir::Operation *origin, mlir::Type type) |
| Ensure that all symbols used within the given Type instance can be resolved. | |
| template<std::ranges::input_range Range> | |
| mlir::LogicalResult | llzk::verifyTypeResolution (mlir::SymbolTableCollection &tables, mlir::Operation *origin, const Range &types) |
| Ensure that all symbols used within all Type instances can be resolved. | |