Documentation ¶
Overview ¶
Package insts provides the definition for GCN3 instructions.
Index ¶
- Constants
- Variables
- func BytesToUint32(data []byte) uint32
- func BytesToUint64(data []byte) uint64
- func BytesToUint8(data []byte) uint8
- func Uint32ToBytes(num uint32) []byte
- func Uint64ToBytes(num uint64) []byte
- func Uint8ToBytes(num uint8) []byte
- type Disassembler
- type ExeUnit
- type Format
- type FormatType
- type HsaCo
- type HsaCoHeader
- func (h *HsaCoHeader) EnableExceptionAddressWatch() bool
- func (h *HsaCoHeader) EnableExceptionMemoryViolation() bool
- func (h *HsaCoHeader) EnableSgprDispatchID() bool
- func (h *HsaCoHeader) EnableSgprDispatchPtr() bool
- func (h *HsaCoHeader) EnableSgprFlatScratchInit() bool
- func (h *HsaCoHeader) EnableSgprGridWorkGroupCountX() bool
- func (h *HsaCoHeader) EnableSgprGridWorkGroupCountY() bool
- func (h *HsaCoHeader) EnableSgprGridWorkGroupCountZ() bool
- func (h *HsaCoHeader) EnableSgprKernelArgSegmentPtr() bool
- func (h *HsaCoHeader) EnableSgprPrivateSegementSize() bool
- func (h *HsaCoHeader) EnableSgprPrivateSegmentBuffer() bool
- func (h *HsaCoHeader) EnableSgprPrivateSegmentWaveByteOffset() bool
- func (h *HsaCoHeader) EnableSgprQueuePtr() bool
- func (h *HsaCoHeader) EnableSgprWorkGroupIDX() bool
- func (h *HsaCoHeader) EnableSgprWorkGroupIDY() bool
- func (h *HsaCoHeader) EnableSgprWorkGroupIDZ() bool
- func (h *HsaCoHeader) EnableSgprWorkGroupInfo() bool
- func (h *HsaCoHeader) EnableVgprWorkItemID() uint32
- func (h *HsaCoHeader) Info() string
- func (h *HsaCoHeader) Priority() uint32
- func (h *HsaCoHeader) UserSgprCount() uint32
- func (h *HsaCoHeader) WavefrontSgprCount() uint32
- func (h *HsaCoHeader) WorkItemVgprCount() uint32
- type Inst
- type InstType
- type Opcode
- type Operand
- type OperandType
- type Reg
- type RegType
- type SDWASelect
- type SDWAUnused
Constants ¶
const ( InvalidOperantType = iota RegOperand FloatOperand IntOperand LiteralConstant )
Operand types
const ( InvalidRegType = iota PC V0 V1 V2 V3 V4 V5 V6 V7 V8 V9 V10 V11 V12 V13 V14 V15 V16 V17 V18 V19 V20 V21 V22 V23 V24 V25 V26 V27 V28 V29 V30 V31 V32 V33 V34 V35 V36 V37 V38 V39 V40 V41 V42 V43 V44 V45 V46 V47 V48 V49 V50 V51 V52 V53 V54 V55 V56 V57 V58 V59 V60 V61 V62 V63 V64 V65 V66 V67 V68 V69 V70 V71 V72 V73 V74 V75 V76 V77 V78 V79 V80 V81 V82 V83 V84 V85 V86 V87 V88 V89 V90 V91 V92 V93 V94 V95 V96 V97 V98 V99 V100 V101 V102 V103 V104 V105 V106 V107 V108 V109 V110 V111 V112 V113 V114 V115 V116 V117 V118 V119 V120 V121 V122 V123 V124 V125 V126 V127 V128 V129 V130 V131 V132 V133 V134 V135 V136 V137 V138 V139 V140 V141 V142 V143 V144 V145 V146 V147 V148 V149 V150 V151 V152 V153 V154 V155 V156 V157 V158 V159 V160 V161 V162 V163 V164 V165 V166 V167 V168 V169 V170 V171 V172 V173 V174 V175 V176 V177 V178 V179 V180 V181 V182 V183 V184 V185 V186 V187 V188 V189 V190 V191 V192 V193 V194 V195 V196 V197 V198 V199 V200 V201 V202 V203 V204 V205 V206 V207 V208 V209 V210 V211 V212 V213 V214 V215 V216 V217 V218 V219 V220 V221 V222 V223 V224 V225 V226 V227 V228 V229 V230 V231 V232 V233 V234 V235 V236 V237 V238 V239 V240 V241 V242 V243 V244 V245 V246 V247 V248 V249 V250 V251 V252 V253 V254 V255 S0 S1 S2 S3 S4 S5 S6 S7 S8 S9 S10 S11 S12 S13 S14 S15 S16 S17 S18 S19 S20 S21 S22 S23 S24 S25 S26 S27 S28 S29 S30 S31 S32 S33 S34 S35 S36 S37 S38 S39 S40 S41 S42 S43 S44 S45 S46 S47 S48 S49 S50 S51 S52 S53 S54 S55 S56 S57 S58 S59 S60 S61 S62 S63 S64 S65 S66 S67 S68 S69 S70 S71 S72 S73 S74 S75 S76 S77 S78 S79 S80 S81 S82 S83 S84 S85 S86 S87 S88 S89 S90 S91 S92 S93 S94 S95 S96 S97 S98 S99 S100 S101 EXEC EXECLO EXECHI EXECZ VCC VCCLO VCCHI VCCZ SCC FlatSratch FlatSratchLo FlatSratchHi XnackMask XnackMaskLo XnackMaskHi Status Mode M0 Trapsts Tba TbaLo TbaHi Tma TmaLo TmaHi Timp0 Timp1 Timp2 Timp3 Timp4 Timp5 Timp6 Timp7 Timp8 Timp9 Timp10 Timp11 VMCNT EXPCNT LGKMCNT )
All the registers
Variables ¶
var FormatTable map[FormatType]*Format
FormatTable is a table that uses FormatType to find detailed format information about the format.
var Regs = map[RegType]*Reg{}/* 400 elements not displayed */
Regs are a list of all registers
Functions ¶
func BytesToUint32 ¶
BytesToUint32 decode a uint32 number from bytes
func BytesToUint64 ¶
BytesToUint64 decode a uint64 number from bytes
func BytesToUint8 ¶
BytesToUint8 decode a uint32 number from bytes
func Uint32ToBytes ¶
Uint32ToBytes returns the bytes representation of a uint32 value
func Uint64ToBytes ¶
Uint64ToBytes returns the bytes representation of a uint64 value
func Uint8ToBytes ¶
Uint8ToBytes returns the bytes representation of a uint32 value
Types ¶
type Disassembler ¶
type Disassembler struct {
// contains filtered or unexported fields
}
Disassembler is the unit that can decode .hsaco file
func NewDisassembler ¶
func NewDisassembler() *Disassembler
NewDisassembler creates a new disassembler
func (*Disassembler) Decode ¶
func (d *Disassembler) Decode(buf []byte) (*Inst, error)
Decode parses the head of the buffer and returns the next instruction
func (*Disassembler) Disassemble ¶
Disassemble take a binary file as an input and put the assembly code in a writer
type Format ¶
type Format struct { FormatType FormatType FormatName string Encoding uint32 Mask uint32 ByteSizeExLiteral int OpcodeLow uint8 OpcodeHigh uint8 }
Format defines the possible microcode format of instructions
type FormatType ¶
type FormatType int
FormatType is a enumeration of all the instruction formats defined by GCN3
const ( SOP2 FormatType = iota SOPK SOP1 SOPC SOPP SMEM VOP2 VOP1 VOP3a VOP3b VOPC VINTRP DS MUBUF MTBUF MIMG EXP FLAT )
All the GCN3 instruction formats
type HsaCo ¶
type HsaCo struct { *HsaCoHeader Symbol *elf.Symbol Data []byte }
An HsaCo is the kernel code to be executed on an AMD GPU
func NewHsaCoFromData ¶
NewHsaCoFromData creates an HsaCo with the provided data
func (*HsaCo) InstructionData ¶
InstructionData returns the instruction binaries in the HsaCo
type HsaCoHeader ¶
type HsaCoHeader struct { CodeVersionMajor uint32 CodeVersionMinor uint32 MachineKind uint16 MachineVersionMajor uint16 MachineVersionMinor uint16 MachineVersionStepping uint16 KernelCodeEntryByteOffset uint64 KernelCodePrefetchByteOffset uint64 KernelCodePrefetchByteSize uint64 MaxScratchBackingMemoryByteSize uint64 ComputePgmRsrc1 uint32 ComputePgmRsrc2 uint32 Flags uint32 WIPrivateSegmentByteSize uint32 WGGroupSegmentByteSize uint32 GDSSegmentByteSize uint32 KernargSegmentByteSize uint64 WGFBarrierCount uint32 WFSgprCount uint16 WIVgprCount uint16 ReservedVgprFirst uint16 ReservedVgprCount uint16 ReservedSgprFirst uint16 ReservedSgprCount uint16 DebugWfPrivateSegmentOffsetSgpr uint16 DebugPrivateSegmentBufferSgpr uint16 KernargSegmentAlignment uint8 GroupSegmentAlignment uint8 PrivateSegmentAlignment uint8 WavefrontSize uint8 CallConvention uint32 Reserved [12]byte RuntimeLoaderKernelSymbol uint64 ControlDirective [128]byte }
HsaCoHeader contains the header information of an HSACO
func (*HsaCoHeader) EnableExceptionAddressWatch ¶
func (h *HsaCoHeader) EnableExceptionAddressWatch() bool
EnableExceptionAddressWatch enable exception address watch
func (*HsaCoHeader) EnableExceptionMemoryViolation ¶
func (h *HsaCoHeader) EnableExceptionMemoryViolation() bool
EnableExceptionMemoryViolation enable exception memory violation
func (*HsaCoHeader) EnableSgprDispatchID ¶
func (h *HsaCoHeader) EnableSgprDispatchID() bool
EnableSgprDispatchID enables dispatch ID
func (*HsaCoHeader) EnableSgprDispatchPtr ¶
func (h *HsaCoHeader) EnableSgprDispatchPtr() bool
EnableSgprDispatchPtr enables dispatch ptr
func (*HsaCoHeader) EnableSgprFlatScratchInit ¶
func (h *HsaCoHeader) EnableSgprFlatScratchInit() bool
EnableSgprFlatScratchInit enables init
func (*HsaCoHeader) EnableSgprGridWorkGroupCountX ¶
func (h *HsaCoHeader) EnableSgprGridWorkGroupCountX() bool
EnableSgprGridWorkGroupCountX enables wg countx
func (*HsaCoHeader) EnableSgprGridWorkGroupCountY ¶
func (h *HsaCoHeader) EnableSgprGridWorkGroupCountY() bool
EnableSgprGridWorkGroupCountY enables wg county
func (*HsaCoHeader) EnableSgprGridWorkGroupCountZ ¶
func (h *HsaCoHeader) EnableSgprGridWorkGroupCountZ() bool
EnableSgprGridWorkGroupCountZ enables wg countz
func (*HsaCoHeader) EnableSgprKernelArgSegmentPtr ¶
func (h *HsaCoHeader) EnableSgprKernelArgSegmentPtr() bool
EnableSgprKernelArgSegmentPtr enables
func (*HsaCoHeader) EnableSgprPrivateSegementSize ¶
func (h *HsaCoHeader) EnableSgprPrivateSegementSize() bool
EnableSgprPrivateSegementSize enables size
func (*HsaCoHeader) EnableSgprPrivateSegmentBuffer ¶
func (h *HsaCoHeader) EnableSgprPrivateSegmentBuffer() bool
EnableSgprPrivateSegmentBuffer checks if the private segment buffer information need to write into the SGPR
func (*HsaCoHeader) EnableSgprPrivateSegmentWaveByteOffset ¶
func (h *HsaCoHeader) EnableSgprPrivateSegmentWaveByteOffset() bool
EnableSgprPrivateSegmentWaveByteOffset enable wavebyteoffset
func (*HsaCoHeader) EnableSgprQueuePtr ¶
func (h *HsaCoHeader) EnableSgprQueuePtr() bool
EnableSgprQueuePtr enables queue ptr
func (*HsaCoHeader) EnableSgprWorkGroupIDX ¶
func (h *HsaCoHeader) EnableSgprWorkGroupIDX() bool
EnableSgprWorkGroupIDX enable idx
func (*HsaCoHeader) EnableSgprWorkGroupIDY ¶
func (h *HsaCoHeader) EnableSgprWorkGroupIDY() bool
EnableSgprWorkGroupIDY enable idy
func (*HsaCoHeader) EnableSgprWorkGroupIDZ ¶
func (h *HsaCoHeader) EnableSgprWorkGroupIDZ() bool
EnableSgprWorkGroupIDZ enable idz
func (*HsaCoHeader) EnableSgprWorkGroupInfo ¶
func (h *HsaCoHeader) EnableSgprWorkGroupInfo() bool
EnableSgprWorkGroupInfo enable wg info
func (*HsaCoHeader) EnableVgprWorkItemID ¶
func (h *HsaCoHeader) EnableVgprWorkItemID() uint32
EnableVgprWorkItemID checks if the setup of the work-item is enabled
func (*HsaCoHeader) Info ¶
func (h *HsaCoHeader) Info() string
Info prints the human readable information that is carried by the HsaCoHeader
func (*HsaCoHeader) Priority ¶
func (h *HsaCoHeader) Priority() uint32
Priority returns the priority of the kernel
func (*HsaCoHeader) UserSgprCount ¶
func (h *HsaCoHeader) UserSgprCount() uint32
UserSgprCount returns user sgpr
func (*HsaCoHeader) WavefrontSgprCount ¶
func (h *HsaCoHeader) WavefrontSgprCount() uint32
WavefrontSgprCount returns the number of SGPRs used by each wavefront
func (*HsaCoHeader) WorkItemVgprCount ¶
func (h *HsaCoHeader) WorkItemVgprCount() uint32
WorkItemVgprCount returns the number of VGPRs used by each work-item
type Inst ¶
type Inst struct { *Format *InstType ByteSize int PC uint64 Src0 *Operand Src1 *Operand Src2 *Operand Dst *Operand SDst *Operand // For VOP3b Addr *Operand Data *Operand Data1 *Operand Base *Operand Offset *Operand SImm16 *Operand Abs int Omod int Neg int Offset0 uint32 Offset1 uint32 SystemLevelCoherent bool GlobalLevelCoherent bool TextureFailEnable bool Imm bool Clamp bool GDS bool VMCNT int LKGMCNT int //Fields for SDWA extensions IsSdwa bool DstSel SDWASelect DstUnused SDWAUnused Src0Sel SDWASelect Src0Sext bool Src0Neg bool Src0Abs bool Src1Sel SDWASelect Src1Sext bool Src1Neg bool Src1Abs bool Src2Neg bool Src2Abs bool }
An Inst is a GCN3 instruction
type InstType ¶
type InstType struct { InstName string Opcode Opcode Format *Format ID int ExeUnit ExeUnit DSTWidth int SRC0Width int SRC1Width int SRC2Width int SDSTWidth int }
A InstType represents an instruction type. For example s_barrier instruction is a instruction type
type Operand ¶
type Operand struct { Code int OperandType OperandType Register *Reg RegCount int // for cases like v[0:3] FloatValue float64 IntValue int64 LiteralConstant uint32 }
An Operand is an operand
func NewFloatOperand ¶
NewFloatOperand returns a new operand of an floating point type
func NewIntOperand ¶
NewIntOperand returns a new operand of an integer type
func NewRegOperand ¶
NewRegOperand returns a new operand of register type
func NewSRegOperand ¶
NewSRegOperand returns a new operand of s register type
func NewVRegOperand ¶
NewVRegOperand returns a new operand of v register type
type OperandType ¶
type OperandType int
OperandType represents the type of an operand. It can be Reg, Float, Int ...
type SDWASelect ¶
type SDWASelect uint32
SDWASelect defines the sub-dword selection type
const ( SDWASelectByte0 SDWASelect = 0x000000ff SDWASelectByte1 SDWASelect = 0x0000ff00 SDWASelectByte2 SDWASelect = 0x00ff0000 SDWASelectByte3 SDWASelect = 0xff000000 SDWASelectWord0 SDWASelect = 0x0000ffff SDWASelectWord1 SDWASelect = 0xffff0000 SDWASelectDWord SDWASelect = 0xffffffff )
Defines all possible sub-dword selection type
type SDWAUnused ¶
type SDWAUnused uint8
SDWAUnused defines how to deal with unused bits
const ( SDWAUnusedPad SDWAUnused = 0 SDWAUnusedSEXT SDWAUnused = 1 SDWAUnusedPreserve SDWAUnused = 2 )
Defines all possible SDWA unused options