wax

package
v0.0.0-...-3940e3f Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagsLoadLocal = 1 << iota
	FlagsLoadGlobal
	FlagsLoadMem
	FlagsStoreLocal
	FlagsStoreGlobal
	FlagsStoreMem
	FlagsMayTrap
	FlagsPseudo

	FlagsBackend = 1 << 16

	FlagsLoadMask  = (FlagsLoadMem << 1) - 1
	FlagsStoreMask = (FlagsStoreMem << 1) - 1
)
View Source
const (
	PseudoBoolConst = 0 + iota
	PseudoI32ConvertBool

	PseudoBackend = 128
)
View Source
const ValueTypeBool = 1

Variables

This section is empty.

Functions

func BoolConst

func BoolConst(x *Expression) bool

Types

type Block

type Block struct {
	Entry *Expression
	Else  *Expression
	End   *Expression

	Label          int
	StackHeight    int
	BranchTarget   bool
	Unreachable    bool
	NeverReachable bool

	Ins  []wasm.ValueType
	Outs []wasm.ValueType

	InTemp  int
	OutTemp int
}

type Def

type Def struct {
	*Expression

	Block *Block

	BranchTargets []*Block
	Types         []wasm.ValueType
	Temp          int
}

func (*Def) Format

func (d *Def) Format(f fmt.State, verb rune)

type Expression

type Expression struct {
	Function *Function

	IP    int
	Instr code.Instruction
	Uses  Uses
	Flags Flags
	// contains filtered or unexported fields
}

func Pseudo

func Pseudo(f *Function, opcode byte, immediate uint64, flags Flags, uses ...*Use) *Expression

func (*Expression) Format

func (x *Expression) Format(f fmt.State, verb rune)

func (*Expression) IsPseudo

func (x *Expression) IsPseudo() bool

type Flags

type Flags int32

func (Flags) CanMoveAfter

func (f Flags) CanMoveAfter(g Flags) bool

type Formatter

type Formatter interface {
	FormatExpression(f fmt.State, verb rune, x *Expression)
	FormatUse(f fmt.State, verb rune, u *Use)
	FormatUses(f fmt.State, verb rune, us Uses)
	FormatDef(f fmt.State, verb rune, d *Def)
}

type Function

type Function struct {
	Formatter Formatter

	Signature wasm.FunctionSig

	Locals     []wasm.ValueType
	UsedLocals []bool
	Stack      []*Use
	Temps      int

	Blocks []*Block
	Labels int

	Body []*Def
	// contains filtered or unexported fields
}

func ImportFunction

func ImportFunction(typeIndex uint32, signature wasm.FunctionSig, body wasm.FunctionBody, scope code.Scope, formatter Formatter) Function

func NewFunction

func NewFunction(typeIndex uint32, signature wasm.FunctionSig, body wasm.FunctionBody, scope code.Scope, formatter Formatter) Function

func (*Function) DropStack

func (f *Function) DropStack(until int)

func (*Function) FinishImport

func (f *Function) FinishImport() []*Def

func (*Function) ImportInstruction

func (f *Function) ImportInstruction(ip int, instr code.Instruction, scope *FunctionScope)

func (*Function) LabelTypes

func (f *Function) LabelTypes(idx int) []wasm.ValueType

func (*Function) Scope

func (f *Function) Scope(module code.Scope) *FunctionScope

func (*Function) Unreachable

func (f *Function) Unreachable() bool

type FunctionScope

type FunctionScope struct {
	code.Scope
	// contains filtered or unexported fields
}

func (*FunctionScope) GetLocalType

func (s *FunctionScope) GetLocalType(localidx uint32) (wasm.ValueType, bool)

type Use

type Use struct {
	Function *Function

	Type     wasm.ValueType
	AllFlags Flags
	Locals   bitset.BitSet

	Temp int
	X    *Expression
}

func UseExpression

func UseExpression(type_ wasm.ValueType, x *Expression) *Use

func (*Use) CanMoveAfter

func (u *Use) CanMoveAfter(flags Flags, localStores bitset.BitSet) bool

func (*Use) Format

func (u *Use) Format(f fmt.State, verb rune)

func (*Use) IsConst

func (u *Use) IsConst() bool

func (*Use) IsTemp

func (u *Use) IsTemp() bool

func (*Use) IsZeroIConst

func (u *Use) IsZeroIConst() bool

type Uses

type Uses []*Use

func (Uses) Format

func (us Uses) Format(f fmt.State, verb rune)

Jump to

Keyboard shortcuts

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