Documentation ¶
Overview ¶
Package interp interprets Go package initializers as much as possible. This avoid running them at runtime, improving code size and making other optimizations possible.
Index ¶
- Variables
- func Run(mod llvm.Module, targetData llvm.TargetData, debug bool) error
- type Eval
- type LocalValue
- func (v *LocalValue) GetElementPtr(indices []uint32) Value
- func (v *LocalValue) IsConstant() bool
- func (v *LocalValue) Load() llvm.Value
- func (v *LocalValue) MarkDirty()
- func (v *LocalValue) Store(value llvm.Value)
- func (v *LocalValue) String() string
- func (v *LocalValue) Type() llvm.Type
- func (v *LocalValue) Value() llvm.Value
- type MapValue
- func (v *MapValue) GetElementPtr(indices []uint32) Value
- func (v *MapValue) IsConstant() bool
- func (v *MapValue) Load() llvm.Value
- func (v *MapValue) PutBinary(keyPtr, valPtr *LocalValue)
- func (v *MapValue) PutString(keyBuf, keyLen, valPtr *LocalValue)
- func (v *MapValue) Store(value llvm.Value)
- func (v *MapValue) String() string
- func (v *MapValue) Type() llvm.Type
- func (v *MapValue) Value() llvm.Value
- type Unsupported
- type Value
Constants ¶
This section is empty.
Variables ¶
var ErrUnreachable = errors.New("interp: unreachable executed")
Functions ¶
Types ¶
type Eval ¶
type Eval struct { Mod llvm.Module TargetData llvm.TargetData Debug bool // contains filtered or unexported fields }
type LocalValue ¶
type LocalValue struct { Eval *Eval Underlying llvm.Value }
A type that simply wraps a LLVM constant value.
func (*LocalValue) GetElementPtr ¶
func (v *LocalValue) GetElementPtr(indices []uint32) Value
GetElementPtr returns a GEP when the underlying value is of pointer type.
func (*LocalValue) IsConstant ¶
func (v *LocalValue) IsConstant() bool
func (*LocalValue) Load ¶
func (v *LocalValue) Load() llvm.Value
Load loads a constant value if this is a constant pointer.
func (*LocalValue) MarkDirty ¶ added in v0.4.0
func (v *LocalValue) MarkDirty()
MarkDirty marks this global as dirty, meaning that every load from and store to this global (from now on) must be performed at runtime.
func (*LocalValue) Store ¶
func (v *LocalValue) Store(value llvm.Value)
Store stores to the underlying value if the value type is a pointer type, otherwise it panics.
func (*LocalValue) String ¶
func (v *LocalValue) String() string
func (*LocalValue) Type ¶
func (v *LocalValue) Type() llvm.Type
func (*LocalValue) Value ¶
func (v *LocalValue) Value() llvm.Value
Value implements Value by returning the constant value itself.
type MapValue ¶
type MapValue struct { Eval *Eval PkgName string Underlying llvm.Value Keys []Value Values []Value KeySize int ValueSize int KeyType llvm.Type ValueType llvm.Type }
MapValue implements a Go map which is created at compile time and stored as a global variable.
func (*MapValue) GetElementPtr ¶
GetElementPtr panics: maps are of reference type so their (interior) addresses cannot be calculated.
func (*MapValue) IsConstant ¶
func (*MapValue) Load ¶
func (v *MapValue) Load() llvm.Value
Load panics: maps are of reference type so cannot be dereferenced.
func (*MapValue) PutBinary ¶
func (v *MapValue) PutBinary(keyPtr, valPtr *LocalValue)
PutBinary does a map assign operation.
func (*MapValue) PutString ¶
func (v *MapValue) PutString(keyBuf, keyLen, valPtr *LocalValue)
PutString does a map assign operation, assuming that the map is of type map[string]T.
func (*MapValue) Store ¶
func (v *MapValue) Store(value llvm.Value)
Store panics: maps are of reference type so cannot be stored to.
type Unsupported ¶
type Unsupported struct {
Inst llvm.Value
}
func (Unsupported) Error ¶
func (e Unsupported) Error() string
type Value ¶
type Value interface { Value() llvm.Value // returns a LLVM value Type() llvm.Type // equal to Value().Type() IsConstant() bool // returns true if this value is a constant value Load() llvm.Value // dereference a pointer Store(llvm.Value) // store to a pointer GetElementPtr([]uint32) Value // returns an interior pointer String() string // string representation, for debugging }
A Value is a LLVM value with some extra methods attached for easier interpretation.