package amd64

import (
	

	
	
	
)

type instruction struct {
	prev, next          *instruction
	op1, op2            operand
	u1, u2              uint64
	b1                  bool
	addedBeforeRegAlloc bool
	kind                instructionKind
}

// IsCall implements regalloc.Instr.
func ( *instruction) () bool { return .kind == call }

// IsIndirectCall implements regalloc.Instr.
func ( *instruction) () bool { return .kind == callIndirect }

// IsReturn implements regalloc.Instr.
func ( *instruction) () bool { return .kind == ret }

// String implements regalloc.Instr.
func ( *instruction) () string {
	switch .kind {
	case nop0:
		return "nop"
	case sourceOffsetInfo:
		return fmt.Sprintf("source_offset_info %d", .u1)
	case ret:
		return "ret"
	case imm:
		if .b1 {
			return fmt.Sprintf("movabsq $%d, %s", int64(.u1), .op2.format(true))
		} else {
			return fmt.Sprintf("movl $%d, %s", int32(.u1), .op2.format(false))
		}
	case aluRmiR:
		return fmt.Sprintf("%s %s, %s", aluRmiROpcode(.u1), .op1.format(.b1), .op2.format(.b1))
	case movRR:
		if .b1 {
			return fmt.Sprintf("movq %s, %s", .op1.format(true), .op2.format(true))
		} else {
			return fmt.Sprintf("movl %s, %s", .op1.format(false), .op2.format(false))
		}
	case xmmRmR:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(false), .op2.format(false))
	case gprToXmm:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(.b1), .op2.format(.b1))
	case xmmUnaryRmR:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(false), .op2.format(false))
	case xmmUnaryRmRImm:
		return fmt.Sprintf("%s $%d, %s, %s", sseOpcode(.u1), roundingMode(.u2), .op1.format(false), .op2.format(false))
	case unaryRmR:
		var  string
		if .b1 {
			 = "q"
		} else {
			 = "l"
		}
		return fmt.Sprintf("%s%s %s, %s", unaryRmROpcode(.u1), , .op1.format(.b1), .op2.format(.b1))
	case not:
		var  string
		if .b1 {
			 = "notq"
		} else {
			 = "notl"
		}
		return fmt.Sprintf("%s %s", , .op1.format(.b1))
	case neg:
		var  string
		if .b1 {
			 = "negq"
		} else {
			 = "negl"
		}
		return fmt.Sprintf("%s %s", , .op1.format(.b1))
	case div:
		var  string
		var  string
		if .b1 {
			 = "divq"
		} else {
			 = "divl"
		}
		if .u1 != 0 {
			 = "i"
		}
		return fmt.Sprintf("%s%s %s", , , .op1.format(.b1))
	case mulHi:
		,  := .u1 != 0, .b1
		var  string
		switch {
		case  && :
			 = "imulq"
		case ! && :
			 = "mulq"
		case  && !:
			 = "imull"
		case ! && !:
			 = "mull"
		}
		return fmt.Sprintf("%s %s", , .op1.format(.b1))
	case signExtendData:
		var  string
		if .b1 {
			 = "cqo"
		} else {
			 = "cdq"
		}
		return 
	case movzxRmR:
		return fmt.Sprintf("movzx.%s %s, %s", extMode(.u1), .op1.format(true), .op2.format(true))
	case mov64MR:
		return fmt.Sprintf("movq %s, %s", .op1.format(true), .op2.format(true))
	case lea:
		return fmt.Sprintf("lea %s, %s", .op1.format(true), .op2.format(true))
	case movsxRmR:
		return fmt.Sprintf("movsx.%s %s, %s", extMode(.u1), .op1.format(true), .op2.format(true))
	case movRM:
		var  string
		switch .u1 {
		case 1:
			 = "b"
		case 2:
			 = "w"
		case 4:
			 = "l"
		case 8:
			 = "q"
		}
		return fmt.Sprintf("mov.%s %s, %s", , .op1.format(true), .op2.format(true))
	case shiftR:
		var  string
		if .b1 {
			 = "q"
		} else {
			 = "l"
		}
		return fmt.Sprintf("%s%s %s, %s", shiftROp(.u1), , .op1.format(false), .op2.format(.b1))
	case xmmRmiReg:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(true), .op2.format(true))
	case cmpRmiR:
		var ,  string
		if .u1 != 0 {
			 = "cmp"
		} else {
			 = "test"
		}
		if .b1 {
			 = "q"
		} else {
			 = "l"
		}
		if  == "test" && .op1.kind == operandKindMem {
			// Print consistently with AT&T syntax.
			return fmt.Sprintf("%s%s %s, %s", , , .op2.format(.b1), .op1.format(.b1))
		}
		return fmt.Sprintf("%s%s %s, %s", , , .op1.format(.b1), .op2.format(.b1))
	case setcc:
		return fmt.Sprintf("set%s %s", cond(.u1), .op2.format(true))
	case cmove:
		var  string
		if .b1 {
			 = "q"
		} else {
			 = "l"
		}
		return fmt.Sprintf("cmov%s%s %s, %s", cond(.u1), , .op1.format(.b1), .op2.format(.b1))
	case push64:
		return fmt.Sprintf("pushq %s", .op1.format(true))
	case pop64:
		return fmt.Sprintf("popq %s", .op1.format(true))
	case xmmMovRM:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(true), .op2.format(true))
	case xmmLoadConst:
		panic("TODO")
	case xmmToGpr:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(.b1), .op2.format(.b1))
	case cvtUint64ToFloatSeq:
		panic("TODO")
	case cvtFloatToSintSeq:
		panic("TODO")
	case cvtFloatToUintSeq:
		panic("TODO")
	case xmmMinMaxSeq:
		panic("TODO")
	case xmmCmpRmR:
		return fmt.Sprintf("%s %s, %s", sseOpcode(.u1), .op1.format(false), .op2.format(false))
	case xmmRmRImm:
		 := sseOpcode(.u1)
		,  := .op1.format( == sseOpcodePextrq ||  == sseOpcodePinsrq),
			.op2.format( == sseOpcodePextrq ||  == sseOpcodePinsrq)
		return fmt.Sprintf("%s $%d, %s, %s", , .u2, , )
	case jmp:
		return fmt.Sprintf("jmp %s", .op1.format(true))
	case jmpIf:
		return fmt.Sprintf("j%s %s", cond(.u1), .op1.format(true))
	case jmpTableIsland:
		return fmt.Sprintf("jump_table_island: jmp_table_index=%d", .u1)
	case exitSequence:
		return fmt.Sprintf("exit_sequence %s", .op1.format(true))
	case ud2:
		return "ud2"
	case call:
		return fmt.Sprintf("call %s", ssa.FuncRef(.u1))
	case callIndirect:
		return fmt.Sprintf("callq *%s", .op1.format(true))
	case xchg:
		var  string
		switch .u1 {
		case 1:
			 = "b"
		case 2:
			 = "w"
		case 4:
			 = "l"
		case 8:
			 = "q"
		}
		return fmt.Sprintf("xchg.%s %s, %s", , .op1.format(true), .op2.format(true))
	case zeros:
		return fmt.Sprintf("xor %s, %s", .op2.format(true), .op2.format(true))
	case fcvtToSintSequence:
		, , , , , , ,  := .fcvtToSintSequenceData()
		return fmt.Sprintf(
			"fcvtToSintSequence execCtx=%s, src=%s, tmpGp=%s, tmpGp2=%s, tmpXmm=%s, src64=%v, dst64=%v, sat=%v",
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true), , , )
	case fcvtToUintSequence:
		, , , , , , , ,  := .fcvtToUintSequenceData()
		return fmt.Sprintf(
			"fcvtToUintSequence execCtx=%s, src=%s, tmpGp=%s, tmpGp2=%s, tmpXmm=%s, tmpXmm2=%s, src64=%v, dst64=%v, sat=%v",
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true),
			formatVRegSized(, true), , , )
	case idivRemSequence:
		, , , , ,  := .idivRemSequenceData()
		return fmt.Sprintf("idivRemSequence execCtx=%s, divisor=%s, tmpGp=%s, isDiv=%v, signed=%v, _64=%v",
			formatVRegSized(, true), formatVRegSized(, ), formatVRegSized(, ), , , )
	case defineUninitializedReg:
		return fmt.Sprintf("defineUninitializedReg %s", .op2.format(true))
	case xmmCMov:
		return fmt.Sprintf("xmmcmov%s %s, %s", cond(.u1), .op1.format(true), .op2.format(true))
	case blendvpd:
		return fmt.Sprintf("blendvpd %s, %s, %%xmm0", .op1.format(false), .op2.format(false))
	case mfence:
		return "mfence"
	case lockcmpxchg:
		var  string
		switch .u1 {
		case 1:
			 = "b"
		case 2:
			 = "w"
		case 4:
			 = "l"
		case 8:
			 = "q"
		}
		return fmt.Sprintf("lock cmpxchg.%s %s, %s", , .op1.format(true), .op2.format(true))
	case lockxadd:
		var  string
		switch .u1 {
		case 1:
			 = "b"
		case 2:
			 = "w"
		case 4:
			 = "l"
		case 8:
			 = "q"
		}
		return fmt.Sprintf("lock xadd.%s %s, %s", , .op1.format(true), .op2.format(true))

	case nopUseReg:
		return fmt.Sprintf("nop_use_reg %s", .op1.format(true))

	default:
		panic(fmt.Sprintf("BUG: %d", int(.kind)))
	}
}

// Defs implements regalloc.Instr.
func ( *instruction) ( *[]regalloc.VReg) []regalloc.VReg {
	* = (*)[:0]
	switch  := defKinds[.kind];  {
	case defKindNone:
	case defKindOp2:
		* = append(*, .op2.reg())
	case defKindCall:
		, , , ,  := backend.ABIInfoFromUint64(.u2)
		for  := byte(0);  < ; ++ {
			* = append(*, regInfo.RealRegToVReg[intArgResultRegs[]])
		}
		for  := byte(0);  < ; ++ {
			* = append(*, regInfo.RealRegToVReg[floatArgResultRegs[]])
		}
	case defKindDivRem:
		, , , , ,  := .idivRemSequenceData()
		if  {
			* = append(*, raxVReg)
		} else {
			* = append(*, rdxVReg)
		}
	default:
		panic(fmt.Sprintf("BUG: invalid defKind \"%s\" for %s", , ))
	}
	return *
}

// Uses implements regalloc.Instr.
func ( *instruction) ( *[]regalloc.VReg) []regalloc.VReg {
	* = (*)[:0]
	switch  := useKinds[.kind];  {
	case useKindNone:
	case useKindOp1Op2Reg, useKindOp1RegOp2:
		,  := &.op1, &.op2
		if  == useKindOp1RegOp2 {
			,  = , 
		}
		// The destination operand (op2) can be only reg,
		// the source operand (op1) can be imm32, reg or mem.
		switch .kind {
		case operandKindReg:
			* = append(*, .reg())
		case operandKindMem:
			.addressMode().uses()
		case operandKindImm32:
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		if .kind != operandKindReg {
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		* = append(*, .reg())
	case useKindOp1:
		 := .op1
		switch .kind {
		case operandKindReg:
			* = append(*, .reg())
		case operandKindMem:
			.addressMode().uses()
		case operandKindImm32, operandKindLabel:
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
	case useKindCallInd:
		 := .op1
		switch .kind {
		case operandKindReg:
			* = append(*, .reg())
		case operandKindMem:
			.addressMode().uses()
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		fallthrough
	case useKindCall:
		, , , ,  := backend.ABIInfoFromUint64(.u2)
		for  := byte(0);  < ; ++ {
			* = append(*, regInfo.RealRegToVReg[intArgResultRegs[]])
		}
		for  := byte(0);  < ; ++ {
			* = append(*, regInfo.RealRegToVReg[floatArgResultRegs[]])
		}
	case useKindFcvtToSintSequence:
		, , , , , , ,  := .fcvtToSintSequenceData()
		* = append(*, , , , , )
	case useKindFcvtToUintSequence:
		, , , , , , , ,  := .fcvtToUintSequenceData()
		* = append(*, , , , , , )
	case useKindDivRem:
		, , , , ,  := .idivRemSequenceData()
		// idiv uses rax and rdx as implicit operands.
		* = append(*, raxVReg, rdxVReg, , , )
	case useKindBlendvpd:
		* = append(*, xmm0VReg)

		,  := &.op1, &.op2
		switch .kind {
		case operandKindReg:
			* = append(*, .reg())
		case operandKindMem:
			.addressMode().uses()
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		if .kind != operandKindReg {
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		* = append(*, .reg())

	case useKindRaxOp1RegOp2:
		,  := &.op1, &.op2
		* = append(*, raxVReg, .reg())
		switch .kind {
		case operandKindReg:
			* = append(*, .reg())
		case operandKindMem:
			.addressMode().uses()
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
		if .kind != operandKindReg {
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}

	default:
		panic(fmt.Sprintf("BUG: invalid useKind %s for %s", , ))
	}
	return *
}

// AssignUse implements regalloc.Instr.
func ( *instruction) ( int,  regalloc.VReg) {
	switch  := useKinds[.kind];  {
	case useKindNone:
	case useKindCallInd:
		if  != 0 {
			panic("BUG")
		}
		 := &.op1
		switch .kind {
		case operandKindReg:
			.setReg()
		case operandKindMem:
			.addressMode().assignUses(, )
		default:
			panic("BUG")
		}
	case useKindOp1Op2Reg, useKindOp1RegOp2:
		,  := &.op1, &.op2
		if  == useKindOp1RegOp2 {
			,  = , 
		}
		switch .kind {
		case operandKindReg:
			if  == 0 {
				.setReg()
			} else if  == 1 {
				.setReg()
			} else {
				panic("BUG")
			}
		case operandKindMem:
			 := .addressMode().nregs()
			if  <  {
				.addressMode().assignUses(, )
			} else if  ==  {
				.setReg()
			} else {
				panic("BUG")
			}
		case operandKindImm32:
			if  == 0 {
				.setReg()
			} else {
				panic("BUG")
			}
		default:
			panic(fmt.Sprintf("BUG: invalid operand pair: %s", ))
		}
	case useKindOp1:
		 := &.op1
		switch .kind {
		case operandKindReg:
			if  != 0 {
				panic("BUG")
			}
			.setReg()
		case operandKindMem:
			.addressMode().assignUses(, )
		default:
			panic(fmt.Sprintf("BUG: invalid operand: %s", ))
		}
	case useKindFcvtToSintSequence:
		switch  {
		case 0:
			.op1.addressMode().base = 
		case 1:
			.op1.addressMode().index = 
		case 2:
			.op2.addressMode().base = 
		case 3:
			.op2.addressMode().index = 
		case 4:
			.u1 = uint64()
		default:
			panic("BUG")
		}
	case useKindFcvtToUintSequence:
		switch  {
		case 0:
			.op1.addressMode().base = 
		case 1:
			.op1.addressMode().index = 
		case 2:
			.op2.addressMode().base = 
		case 3:
			.op2.addressMode().index = 
		case 4:
			.u1 = uint64()
		case 5:
			.u2 = uint64()
		default:
			panic("BUG")
		}
	case useKindDivRem:
		switch  {
		case 0:
			if  != raxVReg {
				panic("BUG")
			}
		case 1:
			if  != rdxVReg {
				panic("BUG")
			}
		case 2:
			.op1.setReg()
		case 3:
			.op2.setReg()
		case 4:
			.u1 = uint64()
		default:
			panic("BUG")
		}
	case useKindBlendvpd:
		,  := &.op1, &.op2
		if  == 0 {
			if .RealReg() != xmm0 {
				panic("BUG")
			}
		} else {
			switch .kind {
			case operandKindReg:
				switch  {
				case 1:
					.setReg()
				case 2:
					.setReg()
				default:
					panic("BUG")
				}
			case operandKindMem:
				 := .addressMode().nregs()
				--
				if  <  {
					.addressMode().assignUses(, )
				} else if  ==  {
					.setReg()
				} else {
					panic("BUG")
				}
			default:
				panic(fmt.Sprintf("BUG: invalid operand pair: %s", ))
			}
		}

	case useKindRaxOp1RegOp2:
		switch  {
		case 0:
			if .RealReg() != rax {
				panic("BUG")
			}
		case 1:
			.op1.setReg()
		default:
			 := &.op2
			switch .kind {
			case operandKindReg:
				switch  {
				case 1:
					.setReg()
				case 2:
					.setReg()
				default:
					panic("BUG")
				}
			case operandKindMem:
				 := .addressMode().nregs()
				 -= 2
				if  <  {
					.addressMode().assignUses(, )
				} else if  ==  {
					.setReg()
				} else {
					panic("BUG")
				}
			default:
				panic(fmt.Sprintf("BUG: invalid operand pair: %s", ))
			}
		}
	default:
		panic(fmt.Sprintf("BUG: invalid useKind %s for %s", , ))
	}
}

// AssignDef implements regalloc.Instr.
func ( *instruction) ( regalloc.VReg) {
	switch  := defKinds[.kind];  {
	case defKindNone:
	case defKindOp2:
		.op2.setReg()
	default:
		panic(fmt.Sprintf("BUG: invalid defKind \"%s\" for %s", , ))
	}
}

// IsCopy implements regalloc.Instr.
func ( *instruction) () bool {
	 := .kind
	if  == movRR {
		return true
	}
	if  == xmmUnaryRmR {
		if .op1.kind == operandKindReg {
			 := sseOpcode(.u1)
			return  == sseOpcodeMovss ||  == sseOpcodeMovsd ||  == sseOpcodeMovdqu
		}
	}
	return false
}

func resetInstruction( *instruction) {
	* = instruction{}
}

func ( *instruction) ( label) *instruction { //nolint
	.kind = nop0
	.u1 = uint64()
	return 
}

func ( *instruction) () label {
	return label(.u1)
}

type instructionKind byte

const (
	nop0 instructionKind = iota + 1

	// Integer arithmetic/bit-twiddling: (add sub and or xor mul, etc.) (32 64) (reg addr imm) reg
	aluRmiR

	// Instructions on GPR that only read src and defines dst (dst is not modified): bsr, etc.
	unaryRmR

	// Bitwise not
	not

	// Integer negation
	neg

	// Integer quotient and remainder: (div idiv) $rax $rdx (reg addr)
	div

	// The high bits (RDX) of a (un)signed multiply: RDX:RAX := RAX * rhs.
	mulHi

	// Do a sign-extend based on the sign of the value in rax into rdx: (cwd cdq cqo)
	// or al into ah: (cbw)
	signExtendData

	// Constant materialization: (imm32 imm64) reg.
	// Either: movl $imm32, %reg32 or movabsq $imm64, %reg64.
	imm

	// GPR to GPR move: mov (64 32) reg reg.
	movRR

	// movzxRmR is zero-extended loads or move (R to R), except for 64 bits: movz (bl bq wl wq lq) addr reg.
	// Note that the lq variant doesn't really exist since the default zero-extend rule makes it
	// unnecessary. For that case we emit the equivalent "movl AM, reg32".
	movzxRmR

	// mov64MR is a plain 64-bit integer load, since movzxRmR can't represent that.
	mov64MR

	// Loads the memory address of addr into dst.
	lea

	// Sign-extended loads and moves: movs (bl bq wl wq lq) addr reg.
	movsxRmR

	// Integer stores: mov (b w l q) reg addr.
	movRM

	// Arithmetic shifts: (shl shr sar) (b w l q) imm reg.
	shiftR

	// Arithmetic SIMD shifts.
	xmmRmiReg

	// Integer comparisons/tests: cmp or test (b w l q) (reg addr imm) reg.
	cmpRmiR

	// Materializes the requested condition code in the destination reg.
	setcc

	// Integer conditional move.
	// Overwrites the destination register.
	cmove

	// pushq (reg addr imm)
	push64

	// popq reg
	pop64

	// XMM (scalar or vector) binary op: (add sub and or xor mul adc? sbb?) (32 64) (reg addr) reg
	xmmRmR

	// XMM (scalar or vector) unary op: mov between XMM registers (32 64) (reg addr) reg.
	//
	// This differs from xmmRmR in that the dst register of xmmUnaryRmR is not used in the
	// computation of the instruction dst value and so does not have to be a previously valid
	// value. This is characteristic of mov instructions.
	xmmUnaryRmR

	// XMM (scalar or vector) unary op with immediate: roundss, roundsd, etc.
	//
	// This differs from XMM_RM_R_IMM in that the dst register of
	// XmmUnaryRmRImm is not used in the computation of the instruction dst
	// value and so does not have to be a previously valid value.
	xmmUnaryRmRImm

	// XMM (scalar or vector) unary op (from xmm to mem): stores, movd, movq
	xmmMovRM

	// XMM (vector) unary op (to move a constant value into an xmm register): movups
	xmmLoadConst

	// XMM (scalar) unary op (from xmm to integer reg): movd, movq, cvtts{s,d}2si
	xmmToGpr

	// XMM (scalar) unary op (from integer to float reg): movd, movq, cvtsi2s{s,d}
	gprToXmm

	// Converts an unsigned int64 to a float32/float64.
	cvtUint64ToFloatSeq

	// Converts a scalar xmm to a signed int32/int64.
	cvtFloatToSintSeq

	// Converts a scalar xmm to an unsigned int32/int64.
	cvtFloatToUintSeq

	// A sequence to compute min/max with the proper NaN semantics for xmm registers.
	xmmMinMaxSeq

	// Float comparisons/tests: cmp (b w l q) (reg addr imm) reg.
	xmmCmpRmR

	// A binary XMM instruction with an 8-bit immediate: e.g. cmp (ps pd) imm (reg addr) reg
	xmmRmRImm

	// Direct call: call simm32.
	// Note that the offset is the relative to the *current RIP*, which points to the first byte of the next instruction.
	call

	// Indirect call: callq (reg mem).
	callIndirect

	// Return.
	ret

	// Jump: jmp (reg, mem, imm32 or label)
	jmp

	// Jump conditionally: jcond cond label.
	jmpIf

	// jmpTableIsland is to emit the jump table.
	jmpTableIsland

	// exitSequence exits the execution and go back to the Go world.
	exitSequence

	// An instruction that will always trigger the illegal instruction exception.
	ud2

	// xchg is described in https://www.felixcloutier.com/x86/xchg.
	// This instruction uses two operands, where one of them can be a memory address, and swaps their values.
	// If the dst is a memory address, the execution is atomic.
	xchg

	// lockcmpxchg is the cmpxchg instruction https://www.felixcloutier.com/x86/cmpxchg with a lock prefix.
	lockcmpxchg

	// zeros puts zeros into the destination register. This is implemented as xor reg, reg for
	// either integer or XMM registers. The reason why we have this instruction instead of using aluRmiR
	// is that it requires the already-defined registers. From reg alloc's perspective, this defines
	// the destination register and takes no inputs.
	zeros

	// sourceOffsetInfo is a dummy instruction to emit source offset info.
	// The existence of this instruction does not affect the execution.
	sourceOffsetInfo

	// defineUninitializedReg is a no-op instruction that defines a register without a defining instruction.
	defineUninitializedReg

	// fcvtToSintSequence is a sequence of instructions to convert a float to a signed integer.
	fcvtToSintSequence

	// fcvtToUintSequence is a sequence of instructions to convert a float to an unsigned integer.
	fcvtToUintSequence

	// xmmCMov is a conditional move instruction for XMM registers. Lowered after register allocation.
	xmmCMov

	// idivRemSequence is a sequence of instructions to compute both the quotient and remainder of a division.
	idivRemSequence

	// blendvpd is https://www.felixcloutier.com/x86/blendvpd.
	blendvpd

	// mfence is https://www.felixcloutier.com/x86/mfence
	mfence

	// lockxadd is xadd https://www.felixcloutier.com/x86/xadd with a lock prefix.
	lockxadd

	// nopUseReg is a meta instruction that uses one register and does nothing.
	nopUseReg

	instrMax
)

func ( *instruction) () *instruction {
	.kind = mfence
	return 
}

func ( *instruction) ( regalloc.VReg) *instruction {
	.kind = nopUseReg
	.op1 = newOperandReg()
	return 
}

func ( *instruction) (, ,  regalloc.VReg, , ,  bool) *instruction {
	.kind = idivRemSequence
	.op1 = newOperandReg()
	.op2 = newOperandReg()
	.u1 = uint64()
	if  {
		.u2 |= 1
	}
	if  {
		.u2 |= 2
	}
	if  {
		.u2 |= 4
	}
	return 
}

func ( *instruction) () (
	, ,  regalloc.VReg, , ,  bool,
) {
	if .kind != idivRemSequence {
		panic("BUG")
	}
	return .op1.reg(), .op2.reg(), regalloc.VReg(.u1), .u2&1 != 0, .u2&2 != 0, .u2&4 != 0
}

func ( *instruction) ( cond,  operand,  regalloc.VReg,  byte) *instruction {
	.kind = xmmCMov
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.u2 = uint64()
	return 
}

func ( *instruction) ( regalloc.VReg) *instruction {
	.kind = defineUninitializedReg
	.op2 = newOperandReg()
	return 
}

func ( *machine) (
	, , , , ,  regalloc.VReg,
	, ,  bool,
) *instruction {
	 := .allocateInstr()
	.kind = fcvtToUintSequence
	 := .amodePool.Allocate()
	 := .amodePool.Allocate()
	.op1 = newOperandMem()
	.op2 = newOperandMem()
	if  {
		.imm32 = 1
	} else {
		.imm32 = 0
	}
	if  {
		.imm32 |= 2
	}
	if  {
		.imm32 |= 4
	}

	.base = 
	.index = 
	.base = 
	.index = 
	.u1 = uint64()
	.u2 = uint64()
	return 
}

func ( *instruction) () (
	, , , , ,  regalloc.VReg, , ,  bool,
) {
	if .kind != fcvtToUintSequence {
		panic("BUG")
	}
	 := .op1.addressMode()
	 := .op2.addressMode()
	return .base, .index, .base, .index, regalloc.VReg(.u1), regalloc.VReg(.u2),
		.imm32&1 != 0, .imm32&2 != 0, .imm32&4 != 0
}

func ( *machine) (
	, , , ,  regalloc.VReg,
	, ,  bool,
) *instruction {
	 := .allocateInstr()
	.kind = fcvtToSintSequence
	 := .amodePool.Allocate()
	 := .amodePool.Allocate()
	.op1 = newOperandMem()
	.op2 = newOperandMem()
	.base = 
	.index = 
	.base = 
	.index = 
	.u1 = uint64()
	if  {
		.u2 = 1
	} else {
		.u2 = 0
	}
	if  {
		.u2 |= 2
	}
	if  {
		.u2 |= 4
	}
	return 
}

func ( *instruction) () (
	, , , ,  regalloc.VReg, , ,  bool,
) {
	if .kind != fcvtToSintSequence {
		panic("BUG")
	}
	 := .op1.addressMode()
	 := .op2.addressMode()
	return .base, .index, .base, .index, regalloc.VReg(.u1),
		.u2&1 != 0, .u2&2 != 0, .u2&4 != 0
}

func ( instructionKind) () string {
	switch  {
	case nop0:
		return "nop"
	case ret:
		return "ret"
	case imm:
		return "imm"
	case aluRmiR:
		return "aluRmiR"
	case movRR:
		return "movRR"
	case xmmRmR:
		return "xmmRmR"
	case gprToXmm:
		return "gprToXmm"
	case xmmUnaryRmR:
		return "xmmUnaryRmR"
	case xmmUnaryRmRImm:
		return "xmmUnaryRmRImm"
	case unaryRmR:
		return "unaryRmR"
	case not:
		return "not"
	case neg:
		return "neg"
	case div:
		return "div"
	case mulHi:
		return "mulHi"
	case signExtendData:
		return "signExtendData"
	case movzxRmR:
		return "movzxRmR"
	case mov64MR:
		return "mov64MR"
	case lea:
		return "lea"
	case movsxRmR:
		return "movsxRmR"
	case movRM:
		return "movRM"
	case shiftR:
		return "shiftR"
	case xmmRmiReg:
		return "xmmRmiReg"
	case cmpRmiR:
		return "cmpRmiR"
	case setcc:
		return "setcc"
	case cmove:
		return "cmove"
	case push64:
		return "push64"
	case pop64:
		return "pop64"
	case xmmMovRM:
		return "xmmMovRM"
	case xmmLoadConst:
		return "xmmLoadConst"
	case xmmToGpr:
		return "xmmToGpr"
	case cvtUint64ToFloatSeq:
		return "cvtUint64ToFloatSeq"
	case cvtFloatToSintSeq:
		return "cvtFloatToSintSeq"
	case cvtFloatToUintSeq:
		return "cvtFloatToUintSeq"
	case xmmMinMaxSeq:
		return "xmmMinMaxSeq"
	case xmmCmpRmR:
		return "xmmCmpRmR"
	case xmmRmRImm:
		return "xmmRmRImm"
	case jmpIf:
		return "jmpIf"
	case jmp:
		return "jmp"
	case jmpTableIsland:
		return "jmpTableIsland"
	case exitSequence:
		return "exit_sequence"
	case ud2:
		return "ud2"
	case xchg:
		return "xchg"
	case zeros:
		return "zeros"
	case fcvtToSintSequence:
		return "fcvtToSintSequence"
	case fcvtToUintSequence:
		return "fcvtToUintSequence"
	case xmmCMov:
		return "xmmCMov"
	case idivRemSequence:
		return "idivRemSequence"
	case mfence:
		return "mfence"
	case lockcmpxchg:
		return "lockcmpxchg"
	case lockxadd:
		return "lockxadd"
	default:
		panic("BUG")
	}
}

type aluRmiROpcode byte

const (
	aluRmiROpcodeAdd aluRmiROpcode = iota + 1
	aluRmiROpcodeSub
	aluRmiROpcodeAnd
	aluRmiROpcodeOr
	aluRmiROpcodeXor
	aluRmiROpcodeMul
)

func ( aluRmiROpcode) () string {
	switch  {
	case aluRmiROpcodeAdd:
		return "add"
	case aluRmiROpcodeSub:
		return "sub"
	case aluRmiROpcodeAnd:
		return "and"
	case aluRmiROpcodeOr:
		return "or"
	case aluRmiROpcodeXor:
		return "xor"
	case aluRmiROpcodeMul:
		return "imul"
	default:
		panic("BUG")
	}
}

func ( *instruction) ( cond,  operand) *instruction {
	.kind = jmpIf
	.u1 = uint64()
	.op1 = 
	return 
}

// asJmpTableSequence is used to emit the jump table.
// targetSliceIndex is the index of the target slice in machine.jmpTableTargets.
func ( *instruction) ( int,  int) *instruction {
	.kind = jmpTableIsland
	.u1 = uint64()
	.u2 = uint64()
	return 
}

func ( *instruction) ( operand) *instruction {
	.kind = jmp
	.op1 = 
	return 
}

func ( *instruction) () label {
	switch .kind {
	case jmp, jmpIf, lea, xmmUnaryRmR:
		return .op1.label()
	default:
		panic("BUG")
	}
}

func ( *instruction) ( operand,  regalloc.VReg) *instruction {
	.kind = lea
	.op1 = 
	.op2 = newOperandReg()
	return 
}

func ( *instruction) ( ssa.FuncRef,  *backend.FunctionABI) *instruction {
	.kind = call
	.u1 = uint64()
	if  != nil {
		.u2 = .ABIInfoAsUint64()
	}
	return 
}

func ( *instruction) ( operand,  *backend.FunctionABI) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = callIndirect
	.op1 = 
	if  != nil {
		.u2 = .ABIInfoAsUint64()
	}
	return 
}

func ( *instruction) () *instruction {
	.kind = ret
	return 
}

func ( *instruction) ( regalloc.VReg,  uint64,  bool) *instruction {
	.kind = imm
	.op2 = newOperandReg()
	.u1 = 
	.b1 = 
	return 
}

func ( *instruction) ( aluRmiROpcode,  operand,  regalloc.VReg,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem && .kind != operandKindImm32 {
		panic("BUG")
	}
	.kind = aluRmiR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *instruction) ( regalloc.VReg) *instruction {
	.kind = zeros
	.op2 = newOperandReg()
	return 
}

func ( *instruction) ( operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = blendvpd
	.op1 = 
	.op2 = newOperandReg()
	return 
}

func ( *instruction) ( sseOpcode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( sseOpcode,  uint8,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmRmRImm
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.u2 = uint64()
	return 
}

func ( *instruction) ( sseOpcode,  operand,  regalloc.VReg,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = gprToXmm
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *instruction) ( ssa.SourceOffset) *instruction {
	.kind = sourceOffsetInfo
	.u1 = uint64()
	return 
}

func ( *instruction) () ssa.SourceOffset {
	return ssa.SourceOffset(.u1)
}

func ( *instruction) ( sseOpcode, ,  regalloc.VReg,  bool) *instruction {
	.kind = xmmToGpr
	.op1 = newOperandReg()
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *instruction) ( regalloc.VReg,  operand,  byte) *instruction {
	if .kind != operandKindMem {
		panic("BUG")
	}
	.kind = movRM
	.op1 = newOperandReg()
	.op2 = 
	.u1 = uint64()
	return 
}

func ( *instruction) ( extMode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = movsxRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( extMode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = movzxRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( bool) *instruction {
	.kind = signExtendData
	.b1 = 
	return 
}

func ( *instruction) () *instruction {
	.kind = ud2
	return 
}

func ( *instruction) ( operand,  bool,  bool) *instruction {
	.kind = div
	.op1 = 
	.b1 = 
	if  {
		.u1 = 1
	}
	return 
}

func ( *instruction) ( operand,  regalloc.VReg) *instruction {
	if .kind != operandKindMem {
		panic("BUG")
	}
	.kind = mov64MR
	.op1 = 
	.op2 = newOperandReg()
	return 
}

func ( *instruction) (,  regalloc.VReg,  bool) *instruction {
	.kind = movRR
	.op1 = newOperandReg()
	.op2 = newOperandReg()
	.b1 = 
	return 
}

func ( *instruction) ( operand,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = not
	.op1 = 
	.b1 = 
	return 
}

func ( *instruction) ( operand,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = neg
	.op1 = 
	.b1 = 
	return 
}

func ( *instruction) ( operand, ,  bool) *instruction {
	if .kind != operandKindReg && (.kind != operandKindMem) {
		panic("BUG")
	}
	.kind = mulHi
	.op1 = 
	.b1 = 
	if  {
		.u1 = 1
	}
	return 
}

func ( *instruction) ( unaryRmROpcode,  operand,  regalloc.VReg,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = unaryRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *instruction) ( shiftROp,  operand,  regalloc.VReg,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindImm32 {
		panic("BUG")
	}
	.kind = shiftR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *instruction) ( sseOpcode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindImm32 && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmRmiReg
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( bool,  operand,  regalloc.VReg,  bool) *instruction {
	if .kind != operandKindReg && .kind != operandKindImm32 && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = cmpRmiR
	.op1 = 
	.op2 = newOperandReg()
	if  {
		.u1 = 1
	}
	.b1 = 
	return 
}

func ( *instruction) ( cond,  regalloc.VReg) *instruction {
	.kind = setcc
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( cond,  operand,  regalloc.VReg,  bool) *instruction {
	.kind = cmove
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.b1 = 
	return 
}

func ( *machine) ( regalloc.VReg) *instruction {
	 := .allocateInstr()
	.kind = exitSequence
	.op1 = newOperandReg()
	// Allocate the address mode that will be used in encoding the exit sequence.
	.op2 = newOperandMem(.amodePool.Allocate())
	return 
}

func ( *instruction) ( sseOpcode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmUnaryRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( sseOpcode,  byte,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmUnaryRmRImm
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	.u2 = uint64()
	return 
}

func ( *instruction) ( sseOpcode,  operand,  regalloc.VReg) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmCmpRmR
	.op1 = 
	.op2 = newOperandReg()
	.u1 = uint64()
	return 
}

func ( *instruction) ( sseOpcode,  regalloc.VReg,  operand) *instruction {
	if .kind != operandKindMem {
		panic("BUG")
	}
	.kind = xmmMovRM
	.op1 = newOperandReg()
	.op2 = 
	.u1 = uint64()
	return 
}

func ( *instruction) ( regalloc.VReg) *instruction {
	.kind = pop64
	.op1 = newOperandReg()
	return 
}

func ( *instruction) ( operand) *instruction {
	if .kind != operandKindReg && .kind != operandKindMem && .kind != operandKindImm32 {
		panic("BUG")
	}
	.kind = push64
	.op1 = 
	return 
}

func ( *instruction) ( regalloc.VReg,  operand,  byte) *instruction {
	.kind = xchg
	.op1 = newOperandReg()
	.op2 = 
	.u1 = uint64()
	return 
}

func ( *instruction) ( regalloc.VReg,  *amode,  byte) *instruction {
	.kind = lockcmpxchg
	.op1 = newOperandReg()
	.op2 = newOperandMem()
	.u1 = uint64()
	return 
}

func ( *instruction) ( regalloc.VReg,  *amode,  byte) *instruction {
	.kind = lockxadd
	.op1 = newOperandReg()
	.op2 = newOperandMem()
	.u1 = uint64()
	return 
}

type unaryRmROpcode byte

const (
	unaryRmROpcodeBsr unaryRmROpcode = iota
	unaryRmROpcodeBsf
	unaryRmROpcodeLzcnt
	unaryRmROpcodeTzcnt
	unaryRmROpcodePopcnt
)

func ( unaryRmROpcode) () string {
	switch  {
	case unaryRmROpcodeBsr:
		return "bsr"
	case unaryRmROpcodeBsf:
		return "bsf"
	case unaryRmROpcodeLzcnt:
		return "lzcnt"
	case unaryRmROpcodeTzcnt:
		return "tzcnt"
	case unaryRmROpcodePopcnt:
		return "popcnt"
	default:
		panic("BUG")
	}
}

type shiftROp byte

const (
	shiftROpRotateLeft           shiftROp = 0
	shiftROpRotateRight          shiftROp = 1
	shiftROpShiftLeft            shiftROp = 4
	shiftROpShiftRightLogical    shiftROp = 5
	shiftROpShiftRightArithmetic shiftROp = 7
)

func ( shiftROp) () string {
	switch  {
	case shiftROpRotateLeft:
		return "rol"
	case shiftROpRotateRight:
		return "ror"
	case shiftROpShiftLeft:
		return "shl"
	case shiftROpShiftRightLogical:
		return "shr"
	case shiftROpShiftRightArithmetic:
		return "sar"
	default:
		panic("BUG")
	}
}

type sseOpcode byte

const (
	sseOpcodeInvalid sseOpcode = iota
	sseOpcodeAddps
	sseOpcodeAddpd
	sseOpcodeAddss
	sseOpcodeAddsd
	sseOpcodeAndps
	sseOpcodeAndpd
	sseOpcodeAndnps
	sseOpcodeAndnpd
	sseOpcodeBlendvps
	sseOpcodeBlendvpd
	sseOpcodeComiss
	sseOpcodeComisd
	sseOpcodeCmpps
	sseOpcodeCmppd
	sseOpcodeCmpss
	sseOpcodeCmpsd
	sseOpcodeCvtdq2ps
	sseOpcodeCvtdq2pd
	sseOpcodeCvtsd2ss
	sseOpcodeCvtsd2si
	sseOpcodeCvtsi2ss
	sseOpcodeCvtsi2sd
	sseOpcodeCvtss2si
	sseOpcodeCvtss2sd
	sseOpcodeCvttps2dq
	sseOpcodeCvttss2si
	sseOpcodeCvttsd2si
	sseOpcodeDivps
	sseOpcodeDivpd
	sseOpcodeDivss
	sseOpcodeDivsd
	sseOpcodeInsertps
	sseOpcodeMaxps
	sseOpcodeMaxpd
	sseOpcodeMaxss
	sseOpcodeMaxsd
	sseOpcodeMinps
	sseOpcodeMinpd
	sseOpcodeMinss
	sseOpcodeMinsd
	sseOpcodeMovaps
	sseOpcodeMovapd
	sseOpcodeMovd
	sseOpcodeMovdqa
	sseOpcodeMovdqu
	sseOpcodeMovlhps
	sseOpcodeMovmskps
	sseOpcodeMovmskpd
	sseOpcodeMovq
	sseOpcodeMovss
	sseOpcodeMovsd
	sseOpcodeMovups
	sseOpcodeMovupd
	sseOpcodeMulps
	sseOpcodeMulpd
	sseOpcodeMulss
	sseOpcodeMulsd
	sseOpcodeOrps
	sseOpcodeOrpd
	sseOpcodePabsb
	sseOpcodePabsw
	sseOpcodePabsd
	sseOpcodePackssdw
	sseOpcodePacksswb
	sseOpcodePackusdw
	sseOpcodePackuswb
	sseOpcodePaddb
	sseOpcodePaddd
	sseOpcodePaddq
	sseOpcodePaddw
	sseOpcodePaddsb
	sseOpcodePaddsw
	sseOpcodePaddusb
	sseOpcodePaddusw
	sseOpcodePalignr
	sseOpcodePand
	sseOpcodePandn
	sseOpcodePavgb
	sseOpcodePavgw
	sseOpcodePcmpeqb
	sseOpcodePcmpeqw
	sseOpcodePcmpeqd
	sseOpcodePcmpeqq
	sseOpcodePcmpgtb
	sseOpcodePcmpgtw
	sseOpcodePcmpgtd
	sseOpcodePcmpgtq
	sseOpcodePextrb
	sseOpcodePextrw
	sseOpcodePextrd
	sseOpcodePextrq
	sseOpcodePinsrb
	sseOpcodePinsrw
	sseOpcodePinsrd
	sseOpcodePinsrq
	sseOpcodePmaddwd
	sseOpcodePmaxsb
	sseOpcodePmaxsw
	sseOpcodePmaxsd
	sseOpcodePmaxub
	sseOpcodePmaxuw
	sseOpcodePmaxud
	sseOpcodePminsb
	sseOpcodePminsw
	sseOpcodePminsd
	sseOpcodePminub
	sseOpcodePminuw
	sseOpcodePminud
	sseOpcodePmovmskb
	sseOpcodePmovsxbd
	sseOpcodePmovsxbw
	sseOpcodePmovsxbq
	sseOpcodePmovsxwd
	sseOpcodePmovsxwq
	sseOpcodePmovsxdq
	sseOpcodePmovzxbd
	sseOpcodePmovzxbw
	sseOpcodePmovzxbq
	sseOpcodePmovzxwd
	sseOpcodePmovzxwq
	sseOpcodePmovzxdq
	sseOpcodePmulld
	sseOpcodePmullw
	sseOpcodePmuludq
	sseOpcodePor
	sseOpcodePshufb
	sseOpcodePshufd
	sseOpcodePsllw
	sseOpcodePslld
	sseOpcodePsllq
	sseOpcodePsraw
	sseOpcodePsrad
	sseOpcodePsrlw
	sseOpcodePsrld
	sseOpcodePsrlq
	sseOpcodePsubb
	sseOpcodePsubd
	sseOpcodePsubq
	sseOpcodePsubw
	sseOpcodePsubsb
	sseOpcodePsubsw
	sseOpcodePsubusb
	sseOpcodePsubusw
	sseOpcodePtest
	sseOpcodePunpckhbw
	sseOpcodePunpcklbw
	sseOpcodePxor
	sseOpcodeRcpss
	sseOpcodeRoundps
	sseOpcodeRoundpd
	sseOpcodeRoundss
	sseOpcodeRoundsd
	sseOpcodeRsqrtss
	sseOpcodeSqrtps
	sseOpcodeSqrtpd
	sseOpcodeSqrtss
	sseOpcodeSqrtsd
	sseOpcodeSubps
	sseOpcodeSubpd
	sseOpcodeSubss
	sseOpcodeSubsd
	sseOpcodeUcomiss
	sseOpcodeUcomisd
	sseOpcodeXorps
	sseOpcodeXorpd
	sseOpcodePmulhrsw
	sseOpcodeUnpcklps
	sseOpcodeCvtps2pd
	sseOpcodeCvtpd2ps
	sseOpcodeCvttpd2dq
	sseOpcodeShufps
	sseOpcodePmaddubsw
)

func ( sseOpcode) () string {
	switch  {
	case sseOpcodeInvalid:
		return "invalid"
	case sseOpcodeAddps:
		return "addps"
	case sseOpcodeAddpd:
		return "addpd"
	case sseOpcodeAddss:
		return "addss"
	case sseOpcodeAddsd:
		return "addsd"
	case sseOpcodeAndps:
		return "andps"
	case sseOpcodeAndpd:
		return "andpd"
	case sseOpcodeAndnps:
		return "andnps"
	case sseOpcodeAndnpd:
		return "andnpd"
	case sseOpcodeBlendvps:
		return "blendvps"
	case sseOpcodeBlendvpd:
		return "blendvpd"
	case sseOpcodeComiss:
		return "comiss"
	case sseOpcodeComisd:
		return "comisd"
	case sseOpcodeCmpps:
		return "cmpps"
	case sseOpcodeCmppd:
		return "cmppd"
	case sseOpcodeCmpss:
		return "cmpss"
	case sseOpcodeCmpsd:
		return "cmpsd"
	case sseOpcodeCvtdq2ps:
		return "cvtdq2ps"
	case sseOpcodeCvtdq2pd:
		return "cvtdq2pd"
	case sseOpcodeCvtsd2ss:
		return "cvtsd2ss"
	case sseOpcodeCvtsd2si:
		return "cvtsd2si"
	case sseOpcodeCvtsi2ss:
		return "cvtsi2ss"
	case sseOpcodeCvtsi2sd:
		return "cvtsi2sd"
	case sseOpcodeCvtss2si:
		return "cvtss2si"
	case sseOpcodeCvtss2sd:
		return "cvtss2sd"
	case sseOpcodeCvttps2dq:
		return "cvttps2dq"
	case sseOpcodeCvttss2si:
		return "cvttss2si"
	case sseOpcodeCvttsd2si:
		return "cvttsd2si"
	case sseOpcodeDivps:
		return "divps"
	case sseOpcodeDivpd:
		return "divpd"
	case sseOpcodeDivss:
		return "divss"
	case sseOpcodeDivsd:
		return "divsd"
	case sseOpcodeInsertps:
		return "insertps"
	case sseOpcodeMaxps:
		return "maxps"
	case sseOpcodeMaxpd:
		return "maxpd"
	case sseOpcodeMaxss:
		return "maxss"
	case sseOpcodeMaxsd:
		return "maxsd"
	case sseOpcodeMinps:
		return "minps"
	case sseOpcodeMinpd:
		return "minpd"
	case sseOpcodeMinss:
		return "minss"
	case sseOpcodeMinsd:
		return "minsd"
	case sseOpcodeMovaps:
		return "movaps"
	case sseOpcodeMovapd:
		return "movapd"
	case sseOpcodeMovd:
		return "movd"
	case sseOpcodeMovdqa:
		return "movdqa"
	case sseOpcodeMovdqu:
		return "movdqu"
	case sseOpcodeMovlhps:
		return "movlhps"
	case sseOpcodeMovmskps:
		return "movmskps"
	case sseOpcodeMovmskpd:
		return "movmskpd"
	case sseOpcodeMovq:
		return "movq"
	case sseOpcodeMovss:
		return "movss"
	case sseOpcodeMovsd:
		return "movsd"
	case sseOpcodeMovups:
		return "movups"
	case sseOpcodeMovupd:
		return "movupd"
	case sseOpcodeMulps:
		return "mulps"
	case sseOpcodeMulpd:
		return "mulpd"
	case sseOpcodeMulss:
		return "mulss"
	case sseOpcodeMulsd:
		return "mulsd"
	case sseOpcodeOrps:
		return "orps"
	case sseOpcodeOrpd:
		return "orpd"
	case sseOpcodePabsb:
		return "pabsb"
	case sseOpcodePabsw:
		return "pabsw"
	case sseOpcodePabsd:
		return "pabsd"
	case sseOpcodePackssdw:
		return "packssdw"
	case sseOpcodePacksswb:
		return "packsswb"
	case sseOpcodePackusdw:
		return "packusdw"
	case sseOpcodePackuswb:
		return "packuswb"
	case sseOpcodePaddb:
		return "paddb"
	case sseOpcodePaddd:
		return "paddd"
	case sseOpcodePaddq:
		return "paddq"
	case sseOpcodePaddw:
		return "paddw"
	case sseOpcodePaddsb:
		return "paddsb"
	case sseOpcodePaddsw:
		return "paddsw"
	case sseOpcodePaddusb:
		return "paddusb"
	case sseOpcodePaddusw:
		return "paddusw"
	case sseOpcodePalignr:
		return "palignr"
	case sseOpcodePand:
		return "pand"
	case sseOpcodePandn:
		return "pandn"
	case sseOpcodePavgb:
		return "pavgb"
	case sseOpcodePavgw:
		return "pavgw"
	case sseOpcodePcmpeqb:
		return "pcmpeqb"
	case sseOpcodePcmpeqw:
		return "pcmpeqw"
	case sseOpcodePcmpeqd:
		return "pcmpeqd"
	case sseOpcodePcmpeqq:
		return "pcmpeqq"
	case sseOpcodePcmpgtb:
		return "pcmpgtb"
	case sseOpcodePcmpgtw:
		return "pcmpgtw"
	case sseOpcodePcmpgtd:
		return "pcmpgtd"
	case sseOpcodePcmpgtq:
		return "pcmpgtq"
	case sseOpcodePextrb:
		return "pextrb"
	case sseOpcodePextrw:
		return "pextrw"
	case sseOpcodePextrd:
		return "pextrd"
	case sseOpcodePextrq:
		return "pextrq"
	case sseOpcodePinsrb:
		return "pinsrb"
	case sseOpcodePinsrw:
		return "pinsrw"
	case sseOpcodePinsrd:
		return "pinsrd"
	case sseOpcodePinsrq:
		return "pinsrq"
	case sseOpcodePmaddwd:
		return "pmaddwd"
	case sseOpcodePmaxsb:
		return "pmaxsb"
	case sseOpcodePmaxsw:
		return "pmaxsw"
	case sseOpcodePmaxsd:
		return "pmaxsd"
	case sseOpcodePmaxub:
		return "pmaxub"
	case sseOpcodePmaxuw:
		return "pmaxuw"
	case sseOpcodePmaxud:
		return "pmaxud"
	case sseOpcodePminsb:
		return "pminsb"
	case sseOpcodePminsw:
		return "pminsw"
	case sseOpcodePminsd:
		return "pminsd"
	case sseOpcodePminub:
		return "pminub"
	case sseOpcodePminuw:
		return "pminuw"
	case sseOpcodePminud:
		return "pminud"
	case sseOpcodePmovmskb:
		return "pmovmskb"
	case sseOpcodePmovsxbd:
		return "pmovsxbd"
	case sseOpcodePmovsxbw:
		return "pmovsxbw"
	case sseOpcodePmovsxbq:
		return "pmovsxbq"
	case sseOpcodePmovsxwd:
		return "pmovsxwd"
	case sseOpcodePmovsxwq:
		return "pmovsxwq"
	case sseOpcodePmovsxdq:
		return "pmovsxdq"
	case sseOpcodePmovzxbd:
		return "pmovzxbd"
	case sseOpcodePmovzxbw:
		return "pmovzxbw"
	case sseOpcodePmovzxbq:
		return "pmovzxbq"
	case sseOpcodePmovzxwd:
		return "pmovzxwd"
	case sseOpcodePmovzxwq:
		return "pmovzxwq"
	case sseOpcodePmovzxdq:
		return "pmovzxdq"
	case sseOpcodePmulld:
		return "pmulld"
	case sseOpcodePmullw:
		return "pmullw"
	case sseOpcodePmuludq:
		return "pmuludq"
	case sseOpcodePor:
		return "por"
	case sseOpcodePshufb:
		return "pshufb"
	case sseOpcodePshufd:
		return "pshufd"
	case sseOpcodePsllw:
		return "psllw"
	case sseOpcodePslld:
		return "pslld"
	case sseOpcodePsllq:
		return "psllq"
	case sseOpcodePsraw:
		return "psraw"
	case sseOpcodePsrad:
		return "psrad"
	case sseOpcodePsrlw:
		return "psrlw"
	case sseOpcodePsrld:
		return "psrld"
	case sseOpcodePsrlq:
		return "psrlq"
	case sseOpcodePsubb:
		return "psubb"
	case sseOpcodePsubd:
		return "psubd"
	case sseOpcodePsubq:
		return "psubq"
	case sseOpcodePsubw:
		return "psubw"
	case sseOpcodePsubsb:
		return "psubsb"
	case sseOpcodePsubsw:
		return "psubsw"
	case sseOpcodePsubusb:
		return "psubusb"
	case sseOpcodePsubusw:
		return "psubusw"
	case sseOpcodePtest:
		return "ptest"
	case sseOpcodePunpckhbw:
		return "punpckhbw"
	case sseOpcodePunpcklbw:
		return "punpcklbw"
	case sseOpcodePxor:
		return "pxor"
	case sseOpcodeRcpss:
		return "rcpss"
	case sseOpcodeRoundps:
		return "roundps"
	case sseOpcodeRoundpd:
		return "roundpd"
	case sseOpcodeRoundss:
		return "roundss"
	case sseOpcodeRoundsd:
		return "roundsd"
	case sseOpcodeRsqrtss:
		return "rsqrtss"
	case sseOpcodeSqrtps:
		return "sqrtps"
	case sseOpcodeSqrtpd:
		return "sqrtpd"
	case sseOpcodeSqrtss:
		return "sqrtss"
	case sseOpcodeSqrtsd:
		return "sqrtsd"
	case sseOpcodeSubps:
		return "subps"
	case sseOpcodeSubpd:
		return "subpd"
	case sseOpcodeSubss:
		return "subss"
	case sseOpcodeSubsd:
		return "subsd"
	case sseOpcodeUcomiss:
		return "ucomiss"
	case sseOpcodeUcomisd:
		return "ucomisd"
	case sseOpcodeXorps:
		return "xorps"
	case sseOpcodeXorpd:
		return "xorpd"
	case sseOpcodePmulhrsw:
		return "pmulhrsw"
	case sseOpcodeUnpcklps:
		return "unpcklps"
	case sseOpcodeCvtps2pd:
		return "cvtps2pd"
	case sseOpcodeCvtpd2ps:
		return "cvtpd2ps"
	case sseOpcodeCvttpd2dq:
		return "cvttpd2dq"
	case sseOpcodeShufps:
		return "shufps"
	case sseOpcodePmaddubsw:
		return "pmaddubsw"
	default:
		panic("BUG")
	}
}

type roundingMode uint8

const (
	roundingModeNearest roundingMode = iota
	roundingModeDown
	roundingModeUp
	roundingModeZero
)

func ( roundingMode) () string {
	switch  {
	case roundingModeNearest:
		return "nearest"
	case roundingModeDown:
		return "down"
	case roundingModeUp:
		return "up"
	case roundingModeZero:
		return "zero"
	default:
		panic("BUG")
	}
}

// cmpPred is the immediate value for a comparison operation in xmmRmRImm.
type cmpPred uint8

const (
	// cmpPredEQ_OQ is Equal (ordered, non-signaling)
	cmpPredEQ_OQ cmpPred = iota
	// cmpPredLT_OS is Less-than (ordered, signaling)
	cmpPredLT_OS
	// cmpPredLE_OS is Less-than-or-equal (ordered, signaling)
	cmpPredLE_OS
	// cmpPredUNORD_Q is Unordered (non-signaling)
	cmpPredUNORD_Q
	// cmpPredNEQ_UQ is Not-equal (unordered, non-signaling)
	cmpPredNEQ_UQ
	// cmpPredNLT_US is Not-less-than (unordered, signaling)
	cmpPredNLT_US
	// cmpPredNLE_US is Not-less-than-or-equal (unordered, signaling)
	cmpPredNLE_US
	// cmpPredORD_Q is Ordered (non-signaling)
	cmpPredORD_Q
	// cmpPredEQ_UQ is Equal (unordered, non-signaling)
	cmpPredEQ_UQ
	// cmpPredNGE_US is Not-greater-than-or-equal (unordered, signaling)
	cmpPredNGE_US
	// cmpPredNGT_US is Not-greater-than (unordered, signaling)
	cmpPredNGT_US
	// cmpPredFALSE_OQ is False (ordered, non-signaling)
	cmpPredFALSE_OQ
	// cmpPredNEQ_OQ is Not-equal (ordered, non-signaling)
	cmpPredNEQ_OQ
	// cmpPredGE_OS is Greater-than-or-equal (ordered, signaling)
	cmpPredGE_OS
	// cmpPredGT_OS is Greater-than (ordered, signaling)
	cmpPredGT_OS
	// cmpPredTRUE_UQ is True (unordered, non-signaling)
	cmpPredTRUE_UQ
	// Equal (ordered, signaling)
	cmpPredEQ_OS
	// Less-than (ordered, nonsignaling)
	cmpPredLT_OQ
	// Less-than-or-equal (ordered, nonsignaling)
	cmpPredLE_OQ
	// Unordered (signaling)
	cmpPredUNORD_S
	// Not-equal (unordered, signaling)
	cmpPredNEQ_US
	// Not-less-than (unordered, nonsignaling)
	cmpPredNLT_UQ
	// Not-less-than-or-equal (unordered, nonsignaling)
	cmpPredNLE_UQ
	// Ordered (signaling)
	cmpPredORD_S
	// Equal (unordered, signaling)
	cmpPredEQ_US
	// Not-greater-than-or-equal (unordered, non-signaling)
	cmpPredNGE_UQ
	// Not-greater-than (unordered, nonsignaling)
	cmpPredNGT_UQ
	// False (ordered, signaling)
	cmpPredFALSE_OS
	// Not-equal (ordered, signaling)
	cmpPredNEQ_OS
	// Greater-than-or-equal (ordered, nonsignaling)
	cmpPredGE_OQ
	// Greater-than (ordered, nonsignaling)
	cmpPredGT_OQ
	// True (unordered, signaling)
	cmpPredTRUE_US
)

func ( cmpPred) () string {
	switch  {
	case cmpPredEQ_OQ:
		return "eq_oq"
	case cmpPredLT_OS:
		return "lt_os"
	case cmpPredLE_OS:
		return "le_os"
	case cmpPredUNORD_Q:
		return "unord_q"
	case cmpPredNEQ_UQ:
		return "neq_uq"
	case cmpPredNLT_US:
		return "nlt_us"
	case cmpPredNLE_US:
		return "nle_us"
	case cmpPredORD_Q:
		return "ord_q"
	case cmpPredEQ_UQ:
		return "eq_uq"
	case cmpPredNGE_US:
		return "nge_us"
	case cmpPredNGT_US:
		return "ngt_us"
	case cmpPredFALSE_OQ:
		return "false_oq"
	case cmpPredNEQ_OQ:
		return "neq_oq"
	case cmpPredGE_OS:
		return "ge_os"
	case cmpPredGT_OS:
		return "gt_os"
	case cmpPredTRUE_UQ:
		return "true_uq"
	case cmpPredEQ_OS:
		return "eq_os"
	case cmpPredLT_OQ:
		return "lt_oq"
	case cmpPredLE_OQ:
		return "le_oq"
	case cmpPredUNORD_S:
		return "unord_s"
	case cmpPredNEQ_US:
		return "neq_us"
	case cmpPredNLT_UQ:
		return "nlt_uq"
	case cmpPredNLE_UQ:
		return "nle_uq"
	case cmpPredORD_S:
		return "ord_s"
	case cmpPredEQ_US:
		return "eq_us"
	case cmpPredNGE_UQ:
		return "nge_uq"
	case cmpPredNGT_UQ:
		return "ngt_uq"
	case cmpPredFALSE_OS:
		return "false_os"
	case cmpPredNEQ_OS:
		return "neq_os"
	case cmpPredGE_OQ:
		return "ge_oq"
	case cmpPredGT_OQ:
		return "gt_oq"
	case cmpPredTRUE_US:
		return "true_us"
	default:
		panic("BUG")
	}
}

func linkInstr(,  *instruction) *instruction {
	.next = 
	.prev = 
	return 
}

type defKind byte

const (
	defKindNone defKind = iota + 1
	defKindOp2
	defKindCall
	defKindDivRem
)

var defKinds = [instrMax]defKind{
	nop0:                   defKindNone,
	ret:                    defKindNone,
	movRR:                  defKindOp2,
	movRM:                  defKindNone,
	xmmMovRM:               defKindNone,
	aluRmiR:                defKindNone,
	shiftR:                 defKindNone,
	imm:                    defKindOp2,
	unaryRmR:               defKindOp2,
	xmmRmiReg:              defKindNone,
	xmmUnaryRmR:            defKindOp2,
	xmmUnaryRmRImm:         defKindOp2,
	xmmCmpRmR:              defKindNone,
	xmmRmR:                 defKindNone,
	xmmRmRImm:              defKindNone,
	mov64MR:                defKindOp2,
	movsxRmR:               defKindOp2,
	movzxRmR:               defKindOp2,
	gprToXmm:               defKindOp2,
	xmmToGpr:               defKindOp2,
	cmove:                  defKindNone,
	call:                   defKindCall,
	callIndirect:           defKindCall,
	ud2:                    defKindNone,
	jmp:                    defKindNone,
	jmpIf:                  defKindNone,
	jmpTableIsland:         defKindNone,
	cmpRmiR:                defKindNone,
	exitSequence:           defKindNone,
	lea:                    defKindOp2,
	setcc:                  defKindOp2,
	zeros:                  defKindOp2,
	sourceOffsetInfo:       defKindNone,
	fcvtToSintSequence:     defKindNone,
	defineUninitializedReg: defKindOp2,
	fcvtToUintSequence:     defKindNone,
	xmmCMov:                defKindOp2,
	idivRemSequence:        defKindDivRem,
	blendvpd:               defKindNone,
	mfence:                 defKindNone,
	xchg:                   defKindNone,
	lockcmpxchg:            defKindNone,
	lockxadd:               defKindNone,
	neg:                    defKindNone,
	nopUseReg:              defKindNone,
}

// String implements fmt.Stringer.
func ( defKind) () string {
	switch  {
	case defKindNone:
		return "none"
	case defKindOp2:
		return "op2"
	case defKindCall:
		return "call"
	case defKindDivRem:
		return "divrem"
	default:
		return "invalid"
	}
}

type useKind byte

const (
	useKindNone useKind = iota + 1
	useKindOp1
	// useKindOp1Op2Reg is Op1 can be any operand, Op2 must be a register.
	useKindOp1Op2Reg
	// useKindOp1RegOp2 is Op1 must be a register, Op2 can be any operand.
	useKindOp1RegOp2
	// useKindRaxOp1RegOp2 is Op1 must be a register, Op2 can be any operand, and RAX is used.
	useKindRaxOp1RegOp2
	useKindDivRem
	useKindBlendvpd
	useKindCall
	useKindCallInd
	useKindFcvtToSintSequence
	useKindFcvtToUintSequence
)

var useKinds = [instrMax]useKind{
	nop0:                   useKindNone,
	ret:                    useKindNone,
	movRR:                  useKindOp1,
	movRM:                  useKindOp1RegOp2,
	xmmMovRM:               useKindOp1RegOp2,
	cmove:                  useKindOp1Op2Reg,
	aluRmiR:                useKindOp1Op2Reg,
	shiftR:                 useKindOp1Op2Reg,
	imm:                    useKindNone,
	unaryRmR:               useKindOp1,
	xmmRmiReg:              useKindOp1Op2Reg,
	xmmUnaryRmR:            useKindOp1,
	xmmUnaryRmRImm:         useKindOp1,
	xmmCmpRmR:              useKindOp1Op2Reg,
	xmmRmR:                 useKindOp1Op2Reg,
	xmmRmRImm:              useKindOp1Op2Reg,
	mov64MR:                useKindOp1,
	movzxRmR:               useKindOp1,
	movsxRmR:               useKindOp1,
	gprToXmm:               useKindOp1,
	xmmToGpr:               useKindOp1,
	call:                   useKindCall,
	callIndirect:           useKindCallInd,
	ud2:                    useKindNone,
	jmpIf:                  useKindOp1,
	jmp:                    useKindOp1,
	cmpRmiR:                useKindOp1Op2Reg,
	exitSequence:           useKindOp1,
	lea:                    useKindOp1,
	jmpTableIsland:         useKindNone,
	setcc:                  useKindNone,
	zeros:                  useKindNone,
	sourceOffsetInfo:       useKindNone,
	fcvtToSintSequence:     useKindFcvtToSintSequence,
	defineUninitializedReg: useKindNone,
	fcvtToUintSequence:     useKindFcvtToUintSequence,
	xmmCMov:                useKindOp1,
	idivRemSequence:        useKindDivRem,
	blendvpd:               useKindBlendvpd,
	mfence:                 useKindNone,
	xchg:                   useKindOp1RegOp2,
	lockcmpxchg:            useKindRaxOp1RegOp2,
	lockxadd:               useKindOp1RegOp2,
	neg:                    useKindOp1,
	nopUseReg:              useKindOp1,
}

func ( useKind) () string {
	switch  {
	case useKindNone:
		return "none"
	case useKindOp1:
		return "op1"
	case useKindOp1Op2Reg:
		return "op1op2Reg"
	case useKindOp1RegOp2:
		return "op1RegOp2"
	case useKindCall:
		return "call"
	case useKindCallInd:
		return "callInd"
	default:
		return "invalid"
	}
}