inst

package
v0.0.0-...-61c2bae Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package inst is the avo instruction database.

Index

Constants

This section is empty.

Variables

View Source
var Instructions = []Instruction{}/* 1308 elements not displayed */

Functions

func ISACombinations

func ISACombinations(is []Instruction) [][]string

ISACombinations returns all the unique combinations of ISAs seen in the given instructions.

func ISAs

func ISAs(is []Instruction) []string

ISAs returns all the unique ISAs seen in the given instructions.

func ImplicitRegisters

func ImplicitRegisters(is []Instruction) []string

ImplicitRegisters returns all the registers that appear as implicit operands in the provided instructions.

func OperandTypes

func OperandTypes(is []Instruction) []string

OperandTypes returns all the operand types that appear in the provided instructions.

func SuffixesClasses

func SuffixesClasses(is []Instruction) map[string][]Suffixes

SuffixesClasses returns all possible classes of suffix combinations.

Types

type Action

type Action uint8

Action specifies the read/write operation of an instruction on an operand.

const (
	R Action = 1 << iota // Read
	W                    // Write

	RW Action = R | W // Read-Write
)

Possible Action types.

func ActionFromReadWrite

func ActionFromReadWrite(r, w bool) Action

ActionFromReadWrite builds an Action from boolean flags.

func (Action) ContainsAll

func (a Action) ContainsAll(s Action) bool

ContainsAll reports whether a supports all actions in s.

func (Action) ContainsAny

func (a Action) ContainsAny(s Action) bool

ContainsAny reports whether a supports any actions in s.

func (Action) Read

func (a Action) Read() bool

Read reports whether a supports read.

func (Action) String

func (a Action) String() string

String represents a as a human-readable string.

func (Action) Write

func (a Action) Write() bool

Write reports whether a supports write.

type EncodingType

type EncodingType uint8

EncodingType specifies a category of encoding types.

const (
	EncodingTypeLegacy EncodingType = 1 + iota
	EncodingTypeREX
	EncodingTypeVEX
	EncodingTypeEVEX
)

Supported encoding types.

type Form

type Form struct {
	// Instruction sets this instruction form requires.
	ISA []string

	// Operands required for this form.
	Operands []Operand

	// Registers read or written but not explicitly passed to the instruction.
	ImplicitOperands []ImplicitOperand

	// Encoding type required for this instruction form.
	EncodingType EncodingType

	// CancellingInputs indicates this instruction form has no dependency on the
	// input operands when they refer to the same register. The classic example of
	// this is "XORQ RAX, RAX", in which case the output has no dependence on the
	// value of RAX. Instruction forms with cancelling inputs have only two input
	// operands, which have the same register type.
	CancellingInputs bool

	// Zeroing indicates whether the instruction form uses AVX-512 zeroing. This
	// is the .Z suffix in Go, usually indicated with {z} operand suffix in
	// Intel manuals.
	Zeroing bool

	// EmbeddedRounding indicates whether the instruction form uses AVX-512
	// embedded rounding. This is the RN_SAE, RZ_SAE, RD_SAE and RU_SAE suffixes
	// in Go, usually indicated with {er} in Intel manuals.
	EmbeddedRounding bool

	// SuppressAllExceptions indicates whether the instruction form uses AVX-512
	// "suppress all exceptions". This is the SAE suffix in Go, usually
	// indicated with {sae} in Intel manuals.
	SuppressAllExceptions bool

	// Broadcast indicates whether the instruction form uses AVX-512
	// broadcast. This is the BCST suffix in Go, usually indicated by operand
	// types like "m64bcst" in Intel manuals.
	Broadcast bool
}

Form specifies one accepted set of operands for an instruction.

func (Form) AcceptsSuffixes

func (f Form) AcceptsSuffixes() bool

AcceptsSuffixes reports whether this form takes any opcode suffixes.

func (Form) Arity

func (f Form) Arity() int

Arity returns the number of operands this form expects.

func (Form) Clone

func (f Form) Clone() Form

Clone the instruction form.

func (Form) Signature

func (f Form) Signature() []string

Signature returns the list of operand types.

func (Form) SuffixesClass

func (f Form) SuffixesClass() string

SuffixesClass returns a key representing the class of instruction suffixes it accepts. All instructions sharing a suffix class accept the same suffixes.

func (Form) SupportedSuffixes

func (f Form) SupportedSuffixes() []Suffixes

SupportedSuffixes returns the list of all possible suffix combinations supported by this instruction form.

type Forms

type Forms []Form

Forms is a collection of instruction forms.

func (Forms) Arities

func (fs Forms) Arities() []int

Arities returns the unique arities among the instruction forms.

func (Forms) Arity

func (fs Forms) Arity() int

Arity is a convenience for returning the unique instruction arity when you know it is not variadic. Panics for a variadic instruction.

func (Forms) Clone

func (fs Forms) Clone() Forms

Clone the instruction forms.

func (Forms) IsNiladic

func (fs Forms) IsNiladic() bool

IsNiladic reports whether the instruction takes no operands.

func (Forms) IsVariadic

func (fs Forms) IsVariadic() bool

IsVariadic reports whether the instruction has more than one arity.

type ImplicitOperand

type ImplicitOperand struct {
	Register string
	Action   Action
}

ImplicitOperand describes a register that is implicitly read/written by an instruction.

type Instruction

type Instruction struct {
	Opcode  string // Golang assembly mnemonic
	AliasOf string // Opcode of instruction that this is an alias for
	Summary string // Description of the instruction
	Forms          // Accepted operand forms
}

Instruction represents an x86 instruction.

func Lookup

func Lookup(opcode string) (Instruction, bool)

Lookup returns the instruction with the given opcode. Boolean return value indicates whether the instruction was found.

func (Instruction) Clone

func (i Instruction) Clone() Instruction

Clone the instruction.

func (Instruction) IsBranch

func (i Instruction) IsBranch() bool

IsBranch reports whether the instruction is a branch; that is, if it can cause control flow to jump to another location.

func (Instruction) IsConditionalBranch

func (i Instruction) IsConditionalBranch() bool

IsConditionalBranch reports whether the instruction branches dependent on some condition.

func (Instruction) IsTerminal

func (i Instruction) IsTerminal() bool

IsTerminal reports whether the instruction exits a function.

type Operand

type Operand struct {
	Type   string
	Action Action
}

Operand is an operand to an instruction, describing the expected type and read/write action.

type Suffix

type Suffix string

Suffix is an opcode suffix.

const (
	BCST   Suffix = "BCST"
	RN_SAE Suffix = "RN_SAE"
	RZ_SAE Suffix = "RZ_SAE"
	RD_SAE Suffix = "RD_SAE"
	RU_SAE Suffix = "RU_SAE"
	SAE    Suffix = "SAE"
	Z      Suffix = "Z"
)

Supported opcode suffixes in x86 assembly.

func UniqueSuffixes

func UniqueSuffixes(is []Instruction) []Suffix

UniqueSuffixes returns all the non-empty suffixes that appear in the provided instructions.

func (Suffix) String

func (s Suffix) String() string

func (Suffix) Summary

func (s Suffix) Summary() string

Summary of the opcode suffix, for documentation purposes.

type Suffixes

type Suffixes []Suffix

Suffixes is a list of opcode suffixes.

func (Suffixes) Join

func (s Suffixes) Join(sep string) string

Join suffixes with the given separator.

func (Suffixes) String

func (s Suffixes) String() string

String returns the dot-separated suffixes.

func (Suffixes) Strings

func (s Suffixes) Strings() []string

Strings returns the suffixes as strings.

func (Suffixes) Summaries

func (s Suffixes) Summaries() []string

Summaries returns all the suffix summaries.

Jump to

Keyboard shortcuts

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