Documentation ¶
Overview ¶
Package pass implements analysis and processing passes on acc programs.
Index ¶
- Variables
- func CanonicalizeOperands(p *ir.Program) error
- func CheckDanglingInputs(p *ir.Program) error
- func ClearNames(p *ir.Program) error
- func Compile(p *ir.Program) error
- func Eval(p *ir.Program) error
- func Exec(p *ir.Program, passes ...Interface) error
- func ReadCounts(p *ir.Program) error
- type Allocator
- type Func
- type Interface
Constants ¶
This section is empty.
Variables ¶
var ( NameByteValues = NameBinaryValues(8, "_%b") NameXRuns = NameBinaryRuns("x%d") )
Naming conventions described in [curvechains].
var Validate = Func(CheckDanglingInputs)
Validate is a pass to sanity check an intermediate representation program.
Functions ¶
func CanonicalizeOperands ¶
CanonicalizeOperands ensures there is only one Operand object for each operand index in the program. In particular, this ensures there are not conflicting names for the same index. Populates the Operands field of the program.
func CheckDanglingInputs ¶
CheckDanglingInputs looks for program inputs that have no instruction outputting them. Note this can happen and still be technically correct. For example a shift instruction produces many intermediate results, and one of these can later be referenced. The resulting program is still correct, but undesirable.
func Compile ¶
Compile generates the fully unrolled sequence of additions. The result is stored in the Program field.
func ReadCounts ¶
ReadCounts computes how many times each index is read in the program. This populates the ReadCount field of the program.
Types ¶
type Allocator ¶
type Allocator struct { // Input is the name of the input variable. Note this is index 0, or the // identity element of the addition chain. Input string // Output is the name to give to the final output of the addition chain. This // variable may itself be used as a temporary during execution. Output string // Format defines how to format any temporary variables. This format string // must accept one integer value. For example "t%d" would be a reasonable // choice. Format string }
Allocator pass assigns a minimal number of temporary variables to execute a program.
type Interface ¶
Interface for a processing pass.
func Concat ¶
Concat returns a pass that executes the given passes in order, stopping on the first error.
func NameBinaryRuns ¶
NameBinaryRuns assigns variable names to operands with values of the form 2ⁿ - 1. The identifier is determined from the format string, which takes the length of the run as a parameter.
func NameBinaryValues ¶
NameBinaryValues assigns variable names to operands with values less than 2ᵏ. The identifier is determined from the format string, which should expect to take one *big.Int argument.