qbe

package module
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2023 License: BSD-3-Clause, MIT Imports: 22 Imported by: 1

README

qbe

Package qbe deals with the QBE intermediate language

Installation
$ go get [-u] modernc.org/qbe
Documentation

godoc.org/modernc.org/qbe

QBE language overview

QBE language reference

Documentation

Overview

Package qbe deals with the QBE intermediate language

QBE intermediate language introduction:

https://c9x.me/compile/

QBE reference:

https://c9x.me/compile/doc/il.html

QBE vs LLVM:

https://c9x.me/compile/doc/llvm.html

Build status

Available at https://modern-c.appspot.com/-/builder/?importpath=modernc.org%2fqbe

Limitations

The environmental function parameter/argument, as defined at

https://c9x.me/compile/doc/il.html#Functions

is not supported.

Index

Constants

View Source
const (
	// Reserved ABI type name that maps to C va_list. For example
	//
	// A C function
	//
	//	int vprintf(const char *format, va_list ap);
	//
	// can become a QBE function
	//
	//	export function w vprintf(l format, :__qbe_va_list ap) { ... }
	VaList = "__qbe_va_list"

	// Reserved ABI type name that maps to C *va_list. For example
	//
	// A C function
	//
	//	void foo(va_list *ap);
	//
	// can become a QBE function
	//
	//	export function foo(:__qbe_va_listp ap) { ... }
	VaListPtr = "__qbe_va_listp"
)

Variables

View Source
var Keywords = map[string]Ch{}/* 124 elements not displayed */

Keywords represents the mapping of identifiers to QBE's reserved names.

View Source
var (
	// TraceC enables printing the generated C code to stdout.
	TraceC bool // testing
)

Functions

func Version added in v0.0.2

func Version() string

Version reports the version of the qbe package.

Types

type AST

type AST struct {
	Defs        []Node // A FuncDef, DataDef of a TypeDef.
	EOF         Token
	ExternData  map[string]struct{} // Referenced but not defined.
	ExternFuncs map[string]Type     // Called but not defined. The value is the result type or nil if void.
	Funcs       map[string]Type     // Defined functions. The value is the result type or nil if void.
	Scope       Scope
	// contains filtered or unexported fields
}

AST represents the abstract syntax tree.

func (*AST) C added in v0.0.2

func (a *AST) C(out io.Writer, includes, os, arch string) error

C renders an AST as the body of compilable C code prepended with includes.

func (*AST) Err added in v0.0.2

func (a *AST) Err() error

Err reports any error encountered during constructing of a.

func (*AST) FirstSeparator added in v0.0.4

func (a *AST) FirstSeparator() []byte

FirstSeparator reports the white space and comments preceding first token. The result must not be modified.

func (*AST) Warning added in v0.0.7

func (a *AST) Warning() error

Warnings reports any warning encountered during constructing of a.

type Add added in v0.0.2

type Add struct {
	InstPreamble
	Binary
}

Add represents the 'add' instruction.

type Alloc16 added in v0.0.2

type Alloc16 struct {
	InstPreamble
	Value Node
}

Alloc16 represents the 'alloc16' instruction.

type Alloc4 added in v0.0.2

type Alloc4 struct {
	InstPreamble
	Value Node
}

Alloc4 represents the 'alloc4' instruction.

type Alloc8 added in v0.0.2

type Alloc8 struct {
	InstPreamble
	Value Node
}

Alloc8 represents the 'alloc8' instruction.

type And added in v0.0.2

type And struct {
	InstPreamble
	Binary
}

And represents the 'and' instruction.

type ArrayField added in v0.0.2

type ArrayField struct {
	Field
	Len uintptr
}

ArrayField represents an array-shaped field.

func (ArrayField) Position added in v0.0.2

func (n ArrayField) Position() (r token.Position)

type Binary added in v0.0.2

type Binary struct {
	A Node
	B Node
	// contains filtered or unexported fields
}

Binary represents the operands of a binary operation.

type Block

type Block struct {
	Label // @name
	Phis  []*Phi
	Insts []Node
	// Jmp, Jnz, Ret or nil indicating fallthrough into the lexically following block.
	Jump Node
	// contains filtered or unexported fields
}

Block is a linear piece of QBE code with a single entry point and a single exit point.

type CFGNode added in v0.0.8

type CFGNode struct {
	*Block
	In   []*CFGNode // In[x] -> this node. Empty for entry block.
	Out1 *CFGNode   // This node -> Out1. Can be nil.
	Out2 *CFGNode   // This node -> Out2. Can be non-nil only if Out1 is non-nil.
}

CFGNode is a node of a control-flow graph.

type CST added in v0.0.2

type CST struct {
	Defs []Node
	EOF  CSTToken
	// contains filtered or unexported fields
}

CST represents the complete syntax tree. It contains all the tokens of the input. The original source, or any part of it can be reconstructed from the CST or some part of it, including the original whitespace/comments.

func Parse

func Parse(buf []byte, name string, allErrros bool) (*CST, error)

Parse produces a CST or an error, of any. Positions are reported as if buf is coming from a file named name. The buffer becomes owned by the CST and must not be modified after calling Parse.

func (*CST) AST added in v0.0.2

func (n *CST) AST(os, arch string) (*AST, error)

AST produces the AST version of n or an error, if any.

func (*CST) FirstSeparator added in v0.0.4

func (n *CST) FirstSeparator() []byte

FirstSeparator reports the white space and comments preceding first token. The result must not be modified.

type CSTAdd added in v0.0.2

type CSTAdd struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTAdd is a CST node for the add instruction.

type CSTAlloc added in v0.0.2

type CSTAlloc struct {
	CSTInstPreamble
	Val Node
}

CSTAlloc is a CST node for the various alloc* instructions.

type CSTAnd added in v0.0.2

type CSTAnd struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTAnd is a CST node for the and instruction.

type CSTBinaryOperands added in v0.0.2

type CSTBinaryOperands struct {
	A     Node
	Comma CSTToken
	B     Node
}

CSTBinaryOperands represents the operands of a binary operation.

type CSTBlock added in v0.0.2

type CSTBlock struct {
	Label CSTToken
	Phis  []*CSTPhi
	Insts []Node
	Jump  Node
}

CSTBlock is a CST node for:

BLOCK :=
    @IDENT    # Block label
    PHI*      # Phi instructions
    INST*     # Regular instructions
    JUMP      # Jump or return

func (*CSTBlock) Position added in v0.0.2

func (n *CSTBlock) Position() token.Position

Position implements Node.

type CSTCall added in v0.0.2

type CSTCall struct {
	CSTInstPreamble
	Val    Node
	LParen CSTToken
	Args   []Node
	RParen CSTToken
}

CSTCall is a CST node for the call instruction.

CALL := [%IDENT '=' ABITY] 'call' VAL '(' (ARG), ')'

type CSTCast added in v0.0.2

type CSTCast struct {
	CSTInstPreamble
	Val Node
}

CSTCast is a CST node for the cast instruction.

type CSTCmp added in v0.0.2

type CSTCmp struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTCmp is a CST node for the various cmp* instructions.

type CSTCopy added in v0.0.2

type CSTCopy struct {
	CSTInstPreamble
	Val Node
}

CSTCopy is a CST node for the copy instruction.

type CSTDataDef added in v0.0.2

type CSTDataDef struct {
	Export     CSTToken
	RO         CSTToken
	Data       CSTToken
	Global     CSTToken
	Eq         CSTToken
	Align      CSTToken
	Number     CSTToken
	LBrace     CSTToken
	Items      []Node
	RBrace     CSTToken
	Attributes []string
}

CSTDataDef is a CST node for:

DATADEF :=
    ['export'] ['ro'] 'data' $IDENT '=' ['align' NUMBER]
    '{'
        ( EXTTY DATAITEM+
        | 'z'   NUMBER ),
    '}';

func (*CSTDataDef) Position added in v0.0.2

func (n *CSTDataDef) Position() token.Position

Position implements Node.

type CSTDataItemConst added in v0.0.2

type CSTDataItemConst struct {
	Type  CSTToken
	Const Node
}

CSTDataItemConst represents a CST node for a numeric/pointer initializer.

func (*CSTDataItemConst) Position added in v0.0.2

func (n *CSTDataItemConst) Position() token.Position

Position implements Node.

type CSTDataItemGlobal added in v0.0.2

type CSTDataItemGlobal struct {
	Type   CSTToken
	Global CSTToken
	Plus   CSTToken
	Number CSTToken
}

CSTDataItemGlobal is a CST node for an address of a global with optional offset.

func (*CSTDataItemGlobal) Position added in v0.0.2

func (n *CSTDataItemGlobal) Position() token.Position

Position implements Node.

type CSTDataItemString added in v0.0.2

type CSTDataItemString struct {
	Type CSTToken
	Val  CSTToken
}

CSTDataItemString represents a CST node for a string literal data initializer.

func (*CSTDataItemString) Position added in v0.0.2

func (n *CSTDataItemString) Position() token.Position

Position implements Node.

type CSTDataItemZero added in v0.0.2

type CSTDataItemZero struct {
	Z      CSTToken
	Number CSTToken
}

CSTDataItemZero is a CST node for zero data item of a data definition.

func (*CSTDataItemZero) Position added in v0.0.2

func (n *CSTDataItemZero) Position() token.Position

Position implements Node.

type CSTDataItems added in v0.0.2

type CSTDataItems struct {
	Items []Node
}

CSTDataItems is a CST node for the data items of a data definition.

func (CSTDataItems) Position added in v0.0.2

func (n CSTDataItems) Position() token.Position

Position implements Node.

type CSTDeclare added in v0.0.7

type CSTDeclare struct {
	CSTInstPreamble
}

CSTDeclare is a CST node for the declare instruction.

type CSTDiv added in v0.0.2

type CSTDiv struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTDiv is a CST node for the div instruction.

type CSTDtosi added in v0.0.2

type CSTDtosi struct {
	CSTInstPreamble
	Val Node
}

CSTDtosi is a CST node for the dtosi instruction.

type CSTDtoui added in v0.0.6

type CSTDtoui struct {
	CSTInstPreamble
	Val Node
}

CSTDtoui is a CST node for the dtoui instruction.

type CSTEnvArg added in v0.0.2

type CSTEnvArg struct {
	Env   CSTToken
	Val   Node
	Comma CSTToken
}

CSTEnvArg is a CST node for a environment argument of a call instruction.

| 'env' VAL     # Environment argument (first)

func (*CSTEnvArg) Position added in v0.0.2

func (n *CSTEnvArg) Position() token.Position

Position implements Node.

type CSTEnvParam added in v0.0.2

type CSTEnvParam struct {
	Env   CSTToken
	Local CSTToken
	Comma CSTToken
}

CSTEnvParam is a CST node for the environment parameter of a function definition.

| 'env' %IDENT  # Environment parameter (first)

func (*CSTEnvParam) Position added in v0.0.2

func (n *CSTEnvParam) Position() token.Position

Position implements Node.

type CSTExt added in v0.0.2

type CSTExt struct {
	CSTInstPreamble
	Val Node
}

CSTExt is a CST node for the various ext* instructions.

type CSTField added in v0.0.2

type CSTField struct {
	Type   CSTToken
	Number CSTToken
	Comma  CSTToken
}

CSTField is a CST node for a field of a TypeDef.

func (*CSTField) Position added in v0.0.2

func (n *CSTField) Position() token.Position

Position implements Node.

type CSTFields added in v0.0.2

type CSTFields struct {
	LBrace CSTToken
	Fields []Node
	RBrace CSTToken
}

CSTFields is a CST node for the fields of a TypeDef.

func (*CSTFields) Position added in v0.0.2

func (n *CSTFields) Position() token.Position

Position implements Node.

type CSTFloat32Lit added in v0.0.2

type CSTFloat32Lit CSTToken

CSTFloat32Lit is a CST node for a float32 literal.

func (CSTFloat32Lit) Position added in v0.0.2

func (n CSTFloat32Lit) Position() token.Position

Position implements Node.

type CSTFloat64Lit added in v0.0.2

type CSTFloat64Lit CSTToken

CSTFloat64Lit is a CST node for a float64 literal.

func (CSTFloat64Lit) Position added in v0.0.2

func (n CSTFloat64Lit) Position() token.Position

Position implements Node.

type CSTFuncDef added in v0.0.2

type CSTFuncDef struct {
	Export     CSTToken
	Function   CSTToken
	ABIType    CSTToken
	Global     CSTToken
	LParen     CSTToken
	Params     []Node
	RParen     CSTToken
	LBrace     CSTToken
	Blocks     []*CSTBlock
	RBrace     CSTToken
	Map        map[string]*MapInfo
	Attributes []string
}

CSTFuncDef is a CST node for:

FUNCDEF :=
    ['export'] 'function' [ABITY] $IDENT '(' (PARAM), ')'
    '{'
       BLOCK+
    '}'

func (*CSTFuncDef) Position added in v0.0.2

func (n *CSTFuncDef) Position() token.Position

Position implements Node.

type CSTInstPreamble added in v0.0.2

type CSTInstPreamble struct {
	Dst  CSTToken
	Eq   CSTToken
	Type CSTToken
	Inst CSTToken
}

CSTInstPreamble represents the common part of a 3-address instruction.

func (*CSTInstPreamble) Position added in v0.0.2

func (n *CSTInstPreamble) Position() token.Position

Position implements Node.

type CSTIntConst added in v0.0.2

type CSTIntConst struct {
	Sign   CSTToken
	Number CSTToken
}

CSTIntConst is a CST node for a integer literal with an optional negative sign.

func (*CSTIntConst) Position added in v0.0.2

func (n *CSTIntConst) Position() token.Position

Position implements Node.

type CSTJmp added in v0.0.2

type CSTJmp struct {
	Inst  CSTToken
	Label CSTToken
}

CSTJmp is a CST node for the jmp instruction.

func (*CSTJmp) Position added in v0.0.2

func (n *CSTJmp) Position() token.Position

Position implements Node.

type CSTJnz added in v0.0.2

type CSTJnz struct {
	Inst    CSTToken
	Val     Node
	Comma   CSTToken
	LabelNZ CSTToken
	Comma2  CSTToken
	LabelZ  CSTToken
}

CSTJnz is a CST node for the jnz instruction.

func (*CSTJnz) Position added in v0.0.2

func (n *CSTJnz) Position() token.Position

Position implements Node.

type CSTLdtosi added in v0.0.6

type CSTLdtosi struct {
	CSTInstPreamble
	Val Node
}

CSTLdtosi is a CST node for the ldtosi instruction.

type CSTLdtoui added in v0.0.6

type CSTLdtoui struct {
	CSTInstPreamble
	Val Node
}

CSTLdtoui is a CST node for the ldtoui instruction.

type CSTLoad added in v0.0.2

type CSTLoad struct {
	CSTInstPreamble
	Val Node
}

CSTLoad is a CST node for the various load* instructions.

type CSTLongDoubleLit added in v0.0.6

type CSTLongDoubleLit CSTToken

CSTLongDoubleLit is a CST node for a long double literal.

func (CSTLongDoubleLit) Position added in v0.0.6

func (n CSTLongDoubleLit) Position() token.Position

Position implements Node.

type CSTMul added in v0.0.4

type CSTMul struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTMul is a CST node for the mul instruction.

type CSTOr added in v0.0.2

type CSTOr struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTOr is a CST node for the or instruction.

type CSTPhi added in v0.0.2

type CSTPhi struct {
	CSTInstPreamble
	Args []CSTPhiArg
}

CSTPhi is a CST node for the CSTPhi instruction.

PHI := %IDENT '=' BASETY 'phi' ( @IDENT VAL ),

type CSTPhiArg added in v0.0.2

type CSTPhiArg struct {
	Label CSTToken
	Val   Node
	Comma CSTToken
}

CSTPhiArg is a CST node for an argument of a phi instruction.

type CSTRegularArg added in v0.0.2

type CSTRegularArg struct {
	Type  CSTToken
	Val   Node
	Comma CSTToken
}

CSTRegularArg is a CST node for a regular argument of a call instruction.

ABITY VAL  # Regular argument

func (*CSTRegularArg) Position added in v0.0.2

func (n *CSTRegularArg) Position() token.Position

Position implements Node.

type CSTRegularParam added in v0.0.2

type CSTRegularParam struct {
	Type  CSTToken
	Local CSTToken
	Comma CSTToken
}

CSTRegularParam is a CST node for a regular parameter of a function definition.

ABITY %IDENT  # Regular parameter

func (*CSTRegularParam) Position added in v0.0.2

func (n *CSTRegularParam) Position() token.Position

Position implements Node.

type CSTRem added in v0.0.2

type CSTRem struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTRem is a CST node for the rem instruction.

type CSTRet added in v0.0.2

type CSTRet struct {
	Inst CSTToken
	Val  Node
}

CSTRet is a CST node for the ret instruction with an optional return value.

func (*CSTRet) Position added in v0.0.2

func (n *CSTRet) Position() token.Position

Position implements Node.

type CSTSar added in v0.0.2

type CSTSar struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTSar is a CST node for the sar instruction.

type CSTShl added in v0.0.2

type CSTShl struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTShl is a CST node for the shl instruction.

type CSTShr added in v0.0.2

type CSTShr struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTShr is a CST node for the shr instruction.

type CSTSltof added in v0.0.2

type CSTSltof struct {
	CSTInstPreamble
	Val Node
}

CSTSltof is a CST node for the sltof instruction.

type CSTStore added in v0.0.2

type CSTStore struct {
	Inst  CSTToken
	Dst   Node
	Comma CSTToken
	Src   Node
}

CSTStore is a CST node for the store instruction.

func (*CSTStore) Position added in v0.0.2

func (n *CSTStore) Position() token.Position

Position implements Node.

type CSTStosi added in v0.0.2

type CSTStosi struct {
	CSTInstPreamble
	Val Node
}

CSTStosi is a CST node for the stosi instruction.

type CSTStoui added in v0.0.6

type CSTStoui struct {
	CSTInstPreamble
	Val Node
}

CSTStoui is a CST node for the stoui instruction.

type CSTSub added in v0.0.2

type CSTSub struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTSub is a CST node for the sub instruction.

type CSTSwtof added in v0.0.2

type CSTSwtof struct {
	CSTInstPreamble
	Val Node
}

CSTSwtof is a CST node for the swtof instruction.

type CSTToken added in v0.0.2

type CSTToken struct {
	Ch
	// contains filtered or unexported fields
}

CSTToken is the product of Scanner.Scan and a terminal node of the complete syntax tree.

func (*CSTToken) IsValid added in v0.0.2

func (n *CSTToken) IsValid() bool

IsValid reports the validity of n. Tokens not present in some nodes will report false.

func (*CSTToken) Offset added in v0.0.2

func (n *CSTToken) Offset() int

Offset reports the offset of n, in bytes, within the source buffer.

func (CSTToken) Position added in v0.0.2

func (n CSTToken) Position() (r token.Position)

Position implements Node.

func (*CSTToken) Sep added in v0.0.2

func (n *CSTToken) Sep() []byte

Sep reports the whitespace preceding n, if any. The result is read only.

func (*CSTToken) SepOffset added in v0.0.2

func (n *CSTToken) SepOffset() int

SepOffset reports the offset of n's preceding white space, if any, in bytes, within the source buffer.

func (*CSTToken) Src added in v0.0.2

func (n *CSTToken) Src() []byte

Src reports the original textual form of n. The result is read only.

func (*CSTToken) String added in v0.0.2

func (n *CSTToken) String() string

String pretty formats n.

type CSTTruncd added in v0.0.2

type CSTTruncd struct {
	CSTInstPreamble
	Val Node
}

CSTTruncd is a CST node for the truncd instruction.

type CSTTruncld added in v0.0.6

type CSTTruncld struct {
	CSTInstPreamble
	Val Node
}

CSTTruncld is a CST node for the truncld instruction.

type CSTTypeDef added in v0.0.2

type CSTTypeDef struct {
	Type   CSTToken
	Name   CSTToken
	Eq     CSTToken
	Align  CSTToken
	Number CSTToken
	Fields *CSTFields
}

CSTTypeDef is a CST node for:

TYPEDEF :=
    # Regular type
    'type' :IDENT '=' ['align' NUMBER]
    '{'
        ( SUBTY [NUMBER] ),
    '}'
  | # Opaque type
    'type' :IDENT '=' 'align' NUMBER '{' NUMBER '}'

SUBTY := EXTTY | :IDENT

func (*CSTTypeDef) Position added in v0.0.2

func (n *CSTTypeDef) Position() token.Position

Position implements Node.

type CSTUdiv added in v0.0.2

type CSTUdiv struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTUdiv is a CST node for the udiv instruction.

type CSTUltof added in v0.0.4

type CSTUltof struct {
	CSTInstPreamble
	Val Node
}

CSTUltof is a CST node for the ultof instruction.

type CSTUrem added in v0.0.2

type CSTUrem struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTUrem is a CST node for the urem instruction.

type CSTUwtof added in v0.0.4

type CSTUwtof struct {
	CSTInstPreamble
	Val Node
}

CSTUwtof is a CST node for the uwtof instruction.

type CSTVaArg added in v0.0.2

type CSTVaArg struct {
	CSTInstPreamble
	Val Node
}

CSTVaArg is a CST node for the vaarg instruction.

type CSTVaStart added in v0.0.2

type CSTVaStart struct {
	Inst CSTToken
	Arg  Node
}

CSTVaStart is a CST node for the vastart instruction.

func (*CSTVaStart) Position added in v0.0.2

func (n *CSTVaStart) Position() token.Position

Position implements Node.

type CSTVariadicMarker added in v0.0.2

type CSTVariadicMarker struct {
	Ellipsis CSTToken
	Comma    CSTToken
}

CSTVariadicMarker is a CST node for a variadic argument of a call instruction.

| '...'         # Variadic marker (last)

func (*CSTVariadicMarker) Position added in v0.0.2

func (n *CSTVariadicMarker) Position() token.Position

Position implements Node.

type CSTXor added in v0.0.2

type CSTXor struct {
	CSTInstPreamble
	CSTBinaryOperands
}

CSTXor is a CST node for the xor instruction.

type Call added in v0.0.2

type Call struct {
	InstPreamble
	VoidCall
}

Call represents a call of a non-void function.

func (*Call) Position added in v0.0.2

func (n *Call) Position() token.Position

Position implements Node.

type Cast added in v0.0.2

type Cast struct {
	InstPreamble
	Value Node
}

Cast represents the 'cast' instruction.

type Ceqd added in v0.0.2

type Ceqd struct {
	InstPreamble
	Binary
}

Ceqd represents the 'ceqd' instruction.

type Ceql added in v0.0.2

type Ceql struct {
	InstPreamble
	Binary
}

Ceql represents the 'ceql' instruction.

type Ceqld added in v0.0.6

type Ceqld struct {
	InstPreamble
	Binary
}

Ceqld represents the 'ceqld' instruction.

type Ceqs added in v0.0.2

type Ceqs struct {
	InstPreamble
	Binary
}

Ceqs represents the 'ceqs' instruction.

type Ceqw added in v0.0.2

type Ceqw struct {
	InstPreamble
	Binary
}

Ceqw represents the 'ceqw' instruction.

type Cged added in v0.0.2

type Cged struct {
	InstPreamble
	Binary
}

Cged represents the 'cged' instruction.

type Cgeld added in v0.0.6

type Cgeld struct {
	InstPreamble
	Binary
}

Cgeld represents the 'cgeld' instruction.

type Cges added in v0.0.2

type Cges struct {
	InstPreamble
	Binary
}

Cges represents the 'cges' instruction.

type Cgtd added in v0.0.2

type Cgtd struct {
	InstPreamble
	Binary
}

Cgtd represents the 'cgtd' instruction.

type Cgtld added in v0.0.6

type Cgtld struct {
	InstPreamble
	Binary
}

Cgtld represents the 'cgtld' instruction.

type Cgts added in v0.0.2

type Cgts struct {
	InstPreamble
	Binary
}

Cgts represents the 'cgts' instruction.

type Ch added in v0.0.2

type Ch rune

Ch represents the lexical value of a CSTToken.

const (
	ADD             Ch = iota + 0xe000 // add
	ALIGN                              // align
	ALLOC16                            // alloc16
	ALLOC4                             // alloc4
	ALLOC8                             // alloc8
	AND                                // and
	B                                  // b
	C                                  // c
	CALL                               // call
	CAST                               // cast
	CEQD                               // ceqd
	CEQL                               // ceql
	CEQLD                              // ceqld
	CEQS                               // ceqs
	CEQW                               // ceqw
	CGED                               // cged
	CGELD                              // cgeld
	CGES                               // cges
	CGTD                               // cgtd
	CGTLD                              // cgtld
	CGTS                               // cgts
	CLED                               // cled
	CLELD                              // cleld
	CLES                               // cles
	CLTD                               // cltd
	CLTLD                              // cltld
	CLTS                               // clts
	CNED                               // cned
	CNEL                               // cnel
	CNELD                              // cneld
	CNES                               // cnes
	CNEW                               // cnew
	COD                                // cod
	COPY                               // copy
	COS                                // cos
	CSGEL                              // csgel
	CSGEW                              // csgew
	CSGTL                              // csgtl
	CSGTW                              // csgtw
	CSLEL                              // cslel
	CSLEW                              // cslew
	CSLTL                              // csltl
	CSLTW                              // csltw
	CUGEL                              // cugel
	CUGEW                              // cugew
	CUGTL                              // cugtl
	CUGTW                              // cugtw
	CULEL                              // culel
	CULEW                              // culew
	CULTL                              // cultl
	CULTW                              // cultw
	CUOD                               // cuod
	CUOS                               // cuos
	D                                  // d
	DATA                               // data
	DECLARE                            // declare
	DIV                                // div
	DTOSI                              // dtosi
	DTOUI                              // dtoui
	ELLIPSIS                           // ...
	ENV                                // env
	EXPORT                             // export
	EXTD                               // exts
	EXTS                               // exts
	EXTSB                              // extsb
	EXTSH                              // extsh
	EXTSW                              // extsw
	EXTUB                              // extub
	EXTUH                              // extuh
	EXTUW                              // extuw
	FLOAT32_LIT                        // float32 literal
	FLOAT64_LIT                        // float64 literal
	FUNCTION                           // function
	GLOBAL                             // global name
	H                                  // h
	INT_LIT                            // integer literal
	JMP                                // jmp
	JNZ                                // jnz
	L                                  // l
	LABEL                              // label name
	LD                                 // ld
	LDTOSI                             // ldtosi
	LDTOUI                             // ldtoui
	LOAD                               // load
	LOADD                              // loadd
	LOADL                              // loadl
	LOADLD                             // loadld
	LOADS                              // loads
	LOADSB                             // loadsb
	LOADSH                             // loadsh
	LOADSW                             // loadsw
	LOADUB                             // loadub
	LOADUH                             // loaduh
	LOADUW                             // loaduw
	LOADW                              // loadw
	LOCAL                              // local name
	LONG_DOUBLE_LIT                    // long double literal
	MUL                                // mul
	OR                                 // or
	P                                  // p
	PHI                                // phi
	REM                                // rem
	RET                                // ret
	RO                                 // ro
	S                                  // s
	SAR                                // sar
	SHL                                // shl
	SHR                                // shr
	SLTOF                              // sltof
	STOREB                             // storeb
	STORED                             // stored
	STOREH                             // storeh
	STOREL                             // storel
	STORELD                            // storeld
	STORES                             // stores
	STOREW                             // storew
	STOSI                              // stosi
	STOUI                              // stoui
	STRING_LIT                         // string literal
	SUB                                // sub
	SWTOF                              // swtof
	TRUNCD                             // truncd
	TRUNCLD                            // truncld
	TYPE                               // type
	TYPENAME                           // type name
	UDIV                               // udiv
	ULTOF                              // ultof
	UREM                               // urem
	UWTOF                              // uwtof
	VAARG                              // vaarg
	VASTART                            // vastart
	W                                  // w
	XOR                                // xor
	Z                                  // z
)

Named values of Ch.

func (Ch) String added in v0.0.2

func (i Ch) String() string

type CharPointer added in v0.0.7

type CharPointer struct {
	Type
}

func (CharPointer) String added in v0.0.7

func (t CharPointer) String() string

type Cled added in v0.0.2

type Cled struct {
	InstPreamble
	Binary
}

Cled represents the 'cled' instruction.

type Cleld added in v0.0.6

type Cleld struct {
	InstPreamble
	Binary
}

Cleld represents the 'cleld' instruction.

type Cles added in v0.0.2

type Cles struct {
	InstPreamble
	Binary
}

Cles represents the 'cles' instruction.

type Cltd added in v0.0.2

type Cltd struct {
	InstPreamble
	Binary
}

Cltd represents the 'cltd' instruction.

type Cltld added in v0.0.6

type Cltld struct {
	InstPreamble
	Binary
}

Cltld represents the 'cltld' instruction.

type Clts added in v0.0.2

type Clts struct {
	InstPreamble
	Binary
}

Clts represents the 'clts' instruction.

type Cned added in v0.0.2

type Cned struct {
	InstPreamble
	Binary
}

Cned represents the 'cned' instruction.

type Cnel added in v0.0.2

type Cnel struct {
	InstPreamble
	Binary
}

Cnel represents the 'cnel' instruction.

type Cneld added in v0.0.6

type Cneld struct {
	InstPreamble
	Binary
}

Cneld represents the 'cneld' instruction.

type Cnes added in v0.0.2

type Cnes struct {
	InstPreamble
	Binary
}

Cnes represents the 'cnes' instruction.

type Cnew added in v0.0.2

type Cnew struct {
	InstPreamble
	Binary
}

Cnew represents the 'cnew' instruction.

type Cod added in v0.0.2

type Cod struct {
	InstPreamble
	Binary
}

Cod represents the 'cod' instruction.

type Copy added in v0.0.2

type Copy struct {
	InstPreamble
	Value Node
}

Copy represents the 'copy' instruction.

type Cos added in v0.0.2

type Cos struct {
	InstPreamble
	Binary
}

Cos represents the 'cos' instruction.

type Csgel added in v0.0.2

type Csgel struct {
	InstPreamble
	Binary
}

Csgel represents the 'csgel' instruction.

type Csgew added in v0.0.2

type Csgew struct {
	InstPreamble
	Binary
}

Csgew represents the 'csgew' instruction.

type Csgtl added in v0.0.2

type Csgtl struct {
	InstPreamble
	Binary
}

Csgtl represents the 'csgtl' instruction.

type Csgtw added in v0.0.2

type Csgtw struct {
	InstPreamble
	Binary
}

Csgtw represents the 'csgtw' instruction.

type Cslel added in v0.0.2

type Cslel struct {
	InstPreamble
	Binary
}

Cslel represents the 'cslel' instruction.

type Cslew added in v0.0.2

type Cslew struct {
	InstPreamble
	Binary
}

Cslew represents the 'cslew' instruction.

type Csltl added in v0.0.2

type Csltl struct {
	InstPreamble
	Binary
}

Csltl represents the 'csltl' instruction.

type Csltw added in v0.0.2

type Csltw struct {
	InstPreamble
	Binary
}

Csltw represents the 'csltw' instruction.

type Cugel added in v0.0.2

type Cugel struct {
	InstPreamble
	Binary
}

Cugel represents the 'cugel' instruction.

type Cugew added in v0.0.2

type Cugew struct {
	InstPreamble
	Binary
}

Cugew represents the 'cugew' instruction.

type Cugtl added in v0.0.2

type Cugtl struct {
	InstPreamble
	Binary
}

Cugtl represents the 'cugtl' instruction.

type Cugtw added in v0.0.2

type Cugtw struct {
	InstPreamble
	Binary
}

Cugtw represents the 'cugtw' instruction.

type Culel added in v0.0.2

type Culel struct {
	InstPreamble
	Binary
}

Culel represents the 'culel' instruction.

type Culew added in v0.0.2

type Culew struct {
	InstPreamble
	Binary
}

Culew represents the 'culew' instruction.

type Cultl added in v0.0.2

type Cultl struct {
	InstPreamble
	Binary
}

Cultl represents the 'cultl' instruction.

type Cultw added in v0.0.2

type Cultw struct {
	InstPreamble
	Binary
}

Cultw represents the 'cultw' instruction.

type Cuod added in v0.0.2

type Cuod struct {
	InstPreamble
	Binary
}

Cuod represents the 'cuod' instruction.

type Cuos added in v0.0.2

type Cuos struct {
	InstPreamble
	Binary
}

Cuos represents the 'cuos' instruction.

type DataDef added in v0.0.2

type DataDef struct {
	Align      uintptr // Non zero only if explicitly specified.
	Global             // $name
	Items      []Node
	Size       uintptr // Packed size in bytes.
	Type       Type    // Non-nil iff all items are of the same type.
	Attributes []string

	IsExported bool
	IsReadOnly bool
}

DataDef represents a data definition, static initialized data.

type Declare added in v0.0.7

type Declare struct {
	InstPreamble
}

Declare represents the 'declare' instruction.

type Div added in v0.0.2

type Div struct {
	InstPreamble
	Binary
}

Div represents the 'div' instruction.

type Dtosi added in v0.0.2

type Dtosi struct {
	InstPreamble
	Value Node
}

Dtosi represents the 'dtosi' instruction.

type Dtoui added in v0.0.6

type Dtoui struct {
	InstPreamble
	Value Node
}

Dtoui represents the 'dtoui' instruction.

type EnvArg added in v0.0.2

type EnvArg struct {
	Value Node
}

EnvArg represents the actual environment parameter of a function call.

func (*EnvArg) Position added in v0.0.2

func (n *EnvArg) Position() token.Position

Position implements Node.

type EnvParameter added in v0.0.2

type EnvParameter struct {
	Local
}

EnvParameter represents the environmental formal parameter of a function definition.

type Extd added in v0.0.6

type Extd struct {
	InstPreamble
	Value Node
}

Extd represents the 'extd' instruction.

type Exts added in v0.0.2

type Exts struct {
	InstPreamble
	Value Node
}

Exts represents the 'exts' instruction.

type Extsb added in v0.0.2

type Extsb struct {
	InstPreamble
	Value Node
}

Extsb represents the 'extsb' instruction.

type Extsh added in v0.0.2

type Extsh struct {
	InstPreamble
	Value Node
}

Extsh represents the 'extsh' instruction.

type Extsw added in v0.0.2

type Extsw struct {
	InstPreamble
	Value Node
}

Extsw represents the 'extsw' instruction.

type Extub added in v0.0.2

type Extub struct {
	InstPreamble
	Value Node
}

Extub represents the 'extub' instruction.

type Extuh added in v0.0.2

type Extuh struct {
	InstPreamble
	Value Node
}

Extuh represents the 'extuh' instruction.

type Extuw added in v0.0.2

type Extuw struct {
	InstPreamble
	Value Node
}

Extuw represents the 'extuw' instruction.

type Field

type Field struct {
	Type
	// contains filtered or unexported fields
}

Field represents field type.

func (Field) Position

func (n Field) Position() (r token.Position)

type Float32

type Float32 struct{}

Float32 represents type 's'.

func (Float32) String added in v0.0.4

func (t Float32) String() string

type Float32Initializer added in v0.0.2

type Float32Initializer struct {
	Float32Lit
	Type
}

Float32Initializer is a DataDef item representing a float32 literal.

type Float32Lit added in v0.0.2

type Float32Lit struct {
	Token
}

Float32Lit represents a float32 literal.

func (Float32Lit) Value added in v0.0.2

func (n Float32Lit) Value() float32

Value returns the float32 value represented by n.

type Float64

type Float64 struct{}

Float64 represents type 'd'.

func (Float64) String added in v0.0.4

func (t Float64) String() string

type Float64Initializer added in v0.0.2

type Float64Initializer struct {
	Float64Lit
	Type
}

Float64Initializer is a DataDef item representing a float64 literal.

type Float64Lit added in v0.0.2

type Float64Lit struct {
	Token
}

Float64Lit represents a float64 literal.

func (Float64Lit) Value added in v0.0.2

func (n Float64Lit) Value() float64

Value returns the float64 value represented by n.

type FuncDef added in v0.0.2

type FuncDef struct {
	Blocks     []*Block // In order of appearance in source code. Read only.
	Global              // $name
	Params     []Node
	Result     Type
	Scope      Scope
	Map        map[string]*MapInfo
	Attributes []string

	IsExported bool
	IsVariadic bool
	// contains filtered or unexported fields
}

FuncDef represents a function definition

func (*FuncDef) NewCFG added in v0.0.8

func (n *FuncDef) NewCFG() (r *CFGNode)

NewCFG returns a newly created contro-flow graph of n.

type Global

type Global struct {
	Name
}

Global represents an address of a function or data definition of the form $name.

type GlobalInitializer added in v0.0.2

type GlobalInitializer struct {
	Global // $name
	Offset uintptr
	Type
}

GlobalInitializer is a DataDef item representing the address of a function of data definition, with an optional offset.

type InstPreamble added in v0.0.2

type InstPreamble struct {
	Dst     Local // %name
	DstType Type
}

InstPreamble represents the common part of a 3-address instruction.

func (*InstPreamble) Position added in v0.0.2

func (n *InstPreamble) Position() token.Position

Position implements Node.

type Int16

type Int16 struct{}

Int16 represents type 'h'.

func (Int16) String added in v0.0.4

func (t Int16) String() string

type Int32

type Int32 struct{}

Int32 represents type 'w'.

func (Int32) String added in v0.0.4

func (t Int32) String() string

type Int64

type Int64 struct{}

Int64 represents type 'l'.

func (Int64) String added in v0.0.4

func (Int64) String() string

type Int8

type Int8 struct{}

Int8 represents type 'b'.

func (Int8) String added in v0.0.4

func (t Int8) String() string

type IntInitializer added in v0.0.2

type IntInitializer struct {
	IntLit
	Type
}

IntInitializer is a DataDef item representing an integer literal.

type IntLit added in v0.0.2

type IntLit Token

IntLit represents a integer literal.

func (IntLit) Position added in v0.0.2

func (n IntLit) Position() token.Position

Position implements Node.

func (IntLit) Value added in v0.0.2

func (n IntLit) Value() uint64

Value return the number n stands for.

type Jmp added in v0.0.2

type Jmp Label // @name

Jmp represents the 'jmp' instruction.

func (Jmp) Position added in v0.0.2

func (n Jmp) Position() token.Position

Position implements Node.

type Jnz added in v0.0.2

type Jnz struct {
	Value Node
	NZ    Label // @name
	Z     Label // @name
}

Jnz represents the 'jnz' instruction.

func (Jnz) Position added in v0.0.2

func (n Jnz) Position() token.Position

Position implements Node.

type Label added in v0.0.2

type Label struct {
	Name
}

Label reprents a label name in the form @name.

type Ldtosi added in v0.0.6

type Ldtosi struct {
	InstPreamble
	Value Node
}

Ldtosi represents the 'ldtosi' instruction.

type Ldtoui added in v0.0.6

type Ldtoui struct {
	InstPreamble
	Value Node
}

Ldtoui represents the 'ldtoui' instruction.

type Loadd added in v0.0.2

type Loadd struct {
	InstPreamble
	Value Node
}

Loadd represents the 'loadd' instruction.

type Loadl added in v0.0.2

type Loadl struct {
	InstPreamble
	Value Node
}

Loadl represents the 'loadl' instruction.

type Loadld added in v0.0.6

type Loadld struct {
	InstPreamble
	Value Node
}

Loadld represents the 'loadld' instruction.

type Loads added in v0.0.2

type Loads struct {
	InstPreamble
	Value Node
}

Loads represents the 'loads' instruction.

type Loadsb added in v0.0.2

type Loadsb struct {
	InstPreamble
	Value Node
}

Loadsb represents the 'loadsb' instruction.

type Loadsh added in v0.0.2

type Loadsh struct {
	InstPreamble
	Value Node
}

Loadsh represents the 'loadsh' instruction.

type Loadsw added in v0.0.2

type Loadsw struct {
	InstPreamble
	Value Node
}

Loadsw represents the 'loadsw' and 'loadw' instructions.

type Loadub added in v0.0.2

type Loadub struct {
	InstPreamble
	Value Node
}

Loadub represents the 'loadub' instruction.

type Loaduh added in v0.0.2

type Loaduh struct {
	InstPreamble
	Value Node
}

Loaduh represents the 'loaduh' instruction.

type Loaduw added in v0.0.2

type Loaduw struct {
	InstPreamble
	Value Node
}

Loaduw represents the 'loaduw' instruction.

type Local added in v0.0.2

type Local struct {
	Name
}

Local represents a SSA temporary variable name of the form %name.

type LocalInfo added in v0.0.2

type LocalInfo struct {
	N int // Zero-based local number.
	Name
	Read int // Static number of times the local is used as an operand.
	Type
	Written int // Static number of times the local is defined (assigned to). Parameters start with 1.

	IsParameter bool
	IsStruct    bool
}

LocalInfo desribes properties of a SSA temporary variable.

type LongDouble added in v0.0.6

type LongDouble struct{}

LongDouble represents type 'ld'.

func (LongDouble) String added in v0.0.6

func (t LongDouble) String() string

type LongDoubleLit added in v0.0.6

type LongDoubleLit Token

LongDoubleLit represents a long double literal.

func (LongDoubleLit) Position added in v0.0.6

func (n LongDoubleLit) Position() token.Position

Position implements Node.

func (LongDoubleLit) Value added in v0.0.6

func (n LongDoubleLit) Value() string

Value returns the long double value represented by n.

type LongDoubleLitInitializer added in v0.0.6

type LongDoubleLitInitializer struct {
	LongDoubleLit
	Type
}

LongDoubleLitInitializer is a DataDef item representing a long double literal.

type MapInfo added in v0.0.7

type MapInfo struct {
	To   string
	More string
}

type Mul added in v0.0.2

type Mul struct {
	InstPreamble
	Binary
}

Mul represents the 'mul' instruction.

type Name added in v0.0.2

type Name Token

Name is a Token that represents a name.

func (Name) Name added in v0.0.2

func (n Name) Name() []byte

Name returns the effective name n stands for. The result is read only and it includes the sigil in the first byte of the result. This automatically separates the namespaces of labels, locals, globals and types.

Names other than gloabls ($name) have the effective value the same as is their source form, unchanged.

Global names of the form $"foo" have the effective name `foo`.

func (Name) Position added in v0.0.2

func (n Name) Position() token.Position

Position implements Node.

func (Name) Src added in v0.0.2

func (n Name) Src() []byte

Src reports the original textual form of n. The result is read only.

type Node

type Node interface {
	Position() token.Position
}

Node is an item of a CST/AST tree.

type Or added in v0.0.2

type Or struct {
	InstPreamble
	Binary
}

Or represents the 'or' instruction.

type Phi added in v0.0.2

type Phi struct {
	InstPreamble
	Args []PhiArg
}

Phi represents the 'phi' instruction.

type PhiArg added in v0.0.2

type PhiArg struct {
	Label
	Value Node
}

PhiArg represents an argument of a 'phi' instruction.

type RegularArg added in v0.0.2

type RegularArg struct {
	Type  Type
	Value Node
}

RegularArg represents the actual parameter of a function call.

func (*RegularArg) Position added in v0.0.2

func (n *RegularArg) Position() token.Position

Position implements Node.

type RegularParameter added in v0.0.2

type RegularParameter struct {
	Local // %name
	Type
}

RegularParameter represents a regular formal parameter of a function definition.

type Rem added in v0.0.2

type Rem struct {
	InstPreamble
	Binary
}

Rem represents the 'rem' instruction.

type Ret added in v0.0.2

type Ret struct {
	Value Node
	// contains filtered or unexported fields
}

Ret represent the 'ret' instruction.

func (Ret) Position added in v0.0.2

func (n Ret) Position() (r token.Position)

type Sar added in v0.0.2

type Sar struct {
	InstPreamble
	Binary
}

Sar represents the 'sar' instruction.

type Scanner added in v0.0.2

type Scanner struct {

	// Tok is the current CST token. It is valid after first call to Scan. The
	// value is read only.
	Tok CSTToken
	// contains filtered or unexported fields
}

Scanner provides lexical analysis of its buffer.

func NewScanner added in v0.0.2

func NewScanner(buf []byte, name string, allErrros bool) (*Scanner, error)

NewScanner returns a newly created scanner that will tokenize buf. Positions are reported as if buf is coming from a file named name. The buffer becomes owned by the scanner and must not be modified after calling NewScanner.

The scanner normally stops scanning after some number of errors. Passing allErrros == true overides that.

func (*Scanner) Err added in v0.0.2

func (s *Scanner) Err() error

Err reports any errors the scanner encountered. For typical use please see the .Scan() documentation.

func (*Scanner) Scan added in v0.0.2

func (s *Scanner) Scan() (r bool)

Scan moves to the next token and returns true if not at end of file. Usage example:

s, _ = NewScanner(buf, name, false)
for s.Scan() {
	...
}
if err := s.Err() {
	...
}

type Scope added in v0.0.2

type Scope struct {
	Nodes map[string]Node
}

Scope maps names to Nodes.

type Shl added in v0.0.2

type Shl struct {
	InstPreamble
	Binary
}

Shl represents the 'shl' instruction.

type Shr added in v0.0.2

type Shr struct {
	InstPreamble
	Binary
}

Shr represents the 'shr' instruction.

type Sltof added in v0.0.2

type Sltof struct {
	InstPreamble
	Value Node
}

Sltof represents the 'sltof' instruction.

type Storeb added in v0.0.2

type Storeb struct {
	Dst Node
	Src Node
}

Storeb represents the 'storeB' instruction.

func (*Storeb) Position added in v0.0.2

func (n *Storeb) Position() token.Position

Position implements Node.

type Stored added in v0.0.2

type Stored struct {
	Dst Node
	Src Node
}

Stored represents the 'stored' instruction.

func (*Stored) Position added in v0.0.2

func (n *Stored) Position() token.Position

Position implements Node.

type Storeh added in v0.0.2

type Storeh struct {
	Dst Node
	Src Node
}

Storeh represents the 'storeh' instruction.

func (*Storeh) Position added in v0.0.2

func (n *Storeh) Position() token.Position

Position implements Node.

type Storel added in v0.0.2

type Storel struct {
	Dst Node
	Src Node
}

Storel represents the 'storel' instruction.

func (*Storel) Position added in v0.0.2

func (n *Storel) Position() token.Position

Position implements Node.

type Storeld added in v0.0.6

type Storeld struct {
	Dst Node
	Src Node
}

Storeld represents the 'storeld' instruction.

func (*Storeld) Position added in v0.0.6

func (n *Storeld) Position() token.Position

Position implements Node.

type Stores added in v0.0.2

type Stores struct {
	Dst Node
	Src Node
}

Stores represents the 'stores' instruction.

func (*Stores) Position added in v0.0.2

func (n *Stores) Position() token.Position

Position implements Node.

type Storew added in v0.0.2

type Storew struct {
	Dst Node
	Src Node
}

Storew represents the 'storew' instruction.

func (*Storew) Position added in v0.0.2

func (n *Storew) Position() token.Position

Position implements Node.

type Stosi added in v0.0.2

type Stosi struct {
	InstPreamble
	Value Node
}

Stosi represents the 'stosi' instruction.

type Stoui added in v0.0.6

type Stoui struct {
	InstPreamble
	Value Node
}

Stoui represents the 'stoui' instruction.

type StringInitializer added in v0.0.2

type StringInitializer struct {
	StringLit
	Type Type
}

StringInitializer is a DataDef item representing a string literal.

type StringLit added in v0.0.2

type StringLit Token

StringLit represents a string literal.

func (StringLit) Position added in v0.0.2

func (n StringLit) Position() token.Position

Position implements Node.

func (StringLit) Value added in v0.0.2

func (n StringLit) Value() []byte

Value returns the unquoted value of n.

type StructField added in v0.0.2

type StructField struct {
	Fields []Node
	// contains filtered or unexported fields
}

StructField represents a struct-shaped field.

func (StructField) Position added in v0.0.2

func (n StructField) Position() (r token.Position)

type Sub added in v0.0.2

type Sub struct {
	InstPreamble
	Binary
}

Sub represents the 'sub' instruction.

type Swtof added in v0.0.2

type Swtof struct {
	InstPreamble
	Value Node
}

Swtof represents the 'swtof' instruction.

type Task added in v0.0.2

type Task struct {
	O string // -O argument. Read only.
	// contains filtered or unexported fields
}

Task represents a compilation job.

func NewTask added in v0.0.2

func NewTask(name string, args []string, stdout, stderr io.Writer) *Task

NewTask returns a newly created Task.

func (*Task) Main added in v0.0.2

func (t *Task) Main() (err error)

Main executes task.

type Token

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

Token is a terminal node of the abstract syntax tree.

func (Token) Position

func (n Token) Position() (r token.Position)

Position implements Node.

func (Token) Src

func (n Token) Src() []byte

Src reports the original textual form of n. The result is read only.

type Truncd added in v0.0.2

type Truncd struct {
	InstPreamble
	Value Node
}

Truncd represents the 'truncd' instruction.

type Truncld added in v0.0.6

type Truncld struct {
	InstPreamble
	Value Node
}

Truncld represents the 'truncld' instruction.

type Type added in v0.0.2

type Type interface {
	String() string
	// contains filtered or unexported methods
}

Type represents a QBE type.

type TypeDef added in v0.0.2

type TypeDef struct {
	Align    uintptr // Non zero only if explicitly specified.
	Fields   []Node
	TypeName // :name
}

TypeDef represents a named type.

type TypeName added in v0.0.2

type TypeName struct {
	Name
}

TypeName represents a named type of the form :name.

func (TypeName) String added in v0.0.4

func (t TypeName) String() string

type Udiv added in v0.0.2

type Udiv struct {
	InstPreamble
	Binary
}

Udiv represents the 'udiv' instruction.

type Ultof added in v0.0.4

type Ultof struct {
	InstPreamble
	Value Node
}

Ultof represents the 'ultof' instruction.

type UnionField added in v0.0.2

type UnionField IntLit

UnionField represents an opaque data type.

func (UnionField) Position added in v0.0.2

func (n UnionField) Position() token.Position

Position implements Node.

func (UnionField) Size added in v0.0.2

func (n UnionField) Size() uintptr

Size returns the declared size of n in bytes.

type Urem added in v0.0.2

type Urem struct {
	InstPreamble
	Binary
}

Urem represents the 'urem' instruction.

type Uwtof added in v0.0.4

type Uwtof struct {
	InstPreamble
	Value Node
}

Uwtof represents the 'uwtof' instruction.

type VaArg added in v0.0.2

type VaArg struct {
	InstPreamble
	Value Node
}

VaArg represents the 'vaarg' instruction.

type VaInfo added in v0.0.7

type VaInfo struct {
	Size     int // sizeof va
	ElemSize int // sizeof *va or 0 if N/A

	// IsStructArray reports whether va_list if defined as, for example
	//
	//	typedef struct {
	//		unsigned int gp_offset;
	//		unsigned int fp_offset;
	//		void *overflow_arg_area;
	//		void *reg_save_area;
	//	} __builtin_va_list[1];
	IsStructArray bool
	// IsPointer reports whether va_list if defined as, for example
	//
	//	typedef char *__builtin_va_list;
	IsPointer bool
	// IsStruct reports whether va_list if defined as, for example
	//
	//	typedef struct {
	//		void *__ap;
	//	} __builtin_va_list;
	IsStruct bool
}

VaInfo describes a va_list

func VaInfoFor added in v0.0.7

func VaInfoFor(os, arch string) (*VaInfo, error)

VaInfoFor returns a VaInfo for os/arch or an error, if any.

type VaStart added in v0.0.2

type VaStart struct {
	Value Node
	// contains filtered or unexported fields
}

VaStart represents the 'vastart' instruction.

func (VaStart) Position added in v0.0.2

func (n VaStart) Position() token.Position

Position implements Node.

type VoidCall added in v0.0.2

type VoidCall struct {
	Value Node
	Args  []Node

	IsVariadic bool
}

VoidCall represents a call of a void function.

func (*VoidCall) Position added in v0.0.2

func (n *VoidCall) Position() token.Position

Position implements Node.

type VoidPointer added in v0.0.7

type VoidPointer struct {
	Type
}

func (VoidPointer) String added in v0.0.7

func (t VoidPointer) String() string

type Xor added in v0.0.2

type Xor struct {
	InstPreamble
	Binary
}

Xor represents the 'xor' instruction.

type ZeroInitializer added in v0.0.2

type ZeroInitializer IntLit

ZeroInitializer is a DataDef item representing zeroed data.

func (ZeroInitializer) Position added in v0.0.2

func (n ZeroInitializer) Position() token.Position

Position implements Node.

func (ZeroInitializer) Size added in v0.0.2

func (n ZeroInitializer) Size() uintptr

Size returns the declared size of n in bytes.

Directories

Path Synopsis
Command qbec is a compiler for the QBE intermediate language
Command qbec is a compiler for the QBE intermediate language

Jump to

Keyboard shortcuts

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