loong64asm

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GNUSyntax

func GNUSyntax(inst Inst) string

GNUSyntax returns the GNU assembler syntax for the instruction, as defined by GNU binutils. This form typically matches the syntax defined in the Loong64 Reference Manual. See https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

func GoSyntax

func GoSyntax(inst Inst, pc uint64, symname func(uint64) (string, uint64)) string

GoSyntax returns the Go assembler syntax for the instruction. The syntax was originally defined by Plan 9. The pc is the program counter of the instruction, used for expanding PC-relative addresses into absolute ones. The symname function queries the symbol table for the program being disassembled. Given a target address it returns the name and base address of the symbol containing the target, if any; otherwise it returns "", 0.

Types

type Arg

type Arg interface {
	String() string
}

An Arg is a single instruction argument

type Args

type Args [5]Arg

An Args holds the instruction arguments. If an instruction has fewer than 5 arguments, the final elements in the array are nil.

type CodeSimm

type CodeSimm int16

func (CodeSimm) String

func (c CodeSimm) String() string

type Fcc

type Fcc uint8

float condition flags register

const (
	FCC0 Fcc = iota
	FCC1
	FCC2
	FCC3
	FCC4
	FCC5
	FCC6
	FCC7
)

func (Fcc) String

func (f Fcc) String() string

type Fcsr

type Fcsr uint8

float control status register

const (
	FCSR0 Fcsr = iota
	FCSR1
	FCSR2
	FCSR3
)

func (Fcsr) String

func (f Fcsr) String() string

type Inst

type Inst struct {
	Op   Op     // Opcode mnemonic
	Enc  uint32 // Raw encoding bits.
	Args Args   // Instruction arguments, in Loong64 manual order.
}

An Inst is a single instruction.

func Decode

func Decode(src []byte) (inst Inst, err error)

Decode decodes the 4 bytes in src as a single instruction.

func (Inst) String

func (i Inst) String() string

type OffsetSimm

type OffsetSimm struct {
	Imm   int32
	Width uint8
}

func (OffsetSimm) String

func (o OffsetSimm) String() string

type Op

type Op uint16

An Op is an Loong64 opcode.

const (
	ADDI_D Op
	ADDI_W
	ADD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MUL_D
	MUL_W
	NOR
	OR
	ORI
	ORN
	PCADDI
	PCADDU12I
	PCADDU18I
	PCALAU12I
	PRELD
	PRELDX
	RDTIMEH_W
	RDTIMEL_W
	RDTIME_D
	REVB_2H
	REVB_2W
	REVB_4H
	REVB_D
	REVH_2W
	REVH_D
	ROTRI_D
	ROTRI_W
	ROTR_D
	ROTR_W
	SCREL_D
	SCREL_W
	SC_D
	SC_Q
	SC_W
	SLLI_D
	SLLI_W
	SLL_D
	SLL_W
	SLT
	SLTI
	SLTU
	SLTUI
	SRAI_D
	SRAI_W
	SRA_D
	SRA_W
	SRLI_D
	SRLI_W
	SRL_D
	SRL_W
	STGT_B
	STGT_D
	STGT_H
	STGT_W
	STLE_B
	STLE_D
	STLE_H
	STLE_W
	STPTR_D
	STPTR_W
	STX_B
	STX_D
	STX_H
	STX_W
	ST_B
	ST_D
	ST_H
	ST_W
	SUB_D
	SUB_W
	SYSCALL
	TLBCLR
	TLBFILL
	TLBFLUSH
	TLBRD
	TLBSRCH
	TLBWR
	XOR
	XORI
)

func (Op) String

func (op Op) String() string

NOTE: The actual Op values are defined in tables.go. They are chosen to simplify instruction decoding and are not a dense packing from 0 to N, although the density is high, probably at least 90%.

type Reg

type Reg uint16

A Reg is a single register. The zero value denotes R0, not the absence of a register.

const (
	// General-purpose register
	R0 Reg = iota
	R1
	R2
	R3
	R4
	R5
	R6
	R7
	R8
	R9
	R10
	R11
	R12
	R13
	R14
	R15
	R16
	R17
	R18
	R19
	R20
	R21
	R22
	R23
	R24
	R25
	R26
	R27
	R28
	R29
	R30
	R31

	// Float point register
	F0
	F1
	F2
	F3
	F4
	F5
	F6
	F7
	F8
	F9
	F10
	F11
	F12
	F13
	F14
	F15
	F16
	F17
	F18
	F19
	F20
	F21
	F22
	F23
	F24
	F25
	F26
	F27
	F28
	F29
	F30
	F31
)

func (Reg) String

func (r Reg) String() string

type SaSimm

type SaSimm int16

func (SaSimm) String

func (s SaSimm) String() string

type Simm16

type Simm16 struct {
	Imm   int16
	Width uint8
}

func (Simm16) String

func (si Simm16) String() string

type Simm32

type Simm32 struct {
	Imm   int32
	Width uint8
}

func (Simm32) String

func (si Simm32) String() string

type Uimm

type Uimm struct {
	Imm     uint32
	Decimal bool
}

An Imm is an integer constant.

func (Uimm) String

func (i Uimm) String() string

Jump to

Keyboard shortcuts

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