Documentation ¶
Index ¶
- Variables
- func IREXpression_length(expr IRExpression, ctx *IR_Context, target lib.Operand) (int, error)
- func IR_Length(stmt IR, ctx *IR_Context) (int, error)
- func IsFloat(b Type) bool
- func IsInteger(b Type) bool
- func IsLiteral(e IRExpression) bool
- func IsLiteralOrVariable(e IRExpression) bool
- func IsNumber(b Type) bool
- func IsSignedInteger(b Type) bool
- func IsVariable(e IRExpression) bool
- type ABI
- type Allocator
- type Architecture
- type BaseIR
- type BaseIRExpression
- type BaseType
- type IR
- type IRExpression
- type IRExpressionType
- type IRType
- type IR_Context
- func (i *IR_Context) AddInstruction(instr ...lib.Instruction)
- func (i *IR_Context) AllocateRegister(typ Type) lib.Operand
- func (i *IR_Context) Copy() *IR_Context
- func (i *IR_Context) DeallocateRegister(reg lib.Operand)
- func (i *IR_Context) GetInstructions() []lib.Instruction
- func (i *IR_Context) PeekReturn() lib.Operand
- func (i *IR_Context) PopReturn() lib.Operand
- func (i *IR_Context) PushReturnOperand(op lib.Operand)
- type SSA_Context
- type SSA_Rewrite
- type SSA_Rewrites
- type Segment
- type SegmentPointer
- type SegmentType
- type Segments
- type TArray
- type TFunction
- type TStruct
- type Type
- type TypeNr
Constants ¶
This section is empty.
Variables ¶
View Source
var ( TUint8 = &BaseType{T_Uint8} TUint16 = &BaseType{T_Uint16} TUint32 = &BaseType{T_Uint32} TUint64 = &BaseType{T_Uint64} TInt8 = &BaseType{T_Int8} TInt16 = &BaseType{T_Int16} TInt32 = &BaseType{T_Int32} TInt64 = &BaseType{T_Int64} TFloat64 = &BaseType{T_Float64} TBool = &BaseType{T_Bool} )
Functions ¶
func IREXpression_length ¶
func IREXpression_length(expr IRExpression, ctx *IR_Context, target lib.Operand) (int, error)
func IsLiteral ¶
func IsLiteral(e IRExpression) bool
func IsLiteralOrVariable ¶
func IsLiteralOrVariable(e IRExpression) bool
func IsSignedInteger ¶
func IsVariable ¶
func IsVariable(e IRExpression) bool
Types ¶
type ABI ¶
type ABI interface { GetRegistersForArgs(args []Type) []*encoding.Register ReturnTypeToOperand(ty Type) lib.Operand }
TODO: should only contain call setup and teardown; this makes no sense.
type Architecture ¶
type Architecture interface { EncodeExpression(expr IRExpression, ctx *IR_Context, target lib.Operand) ([]lib.Instruction, error) EncodeStatement(stmt IR, ctx *IR_Context) ([]lib.Instruction, error) EncodeDataSection(stmts []IR, ctx *IR_Context) (*Segments, error) GetAllocator() Allocator }
type BaseIR ¶
type BaseIR struct {
// contains filtered or unexported fields
}
func (*BaseIR) AddToDataSection ¶
func (b *BaseIR) AddToDataSection(ctx *IR_Context) error
type BaseIRExpression ¶
type BaseIRExpression struct {
// contains filtered or unexported fields
}
func NewBaseIRExpression ¶
func NewBaseIRExpression(typ IRExpressionType) *BaseIRExpression
func (*BaseIRExpression) AddToDataSection ¶
func (b *BaseIRExpression) AddToDataSection(ctx *IR_Context) error
func (*BaseIRExpression) Type ¶
func (b *BaseIRExpression) Type() IRExpressionType
type IR ¶
type IR interface { Type() IRType String() string AddToDataSection(ctx *IR_Context) error SSA_Transform(*SSA_Context) IR }
type IRExpression ¶
type IRExpression interface { Type() IRExpressionType ReturnType(ctx *IR_Context) Type AddToDataSection(ctx *IR_Context) error String() string SSA_Transform(*SSA_Context) (SSA_Rewrites, IRExpression) }
type IRExpressionType ¶
type IRExpressionType int
const ( Uint8 IRExpressionType = iota Uint16 IRExpressionType = iota Uint32 IRExpressionType = iota Uint64 IRExpressionType = iota Int8 IRExpressionType = iota Int16 IRExpressionType = iota Int32 IRExpressionType = iota Int64 IRExpressionType = iota Float64 IRExpressionType = iota ByteArray IRExpressionType = iota StaticArray IRExpressionType = iota ArrayIndex IRExpressionType = iota Bool IRExpressionType = iota Struct IRExpressionType = iota StructField IRExpressionType = iota And IRExpressionType = iota Or IRExpressionType = iota Not IRExpressionType = iota Add IRExpressionType = iota Sub IRExpressionType = iota Mul IRExpressionType = iota Div IRExpressionType = iota Variable IRExpressionType = iota Equals IRExpressionType = iota LT IRExpressionType = iota LTE IRExpressionType = iota GT IRExpressionType = iota GTE IRExpressionType = iota Syscall IRExpressionType = iota Cast IRExpressionType = iota Function IRExpressionType = iota Call IRExpressionType = iota )
func (IRExpressionType) String ¶
func (i IRExpressionType) String() string
type IR_Context ¶
type IR_Context struct { Architecture Architecture ABI ABI Allocator Allocator VariableMap map[string]lib.Operand VariableTypes map[string]Type ReturnOperandStack []lib.Operand Segments *Segments InstructionPointer uint StackPointer int Commit bool // if false turns AddInstruction into a noop // contains filtered or unexported fields }
func NewIRContext ¶
func NewIRContext(arch Architecture, abi ABI) *IR_Context
func (*IR_Context) AddInstruction ¶
func (i *IR_Context) AddInstruction(instr ...lib.Instruction)
func (*IR_Context) AllocateRegister ¶
func (i *IR_Context) AllocateRegister(typ Type) lib.Operand
func (*IR_Context) Copy ¶
func (i *IR_Context) Copy() *IR_Context
func (*IR_Context) DeallocateRegister ¶
func (i *IR_Context) DeallocateRegister(reg lib.Operand)
func (*IR_Context) GetInstructions ¶
func (i *IR_Context) GetInstructions() []lib.Instruction
func (*IR_Context) PeekReturn ¶
func (i *IR_Context) PeekReturn() lib.Operand
func (*IR_Context) PopReturn ¶
func (i *IR_Context) PopReturn() lib.Operand
func (*IR_Context) PushReturnOperand ¶
func (i *IR_Context) PushReturnOperand(op lib.Operand)
type SSA_Context ¶
type SSA_Context struct {
// contains filtered or unexported fields
}
func NewSSA_Context ¶
func NewSSA_Context() *SSA_Context
func (*SSA_Context) GenerateVariable ¶
func (s *SSA_Context) GenerateVariable() string
type SSA_Rewrite ¶
type SSA_Rewrite struct { Variable string Expr IRExpression }
func NewSSA_Rewrite ¶
func NewSSA_Rewrite(v string, e IRExpression) SSA_Rewrite
type SSA_Rewrites ¶
type SSA_Rewrites []SSA_Rewrite
type SegmentPointer ¶
type SegmentPointer struct { SegmentType Offset uint }
type SegmentType ¶
type SegmentType uint8
const ( ReadOnly SegmentType = 1 ReadWrite SegmentType = 2 Executable SegmentType = 3 )
type Segments ¶
type Segments struct {
Segments map[SegmentType]*Segment
}
func NewSegments ¶
func NewSegments() *Segments
func (*Segments) Add ¶
func (s *Segments) Add(ty SegmentType, data ...uint8) *SegmentPointer
func (*Segments) GetAddress ¶
func (s *Segments) GetAddress(p *SegmentPointer) int
type TypeNr ¶
type TypeNr int
const ( T_Uint8 TypeNr = iota T_Uint16 TypeNr = iota T_Uint32 TypeNr = iota T_Uint64 TypeNr = iota T_Int8 TypeNr = iota T_Int16 TypeNr = iota T_Int32 TypeNr = iota T_Int64 TypeNr = iota T_Float64 TypeNr = iota T_Bool TypeNr = iota T_Array TypeNr = iota T_Function TypeNr = iota T_Struct TypeNr = iota )
Click to show internal directories.
Click to hide internal directories.