Documentation
¶
Index ¶
- Constants
- type Backend
- type Emitter
- func (c *Emitter) Add(p1, p2 types.Type, swapped bool) types.Type
- func (c *Emitter) Addr(lv LV)
- func (c *Emitter) Align(k, align int)
- func (c *Emitter) AlignText()
- func (c *Emitter) And()
- func (c *Emitter) BSS(name string, length int, static bool)
- func (c *Emitter) Bool()
- func (c *Emitter) BrFalse(dest int)
- func (c *Emitter) BrTrue(dest int)
- func (c *Emitter) Branch(dest int, inv bool)
- func (c *Emitter) Call(lv LV)
- func (c *Emitter) Calr(lv LV)
- func (c *Emitter) Clear(q bool)
- func (c *Emitter) Commit()
- func (c *Emitter) Data()
- func (c *Emitter) Defb(v int)
- func (c *Emitter) Defp(v int)
- func (c *Emitter) Defs(s string)
- func (c *Emitter) Defw(v int)
- func (c *Emitter) Div(swapped bool)
- func (c *Emitter) Entry()
- func (c *Emitter) Exit()
- func (c *Emitter) Gen(s string)
- func (c *Emitter) Gsym(s string) string
- func (c *Emitter) Inc(lv LV, inc, pre bool)
- func (c *Emitter) Ind(lv LV)
- func (c *Emitter) Int() int
- func (c *Emitter) Jump(dest int)
- func (c *Emitter) Lab(id int)
- func (c *Emitter) Label() int
- func (c *Emitter) Labname(id int) string
- func (c *Emitter) Ldlab(id int)
- func (c *Emitter) Lgen(s, inst string, n int)
- func (c *Emitter) Lgen2(s string, v1, v2 int)
- func (c *Emitter) Lit(v int)
- func (c *Emitter) Load()
- func (c *Emitter) LocInit(localInits [][2]int)
- func (c *Emitter) LogBr(dest int, inv bool)
- func (c *Emitter) LogNot()
- func (c *Emitter) Mod(swapped bool)
- func (c *Emitter) Mul()
- func (c *Emitter) Name(name string)
- func (c *Emitter) Neg()
- func (c *Emitter) Ngen(s string, args ...interface{})
- func (c *Emitter) Ngen2(s, inst string, n, a int)
- func (c *Emitter) Not()
- func (c *Emitter) Or()
- func (c *Emitter) Pointer() int
- func (c *Emitter) Postlude()
- func (c *Emitter) Prelude()
- func (c *Emitter) Public(name string)
- func (c *Emitter) Push()
- func (c *Emitter) PushLit(n int)
- func (c *Emitter) Queue(typ, value int, name string)
- func (c *Emitter) QueueBool(op int)
- func (c *Emitter) QueueCmp(op int)
- func (c *Emitter) Raw(s string)
- func (c *Emitter) Rval(lv LV)
- func (c *Emitter) Scale()
- func (c *Emitter) ScaleBy(v int)
- func (c *Emitter) Sgen(s, inst, s2 string)
- func (c *Emitter) Sgen2(s, inst string, v int, s2 string)
- func (c *Emitter) Shl(swapped bool)
- func (c *Emitter) Shr(swapped bool)
- func (c *Emitter) Sizeof(T types.Type) int
- func (c *Emitter) Spill()
- func (c *Emitter) Stack(n int)
- func (c *Emitter) Store(lv LV)
- func (c *Emitter) Sub(p1, p2 types.Type, swapped bool) types.Type
- func (c *Emitter) Switch(vals, labs []int, dflt int)
- func (c *Emitter) Text()
- func (c *Emitter) Xor()
- type LV
Constants ¶
const ( Empty = iota AddrAuto AddrStatic AddrGlobal AddrLabel Literal AutoByte AutoWord StaticByte StaticWord GlobalByte GlobalWord )
Addressing modes for the code synthesizer.
const ( Cnone = iota Equal NotEqual Less Greater LessEqual GreaterEqual Below Above BelowEqual AboveEqual )
Comparison operations.
const ( Bnone = iota LogNot Normalize )
Boolean operations.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface { Add() Align() And() Bool() BrEq(n int) BrFalse(n int) BrGe(n int) BrGt(n int) BrLe(n int) BrLt(n int) BrNe(n int) BrTrue(n int) BrUge(n int) BrUgt(n int) BrUle(n int) BrUlt(n int) Call(s string) Calr() CalSwtch() Case(v, l int) Clear() Clear2() Data() Dec1ib() Dec1iw() Dec1pi(v int) Dec2ib() Dec2iw() Dec2pi(v int) Decgb(s string) Decgw(s string) Declb(a int) Declw(a int) Decpg(s string, v int) Decpl(a, v int) Decps(a, v int) Decsb(a int) Decsw(a int) Defb(v int) Defc(c int) Defl(v int) Defp(v int) Defw(v int) Div() Entry() Eq() Exit() Gbss(s string, z int) Ge() Gt() Inc1ib() Inc1iw() Inc1pi(v int) Inc2ib() Inc2iw() Inc2pi(v int) Incgb(s string) Incgw(s string) Inclb(a int) Inclw(a int) Incpg(s string, v int) Incpl(a, v int) Incps(a, v int) Incsb(a int) Incsw(a int) Indb() Indw() Initlw(v, a int) Or() Jump(n int) Lbss(s string, z int) Ldga(s string) Ldgb(s string) Ldgw(s string) Ldinc() Ldla(n int) Ldlab(id int) Ldlb(n int) Ldlw(n int) Ldsa(n int) Ldsb(n int) Ldsw(n int) LdSwtch(n int) Le() Lit(v int) Load2() bool LogNot() Lt() Mod() Mul() Ne() Neg() Not() Pop2() PopPtr() Postlude() Prelude() Public(s string) Push() PushLit(n int) Scale() Scale2() Scale2By(v int) ScaleBy(v int) Shl() Shr() Stack(n int) Storgb(s string) Storgw(s string) Storib() Storiw() Storlb(n int) Storlw(n int) Storsb(n int) Storsw(n int) Sub() Swap() Text() Uge() Ugt() Ule() Ult() Unscale() UnscaleBy(v int) Xor() }
Backend represents an interface a architecture specific code generator must have for the compiler to use for generating code.
type Emitter ¶
type Emitter struct { types.Sizes W io.Writer B Backend Q synth Retlab int Acc bool // contains filtered or unexported fields }
Emitter is uses to emit code.
func (*Emitter) AlignText ¶
func (c *Emitter) AlignText()
AlignText emits code for aligning the text segment.
func (*Emitter) Commit ¶
func (c *Emitter) Commit()
Commit flushes the code synthesizer to load and spill the registers to memory.
func (*Emitter) Load ¶
func (c *Emitter) Load()
Load enables the accumulator, meaning it tells the later code generation it must spills if it wants to mess with the accumulator.
func (*Emitter) Public ¶
Public emits code for defining a global symbol, used for global identifiers.
func (*Emitter) Push ¶
func (c *Emitter) Push()
Push emits code for pushing to the stack after flushing the code synthesizer.
func (*Emitter) PushLit ¶
PushLit pushes a literal to the stack after flushing the code synthesizer.
func (*Emitter) Scale ¶
func (c *Emitter) Scale()
Scale emits code to scale indices for pointer arithmetic and array accesses.
type LV ¶
type LV struct { Ident bool // if the variable is an identifier Addressable bool // if the variable is addressable Storage types.Storage // the storage type of the variable Type types.Type // type of the variable Btype types.Type // for binary expressions where it can implicitly cast the result such as pointer - pointer becomes an integer Name string // name of the variable if any Size int // size of the variable, for sizeof Addr int // the location of the variable, such as the offset of where it is on the stack Value constant.Value // if the variable is a constant, the constant will be stored here }
LV is a structure that an emitter uses as arguments to generate code, it mainly contains data structure for variables and their resulting types after an expression has been done on them.
Directories
¶
Path | Synopsis |
---|---|
Package amd64 contains a code emitter for generating code for the x86_64 architecture.
|
Package amd64 contains a code emitter for generating code for the x86_64 architecture. |
Package arm6 contains a code emitter to generate code for the ARMv6 architecture.
|
Package arm6 contains a code emitter to generate code for the ARMv6 architecture. |
Package darwinamd64 contains code to generate a x86_64 architecture that is running on darwin.
|
Package darwinamd64 contains code to generate a x86_64 architecture that is running on darwin. |
Package i386 contains code to generate code for the x86 architecture.
|
Package i386 contains code to generate code for the x86 architecture. |