Expand description
The compiler module contains several passes to transform an ACIR program.
Roughly, the passes are separated into the optimizers which try to reduce the number of opcodes
and the transformers which adapt the opcodes to the proving backend.
ยงOptimizers
- GeneralOptimizer: simple pass which simplifies AssertZero opcodes when possible (e.g remove terms with null coefficient)
- UnusedMemoryOptimizer: simple pass which removes MemoryInit opcodes when they are not used (e.g no corresponding MemoryOp opcode)
- RangeOptimizer: forward pass to collect range check information, and backward pass to remove the ones that are redundant.
- CommonSubexpressionOptimizer: Assigns common subexpressions to witnesses to simplify expressions and reduce the number of opcodes.
ACIR generation is performed by calling the Ssa::into_acir method, providing any necessary brillig bytecode.
The compiled program will be returned as an Artifacts type.
Modulesยง
- optimizers ๐
- simulator ๐
- validator
Structsยง
- Acir
Transformation Map - This module can move and decompose acir opcodes into multiple opcodes. The transformation map allows consumers of this module to map metadata they had about the opcodes to the new opcode structure generated after the transformation. ACIR opcodes are stored inside a vector of opcodes. A transformation pass will generate a new vector of opcodes, but each opcode is the result of the transformation of an opcode in the original vector. So we simply keep track of the relation: index of the original opcode -> index of the new opcode in the new vector However we need a vector of new indexes for the map values in the case the old opcode is decomposed into multiple opcodes.
- Circuit
Simulator - Simulate solving a circuit symbolically Instead of evaluating witness values from the inputs, like the PWG module is doing, this pass simply marks the witness that can be evaluated, from the known inputs, and incrementally from the previously marked witnesses. This avoids any computation on a big field which makes the process efficient. When all the witness of an opcode are marked as solvable, it means that the opcode is solvable.
Functionsยง
- optimize
- Applies backend independent optimizations to a [
Circuit]. - transform_
assert_ ๐messages - Update the assert messages to point to the new opcode locations.