LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
ConversionUtils.h File Reference
#include "llzk/Dialect/Array/IR/Types.h"
#include "llzk/Dialect/Function/IR/Ops.h"
#include "llzk/Dialect/Struct/IR/Ops.h"
#include "llzk/Util/Concepts.h"
#include <mlir/IR/Block.h>
#include <mlir/IR/Builders.h>
#include <mlir/IR/BuiltinAttributes.h>
#include <mlir/IR/BuiltinTypes.h>
#include <mlir/IR/Operation.h>
#include <mlir/IR/PatternMatch.h>
#include <mlir/IR/SymbolTable.h>
#include <mlir/Transforms/DialectConversion.h>
#include <llvm/ADT/ArrayRef.h>
#include <llvm/ADT/DenseMap.h>
#include <llvm/ADT/STLExtras.h>
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/ADT/StringSet.h>
#include <llvm/ADT/Twine.h>
#include <llvm/Support/Casting.h>
#include <llvm/Support/ErrorHandling.h>
#include <cassert>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
Include dependency graph for ConversionUtils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  llzk::SplitFunctionNameInfo
 Cached function arg/result names and split suffixes used while rewriting a function signature. More...
class  llzk::FunctionTypeConverter
 General helper for converting a FuncDefOp by changing its input and/or result types and the associated attributes for those types. More...
class  llzk::SplitAggregateInMemberRefOp< ImplClass, MemberRefOpClass, GenHeaderType, IdType >
 Common implementation for handling MemberWriteOp and MemberReadOp while destructuring an aggregate type (e.g., ArrayType or PodType) stored in a struct member. More...

Namespaces

namespace  llzk

Functions

template<typename OpTy>
OpTy llzk::preserveDiscardableAttrs (mlir::Operation *src, OpTy dst)
 Copy discardable attributes from src to dst.
template<typename OpTy>
OpTy llzk::preserveDiscardableAttrsExcept (mlir::Operation *src, OpTy dst, mlir::StringRef excludedAttr)
 Copy discardable attributes from src to dst while omitting one internal attr.
template<typename OpClass, typename Rewriter, typename... Args>
OpClass llzk::replaceOpWithNewOp (Rewriter &rewriter, mlir::Operation *op, Args &&...args)
 Wrapper for RewriterBase::replaceOpWithNewOp() that automatically copies discardable attributes (i.e., attributes other than those specifically defined as part of the op in ODS).
mlir::DictionaryAttr llzk::withFunctionNameAttr (mlir::DictionaryAttr attrs, llvm::StringRef attrName, llvm::StringRef name)
 Return a copy of the given function argument/result attribute dictionary with attrName set to name.
mlir::DictionaryAttr llzk::withFunctionArgNameAttr (mlir::DictionaryAttr attrs, llvm::StringRef name)
 Return a copy of the given argument attribute dictionary with function.arg_name set to name.
mlir::DictionaryAttr llzk::withFunctionResNameAttr (mlir::DictionaryAttr attrs, llvm::StringRef name)
 Return a copy of the given result attribute dictionary with function.res_name set to name.
std::string llzk::reserveUniqueAttrName (llvm::StringSet<> &usedNames, llvm::StringRef desiredName)
 Reserve and return a unique function argument/result name based on desiredName.
std::optional< mlir::StringAttr > llzk::getAttrAtIndexWithName (mlir::ArrayAttr attrs, unsigned index, llvm::StringRef attrName)
 Return the function arg/result attribute at index for the given name, if present.
template<typename GetNameAttrFn, typename GetSplitSuffixesFn>
SplitFunctionNameInfo llzk::collectSplitFunctionNameInfo (mlir::ArrayRef< mlir::Type > origTypes, GetNameAttrFn &&getNameAttr, GetSplitSuffixesFn &&getSplitSuffixes)
 Collect function arg/result names and split suffixes from a list of original types.
mlir::ArrayAttr llzk::replicateFunctionNameAttrsAsNeeded (mlir::ArrayAttr origAttrs, const llvm::SmallVector< size_t > &originalIdxToSize, const llvm::SmallVector< mlir::Type > &newTypes, llvm::StringRef functionNameAttrName, llvm::ArrayRef< std::optional< llvm::StringRef > > origNames={}, llvm::ArrayRef< llvm::StringRef > existingNames={}, llvm::ArrayRef< llvm::SmallVector< std::string > > splitNameSuffixes={})
 Expand function arg/result attribute arrays to match a split signature, rewriting name attrs with the provided suffixes where available.
function::CallOp llzk::createCallPreservingInstantiationOperands (mlir::Location loc, mlir::TypeRange newResultTypes, function::CallOp oldCall, llvm::ArrayRef< mlir::ValueRange > mapOperands, mlir::ValueRange argOperands, mlir::ConversionPatternRewriter &rewriter)
 Rebuild a function.call while preserving explicit instantiation state from oldCall.