pass

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2021 License: BSD-3-Clause Imports: 8 Imported by: 1

Documentation

Overview

Package pass implements analysis and processing passes on acc programs.

Index

Constants

This section is empty.

Variables

View Source
var (
	NameByteValues = NameBinaryValues(8, "_%b")
	NameXRuns      = NameBinaryRuns("x%d")
)

Naming conventions described in [curvechains].

Validate is a pass to sanity check an intermediate representation program.

Functions

func CanonicalizeOperands

func CanonicalizeOperands(p *ir.Program) error

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

func CheckDanglingInputs(p *ir.Program) error

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 ClearNames

func ClearNames(p *ir.Program) error

ClearNames deletes all operand names.

func Compile

func Compile(p *ir.Program) error

Compile generates the fully unrolled sequence of additions. The result is stored in the Program field.

func Eval

func Eval(p *ir.Program) error

Eval evaluates the program and places the result in the Chain field.

func Exec

func Exec(p *ir.Program, passes ...Interface) error

Exec is a convenience for executing a list of passes on p.

func ReadCounts

func ReadCounts(p *ir.Program) error

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.

func (Allocator) Execute

func (a Allocator) Execute(p *ir.Program) error

Execute performs temporary variable allocation.

type Func

type Func func(*ir.Program) error

Func adapts a function to the pass Interface.

func (Func) Execute

func (f Func) Execute(p *ir.Program) error

Execute calls p.

type Interface

type Interface interface {
	Execute(*ir.Program) error
}

Interface for a processing pass.

func Concat

func Concat(passes ...Interface) Interface

Concat returns a pass that executes the given passes in order, stopping on the first error.

func NameBinaryRuns

func NameBinaryRuns(format string) Interface

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

func NameBinaryValues(k int, format string) Interface

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.

func NameOperands

func NameOperands(name func(int, *big.Int) string) Interface

NameOperands builds a pass that names operands according to the given scheme.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL