Documentation ¶
Index ¶
- Constants
- type Compiler
- func (c *Compiler) ApplyFunctionSections()
- func (c *Compiler) Compile(mainPath string) error
- func (c *Compiler) EmitBitcode(path string) error
- func (c *Compiler) EmitObject(path string) error
- func (c *Compiler) EmitText(path string) error
- func (c *Compiler) ExternalInt64AsPtr() error
- func (c *Compiler) IR() string
- func (c *Compiler) LowerFuncValues()
- func (c *Compiler) LowerGoroutines() error
- func (c *Compiler) LowerInterfaces()
- func (c *Compiler) Module() llvm.Module
- func (c *Compiler) NonConstGlobals()
- func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) error
- func (c *Compiler) OptimizeAllocs()
- func (c *Compiler) OptimizeMaps()
- func (c *Compiler) OptimizeStringToBytes()
- func (c *Compiler) Packages() []*loader.Package
- func (c *Compiler) TargetData() llvm.TargetData
- func (c *Compiler) Verify() error
- type Config
- type Frame
- type Phi
- type StdSizes
Constants ¶
const MaxFieldsPerParam = 3
The maximum number of arguments that can be expanded from a single struct. If a struct contains more fields, it is passed as a struct without expanding.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Compiler ¶
type Compiler struct { Config // contains filtered or unexported fields }
func (*Compiler) ApplyFunctionSections ¶
func (c *Compiler) ApplyFunctionSections()
func (*Compiler) Compile ¶
Compile the given package path or .go file path. Return an error when this fails (in any stage).
func (*Compiler) EmitBitcode ¶
Emit LLVM bitcode file (.bc).
func (*Compiler) EmitObject ¶
Emit object file (.o).
func (*Compiler) ExternalInt64AsPtr ¶
When -wasm-abi flag set to "js" (default), replace i64 in an external function with a stack-allocated i64*, to work around the lack of 64-bit integers in JavaScript (commonly used together with WebAssembly). Once that's resolved, this pass may be avoided. See also the -wasm-abi= flag https://github.com/WebAssembly/design/issues/1172
func (*Compiler) LowerFuncValues ¶ added in v0.5.0
func (c *Compiler) LowerFuncValues()
LowerFuncValue lowers the runtime.funcValueWithSignature type and runtime.getFuncPtr function to their final form.
func (*Compiler) LowerGoroutines ¶
LowerGoroutines is a pass called during optimization that transforms the IR into one where all blocking functions are turned into goroutines and blocking calls into await calls.
func (*Compiler) LowerInterfaces ¶
func (c *Compiler) LowerInterfaces()
Lower all interface functions. They are emitted by the compiler as higher-level intrinsics that need some lowering before LLVM can work on them. This is done so that a few cleanup passes can run before assigning the final type codes.
func (*Compiler) Module ¶
func (c *Compiler) Module() llvm.Module
Return the LLVM module. Only valid after a successful compile.
func (*Compiler) NonConstGlobals ¶
func (c *Compiler) NonConstGlobals()
Turn all global constants into global variables. This works around a limitation on Harvard architectures (e.g. AVR), where constant and non-constant pointers point to a different address space.
func (*Compiler) Optimize ¶
Run the LLVM optimizer over the module. The inliner can be disabled (if necessary) by passing 0 to the inlinerThreshold.
func (*Compiler) OptimizeAllocs ¶
func (c *Compiler) OptimizeAllocs()
Basic escape analysis: translate runtime.alloc calls into alloca instructions.
func (*Compiler) OptimizeMaps ¶
func (c *Compiler) OptimizeMaps()
Eliminate created but not used maps.
In the future, this should statically allocate created but never modified maps. This has not yet been implemented, however.
func (*Compiler) OptimizeStringToBytes ¶
func (c *Compiler) OptimizeStringToBytes()
Transform runtime.stringToBytes(...) calls into const []byte slices whenever possible. This optimizes the following pattern:
w.Write([]byte("foo"))
where Write does not store to the slice.
func (*Compiler) TargetData ¶
func (c *Compiler) TargetData() llvm.TargetData
Return the LLVM target data object. Only valid after a successful compile.
type Config ¶
type Config struct { Triple string // LLVM target triple, e.g. x86_64-unknown-linux-gnu (empty string means default) CPU string // LLVM CPU name, e.g. atmega328p (empty string means default) GOOS string // GOARCH string // GC string // garbage collection strategy CFlags []string // cflags to pass to cgo LDFlags []string // ldflags to pass to cgo DumpSSA bool // dump Go SSA, for compiler debugging Debug bool // add debug symbols for gdb RootDir string // GOROOT for TinyGo GOPATH string // GOPATH, like `go env GOPATH` BuildTags []string // build tags for TinyGo (empty means {Config.GOOS/Config.GOARCH}) }
Configure the compiler.