Documentation
¶
Index ¶
- func BlockName(v value.Value) string
- func Compile(out io.Writer, m *ir.Module, packageName string) error
- func FormatSigned(v value.Value) (*jen.Statement, error)
- func FormatUnsigned(v value.Value) (*jen.Statement, error)
- func FormatValue(v value.Value) (*jen.Statement, error)
- func GetElementPtr(elemType types.Type, src value.Value, indices []value.Value) (expr, error)
- func PhiAssignments(a, b value.Value) (*jen.Statement, error)
- func Qual[T any]() *jen.Statement
- func Sym(fn any) goRef
- func TranslateInstruction(inst ir.Instruction) ([]jen.Code, error)
- func TypeDefinition(t types.Type) (*jen.Statement, error)
- func TypeName(t types.Type) string
- func TypeSpec(t types.Type) (*jen.Statement, error)
- func VariableName(v value.Named) string
- type Command
- type Index
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatSigned ¶
FormatSigned is like FormatValue, except that it converts "byte" to "int8".
func FormatUnsigned ¶
FormatUnsigned is like FormatValue, except that it converts integer types to unsigned.
func FormatValue ¶
FormatValue formats a constant or variable as it should appear in an expression.
func GetElementPtr ¶
GetElementPtr translates a getelementptr expression. The LLVM pointer value is always unsafe.Pointer. *T exists only while indexing into a struct/array or as AddPointer's type argument.
func PhiAssignments ¶
PhiAssignments returns an assignment statement expressing the effects of Phi nodes on the branch from block a to block b. If block b has no phi nodes, it returns nil.
func Sym ¶
func Sym(fn any) goRef
Sym is a resolved package-level func (pkg+name). Call/Types emit jen. Generic instantiations drop [T]. Maps store this; FuncForPC runs once.
func TranslateInstruction ¶
func TranslateInstruction(inst ir.Instruction) ([]jen.Code, error)
TranslateInstruction translates an LLVM instruction to one or more Go statements. A nil slice means the instruction is a no-op in Go.
func TypeDefinition ¶
TypeDefinition returns the definition (not just the name) of t.
func TypeName ¶
TypeName returns t's local Go name, or the empty string if t is unnamed or mapped to a standard-library type. Clang anonymous structs become names like "anon.1"; those are sanitized to legal Go identifiers (anon_1).
func VariableName ¶
VariableName returns the name to use for a local variable or parameter.
Types ¶
type Command ¶
type Command struct {
// Package is the generated Go package name. Empty means "main".
Package string
// Name is an optional source label for parse errors (file path or "<stdin>").
Name string
// Input is LLVM IR assembly.
Input io.Reader
// Output receives generated Go source.
Output io.Writer
}
Command transpiles LLVM IR to Go. Fill Input (and usually Output), then call Run.
type Index ¶
type Index struct {
// contains filtered or unexported fields
}
An Index has maps for navigating "against the grain" of the pointers in the intermediate representation: from values to the instructions that use them, and from instructions to the blocks that contain them.
func (*Index) DeleteInstruction ¶
func (i *Index) DeleteInstruction(inst ir.Instruction)
DeleteInstruction deletes inst.
func (*Index) ReplaceValue ¶
ReplaceValue replaces oldVal with newVal wherever it is used.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
leaven
command
|
|
|
internal
|
|
|
genir
command
Command genir emits testdata/ir/*/input.<LLVM-major>.ll from source.{c,cpp,rs}.
|
Command genir emits testdata/ir/*/input.<LLVM-major>.ll from source.{c,cpp,rs}. |
|
llir/internal/enc
Package enc implements encoding of identifiers for LLVM IR assembly.
|
Package enc implements encoding of identifiers for LLVM IR assembly. |
|
llir/internal/gep
Package gep computes the result type of getelementptr instructions and constant expressions.
|
Package gep computes the result type of getelementptr instructions and constant expressions. |
|
llir/internal/natsort
Package natsort implements natural sort.
|
Package natsort implements natural sort. |
|
llir/ir
Package ir declares the types used to represent LLVM IR modules.
|
Package ir declares the types used to represent LLVM IR modules. |
|
llir/ir/constant
Package constant implements values representing immutable LLVM IR constants.
|
Package constant implements values representing immutable LLVM IR constants. |
|
llir/ir/enum
Package enum defines enumerate types of LLVM IR.
|
Package enum defines enumerate types of LLVM IR. |
|
llir/ir/metadata
Package metadata provides access to LLVM IR metadata.
|
Package metadata provides access to LLVM IR metadata. |
|
llir/ir/types
Package types declares the data types of LLVM IR.
|
Package types declares the data types of LLVM IR. |
|
llir/ir/value
Package value provides a definition of LLVM IR values.
|
Package value provides a definition of LLVM IR values. |
|
llir/v14/asm
Package asm implements a parser for LLVM IR assembly files.
|
Package asm implements a parser for LLVM IR assembly files. |
|
The libc package implements various functions from the C standard library in Go.
|
The libc package implements various functions from the C standard library in Go. |