operand

package
v0.0.0-...-81a76c0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: BSD-3-Clause Imports: 2 Imported by: 1

Documentation

Overview

Package operand provides types for instruction operands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Is1

func Is1(op Op) bool

Is1 returns true if op is the immediate constant 1.

func Is3

func Is3(op Op) bool

Is3 returns true if op is the immediate constant 3.

func IsAL

func IsAL(op Op) bool

IsAL returns true if op is the AL register.

func IsAX

func IsAX(op Op) bool

IsAX returns true if op is the 16-bit AX register.

func IsCL

func IsCL(op Op) bool

IsCL returns true if op is the CL register.

func IsEAX

func IsEAX(op Op) bool

IsEAX returns true if op is the 32-bit EAX register.

func IsGP

func IsGP(op Op, n uint) bool

IsGP returns true if op is a general-purpose register of size n bytes.

func IsIMM16

func IsIMM16(op Op) bool

IsIMM16 returns true is op is a 16-bit immediate.

func IsIMM2U

func IsIMM2U(op Op) bool

IsIMM2U returns true if op is a 2-bit unsigned immediate (less than 4).

func IsIMM32

func IsIMM32(op Op) bool

IsIMM32 returns true is op is a 32-bit immediate.

func IsIMM64

func IsIMM64(op Op) bool

IsIMM64 returns true is op is a 64-bit immediate.

func IsIMM8

func IsIMM8(op Op) bool

IsIMM8 returns true is op is an 8-bit immediate.

func IsK

func IsK(op Op) bool

IsK returns true if op is an Opmask register.

func IsM

func IsM(op Op) bool

IsM returns true if op is a 16-, 32- or 64-bit memory operand.

func IsM128

func IsM128(op Op) bool

IsM128 returns true if op is a 128-bit memory operand.

func IsM16

func IsM16(op Op) bool

IsM16 returns true if op is a 16-bit memory operand.

func IsM256

func IsM256(op Op) bool

IsM256 returns true if op is a 256-bit memory operand.

func IsM32

func IsM32(op Op) bool

IsM32 returns true if op is a 16-bit memory operand.

func IsM512

func IsM512(op Op) bool

IsM512 returns true if op is a 512-bit memory operand.

func IsM64

func IsM64(op Op) bool

IsM64 returns true if op is a 64-bit memory operand.

func IsM8

func IsM8(op Op) bool

IsM8 returns true if op is an 8-bit memory operand.

func IsMReg

func IsMReg(op Op) bool

IsMReg returns true if op is a register that can be used in a memory operand.

func IsMSize

func IsMSize(op Op, n uint) bool

IsMSize returns true if op is a memory operand using general-purpose address registers of the given size in bytes.

func IsMem

func IsMem(op Op) bool

IsMem returns whether op has type Mem.

func IsPseudo

func IsPseudo(op Op) bool

IsPseudo returns true if op is a pseudo register.

func IsR16

func IsR16(op Op) bool

IsR16 returns true if op is a 16-bit general-purpose register.

func IsR32

func IsR32(op Op) bool

IsR32 returns true if op is a 32-bit general-purpose register.

func IsR64

func IsR64(op Op) bool

IsR64 returns true if op is a 64-bit general-purpose register.

func IsR8

func IsR8(op Op) bool

IsR8 returns true if op is an 8-bit general-purpose register.

func IsRAX

func IsRAX(op Op) bool

IsRAX returns true if op is the 64-bit RAX register.

func IsREL32

func IsREL32(op Op) bool

IsREL32 returns true if op is an offset relative to instruction pointer, or a label reference.

func IsREL8

func IsREL8(op Op) bool

IsREL8 returns true if op is an 8-bit offset relative to instruction pointer.

func IsRegister

func IsRegister(op Op) bool

IsRegister returns whether op has type reg.Register.

func IsRegisterKind

func IsRegisterKind(op Op, k reg.Kind) bool

IsRegisterKind returns true if op is a register of the given kind.

func IsRegisterKindSize

func IsRegisterKindSize(op Op, k reg.Kind, n uint) bool

IsRegisterKindSize returns true if op is a register of the given kind and size in bytes.

func IsRel

func IsRel(op Op) bool

IsRel returns whether op has type Rel.

func IsVM32X

func IsVM32X(op Op) bool

IsVM32X returns true if op is a vector memory operand with 32-bit XMM index.

func IsVM32Y

func IsVM32Y(op Op) bool

IsVM32Y returns true if op is a vector memory operand with 32-bit YMM index.

func IsVM32Z

func IsVM32Z(op Op) bool

IsVM32Z returns true if op is a vector memory operand with 32-bit ZMM index.

func IsVM64X

func IsVM64X(op Op) bool

IsVM64X returns true if op is a vector memory operand with 64-bit XMM index.

func IsVM64Y

func IsVM64Y(op Op) bool

IsVM64Y returns true if op is a vector memory operand with 64-bit YMM index.

func IsVM64Z

func IsVM64Z(op Op) bool

IsVM64Z returns true if op is a vector memory operand with 64-bit ZMM index.

func IsVmx

func IsVmx(op Op) bool

IsVmx returns true if op is a vector memory operand with XMM index.

func IsVmy

func IsVmy(op Op) bool

IsVmy returns true if op is a vector memory operand with YMM index.

func IsVmz

func IsVmz(op Op) bool

IsVmz returns true if op is a vector memory operand with ZMM index.

func IsXMM

func IsXMM(op Op) bool

IsXMM returns true if op is a 128-bit XMM register.

func IsXMM0

func IsXMM0(op Op) bool

IsXMM0 returns true if op is the X0 register.

func IsYMM

func IsYMM(op Op) bool

IsYMM returns true if op is a 256-bit YMM register.

func IsZMM

func IsZMM(op Op) bool

IsZMM returns true if op is a 512-bit ZMM register.

func Registers

func Registers(op Op) []reg.Register

Registers returns the list of all operands involved in the given operand.

Types

type Constant

type Constant interface {
	Op
	Bytes() int
	// contains filtered or unexported methods
}

Constant represents a constant literal.

func Imm

func Imm(x uint64) Constant

Imm returns an unsigned integer constant with size guessed from x.

type F32

type F32 float32

F32 is a 32-bit floating point constant.

func (F32) Asm

func (f F32) Asm() string

func (F32) Bytes

func (f F32) Bytes() int

type F64

type F64 float64

F64 is a 64-bit floating point constant.

func (F64) Asm

func (f F64) Asm() string

func (F64) Bytes

func (f F64) Bytes() int

type I16

type I16 int16

I16 is a 16-bit signed integer constant.

func (I16) Asm

func (i I16) Asm() string

func (I16) Bytes

func (i I16) Bytes() int

type I32

type I32 int32

I32 is a 32-bit signed integer constant.

func (I32) Asm

func (i I32) Asm() string

func (I32) Bytes

func (i I32) Bytes() int

type I64

type I64 int64

I64 is a 64-bit signed integer constant.

func (I64) Asm

func (i I64) Asm() string

func (I64) Bytes

func (i I64) Bytes() int

type I8

type I8 int8

I8 is a 8-bit signed integer constant.

func (I8) Asm

func (i I8) Asm() string

func (I8) Bytes

func (i I8) Bytes() int

type LabelRef

type LabelRef string

LabelRef is a reference to a label.

func (LabelRef) Asm

func (l LabelRef) Asm() string

Asm returns an assembly syntax representation of l.

type Mem

type Mem struct {
	Symbol Symbol
	Disp   int
	Base   reg.Register
	Index  reg.Register
	Scale  uint8
}

Mem represents a memory reference.

func NewDataAddr

func NewDataAddr(sym Symbol, offset int) Mem

NewDataAddr returns a memory reference relative to the named data symbol.

func NewParamAddr

func NewParamAddr(name string, offset int) Mem

NewParamAddr is a convenience to build a Mem operand pointing to a function parameter, which is a named offset from the frame pointer pseudo register.

func NewStackAddr

func NewStackAddr(offset int) Mem

NewStackAddr returns a memory reference relative to the stack pointer.

func (Mem) Asm

func (m Mem) Asm() string

Asm returns an assembly syntax representation of m.

func (Mem) Idx

func (m Mem) Idx(r reg.Register, s uint8) Mem

Idx returns a new memory reference with (Index, Scale) set to (r, s).

func (Mem) Offset

func (m Mem) Offset(idx int) Mem

Offset returns a reference to m plus idx bytes.

type Op

type Op interface {
	Asm() string
}

Op is an operand.

func ApplyAllocation

func ApplyAllocation(op Op, a reg.Allocation) Op

ApplyAllocation returns an operand with allocated registers replaced. Registers missing from the allocation are left alone.

type Rel

type Rel int32

Rel is an offset relative to the instruction pointer.

func (Rel) Asm

func (r Rel) Asm() string

Asm returns an assembly syntax representation of r.

type String

type String string

String is a string constant.

func (String) Asm

func (s String) Asm() string

Asm returns an assembly syntax representation of the string s.

func (String) Bytes

func (s String) Bytes() int

Bytes returns the length of s.

type Symbol

type Symbol struct {
	Name   string
	Static bool // only visible in current source file
}

Symbol represents a symbol name.

func NewStaticSymbol

func NewStaticSymbol(name string) Symbol

NewStaticSymbol builds a static Symbol. Static symbols are only visible in the current source file.

func (Symbol) String

func (s Symbol) String() string

type U16

type U16 uint16

U16 is a 16-bit unsigned integer constant.

func (U16) Asm

func (u U16) Asm() string

func (U16) Bytes

func (u U16) Bytes() int

type U32

type U32 uint32

U32 is a 32-bit unsigned integer constant.

func (U32) Asm

func (u U32) Asm() string

func (U32) Bytes

func (u U32) Bytes() int

type U64

type U64 uint64

U64 is a 64-bit unsigned integer constant.

func (U64) Asm

func (u U64) Asm() string

func (U64) Bytes

func (u U64) Bytes() int

type U8

type U8 uint8

U8 is a 8-bit unsigned integer constant.

func (U8) Asm

func (u U8) Asm() string

func (U8) Bytes

func (u U8) Bytes() int

Jump to

Keyboard shortcuts

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