LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
TypeVarInferencePass.cpp File Reference

This file implements the -llzk-infer-tvar pass. More...

#include "llzk/Dialect/Array/IR/Ops.h"
#include "llzk/Dialect/Array/Util/ArrayTypeHelper.h"
#include "llzk/Dialect/Function/IR/Ops.h"
#include "llzk/Dialect/POD/IR/Types.h"
#include "llzk/Dialect/Polymorphic/IR/Ops.h"
#include "llzk/Dialect/Polymorphic/Transforms/TransformationPasses.h"
#include "llzk/Dialect/Struct/IR/Ops.h"
#include "llzk/Dialect/Verif/IR/Ops.h"
#include "llzk/Util/Constants.h"
#include "llzk/Util/SymbolHelper.h"
#include "llzk/Util/SymbolLookup.h"
#include "llzk/Util/SymbolTableLLZK.h"
#include "llzk/Util/TypeHelper.h"
#include "llzk/Util/Walk.h"
#include <mlir/IR/BuiltinOps.h>
#include <mlir/IR/PatternMatch.h>
#include <llvm/ADT/DenseMap.h>
#include <llvm/ADT/DenseSet.h>
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringMap.h>
#include <llvm/Support/raw_ostream.h>
#include <memory>
#include <vector>
#include "llzk/Dialect/Polymorphic/Transforms/TransformationPasses.h.inc"
#include "SharedImpl.h"
Include dependency graph for TypeVarInferencePass.cpp:

Go to the source code of this file.

Classes

class  llzk::polymorphic::impl::TypeVarInferencePassBase< DerivedT >

Namespaces

namespace  llzk
namespace  llzk::polymorphic
namespace  llzk::polymorphic::impl

Macros

#define GEN_PASS_DEF_TYPEVARINFERENCEPASS
#define DEBUG_TYPE   "llzk-infer-tvar"

Functions

std::unique_ptr<::mlir::Pass > llzk::polymorphic::impl::createTypeVarInferencePass ()
std::unique_ptr<::mlir::Pass > llzk::polymorphic::createTypeVarInferencePass ()

Detailed Description

This file implements the -llzk-infer-tvar pass.

The pass specializes polymorphic template type variables in place when the body of a template proves that a !poly.tvar must actually be a concrete type. The motivating case is a poly.unifiable_cast between a value whose type mentions a template type variable and a value whose type is concrete.

For each poly.template, the pass:

  1. Collects concrete type inferences from function and poly.expr bodies for poly.param definitions of the form poly.param @T : !poly.tvar<@T>.
  2. Rejects conflicting inferences for the same template parameter or the same SSA value.
  3. Rewrites function signatures, body value types, and type-bearing attributes that mention the inferred type variables.
  4. Removes poly.unifiable_cast operations that become identity casts.
  5. Removes the resolved poly.param definitions and trims callers' template parameter lists accordingly.

Definition in file TypeVarInferencePass.cpp.

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "llzk-infer-tvar"

Definition at line 66 of file TypeVarInferencePass.cpp.

◆ GEN_PASS_DEF_TYPEVARINFERENCEPASS

#define GEN_PASS_DEF_TYPEVARINFERENCEPASS

Definition at line 60 of file TypeVarInferencePass.cpp.