ir

package
v0.0.0-...-0b552ba Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: MIT Imports: 5 Imported by: 0

README

IR

IR is a representation of high level code.

Currently 3 types exist: Temporaries, Primitives and Complex

Temporaries

Temporaries (T) are variables used to store data read, to apply logical operations and to write data.

Primitives

The simplest IR instructins are primitives. A primitive (P) is a read, a write operation or a logical operation on a temporary. Example: read32((void *)0x500) shown as P:read32 write8((void *)0xdeadbeef, 0) shown as P:write8

Complex

Everything not a primitive is called complex (C). Complex have a higher rank and can overwrite IR instructions with a lower rank. Complex contain a list of primitives.

Read-Modify-Write (RMW):

  • Scans for P:readX, P:writeX
  • Replaces P:readX, p:writeX
  • Needs to gather the & and | mask by running additional test

Branch on bit set (BBS):

  • Scans for branch after P:readX
  • Replaceds P:readX
  • Needs to gather the bit set by running additional test
  • Adds a condition to the AST

Branch on bit clear (BBC):

  • Scans for branch after P:readX
  • Replaceds P:readX
  • Needs to gather the bit cleared by running additional test
  • Adds a condition to the AST

Branch on masked integer (BMI):

  • Scans for branch after P:readX
  • Replaceds P:readX
  • Needs to gather the mask and integer by running additional test
  • Adds a condition to the AST

Simple loop detection counter (SLDC):

  • Scans for duplicated primitives
  • Replaces primitives
  • Includes a counter

Simple loop detection bit set (SLDBS):

  • Scans for duplicated primitives
  • The primitives contain a P:readX
  • Replaces primitives
  • Checks for bit set

Simple loop detection bit clear (SLDBC):

  • Scans for duplicated primitives
  • The primitives contain a P:readX
  • Replaces primitives
  • Checks for bit clear

Conversion from tracelog

The tracelog contains tracelog entries. A tracelog entry can only be converted to a primitive.

The IR AST is generated from all existing tracelogs.

Then the IR AST plugins are run and scan the AST for possible "optimizations". The lower rank plugins are run first, then the higher ones.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoopToIR

func LoopToIR(ident int, start *mesh.MeshNode, end *mesh.MeshNode) string

func MeshToIR

func MeshToIR(m *mesh.Mesh) string

func PrimitiveToIR

func PrimitiveToIR(n *mesh.MeshNode) string

Types

type CRMW

type CRMW struct {
	Type PrimtiveType
	// The address that was accessed
	Address uint
	// The OrMask to set bits
	OrMask uint64
	// The AndMask to clear bits
	AndMask uint64
	// 8, 16, 32, 64 bit
	AccessSize uint
}

func (CRMW) ConvertToC

func (c CRMW) ConvertToC() string

func (CRMW) GetRank

func (c CRMW) GetRank() uint

func (CRMW) GetType

func (c CRMW) GetType() IRType

type IRMeta

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

type IRType

type IRType int
const (
	PrimitiveRead IRType = iota
	PrimitiveWrite
	ComplexReadModifyWrite
)

type PRead

type PRead struct {
	// Meta information
	Meta IRMeta
	// The primitive type (TraceLogEntry Type)
	Type PrimtiveType
	// The address that was accessed
	Address uint
	// The value read/written
	Value uint64
	// 8, 16, 32, 64 bit
	AccessSize uint
}

func IRNewPrimitiveRead

func IRNewPrimitiveRead(e tracelog.TraceLogEntry) PRead

func (PRead) ConvertToC

func (p PRead) ConvertToC() string

func (PRead) GetRank

func (p PRead) GetRank() uint

func (PRead) GetType

func (p PRead) GetType() IRType

type PWrite

type PWrite struct {
	// Meta information
	Meta IRMeta
	// The primitive type (TraceLogEntry Type)
	Type PrimtiveType
	// The address that was accessed
	Address uint
	// The value read/written
	Value uint64
	// 8, 16, 32, 64 bit
	AccessSize uint
}

func IRNewPrimitiveWrite

func IRNewPrimitiveWrite(e tracelog.TraceLogEntry) PWrite

func (PWrite) ConvertToC

func (p PWrite) ConvertToC() string

func (PWrite) GetRank

func (p PWrite) GetRank() uint

func (PWrite) GetType

func (p PWrite) GetType() IRType

type PrimtiveType

type PrimtiveType int
const (
	MEM32 PrimtiveType = iota
	IO
	MSR
	CPUID
	PCI
)

Jump to

Keyboard shortcuts

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