tinygo: github.com/tinygo-org/tinygo/compiler Index | Files

package compiler

import "github.com/tinygo-org/tinygo/compiler"

Index

Package Files

asserts.go calls.go channel.go check.go compiler.go defer.go errors.go func-lowering.go func.go gc.go goroutine-lowering.go goroutine.go inlineasm.go interface-lowering.go interface.go llvm.go map.go optimizer.go reflect.go sizes.go symbol.go syscall.go volatile.go wordpack.go

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.

type Compiler Uses

type Compiler struct {
    Config
    // contains filtered or unexported fields
}

func NewCompiler Uses

func NewCompiler(pkgName string, config Config) (*Compiler, error)

func (*Compiler) ApplyFunctionSections Uses

func (c *Compiler) ApplyFunctionSections()

func (*Compiler) Compile Uses

func (c *Compiler) Compile(mainPath string) []error

Compile the given package path or .go file path. Return an error when this fails (in any stage).

func (*Compiler) EmitBitcode Uses

func (c *Compiler) EmitBitcode(path string) error

Emit LLVM bitcode file (.bc).

func (*Compiler) EmitObject Uses

func (c *Compiler) EmitObject(path string) error

Emit object file (.o).

func (*Compiler) EmitText Uses

func (c *Compiler) EmitText(path string) error

Emit LLVM IR source file (.ll).

func (*Compiler) ExternalInt64AsPtr Uses

func (c *Compiler) ExternalInt64AsPtr() error

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) IR Uses

func (c *Compiler) IR() string

IR returns the whole IR as a human-readable string.

func (*Compiler) LowerFuncValues Uses

func (c *Compiler) LowerFuncValues()

LowerFuncValue lowers the runtime.funcValueWithSignature type and runtime.getFuncPtr function to their final form.

func (*Compiler) LowerGoroutines Uses

func (c *Compiler) LowerGoroutines() error

LowerGoroutines performs some IR transformations necessary to support goroutines. It does something different based on whether it uses the coroutine or the tasks implementation of goroutines, and whether goroutines are necessary at all.

func (*Compiler) LowerInterfaces Uses

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 Uses

func (c *Compiler) Module() llvm.Module

Return the LLVM module. Only valid after a successful compile.

func (*Compiler) NonConstGlobals Uses

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 Uses

func (c *Compiler) Optimize(optLevel, sizeLevel int, inlinerThreshold uint) error

Run the LLVM optimizer over the module. The inliner can be disabled (if necessary) by passing 0 to the inlinerThreshold.

func (*Compiler) OptimizeStringToBytes Uses

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) Packages Uses

func (c *Compiler) Packages() []*loader.Package

func (*Compiler) TargetData Uses

func (c *Compiler) TargetData() llvm.TargetData

Return the LLVM target data object. Only valid after a successful compile.

func (*Compiler) Verify Uses

func (c *Compiler) Verify() error

type Config Uses

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)
    Features      []string // LLVM CPU features
    GOOS          string   //
    GOARCH        string   //
    GC            string   // garbage collection strategy
    Scheduler     string   // scheduler implementation ("coroutines" or "tasks")
    PanicStrategy string   // panic strategy ("print" or "trap")
    CFlags        []string // cflags to pass to cgo
    LDFlags       []string // ldflags to pass to cgo
    ClangHeaders  string   // Clang built-in header include path
    DumpSSA       bool     // dump Go SSA, for compiler debugging
    VerifyIR      bool     // run extra checks on the IR
    Debug         bool     // add debug symbols for gdb
    GOROOT        string   // GOROOT
    TINYGOROOT    string   // GOROOT for TinyGo
    GOPATH        string   // GOPATH, like `go env GOPATH`
    BuildTags     []string // build tags for TinyGo (empty means {Config.GOOS/Config.GOARCH})
    TestConfig    TestConfig
}

Configure the compiler.

type Frame Uses

type Frame struct {
    // contains filtered or unexported fields
}

type Phi Uses

type Phi struct {
    // contains filtered or unexported fields
}

type StdSizes Uses

type StdSizes struct {
    IntSize  int64
    PtrSize  int64
    MaxAlign int64
}

func (*StdSizes) Alignof Uses

func (s *StdSizes) Alignof(T types.Type) int64

func (*StdSizes) Offsetsof Uses

func (s *StdSizes) Offsetsof(fields []*types.Var) []int64

func (*StdSizes) Sizeof Uses

func (s *StdSizes) Sizeof(T types.Type) int64

type TestConfig Uses

type TestConfig struct {
    CompileTestBinary bool
}

Package compiler imports 21 packages (graph) and is imported by 3 packages. Updated 2019-09-18. Refresh now. Tools for package owners.