Documentation
¶
Overview ¶
Package typifier types the expressions of an IR function: Rust naga's Typifier (front/mod.rs) with the rules of proc::ResolveContext::resolve (proc/typifier.rs). The validator's callers, every backend and the WGSL frontend type expressions with it; no stage keeps types of its own in the IR.
A Typifier holds one TypeResolution per expression of one function, in arena order. Grow types the expressions it does not have yet, each from the resolutions of its operands, which it already holds: one linear pass, memoized, with no recursion.
Index ¶
- type Error
- type Module
- type Typifier
- func (t *Typifier) Get(h ir.ExpressionHandle) ir.TypeResolution
- func (t *Typifier) Grow(m *ir.Module, fn *ir.Function, upTo ir.ExpressionHandle) error
- func (t *Typifier) Inner(m *ir.Module, h ir.ExpressionHandle) ir.TypeInner
- func (t *Typifier) Invalidate(m *ir.Module, fn *ir.Function, h ir.ExpressionHandle) error
- func (t *Typifier) Len() int
- func (t *Typifier) Reset()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
Expression ir.ExpressionHandle
Err error
}
Error is a failure to type an expression (Rust's ResolveError, with the expression it is about).
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
Module holds the typifier of every function and entry point of a module: what a backend's Compile types once before it writes the module.
type Typifier ¶
type Typifier struct {
// contains filtered or unexported fields
}
Typifier holds the type of every expression of a function up to Len. The zero value is empty and ready to use.
func (*Typifier) Get ¶
func (t *Typifier) Get(h ir.ExpressionHandle) ir.TypeResolution
Get returns the type of expression h, which Grow has typed.
func (*Typifier) Grow ¶
Grow types every expression of fn below upTo that t has not typed yet, in arena order. A pass that appends expressions to fn calls it again to type them, as Rust's Typifier::grow.
The IR a frontend makes refers only to earlier expressions. The DXIL backend's passes also refer forward: an inlined call's result loads a later return slot, an alias stands for a later phi, a phi merges values of a loop's later iteration. Grow types such an expression once the expression it reads is typed, after the expressions that follow it; a phi takes the type of the first incoming value that is typed, since every incoming value has the phi's type.
On an error t keeps what it had before the call.
func (*Typifier) Invalidate ¶
Invalidate types expression h, which t has typed, again from what fn's arena holds now: for a pass that rewrote h in place (Rust's Typifier::invalidate). The expressions h reads keep their types.