Help us shape the future of Go! Take the 2026 Go Developer Survey

loop

package
v4.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxSCEVDepth = 100

Variables

This section is empty.

Functions

func AnalyzeSCEV

func AnalyzeSCEV(info *LoopInfo)

func CountLoops

func CountLoops(loops []*Loop) int

Types

type IVType

type IVType int
const (
	IVTypeUnknown IVType = iota
	IVTypeBasic
	IVTypeDerived
	IVTypeGeometric
	IVTypePolynomial
)

type InductionVariable

type InductionVariable struct {
	Phi   *ssa.Phi
	Type  IVType
	Start SCEV
	Step  SCEV
}

type Loop

type Loop struct {
	Header     *ssa.BasicBlock
	Latch      *ssa.BasicBlock
	Blocks     map[*ssa.BasicBlock]bool
	Exits      []*ssa.BasicBlock
	Parent     *Loop
	Children   []*Loop
	Inductions map[*ssa.Phi]*InductionVariable
	TripCount  SCEV
	SCEVCache  map[ssa.Value]SCEV
}

func (*Loop) String

func (l *Loop) String() string

type LoopInfo

type LoopInfo struct {
	Function *ssa.Function
	Loops    []*Loop
	LoopMap  map[*ssa.BasicBlock]*Loop
}

func DetectLoops

func DetectLoops(fn *ssa.Function) *LoopInfo

type Renamer

type Renamer func(ssa.Value) string

type SCEV

type SCEV interface {
	ssa.Value
	EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int
	IsLoopInvariant(loop *Loop) bool
	String() string
	StringWithRenamer(r Renamer) string
}

func SCEVFromConst

func SCEVFromConst(c *ssa.Const) SCEV

func ToSCEV

func ToSCEV(v ssa.Value, loop *Loop) SCEV

type SCEVAddRec

type SCEVAddRec struct {
	Start SCEV
	Step  SCEV
	Loop  *Loop
}

func (*SCEVAddRec) EvaluateAt

func (s *SCEVAddRec) EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int

func (*SCEVAddRec) IsLoopInvariant

func (s *SCEVAddRec) IsLoopInvariant(loop *Loop) bool

func (*SCEVAddRec) Name

func (s *SCEVAddRec) Name() string

func (*SCEVAddRec) Parent

func (s *SCEVAddRec) Parent() *ssa.Function

func (*SCEVAddRec) Pos

func (s *SCEVAddRec) Pos() token.Pos

func (*SCEVAddRec) Referrers

func (s *SCEVAddRec) Referrers() *[]ssa.Instruction

func (*SCEVAddRec) String

func (s *SCEVAddRec) String() string

func (*SCEVAddRec) StringWithRenamer

func (s *SCEVAddRec) StringWithRenamer(r Renamer) string

func (*SCEVAddRec) Type

func (s *SCEVAddRec) Type() types.Type

type SCEVConstant

type SCEVConstant struct{ Value *big.Int }

func (*SCEVConstant) EvaluateAt

func (s *SCEVConstant) EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int

func (*SCEVConstant) IsLoopInvariant

func (s *SCEVConstant) IsLoopInvariant(loop *Loop) bool

func (*SCEVConstant) Name

func (s *SCEVConstant) Name() string

func (*SCEVConstant) Parent

func (s *SCEVConstant) Parent() *ssa.Function

func (*SCEVConstant) Pos

func (s *SCEVConstant) Pos() token.Pos

func (*SCEVConstant) Referrers

func (s *SCEVConstant) Referrers() *[]ssa.Instruction

func (*SCEVConstant) String

func (s *SCEVConstant) String() string

func (*SCEVConstant) StringWithRenamer

func (s *SCEVConstant) StringWithRenamer(r Renamer) string

func (*SCEVConstant) Type

func (s *SCEVConstant) Type() types.Type

type SCEVGenericExpr

type SCEVGenericExpr struct {
	Op token.Token
	X  SCEV
	Y  SCEV
}

func (*SCEVGenericExpr) EvaluateAt

func (s *SCEVGenericExpr) EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int

func (*SCEVGenericExpr) IsLoopInvariant

func (s *SCEVGenericExpr) IsLoopInvariant(loop *Loop) bool

func (*SCEVGenericExpr) Name

func (s *SCEVGenericExpr) Name() string

func (*SCEVGenericExpr) Parent

func (s *SCEVGenericExpr) Parent() *ssa.Function

func (*SCEVGenericExpr) Pos

func (s *SCEVGenericExpr) Pos() token.Pos

func (*SCEVGenericExpr) Referrers

func (s *SCEVGenericExpr) Referrers() *[]ssa.Instruction

func (*SCEVGenericExpr) String

func (s *SCEVGenericExpr) String() string

func (*SCEVGenericExpr) StringWithRenamer

func (s *SCEVGenericExpr) StringWithRenamer(r Renamer) string

func (*SCEVGenericExpr) Type

func (s *SCEVGenericExpr) Type() types.Type

type SCEVMax

type SCEVMax struct {
	X SCEV
	Y SCEV
}

func (*SCEVMax) EvaluateAt

func (s *SCEVMax) EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int

func (*SCEVMax) IsLoopInvariant

func (s *SCEVMax) IsLoopInvariant(loop *Loop) bool

func (*SCEVMax) Name

func (s *SCEVMax) Name() string

func (*SCEVMax) Parent

func (s *SCEVMax) Parent() *ssa.Function

func (*SCEVMax) Pos

func (s *SCEVMax) Pos() token.Pos

func (*SCEVMax) Referrers

func (s *SCEVMax) Referrers() *[]ssa.Instruction

func (*SCEVMax) String

func (s *SCEVMax) String() string

func (*SCEVMax) StringWithRenamer

func (s *SCEVMax) StringWithRenamer(r Renamer) string

func (*SCEVMax) Type

func (s *SCEVMax) Type() types.Type

type SCEVUnknown

type SCEVUnknown struct {
	Value       ssa.Value
	IsInvariant bool
}

func (*SCEVUnknown) EvaluateAt

func (s *SCEVUnknown) EvaluateAt(k *big.Int, cache map[SCEV]*big.Int) *big.Int

func (*SCEVUnknown) IsLoopInvariant

func (s *SCEVUnknown) IsLoopInvariant(loop *Loop) bool

func (*SCEVUnknown) Name

func (s *SCEVUnknown) Name() string

func (*SCEVUnknown) Parent

func (s *SCEVUnknown) Parent() *ssa.Function

func (*SCEVUnknown) Pos

func (s *SCEVUnknown) Pos() token.Pos

func (*SCEVUnknown) Referrers

func (s *SCEVUnknown) Referrers() *[]ssa.Instruction

func (*SCEVUnknown) String

func (s *SCEVUnknown) String() string

func (*SCEVUnknown) StringWithRenamer

func (s *SCEVUnknown) StringWithRenamer(r Renamer) string

func (*SCEVUnknown) Type

func (s *SCEVUnknown) Type() types.Type

Jump to

Keyboard shortcuts

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