codegen

package
v0.0.0-...-06eb182 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	XMM_INVALID XmmData = iota
	XMM_F32
	XMM_F64
	XMM_4X_F32
	XMM_2X_F64
	XMM_F128  = XMM_2X_F64
	XMM_M128  = XMM_F128 // [4]float32
	XMM_M128i = XMM_F128 // [16]byte
	XMM_M128d = XMM_F128 // [2]float64

	XMM_I8X16 = XMM_F32
	XMM_U8X16 = XMM_I8X16

	XMM_I16X8 = XMM_F64
	XMM_U16X8 = XMM_I16X8

	XMM_I32X4 = XMM_4X_F32
	XMM_U32X4 = XMM_I32X4

	XMM_I64X2 = XMM_2X_F64
	XMM_U64X2 = XMM_I64X2
)
View Source
const (
	SHIFT_LEFT = iota
	SHIFT_RIGHT
)
View Source
const (
	INVALID_REG = RegType(iota)
	// integer register
	DATA_REG
	// Stack pointer pseudo register
	SpReg
	// Frame pointer pseudo register
	FpReg
	// xmm register
	XMM_REG
)
View Source
const DataRegSize = 8

size in bytes

View Source
const NumDataRegs = 14
View Source
const NumXMM_REGs = 16
View Source
const XmmRegSize = 16

Variables

View Source
var LongSizes = []uint{1, 2, 4}
View Source
var QuadSize = []uint{8}
View Source
var QuadSizes = []uint{1, 2, 4, 8}
View Source
var XmmDataSizes = []uint{1, 2, 4, 8, 16}

Functions

func AddImm32Reg

func AddImm32Reg(ctx context, imm32 uint32, dst *register, spill bool) string

func AddRegReg

func AddRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string

func AndNotRegReg

func AndNotRegReg(ctx context, src, dst *register, size uint, spill bool) string

func AndRegReg

func AndRegReg(ctx context, src, dst *register, size uint, spill bool) string

AndRegReg AND's the src register by the dst register and stores the result in the dst register.

func ArithOp

func ArithOp(ctx context, datatype OpDataType, op token.Token, x, y, result *register) string

func AssemblyFilePreamble

func AssemblyFilePreamble() string

func BitwiseOp

func BitwiseOp(ctx context, op token.Token, signed bool, x, y, result *register, size uint) string

func CMovCCRegReg

func CMovCCRegReg(ctx context, src, dst *register, size uint, spill bool) string

CMovCCRegReg conditionally moves the src reg to the dst reg if the carry flag is clear (ie the previous compare had its src greater than its sub reg).

func CmpOp

func CmpOp(ctx context, data OpDataType, op token.Token, x *register, y *register, result *register) string

CmpOp compares x to y, storing the op comparison flag (EQ, NEQ, ...) in result

func CmpRegImm32

func CmpRegImm32(ctx context, r *register, imm32 uint32, size uint) string

func CmpRegReg

func CmpRegReg(ctx context, odt OpDataType, x, y *register) string

func ConvertOp

func ConvertOp(ctx context, from *register, fromtype OpDataType, to *register, totype OpDataType, tmp *register) string

func CreateFunction

func CreateFunction(fn *ssa.Function, outfn string, debug bool, trace bool, optimize bool) (*Function, *Error)

func DivFloatRegReg

func DivFloatRegReg(ctx context, datatype OpDataType, dividend, divisor *register, spill bool) string

DivFloatRegReg performs floating point division by dividing the dividend register by the divisor register and stores the quotient in the dividend register

func DivRegReg

func DivRegReg(ctx context, signed bool, datatype InstrOpType, dividend, divisor *register, size uint) (asm string, rax *register, rdx *register)

DivRegReg divides the "dividend" register by the "divisor" register and stores the quotient in rax and the remainder in rdx. DivRegReg is only for integer division.

func FloatToFloat

func FloatToFloat(ctx context, from, to *register, ftype, totype OpDataType) string

func FloatToInteger

func FloatToInteger(ctx context, from, to *register, ftype, totype OpDataType) string

func IntegerToFloat

func IntegerToFloat(ctx context, from, to *register, ftype, totype OpDataType, tmp *register) string

func IntegerToInteger

func IntegerToInteger(ctx context, from, to *register, ftype, totype OpDataType) string

func Lea

func Lea(ctx context, srcName string, srcOffset int, src, dst *register, spill bool) string

func MovImm32Reg

func MovImm32Reg(ctx context, imm32 int32, dst *register, spill bool) string

func MovImm8Reg

func MovImm8Reg(ctx context, imm8 int8, dst *register, spill bool) string

func MovImmFloatReg

func MovImmFloatReg(ctx context, f64 float64, isf32 bool, tmp, dst *register, spill bool) string

func MovImmReg

func MovImmReg(ctx context, imm int64, size uint, dst *register, spill bool) string

asmMovImmReg moves imm to reg after converting it to int8/16/32 if size=1/2/4.

func MovImmf32Reg

func MovImmf32Reg(ctx context, f32 float32, tmp, dst *register, spill bool) string

func MovImmf64Reg

func MovImmf64Reg(ctx context, f64 float64, tmp, dst *register, spill bool) string

func MovIntegerSimdMemIndirectMem

func MovIntegerSimdMemIndirectMem(ctx context, datatype OpDataType, srcName string, srcOffset int, src *register, dstName string, dstOffset int, dst *register, size uint, tmp1, tmp2 *register) string

func MovMemIndirectMem

func MovMemIndirectMem(ctx context, datatype OpDataType, srcName string, srcOffset int, src *register, dstName string, dstOffset int, dst *register, size uint, tmpAddr, tmpData *register) string

func MovMemMem

func MovMemMem(ctx context, optype InstrOpType, srcName string, srcOffset int, src *register, dstName string, dstOffset int, dst *register, size uint, tmp *register) string

func MovMemReg

func MovMemReg(ctx context, datatype OpDataType, srcName string, srcOffset int, src, dst *register, spill bool) string

func MovRegIndirectMem

func MovRegIndirectMem(ctx context, datatype OpDataType, src *register, dstName string, dstOffset int, dst *register, size uint, tmpAddr, tmpData *register) string

func MovRegIndirectMemSmall

func MovRegIndirectMemSmall(ctx context, datatype OpDataType, src *register, dstName string, dstOffset int, dst *register, size uint, tmpData *register) string

func MovRegMem

func MovRegMem(ctx context, datatype OpDataType, src *register, dstName string, dst *register, dstOffset int) string

func MovRegReg

func MovRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string

func MovSignExtend

func MovSignExtend(ctx context, src, dst *register, srcSize, dstSize uint, spill bool) string

func MovZeroExtend

func MovZeroExtend(ctx context, src, dst *register, srcSize, dstSize uint, spill bool) string

func MulImm32RegReg

func MulImm32RegReg(ctx context, imm32 uint32, src, dst *register, spill bool) string

func MulRegReg

func MulRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string

MulRegReg multiplies the src register by the dst register and stores the result in the dst register. Overflow is discarded

func NotReg

func NotReg(ctx context, reg *register, size uint, spill bool) string

func OrRegReg

func OrRegReg(ctx context, src, dst *register, spill bool) string

func ResetStackPointer

func ResetStackPointer(size uint32) string

func Ret

func Ret() string

func ShiftImm8Reg

func ShiftImm8Reg(ctx context, signed bool, direction int, count uint8, reg *register) string

func ShiftRegReg

func ShiftRegReg(ctx context, signed bool, direction int, src, shiftReg, tmp *register, size uint, spill bool) string

ShiftRegReg shifts src by shiftReg amount and stores the result in src. The tmp reg is used for intermediates (if shifting right 64 times then SHR isn't used directly)

func SubImm32Reg

func SubImm32Reg(ctx context, imm32 uint32, dst *register, spill bool) string

func SubRegReg

func SubRegReg(ctx context, datatype OpDataType, src, dst *register, spill bool) string

func XmmInstrDataSize

func XmmInstrDataSize(xmmtype XmmData) uint

func XorImm32Reg

func XorImm32Reg(ctx context, imm32 int32, dst *register, size uint, spill bool) string

func XorImm64Reg

func XorImm64Reg(ctx context, imm64 int64, dst *register, size uint, spill bool) string

func XorRegReg

func XorRegReg(ctx context, src, dst *register, spill bool) string

func ZeroMemory

func ZeroMemory(ctx context, name string, offset int, size uint, reg *register) string

ZeroMemory generates "MOVQ $0, name+offset(REG)" instructions, size is in bytes

func ZeroReg

func ZeroReg(ctx context, reg *register) string

ZeroReg generates "XORQ reg, reg" instructions

Types

type DataInstruction

type DataInstruction struct {
	TInstr InstructionType

	// integer forms
	ByteSized Instruction
	WordSized Instruction
	LongSized Instruction
	QuadSized Instruction
	OctSized  Instruction
}

func GetInstruction

func GetInstruction(tinst InstructionType) DataInstruction

func (DataInstruction) GetSized

func (inst DataInstruction) GetSized(size uint) Instruction

type Error

type Error struct {
	Err error
	Pos token.Pos
}

func ErrorMsg

func ErrorMsg(msg string) (string, *Error)

func ErrorMsg2

func ErrorMsg2(msg string) *Error

type Function

type Function struct {
	// if Debug is set, debug comments are included in assembly output
	Debug       bool
	PrintSpills bool
	Trace       bool
	Optimize    bool
	Indent      string
	// contains filtered or unexported fields
}

func (*Function) AllocInstr

func (f *Function) AllocInstr(instr *ssa.Alloc) (string, *Error)

func (*Function) AssignRegIdent

func (f *Function) AssignRegIdent(loc ssa.Instruction, reg *register, ident *identifier, offset uint, size uint) (string, *Error)

func (*Function) BasicBlock

func (f *Function) BasicBlock(block *ssa.BasicBlock) (string, *Error)

func (*Function) BasicBlocks

func (f *Function) BasicBlocks() (string, *Error)

func (*Function) BinOp

func (f *Function) BinOp(instr *ssa.BinOp) (string, *Error)

func (*Function) BinOpLoadXY

func (f *Function) BinOpLoadXY(instr *ssa.BinOp) (asm string, x *register, y *register, err *Error)

func (*Function) Builtin

func (f *Function) Builtin(call *ssa.Call, builtin *ssa.Builtin) (string, *Error)

func (*Function) Call

func (f *Function) Call(call *ssa.Call) (string, *Error)

func (*Function) Convert

func (f *Function) Convert(instr *ssa.Convert) (string, *Error)

func (*Function) ConvertFromTo

func (f *Function) ConvertFromTo(instr *ssa.Convert, fromOpType, toOpType InstrOpType, fromXmm, toXmm XmmData) (string, *Error)

func (*Function) ConvertUint64ToFloat

func (f *Function) ConvertUint64ToFloat(loc ssa.Instruction, tmp, regU64, regFloat *register, floatSize uint) string

func (*Function) CopyToRet

func (f *Function) CopyToRet(ret *ssa.Return, val []ssa.Value) (string, *Error)

func (*Function) Func

func (f *Function) Func() (string, *Error)

func (*Function) GoAssembly

func (f *Function) GoAssembly() (string, *Error)

func (*Function) GoProto

func (f *Function) GoProto() (string, string, string)

func (*Function) Ident

func (f *Function) Ident(v ssa.Value) *identifier

func (*Function) If

func (f *Function) If(instr *ssa.If) (string, *Error)

func (*Function) Index

func (f *Function) Index(instr *ssa.Index) (string, *Error)

func (*Function) IndexAddr

func (f *Function) IndexAddr(instr *ssa.IndexAddr) (string, *Error)

func (*Function) Instr

func (f *Function) Instr(instr ssa.Instruction) (string, *Error)

func (*Function) Jump

func (f *Function) Jump(jmp *ssa.Jump) (string, *Error)

func (*Function) JumpPreamble

func (f *Function) JumpPreamble(loc ssa.Instruction, blockIndex, jmpIndex int) (string, *Error)

func (*Function) Len

func (f *Function) Len(call *ssa.Call) (string, *Error)

func (*Function) LoadIdent

func (f *Function) LoadIdent(loc ssa.Instruction, ident *identifier, offset uint, size uint) (string, *register, *Error)

func (*Function) LoadIdentSimple

func (f *Function) LoadIdentSimple(loc ssa.Instruction, ident *identifier) (string, *register, *Error)

func (*Function) LoadSSE2

func (f *Function) LoadSSE2(loc ssa.Instruction, ident *identifier) (string, *register, *Error)

func (*Function) LoadSimd

func (f *Function) LoadSimd(loc ssa.Instruction, ident *identifier) (string, *register, *Error)

func (*Function) LoadSimdValue

func (f *Function) LoadSimdValue(loc ssa.Instruction, simdvalue ssa.Value) (string, *register, *Error)

func (*Function) LoadValue

func (f *Function) LoadValue(loc ssa.Instruction, val ssa.Value, offset uint, size uint) (string, *register, *Error)

func (*Function) LoadValueSimple

func (f *Function) LoadValueSimple(loc ssa.Instruction, val ssa.Value) (string, *register, *Error)

func (*Function) Params

func (f *Function) Params() (string, *Error)

func (*Function) Phi

func (f *Function) Phi(phi *ssa.Phi) (string, *Error)

func (*Function) Position

func (f *Function) Position(pos token.Pos) token.Position

func (*Function) Return

func (f *Function) Return(ret *ssa.Return) (string, *Error)

func (*Function) SSE2Intrinsic

func (f *Function) SSE2Intrinsic(call *ssa.Call, sse2intrinsic Intrinsic) (string, *Error)

func (*Function) SetStackPointer

func (f *Function) SetStackPointer() string

func (*Function) SimdIntrinsic

func (f *Function) SimdIntrinsic(call *ssa.Call) (string, *Error)

func (*Function) Slice

func (f *Function) Slice(instr *ssa.Slice) (string, *Error)

func (*Function) SliceLen

func (f *Function) SliceLen(loc ssa.Instruction, slice ssa.Value, ident *identifier) (string, *Error)

func (*Function) Store

func (f *Function) Store(instr *ssa.Store) (string, *Error)

func (*Function) StoreSSE2

func (f *Function) StoreSSE2(loc ssa.Instruction, reg *register, ident *identifier) (string, *Error)

func (*Function) StoreSimd

func (f *Function) StoreSimd(loc ssa.Instruction, reg *register, ident *identifier) (string, *Error)

func (*Function) StoreValAddr

func (f *Function) StoreValAddr(loc ssa.Instruction, val ssa.Value, addr *identifier) (string, *Error)

func (*Function) StoreValue

func (f *Function) StoreValue(loc ssa.Instruction, ident *identifier, reg *register) (string, *Error)

func (*Function) UnOp

func (f *Function) UnOp(instr *ssa.UnOp) (string, *Error)

func (*Function) UnOpPointer

func (f *Function) UnOpPointer(instr *ssa.UnOp) (string, *Error)

pointer indirection, in assignment such as "z = *x"

func (*Function) UnOpSub

func (f *Function) UnOpSub(instr *ssa.UnOp) (string, *Error)

arithmetic negation

func (*Function) UnOpXor

func (f *Function) UnOpXor(instr *ssa.UnOp, xorVal int32) (string, *Error)

bitwise negation

func (*Function) ZeroRetValue

func (f *Function) ZeroRetValue() (string, *Error)

func (*Function) ZeroSsaLocals

func (f *Function) ZeroSsaLocals() (string, *Error)

type InstrData

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

type InstrFlags

type InstrFlags int
const (
	FLAGS_NONE InstrFlags = 1 << iota
	SizeB                 // byte
	SizeW                 // word
	SizeL                 // dword
	SizeQ                 // quad word
	SizeO                 // oct word
	SizeD                 // float64
	SizeF                 // float32

	UseCarry
	SetCarry
	KillCarry

	ShiftCX
	ImulAXDX

	LeftRead
	LeftRdwr
	RightRead
	RightRdwr
	RightWrite

	LeftAddr
	RightAddr

	Call
	OK
	Conv

	Cjmp
	Jump
	Break

	Move
)

type InstrInfo

type InstrInfo struct {
	Flags InstrFlags
	Use   Reg
	Set   Reg
}

type InstrOpType

type InstrOpType int
const (
	OP_INVALID InstrOpType = iota
	OP_DATA                // int8/uint8,,..., int64/uint64
	OP_XMM                 // f32/f64, packed f32, packed f64
	OP_PACKED              // packed int8/uint8,....,int63/uint64
)

func (InstrOpType) String

func (i InstrOpType) String() string

type Instruction

type Instruction int
const (
	NONE Instruction = iota
	AAD
	AAM
	AAS
	ADCB
	ADCL
	ADCW
	ADDB
	ADDL
	ADDW
	ADJSP
	ANDB
	ANDL
	ANDW
	ARPL
	BOUNDL
	BOUNDW
	BSFL
	BSFW
	BSRL
	BSRW
	BTL
	BTW
	BTCL
	BTCW
	BTRL
	BTRW
	BTSL
	BTSW
	BYTE
	CLC
	CLD
	CLI
	CLTS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SS2SQ
	CVTTPD2PL
	CVTTPS2PL
	CVTTSD2SL
	CVTTSD2SQ
	CVTTSS2SL
	CVTTSS2SQ
	DIVPD
	DIVPS
	DIVSD
	DIVSS
	EMMS
	FXRSTOR
	FXRSTOR64
	FXSAVE
	FXSAVE64
	LDMXCSR
	MASKMOVOU
	MASKMOVQ
	MAXPD
	MAXPS
	MAXSD
	MAXSS
	MINPD
	MINPS
	MINSD
	MINSS
	MOVAPD
	MOVAPS
	MOVOU
	MOVHLPS
	MOVHPD
	MOVHPS
	MOVLHPS
	MOVLPD
	MOVLPS
	MOVMSKPD
	MOVMSKPS
	MOVNTO
	MOVNTPD
	MOVNTPS
	MOVNTQ
	MOVO
	MOVQOZX
	MOVSD
	MOVSS
	MOVUPD
	MOVUPS
	MULPD
	MULPS
	MULSD
	MULSS
	ORPD
	ORPS
	PACKSSLW
	PACKSSWB
	PACKUSWB
	PADDB
	PADDL
	PADDQ
	PADDSB
	PADDSW
	PADDUSB
	PADDUSW
	PADDW
	PANDB
	PANDL
	PANDSB
	PANDSW
	PANDUSB
	PANDUSW
	PANDW
	PAND
	PANDN
	PAVGB
	PAVGW
	PCMPEQB
	PCMPEQL
	PCMPEQW
	PCMPGTB
	PCMPGTL
	PCMPGTW
	PEXTRW

	// 3DNow! instructions
	PFACC
	PFADD
	PFCMPEQ
	PFCMPGE
	PFCMPGT
	PFMAX
	PFMIN
	PFMUL
	PFNACC
	PFPNACC
	PFRCP
	PFRCPIT1
	PFRCPI2T
	PFRSQIT1
	PFRSQRT
	PFSUB
	PFSUBR

	PINSRW
	PINSRD
	PINSRQ
	PMADDWL
	PMAXSW
	PMAXUB
	PMINSW
	PMINUB
	PMOVMSKB

	// 3DNow! instruction
	PMULHRW

	// Multiply Packed Unsigned Integers (16bit) and Store High Result
	// multiplies the packed unsigned word (16bit) integers in xmm1 and xmm2/m128
	// and store the high 16 bits of the results in xmm1
	// Intel instruction: PMULHUW
	PMULHUW

	// Multiply Packed Signed Integers (16bit) and Store High Result
	// multiplies the packed signed word (16bit) integers in xmm1 and xmm2/m128
	// and store the high 16 bits of the results in xmm1
	// Intel instruction: PMULHW
	PMULHW

	// Multiply Packed Signed Integers (16bit) and Store Low Result
	// multiplies the packed signed word (16bit) integers in xmm1 and xmm2/m128
	// and store the low 16 bits of the results in xmm1
	// Intel instruction: PMULLW
	PMULLW

	// Multiply Packed Unsigned Dword (32bit) Integers
	// multiplies two 32bit ints (in dwords 0 and 2 of the xmms registers)
	// and stores resulting two 64bit ints in result
	// xmm register/128bits mem
	// Intel instruction: PMULUDQ
	PMULULQ

	POR
	PSADBW
	PSHUFHW
	PSHUFL
	PSHUFLW
	PSHUFW
	PSHUFB
	PSLLO
	PSLLL
	PSLLQ
	PSLLW
	PSRAL
	PSRAW
	PSRLO
	PSRLL
	PSRLQ
	PSRLW
	PSUBB
	PSUBL
	PSUBQ
	PSUBSB
	PSUBSW
	PSUBUSB
	PSUBUSW
	PSUBW
	PSWAPL
	PUNPCKHBW
	PUNPCKHLQ
	PUNPCKHQDQ
	PUNPCKHWL
	PUNPCKLBW
	PUNPCKLLQ
	PUNPCKLQDQ
	PUNPCKLWL
	PXOR
	RCPPS
	RCPSS
	RSQRTPS
	RSQRTSS
	SHUFPD
	SHUFPS
	SQRTPD
	SQRTPS
	SQRTSD
	SQRTSS
	STMXCSR
	SUBPD
	SUBPS
	SUBSD
	SUBSS
	UCOMISD
	UCOMISS
	UNPCKHPD
	UNPCKHPS
	UNPCKLPD
	UNPCKLPS
	XORPD
	XORPS
	PF2IW
	PF2IL
	PI2FW
	PI2FL
	RETFW
	RETFL
	RETFQ
	SWAPGS
	MODE
	CRC32B
	CRC32Q
	IMUL3Q
	PREFETCHT0
	PREFETCHT1
	PREFETCHT2
	PREFETCHNTA
	MOVQL
	BSWAPL
	BSWAPQ
	AESENC
	AESENCLAST
	AESDEC
	AESDECLAST
	AESIMC
	AESKEYGENASSIST
	ROUNDPS
	ROUNDSS
	ROUNDPD
	ROUNDSD
	PSHUFD
	PCLMULQDQ // packed carryless quadword multiplication (xmm)
	JCXZW
	FCMOVCC
	FCMOVCS
	FCMOVEQ
	FCMOVHI
	FCMOVLS
	FCMOVNE
	FCMOVNU
	FCMOVUN
	FCOMI
	FCOMIP
	FUCOMI
	FUCOMIP
	LAST
)

https://github.com/golang/go/blob/master/src/cmd/internal/obj/x86/a.out.go

func GetConvertInstruction

func GetConvertInstruction(tinst InstructionType, fromsize, tosize uint) Instruction

func GetInstr

func GetInstr(tinst InstructionType, datatype OpDataType) Instruction

GetInstr, the size is in bytes

func (Instruction) String

func (i Instruction) String() string

type InstructionType

type InstructionType int
const (
	I_INVALID InstructionType = iota
	I_ADD
	I_AND
	I_CMP

	// convert f32/64 to a uint8/int8, ..., uint64/int64
	I_CVT_FLOAT2INT
	// convert f32/f64 to a uint8/int8, ..., uint64/int64
	I_CVT_INT2FLOAT

	// convert f32/f64 to f64/f32
	I_CVT_FLOAT2FLOAT

	I_DIV
	I_IMUL
	I_IDIV
	I_LEA
	I_MOV

	// mov byte, sign extend
	I_MOVBSX
	// mov word, sign extend
	I_MOVWSX
	// mov long, sign extend
	I_MOVLSX

	// mov byte, zero extend
	I_MOVBZX
	// mov word, zero extend
	I_MOVWZX
	// mov long, zero extend
	I_MOVLZX
	I_MUL

	I_OR

	// instructions for packed integers
	I_PADD
	I_PAND
	I_PANDN
	I_PCMPEQ
	I_PCMPGT
	I_PIMUL
	I_PMUL
	I_POR
	I_PSLL //packed shift left logical
	I_PSRA // packed shift right arithmetic
	I_PSRL //packed shift right logical
	I_PSUB
	I_PXOR
	I_PMOV

	I_SAL
	I_SAR

	I_SHL
	I_SHR
	I_SUB
	I_XOR
)

func (InstructionType) String

func (i InstructionType) String() string

type Intrinsic

type Intrinsic struct {
	Name            string
	InstructionName string
	VarOps          []VarOp
	ResultIdxOp     int
}

type OpDataType

type OpDataType struct {
	InstrData
	// contains filtered or unexported fields
}

func GetIntegerOpDataType

func GetIntegerOpDataType(signed bool, size uint) OpDataType

func GetOpDataType

func GetOpDataType(t types.Type) OpDataType

func (OpDataType) String

func (optype OpDataType) String() string

type OpFlags

type OpFlags int
const (
	In OpFlags
	Out
	Implicit
	Const
	Imm8
	Imm32
	ImmF32
	ImmF64
)

type Operand

type Operand struct {
	Flags    OpFlags
	Reg      RegType
	NamedReg Reg
}

type Reg

type Reg int
const (
	REG_INVALID Reg = 1 << iota
	REG_AL
	REG_CL
	REG_DL
	REG_BL
	REG_AX
	REG_CX
	REG_DX
	REG_SI
	REG_DI
	REG_BX
	REG_BP
	REG_SP // SP (stack pointer) is a pseudo register
	REG_FP // FP (frame pointer) is a pseudo register
	REG_R8
	REG_R9
	REG_R10
	REG_R11
	REG_R12
	REG_R13
	REG_R14
	REG_R15
	REG_X0
	REG_X1
	REG_X2
	REG_X3
	REG_X4
	REG_X5
	REG_X6
	REG_X7
	REG_X8
	REG_X9
	REG_X10
	REG_X11
	REG_X12
	REG_X13
	REG_X14
	REG_X15
)

type RegType

type RegType int

func (RegType) String

func (r RegType) String() string

type SimdInstr

type SimdInstr int
const (
	SIMD_INVALID SimdInstr = iota
	// Integer
	AddI8x16
	SubI8x16
	AddI16x8
	SubI16x8
	MulI16x8
	ShlI16x8
	ShrI16x8
	AddI32x4
	SubI32x4
	MulI32x4
	ShlI32x4
	ShrI32x4
	ShuffleI32x4
	AddI64x2
	SubI64x2
	AddU8x16
	SubU8x16
	AddU16x8
	SubU16x8
	MulU16x8
	ShlU16x8
	ShrU16x8
	AddU32x4
	SubU32x4
	MulU32x4
	ShlU32x4
	ShrU32x4
	ShuffleU32x4
	AddU64x2
	SubU64x2
	AddF32x4
	SubF32x4
	MulF32x4
	DivF32x4
	AddF64x2
	SubF64x2
	MulF64x2
	DivF64x2
	LoadSi128
)

func (SimdInstr) String

func (i SimdInstr) String() string

type VarOp

type VarOp struct {
	Var   Variable
	Const int
	Op    Operand
}

type Variable

type Variable struct {
	VarType reflect.Type
}

type WrappedVal

type WrappedVal struct {
	ssa.Value
}

func (WrappedVal) Operands

func (wv WrappedVal) Operands(rands []*ssa.Value) []*ssa.Value

type XmmData

type XmmData int

func GetXmmVariant

func GetXmmVariant(t types.Type) XmmData

func (XmmData) String

func (i XmmData) String() string

type XmmInstruction

type XmmInstruction struct {
	XmmInstr InstructionType
	F32      Instruction // operates on single f32
	F64      Instruction // operates on single f64
	F32x4    Instruction // operates on four packed f32
	F64x2    Instruction // operate on two packed f64
}

func GetXmmInstruction

func GetXmmInstruction(tinst InstructionType) XmmInstruction

func (XmmInstruction) Select

func (xinstr XmmInstruction) Select(variant XmmData) Instruction

Jump to

Keyboard shortcuts

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