llgo

package module
v0.0.0-...-66c8b22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2012 License: BSD-3-Clause, MIT Imports: 18 Imported by: 0

README

llgo

llgo is a compiler for Go, written in Go, and using the LLVM compiler infrastructure.

llgo is a fledgling, and is being developed primarily as an educational exercise. It is not presently useful for real work. Progress will be reported at http://blog.awilkins.id.au.

Installation

The recommended way to install llgo is to use go get. You'll need to set a couple of environment variables first:

export CGO_CFLAGS=`llvm-config --cflags`
export CGO_LDFLAGS="`llvm-config --ldflags` -Wl,-L`llvm-config --libdir` -lLLVM-`llvm-config --version`"
go get github.com/axw/llgo/llgo

You must have LLVM 3.1+ in your path. At the time of writing, LLVM 3.1 has not yet been released, so you must build it from the LLVM SVN repository.

Running

Currently there is just a compiler which produces LLVM bitcode, and there is no integration with gomake/goinstall/cgo, etc. To compile a Go source file, simply run llgo <file.go>, which will emit LLVM bitcode to stdout. To produce human-readable LLVM assembly code, supply an additional -dump command line argument before <file.go>.

Documentation

Index

Constants

View Source
const (
	LLGOAuthor   = "Andrew Wilkins <axwalk@gmail.com>"
	LLGOProducer = "llgo " + LLGOVersion + " (" + LLGOAuthor + ")"
)

llgo constants.

View Source
const (
	LLGOVersion        = "0.1"
	LLGORuntimeVersion = 0
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

type Compiler interface {
	Compile(*token.FileSet, *ast.Package, map[ast.Expr]types.Type) (*Module, error)
	SetTraceEnabled(bool)
	SetTargetArch(string)
	SetTargetOs(string)
}

func NewCompiler

func NewCompiler() Compiler

type ConstValue

type ConstValue struct {
	types.Const
	// contains filtered or unexported fields
}

ConstValue represents a constant value produced as the result of an expression.

func (ConstValue) BinaryOp

func (lhs ConstValue) BinaryOp(op token.Token, rhs_ Value) Value

func (ConstValue) Convert

func (v ConstValue) Convert(dstTyp types.Type) Value

func (ConstValue) Int64

func (v ConstValue) Int64() int64

func (ConstValue) LLVMValue

func (v ConstValue) LLVMValue() llvm.Value

func (ConstValue) Type

func (v ConstValue) Type() types.Type

func (ConstValue) UnaryOp

func (v ConstValue) UnaryOp(op token.Token) Value

type LLVMValue

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

LLVMValue represents a dynamic value produced as the result of an expression.

func (*LLVMValue) BinaryOp

func (lhs *LLVMValue) BinaryOp(op token.Token, rhs_ Value) Value

func (*LLVMValue) Convert

func (v *LLVMValue) Convert(dst_typ types.Type) Value

func (*LLVMValue) LLVMValue

func (v *LLVMValue) LLVMValue() llvm.Value

func (*LLVMValue) Type

func (v *LLVMValue) Type() types.Type

func (*LLVMValue) UnaryOp

func (v *LLVMValue) UnaryOp(op token.Token) Value

type Module

type Module struct {
	llvm.Module
	Name     string
	Disposed bool
}

func (Module) Dispose

func (m Module) Dispose()

type NilValue

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

NilValue represents a nil value. All methods other than Convert will panic when called.

func (NilValue) BinaryOp

func (NilValue) BinaryOp(op token.Token, rhs Value) Value

func (NilValue) Convert

func (n NilValue) Convert(typ types.Type) Value

func (NilValue) LLVMValue

func (NilValue) LLVMValue() llvm.Value

func (NilValue) Type

func (NilValue) Type() types.Type

func (NilValue) UnaryOp

func (NilValue) UnaryOp(op token.Token) Value

type TypeMap

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

func NewTypeMap

func NewTypeMap(module llvm.Module, target llvm.TargetData, exprTypes map[ast.Expr]types.Type) *TypeMap

func (*TypeMap) ToLLVM

func (tm *TypeMap) ToLLVM(t types.Type) llvm.Type

func (*TypeMap) ToRuntime

func (tm *TypeMap) ToRuntime(t types.Type) llvm.Value

type TypeValue

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

TypeValue represents a Type result of an expression. All methods other than Type() will panic when called.

func (TypeValue) BinaryOp

func (TypeValue) BinaryOp(op token.Token, rhs Value) Value

func (TypeValue) Convert

func (TypeValue) Convert(typ types.Type) Value

func (TypeValue) LLVMValue

func (TypeValue) LLVMValue() llvm.Value

func (TypeValue) Type

func (t TypeValue) Type() types.Type

func (TypeValue) UnaryOp

func (TypeValue) UnaryOp(op token.Token) Value

type Value

type Value interface {
	// BinaryOp applies the specified binary operator to this value and the
	// specified right-hand operand, and returns a new Value.
	BinaryOp(op token.Token, rhs Value) Value

	// UnaryOp applies the specified unary operator and returns a new Value.
	UnaryOp(op token.Token) Value

	// Convert returns a new Value which has been converted to the specified
	// type.
	Convert(typ types.Type) Value

	// LLVMValue returns an llvm.Value for this value.
	LLVMValue() llvm.Value

	// Type returns the Type of the value.
	Type() types.Type
}

Value is an interface for representing values returned by Go expressions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL